-
-
[求助]在学习驱动编程过程中遇到的一个问题
-
发表于:
2009-12-15 17:32
3744
-
01 NTSTATUS AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
02 {
03 PDEVICE_OBJECT fido;
04 NTSTATUS status = IoCreateDevice(DriverObject,
05 sizeof(DEVICE_EXTENSION),
06 NULL,
07 FILE_DEVICE_UNKNOWN,
08 0,
09 FALSE,
10 &fido);
11 if (!NT_SUCCESS(status))
12 return status;
13 PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fido->DeviceExtension;
14 _ _try
15 {
16 pdx->DeviceObject = fido;
17 pdx->Pdo = pdo;
18 PDEVICE_OBJECT fdo = IoAttachDeviceToDeviceStack(fido, pdo);
19 pdx->LowerDeviceObject = fdo;
20 fido->Flags |= fdo->Flags & (DO_DIRECT_IO|DO_BUFFERED_IO);
21 fido->Flags |= DO_POWER_PAGABLE
22 fido->DeviceType = fdo->DeviceType;
23 fido->Characteristics = fdo->Characteristics;
24 fido->Flags &= ~DO_DEVICE_INITIALIZING;
25 }
26 _ _finally
27 {
28 if (!NT_SUCCESS(status))
29 IoDeleteDevice(fido);
30 }
31 return status;
32 }
33
疑问:
1:在NT模式的过滤驱动编程中,可以通过IoGetDeviceObjectPoint得到想要过滤设备的设备对象指针,然后IoAttachDeviceToDeviceStack,进行挂载。而在WDM下,直接挂载在AddDevice传进来的pdo上,这是WDM的通用模式吗?
假如我想将fido挂在鼠标设备上,怎么确定AddDevice传进的pdo不是键盘设备呢?
,难道是inf安装文件保证传入的设备对象正是需要的????
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!