MiZeroInParallel
VOID __fastcall MiZeroInParallel(INT64 a1){
unsigned int v1;
unsigned int v2;
__int64 v3;
_ETHREAD *CurrentThread;
unsigned int v5;
__int128 v6;
unsigned __int64 v7;
__int64 v8;
__int64 v9;
unsigned __int8 v10;
unsigned __int64 v11;
KPRIORITY v12;
int v13;
__int128 v14;
__int64 v15;
__int64 Context[2];
_KGATE Gate;
void *ThreadHandle;
ThreadHandle = 0i64;
v1 = 0;
Context[0] = 0i64;
v2 = *(_DWORD *)(a1 + 16);
v3 = *(_QWORD *)a1;
Gate.Header.Reserved1 = 0;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
v5 = dword_140C4DC24;
v6 = *(_OWORD *)(a1 + 32);
v15 = *((_QWORD *)&v6 + 1);
if( v2 )
{
v7 = v6;
v8 = v2;
do
{
if( *(_QWORD *)(v3 + 32) == v3 + 32 )
{
*(_DWORD *)v3 = 1;
}
else
{
*(_DWORD *)v3 = 0;
++v1;
if( v7 )
{
v9 = 0i64;
*((_QWORD *)&v14 + 1) = *((_QWORD *)&v6 + 1);
v10 = 0;
*(_QWORD *)&v14 = 0i64;
if( v5 )
{
do
{
_BitScanForward64(&v11, v7);
v9 |= 1i64 << v11;
v7 &= ~v9;
if( !v7 )
break;
++v10;
}
while( v10 < v5 );
*((_QWORD *)&v6 + 1) = v15;
*(_QWORD *)&v14 = v9;
}
*(_OWORD *)(v3 + 8) = v14;
}
else
{
*(_QWORD *)(v3 + 8) = 0i64;
}
}
v3 += 48i64;
--v8;
}
while( v8 );
}
if( v1 == 1
|| (*(_DWORD *)(a1 + 8) & 4) != 0
|| (*((_DWORD *)CurrentThread + 29) & 0x400) != 0
|| KeGetCurrentIrql() == 2
|| (MiFlags & 0x30) == 0 )
{
v1 = 0;
}
Gate.Header.SignalState = 0;
Gate.Header.WaitListHead.Blink = &Gate.Header.WaitListHead;
Gate.Header.WaitListHead.Flink = &Gate.Header.WaitListHead;
Context[1] = a1;
LOWORD(Gate.Header.Lock) = 263;
Gate.Header.Size = 6;
HIDWORD(Context[0]) = v1;
if( v1 )
v12 = KeSetPriorityThread((PKTHREAD)CurrentThread, 15);
else
v12 = -1;
v13 = 0;
LODWORD(Context[0]) = v12;
if( v1 )
{
while( PsCreateSystemThread(&ThreadHandle, 0x1FFFFFu, 0i64, 0i64, 0i64, MiZeroInParallelWorker, Context) >= 0 )
{
ObCloseHandle(ThreadHandle, 0);
if( ++v13 >= v1 )
goto LABEL_28;
}
v1 -= v13;
if( _InterlockedExchangeAdd((volatile signed __int32 *)Context + 1, -v1) == v1 )
KeSignalGate(&Gate, 1i64);
LABEL_28:
if( v1 )
KeSetPriorityThread((PKTHREAD)CurrentThread, v12);
}
if( v13 )
KeWaitForGate(&Gate, 0);
else
MiZeroInParallelWorker(Context);
}Referenced by:
MiAllocateLargeZeroPages
MiFindLargePageMemory
MiInitializeMdlOneNodeBatchPages