RtlpSizeHeapInternal
UINT64 __stdcall RtlpSizeHeapInternal(VOID *HeapHandle, VOID *BaseAddress){
INT64 v2;
VOID *v3;
UINT64 v5;
unsigned __int64 v6;
UINT64 v7;
_HEAP_ENTRY *v9;
_HEAP_FAILURE_TYPE v10;
unsigned __int8 UnusedBytes;
int v12;
unsigned int SubSegmentCode;
unsigned __int16 Size;
unsigned int v16;
unsigned __int16 v17;
unsigned __int64 PreviousSize;
unsigned int v19;
unsigned __int16 v20;
__int64 v21;
int v22;
int v23;
int v24;
v3 = (VOID *)v2;
if( *((_DWORD *)HeapHandle + 4) == -857879331 )
{
LODWORD(v5) = RtlpHpVsChunkSize((INT64)HeapHandle + 64, v2, v2, 0i64);
v7 = v5;
if( v5 == -1i64 )
RtlpLogHeapFailure(heap_failure_invalid_argument, HeapHandle, v3, (VOID *)v6, (VOID *)(v6 & v21));
return v7;
}
if( (*((_DWORD *)HeapHandle + 30) & 1) != 0 )
{
v9 = RtlpProbeUserBufferSafe((_HEAP *)HeapHandle, (VOID *)v2);
}
else
{
if( (v2 & 0xF) != 0 )
{
v10 = heap_failure_invalid_argument;
}
else
{
v9 = (_HEAP_ENTRY *)(v2 - 16);
_m_prefetchw((const void *)(v2 - 16));
if( *(_BYTE *)(v2 - 16 + 15) == 5 )
v9 -= v9->UnpackedEntry.SegmentOffset;
if( (v9->UnpackedEntry.UnusedBytes & 0x3F) != 0 )
goto LABEL_14;
v2 = (INT64)v9;
v10 = heap_failure_block_not_busy;
}
RtlpLogHeapFailure(v10, HeapHandle, (VOID *)v2, 0i64, 0i64);
v9 = 0i64;
}
LABEL_14:
if( !v9 )
return -1i64;
UnusedBytes = v9->UnpackedEntry.UnusedBytes;
v12 = *((_DWORD *)HeapHandle + 31);
if( UnusedBytes == 4 )
{
if( v12 )
{
SubSegmentCode = v9->UnpackedEntry.SubSegmentCode;
LOWORD(v22) = SubSegmentCode;
if( (SubSegmentCode & *((_DWORD *)HeapHandle + 31)) != 0 )
v22 = *((_DWORD *)HeapHandle + 34) ^ SubSegmentCode;
Size = v22;
}
else
{
Size = v9->UnpackedEntry.Size;
}
return(UINT64)v9[-1].UnpackedEntry.PreviousBlockPrivateData - Size;
}
else
{
if( v12 )
{
v16 = v9->UnpackedEntry.SubSegmentCode;
v12 = *((_DWORD *)HeapHandle + 31);
LOWORD(v23) = v16;
if( (v12 & v16) != 0 )
v23 = *((_DWORD *)HeapHandle + 34) ^ v16;
v17 = v23;
UnusedBytes = v9->UnpackedEntry.UnusedBytes;
}
else
{
v17 = v9->UnpackedEntry.Size;
}
if( UnusedBytes == 5 )
{
PreviousSize = v9->UnpackedEntry.PreviousSize ^ (unsigned __int64)*((unsigned __int16 *)HeapHandle + 70);
}
else if( (UnusedBytes & 0x40) != 0 )
{
PreviousSize = v9[UnusedBytes & 0x3F].UnpackedEntry.PreviousSize;
}
else if( (UnusedBytes & 0x3F) == 63 )
{
if( v12 )
{
v19 = v9->UnpackedEntry.SubSegmentCode;
LOWORD(v24) = v19;
if( (v19 & *((_DWORD *)HeapHandle + 31)) != 0 )
v24 = *((_DWORD *)HeapHandle + 34) ^ v19;
v20 = v24;
}
else
{
v20 = v9->UnpackedEntry.Size;
}
PreviousSize = (unsigned __int64)v9[v20].UnpackedEntry.PreviousBlockPrivateData;
}
else
{
PreviousSize = UnusedBytes & 0x3F;
}
return 16i64 * v17 - PreviousSize;
}
}Referenced by:
RtlSizeHeap