IRP_MJ_WRITE/IRP_MJ_READ

Hi All,
I have such problem. If I do ReadFile/WriteFile a driver without
OVERLAPPED, IRP_MJ_WRITE/IRP_MJ_READ will come in the driver. if with
OVERLAPPED, IRP_MJ_WRITE/IRP_MJ_READ will not come in the driver (When I
do CreateFile I set FILE_FLAG_OVERLAPPED). DeviceIoControl works in both
cases? with OVERLAPPED and without. What is necessary to change in the
driver for normal working with ReadFile/WriteFile?

With best regards,
Edward

Edward,

Your post was very difficult to comprehend, so if I guessed incorrectly as
to what you were asking, my apologies.

Since you specify FILE_FLAG_OVERLAPPED, every call to Read/WriteFile and
DeviceIoControl MUST have a pointer to a properly setup, including event
handle, OVERLAPPED structure. The emphasis here is MUST, otherwise results
are unpredictable … other than things will go bump in the night. Also, to
block in the driver, you must use IoMarkIrpPending and return STATUS_PENDING
if the IRP is not completed by Read/WriteFile or DeviceIoControl.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Edward” wrote in message news:xxxxx@ntdev…
>
> Hi All,
> I have such problem. If I do ReadFile/WriteFile a driver without
> OVERLAPPED, IRP_MJ_WRITE/IRP_MJ_READ will come in the driver. if with
> OVERLAPPED, IRP_MJ_WRITE/IRP_MJ_READ will not come in the driver (When I
> do CreateFile I set FILE_FLAG_OVERLAPPED). DeviceIoControl works in both
> cases? with OVERLAPPED and without. What is necessary to change in the
> driver for normal working with ReadFile/WriteFile?
>
> With best regards,
> Edward
>
>

> Hi All,

I have such problem. If I do ReadFile/WriteFile a driver without
OVERLAPPED, IRP_MJ_WRITE/IRP_MJ_READ will come in the driver. if with
OVERLAPPED, IRP_MJ_WRITE/IRP_MJ_READ will not come in the driver (When I
do CreateFile I set FILE_FLAG_OVERLAPPED). DeviceIoControl works in both
cases? with OVERLAPPED and without. What is necessary to change in the
driver for normal working with ReadFile/WriteFile?

No, driver without bugs must support overlapped IO automatically.

Max

> > Hi All,

> I have such problem. If I do ReadFile/WriteFile a driver without
> OVERLAPPED, IRP_MJ_WRITE/IRP_MJ_READ will come in the driver. if with
> OVERLAPPED, IRP_MJ_WRITE/IRP_MJ_READ will not come in the driver (When I
> do CreateFile I set FILE_FLAG_OVERLAPPED). DeviceIoControl works in both
> cases? with OVERLAPPED and without. What is necessary to change in the
> driver for normal working with ReadFile/WriteFile?

No, driver without bugs must support overlapped IO automatically.

This is my driver and it has bugs…

Edward

> Edward,

Your post was very difficult to comprehend, so if I guessed incorrectly as
to what you were asking, my apologies.

Since you specify FILE_FLAG_OVERLAPPED, every call to Read/WriteFile and
DeviceIoControl MUST have a pointer to a properly setup, including event
handle, OVERLAPPED structure. The emphasis here is MUST, otherwise results
are unpredictable … other than things will go bump in the night. Also,
to
block in the driver, you must use IoMarkIrpPending and return
STATUS_PENDING
if the IRP is not completed by Read/WriteFile or DeviceIoControl.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

Thanks Gary,
I use IoMarkIrpPending and return STATUS_PENDING if the IRP is not
completed. My problem is that IRPs never comes to my driver, if I use
Read/WriteFile with OVERLAPPED. Something is wrong in my driver.

Edward

> completed. My problem is that IRPs never comes to my driver, if I use

Read/WriteFile with OVERLAPPED. Something is wrong in my driver.

Try to debug Read/Write calls.
Is NtReadFile called?
Is IopSynchronousServiceTail called?

Max

My guess is you are not setting up the overlapped structure properly, or
more likely, you are not re-setting it up correctly. Did you use an
overlapped structure and then try to reuse it without zeroing the structure?
This is probably the single most common mistake I see with people trying to
use overlapped I/O. If this is not your problem, not sure what is.


Bill McKenzie

“Edward N.Potapoff” wrote in message
news:xxxxx@ntdev…
>
> > Edward,
> >
> > Your post was very difficult to comprehend, so if I guessed incorrectly
as
> > to what you were asking, my apologies.
> >
> > Since you specify FILE_FLAG_OVERLAPPED, every call to Read/WriteFile and
> > DeviceIoControl MUST have a pointer to a properly setup, including event
> > handle, OVERLAPPED structure. The emphasis here is MUST, otherwise
results
> > are unpredictable … other than things will go bump in the night. Also,
> to
> > block in the driver, you must use IoMarkIrpPending and return
> STATUS_PENDING
> > if the IRP is not completed by Read/WriteFile or DeviceIoControl.
> >
> > –
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
>
>
> Thanks Gary,
> I use IoMarkIrpPending and return STATUS_PENDING if the IRP is not
> completed. My problem is that IRPs never comes to my driver, if I use
> Read/WriteFile with OVERLAPPED. Something is wrong in my driver.
>
> Edward
>
>
>
>

What does GetLastError() return?

“Edward N.Potapoff” wrote in message news:xxxxx@ntdev…
>
> > Edward,
> >
> > Your post was very difficult to comprehend, so if I guessed incorrectly as
> > to what you were asking, my apologies.
> >
> > Since you specify FILE_FLAG_OVERLAPPED, every call to Read/WriteFile and
> > DeviceIoControl MUST have a pointer to a properly setup, including event
> > handle, OVERLAPPED structure. The emphasis here is MUST, otherwise results
> > are unpredictable … other than things will go bump in the night. Also,
> to
> > block in the driver, you must use IoMarkIrpPending and return
> STATUS_PENDING
> > if the IRP is not completed by Read/WriteFile or DeviceIoControl.
> >
> > –
> > Gary G. Little
> > xxxxx@broadstor.com
> > xxxxx@inland.net
> >
>
>
> Thanks Gary,
> I use IoMarkIrpPending and return STATUS_PENDING if the IRP is not
> completed. My problem is that IRPs never comes to my driver, if I use
> Read/WriteFile with OVERLAPPED. Something is wrong in my driver.
>
> Edward
>
>
>
>