public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* How do I open an NT device driver?
@ 1997-10-09 15:57 Peter Craft
  1997-10-13 19:00 ` Tim Newsham
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Craft @ 1997-10-09 15:57 UTC (permalink / raw)
  To: gnu-win32

I'm trying to issue an open to a simple NT device driver using
the cygwin developement environment and I can't figure
out how to do it..

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.

Sorry if this is a stupid question, but I'm a bit stumped here.

Thanks very much,

Pete
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How do I open an NT device driver?
  1997-10-09 15:57 How do I open an NT device driver? Peter Craft
@ 1997-10-13 19:00 ` Tim Newsham
  0 siblings, 0 replies; 2+ messages in thread
From: Tim Newsham @ 1997-10-13 19:00 UTC (permalink / raw)
  To: craft; +Cc: gnu-win32

> 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@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-10-13 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-09 15:57 How do I open an NT device driver? Peter Craft
1997-10-13 19:00 ` Tim Newsham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).