Re: Weird DeviceIoControl bug in win2k (blame the Io Manager for that?)

> Bi Chen wrote:

I encountered a weird DeviceIoControl Bug. I wrote a driver that I
have a special need to send large chuck of data to kernel mode driver
but receive some small piggy-pack data in return. The driver is opened
with GENERIC_READ | GENERIC_WRITE flag.

This is not a bug. With both METHOD_XX_DIRECT buffering methods, the
system creates a system buffer for the so-called “input” buffer and an
MDL for the so-called “output” buffer. The difference between the two,
as described in ch. 9 of my WDM book and many other places, is that
METHOD_IN_DIRECT requires read access to the “output” buffer and
METHOD_OUT_DIRECT requires write access. The “IN” and “OUT” parts of the
names are the opposite of common sense: use METHOD_IN_DIRECT when data
moves from memory to the driver and thence to the device; the “output”
buffer is really a second “input” buffer in this case. Use
METHOD_OUT_DIRECT when data moves from the device to the driver and
thence to memory.

Oops. I see other people have answered the question too. Well, I went to
the trouble of typing it, so I’ll post it anyway.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars
Check out our schedule at http://www.oneysoft.com