Wine device drivers proposal

Damjan Jovanovic dj015 at
Thu Sep 1 06:09:11 CDT 2005

--- Evgeny F <johnlen at> wrote:

> Damjan Jovanovic <dj015 at> wrote:
> > What "microdriver" are you talking about? Are you 
> > working on STI? For STI, there is a convention for
> > Windows 2000 and onwards, something like
> > \\.\USBSCAN\... (check the STI documentation on
> MSDN).
> > 
> > If it's STI, I have some code; do you want it?
> Yes, it is scanner microdriver.

> > Yes, boundaries absolutely must be preserved,
> because
> > USB bulk reads and writes occur in packets, not as
> > streams. How are you going to extract packets from
> a  
> > stream at the other end?
> There are some new type of socket, present since
> 2.6.4 kernel described 
> in unix(7) manual page - SOC_SEQPACKET, which is
> both 
> connection-oriented and preserves message
> bounderies. Will it work for  
> that purpose

No. Here's why:

Your microdriver has a socket, and wine has a socket
connected to that socket. When wine writes, your
microdriver gets packets, and your microdriver can
extract the boundaries and use the packets. But what
happens when wine wants to read from the socket? How
do you know to read from the scanner and send wine the
packet, and what size that packet should be? You
don't. Reading a USB pipe is a synchronous pull
protocol and sockets use an asynchronous push
protocol. That is why sockets can't be used.

I've given this some thought, and wine needs to be
changed. Drastically. Look at the hacks in
ntdll/cdrom.c, kernel/volume.c and many others - the
current handle system is coming apart at the seams. My
advice is to add handle "types" eg. a file handle,
cdrom handle, device handle, ..., with each handle
being a pointer to something like:

struct Handle {
    DWORD (*ReadFile)(VOID *buffer, DWORD size);
    DWORD (*WriteFile)(VOID *buffer, DWORD size);
    DWORD (*DeviceIoControl)(VOID *buffer, DWORD

and have the ReadFile(), WriteFile() and
DeviceIoControl() simply call the function pointers in
the handle. That way it would be trivial to add a new
device driver type of thing into wine: write new
functions, and change CreateFile() to initialize
handles for that device type with the right
combination of function pointers.

What do you think?

Start your day with Yahoo! - make it your home page 

More information about the wine-devel mailing list