Question about sharing MDL's between processes...

Hi,

I have a Windows 2000 filter driver which wants to share some user data
between two processes. To do this, I am filtering a write operation from
process A which is targeted at a disk volume.

In the past, I have copied the data into a non-paged pool buffer, and set
up an MDL in order to make the data available to process B.

My goal now is to eliminate the data copy. I am trying to do this by
reusing the MDL for the original write operation. I am ensuring that the
MDL does not get freed until process B is done with it. Simple tests do
not show up any problems. However, when I run stress tests (i.e., many
writes), I am seeing issues such as a STATUS_INVALID_ADDRESS exception
being raised when I call MmMapLockedPagesSpecifyCache to get a virtual
address for process B.

Is there a fundamental reason why I should not try and do this? One of
the MDL fields is “process”. I’m concerned that my MDL is tied to a
process, and I should therefore not try and use it in a different process
context.

If anyone has any other guidelines / warnings about sharing MDLs, I would
be grateful to hear them.

Thanks
John

> Is there a fundamental reason why I should not try and do this? One
of

the MDL fields is “process”. I’m concerned that my MDL is tied to a
process, and I should therefore not try and use it in a different
process
context.

You must call MmUnlockPages before the process exits, BSOD otherwise.
IoCompleteRequest will call MmUnlockPages for you.

Max