> Robert,
What are you using to “lock” the memory?
Chuck
Here is what I do. Note that if you maintain your lock on the memory
after completing the IRP than you must track it within your driver
on a per handle basis. Failing to release the memory when the
originating handle is closed = BSOD.
Note, code altered to protect the innocent(me) and to eliminate detail
that would obscure things.
__try
{
UserBufferMdl = IoAllocateMdl(
UserAddress,
BufferSize,
FALSE,
FALSE,
NULL);
if (UserBufferMdl) {
// allocation failed, deal with error
}
// lock down the user memory and page it in
MmProbeAndLockPages(
UserBufferMdl,
UserMode,
IoModifyAccess); // throws exception on error
// map system address (if necessary) so that memory can be
// accessed (by address) when not in user’s thread
SystemAddress = MmGetSystemAddressForMdlSafe(
UserBufferMdl,
NormalPagePriority);
if (!SystemAddress) {
// deal with error
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
// deal with error
}