Hi Guys,
I have a strange problem.
In my KMDF driver, I open a file on demand, in an IOCTL context.
File opened with no problems.
I then (in the same context), try to write just 128 bytes to that file, using ZwWriteFile.
The bytes are written (I see them when I open the file with notepad), but the ZwWriteFile call does not return, and hangs forever.
This is not sporadic, it occurs every time.
Can you guess what the problem is?
Here is my call to ZwCreateFile:
==============================
theAccessMode = FILE_APPEND_DATA | SYNCHRONIZE;
res = ZwCreateFile((PHANDLE)FileHandlePtr,
theAccessMode,
&attr,
&statusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN_IF,
FILE_NON_DIRECTORY_FILE | FILE_WRITE_THROUGH | FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0);
===================================
And here is my call to ZwWriteFile:
===================================
offset.HighPart = -1;
offset.LowPart = FILE_WRITE_TO_END_OF_FILE;
res = ZwWriteFile((HANDLE)theFileHandle,
NULL,
NULL,
NULL,
&statusBlock,
(PVOID)writeBuffer,
(ULONG)writeBufferSize,
&offset,
NULL);
==========================
I verified that both Create and Write are in PASSIVE_LEVEL.
What am I missing?
Thanks!