User Mode Server memory question

I have a FSD that operates with a user-mode piece that I need to be able to
pass buffers to and receive buffers from, for reading and writing. I
inherited this thing and it was originally designed to be read-only. I’m
trying to make it do writes too. When a windows client wants to read
something, this user-mode piece allocs buffers and the the FSD can access
those buffers by doing a MmGetSystemAddressForMdlSafe.

My question is how do I get my FSD to allocate buffers and make them
accessable to the user-mode server (The opposite of
MmGetSystemAddressForMdlSafe)? I think I need to pass a virtual address of
the buffer back to the user-mode server, but I don’t know which function
calls can make this happen.

For example, if I am copying a file from NTFS to my FSD, (which in turn
passes it to the user-mode server), is the SystemBuffer address in the IRP
usable? Or should I/must I copy that buffer to another one that the
user-mode piece can access?

Any insight into this would be greatly appreciated - especially a pointer
to an example would be great…!

Thanks - Greg


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Something along the lines below would give you a pointer you can pass
around with IOCTL’s to who needs it. Watch out for the
PROCESS_HAS_LOCKED_PAGES bluescreen if you fail to unlock the pages
before the um application is closed. A suggestion is to watch out for
the IRP_MJ_CLOSE associated with the fileobject of the opened device
you need for passing the pointer to usermode in the first place.

regards,
Anders

DWORD dwSize;
PVOID pMemIWannaAxxInUM;
PMDL pMDL;
PVOID umPtr; // resulting usermode pointer

dwSize = MmSizeOfMdl(pMemoryIWannaAccessInUserMode,SizeOfYourBufferHere);
pMdl = (PMDL) ExAllocatePool( NonPagedPool, dwSize );
pMdl = MmCreateMdl(pMdl, pMemIWannaAxxInUM, SizeOfYourBufferHere);
if ((pMdl->MdlFlags & ( MDL_MAPPED_TO_SYSTEM_VA |
MDL_PAGES_LOCKED |
MDL_SOURCE_IS_NONPAGED_POOL ) ) == 0)
{
MmBuildMdlForNonPagedPool(pMdl);
}
umPtr = MmMapLockedPages(pMdl, UserMode);
Friday, July 13, 2001, 6:00:59 AM, you wrote:

gfc> I have a FSD that operates with a user-mode piece that I need to be able to
gfc> pass buffers to and receive buffers from, for reading and writing. I
gfc> inherited this thing and it was originally designed to be read-only. I’m
gfc> trying to make it do writes too. When a windows client wants to read
gfc> something, this user-mode piece allocs buffers and the the FSD can access
gfc> those buffers by doing a MmGetSystemAddressForMdlSafe.

gfc> My question is how do I get my FSD to allocate buffers and make them
gfc> accessable to the user-mode server (The opposite of
gfc> MmGetSystemAddressForMdlSafe)? I think I need to pass a virtual address of
gfc> the buffer back to the user-mode server, but I don’t know which function
gfc> calls can make this happen.

gfc> For example, if I am copying a file from NTFS to my FSD, (which in turn
gfc> passes it to the user-mode server), is the SystemBuffer address in the IRP
gfc> usable? Or should I/must I copy that buffer to another one that the
gfc> user-mode piece can access?

gfc> Any insight into this would be greatly appreciated - especially a pointer
gfc> to an example would be great…!

gfc> Thanks - Greg

gfc> —
gfc> You are currently subscribed to ntfsd as: xxxxx@flaffer.com
gfc> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Best regards,
Anders mailto:xxxxx@flaffer.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Excellent! Thanks a lot!

Greg


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com