diff --git a/CMakeLists.txt b/CMakeLists.txt index 208124f..7c10b9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,9 @@ if(CMKR_ROOT_PROJECT) configure_file(cmake.toml cmake.toml COPYONLY) endif() + +add_compile_options($<$:/MP>) + project(regenny) if(CMKR_ROOT_PROJECT AND NOT CMKR_DISABLE_VCPKG) @@ -164,6 +167,10 @@ target_compile_features(regenny PRIVATE cxx_std_17 ) +target_compile_options(regenny PRIVATE + "/EHa" +) + target_include_directories(regenny PRIVATE "src/" "thirdparty/scope_gaurd/" diff --git a/cmake.toml b/cmake.toml index ba27863..17fac44 100644 --- a/cmake.toml +++ b/cmake.toml @@ -1,6 +1,9 @@ # Reference: https://build-cpp.github.io/cmkr/cmake-toml [project] name = "regenny" +cmake-before=""" +add_compile_options($<$:/MP>) +""" [vcpkg] version = "2022.08.15" @@ -67,6 +70,7 @@ link-libraries = [ ] compile-definitions = ["UTF_CPP_CPLUSPLUS=201103L"] compile-features = ["cxx_std_17"] +compile-options = ["/EHa"] cmake-after=""" add_custom_command( TARGET regenny POST_BUILD diff --git a/src/arch/Windows.cpp b/src/arch/Windows.cpp index 1a1b9c9..d5bc5ec 100644 --- a/src/arch/Windows.cpp +++ b/src/arch/Windows.cpp @@ -265,7 +265,7 @@ std::optional WindowsProcess::get_typename(uintptr_t ptr) { return get_typename_from_vtable(*vtable); } -std::optional WindowsProcess::get_typename_from_vtable(uintptr_t ptr) { +std::optional WindowsProcess::get_typename_from_vtable(uintptr_t ptr) try { if (ptr == 0) { return std::nullopt; } @@ -285,6 +285,9 @@ std::optional WindowsProcess::get_typename_from_vtable(uintptr_t pt return std::nullopt; } + auto raw_data = (__std_type_info_data*)((uintptr_t)ti + sizeof(void*)); + raw_data->_UndecoratedName = nullptr; // fixes a crash if memory already allocated because it's not allocated by us + const auto result = std::string_view{ti->name()}; if (result.empty() || result == " ") { @@ -292,6 +295,8 @@ std::optional WindowsProcess::get_typename_from_vtable(uintptr_t pt } return std::string{result}; +} catch(...) { + return std::nullopt; } std::map WindowsHelpers::processes() {