MiReturnMdlExcess
VOID __fastcall MiReturnMdlExcess(INT64 rcx0){
MDL *v1;
_MI_PARTITION *v3;
unsigned __int64 v4;
UINT64 v5;
int v6;
_MI_PFN_CACHE_ATTRIBUTE v7;
UINT64 v8;
__int64 v9;
__int64 v10;
UINT64 v11;
v1 = *(MDL **)(rcx0 + 64);
v3 = *(_MI_PARTITION **)rcx0;
v4 = (unsigned __int64)v1->ByteCount >> 12;
v5 = *(_QWORD *)(rcx0 + 40) - v4;
MiReleaseNonPagedResources(*(_MI_PARTITION **)rcx0, v5);
if( v3 == (_MI_PARTITION *)&MiSystemPartition )
_InterlockedExchangeAdd64(&qword_140C4ECF8, -(__int64)v5);
if( !v4 )
goto LABEL_4;
v6 = *(_DWORD *)(rcx0 + 8);
if( (v6 & 4) != 0 )
{
if( (v6 & 0x40) == 0 )
{
MiInitializeMdlBatchPages(rcx0);
MiInitializeMdlPages(v1, *(unsigned int *)(rcx0 + 8), v7, v8, v11);
}
MiFreePagesFromMdl(v1, 0i64);
LABEL_4:
ExFreePoolWithTag(v1, 0);
*(_QWORD *)(rcx0 + 64) = 0i64;
return;
}
if( v5 > 0x800 )
{
LODWORD(v9) = MiAllocatePool((struct _SLIST_ENTRY *)0x40);
v10 = v9;
if( v9 )
{
*(_QWORD *)v9 = 0i64;
*(_WORD *)(v9 + 8) = 8 * (v4 + 6);
*(_DWORD *)(v9 + 40) = (_DWORD)v4 << 12;
*(_WORD *)(v9 + 10) = 0;
*(_QWORD *)(v9 + 32) = 0i64;
*(_DWORD *)(v9 + 44) = 0;
memmove((UINT8 *)(v9 + 48), (UINT8 *)(*(_QWORD *)(rcx0 + 64) + 48i64), 8 * v4);
ExFreePoolWithTag(*(PVOID *)(rcx0 + 64), 0);
*(_QWORD *)(rcx0 + 64) = v10;
}
}
}Referenced by:
MiAllocatePagesForMdl