HvHiveStartMemoryBacked
__int64 __fastcall HvHiveStartMemoryBacked(
_HHIVE *BugCheckParameter2,
__int64 a2,
unsigned int a3,
unsigned int a4,
_HBASE_BLOCK *BaseBlock,
__int64 a6,
int a7,
_UNICODE_STRING *FileName,
__int64 a9,
__int64 a10,
__int64 a11,
__int64 a12,
_HIVE_LOAD_FAILURE *HiveLoadFailure){
__int64 v15;
__int64 v16;
_DWORD *v17;
unsigned int v18;
unsigned int v19;
__int64 v21;
char v22;
int v23;
_HBASE_BLOCK *v24;
_HBASE_BLOCK *v25;
_HBASE_BLOCK *v26;
_GUID RmId;
unsigned int v28;
NTSTATUS v29;
_HBASE_BLOCK *v30;
unsigned int v31;
unsigned int Major;
unsigned int v33;
__int64 v34;
unsigned int v35;
unsigned int v36;
unsigned int v37;
unsigned int Minor;
unsigned int Sequence1;
__int64 v40;
_HBASE_BLOCK *v41;
UINT64 Point;
BugCheckParameter2->HiveLoadFailure = HiveLoadFailure;
if( (_DWORD)a2 == 2
|| (unsigned int)a2 >= 5
|| (a3 & 0xFF617CEC) != 0
|| a4 > 2
|| (unsigned int)(a7 - 1) > 7
|| !BaseBlock && (((_DWORD)a2 - 1) & 0xFFFFFFFC) == 0 )
{
__fastfail(5u);
}
if( a11 )
*(_BYTE *)a11 = 0;
if( a6 )
{
BugCheckParameter2->Allocate = *(void *(__fastcall **)(unsigned int, unsigned __int8, unsigned int))a6;
BugCheckParameter2->Free = *(void(__fastcall **)(void *, unsigned int))(a6 + 8);
BugCheckParameter2->FileWrite = *(int(__fastcall **)(_HHIVE *, unsigned int, CMP_OFFSET_ARRAY *, unsigned int, unsigned int))(a6 + 24);
BugCheckParameter2->FileRead = *(int(__fastcall **)(_HHIVE *, unsigned int, unsigned int, void *, unsigned int))(a6 + 32);
}
v15 = 4i64;
if( a4 )
{
v31 = 4;
if( a4 == 1 )
v31 = 1;
BugCheckParameter2->CurrentLog = v31;
}
else
{
BugCheckParameter2->CurrentLog = 0;
}
BugCheckParameter2->HiveFlags = a3;
BugCheckParameter2->GetCellRoutine = (_CELL_DATA *(__fastcall *)(_HHIVE *, unsigned int, _HV_GET_CELL_CONTEXT *))HvpGetCellPaged;
BugCheckParameter2->Cluster = a7;
BugCheckParameter2->StorageTypeCount = 2;
BugCheckParameter2->ReleaseCellRoutine = (void(__fastcall *)(_HHIVE *, _HV_GET_CELL_CONTEXT *))HvpReleaseCellPaged;
BugCheckParameter2->BaseBlockAlloc = 4096;
v16 = *(_QWORD *)&KUSER_SHARED_DATA.SystemTime.LowPart;
BugCheckParameter2->LastLogSwapTime.QuadPart = *(_QWORD *)&KUSER_SHARED_DATA.SystemTime.LowPart;
BugCheckParameter2->PrimaryFileValid = 1;
switch( (_DWORD)a2 )
{
case 0:
LODWORD(a2) = (a3 & 1) == 0;
v17 = BugCheckParameter2->Allocate(BugCheckParameter2->BaseBlockAlloc, a2, 825314627i64);
if( v17 )
{
if( (((a7 << 9) - 1) & (unsigned int)v17) == 0 )
{
if( a12 )
*(_DWORD *)a12 = 825314627;
LABEL_19:
memset(v17, 0i64, 0x1000u);
v17[9] = -1;
*v17 = 1718052210;
v17[1] = 1;
v17[2] = 1;
v17[8] = 1;
v17[11] = 1;
HvpFillFileName((_HBASE_BLOCK *)v17, FileName);
v17[36] = 0;
v18 = a3 & 0x80000;
if( v18 )
v17[36] = 2;
v17[5] = 1;
v19 = v18 != 0 ? 6 : 3;
v17[6] = v19;
BugCheckParameter2->Version = v19;
v17[41] = 1836346738;
BugCheckParameter2->CurrentLogSequence = 1;
BugCheckParameter2->MinimumLogSequence = 1;
BugCheckParameter2->CurrentLogMinimumSequence = 1;
*(_QWORD *)(v17 + 3) = v16;
if( a9 )
{
*((_OWORD *)v17 + 7) = *(_OWORD *)a9;
*((_OWORD *)v17 + 8) = *(_OWORD *)a9;
}
if( a10 )
*(_OWORD *)(v17 + 37) = *(_OWORD *)a10;
BugCheckParameter2->BaseBlock = (_HBASE_BLOCK *)v17;
v17[1022] = 0;
return 0i64;
}
BugCheckParameter2->Free(v17, BugCheckParameter2->BaseBlockAlloc);
LOBYTE(v34) = 1;
v17 = BugCheckParameter2->Allocate(4096i64, v34, 842091843i64);
if( v17 )
{
BugCheckParameter2->BaseBlockAlloc = 4096;
if( a12 )
*(_DWORD *)a12 = 842091843;
goto LABEL_19;
}
LODWORD(Point) = 112;
}
else
{
LODWORD(Point) = 96;
}
goto LABEL_54;
case 4:
BugCheckParameter2->BaseBlock = BaseBlock;
Major = BaseBlock->Major;
v33 = BaseBlock->Minor - 4096;
BugCheckParameter2->_bf_8c |= 3u;
BugCheckParameter2->GetCellRoutine = (_CELL_DATA *(__fastcall *)(_HHIVE *, unsigned int, _HV_GET_CELL_CONTEXT *))HvpGetCellFlat;
BugCheckParameter2->ReleaseCellRoutine = (void(__fastcall *)(_HHIVE *, _HV_GET_CELL_CONTEXT *))HvpReleaseCellFlat;
BugCheckParameter2->Version = v33 + (Major << 12);
BugCheckParameter2->Storage[0].Length = BaseBlock->Length;
BugCheckParameter2->StorageTypeCount = 1;
if( a12 )
*(_DWORD *)a12 = 0;
return 0i64;
case 3:
if( HvIsInPlaceBaseBlockValid(BaseBlock) )
{
v37 = BaseBlock->Major;
Minor = BaseBlock->Minor;
BugCheckParameter2->_bf_8c &= ~2u;
BugCheckParameter2->BaseBlock = BaseBlock;
BugCheckParameter2->StorageTypeCount = v36;
BugCheckParameter2->Version = Minor - 4096 + (v37 << 12);
BaseBlock->BootType = v35;
Sequence1 = BaseBlock->Sequence1;
BugCheckParameter2->CurrentLogSequence = Sequence1;
BugCheckParameter2->MinimumLogSequence = Sequence1;
BugCheckParameter2->CurrentLogMinimumSequence = Sequence1;
v29 = HvpAdjustHiveFreeDisplay(BugCheckParameter2, BaseBlock->Length, 0);
if( v29 >= 0 )
{
v29 = HvpBuildMapForMemoryBackedHive((ULONG_PTR)BugCheckParameter2);
if( v29 >= 0 )
{
if( a12 )
*(_DWORD *)a12 = 0;
return 0i64;
}
LODWORD(Point) = 160;
}
else
{
LODWORD(Point) = 144;
}
goto LABEL_56;
}
LODWORD(Point) = 128;
goto LABEL_66;
}
if( BaseBlock->Signature != 1718052210
|| BaseBlock->Type
|| BaseBlock->Format != 1
|| BaseBlock->Major > 1
|| BaseBlock->Minor - 3 > 3
|| BaseBlock->Length > 0x7FFFE000
|| (unsigned int)HvpHeaderCheckSum(BaseBlock) != BaseBlock->CheckSum )
{
LODWORD(Point) = 176;
LABEL_66:
v29 = -1073741492;
goto LABEL_56;
}
v23 = 858869059;
LOBYTE(v21) = v22;
v24 = (_HBASE_BLOCK *)BugCheckParameter2->Allocate(BugCheckParameter2->BaseBlockAlloc, v21, 858869059i64);
BugCheckParameter2->BaseBlock = v24;
if( !v24 )
{
LODWORD(Point) = 192;
goto LABEL_54;
}
if( (((a7 << 9) - 1) & (unsigned int)v24) == 0 )
goto LABEL_39;
BugCheckParameter2->Free(v24, BugCheckParameter2->BaseBlockAlloc);
v23 = 875646275;
LOBYTE(v40) = 1;
v41 = (_HBASE_BLOCK *)BugCheckParameter2->Allocate(4096i64, v40, 875646275i64);
BugCheckParameter2->BaseBlock = v41;
if( !v41 )
{
LODWORD(Point) = 208;
LABEL_54:
v29 = -1073741670;
LABEL_56:
SetFailureLocation(HiveLoadFailure, 0i64, _HvStartHiveMemoryBacked, (unsigned int)v29, Point);
return(unsigned int)v29;
}
BugCheckParameter2->BaseBlockAlloc = 4096;
LABEL_39:
if( a12 )
*(_DWORD *)a12 = v23;
v25 = BugCheckParameter2->BaseBlock;
v26 = BaseBlock;
do
{
*(_OWORD *)&v25->Signature = *(_OWORD *)&v26->Signature;
*(_OWORD *)((char *)&v25->TimeStamp.QuadPart + 4) = *(_OWORD *)((char *)&v26->TimeStamp.QuadPart + 4);
*(_OWORD *)&v25->Format = *(_OWORD *)&v26->Format;
*(_OWORD *)v25->FileName = *(_OWORD *)v26->FileName;
*(_OWORD *)&v25->FileName[16] = *(_OWORD *)&v26->FileName[16];
*(_OWORD *)&v25->FileName[32] = *(_OWORD *)&v26->FileName[32];
*(_OWORD *)&v25->FileName[48] = *(_OWORD *)&v26->FileName[48];
v25 = (_HBASE_BLOCK *)((char *)v25 + 128);
RmId = v26->RmId;
v26 = (_HBASE_BLOCK *)((char *)v26 + 128);
*(_GUID *)v25[-1].ThawLogId.Data4 = RmId;
--v15;
}
while( v15 );
BugCheckParameter2->BaseBlock->BootRecover = BaseBlock->BootRecover;
BugCheckParameter2->BaseBlock->BootType = BaseBlock->BootType;
v28 = BaseBlock->Sequence1;
BugCheckParameter2->CurrentLogSequence = v28;
BugCheckParameter2->MinimumLogSequence = v28;
BugCheckParameter2->CurrentLogMinimumSequence = v28;
BugCheckParameter2->Version = BugCheckParameter2->BaseBlock->Minor
- 4096
+ (BugCheckParameter2->BaseBlock->Major << 12);
v29 = HvpAdjustHiveFreeDisplay(BugCheckParameter2, BaseBlock->Length, 0);
if( v29 < 0 )
{
BugCheckParameter2->Free(BugCheckParameter2->BaseBlock, BugCheckParameter2->BaseBlockAlloc);
BugCheckParameter2->BaseBlock = 0i64;
LODWORD(Point) = 224;
goto LABEL_56;
}
if( HvpBuildMapForMemoryBackedHive((ULONG_PTR)BugCheckParameter2) >= 0 )
{
v30 = BugCheckParameter2->BaseBlock;
if( (v30->Flags & 1) != 0 && a11 )
{
*(_BYTE *)a11 = 1;
v30 = BugCheckParameter2->BaseBlock;
}
v30->Flags &= ~1u;
HvpFillFileName(BugCheckParameter2->BaseBlock, FileName);
return 0i64;
}
LODWORD(Point) = 240;
v29 = -1073741492;
SetFailureLocation(HiveLoadFailure, 0i64, _HvStartHiveMemoryBacked, 3221225804i64, Point);
BugCheckParameter2->Free(BugCheckParameter2->BaseBlock, BugCheckParameter2->BaseBlockAlloc);
BugCheckParameter2->BaseBlock = 0i64;
return(unsigned int)v29;
}Referenced by:
CmpCreateHive
CmpGetSystemControlValues