Cygwin:打开字符设备
我需要用userland程序打开在Windows中创建的内核模块 以Cygwin编写;在Windows中,我可以使用Cygwin:打开字符设备,cygwin,Cygwin,我需要用userland程序打开在Windows中创建的内核模块 以Cygwin编写;在Windows中,我可以使用 CreateFile("\\\\.\\deviceName", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) 但在Cygwin如果我尝试使用 open("//deviceName", O_RDWR); 什么也没发生
CreateFile("\\\\.\\deviceName",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL)
但在Cygwin如果我尝试使用
open("//deviceName", O_RDWR);
什么也没发生;我尝试使用“\DosDevices\deviceName”、//deviceName、,
//DosDevices/deviceName等。。。。但我无法打开设备
在Cygwin中有一种方法可以做到这一点,否则我必须在
用户土地申请
编辑:
仅供参考,在内核模块中,链接是在正确调用IoCreateDevice(..)后以这种方式创建的
编辑2:
使用Sysinternals WinObj,我可以正确地看到我的设备
\全球??使用symlink\Device\deviceName确定后,我似乎能够找到它:它是在下面指定的
"/proc/sys/DosDevices/Global/deviceName"
并且可以用
fd = open("/proc/sys/DosDevices/Global/deviceName", O_RDWR);
fd = open("/proc/sys/DosDevices/Global/deviceName", O_RDWR);