You should not be checking for FO_SYNCHRONOUS_IO as an indicator of reader or writer. Instead, your app should open the handle with read or write access and then you can check the current stack location to determine role. The driver should be completely agnostic to the overlapped state of the handle being opened.
In WDM you would do the check this way
If (IoGetCurrentIrpStackLocation(Irp)->Parameters.Create.SecurityContext->DesiredAccess & FILE_READ_DATA) // or FILE_WRITE_DATA
{
…
}
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Charles
Sent: Tuesday, January 10, 2012 11:07 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] KMDF Framework File Objects and WDM FILE_OBJECT
Am 10.01.2012 19:00, schrieb Tim Roberts:
Why do you need to know this? There’s no good way to tell which
process called CreateFile. If you need to identify two different
kinds of access, you can use namespaces (such as
“\\.\MyDriver\reader” and “\\.\MyDriver\writer”), or possibly
have a custom ioctl that identifies the caller, or maybe even use the file permissions.
Well I don’t really need to know which process executes first, but I do need to know whether it is a reader or the writer which is called first. The writer initialises a number of structures and owns a circular buffer in system memory.
Currently, I have four WDFFILEOBJECTS in my device extension (since there are four ‘features’). The spec requires that the writer opens asynchronously (overlapped) and the readers synchronously. I therefore check the file-names to see if it has been opened already and the FO_SYNCHRONOUS_IO flag to deduce whether it is a reader or a writer. Once the four ‘slots’ are occupied no further writers are accepted.
On one system running XP Embedded, I am seeing sporadic problems which I am trying to track down. Other test-systems (XP, XP-Embedded) run for weeks on end with constant PCI Express data transfers and without a single problem. What I notice from TraceView is that sometimes calls to WdfFileObjectGetFlags return zero even though I can see from the application SW source code that the file has been opened with FO_SYNCHRONOUS_IO set. There is not a single OpenFile (or is it FileOpen) call in the application software without SYNCHRONOUS I/O set. I have checked with grep. The writer is a service and this has definitely not been restarted. I am not sure yet whether this is my real problem or just a result of some other problem.
Just wanted to make sure my understanding of WDFFILEOBJECTS and WDM FILE_OBJECTS was correct.
Charles
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