From 4e78d0478818bd2525969c16adb9b51fe66fdef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Ho=CC=88ner?= Date: Mon, 28 Nov 2016 18:56:39 +0100 Subject: [PATCH 1/2] Fixed lib build with clang, fixed tools --- include/Zydis/Formatter.h | 4 ++-- include/Zydis/Input.h | 4 ++-- include/Zydis/Internal/GeneratedTypes.inc | 4 ++-- src/Decoder.c | 22 ---------------------- tools/ZydisDisasm.c | 5 +++-- tools/ZydisFuzzIn.c | 10 +++++++--- 6 files changed, 16 insertions(+), 33 deletions(-) diff --git a/include/Zydis/Formatter.h b/include/Zydis/Formatter.h index 3bf3a57..5173db7 100644 --- a/include/Zydis/Formatter.h +++ b/include/Zydis/Formatter.h @@ -376,7 +376,7 @@ typedef ZydisStatus (*ZydisFormatterFormatAddressFunc)(ZydisInstructionFormatter /** * @brief Defines the @c ZydisInstructionFormatter struct. */ -typedef struct ZydisInstructionFormatter_ +struct ZydisInstructionFormatter_ { ZydisFormatFlags flags; ZydisFormatterAddressFormat addressFormat; @@ -402,7 +402,7 @@ typedef struct ZydisInstructionFormatter_ const char* delimMnemonic; const char* delimOperands; const char* fmtDecorator; // TODO: -} ZydisInstructionFormatter; +}; /* ============================================================================================== */ /* Exported functions */ diff --git a/include/Zydis/Input.h b/include/Zydis/Input.h index ecd22bf..50eca01 100644 --- a/include/Zydis/Input.h +++ b/include/Zydis/Input.h @@ -65,13 +65,13 @@ typedef bool (*ZydisInputNextFunc)(ZydisCustomInput* input, uint8_t* data); /** * @brief Defines the zydis custom input struct. */ -typedef struct ZydisCustomInput_ +struct ZydisCustomInput_ { /** * @brief The @c ZydisInputNextFunc callback. */ ZydisInputNextFunc inputNext; -} ZydisCustomInput; +}; /* ---------------------------------------------------------------------------------------------- */ diff --git a/include/Zydis/Internal/GeneratedTypes.inc b/include/Zydis/Internal/GeneratedTypes.inc index a535977..9dd1e03 100644 --- a/include/Zydis/Internal/GeneratedTypes.inc +++ b/include/Zydis/Internal/GeneratedTypes.inc @@ -17,8 +17,8 @@ typedef struct ZydisInstructionDefinition_ #endif #ifdef ZYDIS_ENABLE_FEATURE_AFFECTED_FLAGS uint8_t affectedFlagsId : 8; -#endif; +#endif #ifdef ZYDIS_ENABLE_FEATURE_CPUID uint8_t cpuidId : 8; #endif -} ZydisInstructionDefinition; \ No newline at end of file +} ZydisInstructionDefinition; diff --git a/src/Decoder.c b/src/Decoder.c index c8f1e48..c27f69f 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -2142,28 +2142,6 @@ static ZydisDecoderStatus ZydisNodeHandlerEvexB(ZydisInstructionInfo* info, uint return ZYDIS_STATUS_DECODER_SUCCESS; } -static ZydisDecoderStatus ZydisNodeHandlerEvexK(ZydisInstructionInfo* info, uint16_t* index) -{ - ZYDIS_ASSERT(info); - ZYDIS_ASSERT(index); - - ZYDIS_ASSERT(info->encoding == ZYDIS_INSTRUCTION_ENCODING_EVEX); - ZYDIS_ASSERT(info->details.evex.isDecoded); - *index = (info->details.evex.aaa == 0) ? 0 : 1; - return ZYDIS_STATUS_DECODER_SUCCESS; -} - -static ZydisDecoderStatus ZydisNodeHandlerEvexZ(ZydisInstructionInfo* info, uint16_t* index) -{ - ZYDIS_ASSERT(info); - ZYDIS_ASSERT(index); - - ZYDIS_ASSERT(info->encoding == ZYDIS_INSTRUCTION_ENCODING_EVEX); - ZYDIS_ASSERT(info->details.evex.isDecoded); - *index = info->details.evex.z; - return ZYDIS_STATUS_DECODER_SUCCESS; -} - /** * @brief Uses the instruction-table to decode the bytestream until an instruction-definition * is found. diff --git a/tools/ZydisDisasm.c b/tools/ZydisDisasm.c index 400637e..0f6989e 100644 --- a/tools/ZydisDisasm.c +++ b/tools/ZydisDisasm.c @@ -59,8 +59,9 @@ int main(int argc, char** argv) } ZydisInstructionFormatter formatter; - if (!ZYDIS_SUCCESS(ZydisFormatterInitInstructionFormatterEx(&formatter, - ZYDIS_FORMATTER_STYLE_INTEL, ZYDIS_FORMATTER_FLAG_ALWAYS_DISPLAY_MEMORY_SEGMENT))) + if (!ZYDIS_SUCCESS(ZydisFormatterInitInstructionFormatterEx(&formatter, + ZYDIS_FORMATTER_STYLE_INTEL, ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE, + ZYDIS_FORMATTER_ADDR_ABSOLUTE, ZYDIS_FORMATTER_DISP_DEFAULT, ZYDIS_FORMATTER_IMM_DEFAULT))) { fputs("Failed to initialized instruction-formatter\n", stderr); return EXIT_FAILURE; diff --git a/tools/ZydisFuzzIn.c b/tools/ZydisFuzzIn.c index d343a12..9e4cbe3 100644 --- a/tools/ZydisFuzzIn.c +++ b/tools/ZydisFuzzIn.c @@ -43,7 +43,10 @@ typedef struct ZydisFuzzControlBlock_ { ZydisDisassemblerMode disasMode; ZydisDecoderFlags decoderFlags; ZydisFormatterStyle formatterStyle; - ZydisFormatterFlags formatterFlags; + ZydisFormatFlags formatterFlags; + ZydisFormatterAddressFormat formatterAddrFormat; + ZydisFormatterDisplacementFormat formatterDispFormat; + ZydisFormatterImmediateFormat formatterImmFormat; uint8_t bufSize; } ZydisFuzzControlBlock; @@ -68,8 +71,9 @@ int main() } ZydisInstructionFormatter formatter; - if (!ZYDIS_SUCCESS(ZydisFormatterInitInstructionFormatterEx(&formatter, - controlBlock.formatterStyle, controlBlock.formatterFlags))) + if (!ZYDIS_SUCCESS(ZydisFormatterInitInstructionFormatterEx(&formatter, + controlBlock.formatterStyle, controlBlock.formatterFlags, controlBlock.formatterAddrFormat, + controlBlock.formatterDispFormat, controlBlock.formatterImmFormat))) { fputs("failed to initialized instruction-formatter\n", stderr); return EXIT_FAILURE; From f4959072dc36bccaba2cc3b1520d1dace04300ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Ho=CC=88ner?= Date: Mon, 28 Nov 2016 19:12:28 +0100 Subject: [PATCH 2/2] Renamed ZydisFormatFlags -> ZydisFormatterFlags --- include/Zydis/Formatter.h | 6 +++--- src/Formatter.c | 2 +- tools/ZydisFuzzIn.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/Zydis/Formatter.h b/include/Zydis/Formatter.h index 5173db7..649229f 100644 --- a/include/Zydis/Formatter.h +++ b/include/Zydis/Formatter.h @@ -61,7 +61,7 @@ enum ZydisFormatterStyles /** * @brief Defines the @c ZydisFormatFlags datatype. */ -typedef uint32_t ZydisFormatFlags; +typedef uint32_t ZydisFormatterFlags; /** * @brief Formats the instruction in uppercase instead of lowercase. @@ -378,7 +378,7 @@ typedef ZydisStatus (*ZydisFormatterFormatAddressFunc)(ZydisInstructionFormatter */ struct ZydisInstructionFormatter_ { - ZydisFormatFlags flags; + ZydisFormatterFlags flags; ZydisFormatterAddressFormat addressFormat; ZydisFormatterDisplacementFormat displacementFormat; ZydisFormatterImmediateFormat immediateFormat; @@ -431,7 +431,7 @@ ZYDIS_EXPORT ZydisStatus ZydisFormatterInitInstructionFormatter( * @return A zydis status code. */ ZYDIS_EXPORT ZydisStatus ZydisFormatterInitInstructionFormatterEx( - ZydisInstructionFormatter* formatter, ZydisFormatterStyle style, ZydisFormatFlags flags, + ZydisInstructionFormatter* formatter, ZydisFormatterStyle style, ZydisFormatterFlags flags, ZydisFormatterAddressFormat addressFormat, ZydisFormatterDisplacementFormat displacementFormat, ZydisFormatterImmediateFormat immmediateFormat); diff --git a/src/Formatter.c b/src/Formatter.c index 00b3759..e12ab61 100644 --- a/src/Formatter.c +++ b/src/Formatter.c @@ -816,7 +816,7 @@ ZydisStatus ZydisFormatterInitInstructionFormatter( } ZydisStatus ZydisFormatterInitInstructionFormatterEx( - ZydisInstructionFormatter* formatter, ZydisFormatterStyle style, ZydisFormatFlags flags, + ZydisInstructionFormatter* formatter, ZydisFormatterStyle style, ZydisFormatterFlags flags, ZydisFormatterAddressFormat addressFormat, ZydisFormatterDisplacementFormat displacementFormat, ZydisFormatterImmediateFormat immmediateFormat) { diff --git a/tools/ZydisFuzzIn.c b/tools/ZydisFuzzIn.c index 9e4cbe3..89cc3bb 100644 --- a/tools/ZydisFuzzIn.c +++ b/tools/ZydisFuzzIn.c @@ -43,7 +43,7 @@ typedef struct ZydisFuzzControlBlock_ { ZydisDisassemblerMode disasMode; ZydisDecoderFlags decoderFlags; ZydisFormatterStyle formatterStyle; - ZydisFormatFlags formatterFlags; + ZydisFormatterFlags formatterFlags; ZydisFormatterAddressFormat formatterAddrFormat; ZydisFormatterDisplacementFormat formatterDispFormat; ZydisFormatterImmediateFormat formatterImmFormat;