Everhart, Glenn From: DavidJ@Charismac.com Sent: Monday, January 25, 1999 1:23 PM To: ntdev@atria.com Subject: [ntdev] Allocating Irps Hi: I have a filter driver that sits on top of a hard drive. I am doing my own I/O by creating my own IRPs. What is happening it that it is working fine for the first 1000 Irps and then it is the blue screen of death with the error PAGE_FAULT_IN_NON_PAGED_AREA. At first I was using IoAllocateIrp and it was my contention that I was running out of memory and the 1000 Irp was the culprit. So I then allocated a block of memory in the driver entry and set up a linked list that would allocate and free Irps to the list. This did not change the result at all, everytime after the 1000 Irp is sent it would crash. So then I thought I would set up my Irp and release it and then just send the original one that was intercepted. This did not change the results on the 1000 irp it crashed. Then just trying scenarios for no reason I found the problem. The problem is when I set data into the stack locations of the Irp that I have allocated, such as MajorFunction, any of the parameters and the device object. Here is the following code segment that is failing after it has been run 1000 times. Note that what is passed in is only the DeviceObject and the Irp. Thanks David Jones CCHAR buffer[32]; PDEVICE_EXTENSION deviceExtension; PIO_STACK_LOCATION currentIrpStack; PIO_STACK_LOCATION nextIrpStack; PIO_STACK_LOCATION newCurrentIrpStack; PIO_STACK_LOCATION newNextIrpStack; PIRP currentIrp; PIRP newIrp; NTSTATUS status; static int count = 1; // Debug purposes only KdPrint(("I am in the write to mirror routine\n")); deviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension; currentIrpStack = IoGetCurrentIrpStackLocation( Irp ); nextIrpStack = IoGetNextIrpStackLocation( Irp ); nextIrpStack->Parameters.Others.Argument1 = (PVOID)1; newIrp = AnubisAllocateIrp( DeviceObject->StackSize, TRUE ); if ( newIrp == NULL ) return STATUS_BAD_DEVICE_TYPE; sprintf( buffer, "The Number of Irp allocated is %d\n", count ); KdPrint((buffer)); count++; newIrp->MdlAddress = Irp->MdlAddress; if ( count == 1000 ) KdPrint(("Dave I am here at 1000\n")); IoSetNextIrpStackLocation( newIrp ); newCurrentIrpStack = IoGetCurrentIrpStackLocation( newIrp ); newCurrentIrpStack->MajorFunction = IRP_MJ_WRITE; // These four statments will cause this to fail but if commented out it works fine newCurrentIrpStack->Parameters.Read.Length = currentIrpStack->Parameters.Read.Length; // newCurrentIrpStack->Parameters.Read.ByteOffset = currentIrpStack->Parameters.Read.ByteOffset; // newCurrentIrpStack->DeviceObject = deviceExtension->TargetDeviceObject; newNextIrpStack = IoGetNextIrpStackLocation( newIrp ); newIrp->AssociatedIrp.MasterIrp = Irp; // *newNextIrpStack = *newCurrentIrpStack; // This statment will also cause it to fail AnubisFreeIrp( newIrp ); *nextIrpStack = *currentIrpStack; IoSetCompletionRoutine( Irp, WriteCompletion, deviceExtension, TRUE, TRUE, TRUE ); status = IoCallDriver( deviceExtension->TargetDeviceObject, Irp ); return status; // IoSetCompletionRoutine( newIrp, // IoCompleteAssociated, // deviceExtension, // TRUE, // TRUE, // TRUE ); // // status = IoCallDriver( deviceExtension->TargetDeviceObject, newIrp ); // return status; return STATUS_SUCCESS; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]