ExpPartitionCreatePool

NTSTATUS __stdcall ExpPartitionCreatePool(INT64 a1, INT64 a2, INT64 a3, UINT64 *a4){
  bool v6; 
  unsigned int v7; 
  unsigned int v8; 
  _KNODE *ParentNode; 
  NTSTATUS result; 
  unsigned __int16 v11; 
  INT64 v12; 
  __int64 v13; 
  signed int v14; 

  do
  {
    v6 = !_BitScanForward(&v7, *(_DWORD *)(a1 + 24));
    v14 = v7;
    if( v6 )
      return -1073741801;
  }
  while( !_interlockedbittestandreset((volatile signed __int32 *)(a1 + 24), v7) );
  v8 = v7;
  LODWORD(v12) = v7;
  ParentNode = KeGetCurrentPrcb()->ParentNode;
  if( (_UNKNOWN *)KeNodeBlock[ParentNode->Affinity.Reserved[0]] == (_UNKNOWN *)((char *)&KiNodeInit
                                                                               + 384 * ParentNode->Affinity.Reserved[0]) )
    ParentNode = 0i64;
  result = ExpPartitionCreatePoolInternal(a1, 1i64, 16i64, (INT64)ParentNode, v12);
  if( result >= 0 )
  {
    v11 = 0;
    if( KeNumberNodes )
    {
      v13 = (2 * (ParentNode->Affinity.Reserved[0] & 0x7Fu)) | 1i64;
      do
      {
        if( v11 != ParentNode->Affinity.Reserved[0] )
        {
          v8 = v14;
          *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8i64 * v11) + 8i64 * v14) = v13;
          KeSetEvent((PRKEVENT)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8i64 * v11) + 16i64), 0, 0);
        }
        ++v11;
      }
      while( v11 < (unsigned __int16)KeNumberNodes );
    }
    *(_DWORD *)a4 = v8;
    result = 0;
    v8 = 8;
  }
  if( v8 != 8 )
    _interlockedbittestandset((volatile signed __int32 *)(a1 + 24), v8);
  return result;
}

Referenced by:

ExAllocatePrivateWorkerPool