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

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:

Is it OK to allocating memory in usermode process from kernel?

tanda996tanda996 Member Posts: 14
edited September 3 in NTDEV

title is obscure, my purpose is: i want my usermode application can read a unknown sized data like registry value's data, and i try this method:
1. KeStackAttachProcess/KeUnstackDetachProcess to attach to my process.
2. call ZwAllocateVirtualMemory to allocating memory, then copy data to returned memory pointer.
3. send to process at least 2 informations: size of data and pointer to that data, so process can read correctly.
4. free all after read.

i tried this method and usermode process can read that data correctly.
my question is: is this a good approach to solve my problem? any other good methods?
thank you.

P/S: mods please move this topic to NTDEV, thanks.

Post edited by Scott_Noone_(OSR) on


  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,343

    Why the gymnastics? Have the app send a request to determine the size and then another request to get the data. This is a pretty standard I/O pattern in Windows.


  • tanda996tanda996 Member Posts: 14
    edited September 4

    im deving a minifilter, anytime an "editing event" occur like registry value editing, registry delete, etc... my driver will notify to the user with FltSendMessage, then receive a reply message. ask how many bytes first seem its more complicated.
    so i just wanna send once to my app with data size and pointer to that data, not send the request first. thanks.

    P/S: for example: when editing a registry value, i will send data in that value to my app too, and that size might be up to 1MB, its big. i just wanna find an easier way to read message send from driver in my app.

  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,343

    Ooooh, it's a Communication Port...

    For as great as they are the API doesn't handle variable length messages very well. Usually the done thing is to have user mode send max size buffers and the driver sends variable length messages to fill those buffers.


  • MBond2MBond2 Member Posts: 184

    1 MB is small. You can allocate many hundreads of buffers of this size on a typical desktop

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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!
Internals & Software Drivers 30 Nov 2020 LIVE ONLINE
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Developing Minifilters Early 2021 LIVE ONLINE