none
Using floating point in KMDF driver ? RRS feed

  • Question

  • Hi:

    I have a question regarding using floating point data type in KMDF
    driver:

    1. Is it safe? Do I need to wrap my FP coding lines
    with KeSaveFloatingPointState/KeRestoreFloatingPointState for 32bit OS ?

    2. Is there an WDF API to check whether OS is 32bit or 64bit ?

    Thanks in advance!


    leo

    Friday, June 24, 2016 10:56 PM

Answers

  • no need for a runtime check, you should use

    #ifdef _WIN64

    ...

    #else

    ...

    #endif

    and use the compiler to key off of saving the FP or not. or better yet, just save the FP in all architectures and don't micro optimize and keep the code simple


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Saturday, June 25, 2016 7:36 AM

All replies

  • Most people don't use floating point in the kernel, if you do you should use KeSaveFloatingPointState/KeRestoreFloatingPointState.  You should not worry about whether the OS is 32 or 64 bit, these calls can be present in both. 

    If your second question is about more than the floating point state stuff, then why do you think you need this?  In general you should not be worrying about 32 versus 64 bit, there are ways to address this without doing a test.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Friday, June 24, 2016 11:15 PM
  • Thanks Don. I read an link below which says for 32bit OS, its needed to call KeSave.../KeRestore... but not for 64bit OS. As for checking for 32 or 64bit OS, I think I can check the size of a pointer ?

    https://msdn.microsoft.com/en-us/library/windows/hardware/ff565388(v=vs.85).aspx


    leo

    Saturday, June 25, 2016 4:07 AM
  • no need for a runtime check, you should use

    #ifdef _WIN64

    ...

    #else

    ...

    #endif

    and use the compiler to key off of saving the FP or not. or better yet, just save the FP in all architectures and don't micro optimize and keep the code simple


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Saturday, June 25, 2016 7:36 AM