Kernel Template Library is open-source library providing CRT environment, STL-style containers and RAII tools for Windows Kernel programming.
- Forked from DymOK92's KTL
- avakar for his vcrtl project which enables exceptions
- Extension from wdk_template to expand on the concept to have a C/C++ runtime
-
C Runtime environment
- Exception handling mechanism (now for x64 only)
- Buffer security checks
- C++ Standard compatible termination if execution is run out of control
- Construction and destruction of the non-trivial static objects
- Memory allocation using new and delete
- Filesystem Mini-Filter support routines
-
C++ Standard Library implementation
<atomic>
(now for x86 and x64 only)- Optimized, C++ Standard compatible
<algorithm>
library <allocator>
with standard allocators for different pool types- Boost-based implementation of the
compressed_pair
- Exceptions objects hierarchy (
std::exception
analog optimized for use in the kernel) - Iterators
- MSVC-intrinsic-based coroutines
- Mutexes, events and condition variables based on kernel synchronization primitives with RAII wrappers
- Smart pointers (
unique_ptr
,shared_ptr
andweak_ptr
,intrusive_ptr
) <type_traits>
<thread>
for managing driver-dedicated threads<tuple>
<optional>
with constexpr supportunordered_node_map
,unordered_node_set
,unordered_flat_map
andunordered_flat_set
using robin-hood-hashing<vector>
- Lock-free queue,
node_allocator
and some auxiliary algorithms - fmt as a string formatting library
- Tested with C++20
-
CMake
- Building of kernel drivers
- Generating a test-signing certificate
- Driver signing
Complete documentation in progress.
You can use KTL directly as driver CMake project subdirectory or link with pre-built KTL binaries applying find_package()
.
It includes 2 static libraries:
ktl-runtime.lib
(CRT)ktl.lib
(C++ tools)
[cmake]
version = "3.10"
cmkr-include = "cmake/cmkr.cmake"
[variables]
CMAKE_MODULE_PATH = "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
[project]
name = "KTL-Example"
languages = ["CXX"]
include-before = ["cmake/msvc-configurations.cmake"]
[fetch-content]
ktl = { git = "https://github.com/oopsmishap/ktl" }
[find-package.WDK]
[template.ktl-driver]
type = "executable"
add-function = "wdk_add_driver"
compile-features = ["cxx_std_20"]
link-libraries = ["ktl::ktl"]
[target.ktl-example]
type = "ktl-driver"
sources = ["src/**.cpp"]
include-directories = ["include"]
- KTL-Example - A barebones driver utilizing KTL
- CoroDriverSample - a simple driver demonstrating the use of C++20 coroutines in kernel mode
- Linked lists and Red-Black-Tree containers
- Intrusive containers
- Coroutine-compatible async primitives
- Exception handling on the x86 platforms