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

Home NTDEV

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/


Before Posting...

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

Kernel to user communication

aroussarouss Member Posts: 12

Hi everyone,

First, I am quite new to windows driver dev, don't be too harsh :smile:
At some point, the driver I am trying to build needs to process some data with floating point operations, and talking to a server with http requests.
So what I would need is a way to send the data the driver extracted to a user app which would perform the various operations, networking etc. and send it back to the driver. During the processing, the driver would need to wait as it is a KMDF filter driver that modifies read/write data in wdfrequests.

Is this even possible ?

And if it is, IOCTL with inverted calls a good way to go ? Or would I need to use some shared memory ? Or maybe using another method I didnt read about ?

Thanks in advance for your advices,
Axel.

Comments

  • craig_howardcraig_howard Member Posts: 126

    Kernel mode can do floating point quite nicely, and there exist kernel level Winsock functions ... google "Winsock Kernel", there are some GitHub libraries and projects that user Kernel Winsock as well, TCP as well as UDP supported in KMDF as well as UMDF v2 flavors ...

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,568

    Kernel mode can do floating point quite nicely

    Hmmmmm... Really? Let's be sure we're super clear here: Unless something has changed since the AMD64 was introduced, ordinary FPP instructions are not supported on X64 in kernel mode. You need to use SSEx instructions instead.

    You can find a (15 year old) thread on this here.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • aroussarouss Member Posts: 12

    I read about floating point operations being either unsupported or complicated/not efficient.
    At first I began to manually implement floating point numbers/operations but I thought it would be a bit over kill if there was a simplier way to give that work to a user mode app. Hence my question above

  • anton_bassovanton_bassov Member MODERATED Posts: 5,267

    You can find a (15 year old) thread on this here.

    OMG......

    I guess it makes sense for you to lock it right on the spot before someone decides "to bring it back from the dead" and replies to some of the posts on it

    Anton Bassov

  • craig_howardcraig_howard Member Posts: 126

    @Peter_Viscarola_(OSR) said:

    Kernel mode can do floating point quite nicely

    Hmmmmm... Really? Let's be sure we're super clear here: Unless something has changed since the AMD64 was introduced, ordinary FPP instructions are not supported on X64 in kernel mode. You need to use SSEx instructions instead.

    You can find a (15 year old) thread on this here.

    Peter

    Yep, we need to be super clear here, and I wasn't to the OP ... as you've rightly pointed out, there are differences in floating point between the X86 processor and the AMD that require someone to jump through hoops (and the thread link is good to show that) ... my point had been that rather than write a service which is catching data from and returning data to a driver with all of the associated headaches that it entails to do that it would be easier just to "do the work" for kernel floating point to work; once that had been done then kernel mode can be done quite nicely.

    I oversimplified, like saying "cars can travel through the air quite nicely" without mentioning over a century of aviation technology to make that statement correct ...

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,568
    edited June 18

    Well…. I looked into this a bit further, and yes… times have changed in 15+ years. I learned this:

    The 64-bit compiler does not use the MMX/x87 registers for floating point operations. Instead, it uses the SSE registers. x64 kernel mode code is not allowed to access the MMX/x87 registers. The compiler also takes care of properly saving and restoring the SSE state, therefore, calls to KeSaveExtendedProcessorState and KeRestoreExtendedProcessorState are unnecessary and floating point operations can be used in ISRs. Use of other extended processor features such as AVX, requires saving and restoring extended state.

    From here.

    So…. not NEARLY as difficult as I thought… the last time I thought about this was when I wrote that thread that I linked… and at that time you had to hand-code the SSE intrinsics. This is, obviously, no longer required.

    Progress!

    Thank you, Mr @craig_howard for encouraging me to investigate further.

    Enter

    Peter Viscarola
    OSR
    @OSRDrivers

  • aroussarouss Member Posts: 12

    Thank you all for your answers, very interesting to follow this discution.
    I will go for manual floating point implementation then (I want it to work on both x86 and x64).

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!
Developing Minifilters 24 May 2021 Live, Online
Writing WDF Drivers 14 June 2021 Live, Online
Internals & Software Drivers 27 September 2021 Live, Online
Kernel Debugging 15 November 2021 Live, Online