DIRECT_IO IOCTL ,driver gets request as a BUFFERED_IO, sometimes ...

This question has been asked and discussed on the list before.

I have a scenario which is similar, but baffling me.

I am using a METHOD_OUT_DIRECT ioctl to share memory between the device driver and
the user app.

This method is discussed in detail in the Microsoft Knowledge Base Article - Q191840
HOWTO: Share Memory Between User Mode and Kernel Mode

http://support.microsoft.com/default.aspx?scid=kb;en-us;q191840

also in an osr article
http://www.osr.com/ntinsider/2000/sharing_memory.htm

The memory is shared for the lifetime of the user app.

The problem is that when the app is debugged (using the debugger in visual studio or any other debugger), everything works perfectly,
when the app is executed, the driver gets a buffered copy of the memory.

I know the data is buffered because the user app makes changes to the memory, and the driver does not see the changes,
and vice versa.

I have tried METHOD_IN_DIRECT and METHOD_OUT_DIRECT with different combinations of inbuffer and outbuffer.

OS is win 2000.

Many thanks in advance, if you can help steer me in the correct direction here.

Regards

David “Digby” Richards
xxxxx@avtransfer.net
AV Media

“digby” wrote in message news:xxxxx@ntdev…

> I am using a METHOD_OUT_DIRECT ioctl to share memory between the device
driver and
> the user app.
>
>
>The problem is that when the app is debugged (using the debugger in visual
studio or any other debugger),
> everything works perfectly,
> when the app is executed, the driver gets a buffered copy of the memory.
>

Sorry, Digby. What you’re saying that you’re observing is impossible, so
you’ve got some sort of bug.

On the IOCTL… which buffer are you trying to use?

Please explain to us in a bit more detail about where this memory is that
you’re trying to share: In a named section, from non-paged pool,
whatever…

You can prove to yourself that the buffer is the same: Just debug the driver
(instead of the app!). Which physical page is being mapped? Likewise,
check the same for the app (from the kernel debugger). Voila! You find the
problem…

Peter
OSR

> Subject: Re: DIRECT_IO IOCTL ,driver gets request as a BUFFERED_IO,
sometimes …

From: “Peter Viscarola”

> >The problem is that when the app is debugged (using the debugger in
visual
> studio or any other debugger),
> > everything works perfectly,
> > when the app is executed, the driver gets a buffered copy of the memory.
> >
>
> Sorry, Digby. What you’re saying that you’re observing is impossible, so
> you’ve got some sort of bug.

You were correct. It was an (unbelievably stupid) bug in the user app.

Thanks Peter

Digby
David “Digby” Richards
xxxxx@avtransfer.net
Software Development Manager
AV Media www.avtransfer.net
Unit 2, 1 Skyline Place,
Frenchs Forest NSW 2086 Australia

Unit 2, 1 Skyline Place,
Frenchs Forest NSW 2086
Australia