Re: To map physical address range to nonpaged system space on 64-bit machine.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Oct 31, 5:22 pm, "Don Burn" <b...@xxxxxxxxxxxxxxxxxxxx> wrote:
This has so many security holes that I don't know where to start. This code
is highly broken for all systems, you do nothing to test that the address is
valid, nothing to test that the next 256 bytes are valid addresses. Why
are you doing this? Make a METHOD_IN_DIRECT Ioctl where the buffer gets
mapped to physical memory for you by the system.

--
Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website:http://www.windrvr.com
Blog:http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

<bhatnagar.a...@xxxxxxxxx> wrote in message

news:46c7aa30-d5ec-4d13-8a5a-7e28a5a2f67f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hello,

I have an application and a device driver that interact with each
other using a buffer. In my application i pass the address of the
buffer to the driver through DeviceIoControl() call and in driver i
map the given physical address range to nonpaged system space using
MmMapIoSpace() call.

In Application i do the following:

dwControlBuf = (DWORD)&szKeyBuffer[0];
and i pass the address of dwControlBuf in DeviceIoControl call.
the variables are:
DWORD dwControlBuf = 0;
char szKeyBuffer[256];

In driver dispatcher (IRP_MJ_DEVICE_CONTROL) i do the following:

szBuff = (UCHAR *)Irp->AssociatedIrp.SystemBuffer;
if(szBuff)
{
memmove(&ulTemp, &szBuff[0], sizeof(ulTemp));
szKeyBuffer = (char *)MmMapIoSpace(MmGetPhysicalAddress((void
*)ulTemp), 256, 0);
}

and the variables are:

ULONG ulTemp;
char *szKeyBuffer = NULL;
UCHAR *szBuff = NULL;

It works file in case of 32-bit application and driver. But how can i
do the same thing for 64-bit application and driver since i can't take
the address of buffer in DWORD and pass that DWORD's address to the
driver?

Please suggest me the method for this....

Thanks
Alok Bhatnagar

Hello Don,

Thanks for ur reply!

I am doing the test to check whether the address is valid or not but i
didn't post that code for the simplicity. To check the address i am
using MmIsAddressValid function.

Can you just post a small sample code that uses METHOD_IN_DIRECT?

Regards
Alok Bhatnagar



.



Relevant Pages