Crtsys
C/C++ Runtime library for system file (Windows Kernel Driver) - Supports Microsoft STL
Install / Use
/learn @ntoskrnl7/CrtsysREADME
crtsys
C/C++ Runtime library for system file (Windows Kernel Driver)
[This document has been machine translated.]
crtsys is open source library that helps you use C++ CRT and STL features in your kernel drivers.
Overview
This project has the most support for C++ STL features among similar projects.
<details> <summary>more</summary>We investigated the functions that help us to use C++ and STL in the kernel driver, and among them, the best implemented project to use is as follows.
(22-04-26)
-
- Pros
- The concept of using the Microsoft STL directly looks good.
- Cons
- Until now, only functions related to data types or data structures such as std::string and std::vector classes, which have little relevance to Win32 API, are supported.
- Since vcxproj is dependent on the development environment, if the VS version changes, you have to manually modify it.
- Hanging occurs on x86. this code
- It seems that they copied Microsoft's source code as it is and put their own license comments at the top and included it in the project, and it does not seem to be free from licensing problems.
- Changing the license and redistributing the Microsoft CRT and STL source code are not permitted.
- Pros
-
- Pros
- CMake
- Easy to create and automate project files suitable for development environment.
- Independent implementation of all code including CRT
- It is free from license, and the exception handling code part is lightweight, which can save the stack.
- Provides a template library specialized for the kernel
- Because it provides a template library for mechanisms that exist only in the kernel, there are many functions that can be used more favorably than STL when making an actual driver.
- high quality code.
- CMake
- Cons
- MIt seems that it was written with consideration to using Microsoft STL, but I feel it is difficult to actually change to use Microsoft STL (there were more typos and code using only ktl than I thought)
- Russian comments, but the file is not UTF8+BOM encoded, so the build fails in a non-Russian environment.
- x86 not supported.
- Pros
While I was working to make up for the shortcomings of each library, I developed a new library for the following reasons.
- UCXXRT copied the Microsoft CRT source code as is and included it in the project.
- KTL does not support x86.
The advantages of crtsys are as follows.
- Microsoft CRT source code is used to support the Microsoft CRT and STL as closely as possible, but it builds and processes the source directly in the directory where Microsoft Visual Studio or Build Tools are installed, so users who use Visual Studio legally can be licensed. . You can use it without any problems.
- It supports a wide range of STL features by leveraging Ldk that implement the Win32 API.
- You can organize your projects with CMake, and CPM makes it really easy to use the library.
Goal
This project aims to provide a development experience similar to using C++ and STL in your applications when writing kernel drivers.
Features currently supported or supported in the future are listed below.
- Checked items are items that have been implemented.
- For the item where the test code is written, a link to the test code is added.
C++ Standard
It was written based on the C++ reference
- Initialization
- [x] Non-local variables
- [ ] Static local variables
- [ ] thread_local
- [ ] static
- Exceptions
STL
- [x] std::chrono (tested)
- [x] std::thread (tested)
- [x] std::condition_variable (tested)
- [x] std::mutex (tested)
- [x] std::shared_mutex (tested)
- [x] std::future (tested)
- [x] std::promise (tested)
- [x] std::packaged_task (tested)
- [x] std::cin
- [x] std::clog
- [x] std::cerr
- [x] std::cout (tested)
- [x] std::wcin
- [x] std::wclog
- [x] std::wcerr
- [x] std::wcout (tested)
C Standard
- [x] math functions
NTL (NT Template Library)
Provides features to support a better development environment in the kernel.
- ntl::expand_stack (tested)
