KeAllocateCalloutStackEx
INT64 __fastcall KeAllocateCalloutStackEx(INT64 a1, UINT8 a2, INT64 a3, CHAR **a4){
unsigned int v4;
unsigned __int8 v5;
_DWORD *PoolWithTag;
unsigned int v7;
__int64 *v8;
__int64 KernelStack;
v4 = a2;
if( (_DWORD)a1 )
{
if( (_DWORD)a1 != 1 )
return 3221225711i64;
v5 = 1;
}
else
{
v5 = 0;
}
if( !a2 )
return 3221225712i64;
if( a3 )
return 3221225713i64;
PoolWithTag = ExAllocatePoolWithTag(NonPagedPoolNx, 8i64 * a2 + 64, 0x6353654Bui64);
if( !PoolWithTag )
return 3221225495i64;
v7 = 0;
if( (_BYTE)v4 )
{
v8 = (__int64 *)(PoolWithTag + 16);
while( 1 )
{
KernelStack = MmCreateKernelStack(v5 != 0 ? 5 : 0, 0, 0i64);
if( !KernelStack )
break;
*v8 = KernelStack;
++v7;
++v8;
if( v7 >= v4 )
goto LABEL_10;
}
while( v7 )
MmDeleteKernelStack(*(PVOID *)&PoolWithTag[2 * --v7 + 16], v5);
ExFreePoolWithTag(PoolWithTag, 0);
return 3221225626i64;
}
else
{
LABEL_10:
*PoolWithTag = 1801548883;
*((_BYTE *)PoolWithTag + 4) = v5;
*((_BYTE *)PoolWithTag + 5) = v4;
*((_BYTE *)PoolWithTag + 6) = 0;
KeInitializeMutex((_KMUTANT *)(PoolWithTag + 2), 0i64);
*a4 = (CHAR *)PoolWithTag;
return 0i64;
}
}Referenced by:
KeAllocateCalloutStack