(Win 2000)
From the user app, I'm calling my kernel driver to fill the given
buffer with some data. The IOCTL is of type METHOD_OUT_DIRECT. The
buffer size can be from 128K to about 2MB. From the driver, I use
MmGetSystemAddressForMdlSafe() to get the address of the buffer. The
DDK doc says that the address is valid because it has been locked by
the manager already.
This has been working well for almost all the cases, but when I run
the app/driver together with a test program that creates a lot of
threads and takes up almost all of the system memory, I get a page
fault on the user buffer (without Soft-Ice, the sytem just reboots).
I've been told that when the OS is low on resources and experiences a
lot of page stealing, my "safe" buffer address may no longer be valid.
How can I be sure that the address MmGetSystemAddressForMdlSafe()
returns is valid? Would it help calling MmProbeAndLockPages()? I
don't mind if the OS fails to give me a valid address while the system
is very busy and low on memory, I'm just trying to avoid the reboot.