Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


ZWwriteFile

OSR_Community_UserOSR_Community_User Member Posts: 110,217
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

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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: <[email protected]>
    To: NT Developers Interest List <[email protected]>
    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: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    >
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 20-24 May 2024 Live, Online