From: mudehuai on
Hi:

I am new to driver and want to modify the bulkusb example to talk to our
device.

The problem is that when the driver receives the raw data from the user
space, I need to add a header to it before sending the data to the device.

In BulkUsb_DispatchReadWrite(), it calls the IoBuildPartialMdl to map the
user mdl directly to the URB mdl allocated by the driver. In my case, i want
the new URB mdl to include a header and then the data described by the user
mdl.

I cannot figure out how to do this with MDL manipulation.

I thought about allocate a buffer in the driver and fill it with the header
and the data described by the user mdl. Then create the new URB mdl from this
buffer.

However, it would be great if I can avoid this extra copy with MDL
manipulation.

Thanks in advance.

cheers,
From: eagersh on
On Nov 8, 9:59 am, mudehuai <mudeh...(a)discussions.microsoft.com>
wrote:
> Hi:
>
> I am new to driver and want to modify the bulkusb example to talk to our
> device.
>
> The problem is that when the driver receives the raw data from the user
> space, I need to add a header to it before sending the data to the device..
>
> In BulkUsb_DispatchReadWrite(), it calls the IoBuildPartialMdl to map the
> user mdl directly to the URB mdl allocated by the driver.  In my case, i want
> the new URB mdl to include a header and then the data described by the user
> mdl.
>
> I cannot figure out how to do this with MDL manipulation.
>
> I thought about allocate a buffer in the driver and fill it with the header
> and the data described by the user mdl. Then create the new URB mdl from this
> buffer.
>
> However, it would be great if I can avoid this extra copy with MDL
> manipulation.
>
> Thanks in advance.
>
> cheers,

The easiest way is to allocate buffer with extra space in user
application program. In this case you don't need to manipulate with
MDL.
It is hard in your case to merge two Mdl's.

Igor Sharovar

From: Tim Roberts on
mudehuai <mudehuai(a)discussions.microsoft.com> wrote:
>
>I am new to driver and want to modify the bulkusb example to talk to our
>device.
>
>The problem is that when the driver receives the raw data from the user
>space, I need to add a header to it before sending the data to the device.
>
>In BulkUsb_DispatchReadWrite(), it calls the IoBuildPartialMdl to map the
>user mdl directly to the URB mdl allocated by the driver. In my case, i want
>the new URB mdl to include a header and then the data described by the user
>mdl.

Does it have to be part of the same transfer? Can you create a new URB
with just the header, and then forward the original URB unchanged?

>I cannot figure out how to do this with MDL manipulation.

You can't do it with MDL manipulation.

>I thought about allocate a buffer in the driver and fill it with the header
>and the data described by the user mdl. Then create the new URB mdl from this
>buffer.
>
>However, it would be great if I can avoid this extra copy with MDL
>manipulation.

Nope. If you can't send it as two transfers, then you'll need to copy.
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.