APC Handling in NtReadFile() / NtWriteFile() ?

Hi Folks,

If an APC is supplied to NtReadFile() or NtWriteFile(), can these calls
still complete with success, or must they always return with
STATUS_PENDING (or failure status).

Furthermore, if NtReadFile() or NtWriteFile() (when called with an APC)
returns STATUS_SUCCESS, should the caller expect the APC to still be
executed?

Thanks in advance for your help.

Best

  • Sunil

You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

>If an APC is supplied to NtReadFile() or NtWriteFile(), can these calls

still complete with success, or must they always return with
STATUS_PENDING (or failure status).

Yes, if the driver will complete the request without pending it (like cached
reads in the FSD) - then you will have STATUS_SUCCESS from NtReadFile.
APC will be fired nevertheless.

Max


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

The issue here is that there are TWO possible APCs that can “fire” as a
result of a call to NtReadFile.

* The APC used by the I/O Manager (a “special kernel APC”) for I/O
completion. This ROUTINE must be called by the thread that initiated the
I/O operation. If the IRP is completed in thread context, the I/O Manager
bypasses enqueuing an APC and just calls the routine directly. If the IRP
is completed in arbitrary context (such as the case when the top driver
returned STATUS_PENDING) then the I/O Manager ensures the routine runs in
thread context by enqueuing the APC.

* The caller’s APC routine. For a user mode caller this is a “user APC” and
for a kernel mode caller this is a “kernel APC”. Regardless, after the
routine for the special kernel mode APC has run, the caller’s APC routine
will be executed.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Thursday, August 02, 2001 11:20 AM
To: File Systems Developers
Subject: [ntfsd] Re: APC Handling in NtReadFile() / NtWriteFile() ?

If an APC is supplied to NtReadFile() or NtWriteFile(), can these calls
still complete with success, or must they always return with
STATUS_PENDING (or failure status).

Yes, if the driver will complete the request without pending it (like cached
reads in the FSD) - then you will have STATUS_SUCCESS from NtReadFile.
APC will be fired nevertheless.

Max


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com