From ee57519cb0bad5136f37188f9b57746ed0dc52a2 Mon Sep 17 00:00:00 2001 From: SamG-Coder <13449963+SamG-Coder@users.noreply.github.com> Date: Tue, 29 Sep 2026 07:39:01 +1000 Subject: [PATCH] fix(relinker): decode EMMS without a ModRM byte --- .../relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp | 1 + core/relinker/codegen/src/x86/X64InstructionDecoder.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp b/core/relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp index 2472fe258..022721a23 100644 --- a/core/relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp +++ b/core/relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp @@ -130,6 +130,7 @@ inline constexpr std::uint8_t TwoByteModRmRangeFMin = 0x38; inline constexpr std::uint8_t TwoByteModRmRangeFMax = 0x3A; inline constexpr std::uint8_t TwoByteModRmRangeGMin = 0x54; inline constexpr std::uint8_t TwoByteModRmRangeGMax = 0x7F; +inline constexpr std::uint8_t TwoByteEmms = 0x77; inline constexpr std::uint8_t TwoByteModRmRangeHMin = 0xD0; inline constexpr std::uint8_t TwoByteModRmRangeHMax = 0xFE; inline constexpr std::uint8_t TwoByteNopModRm = 0x1F; diff --git a/core/relinker/codegen/src/x86/X64InstructionDecoder.cpp b/core/relinker/codegen/src/x86/X64InstructionDecoder.cpp index fe0ee7ef9..462ff5c2d 100644 --- a/core/relinker/codegen/src/x86/X64InstructionDecoder.cpp +++ b/core/relinker/codegen/src/x86/X64InstructionDecoder.cpp @@ -252,7 +252,7 @@ std::size_t X64InstructionDecoder::Decode(const std::uint8_t* data, std::size_t (opcode >= TwoByteModRmRangeCMin && opcode <= TwoByteModRmRangeCMax) || (opcode >= TwoByteModRmRangeDMin && opcode <= TwoByteModRmRangeDMax) || (opcode >= TwoByteModRmRangeEMin && opcode <= TwoByteModRmRangeEMax) || - (opcode >= TwoByteModRmRangeGMin && opcode <= TwoByteModRmRangeGMax) || + (opcode >= TwoByteModRmRangeGMin && opcode <= TwoByteModRmRangeGMax && opcode != TwoByteEmms) || (opcode >= TwoByteModRmRangeHMin && opcode <= TwoByteModRmRangeHMax) || (opcode >= TwoByteModRmRangeIMin && opcode <= TwoByteModRmRangeIMax) || (opcode >= TwoBytePrefetchGrpMin && opcode <= TwoBytePrefetchGrpMax) ||