HvIsCellAllocated
UINT8 __stdcall HvIsCellAllocated(_HHIVE *Hive, UINT64 Cell, _RTL_BITMAP *BitMap){
bool v3;
_RTL_BITMAP *v4;
unsigned __int64 v5;
__int64 v7;
unsigned int Length;
_HMAP_ENTRY *v9;
__int64 v10;
int *v11;
int v12;
int v13;
unsigned int v14;
unsigned int v15;
__int64 v16;
UINT8 v17;
__int64 v19;
v19 = 0i64;
v3 = (Hive->_bf_8c & 1) == 0;
v4 = BitMap;
v5 = (unsigned int)Cell;
LODWORD(v19) = -1;
if( !v3 )
return 1;
v7 = (unsigned int)Cell >> 31;
Length = Hive->Storage[v7].Length;
if( (Cell & 0x7FFFFFFF) >= Length || (Cell & 7) != 0 )
return 0;
if( BitMap && (Cell & 0x80000000) == 0i64 )
{
if( !_bittest64((const signed __int64 *)BitMap->Buffer, (unsigned int)Cell >> 3) )
return 0;
RtlClearBits(BitMap, (unsigned int)Cell >> 3, 1u);
Length = Hive->Storage[v7].Length;
}
if( (unsigned int)v5 + (v5 & 0x80000000) >= Length )
return 0;
v9 = &Hive->Storage[v7].Map->Directory[(v5 >> 21) & 0x3FF]->Table[(v5 >> 12) & 0x1FF];
if( !v9 || (v9->PermanentBinAddress & 2) != 0 )
return 0;
v10 = ((__int64(__fastcall *)(_HHIVE *, _QWORD, __int64 *, _RTL_BITMAP *))Hive->GetCellRoutine)(
Hive,
(unsigned int)v5,
&v19,
v4);
if( !v10 )
return 1;
v11 = (int *)(v10 - 4);
if( !v11 )
return 1;
v12 = (int)v11;
v13 = *v11;
v14 = v12 - (v9->PermanentBinAddress & 0xFFFFFFF0);
v15 = -v13;
v17 = 0;
if( v13 < 0 && v15 - 8 <= 0xFFFF8 )
{
v16 = *(unsigned int *)((v9->PermanentBinAddress & 0xFFFFFFFFFFFFFFF0ui64) + 8);
if( v15 <= (unsigned __int64)(v16 - 32) && v14 - v13 <= (unsigned int)v16 && v14 >= 0x20 )
v17 = 1;
}
Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&v19);
return v17;
}Referenced by:
CmpCheckKey
CmpCheckValueList
CmpValidateHiveSecurityDescriptors