Sharing READONLY memory between driver and Application

Hi all,

I’ve read and followed the instructions found at “A Common Topic Explained - Sharing Memory Between Drivers and Applications” (

I would like, however, to control the protection on the shared memory so that the application can only read from it.
I’ve found ‘MmProtectMdlSystemAddress’, but it fails on MDLs not mapped to KernelMode (by calling MmMapLockedPagesSpecifyCache(pmdl, KernelMode, …)).
Is there any way to control the protection of virtual memory mapped to UserMode?

In my app, I’ve tried calling VirtualQuery which returns the correct information, but I am unable to change the protection on that same memory using VirtualProtect (returns ERROR_INVALID_ADDRESS).

thanks for any input you may have,