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.

About <tuple> from msvc stl in driver

Alex_FunkyAlex_Funky Member - All Emails Posts: 186

Hello everyone!
It is very necessary to use a tuple in the driver, the choice fell on msvc stl, but when connecting the file to the project, an error occurs:
**"_HAS_EXCEPTIONS == 0 is not supported." **
This is defined in the Windows Kits\10\Include\10.0.19041.0\km\crt\xstddef file
Maybe someone will help me understand why such a condition is there and whether it is possible to somehow use , I really need it!

Comments

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

    very necessary to use a tuple

    It might be very convenient but it is never very necessary to use a tuple. If it was, then it would have been in the C Language standard.

    I really need it

    Just program around it. It'll take you less time than it took you to post this query.

    I "need" a lot of things: I need to lose 20 pounds, and I need a month long sea-side vacation on an island in the Caribbean. Doesn't mean I'm going to get any of those soon. Just gotta embrace life and get on with it.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,909

    Anything that can be done with a tuple can also be done with a custom struct.

    As for "why", the Microsoft compiler implements exceptions by using special locations in process memory that do not exist in the kernel.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Alex_FunkyAlex_Funky Member - All Emails Posts: 186

    @Tim_Roberts said:
    Anything that can be done with a tuple can also be done with a custom struct.

    As for "why", the Microsoft compiler implements exceptions by using special locations in process memory that do not exist in the kernel.

    Could this means that C++ templates in the kernel cannot be used? or in very limited circumstances?

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

    /rolls eyes

    Peter Viscarola
    OSR
    @OSRDrivers

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,909

    Could this means that C++ templates in the kernel cannot be used? or in very limited circumstances?

    What makes you think that templates and exceptions are related in any way?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,909

    There do exist versions of STL that do not use exceptions, and those version do work in the kernel. That does mean they aren't standard-compliant, which brings up trust issues. I would never switch to a custom STL just to get support for tuples, which are easily implemented at structus.

    On the other hand, if you look at the source, the Visual C++ version of tuple does not appear to throw any exceptions. If you were really desperate, you could probably isolate it yourself.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • ThatsBerkanThatsBerkan Member Posts: 56
    edited February 10

    Templates are a compiler feature, and the MSVC for kernel drivers supports it.
    You can simply do a template <typename T1, typename T2> struct Tuple { T1 v1; T2 v2; }; if you really need something that looks like a tuple... althought you don't need tuples in any way...

    You're writing a driver for an operating system, you're sort of a "part" of the OS. You're the one providing feature to the softwares running in usermode (or even other drivers, for that matter). You should be able to write a kernel component/driver without needing any libraries or extensions. So please.

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

    You're writing a driver for an operating system, you're sort of a "part" of the OS.

    This.

    And, just to put a finer point on this, you're not "sort of a part of the OS" -- You ARE part of the OS.

    In Windows, a driver is an operating system extension created using the interface provided by the I/O Manager. Full stop.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • Alex_FunkyAlex_Funky Member - All Emails Posts: 186

    Thnx guys, osr - the best professional resource!

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 2 August 2021 Live, Online
Kernel Debugging 27 Sept 2021 Live, Online