•  


GitHub - MiroKaku/ucxxrt: The Universal C++ RunTime library, supporting kernel-mode C++ exception-handler and STL.
Skip to content

The Universal C++ RunTime library, supporting kernel-mode C++ exception-handler and STL.

License

Notifications You must be signed in to change notification settings

MiroKaku/ucxxrt

Repository files navigation

Actions Status LICENSE Windows Visual Studio nuget

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.

1. About

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.

1.1 How ucxxrt works

  • When 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.

1.2 Features

  • support x86, x64, ARM(experimental), ARM64(experimental).
  • support new/delete operators.
  • support C++ exception (/EHa, /EHsc).
  • support SAFESEH、GS (Buffer Security Check).
  • support STL (not fully).
  • support static objects.

List of currently unsupported features ↓

1.3 Example

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: %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
());
    }
}

2. How to use

First, rename DriverEntry to DriverMain .

2.1 Method 1 (recommended)

Right click on the project, select "Manage NuGet Packages". Search for ucxxrt , choose the version that suits you, and then click "Install".

nuget

2.2 Method 2

  1. Download the latest package from Releases and unzip it.

  2. Add the property sheet ucxxrt.props to your project.

usage

3. How to build

IDE:Visual Studio 2022 latest version

  • git clone --recurse-submodules https://github.com/MiroKaku/ucxxrt.git
  • Open ucxxrt.sln and build.

4. Acknowledgements

Thanks to JetBrains for providing free licenses such as Resharper C++ for my open-source projects.

ReSharper C++ logo.

5. References

Great thanks to these excellent projects. Without their existence, there would be no ucxxrt then.

6. List of currently unsupported features

  • Thread Local Storage (TLS): thread_local、TlsAlloc ...
  • std::filesystem
  • std::chrono
  • std::stacktrace_entry
  • std::locale
  • std::stream (std::fstream、std::iostream、std::cin、std::cout、std::cerr)
  • std::future
  • std::latch
  • std::semaphore (std::counting_semaphore、std::binary_semaphore)
  • ...
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본