I'm trying to commit some user-mode memory in the context of the process: (Windows 7, architecture x86)
But when the first command of my shellcode gets invoked, some strange exception is issued.
i.e. I see that the control is passes to my shellcode:
001b:00030004 8bec mov ebp,esp
But after I press F11 (single-step) the ntdll!KiUserExceptionDispatcher is invoked
What can be wrong?
Code: Select all
Them I copy a small shellcode there. PMDL pMdl = NULL;
BYTE *pVirtualMemory = NULL;
PHYSICAL_ADDRESS phBegin,phEnd,phSkip;
phBegin.QuadPart = 0;
phEnd.QuadPart = (LONGLONG)-1;
phSkip.QuadPart = 0;
DWORD dwAllocationSize;
__try
{
pMdl = MmAllocatePagesForMdl(phBegin, phEnd, phSkip, 0x1000);
DBGPRINT(("ImageLoadNotifyRoutine MmAllocatePagesForMdl %X\r\n", pMdl));
if (pMdl)
{
dwAllocationSize = MmGetMdlByteCount(pMdl);
if (dwAllocationSize >= 0x60)
{
pVirtualMemory = (BYTE *)MmMapLockedPagesSpecifyCache(pMdl, UserMode, MmCached, 0, FALSE, NormalPagePriority);
DBGPRINT(("ImageLoadNotifyRoutine MmMapLockedPagesSpecifyCache %X\r\n", pVirtualMemory));
if (pVirtualMemory)
{
But when the first command of my shellcode gets invoked, some strange exception is issued.
i.e. I see that the control is passes to my shellcode:
001b:00030004 8bec mov ebp,esp
But after I press F11 (single-step) the ntdll!KiUserExceptionDispatcher is invoked
What can be wrong?