delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/13/21:49:06

From: newsham AT aloha DOT net (Tim Newsham)
Subject: Re: How do I open an NT device driver?
13 Oct 1997 21:49:06 -0700 :
Message-ID: <199710140104.PAA01737.cygnus.gnu-win32@haleakala.aloha.net>
References: <343D62D0 DOT 4CC2 AT alacritech DOT com>
Mime-Version: 1.0
To: craft AT alacritech DOT com
Cc: gnu-win32 AT cygnus DOT com

> 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
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019