UserMode support has been removed since March 29th, 2022. The final version known to support UserMode is e2f159f8f. Please use VC-LTL5 instead in UserMode.
ucxxrt is an open source runtime library based on MSVC. The highlight of this project is its usability in kernel-mode drivers, and it provides you nearly the same experience as developing user-mode applications in C++.
Before ucxxrt was born, in order to use C++ STL in kernel-mode drivers, users have to craft their own template libraries (eg. KTL, ustd, ...).
There are still several problems. Like it does not support C++ exceptions, and mainly, it costs very much time to implement new language features when C++ ISO standard updates.
Then ucxxrt was born.
ucxxrt worksWhen developing kernel-mode drivers, kernel-mode flag is disabled by using property sheets, forcibly making the compiler support C++ exceptions. Exception flag(/EHsc) is also enabled.
Implements exception functions like throw, catch. Simulates the exception dispatcher in throw and handles the exception in callback functions.
List of currently unsupported features ↓
See project unittest for more information.
void Test$ThrowUnknow()
{
try
{
try
{
try
{
throw std::wstring();
}
catch (int& e)
{
ASSERT(false);
LOG(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Catch Exception: %dn", e);
}
}
catch (std::string& e)
{
ASSERT(false);
LOG(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Catch Exception: %sn", e.c_str());
}
}
catch (...)
{
LOG(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Catch Exception: ...n");
}
}
void Test$HashMap()
{
auto Rand = std::mt19937_64(::rand());
auto Map = std::unordered_map<uint32_t, std::string>();
for (auto i = 0u; i < 10; ++i)
{
Map[i] = std::to_string(Rand());
}
for (const auto& Item : Map)
{
LOG(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL,
"map[%ld] = %sn", Item.first, Item.second.c_str());
}
}First, rename DriverEntry to DriverMain.
Right click on the project, select "Manage NuGet Packages".
Search for ucxxrt, choose the version that suits you, and then click "Install".
Download the latest package from Releases and unzip it.
Add the property sheet ucxxrt.props to your project.
IDE:Visual Studio 2022 latest version
and Windows SDK
and Windows Driver Kits
git clone --recurse-submodules https://github.com/MiroKaku/ucxxrt.git
Open ucxxrt.sln and build.
For clang-cl or llvm-msvc, you will have to add -march=native in the compiler flags.
Thanks to JetBrains for providing free licenses such as Resharper C++ for my open-source projects.
Great thanks to these excellent projects. Without their existence, there would be no
ucxxrtthen.