HalpBuildResumeStructures

NTSTATUS __stdcall HalpBuildResumeStructures(){
  unsigned int ActiveProcessorCount; 
  _HALP_ALLOC_CONTEXT *v1; 
  UINT8 *v2; 
  _HALP_ALLOC_CONTEXT *v3; 
  __int64 v4; 
  _HALP_ALLOC_CONTEXT *v5; 
  UINT8 *v6; 
  _KPROCESSOR_STATE *v7; 
  __int64 v8; 
  __int64 v10; 
  __int64 v11; 

  ActiveProcessorCount = KeQueryActiveProcessorCountEx(0xFFFFu);
  v2 = HalpMmAllocCtxAlloc(v1, 1472i64 * ActiveProcessorCount);
  Memory = v2;
  if( v2 )
  {
    memset(v2, 0i64, 1472 * ActiveProcessorCount);
    v4 = 8i64 * ActiveProcessorCount;
    v6 = HalpMmAllocCtxAlloc(v5, v4);
    qword_140C49D10 = v6;
    if( v6 )
    {
      memset(v6, 0i64, v4);
      v8 = 0i64;
      if( !ActiveProcessorCount )
        return 0;
      while( HalpMmBuildTiledMemoryMap((_TILED_MEMORY_MAP *)((char *)qword_140C49D10 + 8 * v8), v7) >= 0 )
      {
        v8 = (unsigned int)(v8 + 1);
        if( (unsigned int)v8 >= ActiveProcessorCount )
          return 0;
      }
    }
    if( Memory )
    {
      HalpMmAllocCtxFree(v3, Memory);
      Memory = 0i64;
    }
  }
  if( qword_140C49D10 )
  {
    v10 = 0i64;
    if( ActiveProcessorCount )
    {
      v11 = 0i64;
      do
      {
        v3 = (_HALP_ALLOC_CONTEXT *)qword_140C49D10;
        if( *(_DWORD *)((char *)qword_140C49D10 + v11 + 4) )
          HalpMmFreeTiledMemoryMap((UINT64 *)qword_140C49D10 + v10);
        v10 = (unsigned int)(v10 + 1);
        v11 += 8i64;
      }
      while( (unsigned int)v10 < ActiveProcessorCount );
    }
    HalpMmAllocCtxFree(v3, qword_140C49D10);
    qword_140C49D10 = 0i64;
  }
  return -1073741670;
}

Referenced by:

HalpDispatchSystemStateTransition
HalpDpReplaceBegin