Windows驱动开发学习记录-应用层打开设备符号链接在不同系统的区别

  • 驱动层创建
{
    ......

    UNICODE_STRING usMyControlDevice = RTL_CONSTANT_STRING(MY_CONTROL_DEVICE_NAME);
		ntStatus = IoCreateDevice(pDriverObject, NULL, &usMyControlDevice, 0, 0, false, &g_ControlDeviceOjbect);
		if (!NT_SUCCESS(ntStatus))
		{
			KDPRINTEX("【TDIFilter】", "Create Control Device Error \r\n");
			break;
		}
    ......
}

基中MY_CONTROL_DEVICE_NAME定义为:

#define MY_CONTROL_DEVICE_NAME	(L"\\Device\\TDIFilter")

这个名字在XP 32位及 Win7 64位以上都成立  

  • 客户端

客户端打开调用的CreateFile

{
    ......
    m_hLogDevice = CreateFile(MY_CONTROL_DEVICE_SYMBOL_LINK, GENERIC_READ | GENERIC_WRITE,
		0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, 0);
    ......
}

 基中MY_CONTROL_DEVICE_SYMBOL_LINK的定义稍有不同

XP中为

#define MY_CONTROL_DEVICE_SYMBOL_LINK_XP	(L"\\\\.\\TDIFilter")

Win7以上为

#define MY_CONTROL_DEVICE_SYMBOL_LINK	(L"\\\\??\\TDIFilter") 

两种差别是 是个是  \\.\XXXX 另一个是 \\??\XXXX

posted @ 2023-02-27 16:49  禁锢在时空之中的灵魂  阅读(38)  评论(0编辑  收藏  举报