hello,
i'm trying to read kernelmemory and as i'm aware of windows memory management and paging im using the following code to access the memory in a safe manner:
bsod happens on MmUnlockPages(Model);
i already found a thread concerning this issue (http://forum.cheatengine.org/viewtopic. ... ac944c8871) but the provided "solution" isn't satisfying in my opinion.
whats wrong with my code?
best regards
whitepanda
i'm trying to read kernelmemory and as i'm aware of windows memory management and paging im using the following code to access the memory in a safe manner:
Code: Select all
using the function above on some drivers i get a pfn list corrupted bsod, however on most drivers it works.NTSTATUS ReadKernelMemory(LPVOID address, DWORD Size, LPVOID lpOutBuffer, DWORD* lpBytesWritten)
{
NTSTATUS NtStatus = STATUS_UNSUCCESSFUL;
if(MmIsAddressValid(address) && MmIsAddressValid(lpOutBuffer))
{
PMDL Model = IoAllocateMdl(address, Size, FALSE, FALSE, NULL);
if(Model)
{
__try
{
MmProbeAndLockPages(Model, KernelMode, IoReadAccess);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
IoFreeMdl(Model);
return NtStatus;
}
address = MmGetSystemAddressForMdlSafe(Model, NormalPagePriority);
if(address)
{
RtlCopyMemory(lpOutBuffer, address, Size);
*lpBytesWritten = Size;
NtStatus = STATUS_SUCCESS;
}
MmUnlockPages(Model);
IoFreeMdl(Model);
}
}
return NtStatus;
}
bsod happens on MmUnlockPages(Model);
i already found a thread concerning this issue (http://forum.cheatengine.org/viewtopic. ... ac944c8871) but the provided "solution" isn't satisfying in my opinion.
whats wrong with my code?
best regards
whitepanda