ExAllocateCacheAwarePushLock

NTSTATUS __fastcall ExAllocateCacheAwarePushLock(CHAR a1){
  char v1; 
  int v2; 
  int v3; 
  VOID *PoolWithTag; 
  ULONG_PTR v5; 
  char *v6; 
  char *v7; 
  _QWORD *v8; 
  __int64 v9; 
  NTSTATUS v10; 
  unsigned int v12; 
  unsigned int v13; 
  struct _KPRCB *CurrentPrcb; 
  USHORT v15; 
  _QWORD *PoolWithTagFromNode; 
  _QWORD *v17; 
  INT64 v18; 
  unsigned int v19; 
  _QWORD *v20; 
  struct _GROUP_AFFINITY Affinity; 
  struct _GROUP_AFFINITY PreviousAffinity; 
  v1 = 0;
  v2 = a1 & 1;
  Affinity = 0i64;
  v3 = v2 != 0 ? 512 : 1;
  PreviousAffinity = 0i64;
  PoolWithTag = ExAllocatePoolWithTag((_POOL_TYPE)v3, 0x100ui64, 0x70636C50ui64);
  v5 = (ULONG_PTR)PoolWithTag;
  if( !PoolWithTag )
    return 0;
  memset((INT64)PoolWithTag, 0i64);
  if( KeNumberNodes == 1 )
  {
    v6 = (char *)ExAllocatePoolWithTag((_POOL_TYPE)v3, 0x1000ui64, 0x6C636C50ui64);
    v7 = v6;
    if( v6 )
    {
      memset((INT64)v6, 0i64);
      v8 = (_QWORD *)v5;
      v9 = 32i64;
      do
      {
        *(_QWORD *)v7 = 0i64;
        v7[8] = 1;
        *((_QWORD *)v7 + 2) = v5;
        *v8 = v7;
        v7 += 128;
        ++v8;
        --v9;
      }
      while( v9 );
      return v5;
    }
    v10 = 0;
  }
  else
  {
    v12 = KeNumberProcessors_0;
    v13 = 0;
    v19 = KeNumberProcessors_0;
    v20 = (_QWORD *)v5;
    while( 1 )
    {
      if( v13 >= v12 )
        CurrentPrcb = KeGetCurrentPrcb();
      else
        KeGetPrcb(v13);
      v15 = *(_WORD *)(*((_QWORD *)CurrentPrcb + 24) + 146i64);
      if( v2 )
      {
        LODWORD(v18) = 0;
        PoolWithTagFromNode = ExpAllocatePoolWithTagFromNode(0x200ui64, 0x80ui64, 0x6C636C50ui64, v15, v18);
      }
      else
      {
        KeQueryNodeActiveAffinity(v15, &Affinity, 0i64);
        if( v1 )
        {
          KeSetSystemGroupAffinityThread(&Affinity, 0i64);
        }
        else
        {
          KeSetSystemGroupAffinityThread(&Affinity, &PreviousAffinity);
          v1 = 1;
        }
        PoolWithTagFromNode = ExAllocatePoolWithTag((_POOL_TYPE)v3, 0x80ui64, 0x6C636C50ui64);
      }
      v17 = PoolWithTagFromNode;
      if( !PoolWithTagFromNode )
        break;
      memset((INT64)PoolWithTagFromNode, 0i64);
      ++v13;
      v17[2] = v5;
      *v20++ = v17;
      if( v13 >= 0x20 )
      {
        v10 = v5;
        v5 = 0i64;
        goto LABEL_25;
      }
      v12 = v19;
    }
    v10 = 0;
LABEL_25:
    if( v1 )
      KeRevertToUserGroupAffinityThread(&PreviousAffinity);
  }
  if( v5 )
    ExFreeCacheAwarePushLock(v5);
  return v10;
}

Referenced by:

No references.