From 860f5d4cfceced9de423a2abbd0b7eb66b538f6a Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 24 Aug 2025 12:56:15 +0200 Subject: [PATCH 1/3] Automatically build as library if project is not toplevel --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dce0655a..342aa659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,6 @@ option(MOMO_ENABLE_CLANG_TIDY "Enable clang-tidy checks" OFF) option(MOMO_ENABLE_RUST_CODE "Enable code parts written in rust" ON) option(MOMO_EMSCRIPTEN_MEMORY64 "Enable memory 64 support for emscripten builds" OFF) option(MOMO_EMSCRIPTEN_SUPPORT_NODEJS "Enable Node.js filesystem for emscripten compilation" OFF) -option(MOMO_BUILD_AS_LIBRARY "Configure and Build the sogen as a shared library (without the samples and tests)" OFF) set(MOMO_REFLECTION_LEVEL "0" CACHE STRING "Reflection level for the build") message(STATUS "Reflection level is set to: ${MOMO_REFLECTION_LEVEL}") @@ -37,6 +36,18 @@ enable_testing() ########################################## +if(PROJECT_IS_TOP_LEVEL) + set(MOMO_IS_SUBPROJECT OFF) +else() + set(MOMO_IS_SUBPROJECT ON) +endif() + +########################################## + +option(MOMO_BUILD_AS_LIBRARY "Configure and Build the sogen as a shared library (without the samples and tests)" ${MOMO_IS_SUBPROJECT}) + +########################################## + set_property(GLOBAL PROPERTY USE_FOLDERS ON) ########################################## From 22227c8ef2e3a43b33d1bcd4c0ca2f88289e64c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 24 Aug 2025 11:07:49 +0000 Subject: [PATCH 2/3] Build(deps): Bump deps/unicorn from `79f4f7a` to `65f12b1` Bumps [deps/unicorn](https://github.com/momo5502/unicorn) from `79f4f7a` to `65f12b1`. - [Commits](https://github.com/momo5502/unicorn/compare/79f4f7a51eb4e8360ab08a51ce6d68b8ae24cd1b...65f12b11eeba7920abac938d36bf922910be693e) --- updated-dependencies: - dependency-name: deps/unicorn dependency-version: 65f12b11eeba7920abac938d36bf922910be693e dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/unicorn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/unicorn b/deps/unicorn index 79f4f7a5..2b224aeb 160000 --- a/deps/unicorn +++ b/deps/unicorn @@ -1 +1 @@ -Subproject commit 79f4f7a51eb4e8360ab08a51ce6d68b8ae24cd1b +Subproject commit 2b224aebf89900f676ec48f45140e208d35e6c79 From 037f078302b1bd007cf04055ea52e20d89e4386d Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 24 Aug 2025 13:49:46 +0200 Subject: [PATCH 3/3] Revert SGDT hooking support It's useless --- deps/unicorn | 2 +- src/analyzer/main.cpp | 13 ------------- .../unicorn-emulator/unicorn_x86_64_emulator.cpp | 14 -------------- src/emulator/arch_emulator.hpp | 1 - 4 files changed, 1 insertion(+), 29 deletions(-) diff --git a/deps/unicorn b/deps/unicorn index 2b224aeb..6d9cc937 160000 --- a/deps/unicorn +++ b/deps/unicorn @@ -1 +1 @@ -Subproject commit 2b224aebf89900f676ec48f45140e208d35e6c79 +Subproject commit 6d9cc93779a666ed9ce255624730e59e54b55019 diff --git a/src/analyzer/main.cpp b/src/analyzer/main.cpp index 8f7f109b..7d8e97af 100644 --- a/src/analyzer/main.cpp +++ b/src/analyzer/main.cpp @@ -473,19 +473,6 @@ namespace const auto concise_logging = !options.verbose_logging; - win_emu->emu().hook_instruction(x86_hookable_instructions::sgdt, [&](const uint64_t) { - const auto rip = win_emu->emu().read_instruction_pointer(); - const auto mod = get_module_if_interesting(win_emu->mod_manager, options.modules, rip); - - if (mod.has_value()) - { - win_emu->log.print(color::blue, "Executing SGDT instruction at 0x%" PRIx64 " (%s)\n", rip, - (*mod) ? (*mod)->name.c_str() : ""); - } - - return instruction_hook_continuation::run_instruction; - }); - win_emu->emu().hook_instruction(x86_hookable_instructions::cpuid, [&] { const auto rip = win_emu->emu().read_instruction_pointer(); const auto mod = get_module_if_interesting(win_emu->mod_manager, options.modules, rip); diff --git a/src/backends/unicorn-emulator/unicorn_x86_64_emulator.cpp b/src/backends/unicorn-emulator/unicorn_x86_64_emulator.cpp index cf4b9087..8a2afc46 100644 --- a/src/backends/unicorn-emulator/unicorn_x86_64_emulator.cpp +++ b/src/backends/unicorn-emulator/unicorn_x86_64_emulator.cpp @@ -33,8 +33,6 @@ namespace unicorn return UC_X86_INS_RDTSC; case x86_hookable_instructions::rdtscp: return UC_X86_INS_RDTSCP; - case x86_hookable_instructions::sgdt: - return UC_X86_INS_SGDT; default: throw std::runtime_error("Bad instruction for mapping"); } @@ -401,18 +399,6 @@ namespace unicorn container->add(std::move(wrapper), std::move(hook)); } - else if (inst_type == x86_hookable_instructions::sgdt) - { - function_wrapper wrapper([c = std::move(callback)](uc_engine*, const uint64_t data) { - return (c(data) == instruction_hook_continuation::skip_instruction) ? 1 : 0; - }); - - const auto uc_instruction = map_hookable_instruction(inst_type); - uce(uc_hook_add(*this, hook.make_reference(), UC_HOOK_INSN, wrapper.get_function(), wrapper.get_user_data(), 0, - std::numeric_limits::max(), uc_instruction)); - - container->add(std::move(wrapper), std::move(hook)); - } else { function_wrapper wrapper([c = std::move(callback)](uc_engine*) { diff --git a/src/emulator/arch_emulator.hpp b/src/emulator/arch_emulator.hpp index 99260c7d..f20283a1 100644 --- a/src/emulator/arch_emulator.hpp +++ b/src/emulator/arch_emulator.hpp @@ -50,7 +50,6 @@ enum class x86_hookable_instructions cpuid, rdtsc, rdtscp, - sgdt, }; // --[x86_64]-------------------------------------------------------------------------