From 8b12d2387f6518c11428bb3bac181062d3d16803 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Wed, 16 Jul 2025 10:56:19 +0200 Subject: [PATCH] Add an unreachable on hitting ud2 instead of getting stuck in an infinite loop --- src/core/cpu_patches.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/cpu_patches.cpp b/src/core/cpu_patches.cpp index e4f65cd31..d09d960f8 100644 --- a/src/core/cpu_patches.cpp +++ b/src/core/cpu_patches.cpp @@ -753,6 +753,9 @@ static bool PatchesIllegalInstructionHandler(void* context) { ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT]; const auto status = Common::Decoder::Instance()->decodeInstruction(instruction, operands, code_address); + if (ZYAN_SUCCESS(status) && instruction.mnemonic == ZydisMnemonic::ZYDIS_MNEMONIC_UD2) { + UNREACHABLE_MSG("ud2 at code address {:#x}", (u64)code_address); + } LOG_ERROR(Core, "Failed to patch address {:x} -- mnemonic: {}", (u64)code_address, ZYAN_SUCCESS(status) ? ZydisMnemonicGetString(instruction.mnemonic) : "Failed to decode");