Hi all,
i am writing the file system driver.
There is a problem with non-cached read.
here is the sample code,
whenever the call reaches to keWaitForSingleObject() it hangs (waits)
there infinitely?
can anyone please tell me what could be the problem?
i am using my own buffer ( allocated paged memory ).
is it the case that i have to lock the buffer?
i have tried with locking the buffer also.
this problem occurs only in Windows XP not in Vista.
is there any specific thing we need to take care?

please help me,
thanks
hitesh ughreja

here is the sample code.

KEVENT Event;
PIRP Irp;
IO_STATUS_BLOCK IoStatus;
NTSTATUS Status;

KeInitializeEvent(&Event, SynchronizationEvent, FALSE);

Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_READ,
TargetDeviceObject,
Buffer,
Length,
(PLARGE_INTEGER)(&Offset),
&Event,
&IoStatus
);

if (!Irp)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
}

Status = IoCallDriver(TargetDeviceObject, Irp);

if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(
&Event,
Executive,
KernelMode,
FALSE,
NULL
);

Status = IoStatus.Status;
}

if(!NT_SUCCESS(Status))
{
DbgPrint("Read disk failure\n");
return Status;
}

Re: FileSystem: Non cached read. by Vladimir

Vladimir
Wed Apr 30 12:57:59 CDT 2008

Perhaps irql > PASSIVE_LEVEL (or at least special kernel APCs are
disabled).
Use IoBuildAsynchronousFsdRequest instead.
You can see how to use it here:
http://support.microsoft.com/kb/326315

--
Best regards,
Vladimir Zinin


hitesh wrote:
> Hi all,
> i am writing the file system driver.
> There is a problem with non-cached read.
> here is the sample code,
> whenever the call reaches to keWaitForSingleObject() it hangs (waits)
> there infinitely?
> can anyone please tell me what could be the problem?
> i am using my own buffer ( allocated paged memory ).
> is it the case that i have to lock the buffer?
> i have tried with locking the buffer also.
> this problem occurs only in Windows XP not in Vista.
> is there any specific thing we need to take care?
>
> please help me,
> thanks
> hitesh ughreja
>
> here is the sample code.
>
> KEVENT Event;
> PIRP Irp;
> IO_STATUS_BLOCK IoStatus;
> NTSTATUS Status;
>
> KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
>
> Irp = IoBuildSynchronousFsdRequest(
> IRP_MJ_READ,
> TargetDeviceObject,
> Buffer,
> Length,
> (PLARGE_INTEGER)(&Offset),
> &Event,
> &IoStatus
> );
>
> if (!Irp)
> {
> Status = STATUS_INSUFFICIENT_RESOURCES;
> }
>
> Status = IoCallDriver(TargetDeviceObject, Irp);
>
> if (Status == STATUS_PENDING)
> {
> KeWaitForSingleObject(
> &Event,
> Executive,
> KernelMode,
> FALSE,
> NULL
> );
>
> Status = IoStatus.Status;
> }
>
> if(!NT_SUCCESS(Status))
> {
> DbgPrint("Read disk failure\n");
> return Status;
> }

Re: FileSystem: Non cached read. by Maxim

Maxim
Thu May 01 04:13:12 CDT 2008

> Irp = IoBuildSynchronousFsdRequest(
> IRP_MJ_READ,
> TargetDeviceObject,
> Buffer,
> Length,
> (PLARGE_INTEGER)(&Offset),
> &Event,
> &IoStatus
> );

Use IoAllocateIrp and the completion routine which will KeSetEvent for the
event instead of IoBuildSynchronousFsdRequest.

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