(I’m sorry to bother everyone else not interested on the subject;
if that’s your case, please ignore this mail)
Dear Gurus [Max?],
This message’s coming in the sequence of a few others I sent last week.
The subject is basically “how may I use an arbitrary PID I’m getting
hold of (which may refer to a DLL, app, etc.) and access [write to] a
well-known (virtual?) address within that process context”?
(OK, it’s a bit confusing but I’m novice so please be patient)
On Friday, February 02, 2001 7:07 PM Maxim S. Shatskih [Max] wrote:
If you want to access [memory location] from any process - then
IoAllocateMdl/MmProbeAndLockPages/MmGetSystemAddressForMdl
is the only solution.
If you use DO_DIRECT_IO (or METHOD_xxx_DIRECT IOCTLs),
then the IO manager will do the first 2 things for you - you will need only
to call MmGetSystemAddressForMdl. In this case, the MDL will be valid
till the IRP will be completed.
(According to the Win2K DDK documentation, that function is obsolete and
I should use MmGetSystemAddressForMdlSafe instead, due to the page
priority issues; no problem with that, but I thought it was worth to point it
out)
I found a few examples of using the MmGetSystemAddressForMdlSafe,
which basically used the following approach:
PVOID pBuffer;
pBuffer = MmGetSystemAddressForMdlSafe(pIrp->MdlAddress,
High/Normal/LowPagePriority);
As far as I understand, MmGetSystemAddressForMdlSafe receives a
“pointer to a buffer whose corresponding base virtual address is to be mapped”.
I’m sorry, but I’m missing the point here: how may I use this buffer (on Irp?)?
Right now, I have something that seems as follows (this is somewhat simplified
so you can easily catch the idea here in this mail):
-On my driver’s .h file I have:
typedef struct _MYVARTYPE
{
…
ULONG pid; // The PID I’m getting hold of (arbitrary)
ULONG address; // The (virtual?) address I’m getting hold of
…
} MYVARTYPE,
*LPMYVARTYPE, *PMYVARTYPE;
(…)
#define MY_IOCTL CTL_CODE (MYDEVICE_KIND, MYDEVICE_IOCTL, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
-On the DriverDispatchDeviceControl routine I’m using:
MYVARTYPE *pBuffer;
PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation( Irp );
pBuffer = (MYVARTYPE *)Irp->AssociatedIrp.SystemBuffer;
if (irpStack->Parameters.DeviceIoControl.IoControlCode == MY_IOCTL)
{
// pBuffer->pid … the PID I’m getting hold of
// pBuffer->address … the address I’m getting hold of
(…) // Now how am I gonna use MmGetSystemAddressForMdlSafe here?
// if function succeeds, I’m returning sizeof(MYVARTYPE) on
// Irp->IoStatus.Information to indicate the operation succeeded
// (quite simple approach for now)
}
According to Mr. Shatskih, I guess I would be using something like:
#define MY_IOCTL CTL_CODE (MYDEVICE_KIND, MYDEVICE_IOCTL, METHOD_IN_DIRECT, FILE_READ_DATA | FILE_WRITE_DATA)
Is this correct? Yet, how would I use MmGetSystemAddressForMdlSafe?
Remember, I’ve no background yet on MDL’s, I’m novice and this stuff isn’t
easy…
Miguel Monteiro
xxxxx@criticalsoftware.com
www.criticalsoftware.com
«Humour and love are God’s answers
to Human weaknesses»
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com