Sending a Irp request crashes

Hello everyone,

I am trying to figure out why a crash occurs when I am trying to send a
Irp to a audio driver from a upper filter driver sitting above it.
Since I havn’t done this before I was wondering if there is anything
obvious that will cause the crash.

PIRP Irp;
KEVENT event;
IO_STATUS_BLOCK iosb;
KeInitializeEvent(&event, NotificationEvent, FALSE);

KSPROPERTY ksP;
ksP.Set = KSPROPSETID_Audio;
ksP.Id = KSPROPERTY_AUDIO_POSITION;
ksP.Flags = KSPROPERTY_TYPE_GET;
KSAUDIO_POSITION ksAudio;

Irp = IoBuildDeviceIoControlRequest(IOCTL_KS_PROPERTY, pAudioDeviceParent->LowerDeviceObject,
&ksP, sizeof ksP,&ksAudio, sizeof ksAudio, FALSE,&event,&iosb);
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
stack->FileObject = FileObject; // FILE OBJECT FROM MJ_CREATE for the audio pin.

status = IoCallDriver(pAudioDeviceParent->DeviceObject, Irp); // CRASHES HERE
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = iosb.Status;
}

So is there anything in that above that stick out like dog balls or does
anyone have any tips?
p.s. This code is ranned in created thread.

Cheers
Obble.

If you want the lower stack to see the file object, this
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
stack->FileObject = FileObject; // FILE OBJECT FROM MJ_CREATE for the audio pin.

Should be
PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);

Since there is no current irp stack location for an irp that you allocate yourself

d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of NCH Obble Smith
Sent: Wednesday, December 02, 2009 2:28 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Sending a Irp request crashes

Hello everyone,

I am trying to figure out why a crash occurs when I am trying to send a Irp to a audio driver from a upper filter driver sitting above it.
Since I havn’t done this before I was wondering if there is anything obvious that will cause the crash.

PIRP Irp;
KEVENT event;
IO_STATUS_BLOCK iosb;
KeInitializeEvent(&event, NotificationEvent, FALSE);

KSPROPERTY ksP
ksP.Set = KSPROPSETID_Audio;
ksP.Id = KSPROPERTY_AUDIO_POSITION;
ksP.Flags = KSPROPERTY_TYPE_GET;
KSAUDIO_POSITION ksAudio;

Irp = IoBuildDeviceIoControlRequest(IOCTL_KS_PROPERTY, pAudioDeviceParent->LowerDeviceObject,
&ksP, sizeof ksP,&ksAudio, sizeof ksAudio, FALSE,&event,&iosb);
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
stack->FileObject = FileObject; // FILE OBJECT FROM MJ_CREATE for the audio pin.

status = IoCallDriver(pAudioDeviceParent->DeviceObject, Irp); // CRASHES HERE
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = iosb.Status;
}

So is there anything in that above that stick out like dog balls or does anyone have any tips?
p.s. This code is ranned in created thread.

Cheers
Obble.


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

Thank you very much Doron, it works :slight_smile:

Cheers
Obble.

On 3/12/2009 9:49 AM, Doron Holan wrote:

If you want the lower stack to see the file object, this
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
stack->FileObject = FileObject; // FILE OBJECT FROM MJ_CREATE for the audio pin.

Should be
PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);

Since there is no current irp stack location for an irp that you allocate yourself

d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of NCH Obble Smith
Sent: Wednesday, December 02, 2009 2:28 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Sending a Irp request crashes

Hello everyone,

I am trying to figure out why a crash occurs when I am trying to send a Irp to a audio driver from a upper filter driver sitting above it.
Since I havn’t done this before I was wondering if there is anything obvious that will cause the crash.

PIRP Irp;
KEVENT event;
IO_STATUS_BLOCK iosb;
KeInitializeEvent(&event, NotificationEvent, FALSE);

KSPROPERTY ksP
ksP.Set = KSPROPSETID_Audio;
ksP.Id = KSPROPERTY_AUDIO_POSITION;
ksP.Flags = KSPROPERTY_TYPE_GET;
KSAUDIO_POSITION ksAudio;

Irp = IoBuildDeviceIoControlRequest(IOCTL_KS_PROPERTY, pAudioDeviceParent->LowerDeviceObject,
&ksP, sizeof ksP,&ksAudio, sizeof ksAudio, FALSE,&event,&iosb);
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
stack->FileObject = FileObject; // FILE OBJECT FROM MJ_CREATE for the audio pin.

status = IoCallDriver(pAudioDeviceParent->DeviceObject, Irp); // CRASHES HERE
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = iosb.Status;
}

So is there anything in that above that stick out like dog balls or does anyone have any tips?
p.s. This code is ranned in created thread.

Cheers
Obble.


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