HalpBuildResumeStructures

INT64 __fastcall HalpBuildResumeStructures(){
  unsigned int ActiveProcessorCount; 
  __int64 v1; 
  __int64 v2; 
  __int64 v3; 
  __int64 v4; 
  __int64 v5; 
  __int64 v6; 
  __int64 v7; 
  __int64 v9; 
  __int64 v10; 
  ActiveProcessorCount = KeQueryActiveProcessorCountEx(0xFFFFu);
  v2 = HalpMmAllocCtxAlloc(v1, 1472i64 * ActiveProcessorCount);
  HalpHiberProcState = v2;
  if( v2 )
  {
    memset(v2, 0i64);
    v5 = HalpMmAllocCtxAlloc(v4, 8i64 * ActiveProcessorCount);
    HalpTiledCr3Addresses = v5;
    if( v5 )
    {
      memset(v5, 0i64);
      v7 = 0i64;
      if( !ActiveProcessorCount )
        return 0i64;
      while( (int)HalpMmBuildTiledMemoryMap((unsigned int *)(HalpTiledCr3Addresses + 8 * v7), v6, v7) >= 0 )
      {
        v7 = (unsigned int)(v7 + 1);
        if( (unsigned int)v7 >= ActiveProcessorCount )
          return 0i64;
      }
    }
    if( HalpHiberProcState )
    {
      HalpMmAllocCtxFree(v3, HalpHiberProcState);
      HalpHiberProcState = 0i64;
    }
  }
  if( HalpTiledCr3Addresses )
  {
    v9 = 0i64;
    if( ActiveProcessorCount )
    {
      v10 = 0i64;
      do
      {
        v3 = HalpTiledCr3Addresses;
        if( *(_DWORD *)(v10 + HalpTiledCr3Addresses + 4) )
          HalpMmFreeTiledMemoryMap((UINT64 *)(HalpTiledCr3Addresses + 8 * v9));
        v9 = (unsigned int)(v9 + 1);
        v10 += 8i64;
      }
      while( (unsigned int)v9 < ActiveProcessorCount );
    }
    HalpMmAllocCtxFree(v3, HalpTiledCr3Addresses);
    HalpTiledCr3Addresses = 0i64;
  }
  return 3221225626i64;
}

Referenced by:

HalpDispatchSystemStateTransition
HalpDpReplaceBegin