百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

crtsys

> 编程语言
开源

用于系统文件的 C/C++ 运行时库 (Windows 内核驱动程序) - 支持 Microsoft STL

195 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于系统文件的 C/C++ 运行时库 (Windows 内核驱动程序) - 支持 Microsoft STL

crtsys

A modern C++ development platform for Windows kernel drivers (.sys).

Korean documentation

crtsys brings the Microsoft C++ runtime ecosystem (CRT, STL, VCRT, and UCRT) into Windows kernel drivers without maintaining a separate STL fork. It uses the MSVC headers and selected runtime source paths installed with Visual Studio or Build Tools, preserving the familiar MSVC development experience while minimizing divergence from upstream STL.

Driver code keeps the familiar MSVC C++ headers and STL types, while an include-resolution compatibility overlay and kernel runtime layer adapt the paths that require kernel-specific behavior. Runtime dependencies are mapped onto a kernel-mode substrate with explicit driver-test coverage, documented lifecycle behavior, and IRQL contracts.

The goal of crtsys is to let kernel developers use modern C++ development patterns while staying aligned with the MSVC toolchain and upstream STL.

The coverage matrix lists features verified by driver tests. Unlisted APIs may also work, but are not yet part of the verified set.

Quick Start

For the common Visual Studio WDK driver-project workflow, install crtsys from the NuGet package UI:

For an NTL-style WDM driver, select NTL WDM and implement ntl::main in the driver source:

For an NTL-style KMDF driver, set Type of driver to KMDF, select NTL KMDF, and implement ntl::kmdf::main:

For an NTL-style minifilter, select NTL Minifilter and implement ntl::flt::main:

For a Windows Filtering Platform callout driver, select NTL WFP and implement ntl::main. The NuGet package applies the WFP target definitions and links fwpkclnt.lib.

Path Use when Start here
NuGet / MSBuild Visual Studio or Build Tools WDK driver project PackageReference or Install-Package crtsys
vcpkg CMake or manifest-based Visual Studio/MSBuild project vcpkg install crtsys:x64-windows-static
CMake prebuilt Offline or pinned CI dependency find_package(crtsys CONFIG REQUIRED)
CMake / CPM CMake-based driver project that consumes crtsys from GitHub CPMAddPackage("gh:ntoskrnl7/crtsys@")

Minimal MSBuild/NuGet consumer:

In Visual Studio, right-click the driver project and choose Manage NuGet Packages.... Search for crtsys in the package source you use, install it into the WDK driver project, then build the project normally.

xml

  " />
powershell
msbuild .\my_driver.vcxproj /restore /p:Configuration=Debug /p:Platform=x64

For Visual Studio Package Manager Console, the same install is:

powershell
Install-Package crtsys

nuget.exe is optional for modern PackageReference projects when MSBuild restore is available. Build Tools-only environments can use the same msbuild /restore path. See the MSBuild/NuGet quick start.

Minimal CMake/CPM consumer in a separate driver project:

Add CPM.cmake to that driver project, or use your existing CPM bootstrap:

powershell
New-Item -ItemType Directory -Force cmake
Invoke-WebRequest `
  https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.32.0/CPM.cmake `
  -OutFile cmake/CPM.cmake

Then consume crtsys from GitHub in the driver's CMakeLists.txt:

cmake
include("${CMAKE_CURRENT_LIST_DIR}/cmake/CPM.cmake")

set(CRTSYS_NTL_MAIN ON)
CPMAddPackage("gh:ntoskrnl7/crtsys@")
include(${crtsys_SOURCE_DIR}/cmake/CrtSys.cmake)

crtsys_add_driver(my_driver src/main.cpp)

With CRTSYS_NTL_MAIN, driver code can use the C++ entry wrapper:

cpp
#include 

ntl::status ntl::main(ntl::driver& driver,
                      const std::wstring& registry_path) {
  driver.on_unload([registry_path]() {
    // driver cleanup
  });

  return ntl::status::ok();
}

WDM, KMDF, minifilter, and WFP driver models

The NuGet package reads the WDK project's existing DriverType setting. A KMDF project uses its normal DriverEntry and WdfDriverCreate by default. Projects that prefer an NTL-style entry can set CrtSysUseNtlKmdfMain=true and implement ntl::kmdf::main instead. Both modes leave PnP, power, queue, request, object lifetime, and dispatch processing with WDF; crtsys only brackets the WDF startup/unload path with C++ runtime lifetime.

For a regular WDM project that defines its own DriverEntry, set:

xml
false

For CMake, select standard KMDF or the optional NTL KMDF entry on the existing helper:

cmake
crtsys_add_driver(my_kmdf_driver KMDF 1.15 src/main.cpp)
crtsys_add_driver(my_ntl_kmdf_driver KMDF 1.15 NTL src/main.cpp)

See the complete NTL KMDF driver/app sample and the NTL KMDF API guide.

File-system minifilters remain Filter Manager drivers. Select the model explicitly; crtsys links fltmgr.lib, owns the runtime boundary, and calls ntl::flt::main, while Filter Manager continues to own operation dispatch, instances, altitude ordering, and teardown:

cmake
crtsys_add_driver(my_minifilter MINIFILTER NTL src/main.cpp)

Visual Studio/NuGet projects use CrtSysIsMinifilter=true and CrtSysUseNtlFltMain=true. See the NTL minifilter sample catalog and API guide.

