Windows 2000 driver, DPC for ISR without an IRP - memory access error

Hello,

I’m writing a driver which would notify the user-mode application when the
hw device interrupt occurs - and I intend to do the notification by using
an event shared between the application and the driver. In the driver I
want to signal the event in a DPC routine (DPCForIsr) that would be
‘fired’ from the ISR.
However, there is a problem: in my driver, when the interrupt occurs,
usually there is no current IRP, that is DEVICE_OBJECT->CurrentIrp is
NULL. This is because none of IRPs the driver handles is waiting for the
interrupt - they just initiate the hardware operation and are completed
immediately. But in the ISR, when I request the DPC for ISR and pass NULL
as IRP, system crashes with a memory error (some code is trying to access
memory at 0xNULL). Is there a requirement that IRP pointer passed to
IoRequestDPC() should be non-NULL? And how should I invoke the DPC even if
there is no IRP waiting for completion? Thanks for any help in advance.

(A bit wider question: how can I signal a shared event when the interrupt
occurs?)

Regards,
Rafal Gwizdala

  1. Concerning the NULL Irp pointer within the ISR, see Q179254
    ( at http://www.microsoft.com/hwdev/driver/KB-drv.asp )

  2. There are some ways to fire an event from kernel to usermode,
    one more secure than the other. In neither case, an IRP is
    involved. Be careful, you may not switch context within
    a DPC, thus your SetEvent may not hold ( yield ).
    See also Q262947.

----- Original Message -----
From: “Rafal Gwizdala”
To: “NT Developers Interest List”
Sent: Friday, January 17, 2003 10:22 AM
Subject: [ntdev] Windows 2000 driver, DPC for ISR without an IRP - memory
access error

> Hello,
>
> I’m writing a driver which would notify the user-mode application when the
> hw device interrupt occurs - and I intend to do the notification by using
> an event shared between the application and the driver. In the driver I
> want to signal the event in a DPC routine (DPCForIsr) that would be
> ‘fired’ from the ISR.
> However, there is a problem: in my driver, when the interrupt occurs,
> usually there is no current IRP, that is DEVICE_OBJECT->CurrentIrp is
> NULL. This is because none of IRPs the driver handles is waiting for the
> interrupt - they just initiate the hardware operation and are completed
> immediately. But in the ISR, when I request the DPC for ISR and pass NULL
> as IRP, system crashes with a memory error (some code is trying to access
> memory at 0xNULL). Is there a requirement that IRP pointer passed to
> IoRequestDPC() should be non-NULL? And how should I invoke the DPC even if
> there is no IRP waiting for completion? Thanks for any help in advance.
>
> (A bit wider question: how can I signal a shared event when the interrupt
> occurs?)
>
> Regards,
> Rafal Gwizdala
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Hi,

Thanks for suggestion, but I already knew why the Current IRP was NULL. My
problem is that when it is NULL I get error after requesting a DPC. Maybe
there’s a problem in my driver, not in Windows - will keep searching…

Regards,
Rafal Gwizdala

----- Original Message -----
From: “Christiaan Ghijselinck”
To: “NT Developers Interest List”
Sent: Friday, January 17, 2003 11:13 AM
Subject: [ntdev] Re: Windows 2000 driver, DPC for ISR without an IRP -
memory access error

>
>
>
>
> 1. Concerning the NULL Irp pointer within the ISR, see Q179254
> ( at http://www.microsoft.com/hwdev/driver/KB-drv.asp )
>
> 2. There are some ways to fire an event from kernel to usermode,
> one more secure than the other. In neither case, an IRP is
> involved. Be careful, you may not switch context within
> a DPC, thus your SetEvent may not hold ( yield ).
> See also Q262947.
>

Queueing DPC’s with “KeInsertQueueDpc” do not require to have an IRP
around.
The behaveour and mechanism is almost identical.

----- Original Message -----
From: “Rafal Gwizdala”
To: “NT Developers Interest List”
Sent: Friday, January 17, 2003 11:42 AM
Subject: [ntdev] Re: Windows 2000 driver, DPC for ISR without an IRP -
memory access error

> Hi,
>
> Thanks for suggestion, but I already knew why the Current IRP was NULL. My
> problem is that when it is NULL I get error after requesting a DPC. Maybe
> there’s a problem in my driver, not in Windows - will keep searching…
>
> Regards,
> Rafal Gwizdala
>
> ----- Original Message -----
> From: “Christiaan Ghijselinck”
> To: “NT Developers Interest List”
> Sent: Friday, January 17, 2003 11:13 AM
> Subject: [ntdev] Re: Windows 2000 driver, DPC for ISR without an IRP -
> memory access error
>
>
> >
> >
> >
> >
> > 1. Concerning the NULL Irp pointer within the ISR, see Q179254
> > ( at http://www.microsoft.com/hwdev/driver/KB-drv.asp )
> >
> > 2. There are some ways to fire an event from kernel to usermode,
> > one more secure than the other. In neither case, an IRP is
> > involved. Be careful, you may not switch context within
> > a DPC, thus your SetEvent may not hold ( yield ).
> > See also Q262947.
> >
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Neither do I find it back,

Sorry Mark , my smile is already up again.

----- Original Message -----
From: “James A”
To: “NT Developers Interest List”
Sent: Friday, January 17, 2003 4:40 PM
Subject: [ntdev] Re: Windows 2000 driver, DPC for ISR without an IRP -
memory access error

>
> You can find it in ntddk.h or wdm.h
>
> >From: “Christiaan Ghijselinck”
> >Reply-To: “NT Developers Interest List”
> >To: “NT Developers Interest List”
> >Subject: [ntdev] Re: Windows 2000 driver, DPC for ISR without an IRP -
> >memory access error
> >Date: Fri, 17 Jan 2003 15:50:10 +0100
> >
> >
> >Mark,
> >
> >
> >I am upset ( and even a bit angry ). There is no DDK documentation that
> >mentions your
> >“#define IoRequestDpc”. The DDK documentation describes even a
different,
> >more restrictive behaviour for the IoRequestDpc and a suggestion about
the
> >use
> >of KeInsertQueueDpc.
> >
> >If you have found this define at ReactOS, you could be far from the
> >Microsoft reality …
> >
> >
> >----- Original Message -----
> >From: “Mark Roddy”
> >To: “NT Developers Interest List”
> >Sent: Friday, January 17, 2003 3:12 PM
> >Subject: [ntdev] Re: Windows 2000 driver, DPC for ISR without an IRP -
> >memory access error
> >
> >
> > > >
> > > > Queueing DPC’s with “KeInsertQueueDpc” do not require to have an IRP
> > > > around.
> > > > The behaveour and mechanism is almost identical.
> > > >
> > >
> > > #define IoRequestDpc( DeviceObject, Irp, Context ) ( <br>> > > KeInsertQueueDpc( &(DeviceObject)->Dpc, (Irp), (Context) ) )
> > >
> > > I don’t think that is the answer. The Irp is not required.
> > >
> > > ===========================
> > > Mark Roddy
> > > Consultant, Microsoft DDK MVP
> > > Hollis Technology Solutions
> > > xxxxx@hollistech.com
> > > www.hollistech.com
> > > 603-321-1032
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> > > To unsubscribe send a blank email to xxxxx@lists.osr.com
> > >
> >
> >
> >
> >—
> >You are currently subscribed to ntdev as: xxxxx@hotmail.com
> >To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> _________________________________________________________________
> Help STOP SPAM: Try the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

> (A bit wider question: how can I signal a shared event when the
interrupt

occurs?)

You cannot, ISRs can neither signal events nor communicate with user
mode. They are for drivers only.

Max