{"id":51395450,"url":"https://github.com/ntoskrnl7/crtsys","last_synced_at":"2026-07-04T02:05:14.516Z","repository":{"id":36952934,"uuid":"413401438","full_name":"ntoskrnl7/crtsys","owner":"ntoskrnl7","description":"C/C++ Runtime library for system file (Windows Kernel Driver) - Supports Microsoft STL","archived":false,"fork":false,"pushed_at":"2026-07-03T12:21:28.000Z","size":1389,"stargazers_count":193,"open_issues_count":1,"forks_count":35,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-07-03T12:25:36.350Z","etag":null,"topics":["c","cpp","cpp14","cpp17","cpp20","crt","cruntime-library","driver-programming","kernel","kernel-driver","kernel-drivers","kernel-module","modern-cpp","stl","ucrt","wdk","windows-driver","windows-drivers","windows-kernel"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntoskrnl7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-10-04T11:57:24.000Z","updated_at":"2026-07-03T12:21:33.000Z","dependencies_parsed_at":"2022-07-11T10:52:57.926Z","dependency_job_id":null,"html_url":"https://github.com/ntoskrnl7/crtsys","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/ntoskrnl7/crtsys","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fcrtsys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fcrtsys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fcrtsys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fcrtsys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntoskrnl7","download_url":"https://codeload.github.com/ntoskrnl7/crtsys/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fcrtsys/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35104115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cpp","cpp14","cpp17","cpp20","crt","cruntime-library","driver-programming","kernel","kernel-driver","kernel-drivers","kernel-module","modern-cpp","stl","ucrt","wdk","windows-driver","windows-drivers","windows-kernel"],"created_at":"2026-07-04T02:05:13.907Z","updated_at":"2026-07-04T02:05:14.511Z","avatar_url":"https://github.com/ntoskrnl7.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crtsys\n\nFamiliar MSVC C++ runtime and STL experience for Windows kernel drivers (`.sys`).\n\n[![CMake](https://github.com/ntoskrnl7/crtsys/actions/workflows/cmake.yml/badge.svg)](https://github.com/ntoskrnl7/crtsys/actions/workflows/cmake.yml)\n![GitHub](https://img.shields.io/github/license/ntoskrnl7/crtsys)\n![GitHub release](https://img.shields.io/github/v/release/ntoskrnl7/crtsys)\n![Windows 7+](https://img.shields.io/badge/Windows-7%2B-blue?logo=windows\u0026logoColor=white)\n![Visual Studio 2017+](https://img.shields.io/badge/Visual%20Studio-2017%2B-682270?logo=visualstudio\u0026logoColor=white)\n![CMake 3.14+](https://img.shields.io/badge/CMake-3.14%2B-064f8c?logo=cmake\u0026logoColor=white)\n![C++14+](https://img.shields.io/badge/C%2B%2B-14%2B-00599c?logo=cplusplus\u0026logoColor=white)\n\n[Korean documentation](./docs/ko-kr.md)\n\n`crtsys` brings MSVC CRT/STL/VCRT/UCRT source paths into Windows kernel drivers.\nDriver code keeps familiar MSVC C++ headers and STL types while runtime\ndependencies are mapped onto a kernel-mode substrate with explicit driver-test\ncoverage and IRQL contracts.\n\nListed coverage means \"verified by driver tests\". It is not an exhaustive\nsupport ceiling for every header or code path that may compile or work.\n\n## Quick Start\n\n| Path | Use when | Start here |\n| --- | --- | --- |\n| NuGet / MSBuild | Visual Studio or Build Tools WDK driver project | `PackageReference` or `Install-Package crtsys` |\n| CMake prebuilt | Offline or pinned CI dependency | `find_package(crtsys CONFIG REQUIRED)` |\n| CMake / CPM | CMake-based driver project that consumes `crtsys` from GitHub | `CPMAddPackage(\"gh:ntoskrnl7/crtsys@\u003cversion\u003e\")` |\n\nMinimal MSBuild/NuGet consumer:\n\n```xml\n\u003cItemGroup\u003e\n  \u003cPackageReference Include=\"crtsys\" Version=\"\u003cversion\u003e\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\n```powershell\nmsbuild .\\my_driver.vcxproj /restore /p:Configuration=Debug /p:Platform=x64\n```\n\nFor Visual Studio Package Manager Console:\n\n```powershell\nInstall-Package crtsys\n```\n\n`nuget.exe` is optional for modern `PackageReference` projects when MSBuild\nrestore is available. Build Tools-only environments can use the same\n`msbuild /restore` path. See the\n[MSBuild/NuGet quick start](./docs/msbuild-nuget-quickstart.md).\n\nMinimal CMake/CPM consumer in a separate driver project:\n\nAdd `CPM.cmake` to that driver project, or use your existing CPM bootstrap:\n\n```powershell\nNew-Item -ItemType Directory -Force cmake\nInvoke-WebRequest `\n  https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.32.0/CPM.cmake `\n  -OutFile cmake/CPM.cmake\n```\n\nThen consume `crtsys` from GitHub in the driver's `CMakeLists.txt`:\n\n```cmake\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/cmake/CPM.cmake\")\n\nset(CRTSYS_NTL_MAIN ON)\nCPMAddPackage(\"gh:ntoskrnl7/crtsys@\u003cversion\u003e\")\ninclude(${crtsys_SOURCE_DIR}/cmake/CrtSys.cmake)\n\ncrtsys_add_driver(my_driver src/main.cpp)\n```\n\nWith `CRTSYS_NTL_MAIN`, driver code can use the C++ entry wrapper:\n\n```cpp\n#include \u003cntl/driver\u003e\n\nntl::status ntl::main(ntl::driver\u0026 driver,\n                      const std::wstring\u0026 registry_path) {\n  driver.on_unload([registry_path]() {\n    // driver cleanup\n  });\n\n  return ntl::status::ok();\n}\n```\n\n## Runtime Stack\n\n```mermaid\nflowchart TD\n    Driver[\"Driver code (.sys)\u003cbr/\u003eMSVC headers + optional NTL\"]\n    Runtime[\"MSVC CRT / UCRT / STL / VCRT\u003cbr/\u003esource paths\"]\n    CrtSys[\"crtsys compatibility layer\u003cbr/\u003eruntime adapters + ABI helpers + tested contracts\"]\n    LDK[\"LDK substrate\u003cbr/\u003eWindows / NTDLL API + ICU ABI\"]\n    Kernel[\"WDK / NT kernel primitives\"]\n\n    Driver --\u003e Runtime --\u003e CrtSys --\u003e LDK --\u003e Kernel\n```\n\n## Capability Map\n\n| Surface | Driver-facing result |\n| --- | --- |\n| C++ runtime | static init, EH/SEH, RTTI, ABI |\n| CRT/UCRT | STL dependencies, math, char conversion |\n| STL | containers, ranges, filesystem, format/print, regex, locale, chrono, threading, atomics, PMR, streams, random |\n| Substrate | crtsys adapters + LDK Windows/NTDLL/ICU |\n| Evidence | driver-run matrix + cppreference + IRQL contracts |\n| Packaging | NuGet/MSBuild + prebuilt bundle + CPM.cmake |\n\n## Feature Highlights\n\n| Feature | Status | Notes |\n| --- | --- | --- |\n| C++ exceptions | Driver-tested | `throw`, `try`/`catch`, function-try-block, `std::exception_ptr` |\n| SEH handling | Driver-tested | C++ helper path for `__try` / `__except` boundary handling |\n| Static initialization | Driver-tested | non-local, dynamic, and MSVC function-local static initialization |\n| RTTI | Driver-tested | `typeid`, `dynamic_cast` |\n| STL containers / algorithms | Driver-tested | containers, algorithms, ranges, smart pointers, PMR, utility |\n| `std::format` / `std::print` | Driver-tested | formatted string/output paths |\n| `std::regex` | Driver-tested | regular expression path |\n| `std::filesystem` | Driver-tested | path, directory, copy, metadata, time, link-oriented paths covered by the matrix |\n| Concurrency | Driver-tested | thread, synchronization, async/future, atomic wait/notify |\n| Locale / chrono / charconv | Driver-tested | locale facets, timezone/chrono paths, integer and floating char conversion |\n| NTL driver helpers | Driver-tested | `ntl::main`, driver/device helpers, RPC, IRQL helpers, stack expansion |\n| `thread_local` | Not true TLS | Compiler TLS is not exposed as true per-thread kernel TLS |\n\nThe detailed matrix is intentionally test-linked: it records features exercised\nby the kernel driver test suite, not the full set of headers or code paths that\nmay compile or work.\n\n## Documentation\n\n| Document | Use it for |\n| --- | --- |\n| [Architecture](./docs/architecture.md) | Runtime stack, layer responsibilities, consumer paths |\n| [MSBuild/NuGet Quick Start](./docs/msbuild-nuget-quickstart.md) | Visual Studio, Build Tools-only, and CI package consumption |\n| [Design Rationale](./docs/design-rationale.md) | IRQL, pool, stack, unload, and operational boundaries |\n| [Feature Coverage](./docs/feature-coverage.md) | Driver-tested C++/CRT/STL matrix and known gaps |\n| [NTL API](./docs/ntl-api.md) | Driver helper APIs, entry wrapper, synchronization, SEH helper |\n| [Usage Examples](./docs/usage-examples.md) | Small driver-side NTL examples |\n| [CI Driver Load Tests](./docs/ci-driver-load-tests.md) | Optional self-hosted driver load/run workflow |\n\n## Operational Boundaries\n\n| Boundary | Policy |\n| --- | --- |\n| Driver model | The driver remains a normal WDK driver. Verifier, HVCI, unload safety, target OS validation, and paging rules still matter. |\n| IRQL | Runtime-backed C++/CRT/STL paths are `PASSIVE_LEVEL` unless a specific API documents a wider contract. |\n| Stack | Kernel stacks are small; use `ntl::expand_stack` for exception-heavy or STL-heavy paths. |\n| TLS | MSVC function-local statics are supported. General C++ `thread_local` is not true per-thread TLS. |\n| Toolchain | Use matching SDK/WDK versions. Use WDK 23H2 or older for x86 kernel-mode targets. |\n\n## Requirements\n\n- Windows 7 or later\n- Visual Studio or Build Tools 2017 or later\n- Windows SDK and WDK compatible with the selected Visual Studio toolset\n- CMake 3.14 or later\n- Git\n\nTested toolchains include Visual Studio 2017, 2019, 2022, and 2026 with WDK/SDK\nversions such as `10.0.17763.0`, `10.0.18362.0`, `10.0.22000.0`,\n`10.0.22621.0`, and `10.0.26100.0`.\n\nVisual Studio 2017 has missing CRT source/header pieces for some paths, so\n`crtsys` uses selected UCXXRT compatibility code for that toolset.\n\n## CMake Quick Start\n\nCreate a separate driver project, add `CPM.cmake` to that project, and consume\n`crtsys` from GitHub:\n\n```powershell\nNew-Item -ItemType Directory -Force cmake\nInvoke-WebRequest `\n  https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.32.0/CPM.cmake `\n  -OutFile cmake/CPM.cmake\n```\n\n```cmake\ncmake_minimum_required(VERSION 3.14 FATAL_ERROR)\n\nproject(my_driver LANGUAGES C CXX)\n\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/cmake/CPM.cmake\")\n\nset(CRTSYS_NTL_MAIN ON)\nCPMAddPackage(\"gh:ntoskrnl7/crtsys@\u003cversion\u003e\")\ninclude(${crtsys_SOURCE_DIR}/cmake/CrtSys.cmake)\n\ncrtsys_add_driver(my_driver src/main.cpp)\n```\n\n`CRTSYS_NTL_MAIN` enables the C++ entry point wrapper. With it enabled, define\n`ntl::main` instead of writing `DriverEntry` directly:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n#include \u003cntl/driver\u003e\n\nntl::status ntl::main(ntl::driver\u0026 driver,\n                      const std::wstring\u0026 registry_path) {\n  std::wcout \u003c\u003c L\"load: \" \u003c\u003c registry_path \u003c\u003c L\"\\n\";\n\n  driver.on_unload([registry_path]() {\n    std::wcout \u003c\u003c L\"unload: \" \u003c\u003c registry_path \u003c\u003c L\"\\n\";\n  });\n\n  return ntl::status::ok();\n}\n```\n\nIf `CRTSYS_NTL_MAIN` is disabled, keep the normal WDK `DriverEntry` entry\npoint and initialize your driver manually.\n\nBuild the project with a Visual Studio generator:\n\n```bat\ncmake -S . -B build_x64 -A x64\ncmake --build build_x64 --config Debug\n```\n\n`crtsys` keeps diagnostic `KdBreakPoint()` calls enabled by default. To build\nwithout those diagnostic breakpoints, configure with:\n\n```bat\ncmake -S . -B build_x64 -A x64 -DCRTSYS_ENABLE_DIAGNOSTIC_BREAKPOINTS=OFF\n```\n\n## NuGet Package Details\n\n`crtsys` publishes a NuGet package with native MSBuild imports and prebuilt\ndriver libraries for `x86`, `x64`, `ARM`, and `ARM64` `Debug`/`Release` on\nv142/v143, and `x86`, `x64`, and `ARM64` on v145. The package workflow builds\nWDK consumer projects for every packaged architecture that the selected toolset\nsupports. The checked-in smoke projects live under [`test/nuget`](./test/nuget).\n\nThe NuGet distribution is `crtsys.\u003cversion\u003e.nupkg` for Visual Studio/MSBuild\nprojects.\n\n## GitHub Release Prebuilt Bundle Details\n\nGitHub Release publishes these offline-only assets:\n\n- `crtsys-\u003cversion\u003e-prebuilt.zip`: headers, docs, CMake helpers,\n  and prebuilt `x86/x64/ARM/ARM64` `Debug`/`Release` libraries under an MSVC\n  toolset-specific layout, with ARM omitted for v145.\n- `crtsys-\u003cversion\u003e-SHA256SUMS.txt`\n\nThe prebuilt bundle is intended for CMake projects that want a checked-in or\ncached runtime package instead of fetching and building `crtsys` from source.\n\nFor full packaging and publishing command details, see `nuget/README.md`.\n\n## CMake Install\n\nCMake consumers can install a local CMake package:\n\n```bat\ncmake -S . -B build_x64 -A x64 -DCMAKE_INSTALL_PREFIX=%CD%\\artifacts\\install\\crtsys\ncmake --build build_x64 --config Release --target crtsys\ncmake --install build_x64 --config Release\n```\n\nInstalled consumers can then use the package config:\n\n```cmake\nfind_package(crtsys CONFIG REQUIRED PATHS path/to/install-prefix)\ncrtsys_add_driver(my_driver src/main.cpp)\n```\n\nThe install tree uses the same native library layout as the prebuilt release\nbundle: `lib/native/\u003ctoolset\u003e/\u003carch\u003e/\u003cconfig\u003e`, for example\n`lib/native/v143/x64/Release` or `lib/native/v145/x64/Release`.\n\nThe install flow can be smoke-tested with:\n\n```powershell\n.\\scripts\\cmake\\Test-CrtSysInstall.ps1 -Architecture x64 -Configuration Release\n```\n\nTo publish a new version from `main`:\n\n```powershell\n.\\scripts\\release\\Prepare-CrtSysRelease.ps1 -Version \u003cversion\u003e -Push\n```\n\nThe helper updates `include/.internal/version`, commits the version bump,\ncreates the matching `v\u003cversion\u003e` tag, and pushes both the commit and tag. The tag\npush starts the `Package` workflow.\n\nThe same flow is also available from the GitHub UI: open **Actions**,\nselect **Release**, choose **Run workflow**, and enter the release version. The\nworkflow creates the version bump commit and tag, then dispatches the `Package`\nworkflow for that tag. If branch protection blocks direct pushes to `main`, use\nthe local helper or adjust the release rule first.\n\n## Building This Repository\n\nClone the repository and build the test app and driver for the host\narchitecture:\n\n```bat\ngit clone https://github.com/ntoskrnl7/crtsys\ncd crtsys\ntest\\build.bat\n```\n\nBuild a specific target manually:\n\n```bat\nbuild.bat test\\cmake\\app x64 Debug\nbuild.bat test\\cmake\\driver x64 Debug\nbuild.bat test\\cmake\\app x64 Release\nbuild.bat test\\cmake\\driver x64 Release\n```\n\nBuild all supported architecture/configuration combinations:\n\n```bat\nbuild_all.bat test\\cmake\\app\nbuild_all.bat test\\cmake\\driver\n```\n\n`build_all.bat` runs builds sequentially and returns the first failing exit\ncode. Pass `Debug` or `Release` as the second argument to build only one\nconfiguration.\n\nTypical Debug outputs:\n\n```text\ntest\\cmake\\driver\\build_x64\\Debug\\crtsys_test.sys\ntest\\cmake\\app\\build_x64\\Debug\\crtsys_test_app.exe\n```\n\n## Running Tests\n\n`crtsys_test.sys` is a kernel driver. Build validation can happen in CI, but\nloading and executing the test driver must happen in a Windows driver test\nenvironment.\n\nThe CI build workflow and optional self-hosted driver load test path are\ndocumented in [CI driver load tests](./docs/ci-driver-load-tests.md).\n\n```bat\nsc create CrtSysTest binpath= \"C:\\path\\to\\crtsys_test.sys\" displayname= \"crtsys test\" start= demand type= kernel\nsc start CrtSysTest\n\nC:\\path\\to\\crtsys_test_app.exe\n\nsc stop CrtSysTest\nsc delete CrtSysTest\n```\n\nThe test driver uses Google Test internally. Inspect output with DebugView,\nWinDbg, or your normal kernel debugging setup.\n\n## Repository Layout\n\n```text\ncmake/             CMake helpers, including CrtSys.cmake\ninclude/ntl/       NTL C++ helper headers\ninclude/.internal/ Internal version and toolchain compatibility headers\nsrc/               crtsys runtime and CRT/STL compatibility code\ntest/cmake/app/    CMake user-mode test companion application\ntest/cmake/driver/ CMake kernel-mode test driver\ntest/nuget/        Visual Studio WDK NuGet consumer test project\ndocs/              Additional documentation\n```\n\n## Background\n\n`crtsys` was created after experimenting with other kernel C++ runtime\nprojects, especially UCXXRT and KTL. The design goal is to keep the CMake/WDK\nworkflow practical while supporting a substantial Microsoft CRT/STL surface for\nreal driver experiments.\n\nThe project avoids treating the Microsoft CRT/STL source as a vendored library.\nInstead, it relies on the locally installed Visual Studio/Build Tools layout\nand layers kernel-mode compatibility code around it. For older toolsets where\nthe Microsoft-provided source/header layout is incomplete, small compatibility\npieces are used.\n\nSeveral standalone implementations are also referenced where they are a better\nfit for kernel-mode support:\n\n- [RetrievAL](https://github.com/SpoilerScriptsGroup/RetrievAL)\n- [musl](https://github.com/bminor/musl)\n- [zpp serializer](https://github.com/eyalz800/serializer)\n\n## Roadmap\n\n- Expand driver-tested C++ and STL coverage, including investigation of true\n  `thread_local` storage.\n- Reduce Visual Studio 2017 compatibility gaps and keep toolset-specific\n  compatibility code smaller.\n- Broaden real driver load/run CI coverage where suitable test environments are\n  available.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntoskrnl7%2Fcrtsys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntoskrnl7%2Fcrtsys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntoskrnl7%2Fcrtsys/lists"}