Windows Filtering Platform callout drivers select the model explicitly. In Visual Studio/NuGet projects, select NTL WFP, or set NtlWfp. The package applies the Windows 8 WFP contract, selects the architecture-appropriate NDIS definitions, links fwpkclnt.lib, and uses the ntl::main entry wrapper.

CMake consumers use the equivalent helper:

cmake
crtsys_add_driver(my_wfp_callout WFP NTL src/main.cpp)

If that driver uses the kernel MsQuic NMR backend, add KERNEL_MSQUIC to the same call. It selects the pinned headers, Windows 10 version-2004 target, and netio.lib together.

See the WFP ALE connect-block driver/controller, its Korean walkthrough, the WFP guide for driver developers, the typed API and ownership guide, the connect-redirect coroutine TCP proxy, the Schannel TLS inspection proxy, the separate browser HTTPS inspection example, the UDP content-filter and TCP content-filter driver/app samples, the content inspection and framing guide, the kernel/user network dual-runtime guide, the kernel networking contract test, the user-mode TLS stream guide, and the WDK sample coverage map.

NDIS lightweight-filter drivers have a separate first-class model. Visual Studio/NuGet projects select NTL NDIS LWF, or set NtlNdis. The package selects the NDIS 6.30 contract, defines NDIS_WDM/NDISLWF, links ndis.lib, and uses the ntl::main entry wrapper. CMake consumers use:

cmake
crtsys_add_driver(my_lwf NDIS NTL src/main.cpp)

ntl::ndis::lightweight_filter keeps pass-through forwarding, completion, receive return, regular/direct OID clone/completion/cancel, status/PnP propagation, and metadata restoration in the adapter. See the NDIS examples and the disposable-VM acceptance gate.

Runtime Stack

mermaid
flowchart TD
    Driver["Driver code (.sys)
MSVC headers + optional NTL"]
    Runtime["MSVC CRT / UCRT / STL / VCRT
source paths"]
    CrtSys["crtsys compatibility layer
runtime adapters + ABI helpers + tested contracts"]
    LDK["LDK substrate
Windows / NTDLL API + ICU ABI"]
    Kernel["WDK / NT kernel primitives"]

    Driver --> Runtime --> CrtSys --> LDK --> Kernel

Capability Map

Surface Driver-facing result
C++ runtime static init, EH/SEH, RTTI, ABI
CRT/UCRT STL dependencies, math, char conversion
STL containers, ranges, filesystem, format/print, regex, locale, chrono, threading, atomics, PMR, streams, random
Substrate crtsys adapters + LDK Windows/NTDLL/ICU
Evidence driver-run matrix + cppreference + IRQL contracts
Packaging NuGet/MSBuild + prebuilt bundle + CPM.cmake

Feature Highlights

Feature Status Notes
C++ exceptions Driver-tested throw, try/catch, function-try-block, std::exception_ptr
SEH handling Driver-tested C++ helper path for __try / __except boundary handling
Static initialization Driver-tested non-local, dynamic, and MSVC function-local static initialization
Multi-driver compiler TLS Driver-tested distinct MSVC _tls_index values across crtsys-linked drivers so runtime TLS slots do not collide
RTTI Driver-tested typeid, dynamic_cast
STL containers / algorithms Driver-tested containers, algorithms, ranges, smart pointers, PMR, utility
std::format / std::print Driver-tested formatted string/output paths
std::regex Driver-tested regular expression path
std::filesystem Driver-tested path, directory, copy, metadata, time, link-oriented paths covered by the matrix
Concurrency Driver-tested thread, synchronization, async/future, atomic wait/notify
Locale / chrono / charconv Driver-tested locale facets, timezone/chrono paths, integer and floating char conversion
NTL driver helpers Driver-tested ntl::main, driver/device helpers, symbolic link/event/work item RAII, RPC, IRQL helpers, pool allocators, stack expansion
thread_local Unsupported for user variables Kernel GS is processor-local KPCR, not user-mode TEB; user-declared thread_local would not be per-thread storage

The detailed matrix is intentionally test-linked: it records features exercised by the kernel driver test suite, not the full set of headers or code paths that may compile or work.

Documentation

Document Use it for
Architecture Runtime stack, layer responsibilities, consumer paths
MSBuild/NuGet Quick Start Visual Studio, Build Tools-only, and CI package consumption
Design Rationale IRQL, pool, stack, unload, and operational boundaries
Feature Coverage Driver-tested C++/CRT/STL matrix and known gaps
NTL API Driver helper APIs, entry wrapper, synchronization, pool allocators, SEH helper
Usage Examples Small driver-side NTL examples
NTL sample driver Complete Visual Studio/NuGet and CMake driver sample using ntl::main, device endpoint, typed IOCTLs, remove lock, registry config, passive executor, and pool-backed PMR
NTL RPC sample driver Complete Visual Studio/NuGet and CMake driver/app pair using the shared NTL RPC schema
NTL KMDF samples Independent control, PnP, echo/cancel, reference, bus, filter-stack, DMA, USB, and WMI projects
NTL KMDF basic sample ntl::kmdf::main, C++ WDF contexts, typed file/request and manual-queue cancellation, common WDF object utilities, deferred callbacks, and STL in passive KMDF callbacks
NTL KMDF PnP sample Root-enumerated PnP/power lifecycle, resources, device interface, idle policy, and typed IOCTL
NTL KMDF echo sample Timer-backed asynchronous I/O, cancellation races, queue synchronization, restart, and unload-safe ownership
NTL KMDF reference driver Production-oriented software device with a versioned ABI

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++ccmakecppcpp14

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言