RtlpHpFreeHeap
INT64 __stdcall RtlpHpFreeHeap(PVOID HeapAddress, PVOID Address, INT64 a3){
unsigned int v4;
int v6;
unsigned int v7;
int v8;
unsigned int v9;
int v10;
union _RTL_RUN_ONCE *HeapManager;
INT64 v13;
UINT64 v14;
char v15;
int v16;
int v17;
__int128 v18;
v4 = 0;
v6 = 0;
v7 = a3 | *((_DWORD *)HeapAddress + 5) & 0x11000001;
v8 = *((_DWORD *)HeapAddress + 55);
if( v8 )
LOBYTE(v6) = v8 == *((_DWORD *)KeGetCurrentThread() + 288);
v9 = v7 | 1;
if( !v6 )
v9 = v7;
if( (v9 & 0x1000000) != 0
|| !*((_DWORD *)HeapAddress + 6)
|| (v14 = RtlpHpExtrasGet((__int128 *)HeapAddress, (UINT64)Address, v9, 0i64), v14 - 1 > 0xFFFFFFFFFFFFFFFDui64)
|| (v15 = *(_BYTE *)(v14 + 2), (v15 & 0xF) == 0)
|| ((v16 = v15 & 0xF) == 0 || (_WORD)v16 != 1 ? (v17 = -1073741823) : (v17 = ((__int64(__fastcall *)(PVOID, PVOID, __int64, UINT64))RtlpInterceptorRoutines)(
HeapAddress,
Address,
3i64,
v14 + 16)),
v17 >= 0) )
{
if( (*((_DWORD *)HeapAddress + 5) & 0x10000000) != 0
&& RtlpHpSizeHeap((INT64)HeapAddress, (UINT64)Address, v9) == -1 )
{
RtlpLogHeapFailure(9i64, (INT64)HeapAddress, (UINT64)Address, 0i64, 0i64, 0i64);
return v4;
}
if( (_WORD)Address )
{
v10 = 0;
}
else
{
v18 = *(_OWORD *)HeapAddress;
HeapManager = RtlpHpEnvGetHeapManager(&v18);
v13 = RtlCSparseBitmapBitmaskRead(
(INT64)&HeapManager[2],
2 * (((unsigned __int64)Address - HeapManager[1].Value) >> 20));
if( !v13 )
goto LABEL_25;
v10 = v13 - 1;
}
if( v10 != 2 )
return(unsigned int)RtlpHpSegFree((INT64)HeapAddress + 192 * v10 + 256, (UINT64)Address, v9);
LABEL_25:
LOBYTE(v4) = RtlpHpLargeFree(HeapAddress, Address, v9) != 0;
}
return v4;
}Referenced by:
ExAllocateContiguousHeapPool
ExAllocateHeapPool
ExGetBigPoolInfo
ExPoolCleanupExpansionTable
ExpFreeHeapSpecialPool
ExpHpCompactionRoutine
ExpResizeBigPageTable
RtlpHpAllocateHeap
RtlpHpMetadataFree