Hi,
I’m now wondering something about MDL…
Now I’ve a buffer named buf, which is allocated by ExAllocatePool.
buf = ExAllocatePool(…);
Next, I use a MDL to describe this buffer and lock the pages related to this buffer:
mdl = IoAllocateMdl(…);
MmProbeAndLockPages(mdl, …);
Now comes something I’m not very sure.
If I somewhere use ExFreePool to free buf, and again use the memory described by mdl in some other places, to say in another thread, shall I get an access violation?
// in one thread or one place in the driver
ExFreePool(buf);
// in another thread or another place in the same driver, and after ExFreePool above
buf2 = MmGetSystemAddressForMdlSafe(mdl, …);
… …// use buf2
MmUnlockPages(mdl, …)
IoFreeMdl(…);
I’ve tried this, and got no access violation.
To my mind, the MmProbeAndLockPages function will lock the physical pages related to buf memory, so even we free buf, we still could access the locked pages. This would be the same regardless of what type the buf is: PagedPool or NonPagedPool.
Could someone tell me whether my analysis is all right?
Thanks in advance.