please check the below code.
I open the device from the application using "\\\\.\\%c:" as the input
parameter to createfile.
called deviceiocontrol with IOCTL_DISK_GET_DRIVE_LAYOUT ioctl
I received this IOCTL in my lower file system filter driver
below is the code,
if ((pReceivedIrpStack->MajorFunction == IRP_MJ_DEVICE_CONTROL) &&
(pReceivedIrpStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_DISK_GET_DRIVE_LAYOUT))
{
KeInitializeEvent(&Event, NotificationEvent,FALSE);
IoSkipCurrentIrpStackLocation(pReceivedIrp);
status = IoCallDriver(pFilterDeviceExtension->pPartitionDeviceObject,
pReceivedIrp);
if (status == STATUS_PENDING)
{
status = KeWaitForSingleObject(&Event,
Suspended,
KernelMode,
FALSE,
NULL);
status = pReceivedIrp->IoStatus.Status;
}
if(!NT_SUCCESS(status))
{
debug statement
}
pReceivedIrp->IoStatus.Status = status;
return(status);
}

problem : The status of IoCallDriver is status_pending and the
KeWaitForSingleObject never returns.I am not sure why it doesnt return.
can anybody help me.
Thanks in advance

Re: KeWaitForSingleObject never returns by Don

Don
Wed May 07 06:46:33 CDT 2008

Where are you setting up a completion routine to signal the event? This
looks like half of a common implementation of a sychronous call to a lower
driver.

--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply




"qwert" <qwert@discussions.microsoft.com> wrote in message
news:BA011AD1-01E2-4695-B32D-F046A499286D@microsoft.com...
> please check the below code.
> I open the device from the application using "\\\\.\\%c:" as the input
> parameter to createfile.
> called deviceiocontrol with IOCTL_DISK_GET_DRIVE_LAYOUT ioctl
> I received this IOCTL in my lower file system filter driver
> below is the code,
> if ((pReceivedIrpStack->MajorFunction == IRP_MJ_DEVICE_CONTROL) &&
> (pReceivedIrpStack->Parameters.DeviceIoControl.IoControlCode ==
> IOCTL_DISK_GET_DRIVE_LAYOUT))
> {
> KeInitializeEvent(&Event, NotificationEvent,FALSE);
> IoSkipCurrentIrpStackLocation(pReceivedIrp);
> status = IoCallDriver(pFilterDeviceExtension->pPartitionDeviceObject,
> pReceivedIrp);
> if (status == STATUS_PENDING)
> {
> status = KeWaitForSingleObject(&Event,
> Suspended,
> KernelMode,
> FALSE,
> NULL);
> status = pReceivedIrp->IoStatus.Status;
> }
> if(!NT_SUCCESS(status))
> {
> debug statement
> }
> pReceivedIrp->IoStatus.Status = status;
> return(status);
> }
>
> problem : The status of IoCallDriver is status_pending and the
> KeWaitForSingleObject never returns.I am not sure why it doesnt return.
> can anybody help me.
> Thanks in advance
>



Re: KeWaitForSingleObject never returns by qwert

qwert
Wed May 07 06:57:00 CDT 2008

I used IoSkipCurrentIrpStackLocation.
I thought that I need not provide completion routine.
I wnated to implement synchronous call only.
completion routine gets executed when the kewait.... gets signalled,if I am
right.
but here the signalling itself is not happening.

"Don Burn" wrote:

> Where are you setting up a completion routine to signal the event? This
> looks like half of a common implementation of a sychronous call to a lower
> driver.
>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
> Remove StopSpam to reply
>
>
>
>
> "qwert" <qwert@discussions.microsoft.com> wrote in message
> news:BA011AD1-01E2-4695-B32D-F046A499286D@microsoft.com...
> > please check the below code.
> > I open the device from the application using "\\\\.\\%c:" as the input
> > parameter to createfile.
> > called deviceiocontrol with IOCTL_DISK_GET_DRIVE_LAYOUT ioctl
> > I received this IOCTL in my lower file system filter driver
> > below is the code,
> > if ((pReceivedIrpStack->MajorFunction == IRP_MJ_DEVICE_CONTROL) &&
> > (pReceivedIrpStack->Parameters.DeviceIoControl.IoControlCode ==
> > IOCTL_DISK_GET_DRIVE_LAYOUT))
> > {
> > KeInitializeEvent(&Event, NotificationEvent,FALSE);
> > IoSkipCurrentIrpStackLocation(pReceivedIrp);
> > status = IoCallDriver(pFilterDeviceExtension->pPartitionDeviceObject,
> > pReceivedIrp);
> > if (status == STATUS_PENDING)
> > {
> > status = KeWaitForSingleObject(&Event,
> > Suspended,
> > KernelMode,
> > FALSE,
> > NULL);
> > status = pReceivedIrp->IoStatus.Status;
> > }
> > if(!NT_SUCCESS(status))
> > {
> > debug statement
> > }
> > pReceivedIrp->IoStatus.Status = status;
> > return(status);
> > }
> >
> > problem : The status of IoCallDriver is status_pending and the
> > KeWaitForSingleObject never returns.I am not sure why it doesnt return.
> > can anybody help me.
> > Thanks in advance
> >
>
>
>

Re: KeWaitForSingleObject never returns by Vetzak

Vetzak
Wed May 07 08:33:06 CDT 2008

