RtlZeroHeap
NTSTATUS __stdcall RtlZeroHeap(VOID *HeapHandle, UINT64 Flags, VOID *a3, VOID *a4, VOID *a5, VOID *a6){
_BYTE *v7;
char *v9;
char *v10;
unsigned __int64 v11;
unsigned __int8 v12;
unsigned __int64 v13;
_QWORD *v14;
VOID **v15;
VOID *v16;
VOID *v17;
_HEAP_LIST_LOOKUP *v18;
_LIST_ENTRY *v19;
unsigned __int64 ArraySize;
int v21;
unsigned __int64 v22;
_LIST_ENTRY **v23;
_LIST_ENTRY *Entry;
int Blink;
unsigned __int16 v26;
_LIST_ENTRY *v27;
VOID **p_Flink;
_HEAP_LIST_LOOKUP *v29;
_LIST_ENTRY *v30;
unsigned __int64 v31;
int v32;
unsigned __int64 v33;
_DWORD *v34;
unsigned __int64 v35;
unsigned __int64 v36;
UINT64 Context;
char v38;
unsigned __int64 v39;
unsigned __int64 v40;
int v41;
v7 = 0i64;
v38 = 0;
if( *((_DWORD *)HeapHandle + 4) == -571548178 )
return 0;
if( ((*((_BYTE *)HeapHandle + 116) | (unsigned __int8)Flags) & 1) == 0 )
{
ExAcquireResourceExclusiveLite(*((_QWORD *)HeapHandle + 44), 1, (INT64)a3);
v38 = 1;
}
v9 = (char *)HeapHandle + 288;
v10 = (char *)*((_QWORD *)HeapHandle + 36);
LABEL_6:
if( v10 != v9 )
{
v11 = *((_QWORD *)v10 + 5);
v39 = v11;
while( 1 )
{
if( v11 >= *((_QWORD *)v10 + 6) )
{
v10 = *(char **)v10;
v9 = (char *)HeapHandle + 288;
goto LABEL_6;
}
if( !v7 )
goto LABEL_12;
if( *((_DWORD *)HeapHandle + 31) )
break;
LABEL_15:
v7 = (_BYTE *)v11;
v12 = *(_BYTE *)(v11 + 10);
if( (v12 & 1) != 0 )
goto LABEL_66;
v13 = v11;
v40 = v11;
if( (v12 & 8) != 0 )
{
v14 = *(_QWORD **)(v11 + 16);
v15 = *(VOID ***)(v11 + 24);
v16 = *v15;
v17 = (VOID *)v14[1];
if( *v15 == v17 && v16 == (VOID *)(v11 + 16) )
{
*((_QWORD *)HeapHandle + 24) -= *(unsigned __int16 *)(v11 + 8);
v18 = (_HEAP_LIST_LOOKUP *)*((_QWORD *)HeapHandle + 39);
if( v18 )
{
v19 = (_LIST_ENTRY *)*(unsigned __int16 *)(v11 + 8);
while( 1 )
{
ArraySize = v18->ArraySize;
if( (unsigned __int64)v19 < ArraySize )
{
v21 = *(unsigned __int16 *)(v11 + 8);
goto LABEL_25;
}
if( !v18->ExtendedLookup )
break;
v18 = v18->ExtendedLookup;
}
v21 = ArraySize - 1;
LABEL_25:
LODWORD(Context) = v21;
RtlpHeapRemoveListEntry((_HEAP *)HeapHandle, v18, v19, v11 + 16, Context);
}
*v15 = v14;
v14[1] = v15;
v22 = *(unsigned __int16 *)(v11 + 8);
*(_BYTE *)(v11 + 10) = 0;
*(_BYTE *)(v11 + 15) = 0;
v23 = (_LIST_ENTRY **)((char *)HeapHandle + 336);
if( *((_QWORD *)HeapHandle + 39) )
Entry = RtlpFindEntry((_HEAP *)HeapHandle, (unsigned int)v22);
else
Entry = *v23;
while( v23 != (_LIST_ENTRY **)Entry )
{
if( *((_DWORD *)HeapHandle + 31) )
{
Blink = (int)Entry[-1].Blink;
LOWORD(v41) = Blink;
if( (Blink & *((_DWORD *)HeapHandle + 31)) != 0 )
v41 = Blink ^ *((_DWORD *)HeapHandle + 34);
v26 = v41;
v11 = v39;
v13 = v40;
}
else
{
v26 = (unsigned __int16)Entry[-1].Blink;
}
if( v22 <= v26 )
break;
Entry = Entry->Flink;
}
v27 = (_LIST_ENTRY *)(v13 + 16);
p_Flink = (VOID **)&Entry->Blink->Flink;
if( *p_Flink == Entry )
{
v27->Flink = Entry;
*(_QWORD *)(v13 + 24) = p_Flink;
*p_Flink = v27;
Entry->Blink = v27;
}
else
{
RtlpLogHeapFailure(heap_failure_freelists_corruption, 0i64, Entry, 0i64, *p_Flink);
}
*((_QWORD *)HeapHandle + 24) += *(unsigned __int16 *)(v13 + 8);
v29 = (_HEAP_LIST_LOOKUP *)*((_QWORD *)HeapHandle + 39);
if( v29 )
{
v30 = (_LIST_ENTRY *)*(unsigned __int16 *)(v13 + 8);
while( 1 )
{
v31 = v29->ArraySize;
if( (unsigned __int64)v30 < v31 )
{
v32 = *(unsigned __int16 *)(v13 + 8);
goto LABEL_47;
}
if( !v29->ExtendedLookup )
break;
v29 = v29->ExtendedLookup;
}
v32 = v31 - 1;
LABEL_47:
LODWORD(Context) = v32;
RtlpHeapAddListEntry((_HEAP *)HeapHandle, v29, v30, v13 + 16, Context);
}
if( *((_DWORD *)HeapHandle + 31) )
{
*(_BYTE *)(v13 + 11) = *(_BYTE *)(v13 + 8) ^ *(_BYTE *)(v13 + 9) ^ *(_BYTE *)(v13 + 10);
*(_DWORD *)(v13 + 8) ^= *((_DWORD *)HeapHandle + 34);
}
}
else
{
RtlpLogHeapFailure(heap_failure_freelists_corruption, HeapHandle, (VOID *)(v11 + 16), v17, v16);
}
v7 = 0i64;
}
else
{
v33 = 16i64 * *(unsigned __int16 *)(v11 + 8) - 32;
v34 = (_DWORD *)(v11 + 32);
if( ((v12 >> 2) & ((*((_BYTE *)HeapHandle + 112) & 0x40) != 0)) != 0 )
{
v35 = v33 >> 2;
if( !v35 )
goto LABEL_66;
if( ((unsigned __int8)v34 & 4) != 0 )
{
*v34 = -17891602;
if( !--v35 )
goto LABEL_66;
v34 = (_DWORD *)(v11 + 36);
}
memset64(v34, 0xFEEEFEEEFEEEFEEEui64, v35 >> 1);
if( (v35 & 1) != 0 )
v34[v35 - 1] = -17891602;
}
else
{
v36 = v33 >> 2;
if( !v36 )
goto LABEL_66;
if( ((unsigned __int8)v34 & 4) != 0 )
{
*v34 = 0;
if( !--v36 )
goto LABEL_66;
v34 = (_DWORD *)(v11 + 36);
}
memset(v34, 0, 8 * (v36 >> 1));
if( (v36 & 1) != 0 )
v34[v36 - 1] = 0;
}
LABEL_66:
if( *(_BYTE *)(v11 + 15) == 3 )
v11 += *(_QWORD *)(v11 + 56) + 64i64;
else
v11 += 16i64 * *(unsigned __int16 *)(v11 + 8);
v39 = v11;
}
}
v7[11] = v7[8] ^ v7[9] ^ v7[10];
*((_DWORD *)v7 + 2) ^= *((_DWORD *)HeapHandle + 34);
LABEL_12:
if( *((_DWORD *)HeapHandle + 31) )
{
*(_DWORD *)(v11 + 8) ^= *((_DWORD *)HeapHandle + 34);
if( *(_BYTE *)(v11 + 11) != (*(_BYTE *)(v11 + 8) ^ (unsigned __int8)(*(_BYTE *)(v11 + 9) ^ *(_BYTE *)(v11 + 10))) )
RtlpAnalyzeHeapFailure((_HEAP *)HeapHandle, (_HEAP_ENTRY *)v11);
}
goto LABEL_15;
}
if( v7 && *((_DWORD *)HeapHandle + 31) )
{
v7[11] = v7[8] ^ v7[9] ^ v7[10];
*((_DWORD *)v7 + 2) ^= *((_DWORD *)HeapHandle + 34);
}
if( v38 )
ExReleaseResourceLite(*((PERESOURCE *)HeapHandle + 44));
return 0;
}Referenced by:
No references.