Giter Club home page Giter Club logo

ktl's Introduction

KTL

Kernel Template Library is open-source library providing CRT environment, STL-style containers and RAII tools for Windows Kernel programming.

Status

License Lines of Code
License

Features

  • 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 and weak_ptr, intrusive_ptr)
    • <type_traits>
    • <thread> for managing driver-dedicated threads
    • <tuple>
    • <optional> with constexpr support
    • unordered_node_map, unordered_node_set, unordered_flat_map and unordered_flat_set using robin-hood-hashing
    • <vector>
    • Lock-free queue, node_allocator and some auxiliary algorithms
    • fmt as a string formatting library
    • Designed in C++17, feel free to build with C++20
  • CMake

    • Building of kernel drivers
    • Generating a test-signing certificate
    • Driver signing

Complete documentation in progress.

Installation & Usage

You can use KTL directly as driver CMake project subdirectory or link with pre-built KTL binaries applying find_package().

It includes 3 static libraries:

  • basic_runtime.lib (CRT)
  • cpp_runtime.lib (C++ tools)
  • minifilter_runtime.lib (optional Filesystem Mini-Filter support)

CMakeLists.txt to build with a pre-built KTL:

    project(MyDriver CXX)

    find_package(WDK REQUIRED)  # Windows Driver Kit
    find_package(KTL REQUIRED)

    wdk_add_driver(
      ${DRIVER_NAME} minifilter.cpp
        CUSTOM_ENTRY_POINT KtlDriverEntry   # Required for C and C++ Runtime initialization and destruction
		    EXTENDED_CPP_FEATURES               # Exceptions handling enabled
    )
    target_include_directories(
	    ${DRIVER_NAME} PUBLIC
		    ${KTL_INCLUDE_DIR}
		    ${KTL_MODULES_DIR}                  # Lock-Free tools
		    ${KTL_RUNTIME_INCLUDE_DIR}
		    ${CMAKE_INCLUDE_CURRENT_DIR}
    )
    target_link_libraries(
      ${DRIVER_NAME} PRIVATE
        ktl::basic_runtime
        ktl::minifilter_runtime
        ktl::cpp_runtime
    )
    wdk_sign_driver(        # Driver signing (in this example - using given certificate)
	    ${DRIVER_NAME}
		    ${YOUR_CERTIFICATE_NAME}
		    CERTIFICATE_PATH ${YOUR_CERTIFICATE_PATH}
		    TIMESTAMP_SERVER ${YOUR_TIMESTAMP_SERVER} # Default is timestamp.verisign.com
    )

Build requirements:

  • WDK10
  • Visual Studio 2019 (not tested on older versions)
  • CMake 3.0 and higher
  • FindWDK (used as a Git submodule)

Examples

  • CoroDriverSample - a simple driver demonstrating the use of C++20 coroutines in kernel mode

Roadmap for the near future

  • Linked lists and Red-Black-Tree containers
  • Intrusive containers
  • Coroutine-compatible async primitives
  • Exception handling on the x86 platforms

ktl's People

Contributors

dymok93 avatar georgyfirsov avatar shtan7 avatar unterumarmung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ktl's Issues

Bug in ktl::basic_winnt_string

As a result, operator = (const wchar_t *) and moving from the string may end up in an inconsistent state: capacity ()> SSO_CH_BUFFER_COUNT (i.e. !is_small()), but m_str.get_first (). Buffer == m_buffer

BSOD in __GSHandlerCheck()

__GSHandlerCheck, contrary to the documentation, is added by the compiler to the table of exception handlers and is called even with "/ EHsc". It expects as a parameter a pointer to an object of the _DISPATCHER_CONTEXT structure, the contents of which are different from ktl::crt::exc_engine::dispatcher_constext, which leads to BSOD

CRT is seriously bugged

The use of static objects with non-trivial initialization in drivers (Scott Meyers' singleton, for example) leads to BSOD.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.