阅读:1137回复:2
在DISPATCH_LEVEL级该怎么办?
static NTSTATUS fnCompletionRoutineWithEvent (
IN PDEVICE_OBJECT DeviceObject, IN PIRP pIrp, IN PVOID Context ) { PKEVENT pKEvent = (PKEVENT)Context; KeSetEvent( pKEvent, IO_NO_INCREMENT, FALSE); return STATUS_MORE_PROCESSING_REQUIRED; } NTSTATUS MaHidInit( HANDLE *pHandle) { NTSTATUS ntStatus = STATUS_UNSUCCESSFUL; PDEVICE_OBJECT pDeviceObject; PFILE_OBJECT pFileObject; UNICODE_STRING usName; WCHAR wsBuffer[ 128]; if( KeGetCurrentIrql() == PASSIVE_LEVEL) { . . . ntStatus = IoGetDeviceObjectPointer( &usName, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, &pFileObject, &pDeviceObject ); if (ntStatus == STATUS_SUCCESS) { . . . PIRP pIrp = IoAllocateIrp( pDeviceObject->StackSize + 1, FALSE); if ( pIrp ) { . . . KEVENT eventComplete; if( KeGetCurrentIrql() == PASSIVE_LEVEL) { KeInitializeEvent( &eventComplete, NotificationEvent, FALSE); IoSetCompletionRoutine( pIrp, fnCompletionRoutineWithEvent, eventComplete, TRUE, TRUE, TRUE); ntStatus = IoCallDriver( pDeviceObject, pIrp); if( ntStatus == STATUS_PENDING ) { if( KeGetCurrentIrql() == PASSIVE_LEVEL) { LARGE_INTEGER liWait; liWait.QuadPart = -30000000; ntStatus = KeWaitForSingleObject( &eventComplete, UserRequest, KernelMode, TRUE, &liWait); if( ntStatus == STATUS_SUCCESS) ntStatus = pIrp->IoStatus.Status; } } } } if( ntStatus == STATUS_SUCCESS) DbgPrint(\"[%x][%x]\\n\", hidCollectionInfo.VendorID,hidCollectionInfo.ProductID); } return ntStatus; } 以上的代码都有判断式判别是否处于PASSIVE_LEVLE级, 如果是在DISPATCH_LEVEL级 (比如说在程序最前端加上: KIRQL oldirql; ASSERT( KeGetCurrentIrql( ) <= DISPATCH_LEVEL); KeRaiseIrql( DISPATCH_LEVEL, &oldirql); 强迫提高至DISPATCH_LEVEL) 要怎么改才能使这段代码正常运作呢? |
|
沙发#
发布于:2005-04-03 09:31
不司已经清楚了,在PASSIVE_LEVEL上就不要执行他们.
|
|
|
板凳#
发布于:2005-04-03 23:57
不司已经清楚了,在PASSIVE_LEVEL上就不要执行他们. 这么说好了: 在DISPATCH_LEVEL级怎么得到HID装置的VID和PID? 小弟我对驱动还是一知半解的, 实在不知道在DISPATCH_LEVEL级程序是怎么运行的! |
|