PAGE FAULT in Completion Routine

Hi,

I am developing a serial filter driver on NT 4.0 I am allocating an IRP
with IoAllocateIrp and set the completion routine with
IoSetCompletionRoutine.

In the completion routine, when I try to read device extension from the
device object, the system crahes with page fault (PAGE FAULT AT IRQL > 1
Va 28, IRQL 2).
It’s just plain READ operation :
deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

My question is :- Is it forbidden to use the Device Object passed in the
completion routine?
It’s unused even in all samples in the DDK.

Please comment.

Regards,
Abhijit


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> In the completion routine, when I try to read device extension from the

device object, the system crahes with page fault (PAGE FAULT AT IRQL > 1
Va 28, IRQL 2).
It’s just plain READ operation :
deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

My question is :- Is it forbidden to use the Device Object passed in the
completion routine?

You must allocate an additional IRP stack location for this and call
IoSetNextIrpStackLocation just after IoAllocateIrp.
Otherwise, the DeviceObject parameter to the completion routine will be
NULL.
Irp and Context parameters, though, are always valid.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Check the value of the DeviceObject. It will be NULL in this case, which is
why the page fault is occuring.

Actually the device object pointer passed to the completion routine is the
value
left in the I/O stack location’s DeviceObject pointer. Since you are
allocating the IRP, set the DeviceObject field in the I/O stack location to
point to the actual device object. if you do this, then you will get back
the same device object in the completion routine.

The normal method is to pass the device object/device extension as a context
parameter to IoSetCompletionRoutine so that you can access the device
extension in the completion routine.

HTH
Venky

–>-----Original Message-----
–>From: xxxxx@lists.osr.com
–>[mailto:xxxxx@lists.osr.com]On Behalf Of
–>xxxxx@controlnet.co.in
–>Sent: Tuesday, September 25, 2001 12:00 AM
–>To: NT Developers Interest List
–>Subject: [ntdev] PAGE FAULT in Completion Routine
–>
–>
–>Hi,
–>
–>I am developing a serial filter driver on NT 4.0 I am allocating an IRP
–>with IoAllocateIrp and set the completion routine with
–>IoSetCompletionRoutine.
–>
–>In the completion routine, when I try to read device extension from the
–>device object, the system crahes with page fault (PAGE FAULT AT
–>IRQL > 1
–>Va 28, IRQL 2).
–>It’s just plain READ operation :
–>deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
–>
–>My question is :- Is it forbidden to use the Device Object passed in the
–>completion routine?
–>It’s unused even in all samples in the DDK.
–>
–>Please comment.
–>
–>Regards,
–>Abhijit
–>
–>—
–>You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
–>To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

An easier way is to pass in the pointer to DeviceExtension using the context
parameter of the CompleteRequest function…

  • Dennis

Dennis Merrill
Embedded Systems Engineer
Thermo Nicolet Corporation

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Tuesday, September 25, 2001 8:31 AM
To: NT Developers Interest List
Subject: [ntdev] Re: PAGE FAULT in Completion Routine

In the completion routine, when I try to read device extension from the
device object, the system crahes with page fault (PAGE FAULT AT IRQL > 1
Va 28, IRQL 2).
It’s just plain READ operation :
deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

My question is :- Is it forbidden to use the Device Object passed in the
completion routine?

You must allocate an additional IRP stack location for this and call
IoSetNextIrpStackLocation just after IoAllocateIrp.
Otherwise, the DeviceObject parameter to the completion routine will be
NULL.
Irp and Context parameters, though, are always valid.

Max


You are currently subscribed to ntdev as: xxxxx@thermonicolet.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Abhijit,
The deviceobject that comes along with the
completion routine is Device Object of the lower
driver and NOT your driver. So What you need to do is,
pass the address of your DeviceExtension to the
“context” parameter in the IoSetCompletionRoutine and
then in the completion routine typecast the context
parameter to DeviceExtension and then use.

Cheers,
Jay

— xxxxx@controlnet.co.in wrote:

Hi,

I am developing a serial filter driver on NT 4.0 I
am allocating an IRP
with IoAllocateIrp and set the completion routine
with
IoSetCompletionRoutine.

In the completion routine, when I try to read device
extension from the
device object, the system crahes with page fault
(PAGE FAULT AT IRQL > 1
Va 28, IRQL 2).
It’s just plain READ operation :
deviceExtension = (PDEVICE_EXTENSION)
DeviceObject->DeviceExtension;

My question is :- Is it forbidden to use the Device
Object passed in the
completion routine?
It’s unused even in all samples in the DDK.

Please comment.

Regards,
Abhijit


You are currently subscribed to ntdev as:
xxxxx@yahoo.com
To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com