Hi–
Could not find any relevant Q&A on the list server on this topic.
I’m trying to wait on file I/O (ZwWriteFile ()) and am not able
to successfully use an event. The routine is called from an
IoQueueWorkItem-dispatched
routine. It errs with code 0xC0000008–Invalid Handle.
The Create:
InitializeObjectAttributes (&ObjectAttributes,
&unicodeFileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL );
ntStatus = ZwCreateFile(&hHandle,
SYNCHRONIZE | FILE_WRITE_DATA,
&ObjectAttributes,
&IoStatus,
NULL, // alloc size = none
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OVERWRITE_IF,
FILE_SEQUENTIAL_ONLY
| FILE_NO_INTERMEDIATE_BUFFERING
| FILE_SYNCHRONOUS_IO_NONALERT,
NULL,0 );
The Write Attempt:
KEVENT event ;
KeInitializeEvent (&event, NotificationEvent, FALSE) ;
ntStatus = ZwWriteFile(hHandle,
&event,
NULL,NULL,
&IoStatus,
pDataBlock,
u32WriteAmount,
0,NULL );
ntStatus is == 0xC0000008.
The code works fine if I do not attempt to wait on the operation.
The DDK (apparently) recommends against using an event in this context
but there are times when I must not proceed until the I/O has completed.
What is the recommended way for waiting on file I/O in a driver?
Bob Loewer