ExpQueryNumaAvailableMemory

NTSTATUS __stdcall ExpQueryNumaAvailableMemory(
        VOID *SystemInformation,
        UINT64 SystemInformationLength,
        UINT64 *ReturnedLength){
  unsigned int v4; 
  _DWORD *v5; 
  unsigned __int16 ProcessPartitionId; 
  NTSTATUS result; 
  unsigned int v8; 
  unsigned int v9; 
  __int64 i; 
  __int64 v11; 
  __int64 j; 
  __int64 v13; 
  UINT64 v14; 
  PVOID P; 
  __int64 v16; 
  UINT64 v17; 

  P = 0i64;
  v14 = 0i64;
  ProcessPartitionId = MmGetProcessPartitionId((INT64)KeGetCurrentThread()->ApcState.Process);
  if( v4 >= 4 )
  {
    v8 = (unsigned __int16)KeNumberNodes;
    v9 = (unsigned __int16)KeNumberNodes;
    *(_DWORD *)SystemInformation = (unsigned __int16)KeNumberNodes - 1;
    if( (v4 - 8) >> 3 <= v8 )
      v9 = (v4 - 8) >> 3;
    if( v4 >= 8 && v9 )
    {
      *v5 = 8 * v9 + 8;
      if( (unsigned __int16)v8 <= 1u )
      {
        LODWORD(v13) = MmGetAvailablePages(ProcessPartitionId);
        *((_QWORD *)SystemInformation + 1) = v13 << 12;
      }
      else
      {
        for( i = 0i64; (unsigned int)i < v9; i = (unsigned int)(i + 1) )
        {
          result = MmGetChannelInformation(ProcessPartitionId, (unsigned int)i, &P, &v14);
          if( result < 0 )
            return result;
          v11 = 0i64;
          v16 = 0i64;
          v17 = v14 / 0x28;
          for( j = 0i64; (unsigned int)j < v14 / 0x28; j = (unsigned int)(j + 1) )
          {
            v11 += *((_QWORD *)P + 5 * j + 2) + *((_QWORD *)P + 5 * j + 3);
            v16 = v11;
          }
          ExFreePoolWithTag(P, 0);
          *((_QWORD *)SystemInformation + i + 1) = v11 << 12;
        }
      }
      return 0;
    }
    else
    {
      *v5 = 4;
      return 0;
    }
  }
  else
  {
    if( v5 )
      *v5 = 4;
    return -1073741820;
  }
}

Referenced by:

ExpQuerySystemInformation