From 3a346b5e9dc4c198aa744f9f445faaae54bcda7e Mon Sep 17 00:00:00 2001 From: flobernd Date: Sat, 24 Jun 2017 03:29:35 +0200 Subject: [PATCH] Fixed segment-register for XOP/VEX/EVEX/MVEX instructions --- src/Decoder.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Decoder.c b/src/Decoder.c index b0b191a..fb5b798 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -2249,6 +2249,32 @@ static void ZydisSetPrefixRelatedAttributes(ZydisDecoderContext* context, case ZYDIS_INSTRUCTION_ENCODING_VEX: case ZYDIS_INSTRUCTION_ENCODING_EVEX: case ZYDIS_INSTRUCTION_ENCODING_MVEX: + if (context->lastSegmentPrefix) + { + switch (context->lastSegmentPrefix) + { + case 0x2E: + info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_CS; + break; + case 0x36: + info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_SS; + break; + case 0x3E: + info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_DS; + break; + case 0x26: + info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_ES; + break; + case 0x64: + info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_FS; + break; + case 0x65: + info->attributes |= ZYDIS_ATTRIB_HAS_SEGMENT_GS; + break; + default: + ZYDIS_UNREACHABLE; + } + } break; default: ZYDIS_UNREACHABLE;