From 58acf3c26c2c4a10f2cafbe36a14ddd01e55a564 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Tue, 5 Nov 2024 13:51:04 +0100 Subject: [PATCH] Fix `has_egpr` flag --- src/Decoder.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Decoder.c b/src/Decoder.c index f1f4af30..b8d3383e 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -4676,10 +4676,16 @@ static ZyanStatus ZydisPopulateRegisterIds(ZydisDecoderContext* context, // Update APX info + if (!is_64_bit) + { + return ZYAN_STATUS_SUCCESS; + } + const ZyanBool has_egpr_reg = (def_reg == ZYDIS_REGKIND_GPR) && (id_reg >= 16); const ZyanBool has_egpr_rm = is_mod_reg && (def_rm == ZYDIS_REGKIND_GPR) && (id_rm >= 16); const ZyanBool has_egpr_vvvv = (def_vvvv == ZYDIS_REGKIND_GPR) && (id_vvvv >= 16); - const ZyanBool has_egpr_base = !is_mod_reg && (id_base >= 16); + const ZyanBool has_egpr_base = !is_mod_reg && (id_base >= 16) && + ((instruction->raw.modrm.mod != 0) || (instruction->raw.modrm.rm != 5)); const ZyanBool has_egpr_index = !is_mod_reg && !has_vsib && (id_index >= 16); if (has_egpr_reg || has_egpr_rm || has_egpr_vvvv || has_egpr_base || has_egpr_index)