From 63f5b2f68092bebb83ad3095bddace388b72c4e7 Mon Sep 17 00:00:00 2001 From: flobernd Date: Sat, 24 Feb 2018 20:59:35 +0100 Subject: [PATCH] Minor refactorings - Register enum is now auto generated - Cosmetical changes --- include/Zydis/DecoderTypes.h | 16 +- include/Zydis/Generated/EnumRegister.h | 294 +++++++++++++++++++++++++ include/Zydis/Register.h | 107 +-------- include/Zydis/SharedTypes.h | 22 +- src/Generated/EnumRegister.inc | 277 +++++++++++++++++++++++ src/Register.c | 160 +------------- 6 files changed, 613 insertions(+), 263 deletions(-) create mode 100644 include/Zydis/Generated/EnumRegister.h create mode 100644 src/Generated/EnumRegister.inc diff --git a/include/Zydis/DecoderTypes.h b/include/Zydis/DecoderTypes.h index c90e81a..f3d0cc7 100644 --- a/include/Zydis/DecoderTypes.h +++ b/include/Zydis/DecoderTypes.h @@ -74,7 +74,12 @@ enum ZydisMemoryOperandTypes * @brief A memory operand using `SIB` addressing form, where the index register is not used * in address calculation and scale is ignored. No real memory-access is caused. */ - ZYDIS_MEMOP_TYPE_MIB + ZYDIS_MEMOP_TYPE_MIB, + + /** + * @brief Maximum value of this enum. + */ + ZYDIS_MEMOP_TYPE_MAX_VALUE = ZYDIS_MEMOP_TYPE_MIB }; /* ---------------------------------------------------------------------------------------------- */ @@ -498,6 +503,7 @@ enum ZydisCPUFlags * @brief FPU condition-code flag 3. */ ZYDIS_CPUFLAG_C3, + /** * @brief Maximum value of this enum. */ @@ -520,6 +526,7 @@ enum ZydisCPUFlagActions ZYDIS_CPUFLAG_ACTION_SET_0, ZYDIS_CPUFLAG_ACTION_SET_1, ZYDIS_CPUFLAG_ACTION_UNDEFINED, + /** * @brief Maximum value of this enum. */ @@ -581,6 +588,7 @@ enum ZydisExceptionClasses ZYDIS_EXCEPTION_CLASS_E12NP, ZYDIS_EXCEPTION_CLASS_K20, ZYDIS_EXCEPTION_CLASS_K21, + /** * @brief Maximum value of this enum. */ @@ -605,6 +613,7 @@ enum ZydisVectorLengths ZYDIS_VECTOR_LENGTH_128 = 128, ZYDIS_VECTOR_LENGTH_256 = 256, ZYDIS_VECTOR_LENGTH_512 = 512, + /** * @brief Maximum value of this enum. */ @@ -640,6 +649,7 @@ enum ZydisMaskModes * @brief The embedded mask register is used as a zero-mask. */ ZYDIS_MASK_MODE_ZERO, + /** * @brief Maximum value of this enum. */ @@ -673,6 +683,7 @@ enum ZydisBroadcastModes ZYDIS_BROADCAST_MODE_4_TO_8, ZYDIS_BROADCAST_MODE_4_TO_16, ZYDIS_BROADCAST_MODE_8_TO_16, + /** * @brief Maximum value of this enum. */ @@ -710,6 +721,7 @@ enum ZydisRoundingModes * @brief Round towards zero. */ ZYDIS_ROUNDING_MODE_RZ, + /** * @brief Maximum value of this enum. */ @@ -739,6 +751,7 @@ enum ZydisSwizzleModes ZYDIS_SWIZZLE_MODE_BBBB, ZYDIS_SWIZZLE_MODE_CCCC, ZYDIS_SWIZZLE_MODE_DDDD, + /** * @brief Maximum value of this enum. */ @@ -765,6 +778,7 @@ enum ZydisConversionModes ZYDIS_CONVERSION_MODE_UINT8, ZYDIS_CONVERSION_MODE_SINT16, ZYDIS_CONVERSION_MODE_UINT16, + /** * @brief Maximum value of this enum. */ diff --git a/include/Zydis/Generated/EnumRegister.h b/include/Zydis/Generated/EnumRegister.h new file mode 100644 index 0000000..12d5fff --- /dev/null +++ b/include/Zydis/Generated/EnumRegister.h @@ -0,0 +1,294 @@ +/** + * @brief Defines the `ZydisRegister` datatype. + */ +typedef ZydisU8 ZydisRegister; + +/** + * @brief Values that represent `ZydisRegister` elements. + */ +enum ZydisRegisters +{ + ZYDIS_REGISTER_NONE, + + // General purpose registers 8-bit, + ZYDIS_REGISTER_AL, + ZYDIS_REGISTER_CL, + ZYDIS_REGISTER_DL, + ZYDIS_REGISTER_BL, + ZYDIS_REGISTER_AH, + ZYDIS_REGISTER_CH, + ZYDIS_REGISTER_DH, + ZYDIS_REGISTER_BH, + ZYDIS_REGISTER_SPL, + ZYDIS_REGISTER_BPL, + ZYDIS_REGISTER_SIL, + ZYDIS_REGISTER_DIL, + ZYDIS_REGISTER_R8B, + ZYDIS_REGISTER_R9B, + ZYDIS_REGISTER_R10B, + ZYDIS_REGISTER_R11B, + ZYDIS_REGISTER_R12B, + ZYDIS_REGISTER_R13B, + ZYDIS_REGISTER_R14B, + ZYDIS_REGISTER_R15B, + // General purpose registers 16-bit, + ZYDIS_REGISTER_AX, + ZYDIS_REGISTER_CX, + ZYDIS_REGISTER_DX, + ZYDIS_REGISTER_BX, + ZYDIS_REGISTER_SP, + ZYDIS_REGISTER_BP, + ZYDIS_REGISTER_SI, + ZYDIS_REGISTER_DI, + ZYDIS_REGISTER_R8W, + ZYDIS_REGISTER_R9W, + ZYDIS_REGISTER_R10W, + ZYDIS_REGISTER_R11W, + ZYDIS_REGISTER_R12W, + ZYDIS_REGISTER_R13W, + ZYDIS_REGISTER_R14W, + ZYDIS_REGISTER_R15W, + // General purpose registers 32-bit, + ZYDIS_REGISTER_EAX, + ZYDIS_REGISTER_ECX, + ZYDIS_REGISTER_EDX, + ZYDIS_REGISTER_EBX, + ZYDIS_REGISTER_ESP, + ZYDIS_REGISTER_EBP, + ZYDIS_REGISTER_ESI, + ZYDIS_REGISTER_EDI, + ZYDIS_REGISTER_R8D, + ZYDIS_REGISTER_R9D, + ZYDIS_REGISTER_R10D, + ZYDIS_REGISTER_R11D, + ZYDIS_REGISTER_R12D, + ZYDIS_REGISTER_R13D, + ZYDIS_REGISTER_R14D, + ZYDIS_REGISTER_R15D, + // General purpose registers 64-bit, + ZYDIS_REGISTER_RAX, + ZYDIS_REGISTER_RCX, + ZYDIS_REGISTER_RDX, + ZYDIS_REGISTER_RBX, + ZYDIS_REGISTER_RSP, + ZYDIS_REGISTER_RBP, + ZYDIS_REGISTER_RSI, + ZYDIS_REGISTER_RDI, + ZYDIS_REGISTER_R8, + ZYDIS_REGISTER_R9, + ZYDIS_REGISTER_R10, + ZYDIS_REGISTER_R11, + ZYDIS_REGISTER_R12, + ZYDIS_REGISTER_R13, + ZYDIS_REGISTER_R14, + ZYDIS_REGISTER_R15, + // Floating point legacy registers, + ZYDIS_REGISTER_ST0, + ZYDIS_REGISTER_ST1, + ZYDIS_REGISTER_ST2, + ZYDIS_REGISTER_ST3, + ZYDIS_REGISTER_ST4, + ZYDIS_REGISTER_ST5, + ZYDIS_REGISTER_ST6, + ZYDIS_REGISTER_ST7, + // Floating point multimedia registers, + ZYDIS_REGISTER_MM0, + ZYDIS_REGISTER_MM1, + ZYDIS_REGISTER_MM2, + ZYDIS_REGISTER_MM3, + ZYDIS_REGISTER_MM4, + ZYDIS_REGISTER_MM5, + ZYDIS_REGISTER_MM6, + ZYDIS_REGISTER_MM7, + // Floating point vector registers 128-bit, + ZYDIS_REGISTER_XMM0, + ZYDIS_REGISTER_XMM1, + ZYDIS_REGISTER_XMM2, + ZYDIS_REGISTER_XMM3, + ZYDIS_REGISTER_XMM4, + ZYDIS_REGISTER_XMM5, + ZYDIS_REGISTER_XMM6, + ZYDIS_REGISTER_XMM7, + ZYDIS_REGISTER_XMM8, + ZYDIS_REGISTER_XMM9, + ZYDIS_REGISTER_XMM10, + ZYDIS_REGISTER_XMM11, + ZYDIS_REGISTER_XMM12, + ZYDIS_REGISTER_XMM13, + ZYDIS_REGISTER_XMM14, + ZYDIS_REGISTER_XMM15, + ZYDIS_REGISTER_XMM16, + ZYDIS_REGISTER_XMM17, + ZYDIS_REGISTER_XMM18, + ZYDIS_REGISTER_XMM19, + ZYDIS_REGISTER_XMM20, + ZYDIS_REGISTER_XMM21, + ZYDIS_REGISTER_XMM22, + ZYDIS_REGISTER_XMM23, + ZYDIS_REGISTER_XMM24, + ZYDIS_REGISTER_XMM25, + ZYDIS_REGISTER_XMM26, + ZYDIS_REGISTER_XMM27, + ZYDIS_REGISTER_XMM28, + ZYDIS_REGISTER_XMM29, + ZYDIS_REGISTER_XMM30, + ZYDIS_REGISTER_XMM31, + // Floating point vector registers 256-bit, + ZYDIS_REGISTER_YMM0, + ZYDIS_REGISTER_YMM1, + ZYDIS_REGISTER_YMM2, + ZYDIS_REGISTER_YMM3, + ZYDIS_REGISTER_YMM4, + ZYDIS_REGISTER_YMM5, + ZYDIS_REGISTER_YMM6, + ZYDIS_REGISTER_YMM7, + ZYDIS_REGISTER_YMM8, + ZYDIS_REGISTER_YMM9, + ZYDIS_REGISTER_YMM10, + ZYDIS_REGISTER_YMM11, + ZYDIS_REGISTER_YMM12, + ZYDIS_REGISTER_YMM13, + ZYDIS_REGISTER_YMM14, + ZYDIS_REGISTER_YMM15, + ZYDIS_REGISTER_YMM16, + ZYDIS_REGISTER_YMM17, + ZYDIS_REGISTER_YMM18, + ZYDIS_REGISTER_YMM19, + ZYDIS_REGISTER_YMM20, + ZYDIS_REGISTER_YMM21, + ZYDIS_REGISTER_YMM22, + ZYDIS_REGISTER_YMM23, + ZYDIS_REGISTER_YMM24, + ZYDIS_REGISTER_YMM25, + ZYDIS_REGISTER_YMM26, + ZYDIS_REGISTER_YMM27, + ZYDIS_REGISTER_YMM28, + ZYDIS_REGISTER_YMM29, + ZYDIS_REGISTER_YMM30, + ZYDIS_REGISTER_YMM31, + // Floating point vector registers 512-bit, + ZYDIS_REGISTER_ZMM0, + ZYDIS_REGISTER_ZMM1, + ZYDIS_REGISTER_ZMM2, + ZYDIS_REGISTER_ZMM3, + ZYDIS_REGISTER_ZMM4, + ZYDIS_REGISTER_ZMM5, + ZYDIS_REGISTER_ZMM6, + ZYDIS_REGISTER_ZMM7, + ZYDIS_REGISTER_ZMM8, + ZYDIS_REGISTER_ZMM9, + ZYDIS_REGISTER_ZMM10, + ZYDIS_REGISTER_ZMM11, + ZYDIS_REGISTER_ZMM12, + ZYDIS_REGISTER_ZMM13, + ZYDIS_REGISTER_ZMM14, + ZYDIS_REGISTER_ZMM15, + ZYDIS_REGISTER_ZMM16, + ZYDIS_REGISTER_ZMM17, + ZYDIS_REGISTER_ZMM18, + ZYDIS_REGISTER_ZMM19, + ZYDIS_REGISTER_ZMM20, + ZYDIS_REGISTER_ZMM21, + ZYDIS_REGISTER_ZMM22, + ZYDIS_REGISTER_ZMM23, + ZYDIS_REGISTER_ZMM24, + ZYDIS_REGISTER_ZMM25, + ZYDIS_REGISTER_ZMM26, + ZYDIS_REGISTER_ZMM27, + ZYDIS_REGISTER_ZMM28, + ZYDIS_REGISTER_ZMM29, + ZYDIS_REGISTER_ZMM30, + ZYDIS_REGISTER_ZMM31, + // Flags registers, + ZYDIS_REGISTER_FLAGS, + ZYDIS_REGISTER_EFLAGS, + ZYDIS_REGISTER_RFLAGS, + // Instruction-pointer registers, + ZYDIS_REGISTER_IP, + ZYDIS_REGISTER_EIP, + ZYDIS_REGISTER_RIP, + // Segment registers, + ZYDIS_REGISTER_ES, + ZYDIS_REGISTER_CS, + ZYDIS_REGISTER_SS, + ZYDIS_REGISTER_DS, + ZYDIS_REGISTER_FS, + ZYDIS_REGISTER_GS, + // Table registers, + ZYDIS_REGISTER_GDTR, + ZYDIS_REGISTER_LDTR, + ZYDIS_REGISTER_IDTR, + ZYDIS_REGISTER_TR, + // Test registers, + ZYDIS_REGISTER_TR0, + ZYDIS_REGISTER_TR1, + ZYDIS_REGISTER_TR2, + ZYDIS_REGISTER_TR3, + ZYDIS_REGISTER_TR4, + ZYDIS_REGISTER_TR5, + ZYDIS_REGISTER_TR6, + ZYDIS_REGISTER_TR7, + // Control registers, + ZYDIS_REGISTER_CR0, + ZYDIS_REGISTER_CR1, + ZYDIS_REGISTER_CR2, + ZYDIS_REGISTER_CR3, + ZYDIS_REGISTER_CR4, + ZYDIS_REGISTER_CR5, + ZYDIS_REGISTER_CR6, + ZYDIS_REGISTER_CR7, + ZYDIS_REGISTER_CR8, + ZYDIS_REGISTER_CR9, + ZYDIS_REGISTER_CR10, + ZYDIS_REGISTER_CR11, + ZYDIS_REGISTER_CR12, + ZYDIS_REGISTER_CR13, + ZYDIS_REGISTER_CR14, + ZYDIS_REGISTER_CR15, + // Debug registers, + ZYDIS_REGISTER_DR0, + ZYDIS_REGISTER_DR1, + ZYDIS_REGISTER_DR2, + ZYDIS_REGISTER_DR3, + ZYDIS_REGISTER_DR4, + ZYDIS_REGISTER_DR5, + ZYDIS_REGISTER_DR6, + ZYDIS_REGISTER_DR7, + ZYDIS_REGISTER_DR8, + ZYDIS_REGISTER_DR9, + ZYDIS_REGISTER_DR10, + ZYDIS_REGISTER_DR11, + ZYDIS_REGISTER_DR12, + ZYDIS_REGISTER_DR13, + ZYDIS_REGISTER_DR14, + ZYDIS_REGISTER_DR15, + // Mask registers, + ZYDIS_REGISTER_K0, + ZYDIS_REGISTER_K1, + ZYDIS_REGISTER_K2, + ZYDIS_REGISTER_K3, + ZYDIS_REGISTER_K4, + ZYDIS_REGISTER_K5, + ZYDIS_REGISTER_K6, + ZYDIS_REGISTER_K7, + // Bound registers, + ZYDIS_REGISTER_BND0, + ZYDIS_REGISTER_BND1, + ZYDIS_REGISTER_BND2, + ZYDIS_REGISTER_BND3, + ZYDIS_REGISTER_BNDCFG, + ZYDIS_REGISTER_BNDSTATUS, + // Uncategorized, + ZYDIS_REGISTER_MXCSR, + ZYDIS_REGISTER_PKRU, + ZYDIS_REGISTER_XCR0, + + /** + * @brief Maximum value of this enum. + */ + ZYDIS_REGISTER_MAX_VALUE = ZYDIS_REGISTER_XCR0, + /** + * @brief Minimum amount of bits required to store a value of this enum. + */ + ZYDIS_REGISTER_MIN_BITS = 0x0008 +}; diff --git a/include/Zydis/Register.h b/include/Zydis/Register.h index b3b8b78..06a7c58 100644 --- a/include/Zydis/Register.h +++ b/include/Zydis/Register.h @@ -48,112 +48,7 @@ extern "C" { /* Registers */ /* ---------------------------------------------------------------------------------------------- */ -/** - * @brief Defines the @c ZydisRegister datatype. - */ -typedef ZydisU8 ZydisRegister; - -/** - * @brief Values that represent zydis registers. - */ -enum ZydisRegisters -{ - ZYDIS_REGISTER_NONE, - - // General purpose registers 8-bit - ZYDIS_REGISTER_AL, ZYDIS_REGISTER_CL, ZYDIS_REGISTER_DL, ZYDIS_REGISTER_BL, - ZYDIS_REGISTER_AH, ZYDIS_REGISTER_CH, ZYDIS_REGISTER_DH, ZYDIS_REGISTER_BH, - ZYDIS_REGISTER_SPL, ZYDIS_REGISTER_BPL, ZYDIS_REGISTER_SIL, ZYDIS_REGISTER_DIL, - ZYDIS_REGISTER_R8B, ZYDIS_REGISTER_R9B, ZYDIS_REGISTER_R10B, ZYDIS_REGISTER_R11B, - ZYDIS_REGISTER_R12B, ZYDIS_REGISTER_R13B, ZYDIS_REGISTER_R14B, ZYDIS_REGISTER_R15B, - // General purpose registers 16-bit - ZYDIS_REGISTER_AX, ZYDIS_REGISTER_CX, ZYDIS_REGISTER_DX, ZYDIS_REGISTER_BX, - ZYDIS_REGISTER_SP, ZYDIS_REGISTER_BP, ZYDIS_REGISTER_SI, ZYDIS_REGISTER_DI, - ZYDIS_REGISTER_R8W, ZYDIS_REGISTER_R9W, ZYDIS_REGISTER_R10W, ZYDIS_REGISTER_R11W, - ZYDIS_REGISTER_R12W, ZYDIS_REGISTER_R13W, ZYDIS_REGISTER_R14W, ZYDIS_REGISTER_R15W, - // General purpose registers 32-bit - ZYDIS_REGISTER_EAX, ZYDIS_REGISTER_ECX, ZYDIS_REGISTER_EDX, ZYDIS_REGISTER_EBX, - ZYDIS_REGISTER_ESP, ZYDIS_REGISTER_EBP, ZYDIS_REGISTER_ESI, ZYDIS_REGISTER_EDI, - ZYDIS_REGISTER_R8D, ZYDIS_REGISTER_R9D, ZYDIS_REGISTER_R10D, ZYDIS_REGISTER_R11D, - ZYDIS_REGISTER_R12D, ZYDIS_REGISTER_R13D, ZYDIS_REGISTER_R14D, ZYDIS_REGISTER_R15D, - // General purpose registers 64-bit - ZYDIS_REGISTER_RAX, ZYDIS_REGISTER_RCX, ZYDIS_REGISTER_RDX, ZYDIS_REGISTER_RBX, - ZYDIS_REGISTER_RSP, ZYDIS_REGISTER_RBP, ZYDIS_REGISTER_RSI, ZYDIS_REGISTER_RDI, - ZYDIS_REGISTER_R8, ZYDIS_REGISTER_R9, ZYDIS_REGISTER_R10, ZYDIS_REGISTER_R11, - ZYDIS_REGISTER_R12, ZYDIS_REGISTER_R13, ZYDIS_REGISTER_R14, ZYDIS_REGISTER_R15, - // Floating point legacy registers - ZYDIS_REGISTER_ST0, ZYDIS_REGISTER_ST1, ZYDIS_REGISTER_ST2, ZYDIS_REGISTER_ST3, - ZYDIS_REGISTER_ST4, ZYDIS_REGISTER_ST5, ZYDIS_REGISTER_ST6, ZYDIS_REGISTER_ST7, - // Floating point multimedia registers - ZYDIS_REGISTER_MM0, ZYDIS_REGISTER_MM1, ZYDIS_REGISTER_MM2, ZYDIS_REGISTER_MM3, - ZYDIS_REGISTER_MM4, ZYDIS_REGISTER_MM5, ZYDIS_REGISTER_MM6, ZYDIS_REGISTER_MM7, - // Floating point vector registers 128-bit - ZYDIS_REGISTER_XMM0, ZYDIS_REGISTER_XMM1, ZYDIS_REGISTER_XMM2, ZYDIS_REGISTER_XMM3, - ZYDIS_REGISTER_XMM4, ZYDIS_REGISTER_XMM5, ZYDIS_REGISTER_XMM6, ZYDIS_REGISTER_XMM7, - ZYDIS_REGISTER_XMM8, ZYDIS_REGISTER_XMM9, ZYDIS_REGISTER_XMM10, ZYDIS_REGISTER_XMM11, - ZYDIS_REGISTER_XMM12, ZYDIS_REGISTER_XMM13, ZYDIS_REGISTER_XMM14, ZYDIS_REGISTER_XMM15, - ZYDIS_REGISTER_XMM16, ZYDIS_REGISTER_XMM17, ZYDIS_REGISTER_XMM18, ZYDIS_REGISTER_XMM19, - ZYDIS_REGISTER_XMM20, ZYDIS_REGISTER_XMM21, ZYDIS_REGISTER_XMM22, ZYDIS_REGISTER_XMM23, - ZYDIS_REGISTER_XMM24, ZYDIS_REGISTER_XMM25, ZYDIS_REGISTER_XMM26, ZYDIS_REGISTER_XMM27, - ZYDIS_REGISTER_XMM28, ZYDIS_REGISTER_XMM29, ZYDIS_REGISTER_XMM30, ZYDIS_REGISTER_XMM31, - // Floating point vector registers 256-bit - ZYDIS_REGISTER_YMM0, ZYDIS_REGISTER_YMM1, ZYDIS_REGISTER_YMM2, ZYDIS_REGISTER_YMM3, - ZYDIS_REGISTER_YMM4, ZYDIS_REGISTER_YMM5, ZYDIS_REGISTER_YMM6, ZYDIS_REGISTER_YMM7, - ZYDIS_REGISTER_YMM8, ZYDIS_REGISTER_YMM9, ZYDIS_REGISTER_YMM10, ZYDIS_REGISTER_YMM11, - ZYDIS_REGISTER_YMM12, ZYDIS_REGISTER_YMM13, ZYDIS_REGISTER_YMM14, ZYDIS_REGISTER_YMM15, - ZYDIS_REGISTER_YMM16, ZYDIS_REGISTER_YMM17, ZYDIS_REGISTER_YMM18, ZYDIS_REGISTER_YMM19, - ZYDIS_REGISTER_YMM20, ZYDIS_REGISTER_YMM21, ZYDIS_REGISTER_YMM22, ZYDIS_REGISTER_YMM23, - ZYDIS_REGISTER_YMM24, ZYDIS_REGISTER_YMM25, ZYDIS_REGISTER_YMM26, ZYDIS_REGISTER_YMM27, - ZYDIS_REGISTER_YMM28, ZYDIS_REGISTER_YMM29, ZYDIS_REGISTER_YMM30, ZYDIS_REGISTER_YMM31, - // Floating point vector registers 512-bit - ZYDIS_REGISTER_ZMM0, ZYDIS_REGISTER_ZMM1, ZYDIS_REGISTER_ZMM2, ZYDIS_REGISTER_ZMM3, - ZYDIS_REGISTER_ZMM4, ZYDIS_REGISTER_ZMM5, ZYDIS_REGISTER_ZMM6, ZYDIS_REGISTER_ZMM7, - ZYDIS_REGISTER_ZMM8, ZYDIS_REGISTER_ZMM9, ZYDIS_REGISTER_ZMM10, ZYDIS_REGISTER_ZMM11, - ZYDIS_REGISTER_ZMM12, ZYDIS_REGISTER_ZMM13, ZYDIS_REGISTER_ZMM14, ZYDIS_REGISTER_ZMM15, - ZYDIS_REGISTER_ZMM16, ZYDIS_REGISTER_ZMM17, ZYDIS_REGISTER_ZMM18, ZYDIS_REGISTER_ZMM19, - ZYDIS_REGISTER_ZMM20, ZYDIS_REGISTER_ZMM21, ZYDIS_REGISTER_ZMM22, ZYDIS_REGISTER_ZMM23, - ZYDIS_REGISTER_ZMM24, ZYDIS_REGISTER_ZMM25, ZYDIS_REGISTER_ZMM26, ZYDIS_REGISTER_ZMM27, - ZYDIS_REGISTER_ZMM28, ZYDIS_REGISTER_ZMM29, ZYDIS_REGISTER_ZMM30, ZYDIS_REGISTER_ZMM31, - // Flags registers - ZYDIS_REGISTER_FLAGS, ZYDIS_REGISTER_EFLAGS, ZYDIS_REGISTER_RFLAGS, - // IP registers - ZYDIS_REGISTER_IP, ZYDIS_REGISTER_EIP, ZYDIS_REGISTER_RIP, - // Segment registers - ZYDIS_REGISTER_ES, ZYDIS_REGISTER_CS, ZYDIS_REGISTER_SS, ZYDIS_REGISTER_DS, - ZYDIS_REGISTER_FS, ZYDIS_REGISTER_GS, - // Table registers - ZYDIS_REGISTER_GDTR, ZYDIS_REGISTER_LDTR, ZYDIS_REGISTER_IDTR, ZYDIS_REGISTER_TR, - // Test registers - ZYDIS_REGISTER_TR0, ZYDIS_REGISTER_TR1, ZYDIS_REGISTER_TR2, ZYDIS_REGISTER_TR3, - ZYDIS_REGISTER_TR4, ZYDIS_REGISTER_TR5, ZYDIS_REGISTER_TR6, ZYDIS_REGISTER_TR7, - // Control registers - ZYDIS_REGISTER_CR0, ZYDIS_REGISTER_CR1, ZYDIS_REGISTER_CR2, ZYDIS_REGISTER_CR3, - ZYDIS_REGISTER_CR4, ZYDIS_REGISTER_CR5, ZYDIS_REGISTER_CR6, ZYDIS_REGISTER_CR7, - ZYDIS_REGISTER_CR8, ZYDIS_REGISTER_CR9, ZYDIS_REGISTER_CR10, ZYDIS_REGISTER_CR11, - ZYDIS_REGISTER_CR12, ZYDIS_REGISTER_CR13, ZYDIS_REGISTER_CR14, ZYDIS_REGISTER_CR15, - // Debug registers - ZYDIS_REGISTER_DR0, ZYDIS_REGISTER_DR1, ZYDIS_REGISTER_DR2, ZYDIS_REGISTER_DR3, - ZYDIS_REGISTER_DR4, ZYDIS_REGISTER_DR5, ZYDIS_REGISTER_DR6, ZYDIS_REGISTER_DR7, - ZYDIS_REGISTER_DR8, ZYDIS_REGISTER_DR9, ZYDIS_REGISTER_DR10, ZYDIS_REGISTER_DR11, - ZYDIS_REGISTER_DR12, ZYDIS_REGISTER_DR13, ZYDIS_REGISTER_DR14, ZYDIS_REGISTER_DR15, - // Mask registers - ZYDIS_REGISTER_K0, ZYDIS_REGISTER_K1, ZYDIS_REGISTER_K2, ZYDIS_REGISTER_K3, - ZYDIS_REGISTER_K4, ZYDIS_REGISTER_K5, ZYDIS_REGISTER_K6, ZYDIS_REGISTER_K7, - // Bound registers - ZYDIS_REGISTER_BND0, ZYDIS_REGISTER_BND1, ZYDIS_REGISTER_BND2, ZYDIS_REGISTER_BND3, - ZYDIS_REGISTER_BNDCFG, ZYDIS_REGISTER_BNDSTATUS, - // Misc registers - ZYDIS_REGISTER_MXCSR, ZYDIS_REGISTER_PKRU, ZYDIS_REGISTER_XCR0, - - /** - * @brief Maximum value of this enum. - */ - ZYDIS_REGISTER_MAX_VALUE = ZYDIS_REGISTER_XCR0, - /** - * @brief Minimum amount of bits required to store a value of this enum. - */ - ZYDIS_REGISTER_MIN_BITS = 0x0008 -}; +#include /* ---------------------------------------------------------------------------------------------- */ /* Register classes */ diff --git a/include/Zydis/SharedTypes.h b/include/Zydis/SharedTypes.h index a457857..1d9fd52 100644 --- a/include/Zydis/SharedTypes.h +++ b/include/Zydis/SharedTypes.h @@ -94,6 +94,7 @@ enum ZydisMachineModes * @brief 16 bit real mode. */ ZYDIS_MACHINE_MODE_REAL_16, + /** * @brief Maximum value of this enum. */ @@ -118,6 +119,10 @@ enum ZydisAddressWidths ZYDIS_ADDRESS_WIDTH_16 = 16, ZYDIS_ADDRESS_WIDTH_32 = 32, ZYDIS_ADDRESS_WIDTH_64 = 64, + + /** + * @brief Maximum value of this enum. + */ ZYDIS_ADDRESS_WIDTH_MAX_VALUE = ZYDIS_ADDRESS_WIDTH_64 }; @@ -144,6 +149,10 @@ enum ZydisElementTypes ZYDIS_ELEMENT_TYPE_FLOAT64, ZYDIS_ELEMENT_TYPE_FLOAT80, ZYDIS_ELEMENT_TYPE_LONGBCD, + + /** + * @brief Maximum value of this enum. + */ ZYDIS_ELEMENT_TYPE_MAX_VALUE = ZYDIS_ELEMENT_TYPE_LONGBCD }; @@ -186,6 +195,7 @@ enum ZydisOperandTypes * @brief The operand is an immediate operand. */ ZYDIS_OPERAND_TYPE_IMMEDIATE, + /** * @brief Maximum value of this enum. */ @@ -241,6 +251,10 @@ enum ZydisOperandEncodings ZYDIS_OPERAND_ENCODING_JIMM16_32_64, ZYDIS_OPERAND_ENCODING_JIMM32_32_64, ZYDIS_OPERAND_ENCODING_JIMM16_32_32, + + /** + * @brief Maximum value of this enum. + */ ZYDIS_OPERAND_ENCODING_MAX_VALUE = ZYDIS_OPERAND_ENCODING_JIMM16_32_32 }; @@ -271,6 +285,7 @@ enum ZydisOperandVisibilities * @brief The operand is part of the opcode, and not typically listed as an operand. */ ZYDIS_OPERAND_VISIBILITY_HIDDEN, + /** * @brief Maximum value of this enum. */ @@ -379,6 +394,7 @@ enum ZydisInstructionEncodings * @brief The instruction uses the MVEX-encoding. */ ZYDIS_INSTRUCTION_ENCODING_MVEX, + /** * @brief Maximum value of this enum. */ @@ -407,7 +423,11 @@ enum ZydisOpcodeMaps ZYDIS_OPCODE_MAP_XOP8, ZYDIS_OPCODE_MAP_XOP9, ZYDIS_OPCODE_MAP_XOPA, - ZYDIS_OPCODE_MAP_MAX_VALUE = ZYDIS_OPCODE_MAP_XOP9 + + /** + * @brief Maximum value of this enum. + */ + ZYDIS_OPCODE_MAP_MAX_VALUE = ZYDIS_OPCODE_MAP_XOPA }; /* ---------------------------------------------------------------------------------------------- */ diff --git a/src/Generated/EnumRegister.inc b/src/Generated/EnumRegister.inc new file mode 100644 index 0000000..fb32576 --- /dev/null +++ b/src/Generated/EnumRegister.inc @@ -0,0 +1,277 @@ +static const ZydisStaticString zydisRegisterStrings[] = +{ + ZYDIS_MAKE_STATIC_STRING("none"), + + // General purpose registers 8-bit, + ZYDIS_MAKE_STATIC_STRING("al"), + ZYDIS_MAKE_STATIC_STRING("cl"), + ZYDIS_MAKE_STATIC_STRING("dl"), + ZYDIS_MAKE_STATIC_STRING("bl"), + ZYDIS_MAKE_STATIC_STRING("ah"), + ZYDIS_MAKE_STATIC_STRING("ch"), + ZYDIS_MAKE_STATIC_STRING("dh"), + ZYDIS_MAKE_STATIC_STRING("bh"), + ZYDIS_MAKE_STATIC_STRING("spl"), + ZYDIS_MAKE_STATIC_STRING("bpl"), + ZYDIS_MAKE_STATIC_STRING("sil"), + ZYDIS_MAKE_STATIC_STRING("dil"), + ZYDIS_MAKE_STATIC_STRING("r8b"), + ZYDIS_MAKE_STATIC_STRING("r9b"), + ZYDIS_MAKE_STATIC_STRING("r10b"), + ZYDIS_MAKE_STATIC_STRING("r11b"), + ZYDIS_MAKE_STATIC_STRING("r12b"), + ZYDIS_MAKE_STATIC_STRING("r13b"), + ZYDIS_MAKE_STATIC_STRING("r14b"), + ZYDIS_MAKE_STATIC_STRING("r15b"), + // General purpose registers 16-bit, + ZYDIS_MAKE_STATIC_STRING("ax"), + ZYDIS_MAKE_STATIC_STRING("cx"), + ZYDIS_MAKE_STATIC_STRING("dx"), + ZYDIS_MAKE_STATIC_STRING("bx"), + ZYDIS_MAKE_STATIC_STRING("sp"), + ZYDIS_MAKE_STATIC_STRING("bp"), + ZYDIS_MAKE_STATIC_STRING("si"), + ZYDIS_MAKE_STATIC_STRING("di"), + ZYDIS_MAKE_STATIC_STRING("r8w"), + ZYDIS_MAKE_STATIC_STRING("r9w"), + ZYDIS_MAKE_STATIC_STRING("r10w"), + ZYDIS_MAKE_STATIC_STRING("r11w"), + ZYDIS_MAKE_STATIC_STRING("r12w"), + ZYDIS_MAKE_STATIC_STRING("r13w"), + ZYDIS_MAKE_STATIC_STRING("r14w"), + ZYDIS_MAKE_STATIC_STRING("r15w"), + // General purpose registers 32-bit, + ZYDIS_MAKE_STATIC_STRING("eax"), + ZYDIS_MAKE_STATIC_STRING("ecx"), + ZYDIS_MAKE_STATIC_STRING("edx"), + ZYDIS_MAKE_STATIC_STRING("ebx"), + ZYDIS_MAKE_STATIC_STRING("esp"), + ZYDIS_MAKE_STATIC_STRING("ebp"), + ZYDIS_MAKE_STATIC_STRING("esi"), + ZYDIS_MAKE_STATIC_STRING("edi"), + ZYDIS_MAKE_STATIC_STRING("r8d"), + ZYDIS_MAKE_STATIC_STRING("r9d"), + ZYDIS_MAKE_STATIC_STRING("r10d"), + ZYDIS_MAKE_STATIC_STRING("r11d"), + ZYDIS_MAKE_STATIC_STRING("r12d"), + ZYDIS_MAKE_STATIC_STRING("r13d"), + ZYDIS_MAKE_STATIC_STRING("r14d"), + ZYDIS_MAKE_STATIC_STRING("r15d"), + // General purpose registers 64-bit, + ZYDIS_MAKE_STATIC_STRING("rax"), + ZYDIS_MAKE_STATIC_STRING("rcx"), + ZYDIS_MAKE_STATIC_STRING("rdx"), + ZYDIS_MAKE_STATIC_STRING("rbx"), + ZYDIS_MAKE_STATIC_STRING("rsp"), + ZYDIS_MAKE_STATIC_STRING("rbp"), + ZYDIS_MAKE_STATIC_STRING("rsi"), + ZYDIS_MAKE_STATIC_STRING("rdi"), + ZYDIS_MAKE_STATIC_STRING("r8"), + ZYDIS_MAKE_STATIC_STRING("r9"), + ZYDIS_MAKE_STATIC_STRING("r10"), + ZYDIS_MAKE_STATIC_STRING("r11"), + ZYDIS_MAKE_STATIC_STRING("r12"), + ZYDIS_MAKE_STATIC_STRING("r13"), + ZYDIS_MAKE_STATIC_STRING("r14"), + ZYDIS_MAKE_STATIC_STRING("r15"), + // Floating point legacy registers, + ZYDIS_MAKE_STATIC_STRING("st0"), + ZYDIS_MAKE_STATIC_STRING("st1"), + ZYDIS_MAKE_STATIC_STRING("st2"), + ZYDIS_MAKE_STATIC_STRING("st3"), + ZYDIS_MAKE_STATIC_STRING("st4"), + ZYDIS_MAKE_STATIC_STRING("st5"), + ZYDIS_MAKE_STATIC_STRING("st6"), + ZYDIS_MAKE_STATIC_STRING("st7"), + // Floating point multimedia registers, + ZYDIS_MAKE_STATIC_STRING("mm0"), + ZYDIS_MAKE_STATIC_STRING("mm1"), + ZYDIS_MAKE_STATIC_STRING("mm2"), + ZYDIS_MAKE_STATIC_STRING("mm3"), + ZYDIS_MAKE_STATIC_STRING("mm4"), + ZYDIS_MAKE_STATIC_STRING("mm5"), + ZYDIS_MAKE_STATIC_STRING("mm6"), + ZYDIS_MAKE_STATIC_STRING("mm7"), + // Floating point vector registers 128-bit, + ZYDIS_MAKE_STATIC_STRING("xmm0"), + ZYDIS_MAKE_STATIC_STRING("xmm1"), + ZYDIS_MAKE_STATIC_STRING("xmm2"), + ZYDIS_MAKE_STATIC_STRING("xmm3"), + ZYDIS_MAKE_STATIC_STRING("xmm4"), + ZYDIS_MAKE_STATIC_STRING("xmm5"), + ZYDIS_MAKE_STATIC_STRING("xmm6"), + ZYDIS_MAKE_STATIC_STRING("xmm7"), + ZYDIS_MAKE_STATIC_STRING("xmm8"), + ZYDIS_MAKE_STATIC_STRING("xmm9"), + ZYDIS_MAKE_STATIC_STRING("xmm10"), + ZYDIS_MAKE_STATIC_STRING("xmm11"), + ZYDIS_MAKE_STATIC_STRING("xmm12"), + ZYDIS_MAKE_STATIC_STRING("xmm13"), + ZYDIS_MAKE_STATIC_STRING("xmm14"), + ZYDIS_MAKE_STATIC_STRING("xmm15"), + ZYDIS_MAKE_STATIC_STRING("xmm16"), + ZYDIS_MAKE_STATIC_STRING("xmm17"), + ZYDIS_MAKE_STATIC_STRING("xmm18"), + ZYDIS_MAKE_STATIC_STRING("xmm19"), + ZYDIS_MAKE_STATIC_STRING("xmm20"), + ZYDIS_MAKE_STATIC_STRING("xmm21"), + ZYDIS_MAKE_STATIC_STRING("xmm22"), + ZYDIS_MAKE_STATIC_STRING("xmm23"), + ZYDIS_MAKE_STATIC_STRING("xmm24"), + ZYDIS_MAKE_STATIC_STRING("xmm25"), + ZYDIS_MAKE_STATIC_STRING("xmm26"), + ZYDIS_MAKE_STATIC_STRING("xmm27"), + ZYDIS_MAKE_STATIC_STRING("xmm28"), + ZYDIS_MAKE_STATIC_STRING("xmm29"), + ZYDIS_MAKE_STATIC_STRING("xmm30"), + ZYDIS_MAKE_STATIC_STRING("xmm31"), + // Floating point vector registers 256-bit, + ZYDIS_MAKE_STATIC_STRING("ymm0"), + ZYDIS_MAKE_STATIC_STRING("ymm1"), + ZYDIS_MAKE_STATIC_STRING("ymm2"), + ZYDIS_MAKE_STATIC_STRING("ymm3"), + ZYDIS_MAKE_STATIC_STRING("ymm4"), + ZYDIS_MAKE_STATIC_STRING("ymm5"), + ZYDIS_MAKE_STATIC_STRING("ymm6"), + ZYDIS_MAKE_STATIC_STRING("ymm7"), + ZYDIS_MAKE_STATIC_STRING("ymm8"), + ZYDIS_MAKE_STATIC_STRING("ymm9"), + ZYDIS_MAKE_STATIC_STRING("ymm10"), + ZYDIS_MAKE_STATIC_STRING("ymm11"), + ZYDIS_MAKE_STATIC_STRING("ymm12"), + ZYDIS_MAKE_STATIC_STRING("ymm13"), + ZYDIS_MAKE_STATIC_STRING("ymm14"), + ZYDIS_MAKE_STATIC_STRING("ymm15"), + ZYDIS_MAKE_STATIC_STRING("ymm16"), + ZYDIS_MAKE_STATIC_STRING("ymm17"), + ZYDIS_MAKE_STATIC_STRING("ymm18"), + ZYDIS_MAKE_STATIC_STRING("ymm19"), + ZYDIS_MAKE_STATIC_STRING("ymm20"), + ZYDIS_MAKE_STATIC_STRING("ymm21"), + ZYDIS_MAKE_STATIC_STRING("ymm22"), + ZYDIS_MAKE_STATIC_STRING("ymm23"), + ZYDIS_MAKE_STATIC_STRING("ymm24"), + ZYDIS_MAKE_STATIC_STRING("ymm25"), + ZYDIS_MAKE_STATIC_STRING("ymm26"), + ZYDIS_MAKE_STATIC_STRING("ymm27"), + ZYDIS_MAKE_STATIC_STRING("ymm28"), + ZYDIS_MAKE_STATIC_STRING("ymm29"), + ZYDIS_MAKE_STATIC_STRING("ymm30"), + ZYDIS_MAKE_STATIC_STRING("ymm31"), + // Floating point vector registers 512-bit, + ZYDIS_MAKE_STATIC_STRING("zmm0"), + ZYDIS_MAKE_STATIC_STRING("zmm1"), + ZYDIS_MAKE_STATIC_STRING("zmm2"), + ZYDIS_MAKE_STATIC_STRING("zmm3"), + ZYDIS_MAKE_STATIC_STRING("zmm4"), + ZYDIS_MAKE_STATIC_STRING("zmm5"), + ZYDIS_MAKE_STATIC_STRING("zmm6"), + ZYDIS_MAKE_STATIC_STRING("zmm7"), + ZYDIS_MAKE_STATIC_STRING("zmm8"), + ZYDIS_MAKE_STATIC_STRING("zmm9"), + ZYDIS_MAKE_STATIC_STRING("zmm10"), + ZYDIS_MAKE_STATIC_STRING("zmm11"), + ZYDIS_MAKE_STATIC_STRING("zmm12"), + ZYDIS_MAKE_STATIC_STRING("zmm13"), + ZYDIS_MAKE_STATIC_STRING("zmm14"), + ZYDIS_MAKE_STATIC_STRING("zmm15"), + ZYDIS_MAKE_STATIC_STRING("zmm16"), + ZYDIS_MAKE_STATIC_STRING("zmm17"), + ZYDIS_MAKE_STATIC_STRING("zmm18"), + ZYDIS_MAKE_STATIC_STRING("zmm19"), + ZYDIS_MAKE_STATIC_STRING("zmm20"), + ZYDIS_MAKE_STATIC_STRING("zmm21"), + ZYDIS_MAKE_STATIC_STRING("zmm22"), + ZYDIS_MAKE_STATIC_STRING("zmm23"), + ZYDIS_MAKE_STATIC_STRING("zmm24"), + ZYDIS_MAKE_STATIC_STRING("zmm25"), + ZYDIS_MAKE_STATIC_STRING("zmm26"), + ZYDIS_MAKE_STATIC_STRING("zmm27"), + ZYDIS_MAKE_STATIC_STRING("zmm28"), + ZYDIS_MAKE_STATIC_STRING("zmm29"), + ZYDIS_MAKE_STATIC_STRING("zmm30"), + ZYDIS_MAKE_STATIC_STRING("zmm31"), + // Flags registers, + ZYDIS_MAKE_STATIC_STRING("flags"), + ZYDIS_MAKE_STATIC_STRING("eflags"), + ZYDIS_MAKE_STATIC_STRING("rflags"), + // Instruction-pointer registers, + ZYDIS_MAKE_STATIC_STRING("ip"), + ZYDIS_MAKE_STATIC_STRING("eip"), + ZYDIS_MAKE_STATIC_STRING("rip"), + // Segment registers, + ZYDIS_MAKE_STATIC_STRING("es"), + ZYDIS_MAKE_STATIC_STRING("cs"), + ZYDIS_MAKE_STATIC_STRING("ss"), + ZYDIS_MAKE_STATIC_STRING("ds"), + ZYDIS_MAKE_STATIC_STRING("fs"), + ZYDIS_MAKE_STATIC_STRING("gs"), + // Table registers, + ZYDIS_MAKE_STATIC_STRING("gdtr"), + ZYDIS_MAKE_STATIC_STRING("ldtr"), + ZYDIS_MAKE_STATIC_STRING("idtr"), + ZYDIS_MAKE_STATIC_STRING("tr"), + // Test registers, + ZYDIS_MAKE_STATIC_STRING("tr0"), + ZYDIS_MAKE_STATIC_STRING("tr1"), + ZYDIS_MAKE_STATIC_STRING("tr2"), + ZYDIS_MAKE_STATIC_STRING("tr3"), + ZYDIS_MAKE_STATIC_STRING("tr4"), + ZYDIS_MAKE_STATIC_STRING("tr5"), + ZYDIS_MAKE_STATIC_STRING("tr6"), + ZYDIS_MAKE_STATIC_STRING("tr7"), + // Control registers, + ZYDIS_MAKE_STATIC_STRING("cr0"), + ZYDIS_MAKE_STATIC_STRING("cr1"), + ZYDIS_MAKE_STATIC_STRING("cr2"), + ZYDIS_MAKE_STATIC_STRING("cr3"), + ZYDIS_MAKE_STATIC_STRING("cr4"), + ZYDIS_MAKE_STATIC_STRING("cr5"), + ZYDIS_MAKE_STATIC_STRING("cr6"), + ZYDIS_MAKE_STATIC_STRING("cr7"), + ZYDIS_MAKE_STATIC_STRING("cr8"), + ZYDIS_MAKE_STATIC_STRING("cr9"), + ZYDIS_MAKE_STATIC_STRING("cr10"), + ZYDIS_MAKE_STATIC_STRING("cr11"), + ZYDIS_MAKE_STATIC_STRING("cr12"), + ZYDIS_MAKE_STATIC_STRING("cr13"), + ZYDIS_MAKE_STATIC_STRING("cr14"), + ZYDIS_MAKE_STATIC_STRING("cr15"), + // Debug registers, + ZYDIS_MAKE_STATIC_STRING("dr0"), + ZYDIS_MAKE_STATIC_STRING("dr1"), + ZYDIS_MAKE_STATIC_STRING("dr2"), + ZYDIS_MAKE_STATIC_STRING("dr3"), + ZYDIS_MAKE_STATIC_STRING("dr4"), + ZYDIS_MAKE_STATIC_STRING("dr5"), + ZYDIS_MAKE_STATIC_STRING("dr6"), + ZYDIS_MAKE_STATIC_STRING("dr7"), + ZYDIS_MAKE_STATIC_STRING("dr8"), + ZYDIS_MAKE_STATIC_STRING("dr9"), + ZYDIS_MAKE_STATIC_STRING("dr10"), + ZYDIS_MAKE_STATIC_STRING("dr11"), + ZYDIS_MAKE_STATIC_STRING("dr12"), + ZYDIS_MAKE_STATIC_STRING("dr13"), + ZYDIS_MAKE_STATIC_STRING("dr14"), + ZYDIS_MAKE_STATIC_STRING("dr15"), + // Mask registers, + ZYDIS_MAKE_STATIC_STRING("k0"), + ZYDIS_MAKE_STATIC_STRING("k1"), + ZYDIS_MAKE_STATIC_STRING("k2"), + ZYDIS_MAKE_STATIC_STRING("k3"), + ZYDIS_MAKE_STATIC_STRING("k4"), + ZYDIS_MAKE_STATIC_STRING("k5"), + ZYDIS_MAKE_STATIC_STRING("k6"), + ZYDIS_MAKE_STATIC_STRING("k7"), + // Bound registers, + ZYDIS_MAKE_STATIC_STRING("bnd0"), + ZYDIS_MAKE_STATIC_STRING("bnd1"), + ZYDIS_MAKE_STATIC_STRING("bnd2"), + ZYDIS_MAKE_STATIC_STRING("bnd3"), + ZYDIS_MAKE_STATIC_STRING("bndcfg"), + ZYDIS_MAKE_STATIC_STRING("bndstatus"), + // Uncategorized, + ZYDIS_MAKE_STATIC_STRING("mxcsr"), + ZYDIS_MAKE_STATIC_STRING("pkru"), + ZYDIS_MAKE_STATIC_STRING("xcr0") +}; diff --git a/src/Register.c b/src/Register.c index dcba8d8..97c3956 100644 --- a/src/Register.c +++ b/src/Register.c @@ -30,157 +30,7 @@ /* Register strings */ /* ============================================================================================== */ -static const ZydisStaticString registerStrings[] = -{ - ZYDIS_MAKE_STATIC_STRING("none"), - // General purpose registers 8-bit - ZYDIS_MAKE_STATIC_STRING("al"), ZYDIS_MAKE_STATIC_STRING("cl"), - ZYDIS_MAKE_STATIC_STRING("dl"), ZYDIS_MAKE_STATIC_STRING("bl"), - ZYDIS_MAKE_STATIC_STRING("ah"), ZYDIS_MAKE_STATIC_STRING("ch"), - ZYDIS_MAKE_STATIC_STRING("dh"), ZYDIS_MAKE_STATIC_STRING("bh"), - ZYDIS_MAKE_STATIC_STRING("spl"), ZYDIS_MAKE_STATIC_STRING("bpl"), - ZYDIS_MAKE_STATIC_STRING("sil"), ZYDIS_MAKE_STATIC_STRING("dil"), - ZYDIS_MAKE_STATIC_STRING("r8b"), ZYDIS_MAKE_STATIC_STRING("r9b"), - ZYDIS_MAKE_STATIC_STRING("r10b"), ZYDIS_MAKE_STATIC_STRING("r11b"), - ZYDIS_MAKE_STATIC_STRING("r12b"), ZYDIS_MAKE_STATIC_STRING("r13b"), - ZYDIS_MAKE_STATIC_STRING("r14b"), ZYDIS_MAKE_STATIC_STRING("r15b"), - // General purpose registers 16-bit - ZYDIS_MAKE_STATIC_STRING("ax"), ZYDIS_MAKE_STATIC_STRING("cx"), - ZYDIS_MAKE_STATIC_STRING("dx"), ZYDIS_MAKE_STATIC_STRING("bx"), - ZYDIS_MAKE_STATIC_STRING("sp"), ZYDIS_MAKE_STATIC_STRING("bp"), - ZYDIS_MAKE_STATIC_STRING("si"), ZYDIS_MAKE_STATIC_STRING("di"), - ZYDIS_MAKE_STATIC_STRING("r8w"), ZYDIS_MAKE_STATIC_STRING("r9w"), - ZYDIS_MAKE_STATIC_STRING("r10w"), ZYDIS_MAKE_STATIC_STRING("r11w"), - ZYDIS_MAKE_STATIC_STRING("r12w"), ZYDIS_MAKE_STATIC_STRING("r13w"), - ZYDIS_MAKE_STATIC_STRING("r14w"), ZYDIS_MAKE_STATIC_STRING("r15w"), - // General purpose registers 32-bit - ZYDIS_MAKE_STATIC_STRING("eax"), ZYDIS_MAKE_STATIC_STRING("ecx"), - ZYDIS_MAKE_STATIC_STRING("edx"), ZYDIS_MAKE_STATIC_STRING("ebx"), - ZYDIS_MAKE_STATIC_STRING("esp"), ZYDIS_MAKE_STATIC_STRING("ebp"), - ZYDIS_MAKE_STATIC_STRING("esi"), ZYDIS_MAKE_STATIC_STRING("edi"), - ZYDIS_MAKE_STATIC_STRING("r8d"), ZYDIS_MAKE_STATIC_STRING("r9d"), - ZYDIS_MAKE_STATIC_STRING("r10d"), ZYDIS_MAKE_STATIC_STRING("r11d"), - ZYDIS_MAKE_STATIC_STRING("r12d"), ZYDIS_MAKE_STATIC_STRING("r13d"), - ZYDIS_MAKE_STATIC_STRING("r14d"), ZYDIS_MAKE_STATIC_STRING("r15d"), - // General purpose registers 64-bi - ZYDIS_MAKE_STATIC_STRING("rax"), ZYDIS_MAKE_STATIC_STRING("rcx"), - ZYDIS_MAKE_STATIC_STRING("rdx"), ZYDIS_MAKE_STATIC_STRING("rbx"), - ZYDIS_MAKE_STATIC_STRING("rsp"), ZYDIS_MAKE_STATIC_STRING("rbp"), - ZYDIS_MAKE_STATIC_STRING("rsi"), ZYDIS_MAKE_STATIC_STRING("rdi"), - ZYDIS_MAKE_STATIC_STRING("r8"), ZYDIS_MAKE_STATIC_STRING("r9"), - ZYDIS_MAKE_STATIC_STRING("r10"), ZYDIS_MAKE_STATIC_STRING("r11"), - ZYDIS_MAKE_STATIC_STRING("r12"), ZYDIS_MAKE_STATIC_STRING("r13"), - ZYDIS_MAKE_STATIC_STRING("r14"), ZYDIS_MAKE_STATIC_STRING("r15"), - // Floating point legacy registers - ZYDIS_MAKE_STATIC_STRING("st0"), ZYDIS_MAKE_STATIC_STRING("st1"), - ZYDIS_MAKE_STATIC_STRING("st2"), ZYDIS_MAKE_STATIC_STRING("st3"), - ZYDIS_MAKE_STATIC_STRING("st4"), ZYDIS_MAKE_STATIC_STRING("st5"), - ZYDIS_MAKE_STATIC_STRING("st6"), ZYDIS_MAKE_STATIC_STRING("st7"), - // Floating point multimedia registers - ZYDIS_MAKE_STATIC_STRING("mm0"), ZYDIS_MAKE_STATIC_STRING("mm1"), - ZYDIS_MAKE_STATIC_STRING("mm2"), ZYDIS_MAKE_STATIC_STRING("mm3"), - ZYDIS_MAKE_STATIC_STRING("mm4"), ZYDIS_MAKE_STATIC_STRING("mm5"), - ZYDIS_MAKE_STATIC_STRING("mm6"), ZYDIS_MAKE_STATIC_STRING("mm7"), - // Floating point vector registers 128-bit - ZYDIS_MAKE_STATIC_STRING("xmm0"), ZYDIS_MAKE_STATIC_STRING("xmm1"), - ZYDIS_MAKE_STATIC_STRING("xmm2"), ZYDIS_MAKE_STATIC_STRING("xmm3"), - ZYDIS_MAKE_STATIC_STRING("xmm4"), ZYDIS_MAKE_STATIC_STRING("xmm5"), - ZYDIS_MAKE_STATIC_STRING("xmm6"), ZYDIS_MAKE_STATIC_STRING("xmm7"), - ZYDIS_MAKE_STATIC_STRING("xmm8"), ZYDIS_MAKE_STATIC_STRING("xmm9"), - ZYDIS_MAKE_STATIC_STRING("xmm10"), ZYDIS_MAKE_STATIC_STRING("xmm11"), - ZYDIS_MAKE_STATIC_STRING("xmm12"), ZYDIS_MAKE_STATIC_STRING("xmm13"), - ZYDIS_MAKE_STATIC_STRING("xmm14"), ZYDIS_MAKE_STATIC_STRING("xmm15"), - ZYDIS_MAKE_STATIC_STRING("xmm16"), ZYDIS_MAKE_STATIC_STRING("xmm17"), - ZYDIS_MAKE_STATIC_STRING("xmm18"), ZYDIS_MAKE_STATIC_STRING("xmm19"), - ZYDIS_MAKE_STATIC_STRING("xmm20"), ZYDIS_MAKE_STATIC_STRING("xmm21"), - ZYDIS_MAKE_STATIC_STRING("xmm22"), ZYDIS_MAKE_STATIC_STRING("xmm23"), - ZYDIS_MAKE_STATIC_STRING("xmm24"), ZYDIS_MAKE_STATIC_STRING("xmm25"), - ZYDIS_MAKE_STATIC_STRING("xmm26"), ZYDIS_MAKE_STATIC_STRING("xmm27"), - ZYDIS_MAKE_STATIC_STRING("xmm28"), ZYDIS_MAKE_STATIC_STRING("xmm29"), - ZYDIS_MAKE_STATIC_STRING("xmm30"), ZYDIS_MAKE_STATIC_STRING("xmm31"), - // Floating point vector registers 256-bit - ZYDIS_MAKE_STATIC_STRING("ymm0"), ZYDIS_MAKE_STATIC_STRING("ymm1"), - ZYDIS_MAKE_STATIC_STRING("ymm2"), ZYDIS_MAKE_STATIC_STRING("ymm3"), - ZYDIS_MAKE_STATIC_STRING("ymm4"), ZYDIS_MAKE_STATIC_STRING("ymm5"), - ZYDIS_MAKE_STATIC_STRING("ymm6"), ZYDIS_MAKE_STATIC_STRING("ymm7"), - ZYDIS_MAKE_STATIC_STRING("ymm8"), ZYDIS_MAKE_STATIC_STRING("ymm9"), - ZYDIS_MAKE_STATIC_STRING("ymm10"), ZYDIS_MAKE_STATIC_STRING("ymm11"), - ZYDIS_MAKE_STATIC_STRING("ymm12"), ZYDIS_MAKE_STATIC_STRING("ymm13"), - ZYDIS_MAKE_STATIC_STRING("ymm14"), ZYDIS_MAKE_STATIC_STRING("ymm15"), - ZYDIS_MAKE_STATIC_STRING("ymm16"), ZYDIS_MAKE_STATIC_STRING("ymm17"), - ZYDIS_MAKE_STATIC_STRING("ymm18"), ZYDIS_MAKE_STATIC_STRING("ymm19"), - ZYDIS_MAKE_STATIC_STRING("ymm20"), ZYDIS_MAKE_STATIC_STRING("ymm21"), - ZYDIS_MAKE_STATIC_STRING("ymm22"), ZYDIS_MAKE_STATIC_STRING("ymm23"), - ZYDIS_MAKE_STATIC_STRING("ymm24"), ZYDIS_MAKE_STATIC_STRING("ymm25"), - ZYDIS_MAKE_STATIC_STRING("ymm26"), ZYDIS_MAKE_STATIC_STRING("ymm27"), - ZYDIS_MAKE_STATIC_STRING("ymm28"), ZYDIS_MAKE_STATIC_STRING("ymm29"), - ZYDIS_MAKE_STATIC_STRING("ymm30"), ZYDIS_MAKE_STATIC_STRING("ymm31"), - // Floating point vector registers 512-bit - ZYDIS_MAKE_STATIC_STRING("zmm0"), ZYDIS_MAKE_STATIC_STRING("zmm1"), - ZYDIS_MAKE_STATIC_STRING("zmm2"), ZYDIS_MAKE_STATIC_STRING("zmm3"), - ZYDIS_MAKE_STATIC_STRING("zmm4"), ZYDIS_MAKE_STATIC_STRING("zmm5"), - ZYDIS_MAKE_STATIC_STRING("zmm6"), ZYDIS_MAKE_STATIC_STRING("zmm7"), - ZYDIS_MAKE_STATIC_STRING("zmm8"), ZYDIS_MAKE_STATIC_STRING("zmm9"), - ZYDIS_MAKE_STATIC_STRING("zmm10"), ZYDIS_MAKE_STATIC_STRING("zmm11"), - ZYDIS_MAKE_STATIC_STRING("zmm12"), ZYDIS_MAKE_STATIC_STRING("zmm13"), - ZYDIS_MAKE_STATIC_STRING("zmm14"), ZYDIS_MAKE_STATIC_STRING("zmm15"), - ZYDIS_MAKE_STATIC_STRING("zmm16"), ZYDIS_MAKE_STATIC_STRING("zmm17"), - ZYDIS_MAKE_STATIC_STRING("zmm18"), ZYDIS_MAKE_STATIC_STRING("zmm19"), - ZYDIS_MAKE_STATIC_STRING("zmm20"), ZYDIS_MAKE_STATIC_STRING("zmm21"), - ZYDIS_MAKE_STATIC_STRING("zmm22"), ZYDIS_MAKE_STATIC_STRING("zmm23"), - ZYDIS_MAKE_STATIC_STRING("zmm24"), ZYDIS_MAKE_STATIC_STRING("zmm25"), - ZYDIS_MAKE_STATIC_STRING("zmm26"), ZYDIS_MAKE_STATIC_STRING("zmm27"), - ZYDIS_MAKE_STATIC_STRING("zmm28"), ZYDIS_MAKE_STATIC_STRING("zmm29"), - ZYDIS_MAKE_STATIC_STRING("zmm30"), ZYDIS_MAKE_STATIC_STRING("zmm31"), - // Flags registers - ZYDIS_MAKE_STATIC_STRING("flags"), ZYDIS_MAKE_STATIC_STRING("eflags"), - ZYDIS_MAKE_STATIC_STRING("rflags"), - // Instruction-pointer registers - ZYDIS_MAKE_STATIC_STRING("ip"), ZYDIS_MAKE_STATIC_STRING("eip"), - ZYDIS_MAKE_STATIC_STRING("rip"), - // Segment registers - ZYDIS_MAKE_STATIC_STRING("es"), ZYDIS_MAKE_STATIC_STRING("cs"), - ZYDIS_MAKE_STATIC_STRING("ss"), ZYDIS_MAKE_STATIC_STRING("ds"), - ZYDIS_MAKE_STATIC_STRING("fs"), ZYDIS_MAKE_STATIC_STRING("gs"), - // Table registers - ZYDIS_MAKE_STATIC_STRING("gdtr"), ZYDIS_MAKE_STATIC_STRING("ldtr"), - ZYDIS_MAKE_STATIC_STRING("idtr"), ZYDIS_MAKE_STATIC_STRING("tr"), - // Test registers - ZYDIS_MAKE_STATIC_STRING("tr0"), ZYDIS_MAKE_STATIC_STRING("tr1"), - ZYDIS_MAKE_STATIC_STRING("tr2"), ZYDIS_MAKE_STATIC_STRING("tr3"), - ZYDIS_MAKE_STATIC_STRING("tr4"), ZYDIS_MAKE_STATIC_STRING("tr5"), - ZYDIS_MAKE_STATIC_STRING("tr6"), ZYDIS_MAKE_STATIC_STRING("tr7"), - // Control registers - ZYDIS_MAKE_STATIC_STRING("cr0"), ZYDIS_MAKE_STATIC_STRING("cr1"), - ZYDIS_MAKE_STATIC_STRING("cr2"), ZYDIS_MAKE_STATIC_STRING("cr3"), - ZYDIS_MAKE_STATIC_STRING("cr4"), ZYDIS_MAKE_STATIC_STRING("cr5"), - ZYDIS_MAKE_STATIC_STRING("cr6"), ZYDIS_MAKE_STATIC_STRING("cr7"), - ZYDIS_MAKE_STATIC_STRING("cr8"), ZYDIS_MAKE_STATIC_STRING("cr9"), - ZYDIS_MAKE_STATIC_STRING("cr10"), ZYDIS_MAKE_STATIC_STRING("cr11"), - ZYDIS_MAKE_STATIC_STRING("cr12"), ZYDIS_MAKE_STATIC_STRING("cr13"), - ZYDIS_MAKE_STATIC_STRING("cr14"), ZYDIS_MAKE_STATIC_STRING("cr15"), - // Debug registers - ZYDIS_MAKE_STATIC_STRING("dr0"), ZYDIS_MAKE_STATIC_STRING("dr1"), - ZYDIS_MAKE_STATIC_STRING("dr2"), ZYDIS_MAKE_STATIC_STRING("dr3"), - ZYDIS_MAKE_STATIC_STRING("dr4"), ZYDIS_MAKE_STATIC_STRING("dr5"), - ZYDIS_MAKE_STATIC_STRING("dr6"), ZYDIS_MAKE_STATIC_STRING("dr7"), - ZYDIS_MAKE_STATIC_STRING("dr8"), ZYDIS_MAKE_STATIC_STRING("dr9"), - ZYDIS_MAKE_STATIC_STRING("dr10"), ZYDIS_MAKE_STATIC_STRING("dr11"), - ZYDIS_MAKE_STATIC_STRING("dr12"), ZYDIS_MAKE_STATIC_STRING("dr13"), - ZYDIS_MAKE_STATIC_STRING("dr14"), ZYDIS_MAKE_STATIC_STRING("dr15"), - // Mask registers - ZYDIS_MAKE_STATIC_STRING("k0"), ZYDIS_MAKE_STATIC_STRING("k1"), - ZYDIS_MAKE_STATIC_STRING("k2"), ZYDIS_MAKE_STATIC_STRING("k3"), - ZYDIS_MAKE_STATIC_STRING("k4"), ZYDIS_MAKE_STATIC_STRING("k5"), - ZYDIS_MAKE_STATIC_STRING("k6"), ZYDIS_MAKE_STATIC_STRING("k7"), - // Bound registers - ZYDIS_MAKE_STATIC_STRING("bnd0"), ZYDIS_MAKE_STATIC_STRING("bnd1"), - ZYDIS_MAKE_STATIC_STRING("bnd2"), ZYDIS_MAKE_STATIC_STRING("bnd3"), - ZYDIS_MAKE_STATIC_STRING("bndcfg"), ZYDIS_MAKE_STATIC_STRING("bndstatus"), - // Misc registers - ZYDIS_MAKE_STATIC_STRING("mxcsr"), ZYDIS_MAKE_STATIC_STRING("pkru"), - ZYDIS_MAKE_STATIC_STRING("xcr0") -}; +#include /* ============================================================================================== */ /* Register-class mapping */ @@ -333,20 +183,20 @@ ZydisRegisterWidth ZydisRegisterGetWidth64(ZydisRegister reg) const char* ZydisRegisterGetString(ZydisRegister reg) { - if (reg >= ZYDIS_ARRAY_SIZE(registerStrings)) + if (reg >= ZYDIS_ARRAY_SIZE(zydisRegisterStrings)) { return ZYDIS_NULL; } - return registerStrings[reg].buffer; + return zydisRegisterStrings[reg].buffer; } const ZydisStaticString* ZydisRegisterGetStaticString(ZydisRegister reg) { - if (reg >= ZYDIS_ARRAY_SIZE(registerStrings)) + if (reg >= ZYDIS_ARRAY_SIZE(zydisRegisterStrings)) { return ZYDIS_NULL; } - return ®isterStrings[reg]; + return &zydisRegisterStrings[reg]; } /* ============================================================================================== */