阅读:1071回复:6
这个问题困绕我很久!指教!
在看驱动的书籍的时候经常看到,代码应该执行在什么级别上!可是有时候一个函数里面的调用的函数应该执行在不同的级别上的,那该怎么办呢!
比如: NTSTATUS AddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT pdo) { // AddDevice NTSTATUS status; PDEVICE_OBJECT fdo; status = IoCreateDevice(DriverObject, sizeof(DEVICE_EXTENSION), NULL, FILE_DEVICE_UNKNOWN, 0, FALSE, &fdo); if (!NT_SUCCESS(status)) return status; PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) (fdo->DeviceExtension); pdx->DeviceObject = fdo; pdx->usage = 1; // locked until RemoveDevice KeInitializeEvent(&pdx->evRemove, NotificationEvent, FALSE); status = IoRegisterDeviceInterface(pdo, &GUID_HELLOWDM, NULL, &pdx->ifname); if (!NT_SUCCESS(status)) { // unable to register interface IoDeleteDevice(fdo); return status; } // unable to register interface IoSetDeviceInterfaceState(&pdx->ifname, TRUE); pdx->LowerDeviceObject = IoAttachDeviceToDeviceStack(fdo, pdo); fdo->Flags &= ~DO_DEVICE_INITIALIZING; fdo->Flags |= DO_BUFFERED_IO; pdx->power = PowerDeviceD0; // device starts in full power state pdx->idle = PoRegisterDeviceForIdleDetection(pdo, SIMPLE_IDLE_CONSERVATION, SIMPLE_IDLE_PERFORMANCE, PowerDeviceD3); return STATUS_SUCCESS; } ____________________________________________________________ Callers of IoCreateDevice must be running at IRQL PASSIVE_LEVEL Callers of this routine must be running at IRQL PASSIVE_LEVEL. Callers of IoRegisterDeviceInterface must be running at IRQL PASSIVE_LEVEL in the context of a system thread Callers of IoSetDeviceInterfaceState must be running at IRQL = PASSIVE_LEVEL in the context of a system thread Callers of IoAttachDeviceToDeviceStack must be running at IRQL <= DISPATCH_LEVEL. Callers of PoRegisterDeviceForIdleDetection must be running at IRQL<DISPATCH_LEVEL. 以上的函数的级别不同啊,可是怎么放到同一个函数中调用呢! |
|
沙发#
发布于:2003-05-10 18:18
那个执行的级别我怎么才能确定呢!
|
|
板凳#
发布于:2003-05-11 08:20
没有大虾来指点指点吗?
|
|
地板#
发布于:2003-05-11 10:01
还有一种情况,在非分页内存中分配一个KTIMER对象,然后在<=DISPATCH_LEVEL级上初始化这个定时器对象!
PKTIMER timer; ASSERT(KeGetCurrentIrql()<=DISPATCH_LEVEL); KeInitializeTimer(timer); 因为在DISPATCH_LEVEL级上不能用分页内存,所以以上的几行代码是运行在DISPATCH_LEVEL级上的,对吗? 根据什么来判定运行在什么级别上呢? |
|
地下室#
发布于:2003-05-12 15:36
没希望也顶一下
|
|
5楼#
发布于:2003-05-13 11:56
walt oney 的书上说:IRQL大多数情况下依赖于“隐含控制”。就是说你不用去管,到时候自然就会在正确地IRQL级上。
具体看看那本书。说得比较详细 |
|
|
6楼#
发布于:2003-05-14 08:48
可以用明确控制啊
|
|
|