HvpSetRangeProtection
INT64 __fastcall HvpSetRangeProtection(_HHIVE *Hive, UINT64 Offset, INT64 Length, UINT64 Protection){
unsigned int v4;
unsigned int v5;
unsigned int v6;
INT64 CellMap;
__int64 FreeBin;
_DWORD *v10;
int v11;
INT64 v12;
char v13;
int v14;
char *v15;
unsigned int v16;
_HVP_VIEW_MAP *p_ViewMap;
INT64 result;
v4 = Protection;
v5 = Length;
v6 = Offset;
if( (Hive->HiveFlags & 0x11) == 0 && (_DWORD)Length )
{
while( 1 )
{
CellMap = HvpGetCellMap((INT64)Hive, v6);
if( !CellMap )
KeBugCheckEx(0x51u, 1ui64, (ULONG_PTR)Hive, v6, 0x40Cui64);
if( (*(_QWORD *)(CellMap + 8) & 0xFFFFFFFFFFFFFFF0ui64) == 0 )
{
v5 -= 4096;
v16 = 4096;
goto LABEL_14;
}
FreeBin = HvpMapEntryGetFreeBin((_BYTE *)CellMap);
v11 = FreeBin ? v6 - *(_DWORD *)(FreeBin + 20) : *v10;
v12 = HvpGetCellMap((INT64)Hive, v6 - v11);
v16 = v5;
if( v5 >= *(_DWORD *)(v12 + 16) - v14 )
v16 = *(_DWORD *)(v12 + 16) - v14;
if( (v13 & 8) != 0 )
break;
if( (Hive->HiveFlags & 0x20000) == 0 )
{
result = 1i64;
LABEL_19:
if( !(_DWORD)result )
goto LABEL_23;
goto LABEL_13;
}
p_ViewMap = &Hive->ViewMap;
if( v4 == 2 )
{
HvpViewMapSealRange((INT64)p_ViewMap, v6, v16);
}
else if( (int)HvpViewMapCOWAndUnsealRange((INT64)p_ViewMap, v6, v16) < 0 )
{
result = 0i64;
LABEL_23:
if( v4 == 4 )
return result;
}
LABEL_13:
v5 -= v16;
LABEL_14:
v6 += v16;
if( !v5 )
return 1i64;
}
result = ExProtectPoolEx(v15, &v15[v14], v16, v4);
goto LABEL_19;
}
return 1i64;
}Referenced by:
HvpAddBin
HvpApplyLogEntryDataToFileBackedHive
HvpMarkDirty
HvpPerformLogFileRecovery
HvpResetPageProtection