On May 7, 1:57 pm, qwert <qw...@discussions.microsoft.com> wrote:
> I used IoSkipCurrentIrpStackLocation.
> I thought that I need not provide completion routine.
> I wnated to implement synchronous call only.
> completion routine gets executed when the kewait.... gets signalled,if I am
> right.
> but here the signalling itself is not happening.
>
> "Don Burn" wrote:
> > Where are you setting up a completion routine to signal the event? This
> > looks like half of a common implementation of a sychronous call to a lower
> > driver.
>
> > --
> > Don Burn (MVP, Windows DDK)
> > Windows 2k/XP/2k3 Filesystem and Driver Consulting
> > Website:http://www.windrvr.com
> > Blog:http://msmvps.com/blogs/WinDrvr
> > Remove StopSpam to reply
>
> > "qwert" <qw...@discussions.microsoft.com> wrote in message
> >news:BA011AD1-01E2-4695-B32D-F046A499286D@microsoft.com...
> > > please check the below code.
> > > I open the device from the application using "\\\\.\\%c:" as the input
> > > parameter to createfile.
> > > called deviceiocontrol with IOCTL_DISK_GET_DRIVE_LAYOUT ioctl
> > > I received this IOCTL in my lower file system filter driver
> > > below is the code,
> > > if ((pReceivedIrpStack->MajorFunction == IRP_MJ_DEVICE_CONTROL) &&
> > > (pReceivedIrpStack->Parameters.DeviceIoControl.IoControlCode ==
> > > IOCTL_DISK_GET_DRIVE_LAYOUT))
> > > {
> > > KeInitializeEvent(&Event, NotificationEvent,FALSE);
> > > IoSkipCurrentIrpStackLocation(pReceivedIrp);
> > > status = IoCallDriver(pFilterDeviceExtension->pPartitionDeviceObject,
> > > pReceivedIrp);
> > > if (status == STATUS_PENDING)
> > > {
> > > status = KeWaitForSingleObject(&Event,
> > > Suspended,
> > > KernelMode,
> > > FALSE,
> > > NULL);
> > > status = pReceivedIrp->IoStatus.Status;
> > > }
> > > if(!NT_SUCCESS(status))
> > > {
> > > debug statement
> > > }
> > > pReceivedIrp->IoStatus.Status = status;
> > > return(status);
> > > }
>
> > > problem : The status of IoCallDriver is status_pending and the
> > > KeWaitForSingleObject never returns.I am not sure why it doesnt return.
> > > can anybody help me.
> > > Thanks in advance

Besides your driver's code, no other code in the universe knows about
the event you're waiting for. You have to implement a completion
routine that sets the event.

Re: KeWaitForSingleObject never returns by Maxim

Maxim
Wed May 07 11:31:58 CDT 2008

I cannot see how Event is associated with the IRP.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"qwert" <qwert@discussions.microsoft.com> wrote in message
news:BA011AD1-01E2-4695-B32D-F046A499286D@microsoft.com...
> please check the below code.
> I open the device from the application using "\\\\.\\%c:" as the input
> parameter to createfile.
> called deviceiocontrol with IOCTL_DISK_GET_DRIVE_LAYOUT ioctl
> I received this IOCTL in my lower file system filter driver
> below is the code,
> if ((pReceivedIrpStack->MajorFunction == IRP_MJ_DEVICE_CONTROL) &&
> (pReceivedIrpStack->Parameters.DeviceIoControl.IoControlCode ==
> IOCTL_DISK_GET_DRIVE_LAYOUT))
> {
> KeInitializeEvent(&Event, NotificationEvent,FALSE);
> IoSkipCurrentIrpStackLocation(pReceivedIrp);
> status = IoCallDriver(pFilterDeviceExtension->pPartitionDeviceObject,
> pReceivedIrp);
> if (status == STATUS_PENDING)
> {
> status = KeWaitForSingleObject(&Event,
> Suspended,
> KernelMode,
> FALSE,
> NULL);
> status = pReceivedIrp->IoStatus.Status;
> }
> if(!NT_SUCCESS(status))
> {
> debug statement
> }
> pReceivedIrp->IoStatus.Status = status;
> return(status);
> }
>
> problem : The status of IoCallDriver is status_pending and the
> KeWaitForSingleObject never returns.I am not sure why it doesnt return.
> can anybody help me.
> Thanks in advance
>


Re: KeWaitForSingleObject never returns by Uv

Uv
Thu May 08 03:16:07 CDT 2008

You've got cause and effect reversed, I think:
The completion routine needs to signal the event on which KeWait is
waiting.
There is no code internal to Windows that will signal the event for
you.

You need to set the completion routine, set the context to pass to it
(probably a pointer to an on-stack event) and write the completion
routine to signal the event.
Only then will KeWait ever wake up.

On May 7, 4:57 am, qwert <qw...@discussions.microsoft.com> wrote:
> I used IoSkipCurrentIrpStackLocation.
> I thought that I need not provide completion routine.
> I wnated to implement synchronous call only.
> completion routine gets executed when the kewait.... gets signalled,if I am
> right.
> but here the signalling itself is not happening.
>
> "Don Burn" wrote:
> > Where are you setting up a completion routine to signal the event? This
> > looks like half of a common implementation of a sychronous call to a lower
> > driver.
>
> > --
> > Don Burn (MVP, Windows DDK)
> > Windows 2k/XP/2k3 Filesystem and Driver Consulting
> > Website:http://www.windrvr.com
> > Blog:http://msmvps.com/blogs/WinDrvr
> > Remove StopSpam to reply
>