Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AssociatedSystemBuffer Vs MdlAddress Vs UserBuffer

0 views
Skip to first unread message

Hari

unread,
Mar 6, 2004, 6:56:05 AM3/6/04
to
HI,

When to use these three things
Irp->AssociatedIrp->AssociatedSystemBuffer
Irp->MdlAddress
Irp->UserBuffer

Can somebody give some info on this

Also if iam going to allocate from Driver for the Read how can i do that
how that memory can be released.

Thanks

@yahoo.co.in Rushikesh Patil

unread,
Mar 6, 2004, 11:43:08 PM3/6/04
to
Check for DeviceObject->Flags.
1. If DO_BUFFERED_IO is set in Flags use
Irp->AssociatedIrp->AssociatedSystemBuffer.

2. If DO_DIRECT_IO is set in Flags use MdlAddress with
MmGetSystemAddressForMdl(Irp->MdlAddress).

3. If METHOD_NEITHER then Irp->UserBuffer is supposed to be used. But keep
in mind, this is a virtual address in the context of the user mode process
and this may not be always valid in your drivers context. Sometimes higher
level drivers which execute in the context of user mode process, lock this
buffer and create and MdlAddress. So if MdlAddress is not NULL then it is
safe to use that to get the buffer.

> Also if iam going to allocate from Driver for the Read how can i do
that
> how that memory can be released.

I did not understand what do you mean here?


HTH,
Rushikesh.

Hari

unread,
Mar 7, 2004, 11:26:07 PM3/7/04
to
Hi Thanks for the reply
What i asked is
Say i am isssuing a readfile from my ring3 app.
normally we declare a struct there and pass it to the driver.

Struct something
ReadFile(driverhandle,..&struct,sizeof(struct)..)

here the allocation is from ring 3

say if i am want to allocate @ ring 0 ie at the driver.. how can i do that...

@yahoo.co.in Rushikesh Patil

unread,
Mar 8, 2004, 6:27:17 PM3/8/04
to
I am still not very clear with what you want to ask. But I'll try to give
some info see if it answers your question.

In general in Ring 0 you can allocate memory using kernel mode API
'ExAllocatePoolWithTag'.

And when you pass the Ring3 buffer down to kernel, higher level drivers
either need to lock this buffer using MDL structures or need to implement
this using BUFFERED_IO. In BUFFERED_IO, IO Manager allocates a system(Ring
0) buffer and passes it to driver. After IO completion this buffer is
updated with user mode buffer.

HTH,
Rushikesh.


"Hari" <anon...@discussions.microsoft.com> wrote in message
news:B8C87662-548D-4079...@microsoft.com...

@yahoo.co.in Rushikesh Patil

unread,
Mar 9, 2004, 4:05:25 AM3/9/04
to
No, your driver need not allocate any memory for this buffer. Just create a
device object with flag set to DO_BUFFERED_IO and IO manager will do all the
things for you including allocation, copying and freeing.


~rushikesh.
http://rushikeshpatil.8m.com

"HAri" <anon...@discussions.microsoft.com> wrote in message
news:644DC58B-5E78-4273...@microsoft.com...
> Hi thanks,
> That is what i am asking.. shall i allocate something in the kernel mode
and pass it to the ring 3 app.
> After passing to the ring3 whose responsible to clear the memory.
>
> Thanks


0 new messages