HvValidateOrInvalidatePrimaryFileHeader
NTSTATUS __stdcall HvValidateOrInvalidatePrimaryFileHeader(
_HHIVE *Hive,
UINT8 Validate,
UINT8 UseCapturedData,
UINT64 Flags){
unsigned int v7;
_HBASE_BLOCK *SectionEndFileOffset;
unsigned int CurrentLogSequence;
unsigned int v10;
int(__fastcall *FileWrite)(_HHIVE *, unsigned int, CMP_OFFSET_ARRAY *, unsigned int, unsigned int);
NTSTATUS v12;
VOID **PoolWithTag;
_HBASE_BLOCK *BaseBlock;
__int64 v16;
_HBASE_BLOCK *v17;
_GUID RmId;
int v19[2];
_HBASE_BLOCK *v20;
int v21;
int v22;
v19[1] = 0;
v22 = 0;
if( !*(_QWORD *)&Hive[1].Signature )
return 0;
v7 = Flags & 1;
if( UseCapturedData )
{
SectionEndFileOffset = (_HBASE_BLOCK *)Hive[1].ViewMap.SectionEndFileOffset;
}
else
{
PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x1000ui64, 1867074883i64);
SectionEndFileOffset = (_HBASE_BLOCK *)PoolWithTag;
if( !PoolWithTag )
return -1073741801;
memset(PoolWithTag, 0i64, 0x1000u);
BaseBlock = Hive->BaseBlock;
v16 = 4i64;
v17 = SectionEndFileOffset;
do
{
*(_OWORD *)&v17->Signature = *(_OWORD *)&BaseBlock->Signature;
*(_OWORD *)((char *)&v17->TimeStamp.QuadPart + 4) = *(_OWORD *)((char *)&BaseBlock->TimeStamp.QuadPart + 4);
*(_OWORD *)&v17->Format = *(_OWORD *)&BaseBlock->Format;
*(_OWORD *)v17->FileName = *(_OWORD *)BaseBlock->FileName;
*(_OWORD *)&v17->FileName[16] = *(_OWORD *)&BaseBlock->FileName[16];
*(_OWORD *)&v17->FileName[32] = *(_OWORD *)&BaseBlock->FileName[32];
*(_OWORD *)&v17->FileName[48] = *(_OWORD *)&BaseBlock->FileName[48];
v17 = (_HBASE_BLOCK *)((char *)v17 + 128);
RmId = BaseBlock->RmId;
BaseBlock = (_HBASE_BLOCK *)((char *)BaseBlock + 128);
*(_GUID *)v17[-1].ThawLogId.Data4 = RmId;
--v16;
}
while( v16 );
}
CurrentLogSequence = Hive->CurrentLogSequence;
v10 = CurrentLogSequence - 1;
if( Validate )
v10 = Hive->CurrentLogSequence;
SectionEndFileOffset->Sequence2 = v10;
SectionEndFileOffset->Sequence1 = CurrentLogSequence;
SectionEndFileOffset->CheckSum = HvpHeaderCheckSum(SectionEndFileOffset);
FileWrite = Hive->FileWrite;
v19[0] = 0;
v20 = SectionEndFileOffset;
v21 = 4096;
v12 = FileWrite(Hive, 0, (CMP_OFFSET_ARRAY *)v19, 1u, v7);
if( v12 >= 0 )
{
v12 = CmpFileFlushAndPurge(Hive, 0i64);
if( v12 >= 0 )
{
Hive->PrimaryFileValid = Validate;
v12 = 0;
Hive->MinimumLogSequence = SectionEndFileOffset->Sequence2;
}
}
if( !UseCapturedData )
ExFreePoolWithTag(SectionEndFileOffset, 0);
return v12;
}Referenced by:
CmpFlushHive
HvpPerformLogFileRecovery