If you create a locked buffer in the following manner:
pMdl = IoAllocateMdl(deviceContext->Descriptor->DataBuffer,
deviceContext->Descriptor->Length,
TRUE,
FALSE,
pIrp);
_try {
MmProbeAndLockPages(pMdl,
KernelMode,
((pIrpStack->MajorFunction ==
IRP_MJ_WRITE) ?
IoWriteAccess :
IoReadAccess));
MmGetSystemAddressForMdl(pMdl);
deviceContext->unlockPages =
TRUE;
}
_except(EXCEPTION_EXECUTE_HANDLER) {
pIrp->IoStatus.Status = status = GetExceptionCode();
pIrp->IoStatus.Information = 0;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return status;
}
Note: pIrp->MdlAddress already contains an allocated MDL so that
IoAllocateMdl will insert the new MDL address into pIrp->MdlAddress->Next.
When the IRP is completed, will the system unlock and release any PTE for
the MDL in Next, or is it needed to then do the reverse:
MmUnlockPages(pIrp->MdlAddress->Next);
IoFreeMdl(pIrp->MdlAddress->Next);
I’m getting BSODs with NO_MORE_SYSTEM_PTES in MmProbeAndLockPages, after the
system runs for a while. Interestingly enough, if the application is doing
only single Read/WriteFileEx, the BSOD does not happen. The BSOD pops when
the application has 4 or more concurrent Read/WriteFileEx active and
pending.
Gary
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