ZWwriteFile

Hi
I need write to file data 10 Mbit/s from PCI card. Data is 32 bit numbers and i
want write those numbers to HD. Can anybody tell what is a efficient way to do
this. Is there other/better ways than ZWwriteFile to do this operation.

Best regards

Mika Piirainen
Patria Oy

Try:

  • creating a file with preallocated size from ZwCreateFile or user mode
    CreateFile + MoveFilePointer + SetEndOfFile.
  • then use FSCTL_GET_RETRIEVAL_POINTERS to get the disk sector
    numbers covered by the file.
  • then work with the disk driver directly, bypassing the FSD.

Note that FSCTL_GET_RETRIEVAL_POINTERS cannot be called from
kmode directly - at least on NT4. The filesystems use ProbeForWrite function
to test the IOCTL’s buffer - and this function will fail if this buffer will
be in the
kmode address space.

You can use a trick to bypass it:

  • ZwCreateSection not based on any file (pagefile-based).
  • ZwMapViewOfSection for this section while being in a System process
    context (you can use, for instance, ExQueueWorkItem callbacks - they are
    executed in System process).
  • this will allocate memory in System process’s usermode address space.
    This memory is accessible from kmode - you can reference it directly and
    even without try/catch blocks provided you have specified the valid
    address -
    this memory is private for your driver and nobody else knows on it.

BTW - this is a good way if you want to allocate several megabytes of
pageable memory in your driver.

Max

----- Original Message -----
From:
To: NT Developers Interest List
Sent: Wednesday, May 31, 2000 1:59 PM
Subject: [ntdev] ZWwriteFile

> Hi
> I need write to file data 10 Mbit/s from PCI card. Data is 32 bit numbers
and i
> want write those numbers to HD. Can anybody tell what is a efficient way
to do
> this. Is there other/better ways than ZWwriteFile to do this operation.
>
>
> Best regards
>
> Mika Piirainen
> Patria Oy
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>