From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Newsham To: craft@alacritech.com Cc: gnu-win32@cygnus.com Subject: Re: How do I open an NT device driver? Date: Mon, 13 Oct 1997 19:00:00 -0000 Message-id: <199710140104.PAA01737@haleakala.aloha.net> References: <343D62D0.4CC2@alacritech.com> X-SW-Source: 1997-10/msg00268.html > 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_". 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_".. > 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 [...] 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".