HvpBuildMapForMemoryBackedHive

NTSTATUS __stdcall HvpBuildMapForMemoryBackedHive(ULONG_PTR BugCheckParameter2){
  __int64 v1; 
  int v2; 
  _HIVE_LOAD_FAILURE *v3; 
  int v4; 
  _HHIVE *v5; 
  char v6; 
  NTSTATUS inited; 
  unsigned int v8; 
  unsigned int Length; 
  _HBIN *v10; 
  int v11; 
  INT64 v13; 
  UINT64 Point; 
  __int64 v15; 

  v15 = v1;
  v3 = *(_HIVE_LOAD_FAILURE **)(*(_QWORD *)&BugCheckParameter2 + 56i64);
  v4 = v2;
  v5 = *(_HHIVE **)&BugCheckParameter2;
  v6 = 0;
  inited = HvpInitMap(*(_HHIVE **)&BugCheckParameter2, v1);
  if( inited < 0 )
    return inited;
  v8 = 0;
  Length = v5->BaseBlock->Length;
  if( !Length )
    return 0;
  inited = 1073741833;
  do
  {
    v10 = (_HBIN *)(v15 + v8);
    if( !HvpValidateLoadedBin(v10, v8, Length) )
    {
      if( (v4 & 0x20000) != 0 || !BYTE3(NlsMbCodePageTag) && (*(&CmpDummyThreadEvent + 2744) & 6) == 0 )
      {
        LODWORD(Point) = 0;
        v13 = 3221225804i64;
        inited = -1073741492;
        goto LABEL_20;
      }
      LODWORD(Point) = 0;
      v10->Signature = 1852400232;
      v10->FileOffset = v8;
      v10->Size = 4096;
      v6 = 1;
      v5->BaseBlock->BootType |= 4u;
      SetFailureLocation(v3, 1ui64, _HvpBuildMapForLoaderHive, 1073741833i64, Point);
    }
    if( !CmpClaimGlobalQuota(v10->Size) )
    {
      inited = -1073741670;
      LODWORD(Point) = 16;
      v13 = 3221225626i64;
LABEL_20:
      SetFailureLocation(v3, 0i64, _HvpBuildMapForLoaderHive, v13, Point);
      v3->CheckHive.Space = Length;
      v3->CheckHive.MapPoint = v8;
      goto LABEL_22;
    }
    HvpPointMapEntriesToBuffer(v5, (UINT64)v10, v10->Size, v8, 0, 0i64);
    if( (v5->_bf_8c & 2) != 0 )
      goto LABEL_9;
    LOBYTE(v11) = HvpEnlistFreeCells(v5, v10, v8);
    if( v11 != 1073741833 )
    {
      if( v11 >= 0 )
        goto LABEL_9;
      LODWORD(Point) = 32;
      inited = -1073741492;
      SetFailureLocation(v3, 0i64, _HvpBuildMapForLoaderHive, 3221225804i64, Point);
      v3->CheckHive.Space = v10->Size;
      v3->CheckHive.MapPoint = v10->FileOffset;
LABEL_22:
      v3->CheckHive.BinPoint = v10;
      return inited;
    }
    v6 = 1;
LABEL_9:
    v8 += v10->Size;
  }
  while( v8 < Length );
  if( v6 )
    return inited;
  return 0;
}

Referenced by:

HvHiveStartMemoryBacked