MmRemovePhysicalMemory
NTSTATUS __stdcall MmRemovePhysicalMemory(PPHYSICAL_ADDRESS StartAddress, PLARGE_INTEGER NumberOfBytes){
unsigned __int64 QuadPart;
unsigned __int64 v4;
UINT64 SizeInPages;
INT64 v6;
bool v7;
UINT64 v8;
NTSTATUS result;
UINT64 v10;
int v11;
NTSTATUS v12;
UINT64 PreferredNode;
UINT64 PreferredChannel;
UINT64 Flags;
LONGLONG BugCheckParameter2;
_MI_PARTITION *BugCheckParameter2a;
QuadPart = NumberOfBytes->QuadPart;
v4 = StartAddress->QuadPart;
SizeInPages = QuadPart >> 12;
BugCheckParameter2 = StartAddress->QuadPart;
v6 = (unsigned int)StartAddress->QuadPart;
v7 = (BugCheckParameter2 & 1) != 0 && (BugCheckParameter2 & 0xFFF) != 0;
if( v7 )
{
v6 = (unsigned int)v6 & 0xFFFFFFFE;
LODWORD(BugCheckParameter2) = v6;
v4 = BugCheckParameter2;
}
v8 = v4 >> 12;
BugCheckParameter2a = (_MI_PARTITION *)v8;
if( v8 >= v8 + SizeInPages )
return -1073741585;
if( v7 )
{
result = MiRemoveBadPages(v6, v8, SizeInPages);
}
else
{
LODWORD(Flags) = 202375168;
LODWORD(PreferredChannel) = 0x80000000;
LODWORD(PreferredNode) = 0x80000000;
result = MiFindContiguousPages(
(_MI_PARTITION *)&MiSystemPartition,
v8,
v8 + SizeInPages - 1,
0i64,
SizeInPages,
MiCached,
PreferredNode,
PreferredChannel,
Flags,
0i64);
}
if( result >= 0 )
{
MiRemovePhysicalMemory((UINT64)BugCheckParameter2a, SizeInPages, 0x10ui64);
v12 = v11;
if( v11 < 0 )
{
if( v7 )
MiReturnBadPagesToBadList((INT64)BugCheckParameter2a, SizeInPages);
else
MiFreeContiguousPages(BugCheckParameter2a, SizeInPages, v10);
}
else
{
NumberOfBytes->QuadPart = SizeInPages << 12;
}
return v12;
}
return result;
}Referenced by:
WheapClearPoison