Subject: Re: How do I open an NT device driver?
From: [email-masked] (Tim Newsham)

13 Oct 1997 21:49:06 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
To: [email-masked]
Cc: [email-masked]

> For example, the NT DDK includes source for a "packet driver"
> which allows a user to connect to a NT protocol driver directly
> from user space.  The included application does this by
> issueing a call to CreateFile with the unicode device name
> "\\.\Packet_Packet_<adaptername>".  Is it possible to perform this
> same function using the GNU library?  If so, I presume I would
> perform an "open" instead of the "CreateFile"?  If so, what device
> name do I use?  I've tried open("\\\\.\\Packet_Packet_<adaptername>"..
> but that didn't work.

you can mount the device and open it after mounting:

    mount '\\.\Packet_Packet_foo' /dev/pack_foo

    in prog.c:
        int fd = open("/dev/pack_foo", O_RDWR);

but if you are going to be using device io controls anyway,
you're best off just sticking with the win32 calls to interact
with the device.  Cygwin does not support arbitrary
ioctl's yet (ever?), just the specific ones implemented in the 
cygwin.dll.  So what you should do is something like:

    #include <windows.h>
    [...]

    HANDLE devh;

    devh = CreateFile("\\\\.\\Packet_Packet_foo", GENERIC_READ | GENERIC_WRITE,
                      0, 0, OPEN_EXISTING, 0);
    if(handle == INVALID_HANDLE_VALUE) { ... }
    [...]
    if(!DeviceIoControl(devh, IOCTL_SOME_CODE, out, outlen,
                       in, inlen, &retlen, 0)) {
        ....
    }

and similarly use ReadFile/WriteFile to do normal IO to the
device.

> Pete

                                            Tim N.
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".