HvpSetRangeProtection
UINT8 __stdcall HvpSetRangeProtection(ULONG_PTR Hive, ULONG_PTR Offset, UINT64 Length, UINT64 Protection){
unsigned int v4;
unsigned int v5;
_HHIVE *v7;
_HMAP_ENTRY *CellMap;
__int64 FreeBin;
_DWORD *v10;
ULONG_PTR v11;
_HMAP_ENTRY *v12;
char v13;
int v14;
char *v15;
unsigned int v16;
UINT64 p_ViewMap;
int v18;
v4 = Protection;
v5 = Length;
v7 = *(_HHIVE **)&Hive;
if( (*(_DWORD *)(*(_QWORD *)&Hive + 160i64) & 0x11) == 0 && (_DWORD)Length )
{
while( 1 )
{
CellMap = HvpGetCellMap(v7, Offset);
if( !CellMap )
KeBugCheckEx(0x51u, (PVOID)1, v7, (PVOID)Offset, (PVOID)0x40C);
if( (CellMap->PermanentBinAddress & 0xFFFFFFFFFFFFFFF0ui64) == 0 )
{
v5 -= 4096;
v16 = 4096;
goto LABEL_14;
}
FreeBin = HvpMapEntryGetFreeBin(CellMap);
v11 = FreeBin ? Offset - *(_DWORD *)(FreeBin + 20) : *v10;
v12 = HvpGetCellMap(v7, Offset - v11);
v16 = v5;
if( v5 >= v12->MemAlloc - v14 )
v16 = v12->MemAlloc - v14;
if( (v13 & 8) != 0 )
break;
if( (v7->HiveFlags & 0x20000) == 0 )
{
v18 = 1;
LABEL_19:
if( !v18 )
goto LABEL_23;
goto LABEL_13;
}
p_ViewMap = (UINT64)&v7->ViewMap;
if( v4 == 2 )
{
HvpViewMapSealRange(p_ViewMap, Offset, v16);
}
else if( (int)HvpViewMapCOWAndUnsealRange(p_ViewMap, Offset, v16) < 0 )
{
LOBYTE(v18) = 0;
LABEL_23:
if( v4 == 4 )
return v18;
}
LABEL_13:
v5 -= v16;
LABEL_14:
Offset += v16;
if( !v5 )
goto LABEL_15;
}
v18 = ExProtectPoolEx(v15, &v15[v14], v16, v4);
goto LABEL_19;
}
LABEL_15:
LOBYTE(v18) = 1;
return v18;
}Referenced by:
HvpAddBin
HvpApplyLogEntryDataToFileBackedHive
HvpMarkDirty
HvpPerformLogFileRecovery
HvpResetPageProtection