自2022年3月29日以來,USERMODE支持已被刪除。支持USERMODE的最終版本是E2F159F8F。請在Usermode中使用VC-LTL5。
ucxxrt是基於MSVC的開源運行時庫。該項目的重點是它在內核模式驅動程序中的可用性,它為您提供了與在C ++中開髮用戶模式應用程序幾乎相同的體驗。
在ucxxrt誕生之前,要在內核模式驅動程序中使用C ++ STL,用戶必須製作自己的模板庫(例如KTL,USTD,...)。仍然有幾個問題。就像它不支持C ++異常一樣,主要是,當C ++ ISO標準更新時,實現新語言功能的時間很大。
然後ucxxrt出生。
ucxxrt如何工作在開發內核模式驅動程序時,使用屬性表可以禁用內核模式標誌,並強行使編譯器支持C ++異常。還啟用了異常標誌( /EHsc )。
實施異常功能,例如throw , catch 。在throw中模擬異常調度程序,並在回調函數中處理異常。
當前不受支持的功能的列表↓
有關更多信息,請參見Unitest項目。
void Test$ThrowUnknow()
{
try
{
try
{
try
{
throw std::wstring ();
}
catch ( int & e)
{
ASSERT ( false );
LOG (DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, " Catch Exception: %d n " , e);
}
}
catch (std::string& e)
{
ASSERT ( false );
LOG (DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, " Catch Exception: %s n " , 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] = %s n " , Item. first , Item. second . c_str ());
}
}首先,將DriverEntry重命名為DriverMain 。
右鍵單擊該項目,選擇“管理Nuget軟件包”。搜索ucxxrt ,選擇適合您的版本,然後單擊“安裝”。
從發行版中下載最新的軟件包並解壓縮。
將屬性表ucxxrt.props添加到您的項目中。
IDE:Visual Studio 2022最新版本
和Windows SDK
和Windows驅動程序套件
git clone --recurse-submodules https://github.com/MiroKaku/ucxxrt.git
打開ucxxrt.sln並構建。
對於Clang-CL或LLVM-MSVC,您必須在編譯器標誌中添加-march=native 。
感謝JetBrains為我的開源項目提供免費許可證,例如Resmanper C ++。
非常感謝這些出色的項目。沒有它們的存在,就不會有
ucxxrt。