阅读:3110回复:12
IoCallDriver(AttachedToDeviceObject, irp); 函数调用出错 IRQL_NOT_LESS_OR_EQUAL
我通过windbg跟踪出来当调用IoCallDriver(AttachedToDeviceObject, irp); 这个函数以后,会发生 IRQL_NOT_LESS_OR_EQUAL 这个错误。请问各位大侠有什么办法处理!谢谢!
|
|
沙发#
发布于:2007-08-21 20:02
|
|
板凳#
发布于:2007-08-22 14:43
这个问题是不是和内存有关
路过顶一下 |
|
地板#
发布于:2007-08-23 09:12
各位高手别潜水啊,这个事情头痛啊。
而且我调用IoCallDriver(AttachedToDeviceObject, irp);函数的时候不是每次都会失败,是时而好时而不好。 |
|
地下室#
发布于:2007-08-23 09:30
他不是已经说得很清楚了??如果你是自己分配IRP,那么完成里你释放irp,返回MOREPROCESSING告诉系统,这事你别管了。
如果不是你分配的那么完成里COMPLETEREQUEST然后让系统处理。 |
|
|
5楼#
发布于:2007-08-23 13:56
谢谢 楼上的回答!
我是参考KfcIoCompletion做的,代码如下: static NTSTATUS KfcIoCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context) { // // Copy the status information back into the "user" IOSB. // KdPrint(("Sfilter!KfcIoCompletion INTO !!!!!!!!!!!!!!!!!!\n")); *Irp->UserIosb = Irp->IoStatus; // // Set the user event - wakes up the mainline code doing this. // KeSetEvent(Irp->UserEvent, 0, FALSE); // // Free the IRP now that we are done with it. // IoFreeIrp(Irp); // // We return STATUS_MORE_PROCESSING_REQUIRED because this "magic" return value // tells the I/O Manager that additional processing will be done by this driver // to the IRP - in fact, it might (as it is in this case) already BE done - and // the IRP cannot be completed. // KdPrint(("Sfilter!KfcIoCompletion END !!!!!!!!!!!!!!!!!!\n")); return STATUS_MORE_PROCESSING_REQUIRED; } 我想这个完成例程应该对的。 |
|
6楼#
发布于:2007-08-23 14:00
但是问题不是出在这个函数,而是出在下面这个函数
VOID KfcWrite(PFILE_OBJECT FileObject, PLARGE_INTEGER Offset, ULONG Length, PMDL Mdl, PIO_STATUS_BLOCK IoStatusBlock, PDEVICE_OBJECT AttachedToDeviceObject, IN PDEVICE_OBJECT DeviceObject, IN ULONG Jsq) { PIRP irp; KEVENT event; PIO_STACK_LOCATION ioStackLocation; PDEVICE_OBJECT fsdDevice = IoGetRelatedDeviceObject(FileObject); KIRQL irql; NTSTATUS status = STATUS_SUCCESS; // // Set up the event we'll use. // KeInitializeEvent(&event, SynchronizationEvent, FALSE); // Allocate and build the IRP we'll be sending to the FSD. // irp = IoAllocateIrp(AttachedToDeviceObject->StackSize, FALSE); if (!irp) { // // Allocation failed, presumably due to memory allocation failure. // IoStatusBlock->Status = STATUS_INSUFFICIENT_RESOURCES; IoStatusBlock->Information = 0; } irp->MdlAddress = Mdl; irp->UserEvent = &event; irp->UserIosb = IoStatusBlock; irp->Tail.Overlay.Thread = PsGetCurrentThread(); irp->Tail.Overlay.OriginalFileObject= FileObject; irp->RequestorMode = KernelMode; // // Indicate that this is a WRITE operation. // irp->Flags = IRP_WRITE_OPERATION; // // Set up the next I/O stack location. These are the parameters // that will be passed to the underlying driver. // ioStackLocation = IoGetNextIrpStackLocation(irp); ioStackLocation->MajorFunction = IRP_MJ_WRITE; ioStackLocation->MinorFunction = 0; ioStackLocation->DeviceObject = DeviceObject; ioStackLocation->FileObject = FileObject; // // We use a completion routine to keep the I/O Manager from doing // "cleanup" on our IRP - like freeing our MDL. // IoSetCompletionRoutine(irp, KfcIoCompletion, 0, TRUE, TRUE, TRUE); ioStackLocation->Parameters.Write.Length = Length; ioStackLocation->Parameters.Write.ByteOffset = *Offset; ASSERT(AttachedToDeviceObject); ASSERT(irp); IoCallDriver(AttachedToDeviceObject, irp);//跟踪出来这句话常常要出错 ,使得电脑蓝屏 KeWaitForSingleObject(&event, Executive, KernelMode, TRUE, 0); return; } |
|
7楼#
发布于:2007-08-24 13:20
请哪位大侠稍微花一点时间,给小弟看看代码,解答一下,谢谢!
|
|
8楼#
发布于:2007-08-24 14:50
irp = IoAllocateIrp(AttachedToDeviceObject->StackSize, FALSE);
if (!irp) { // // Allocation failed, presumably due to memory allocation failure. // IoStatusBlock->Status = STATUS_INSUFFICIENT_RESOURCES; IoStatusBlock->Information = 0; } irp->MdlAddress = Mdl; irp->UserEvent = &event; irp->UserIosb = IoStatusBlock; irp->Tail.Overlay.Thread = PsGetCurrentThread(); irp->Tail.Overlay.OriginalFileObject= FileObject; irp->RequestorMode = KernelMode; 你自己看这段吧 |
|
|
9楼#
发布于:2007-08-24 14:51
if (!irp) {
的情况下,你还让它继续处理?继续BSOD好了。。。 |
|
|
10楼#
发布于:2007-08-24 15:11
谢谢:ProPlayboy
但是我调试过了,因为我下面有ASSERT(irp); 如果真的是上面的 irp = IoAllocateIrp(AttachedToDeviceObject->StackSize, FALSE); 出现问题也会在下面停下来的。 而且我用了windbg跟踪过了,在 if (!irp) { // // Allocation failed, presumably due to memory allocation failure. // IoStatusBlock->Status = STATUS_INSUFFICIENT_RESOURCES; IoStatusBlock->Information = 0; } 里面设了断点,没有停下来过就蓝屏了。不过这也是一个问题,呵呵,谢谢。 但是不是我想找的问题啊,还有其他原因导致 IRQL_NOT_LESS_OR_EQUAL 错误呢? |
|
11楼#
发布于:2007-08-24 18:02
我有同样的问题在win2k中每次都有
有高人给个解决思路 |
|
12楼#
发布于:2007-08-25 03:39
Re:IoCallDriver(AttachedToDeviceObject, irp);
What is the IRQL when you got BSOD? Better post your crash dump here. |
|