Porting IoCallDrver

Dear All,
Please help me to port a request sending to lower bus driver. This is
forward and wait call.
The code is given below

NTSTATUS MyDrvSendIrpSynchronously (PDEVICE_OBJECT DeviceObject,
PIRP Irp
)

{
KEVENT event;
NTSTATUS status;

PAGED_CODE();

KeInitializeEvent(&event, NotificationEvent, FALSE);

IoCopyCurrentIrpStackLocationToNext(Irp);

IoSetCompletionRoutine(Irp,
MyDrvCompletionRoutine,
&event,
TRUE,
TRUE,
TRUE
);

status = IoCallDriver(DeviceObject, Irp);

if (status == STATUS_PENDING) {
KeWaitForSingleObject(&event,
Executive,
KernelMode,
FALSE,
NULL
);
status = Irp->IoStatus.Status;
}

return status;
}


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Assuming that your completion routine does actually set Event, then
where are you calling IoCompleteRequest() ?

At 10:05 01/08/2008, Sreejesh S. Warrier wrote:

Dear All,
Please help me to port a request sending to lower bus driver. This is
forward and wait call.
The code is given below

NTSTATUS MyDrvSendIrpSynchronously (PDEVICE_OBJECT DeviceObject,
PIRP Irp
)

{
KEVENT event;
NTSTATUS status;

PAGED_CODE();

KeInitializeEvent(&event, NotificationEvent, FALSE);

IoCopyCurrentIrpStackLocationToNext(Irp);

IoSetCompletionRoutine(Irp,
MyDrvCompletionRoutine,
&event,
TRUE,
TRUE,
TRUE
);

status = IoCallDriver(DeviceObject, Irp);

if (status == STATUS_PENDING) {
KeWaitForSingleObject(&event,
Executive,
KernelMode,
FALSE,
NULL
);
status = Irp->IoStatus.Status;
}

return status;
}

This is the code.

NTSTATUS DespatchMinorPnP (
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PIO_STACK_LOCATION IrpStack,
PDEV_EXTN DevExtn
)

{
NTSTATUS ntStatus;

PAGED_CODE ();

switch (IrpStack->MinorFunction) {

case IRP_MN_START_DEVICE:

ntStatus = MyDrvSendIrpSynchronously DevExtn->NextLowerDriver,
Irp);

if (NT_SUCCESS(ntStatus)) {

ntStatus = StartMyDO(DeviceData, Irp);
}

Irp->IoStatus.Status = ntStatus ;
IoCompleteRequest (Irp, IO_NO_INCREMENT);

return ntStatus ;
case

thanks&rgrds
sreejeshs

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark S. Edwards
Sent: Friday, August 01, 2008 2:47 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Porting IoCallDrver

Assuming that your completion routine does actually set Event, then
where are you calling IoCompleteRequest() ?

At 10:05 01/08/2008, Sreejesh S. Warrier wrote:

Dear All,
Please help me to port a request sending to lower bus driver. This is
forward and wait call.
The code is given below

NTSTATUS MyDrvSendIrpSynchronously (PDEVICE_OBJECT DeviceObject,
PIRP Irp
)

{
KEVENT event;
NTSTATUS status;

PAGED_CODE();

KeInitializeEvent(&event, NotificationEvent, FALSE);

IoCopyCurrentIrpStackLocationToNext(Irp);

IoSetCompletionRoutine(Irp,
MyDrvCompletionRoutine,
&event,
TRUE,
TRUE,
TRUE
);

status = IoCallDriver(DeviceObject, Irp);

if (status == STATUS_PENDING) {
KeWaitForSingleObject(&event,
Executive,
KernelMode,
FALSE,
NULL
);
status = Irp->IoStatus.Status;
}

return status;
}


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Ok, so you are calling IoCompleteRequest(), it was the obvious bit missing.

I’m afraid I failed telepathy 101, so how about telling us what is
going wrong and where - you have stepped through the code using
windbg, haven’t you ?

Posting code snippets, especially ones where you remove what you
think are irrelevant lines, is not good if you can’t say
approximately where it breaks and how.

At 10:28 01/08/2008, Sreejesh S. Warrier wrote:

This is the code.

NTSTATUS DespatchMinorPnP (
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PIO_STACK_LOCATION IrpStack,
PDEV_EXTN DevExtn
)

{
NTSTATUS ntStatus;

PAGED_CODE ();

switch (IrpStack->MinorFunction) {

case IRP_MN_START_DEVICE:

ntStatus = MyDrvSendIrpSynchronously DevExtn->NextLowerDriver,
Irp);

if (NT_SUCCESS(ntStatus)) {

ntStatus = StartMyDO(DeviceData, Irp);
}

Irp->IoStatus.Status = ntStatus ;
IoCompleteRequest (Irp, IO_NO_INCREMENT);

return ntStatus ;
case

thanks&rgrds
sreejeshs

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark S. Edwards
Sent: Friday, August 01, 2008 2:47 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Porting IoCallDrver

Assuming that your completion routine does actually set Event, then
where are you calling IoCompleteRequest() ?

At 10:05 01/08/2008, Sreejesh S. Warrier wrote:
>Dear All,
>Please help me to port a request sending to lower bus driver. This is
>forward and wait call.
>The code is given below
>
>NTSTATUS MyDrvSendIrpSynchronously (PDEVICE_OBJECT DeviceObject,
> PIRP Irp
> )
>
>{
> KEVENT event;
> NTSTATUS status;
>
> PAGED_CODE();
>
> KeInitializeEvent(&event, NotificationEvent, FALSE);
>
> IoCopyCurrentIrpStackLocationToNext(Irp);
>
> IoSetCompletionRoutine(Irp,
> MyDrvCompletionRoutine,
> &event,
> TRUE,
> TRUE,
> TRUE
> );
>
> status = IoCallDriver(DeviceObject, Irp);
>
> if (status == STATUS_PENDING) {
> KeWaitForSingleObject(&event,
> Executive,
> KernelMode,
> FALSE,
> NULL
> );
> status = Irp->IoStatus.Status;
> }
>
> return status;
>}


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

There also is IoForwardIrpSynchronously, see the WDK docs.

Jan

>Please help me to port a request sending to lower bus driver. This is
>forward and wait call.
>The code is given below

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3317 (20080801) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com