TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24142 13
Develop Windows kernel-mode drivers using C++ and STL

Windows kernel-mode drivers have been traditionally developed using C programming language. Usage examples, existing frameworks and APIs usually imply C.

However, Windows kernel-mode drivers not only may be developed using C++ (including latest language standards, like C++23), but may also use large portion of standard library, including STL. WDM and KMDF drivers can easily include the following STL headers and use most of the classes and functions defined in them:

* `<memory>`: `std::unique_ptr`, including `std::make_unique_*`...
* `<array>`
* `<atomic>`
* `<algorithm>`
* `<ranges>`
* `<chrono>`
* `<type_traits>`
* `<concepts>`
* `<string_view>`
* `<utility>`: `std::exchange`, `std::move`, `std::swap`, `std::pair` …
* `<tuple>`
* `<optional>`
* `<variant>`
* `<bit>`
* `<span>`
* `<expected>`
* `<mutex>`
* `<coroutine>` - yes, you can even use coroutines in kernel-mode driver!

Additionally, the following libraries have been successfully used from Boost:

* `variant2`
* `intrusive_ptr`
* Some containers from Boost.Container

The [following repository](https://github.com/AlexBAV/cppindriver) provides a small C++ framework library and illustrates how it can be used to create a WDM function and WDM filter drivers.

The library and the article also show how using modern C++ with STL allows a much safer approach for developing kernel-mode drivers: use RAII and automatic memory management to forget about memory and resource leaks.

Simplify asynchronous request processing with coroutines and remove a burden of request cancellation handling with a convenient C++ wrapper for Cancel-Safe queues.

https://redd.it/1ok5hso
@r_cpp
GitHub GitHub - AlexBAV/cppindriver: A small header-only library that simplifies Windows kernel-mode WDM and KMDF driver development using… A small header-only library that simplifies Windows kernel-mode WDM and KMDF driver development using C++ and STL. - AlexBAV/cppindriver
More from @r_cpp
  1. Oct 12, 2026[Release] slick-logger v2.2.0 — Lock-free asynchronous C++20 logging with multi-process sh…
  2. Oct 12, 2026Cheap alternative to reboot parameters (nohz, rcu, isolcpus) for stable benchmarks When no…
  3. Oct 12, 2026This C++ drama is crazy - Adobe votes no https://www.youtube.com/watch?v=DEqx_NMMH9Q https…
  4. Oct 12, 2026FastNoise2: noise generation using SIMD and C++17 https://github.com/Auburn/FastNoise2 htt…
  5. Oct 12, 2026New C++ Conference Videos Released This Month - October 2026 (Updated To Include Videos Re…
  6. Oct 12, 2026cxvm: pin a GCC or Clang version per project on Linux (pyenv/nvm, but for C++ compilers) I…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →