Re: ZwWriteFile and buffer reuse



Hi mate

Is it your ISR code????????

You cannot call *ANY* of Zw... functions from ISR, and you cannot wait
on synchronization objects either - at IRQL>=DISPATCH_LEVEL your
choice is severely constrained. You have to re-design your problem -
you cannot run the above code either as ISR or as DPC

Anton Bassov

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: How to manipulate a receiving buffer
    ... You'll need to disable your receive interrupt during ... flush_receiving_buffalways clear the buffer to empty (for ... dont want to put packet recognizing logical into the ISR. ... After the upper level code has read all of the chars from the buffer, ...
    (comp.arch.embedded)
  • Re: General Q: Interrupt vs. Polling
    ... An external device writes data to two buffers in my DSP. ... Interrupt DSP ... Write block of data to Buffer B ... DSP processes all data within the ISR ...
    (comp.arch.embedded)
  • 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
    ... How can I make sure that NtWriteFile is complete? ... interrupt routine that ZwWrite routine is completed. ... You cannot touch a buffer passed to NtReadFile/NtWriteFile while it is ...
    (microsoft.public.development.device.drivers)