Re: ZwWriteFile and buffer reuse



How can I make sure that NtWriteFile is complete?

"RJ" wrote:

Here is my file create routine and file write routines. I make sure in the
interrupt routine that ZwWrite routine is completed. But seems it doesn't
mean than write operation is actually completed. I tried to use event object
to signal write complete as shown below. But this event object never set
into signaled state.
RJ

status = ZwCreateFile(&(pDevExt->hFileHandle),
GENERIC_WRITE | SYNCHRONIZE,
&objAttrs,
&ioStatus,
0,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_SUPERSEDE, FILE_SYNCHRONOUS_IO_ALERT,
NULL,
0);


KeClearEvent(gpDevExt->pfileEvent);
status = ZwWriteFile( pDevExt->hFileHandle,
pDevExt->pfileEvent,
NULL,
NULL,
&ioStatus,
pucStartAddress,
ulNumBytes,
NULL,
NULL);

KeWaitForSingleObject(pDevExt->pfileEvent,
Executive,
KernelMode,
FALSE,
NULL);



"Skywing [MVP]" wrote:

Wait until either NtWriteFile returns or signals asynchronous completion.
You cannot touch a buffer passed to NtReadFile/NtWriteFile while it is
working on the operation.

--
Ken Johnson (Skywing)
Windows SDK MVP
http://www.nynaeve.net

"RJ" <RJ@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1E31915E-06C5-4721-8784-5ED892157540@xxxxxxxxxxxxxxxx
I use ZwWriteFile function to write data from a buffer to a file in a
worker
thread. I would like to know when can I resue the input buffer again to
fill
new data. Buffer is filled in the interrupt/DPC and once the buffer is
filled, a worker thread is scheduled to write the data to file. My
interrupt
routine is trying to write new date to the buffer while NtWriteFile
routine
is still running. This creates a bugcheck.
Any help appreciated.
Thanks,
RJ



.



Relevant Pages

  • Re: selfmade serial driver problem with chipset other than VIA
    ... > empty as well as when the RX buffer contains data. ... > A de facto standard way of doing this is to make a tx_sendroutine ... > of the transmit holding register and interrupt enable register> ...
    (Linux-Kernel)
  • Re: ZwWriteFile and buffer reuse
    ... Stack unwind information not available. ... interrupt routine that ZwWrite routine is completed. ... You cannot touch a buffer passed to NtReadFile/NtWriteFile while it is ...
    (microsoft.public.development.device.drivers)
  • Re: ZwWriteFile and buffer reuse
    ... Is it your ISR code???????? ... interrupt routine that ZwWrite routine is completed. ... You cannot touch a buffer passed to NtReadFile/NtWriteFile while it is ...
    (microsoft.public.development.device.drivers)
  • Re: ZwWriteFile and buffer reuse
    ... the below code is in Worker thread which is in PASSIVE LEVEL. ... fills the buffer with data to be writen to file. ... interrupt routine that ZwWrite routine is completed. ...
    (microsoft.public.development.device.drivers)
  • Re: ZwWriteFile and buffer reuse
    ... Wait until either NtWriteFile returns or signals asynchronous completion. ... You cannot touch a buffer passed to NtReadFile/NtWriteFile while it is ... Buffer is filled in the interrupt/DPC and once the buffer is ... routine is trying to write new date to the buffer while NtWriteFile ...
    (microsoft.public.development.device.drivers)

Quantcast