From c912af00f9b3b1b4b00e05d33ca1d47864658d07 Mon Sep 17 00:00:00 2001 From: Ende! Date: Mon, 16 Mar 2015 16:37:15 +0100 Subject: [PATCH] altered directory structure to use C implementation of library as the default --- Bindings/C/VXInstructionDecoderC.h | 304 --- Bindings/C/VXInstructionFormatterC.h | 161 -- Bindings/C/VXOpcodeTableC.h | 1504 ----------- .../VXDisassembler.hpp} | 19 +- .../VXDisassemblerTypes.hpp} | 171 +- .../Cpp}/VXDisassemblerUtils.cpp | 2 +- .../VXDisassemblerUtils.hpp} | 31 +- .../Cpp}/VXInstructionDecoder.cpp | 2 +- Bindings/Cpp/VXInstructionDecoder.hpp | 718 +++++ .../Cpp}/VXInstructionFormatter.cpp | 4 +- Bindings/Cpp/VXInstructionFormatter.hpp | 320 +++ .../Cpp}/VXOpcodeTable.cpp | 2 +- Bindings/Cpp/VXOpcodeTable.hpp | 1753 +++++++++++++ CMakeLists.txt | 74 +- Examples/{SimpleDemo => CppBindings}/Main.cpp | 3 +- .../CustomDataSource/CustomDataSource.vcxproj | 157 -- .../CustomDataSource.vcxproj.filters | 6 - .../CustomDataSource/{Main.cpp => Main.c} | 0 Examples/Examples.sln | 90 - Examples/PerformanceTest/{Main.cpp => Main.c} | 0 .../PerformanceTest/PerformanceTest.vcxproj | 157 -- .../PerformanceTest.vcxproj.filters | 6 - .../{CBindings/test.c => SimpleDemo/Main.c} | 2 +- Examples/SimpleDemo/SimpleDemo.vcxproj | 157 -- .../SimpleDemo/SimpleDemo.vcxproj.filters | 6 - Examples/SymbolResolver/{Main.cpp => Main.c} | 20 +- .../SymbolResolver/SymbolResolver.vcxproj | 157 -- .../SymbolResolver.vcxproj.filters | 6 - VerteronDisassemblerEngine.sln | 38 - VerteronDisassemblerEngine/VXDisassembler.h | 12 +- .../VXDisassemblerTypes.h | 169 +- .../VXDisassemblerUtils.c | 2 +- .../VXDisassemblerUtils.h | 31 +- .../VXInstructionDecoder.c | 16 +- .../VXInstructionDecoder.h | 892 ++----- .../VXInstructionFormatter.c | 8 +- .../VXInstructionFormatter.h | 377 +-- .../VXInternalConfig.h | 10 +- .../VXInternalHelpers.h | 4 +- .../VXOpcodeTable.c | 2 +- VerteronDisassemblerEngine/VXOpcodeTable.h | 2329 ++++++++--------- .../VXOpcodeTableInternal.h | 2 +- .../VerteronDisassemblerEngine.vcxproj | 147 -- ...VerteronDisassemblerEngine.vcxproj.filters | 17 - 44 files changed, 4483 insertions(+), 5405 deletions(-) delete mode 100644 Bindings/C/VXInstructionDecoderC.h delete mode 100644 Bindings/C/VXInstructionFormatterC.h delete mode 100644 Bindings/C/VXOpcodeTableC.h rename Bindings/{C/VXDisassemblerC.h => Cpp/VXDisassembler.hpp} (76%) rename Bindings/{C/VXDisassemblerTypesC.h => Cpp/VXDisassemblerTypes.hpp} (80%) rename {VerteronDisassemblerEngine => Bindings/Cpp}/VXDisassemblerUtils.cpp (98%) rename Bindings/{C/VXDisassemblerUtilsC.h => Cpp/VXDisassemblerUtils.hpp} (76%) rename {VerteronDisassemblerEngine => Bindings/Cpp}/VXInstructionDecoder.cpp (99%) create mode 100644 Bindings/Cpp/VXInstructionDecoder.hpp rename {VerteronDisassemblerEngine => Bindings/Cpp}/VXInstructionFormatter.cpp (99%) create mode 100644 Bindings/Cpp/VXInstructionFormatter.hpp rename {VerteronDisassemblerEngine => Bindings/Cpp}/VXOpcodeTable.cpp (99%) create mode 100644 Bindings/Cpp/VXOpcodeTable.hpp rename Examples/{SimpleDemo => CppBindings}/Main.cpp (99%) delete mode 100644 Examples/CustomDataSource/CustomDataSource.vcxproj delete mode 100644 Examples/CustomDataSource/CustomDataSource.vcxproj.filters rename Examples/CustomDataSource/{Main.cpp => Main.c} (100%) delete mode 100644 Examples/Examples.sln rename Examples/PerformanceTest/{Main.cpp => Main.c} (100%) delete mode 100644 Examples/PerformanceTest/PerformanceTest.vcxproj delete mode 100644 Examples/PerformanceTest/PerformanceTest.vcxproj.filters rename Examples/{CBindings/test.c => SimpleDemo/Main.c} (99%) delete mode 100644 Examples/SimpleDemo/SimpleDemo.vcxproj delete mode 100644 Examples/SimpleDemo/SimpleDemo.vcxproj.filters rename Examples/SymbolResolver/{Main.cpp => Main.c} (95%) delete mode 100644 Examples/SymbolResolver/SymbolResolver.vcxproj delete mode 100644 Examples/SymbolResolver/SymbolResolver.vcxproj.filters delete mode 100644 VerteronDisassemblerEngine.sln rename Bindings/C/VXDisassemblerUtilsC.c => VerteronDisassemblerEngine/VXDisassemblerUtils.c (98%) rename Bindings/C/VXInstructionDecoderC.c => VerteronDisassemblerEngine/VXInstructionDecoder.c (99%) rename Bindings/C/VXInstructionFormatterC.c => VerteronDisassemblerEngine/VXInstructionFormatter.c (99%) rename {Bindings/C => VerteronDisassemblerEngine}/VXInternalConfig.h (84%) rename Bindings/C/VXInternalHelpersC.h => VerteronDisassemblerEngine/VXInternalHelpers.h (98%) rename Bindings/C/VXOpcodeTableC.c => VerteronDisassemblerEngine/VXOpcodeTable.c (99%) rename Bindings/C/VXOpcodeTableInternalC.h => VerteronDisassemblerEngine/VXOpcodeTableInternal.h (99%) delete mode 100644 VerteronDisassemblerEngine/VerteronDisassemblerEngine.vcxproj delete mode 100644 VerteronDisassemblerEngine/VerteronDisassemblerEngine.vcxproj.filters diff --git a/Bindings/C/VXInstructionDecoderC.h b/Bindings/C/VXInstructionDecoderC.h deleted file mode 100644 index bf3058c..0000000 --- a/Bindings/C/VXInstructionDecoderC.h +++ /dev/null @@ -1,304 +0,0 @@ -/************************************************************************************************** - - Verteron Disassembler Engine - Version 1.0 - - Remarks : Freeware, Copyright must be included - - Original Author : Florian Bernd - Modifications : athre0z - - Last change : 14. March 2015 - - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - -**************************************************************************************************/ - -#ifndef _VDE_VXINSTRUCTIONDECODERC_H_ -#define _VDE_VXINSTRUCTIONDECODERC_H_ - -#include "VXDisassemblerTypesC.h" -#include "VXDisassemblerUtilsC.h" - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* VXBaseDataSource ============================================================================ */ - -typedef struct _VXBaseDataSourceContext { VXContextDescriptor d; } VXBaseDataSourceContext; - -/** - * @brief Releases a data source. - * @param ctx The context to release. - * The context may no longer be used after it was released. - */ -VX_EXPORT void VXBaseDataSource_Release( - VXBaseDataSourceContext *ctx); - -/** - * @brief Reads the next byte from the data source without altering the current input position - * or the @c length field of the @c info parameter. - * @param ctx The data source context. - * @param info The instruction info struct. - * @return The current input byte. If the result is zero, you should always check the @c flags - * field of the @c info parameter for error flags. Possible error values are - * @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. - */ -VX_EXPORT uint8_t VXBaseDataSource_InputPeek( - VXBaseDataSourceContext *ctx, - VXInstructionInfo *info); - -/** - * @brief Reads the next byte from the data source. - * @param ctx The data soruce context. - * @param info The instruction info. - * @return The current input byte. If the result is zero, you should always check the - * @c flags field of the @c info parameter for error flags. - * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. - * This method increases the current input position and the @c length field of the @c info - * parameter. This function also appends the new byte to to @c data field of the @c info - * parameter. - */ -VX_EXPORT uint8_t VXBaseDataSource_InputNext8( - VXBaseDataSourceContext *ctx, - VXInstructionInfo *info); - -/** - * @copydoc VXBaseDataSource_InputNext8 - */ -VX_EXPORT uint16_t VXBaseDataSource_InputNext16( - VXBaseDataSourceContext *ctx, - VXInstructionInfo *info); - -/** - * @copydoc VXBaseDataSource_InputNext8 - */ -VX_EXPORT uint32_t VXBaseDataSource_InputNext32( - VXBaseDataSourceContext *ctx, - VXInstructionInfo *info); - -/** - * @copydoc VXBaseDataSource_InputNext8 - */ -VX_EXPORT uint64_t VXBaseDataSource_InputNext64( - VXBaseDataSourceContext *ctx, - VXInstructionInfo *info); - -/** - * @brief Returns the current input byte. - * @param ctx The data soruce context. - * @return The current input byte. - * The current input byte is set everytime the @c inputPeek or @c inputNext method is called. - */ -// TODO: check long descr -VX_EXPORT uint8_t VXBaseDataSource_InputCurrent( - const VXBaseDataSourceContext *ctx); - -/** - * @brief Queries if the end of the data source is reached. - * @param ctx The data soruce context. - * @return @c true if end of input, @c false if not. - */ -VX_EXPORT bool VXBaseDataSource_IsEndOfInput( - const VXBaseDataSourceContext *ctx); - -/** - * @brief Returns the current input position. - * @param ctx The data soruce context. - * @return The current input position. - */ -VX_EXPORT uint64_t VXBaseDataSource_GetPosition( - const VXBaseDataSourceContext *ctx); - -/** - * @brief Sets a new input position. - * @param ctx The data soruce context. - * @param position The new input position. - * @return @c false if the new position exceeds the maximum input length. - */ -VX_EXPORT bool VXBaseDataSource_SetPosition( - VXBaseDataSourceContext *ctx, - uint64_t position); - -/* VXMemoryDataSource ========================================================================== */ - -/** - * @brief Creates a memory data source. - * @param buffer The input buffer. - * @param bufferLen THe length of the input buffer. - * @return @c NULL if it fails, else a data source context. - * @see VXBaseDataSource_Release - */ -// TODO: verify return value -VX_EXPORT VXBaseDataSourceContext* VXMemoryDataSource_Create( - const void* buffer, - size_t bufferLen); - -/* Enums ======================================================================================= */ - -/** - * @brief Values that represent a disassembler mode. - */ -typedef enum _VXDisassemblerMode /* : uint8_t */ -{ - DM_M16BIT, - DM_M32BIT, - DM_M64BIT -} VXDisassemblerMode; - -/** - * @brief Values that represent an instruction-set vendor. - */ -typedef enum _VXInstructionSetVendor /* : uint8_t */ -{ - ISV_ANY, - ISV_INTEL, - ISV_AMD -} VXInstructionSetVendor; - -/* VXInstructionDecoder ======================================================================== */ - -typedef struct _VXInstructionDecoderContext -{ - VXContextDescriptor d; -} VXInstructionDecoderContext; - -/** - * @brief Creates an instruction decoder. - * @return @c NULL if it fails, else an instruction decoder context. - * @see VXInstructionDecoder_Release - */ -// TODO: verify return value -VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_Create(void); - -/** - * @brief Creates an instruction decoder. - * @param input A reference to the input data source. - * @param disassemblerMode The disassembler mode. - * @param preferredVendor The preferred instruction-set vendor. - * @param instructionPointer The initial instruction pointer. - * @return @c NULL if it fails, else an instruction decoder context. - * @see VXInstructionDecoder_Release - */ -VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_CreateEx( - VXBaseDataSourceContext *input, - VXDisassemblerMode disassemblerMode, - VXInstructionSetVendor preferredVendor, - uint64_t instructionPointer); - -/** - * @brief Releases an instruction decoder. - * @param ctx The context of the instruction decoder to release. - */ -VX_EXPORT void VXInstructionDecoder_Release( - VXInstructionDecoderContext *ctx); - -/** - * @brief Decodes the next instruction from the input data source. - * @param ctx The instruction decoder context. - * @param info The @c VXInstructionInfo struct that receives the information about the decoded - * instruction. - * @return This function returns @c false if the current position exceeds the maximum input - * length. In all other cases (valid and invalid instructions) the return value is - * @c true. - */ -VX_EXPORT bool VXInstructionDecoder_DecodeInstruction( - VXInstructionDecoderContext *ctx, - VXInstructionInfo *info); - -/** - * @brief Returns a pointer to the current data source. - * @param ctx The instruction decoder context. - * @return The context of the data source. - */ -VX_EXPORT VXBaseDataSourceContext* VXInstructionDecoder_GetDataSource( - const VXInstructionDecoderContext *ctx); - -/** - * @brief Sets a new data source. - * @param ctx The instruction decoder context. - * @param input The context of the new input data source. - */ -VX_EXPORT void VXInstructionDecoder_SetDataSource( - VXInstructionDecoderContext *ctx, - VXBaseDataSourceContext *input); - -/** - * @brief Returns the current disassembler mode. - * @param ctx The instruction decoder context. - * @return The current disassembler mode. - */ -VX_EXPORT VXDisassemblerMode VXInstructionDecoder_GetDisassemblerMode( - const VXInstructionDecoderContext *ctx); - -/** - * @brief Sets the current disassembler mode. - * @param ctx The instruction decoder context. - * @param disassemblerMode The new disassembler mode. - */ -VX_EXPORT void VXInstructionDecoder_SetDisassemblerMode( - VXInstructionDecoderContext *ctx, - VXDisassemblerMode disassemblerMode); - -/** - * @brief Returns the preferred instruction-set vendor. - * @param ctx The instruction decoder context. - * @return The preferred instruction-set vendor. - */ -VX_EXPORT VXInstructionSetVendor VXInstructionDecoder_GetPreferredVendor( - const VXInstructionDecoderContext *ctx); - -/** - * @brief Sets the preferred instruction-set vendor. - * @param ctx The instruction decoder context. - * @param preferredVendor The new preferred instruction-set vendor. - */ -VX_EXPORT void VXInstructionDecoder_SetPreferredVendor( - VXInstructionDecoderContext *ctx, - VXInstructionSetVendor preferredVendor); - -/** - * @brief Returns the current instruction pointer. - * @param ctx The instruction decoder context. - * @return The current instruction pointer. - */ -VX_EXPORT uint64_t VXInstructionDecoder_GetInstructionPointer( - const VXInstructionDecoderContext *ctx); - -/** - * @brief Sets a new instruction pointer. - * @param ctx The instruction decoder context. - * @param instructionPointer The new instruction pointer. - */ -VX_EXPORT void VXInstructionDecoder_SetInstructionPointer( - VXInstructionDecoderContext *ctx, - uint64_t instructionPointer); - -/* ============================================================================================= */ - -#ifdef __cplusplus -} -#endif - -#endif /* _VDE_VXINSTRUCTIONDECODERC_H_ */ diff --git a/Bindings/C/VXInstructionFormatterC.h b/Bindings/C/VXInstructionFormatterC.h deleted file mode 100644 index 0507ec8..0000000 --- a/Bindings/C/VXInstructionFormatterC.h +++ /dev/null @@ -1,161 +0,0 @@ -/************************************************************************************************** - - Verteron Disassembler Engine - Version 1.0 - - Remarks : Freeware, Copyright must be included - - Original Author : Florian Bernd - Modifications : athre0z - - Last change : 14. March 2015 - - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - -**************************************************************************************************/ - -#ifndef _VDE_VXINSTRUCTIONFORMATTERC_H_ -#define _VDE_VXINSTRUCTIONFORMATTERC_H_ - -#include "VXDisassemblerTypesC.h" -#include "VXDisassemblerUtilsC.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* VXBaseSymbolResolver ======================================================================== */ - -typedef struct _VXBaseSymbolResolverContext -{ - VXContextDescriptor d; -} VXBaseSymbolResolverContext; - -/** - * @brief Releases a symbol resolver. - * @param ctx The context of the symbol resolver to free. - * The context may no longer used after it was released. - */ -VX_EXPORT void VXBaseSymbolResolver_Release( - VXBaseSymbolResolverContext *ctx); - -/** - * @brief Resolves a symbol. - * @param ctx The symbol resolver context. - * @param info The instruction info. - * @param address The address. - * @param offset Pointer to an unsigned 64 bit integer that receives an offset relative to - * the base address of the symbol. - * @return The name of the symbol if the symbol was found, else @c NULL. - */ -VX_EXPORT const char* VXBaseSymbolResolver_ResolveSymbol( - VXBaseSymbolResolverContext *ctx, - const VXInstructionInfo *info, - uint64_t address, - uint64_t *offset); - -/* VXCustomSymbolResolver ====================================================================== */ - -typedef const char* (*VXCustomSymbolResolver_ResolveSymbolCallback)( - const VXInstructionInfo *info, - uint64_t address, - uint64_t *offset, - void *userData); - -/** - * @brief Creates a custom symbol resolver. - * @param resolverCb The resolver callback consulted when symbols need to be resolved. - * @param userData A pointer to arbitrary data passed to the resolver callback. - * May also be @c NULL. - * @return @c NULL if it fails, else a symbol resolver context. - */ -VX_EXPORT VXBaseSymbolResolverContext* VXCustomSymbolResolver_Create( - VXCustomSymbolResolver_ResolveSymbolCallback resolverCb, - void *userData); - -/* VXBaseInstructionFormatter ================================================================== */ - -typedef struct _VXBaseInstructionFormatterContext -{ - VXContextDescriptor d; -} VXBaseInstructionFormatterContext; - -/** - * @brief Formats a decoded instruction. - * @param ctx The instruction formatter context. - * @param info The instruction info. - * @return Pointer to the formatted instruction string. This pointer remains valid until - * this function is called again or the context is released. - */ -VX_EXPORT const char* VXBaseInstructionFormatter_FormatInstruction( - VXBaseInstructionFormatterContext *ctx, - const VXInstructionInfo *info); - -/** - * @brief Returns a pointer to the current symbol resolver. - * @param ctx The instruction formatter context. - * @return Pointer to the current symbol resolver or @c NULL if no symbol resolver is used. - */ -VX_EXPORT VXBaseSymbolResolverContext* VXBaseInstructionFormatter_GetSymbolResolver( - const VXBaseInstructionFormatterContext *ctx); - -/** - * @brief Sets a new symbol resolver. - * @param ctx The instruction formatter context. - * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol - * resolver should be used. - */ -VX_EXPORT void VXBaseInstructionFormatter_SetSymbolResolver( - VXBaseInstructionFormatterContext *ctx, - VXBaseSymbolResolverContext *resolver); - -/** - * @brief Releases an instruction formatter. - * @param ctx The context of the instruction formatter to release. - * The context may no longer used after it has been released. - */ -VX_EXPORT void VXBaseInstructionFormatter_Release( - VXBaseInstructionFormatterContext *ctx); - -/* VXIntelInstructionFormatter ================================================================ */ - -/** - * @brief Creates an Intel-syntax instruction formatter. - * @return @c NULL if it fails, else an Intel instruction formatter context. - * @see VXBaseInstructionFormatter_Release - */ -VX_EXPORT VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_Create(void); - -/** - * @brief Creates an Intel-syntax instruction formatter. - * @param resolver The symbol resolver consulted to resolve symbols on formatting. - * @return @c NULL if it fails, else an Intel instruction formatter context. - * @see VXBaseInstructionFormatter_Release - */ -VX_EXPORT VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_CreateEx( - VXBaseSymbolResolverContext *resolver); - -/* ============================================================================================= */ - -#ifdef __cplusplus -} -#endif - -#endif /* _VDE_VXINSTRUCTIONFORMATTERC_H_ */ \ No newline at end of file diff --git a/Bindings/C/VXOpcodeTableC.h b/Bindings/C/VXOpcodeTableC.h deleted file mode 100644 index f36cc41..0000000 --- a/Bindings/C/VXOpcodeTableC.h +++ /dev/null @@ -1,1504 +0,0 @@ -/************************************************************************************************** - - Verteron Disassembler Engine - Version 1.0 - - Remarks : Freeware, Copyright must be included - - Original Author : Florian Bernd - Modifications : athre0z - - Last change : 04. February 2015 - - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - -**************************************************************************************************/ - -#ifndef _VDE_VXOPCODETABLEC_H_ -#define _VDE_VXOPCODETABLEC_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * @brief Values that represent an instruction mnemonic. - */ -typedef enum _VXInstructionMnemonic /* : uint16_t */ -{ - /* 000 */ MNEM_INVALID, - /* 001 */ MNEM_AAA, - /* 002 */ MNEM_AAD, - /* 003 */ MNEM_AAM, - /* 004 */ MNEM_AAS, - /* 005 */ MNEM_ADC, - /* 006 */ MNEM_ADD, - /* 007 */ MNEM_ADDPD, - /* 008 */ MNEM_ADDPS, - /* 009 */ MNEM_ADDSD, - /* 00A */ MNEM_ADDSS, - /* 00B */ MNEM_ADDSUBPD, - /* 00C */ MNEM_ADDSUBPS, - /* 00D */ MNEM_AESDEC, - /* 00E */ MNEM_AESDECLAST, - /* 00F */ MNEM_AESENC, - /* 010 */ MNEM_AESENCLAST, - /* 011 */ MNEM_AESIMC, - /* 012 */ MNEM_AESKEYGENASSIST, - /* 013 */ MNEM_AND, - /* 014 */ MNEM_ANDNPD, - /* 015 */ MNEM_ANDNPS, - /* 016 */ MNEM_ANDPD, - /* 017 */ MNEM_ANDPS, - /* 018 */ MNEM_ARPL, - /* 019 */ MNEM_BLENDPD, - /* 01A */ MNEM_BLENDPS, - /* 01B */ MNEM_BLENDVPD, - /* 01C */ MNEM_BLENDVPS, - /* 01D */ MNEM_BOUND, - /* 01E */ MNEM_BSF, - /* 01F */ MNEM_BSR, - /* 020 */ MNEM_BSWAP, - /* 021 */ MNEM_BT, - /* 022 */ MNEM_BTC, - /* 023 */ MNEM_BTR, - /* 024 */ MNEM_BTS, - /* 025 */ MNEM_CALL, - /* 026 */ MNEM_CBW, - /* 027 */ MNEM_CDQ, - /* 028 */ MNEM_CDQE, - /* 029 */ MNEM_CLC, - /* 02A */ MNEM_CLD, - /* 02B */ MNEM_CLFLUSH, - /* 02C */ MNEM_CLGI, - /* 02D */ MNEM_CLI, - /* 02E */ MNEM_CLTS, - /* 02F */ MNEM_CMC, - /* 030 */ MNEM_CMOVA, - /* 031 */ MNEM_CMOVAE, - /* 032 */ MNEM_CMOVB, - /* 033 */ MNEM_CMOVBE, - /* 034 */ MNEM_CMOVE, - /* 035 */ MNEM_CMOVG, - /* 036 */ MNEM_CMOVGE, - /* 037 */ MNEM_CMOVL, - /* 038 */ MNEM_CMOVLE, - /* 039 */ MNEM_CMOVNE, - /* 03A */ MNEM_CMOVNO, - /* 03B */ MNEM_CMOVNP, - /* 03C */ MNEM_CMOVNS, - /* 03D */ MNEM_CMOVO, - /* 03E */ MNEM_CMOVP, - /* 03F */ MNEM_CMOVS, - /* 040 */ MNEM_CMP, - /* 041 */ MNEM_CMPPD, - /* 042 */ MNEM_CMPPS, - /* 043 */ MNEM_CMPSB, - /* 044 */ MNEM_CMPSD, - /* 045 */ MNEM_CMPSQ, - /* 046 */ MNEM_CMPSS, - /* 047 */ MNEM_CMPSW, - /* 048 */ MNEM_CMPXCHG, - /* 049 */ MNEM_CMPXCHG16B, - /* 04A */ MNEM_CMPXCHG8B, - /* 04B */ MNEM_COMISD, - /* 04C */ MNEM_COMISS, - /* 04D */ MNEM_CPUID, - /* 04E */ MNEM_CQO, - /* 04F */ MNEM_CRC32, - /* 050 */ MNEM_CVTDQ2PD, - /* 051 */ MNEM_CVTDQ2PS, - /* 052 */ MNEM_CVTPD2DQ, - /* 053 */ MNEM_CVTPD2PI, - /* 054 */ MNEM_CVTPD2PS, - /* 055 */ MNEM_CVTPI2PD, - /* 056 */ MNEM_CVTPI2PS, - /* 057 */ MNEM_CVTPS2DQ, - /* 058 */ MNEM_CVTPS2PD, - /* 059 */ MNEM_CVTPS2PI, - /* 05A */ MNEM_CVTSD2SI, - /* 05B */ MNEM_CVTSD2SS, - /* 05C */ MNEM_CVTSI2SD, - /* 05D */ MNEM_CVTSI2SS, - /* 05E */ MNEM_CVTSS2SD, - /* 05F */ MNEM_CVTSS2SI, - /* 060 */ MNEM_CVTTPD2DQ, - /* 061 */ MNEM_CVTTPD2PI, - /* 062 */ MNEM_CVTTPS2DQ, - /* 063 */ MNEM_CVTTPS2PI, - /* 064 */ MNEM_CVTTSD2SI, - /* 065 */ MNEM_CVTTSS2SI, - /* 066 */ MNEM_CWD, - /* 067 */ MNEM_CWDE, - /* 068 */ MNEM_DAA, - /* 069 */ MNEM_DAS, - /* 06A */ MNEM_DEC, - /* 06B */ MNEM_DIV, - /* 06C */ MNEM_DIVPD, - /* 06D */ MNEM_DIVPS, - /* 06E */ MNEM_DIVSD, - /* 06F */ MNEM_DIVSS, - /* 070 */ MNEM_DPPD, - /* 071 */ MNEM_DPPS, - /* 072 */ MNEM_EMMS, - /* 073 */ MNEM_ENTER, - /* 074 */ MNEM_EXTRACTPS, - /* 075 */ MNEM_F2XM1, - /* 076 */ MNEM_FABS, - /* 077 */ MNEM_FADD, - /* 078 */ MNEM_FADDP, - /* 079 */ MNEM_FBLD, - /* 07A */ MNEM_FBSTP, - /* 07B */ MNEM_FCHS, - /* 07C */ MNEM_FCLEX, - /* 07D */ MNEM_FCMOVB, - /* 07E */ MNEM_FCMOVBE, - /* 07F */ MNEM_FCMOVE, - /* 080 */ MNEM_FCMOVNB, - /* 081 */ MNEM_FCMOVNBE, - /* 082 */ MNEM_FCMOVNE, - /* 083 */ MNEM_FCMOVNU, - /* 084 */ MNEM_FCMOVU, - /* 085 */ MNEM_FCOM, - /* 086 */ MNEM_FCOM2, - /* 087 */ MNEM_FCOMI, - /* 088 */ MNEM_FCOMIP, - /* 089 */ MNEM_FCOMP, - /* 08A */ MNEM_FCOMP3, - /* 08B */ MNEM_FCOMP5, - /* 08C */ MNEM_FCOMPP, - /* 08D */ MNEM_FCOS, - /* 08E */ MNEM_FDECSTP, - /* 08F */ MNEM_FDIV, - /* 090 */ MNEM_FDIVP, - /* 091 */ MNEM_FDIVR, - /* 092 */ MNEM_FDIVRP, - /* 093 */ MNEM_FEMMS, - /* 094 */ MNEM_FFREE, - /* 095 */ MNEM_FFREEP, - /* 096 */ MNEM_FIADD, - /* 097 */ MNEM_FICOM, - /* 098 */ MNEM_FICOMP, - /* 099 */ MNEM_FIDIV, - /* 09A */ MNEM_FIDIVR, - /* 09B */ MNEM_FILD, - /* 09C */ MNEM_FIMUL, - /* 09D */ MNEM_FINCSTP, - /* 09E */ MNEM_FIST, - /* 09F */ MNEM_FISTP, - /* 0A0 */ MNEM_FISTTP, - /* 0A1 */ MNEM_FISUB, - /* 0A2 */ MNEM_FISUBR, - /* 0A3 */ MNEM_FLD, - /* 0A4 */ MNEM_FLD1, - /* 0A5 */ MNEM_FLDCW, - /* 0A6 */ MNEM_FLDENV, - /* 0A7 */ MNEM_FLDL2E, - /* 0A8 */ MNEM_FLDL2T, - /* 0A9 */ MNEM_FLDLG2, - /* 0AA */ MNEM_FLDLN2, - /* 0AB */ MNEM_FLDPI, - /* 0AC */ MNEM_FLDZ, - /* 0AD */ MNEM_FMUL, - /* 0AE */ MNEM_FMULP, - /* 0AF */ MNEM_FNDISI, - /* 0B0 */ MNEM_FNENI, - /* 0B1 */ MNEM_FNINIT, - /* 0B2 */ MNEM_FNOP, - /* 0B3 */ MNEM_FNSAVE, - /* 0B4 */ MNEM_FNSETPM, - /* 0B5 */ MNEM_FNSTCW, - /* 0B6 */ MNEM_FNSTENV, - /* 0B7 */ MNEM_FNSTSW, - /* 0B8 */ MNEM_FPATAN, - /* 0B9 */ MNEM_FPREM, - /* 0BA */ MNEM_FPREM1, - /* 0BB */ MNEM_FPTAN, - /* 0BC */ MNEM_FRNDINT, - /* 0BD */ MNEM_FRSTOR, - /* 0BE */ MNEM_FRSTPM, - /* 0BF */ MNEM_FSCALE, - /* 0C0 */ MNEM_FSIN, - /* 0C1 */ MNEM_FSINCOS, - /* 0C2 */ MNEM_FSQRT, - /* 0C3 */ MNEM_FST, - /* 0C4 */ MNEM_FSTP, - /* 0C5 */ MNEM_FSTP1, - /* 0C6 */ MNEM_FSTP8, - /* 0C7 */ MNEM_FSTP9, - /* 0C8 */ MNEM_FSUB, - /* 0C9 */ MNEM_FSUBP, - /* 0CA */ MNEM_FSUBR, - /* 0CB */ MNEM_FSUBRP, - /* 0CC */ MNEM_FTST, - /* 0CD */ MNEM_FUCOM, - /* 0CE */ MNEM_FUCOMI, - /* 0CF */ MNEM_FUCOMIP, - /* 0D0 */ MNEM_FUCOMP, - /* 0D1 */ MNEM_FUCOMPP, - /* 0D2 */ MNEM_FXAM, - /* 0D3 */ MNEM_FXCH, - /* 0D4 */ MNEM_FXCH4, - /* 0D5 */ MNEM_FXCH7, - /* 0D6 */ MNEM_FXRSTOR, - /* 0D7 */ MNEM_FXSAVE, - /* 0D8 */ MNEM_FXTRACT, - /* 0D9 */ MNEM_FYL2X, - /* 0DA */ MNEM_FYL2XP1, - /* 0DB */ MNEM_GETSEC, - /* 0DC */ MNEM_HADDPD, - /* 0DD */ MNEM_HADDPS, - /* 0DE */ MNEM_HLT, - /* 0DF */ MNEM_HSUBPD, - /* 0E0 */ MNEM_HSUBPS, - /* 0E1 */ MNEM_IDIV, - /* 0E2 */ MNEM_IMUL, - /* 0E3 */ MNEM_IN, - /* 0E4 */ MNEM_INC, - /* 0E5 */ MNEM_INSB, - /* 0E6 */ MNEM_INSD, - /* 0E7 */ MNEM_INSERTPS, - /* 0E8 */ MNEM_INSW, - /* 0E9 */ MNEM_INT, - /* 0EA */ MNEM_INT1, - /* 0EB */ MNEM_INT3, - /* 0EC */ MNEM_INTO, - /* 0ED */ MNEM_INVD, - /* 0EE */ MNEM_INVEPT, - /* 0EF */ MNEM_INVLPG, - /* 0F0 */ MNEM_INVLPGA, - /* 0F1 */ MNEM_INVVPID, - /* 0F2 */ MNEM_IRETD, - /* 0F3 */ MNEM_IRETQ, - /* 0F4 */ MNEM_IRETW, - /* 0F5 */ MNEM_JA, - /* 0F6 */ MNEM_JB, - /* 0F7 */ MNEM_JBE, - /* 0F8 */ MNEM_JCXZ, - /* 0F9 */ MNEM_JE, - /* 0FA */ MNEM_JECXZ, - /* 0FB */ MNEM_JG, - /* 0FC */ MNEM_JGE, - /* 0FD */ MNEM_JL, - /* 0FE */ MNEM_JLE, - /* 0FF */ MNEM_JMP, - /* 100 */ MNEM_JNB, - /* 101 */ MNEM_JNE, - /* 102 */ MNEM_JNO, - /* 103 */ MNEM_JNP, - /* 104 */ MNEM_JNS, - /* 105 */ MNEM_JO, - /* 106 */ MNEM_JP, - /* 107 */ MNEM_JRCXZ, - /* 108 */ MNEM_JS, - /* 109 */ MNEM_LAHF, - /* 10A */ MNEM_LAR, - /* 10B */ MNEM_LDDQU, - /* 10C */ MNEM_LDMXCSR, - /* 10D */ MNEM_LDS, - /* 10E */ MNEM_LEA, - /* 10F */ MNEM_LEAVE, - /* 110 */ MNEM_LES, - /* 111 */ MNEM_LFENCE, - /* 112 */ MNEM_LFS, - /* 113 */ MNEM_LGDT, - /* 114 */ MNEM_LGS, - /* 115 */ MNEM_LIDT, - /* 116 */ MNEM_LLDT, - /* 117 */ MNEM_LMSW, - /* 118 */ MNEM_LOCK, - /* 119 */ MNEM_LODSB, - /* 11A */ MNEM_LODSD, - /* 11B */ MNEM_LODSQ, - /* 11C */ MNEM_LODSW, - /* 11D */ MNEM_LOOP, - /* 11E */ MNEM_LOOPE, - /* 11F */ MNEM_LOOPNE, - /* 120 */ MNEM_LSL, - /* 121 */ MNEM_LSS, - /* 122 */ MNEM_LTR, - /* 123 */ MNEM_MASKMOVDQU, - /* 124 */ MNEM_MASKMOVQ, - /* 125 */ MNEM_MAXPD, - /* 126 */ MNEM_MAXPS, - /* 127 */ MNEM_MAXSD, - /* 128 */ MNEM_MAXSS, - /* 129 */ MNEM_MFENCE, - /* 12A */ MNEM_MINPD, - /* 12B */ MNEM_MINPS, - /* 12C */ MNEM_MINSD, - /* 12D */ MNEM_MINSS, - /* 12E */ MNEM_MONITOR, - /* 12F */ MNEM_MONTMUL, - /* 130 */ MNEM_MOV, - /* 131 */ MNEM_MOVAPD, - /* 132 */ MNEM_MOVAPS, - /* 133 */ MNEM_MOVBE, - /* 134 */ MNEM_MOVD, - /* 135 */ MNEM_MOVDDUP, - /* 136 */ MNEM_MOVDQ2Q, - /* 137 */ MNEM_MOVDQA, - /* 138 */ MNEM_MOVDQU, - /* 139 */ MNEM_MOVHLPS, - /* 13A */ MNEM_MOVHPD, - /* 13B */ MNEM_MOVHPS, - /* 13C */ MNEM_MOVLHPS, - /* 13D */ MNEM_MOVLPD, - /* 13E */ MNEM_MOVLPS, - /* 13F */ MNEM_MOVMSKPD, - /* 140 */ MNEM_MOVMSKPS, - /* 141 */ MNEM_MOVNTDQ, - /* 142 */ MNEM_MOVNTDQA, - /* 143 */ MNEM_MOVNTI, - /* 144 */ MNEM_MOVNTPD, - /* 145 */ MNEM_MOVNTPS, - /* 146 */ MNEM_MOVNTQ, - /* 147 */ MNEM_MOVQ, - /* 148 */ MNEM_MOVQ2DQ, - /* 149 */ MNEM_MOVSB, - /* 14A */ MNEM_MOVSD, - /* 14B */ MNEM_MOVSHDUP, - /* 14C */ MNEM_MOVSLDUP, - /* 14D */ MNEM_MOVSQ, - /* 14E */ MNEM_MOVSS, - /* 14F */ MNEM_MOVSW, - /* 150 */ MNEM_MOVSX, - /* 151 */ MNEM_MOVSXD, - /* 152 */ MNEM_MOVUPD, - /* 153 */ MNEM_MOVUPS, - /* 154 */ MNEM_MOVZX, - /* 155 */ MNEM_MPSADBW, - /* 156 */ MNEM_MUL, - /* 157 */ MNEM_MULPD, - /* 158 */ MNEM_MULPS, - /* 159 */ MNEM_MULSD, - /* 15A */ MNEM_MULSS, - /* 15B */ MNEM_MWAIT, - /* 15C */ MNEM_NEG, - /* 15D */ MNEM_NOP, - /* 15E */ MNEM_NOT, - /* 15F */ MNEM_OR, - /* 160 */ MNEM_ORPD, - /* 161 */ MNEM_ORPS, - /* 162 */ MNEM_OUT, - /* 163 */ MNEM_OUTSB, - /* 164 */ MNEM_OUTSD, - /* 165 */ MNEM_OUTSW, - /* 166 */ MNEM_PABSB, - /* 167 */ MNEM_PABSD, - /* 168 */ MNEM_PABSW, - /* 169 */ MNEM_PACKSSDW, - /* 16A */ MNEM_PACKSSWB, - /* 16B */ MNEM_PACKUSDW, - /* 16C */ MNEM_PACKUSWB, - /* 16D */ MNEM_PADDB, - /* 16E */ MNEM_PADDD, - /* 16F */ MNEM_PADDQ, - /* 170 */ MNEM_PADDSB, - /* 171 */ MNEM_PADDSW, - /* 172 */ MNEM_PADDUSB, - /* 173 */ MNEM_PADDUSW, - /* 174 */ MNEM_PADDW, - /* 175 */ MNEM_PALIGNR, - /* 176 */ MNEM_PAND, - /* 177 */ MNEM_PANDN, - /* 178 */ MNEM_PAUSE, - /* 179 */ MNEM_PAVGB, - /* 17A */ MNEM_PAVGUSB, - /* 17B */ MNEM_PAVGW, - /* 17C */ MNEM_PBLENDVB, - /* 17D */ MNEM_PBLENDW, - /* 17E */ MNEM_PCLMULQDQ, - /* 17F */ MNEM_PCMPEQB, - /* 180 */ MNEM_PCMPEQD, - /* 181 */ MNEM_PCMPEQQ, - /* 182 */ MNEM_PCMPEQW, - /* 183 */ MNEM_PCMPESTRI, - /* 184 */ MNEM_PCMPESTRM, - /* 185 */ MNEM_PCMPGTB, - /* 186 */ MNEM_PCMPGTD, - /* 187 */ MNEM_PCMPGTQ, - /* 188 */ MNEM_PCMPGTW, - /* 189 */ MNEM_PCMPISTRI, - /* 18A */ MNEM_PCMPISTRM, - /* 18B */ MNEM_PEXTRB, - /* 18C */ MNEM_PEXTRD, - /* 18D */ MNEM_PEXTRQ, - /* 18E */ MNEM_PEXTRW, - /* 18F */ MNEM_PF2ID, - /* 190 */ MNEM_PF2IW, - /* 191 */ MNEM_PFACC, - /* 192 */ MNEM_PFADD, - /* 193 */ MNEM_PFCMPEQ, - /* 194 */ MNEM_PFCMPGE, - /* 195 */ MNEM_PFCMPGT, - /* 196 */ MNEM_PFMAX, - /* 197 */ MNEM_PFMIN, - /* 198 */ MNEM_PFMUL, - /* 199 */ MNEM_PFNACC, - /* 19A */ MNEM_PFPNACC, - /* 19B */ MNEM_PFRCP, - /* 19C */ MNEM_PFRCPIT1, - /* 19D */ MNEM_PFRCPIT2, - /* 19E */ MNEM_PFRSQIT1, - /* 19F */ MNEM_PFRSQRT, - /* 1A0 */ MNEM_PFSUB, - /* 1A1 */ MNEM_PFSUBR, - /* 1A2 */ MNEM_PHADDD, - /* 1A3 */ MNEM_PHADDSW, - /* 1A4 */ MNEM_PHADDW, - /* 1A5 */ MNEM_PHMINPOSUW, - /* 1A6 */ MNEM_PHSUBD, - /* 1A7 */ MNEM_PHSUBSW, - /* 1A8 */ MNEM_PHSUBW, - /* 1A9 */ MNEM_PI2FD, - /* 1AA */ MNEM_PI2FW, - /* 1AB */ MNEM_PINSRB, - /* 1AC */ MNEM_PINSRD, - /* 1AD */ MNEM_PINSRQ, - /* 1AE */ MNEM_PINSRW, - /* 1AF */ MNEM_PMADDUBSW, - /* 1B0 */ MNEM_PMADDWD, - /* 1B1 */ MNEM_PMAXSB, - /* 1B2 */ MNEM_PMAXSD, - /* 1B3 */ MNEM_PMAXSW, - /* 1B4 */ MNEM_PMAXUB, - /* 1B5 */ MNEM_PMAXUD, - /* 1B6 */ MNEM_PMAXUW, - /* 1B7 */ MNEM_PMINSB, - /* 1B8 */ MNEM_PMINSD, - /* 1B9 */ MNEM_PMINSW, - /* 1BA */ MNEM_PMINUB, - /* 1BB */ MNEM_PMINUD, - /* 1BC */ MNEM_PMINUW, - /* 1BD */ MNEM_PMOVMSKB, - /* 1BE */ MNEM_PMOVSXBD, - /* 1BF */ MNEM_PMOVSXBQ, - /* 1C0 */ MNEM_PMOVSXBW, - /* 1C1 */ MNEM_PMOVSXDQ, - /* 1C2 */ MNEM_PMOVSXWD, - /* 1C3 */ MNEM_PMOVSXWQ, - /* 1C4 */ MNEM_PMOVZXBD, - /* 1C5 */ MNEM_PMOVZXBQ, - /* 1C6 */ MNEM_PMOVZXBW, - /* 1C7 */ MNEM_PMOVZXDQ, - /* 1C8 */ MNEM_PMOVZXWD, - /* 1C9 */ MNEM_PMOVZXWQ, - /* 1CA */ MNEM_PMULDQ, - /* 1CB */ MNEM_PMULHRSW, - /* 1CC */ MNEM_PMULHRW, - /* 1CD */ MNEM_PMULHUW, - /* 1CE */ MNEM_PMULHW, - /* 1CF */ MNEM_PMULLD, - /* 1D0 */ MNEM_PMULLW, - /* 1D1 */ MNEM_PMULUDQ, - /* 1D2 */ MNEM_POP, - /* 1D3 */ MNEM_POPA, - /* 1D4 */ MNEM_POPAD, - /* 1D5 */ MNEM_POPCNT, - /* 1D6 */ MNEM_POPFD, - /* 1D7 */ MNEM_POPFQ, - /* 1D8 */ MNEM_POPFW, - /* 1D9 */ MNEM_POR, - /* 1DA */ MNEM_PREFETCH, - /* 1DB */ MNEM_PREFETCHNTA, - /* 1DC */ MNEM_PREFETCHT0, - /* 1DD */ MNEM_PREFETCHT1, - /* 1DE */ MNEM_PREFETCHT2, - /* 1DF */ MNEM_PSADBW, - /* 1E0 */ MNEM_PSHUFB, - /* 1E1 */ MNEM_PSHUFD, - /* 1E2 */ MNEM_PSHUFHW, - /* 1E3 */ MNEM_PSHUFLW, - /* 1E4 */ MNEM_PSHUFW, - /* 1E5 */ MNEM_PSIGNB, - /* 1E6 */ MNEM_PSIGND, - /* 1E7 */ MNEM_PSIGNW, - /* 1E8 */ MNEM_PSLLD, - /* 1E9 */ MNEM_PSLLDQ, - /* 1EA */ MNEM_PSLLQ, - /* 1EB */ MNEM_PSLLW, - /* 1EC */ MNEM_PSRAD, - /* 1ED */ MNEM_PSRAW, - /* 1EE */ MNEM_PSRLD, - /* 1EF */ MNEM_PSRLDQ, - /* 1F0 */ MNEM_PSRLQ, - /* 1F1 */ MNEM_PSRLW, - /* 1F2 */ MNEM_PSUBB, - /* 1F3 */ MNEM_PSUBD, - /* 1F4 */ MNEM_PSUBQ, - /* 1F5 */ MNEM_PSUBSB, - /* 1F6 */ MNEM_PSUBSW, - /* 1F7 */ MNEM_PSUBUSB, - /* 1F8 */ MNEM_PSUBUSW, - /* 1F9 */ MNEM_PSUBW, - /* 1FA */ MNEM_PSWAPD, - /* 1FB */ MNEM_PTEST, - /* 1FC */ MNEM_PUNPCKHBW, - /* 1FD */ MNEM_PUNPCKHDQ, - /* 1FE */ MNEM_PUNPCKHQDQ, - /* 1FF */ MNEM_PUNPCKHWD, - /* 200 */ MNEM_PUNPCKLBW, - /* 201 */ MNEM_PUNPCKLDQ, - /* 202 */ MNEM_PUNPCKLQDQ, - /* 203 */ MNEM_PUNPCKLWD, - /* 204 */ MNEM_PUSH, - /* 205 */ MNEM_PUSHA, - /* 206 */ MNEM_PUSHAD, - /* 207 */ MNEM_PUSHFD, - /* 208 */ MNEM_PUSHFQ, - /* 209 */ MNEM_PUSHFW, - /* 20A */ MNEM_PXOR, - /* 20B */ MNEM_RCL, - /* 20C */ MNEM_RCPPS, - /* 20D */ MNEM_RCPSS, - /* 20E */ MNEM_RCR, - /* 20F */ MNEM_RDMSR, - /* 210 */ MNEM_RDPMC, - /* 211 */ MNEM_RDRAND, - /* 212 */ MNEM_RDTSC, - /* 213 */ MNEM_RDTSCP, - /* 214 */ MNEM_REP, - /* 215 */ MNEM_REPNE, - /* 216 */ MNEM_RET, - /* 217 */ MNEM_RETF, - /* 218 */ MNEM_ROL, - /* 219 */ MNEM_ROR, - /* 21A */ MNEM_ROUNDPD, - /* 21B */ MNEM_ROUNDPS, - /* 21C */ MNEM_ROUNDSD, - /* 21D */ MNEM_ROUNDSS, - /* 21E */ MNEM_RSM, - /* 21F */ MNEM_RSQRTPS, - /* 220 */ MNEM_RSQRTSS, - /* 221 */ MNEM_SAHF, - /* 222 */ MNEM_SALC, - /* 223 */ MNEM_SAR, - /* 224 */ MNEM_SBB, - /* 225 */ MNEM_SCASB, - /* 226 */ MNEM_SCASD, - /* 227 */ MNEM_SCASQ, - /* 228 */ MNEM_SCASW, - /* 229 */ MNEM_SETA, - /* 22A */ MNEM_SETAE, - /* 22B */ MNEM_SETB, - /* 22C */ MNEM_SETBE, - /* 22D */ MNEM_SETE, - /* 22E */ MNEM_SETG, - /* 22F */ MNEM_SETGE, - /* 230 */ MNEM_SETL, - /* 231 */ MNEM_SETLE, - /* 232 */ MNEM_SETNE, - /* 233 */ MNEM_SETNO, - /* 234 */ MNEM_SETNP, - /* 235 */ MNEM_SETNS, - /* 236 */ MNEM_SETO, - /* 237 */ MNEM_SETP, - /* 238 */ MNEM_SETS, - /* 239 */ MNEM_SFENCE, - /* 23A */ MNEM_SGDT, - /* 23B */ MNEM_SHL, - /* 23C */ MNEM_SHLD, - /* 23D */ MNEM_SHR, - /* 23E */ MNEM_SHRD, - /* 23F */ MNEM_SHUFPD, - /* 240 */ MNEM_SHUFPS, - /* 241 */ MNEM_SIDT, - /* 242 */ MNEM_SKINIT, - /* 243 */ MNEM_SLDT, - /* 244 */ MNEM_SMSW, - /* 245 */ MNEM_SQRTPD, - /* 246 */ MNEM_SQRTPS, - /* 247 */ MNEM_SQRTSD, - /* 248 */ MNEM_SQRTSS, - /* 249 */ MNEM_STC, - /* 24A */ MNEM_STD, - /* 24B */ MNEM_STGI, - /* 24C */ MNEM_STI, - /* 24D */ MNEM_STMXCSR, - /* 24E */ MNEM_STOSB, - /* 24F */ MNEM_STOSD, - /* 250 */ MNEM_STOSQ, - /* 251 */ MNEM_STOSW, - /* 252 */ MNEM_STR, - /* 253 */ MNEM_SUB, - /* 254 */ MNEM_SUBPD, - /* 255 */ MNEM_SUBPS, - /* 256 */ MNEM_SUBSD, - /* 257 */ MNEM_SUBSS, - /* 258 */ MNEM_SWAPGS, - /* 259 */ MNEM_SYSCALL, - /* 25A */ MNEM_SYSENTER, - /* 25B */ MNEM_SYSEXIT, - /* 25C */ MNEM_SYSRET, - /* 25D */ MNEM_TEST, - /* 25E */ MNEM_UCOMISD, - /* 25F */ MNEM_UCOMISS, - /* 260 */ MNEM_UD2, - /* 261 */ MNEM_UNPCKHPD, - /* 262 */ MNEM_UNPCKHPS, - /* 263 */ MNEM_UNPCKLPD, - /* 264 */ MNEM_UNPCKLPS, - /* 265 */ MNEM_VADDPD, - /* 266 */ MNEM_VADDPS, - /* 267 */ MNEM_VADDSD, - /* 268 */ MNEM_VADDSS, - /* 269 */ MNEM_VADDSUBPD, - /* 26A */ MNEM_VADDSUBPS, - /* 26B */ MNEM_VAESDEC, - /* 26C */ MNEM_VAESDECLAST, - /* 26D */ MNEM_VAESENC, - /* 26E */ MNEM_VAESENCLAST, - /* 26F */ MNEM_VAESIMC, - /* 270 */ MNEM_VAESKEYGENASSIST, - /* 271 */ MNEM_VANDNPD, - /* 272 */ MNEM_VANDNPS, - /* 273 */ MNEM_VANDPD, - /* 274 */ MNEM_VANDPS, - /* 275 */ MNEM_VBLENDPD, - /* 276 */ MNEM_VBLENDPS, - /* 277 */ MNEM_VBLENDVPD, - /* 278 */ MNEM_VBLENDVPS, - /* 279 */ MNEM_VBROADCASTSD, - /* 27A */ MNEM_VBROADCASTSS, - /* 27B */ MNEM_VCMPPD, - /* 27C */ MNEM_VCMPPS, - /* 27D */ MNEM_VCMPSD, - /* 27E */ MNEM_VCMPSS, - /* 27F */ MNEM_VCOMISD, - /* 280 */ MNEM_VCOMISS, - /* 281 */ MNEM_VCVTDQ2PD, - /* 282 */ MNEM_VCVTDQ2PS, - /* 283 */ MNEM_VCVTPD2DQ, - /* 284 */ MNEM_VCVTPD2PS, - /* 285 */ MNEM_VCVTPS2DQ, - /* 286 */ MNEM_VCVTPS2PD, - /* 287 */ MNEM_VCVTSD2SI, - /* 288 */ MNEM_VCVTSD2SS, - /* 289 */ MNEM_VCVTSI2SD, - /* 28A */ MNEM_VCVTSI2SS, - /* 28B */ MNEM_VCVTSS2SD, - /* 28C */ MNEM_VCVTSS2SI, - /* 28D */ MNEM_VCVTTPD2DQ, - /* 28E */ MNEM_VCVTTPS2DQ, - /* 28F */ MNEM_VCVTTSD2SI, - /* 290 */ MNEM_VCVTTSS2SI, - /* 291 */ MNEM_VDIVPD, - /* 292 */ MNEM_VDIVPS, - /* 293 */ MNEM_VDIVSD, - /* 294 */ MNEM_VDIVSS, - /* 295 */ MNEM_VDPPD, - /* 296 */ MNEM_VDPPS, - /* 297 */ MNEM_VERR, - /* 298 */ MNEM_VERW, - /* 299 */ MNEM_VEXTRACTF128, - /* 29A */ MNEM_VEXTRACTPS, - /* 29B */ MNEM_VHADDPD, - /* 29C */ MNEM_VHADDPS, - /* 29D */ MNEM_VHSUBPD, - /* 29E */ MNEM_VHSUBPS, - /* 29F */ MNEM_VINSERTF128, - /* 2A0 */ MNEM_VINSERTPS, - /* 2A1 */ MNEM_VLDDQU, - /* 2A2 */ MNEM_VMASKMOVDQU, - /* 2A3 */ MNEM_VMASKMOVPD, - /* 2A4 */ MNEM_VMASKMOVPS, - /* 2A5 */ MNEM_VMAXPD, - /* 2A6 */ MNEM_VMAXPS, - /* 2A7 */ MNEM_VMAXSD, - /* 2A8 */ MNEM_VMAXSS, - /* 2A9 */ MNEM_VMCALL, - /* 2AA */ MNEM_VMCLEAR, - /* 2AB */ MNEM_VMINPD, - /* 2AC */ MNEM_VMINPS, - /* 2AD */ MNEM_VMINSD, - /* 2AE */ MNEM_VMINSS, - /* 2AF */ MNEM_VMLAUNCH, - /* 2B0 */ MNEM_VMLOAD, - /* 2B1 */ MNEM_VMMCALL, - /* 2B2 */ MNEM_VMOVAPD, - /* 2B3 */ MNEM_VMOVAPS, - /* 2B4 */ MNEM_VMOVD, - /* 2B5 */ MNEM_VMOVDDUP, - /* 2B6 */ MNEM_VMOVDQA, - /* 2B7 */ MNEM_VMOVDQU, - /* 2B8 */ MNEM_VMOVHLPS, - /* 2B9 */ MNEM_VMOVHPD, - /* 2BA */ MNEM_VMOVHPS, - /* 2BB */ MNEM_VMOVLHPS, - /* 2BC */ MNEM_VMOVLPD, - /* 2BD */ MNEM_VMOVLPS, - /* 2BE */ MNEM_VMOVMSKPD, - /* 2BF */ MNEM_VMOVMSKPS, - /* 2C0 */ MNEM_VMOVNTDQ, - /* 2C1 */ MNEM_VMOVNTDQA, - /* 2C2 */ MNEM_VMOVNTPD, - /* 2C3 */ MNEM_VMOVNTPS, - /* 2C4 */ MNEM_VMOVQ, - /* 2C5 */ MNEM_VMOVSD, - /* 2C6 */ MNEM_VMOVSHDUP, - /* 2C7 */ MNEM_VMOVSLDUP, - /* 2C8 */ MNEM_VMOVSS, - /* 2C9 */ MNEM_VMOVUPD, - /* 2CA */ MNEM_VMOVUPS, - /* 2CB */ MNEM_VMPSADBW, - /* 2CC */ MNEM_VMPTRLD, - /* 2CD */ MNEM_VMPTRST, - /* 2CE */ MNEM_VMREAD, - /* 2CF */ MNEM_VMRESUME, - /* 2D0 */ MNEM_VMRUN, - /* 2D1 */ MNEM_VMSAVE, - /* 2D2 */ MNEM_VMULPD, - /* 2D3 */ MNEM_VMULPS, - /* 2D4 */ MNEM_VMULSD, - /* 2D5 */ MNEM_VMULSS, - /* 2D6 */ MNEM_VMWRITE, - /* 2D7 */ MNEM_VMXOFF, - /* 2D8 */ MNEM_VMXON, - /* 2D9 */ MNEM_VORPD, - /* 2DA */ MNEM_VORPS, - /* 2DB */ MNEM_VPABSB, - /* 2DC */ MNEM_VPABSD, - /* 2DD */ MNEM_VPABSW, - /* 2DE */ MNEM_VPACKSSDW, - /* 2DF */ MNEM_VPACKSSWB, - /* 2E0 */ MNEM_VPACKUSDW, - /* 2E1 */ MNEM_VPACKUSWB, - /* 2E2 */ MNEM_VPADDB, - /* 2E3 */ MNEM_VPADDD, - /* 2E4 */ MNEM_VPADDQ, - /* 2E5 */ MNEM_VPADDSB, - /* 2E6 */ MNEM_VPADDSW, - /* 2E7 */ MNEM_VPADDUSB, - /* 2E8 */ MNEM_VPADDUSW, - /* 2E9 */ MNEM_VPADDW, - /* 2EA */ MNEM_VPALIGNR, - /* 2EB */ MNEM_VPAND, - /* 2EC */ MNEM_VPANDN, - /* 2ED */ MNEM_VPAVGB, - /* 2EE */ MNEM_VPAVGW, - /* 2EF */ MNEM_VPBLENDVB, - /* 2F0 */ MNEM_VPBLENDW, - /* 2F1 */ MNEM_VPCLMULQDQ, - /* 2F2 */ MNEM_VPCMPEQB, - /* 2F3 */ MNEM_VPCMPEQD, - /* 2F4 */ MNEM_VPCMPEQQ, - /* 2F5 */ MNEM_VPCMPEQW, - /* 2F6 */ MNEM_VPCMPESTRI, - /* 2F7 */ MNEM_VPCMPESTRM, - /* 2F8 */ MNEM_VPCMPGTB, - /* 2F9 */ MNEM_VPCMPGTD, - /* 2FA */ MNEM_VPCMPGTQ, - /* 2FB */ MNEM_VPCMPGTW, - /* 2FC */ MNEM_VPCMPISTRI, - /* 2FD */ MNEM_VPCMPISTRM, - /* 2FE */ MNEM_VPERM2F128, - /* 2FF */ MNEM_VPERMILPD, - /* 300 */ MNEM_VPERMILPS, - /* 301 */ MNEM_VPEXTRB, - /* 302 */ MNEM_VPEXTRD, - /* 303 */ MNEM_VPEXTRQ, - /* 304 */ MNEM_VPEXTRW, - /* 305 */ MNEM_VPHADDD, - /* 306 */ MNEM_VPHADDSW, - /* 307 */ MNEM_VPHADDW, - /* 308 */ MNEM_VPHMINPOSUW, - /* 309 */ MNEM_VPHSUBD, - /* 30A */ MNEM_VPHSUBSW, - /* 30B */ MNEM_VPHSUBW, - /* 30C */ MNEM_VPINSRB, - /* 30D */ MNEM_VPINSRD, - /* 30E */ MNEM_VPINSRQ, - /* 30F */ MNEM_VPINSRW, - /* 310 */ MNEM_VPMADDUBSW, - /* 311 */ MNEM_VPMADDWD, - /* 312 */ MNEM_VPMAXSB, - /* 313 */ MNEM_VPMAXSD, - /* 314 */ MNEM_VPMAXSW, - /* 315 */ MNEM_VPMAXUB, - /* 316 */ MNEM_VPMAXUD, - /* 317 */ MNEM_VPMAXUW, - /* 318 */ MNEM_VPMINSB, - /* 319 */ MNEM_VPMINSD, - /* 31A */ MNEM_VPMINSW, - /* 31B */ MNEM_VPMINUB, - /* 31C */ MNEM_VPMINUD, - /* 31D */ MNEM_VPMINUW, - /* 31E */ MNEM_VPMOVMSKB, - /* 31F */ MNEM_VPMOVSXBD, - /* 320 */ MNEM_VPMOVSXBQ, - /* 321 */ MNEM_VPMOVSXBW, - /* 322 */ MNEM_VPMOVSXWD, - /* 323 */ MNEM_VPMOVSXWQ, - /* 324 */ MNEM_VPMOVZXBD, - /* 325 */ MNEM_VPMOVZXBQ, - /* 326 */ MNEM_VPMOVZXBW, - /* 327 */ MNEM_VPMOVZXDQ, - /* 328 */ MNEM_VPMOVZXWD, - /* 329 */ MNEM_VPMOVZXWQ, - /* 32A */ MNEM_VPMULDQ, - /* 32B */ MNEM_VPMULHRSW, - /* 32C */ MNEM_VPMULHUW, - /* 32D */ MNEM_VPMULHW, - /* 32E */ MNEM_VPMULLD, - /* 32F */ MNEM_VPMULLW, - /* 330 */ MNEM_VPOR, - /* 331 */ MNEM_VPSADBW, - /* 332 */ MNEM_VPSHUFB, - /* 333 */ MNEM_VPSHUFD, - /* 334 */ MNEM_VPSHUFHW, - /* 335 */ MNEM_VPSHUFLW, - /* 336 */ MNEM_VPSIGNB, - /* 337 */ MNEM_VPSIGND, - /* 338 */ MNEM_VPSIGNW, - /* 339 */ MNEM_VPSLLD, - /* 33A */ MNEM_VPSLLDQ, - /* 33B */ MNEM_VPSLLQ, - /* 33C */ MNEM_VPSLLW, - /* 33D */ MNEM_VPSRAD, - /* 33E */ MNEM_VPSRAW, - /* 33F */ MNEM_VPSRLD, - /* 340 */ MNEM_VPSRLDQ, - /* 341 */ MNEM_VPSRLQ, - /* 342 */ MNEM_VPSRLW, - /* 343 */ MNEM_VPSUBB, - /* 344 */ MNEM_VPSUBD, - /* 345 */ MNEM_VPSUBQ, - /* 346 */ MNEM_VPSUBSB, - /* 347 */ MNEM_VPSUBSW, - /* 348 */ MNEM_VPSUBUSB, - /* 349 */ MNEM_VPSUBUSW, - /* 34A */ MNEM_VPSUBW, - /* 34B */ MNEM_VPTEST, - /* 34C */ MNEM_VPUNPCKHBW, - /* 34D */ MNEM_VPUNPCKHDQ, - /* 34E */ MNEM_VPUNPCKHQDQ, - /* 34F */ MNEM_VPUNPCKHWD, - /* 350 */ MNEM_VPUNPCKLBW, - /* 351 */ MNEM_VPUNPCKLDQ, - /* 352 */ MNEM_VPUNPCKLQDQ, - /* 353 */ MNEM_VPUNPCKLWD, - /* 354 */ MNEM_VPXOR, - /* 355 */ MNEM_VRCPPS, - /* 356 */ MNEM_VRCPSS, - /* 357 */ MNEM_VROUNDPD, - /* 358 */ MNEM_VROUNDPS, - /* 359 */ MNEM_VROUNDSD, - /* 35A */ MNEM_VROUNDSS, - /* 35B */ MNEM_VRSQRTPS, - /* 35C */ MNEM_VRSQRTSS, - /* 35D */ MNEM_VSHUFPD, - /* 35E */ MNEM_VSHUFPS, - /* 35F */ MNEM_VSQRTPD, - /* 360 */ MNEM_VSQRTPS, - /* 361 */ MNEM_VSQRTSD, - /* 362 */ MNEM_VSQRTSS, - /* 363 */ MNEM_VSTMXCSR, - /* 364 */ MNEM_VSUBPD, - /* 365 */ MNEM_VSUBPS, - /* 366 */ MNEM_VSUBSD, - /* 367 */ MNEM_VSUBSS, - /* 368 */ MNEM_VTESTPD, - /* 369 */ MNEM_VTESTPS, - /* 36A */ MNEM_VUCOMISD, - /* 36B */ MNEM_VUCOMISS, - /* 36C */ MNEM_VUNPCKHPD, - /* 36D */ MNEM_VUNPCKHPS, - /* 36E */ MNEM_VUNPCKLPD, - /* 36F */ MNEM_VUNPCKLPS, - /* 370 */ MNEM_VXORPD, - /* 371 */ MNEM_VXORPS, - /* 372 */ MNEM_VZEROALL, - /* 373 */ MNEM_VZEROUPPER, - /* 374 */ MNEM_WAIT, - /* 375 */ MNEM_WBINVD, - /* 376 */ MNEM_WRMSR, - /* 377 */ MNEM_XADD, - /* 378 */ MNEM_XCHG, - /* 379 */ MNEM_XCRYPTCBC, - /* 37A */ MNEM_XCRYPTCFB, - /* 37B */ MNEM_XCRYPTCTR, - /* 37C */ MNEM_XCRYPTECB, - /* 37D */ MNEM_XCRYPTOFB, - /* 37E */ MNEM_XGETBV, - /* 37F */ MNEM_XLATB, - /* 380 */ MNEM_XOR, - /* 381 */ MNEM_XORPD, - /* 382 */ MNEM_XORPS, - /* 383 */ MNEM_XRSTOR, - /* 384 */ MNEM_XSAVE, - /* 385 */ MNEM_XSETBV, - /* 386 */ MNEM_XSHA1, - /* 387 */ MNEM_XSHA256, - /* 388 */ MNEM_XSTORE, - - MNEM_FORCE_WORD = 0x7FFF -} VXInstructionMnemonic; - -/** - * @brief Defines an alias representing an opcode tree node. An opcode tree node is a 16 bit - * unsigned integer value with its first 4 bits reserved for the node type. - */ -typedef uint16_t VXOpcodeTreeNode; - -/** - * @brief Values that represent the type of an opcode tree node. - */ -typedef enum _VXOpcodeTreeNodeType /* : uint8_t */ -{ - /** - * @brief Reference to a concrete instruction definition. - */ - OTNT_INSTRUCTION_DEFINITION = 0, - /** - * @brief Reference to an opcode table. - */ - OTNT_TABLE = 1, - /** - * @brief Reference to a modrm_mod switch table. - */ - OTNT_MODRM_MOD = 2, - /** - * @brief Reference to a modrm_reg switch table. - */ - OTNT_MODRM_REG = 3, - /** - * @brief Reference to a modrm_rm switch table. - */ - OTNT_MODRM_RM = 4, - /** - * @brief Reference to a mandatory-prefix switch table. - */ - OTNT_MANDATORY = 5, - /** - * @brief Reference to a x87 opcode table. - */ - OTNT_X87 = 6, - /** - * @brief Reference to an address-size switch table. - */ - OTNT_ADDRESS_SIZE = 7, - /** - * @brief Reference to an operand-size switch table. - */ - OTNT_OPERAND_SIZE = 8, - /** - * @brief Reference to a cpu-mode switch table. - */ - OTNT_MODE = 9, - /** - * @brief Reference to a vendor switch table. - */ - OTNT_VENDOR = 10, - /** - * @brief Reference to a 3dnow! opcode table. - */ - OTNT_AMD3DNOW = 11, - /** - * @brief Reference to a vex-prefix switch table. - */ - OTNT_VEX = 12, - /** - * @brief Reference to a vex_w switch table. - */ - OTNT_VEXW = 13, - /** - * @brief Reference to a vex_l switch table. - */ - OTNT_VEXL = 14 -} VXOpcodeTreeNodeType; - -/** - * @brief Values that represent the type of an operand in the instruction definition. - */ -typedef enum _VXDefinedOperandType /* : uint8_t */ -{ - /* - * @brief No operand. - */ - DOT_NONE, - /* - * @brief Direct address. The instruction has no ModR/M byte; the address of the operand is - * encoded in the instruction; no base register, index register, or scaling factor - * can be applied. - */ - DOT_A, - /* - * @brief The reg field of the ModR/M byte selects a control register. - */ - DOT_C, - /* - * @brief The reg field of the ModR/M byte selects a debug register. - */ - DOT_D, - /* - * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either - * a general-purpose register or a memory address. If it is a memory address, the - * address is computed from a segment register and any of the following values: - * a base register, an index register, a scaling factor, or a displacement. - */ - DOT_E, - /* - * @brief rFLAGS register. - */ - DOT_F, - /* - * @brief The reg field of the ModR/M byte selects a general register. - */ - DOT_G, - /* - * @brief The r/m field of the ModR/M byte always selects a general register, regardless of - * the mod field. - */ - DOT_H, - /* - * @brief Immediate data. The operand value is encoded in subsequent bytes of the - * instruction. - */ - DOT_I, - /* - * @brief Signed immediate data. The operand value is encoded in subsequent bytes of the - * instruction. - */ - DOT_sI, - /* - * @brief Constant immediate data value of 1. - */ - DOT_I1, - /* - * @brief The instruction contains a relative offset to be added to the instruction pointer - * register. - */ - DOT_J, - /* - * @brief Source operand is encoded in immediate byte (VEX only). - */ - DOT_L, - /* - * @brief The ModR/M byte may refer only to memory: mod != 11bin. - */ - DOT_M, - /* - * @brief Combination of M and R. - */ - DOT_MR, - /* - * @brief Combination of M and U. - */ - DOT_MU, - /* - * @brief The R/M field of the ModR/M byte selects a packed quadword MMX technology register. - */ - DOT_N, - /* - * @brief The instruction has no ModR/M byte; the offset of the operand is coded as a word, - * double word or quad word (depending on address size attribute) in the instruction. - * No base register, index register, or scaling factor can be applied. - */ - DOT_O, - /* - * @brief The reg field of the ModR/M byte selects a packed quadword MMX technology register. - */ - DOT_P, - /* - * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either - * an MMX technology register or a memory address. If it is a memory address, the - * address is computed from a segment register and any of the following values: - * a base register, an index register, a scaling factor, and a displacement. - */ - DOT_Q, - /* - * @brief The mod field of the ModR/M byte may refer only to a general register. - */ - DOT_R, - /* - * @brief The reg field of the ModR/M byte selects a segment register. - */ - DOT_S, - /* - * @brief The R/M field of the ModR/M byte selects a 128-bit XMM register. - */ - DOT_U, - /* - * @brief The reg field of the ModR/M byte selects a 128-bit XMM register. - */ - DOT_V, - /* - * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either - * a 128-bit XMM register or a memory address. If it is a memory address, the address - * is computed from a segment register and any of the following values: - * a base register, an index register, a scaling factor, and a displacement. - */ - DOT_W, - /** - * @brief Register 0. - */ - DOT_R0, - /** - * @brief Register 1. - */ - DOT_R1, - /** - * @brief Register 2. - */ - DOT_R2, - /** - * @brief Register 3. - */ - DOT_R3, - /** - * @brief Register 4. - */ - DOT_R4, - /** - * @brief Register 5. - */ - DOT_R5, - /** - * @brief Register 6. - */ - DOT_R6, - /** - * @brief Register 7. - */ - DOT_R7, - /** - * @brief AL register. - */ - DOT_AL, - /** - * @brief CL register. - */ - DOT_CL, - /** - * @brief DL register. - */ - DOT_DL, - /** - * @brief AX register. - */ - DOT_AX, - /** - * @brief CX register. - */ - DOT_CX, - /** - * @brief DX register. - */ - DOT_DX, - /** - * @brief EAX register. - */ - DOT_EAX, - /** - * @brief ECX register. - */ - DOT_ECX, - /** - * @brief EDX register. - */ - DOT_EDX, - /** - * @brief RAX register. - */ - DOT_RAX, - /** - * @brief RCX register. - */ - DOT_RCX, - /** - * @brief RDX register. - */ - DOT_RDX, - /** - * @brief ES segment register. - */ - DOT_ES, - /** - * @brief CS segment register. - */ - DOT_CS, - /** - * @brief SS segment register. - */ - DOT_SS, - /** - * @brief DS segment register. - */ - DOT_DS, - /** - * @brief FS segment register. - */ - DOT_FS, - /** - * @brief GS segment register. - */ - DOT_GS, - /** - * @brief Floating point register 0. - */ - DOT_ST0, - /** - * @brief Floating point register 1. - */ - DOT_ST1, - /** - * @brief Floating point register 2. - */ - DOT_ST2, - /** - * @brief Floating point register 3. - */ - DOT_ST3, - /** - * @brief Floating point register 4. - */ - DOT_ST4, - /** - * @brief Floating point register 5. - */ - DOT_ST5, - /** - * @brief Floating point register 6. - */ - DOT_ST6, - /** - * @brief Floating point register 7. - */ - DOT_ST7 -} VXDefinedOperandType; - -/** - * @brief Values that represent the size of an operand in the instruction definition. - * Do not change the order or the values of this enum! - */ -typedef enum _VXDefinedOperandSize /* : uint8_t */ -{ - /** - * @brief No operand. - */ - DOS_NA = 0, - /** - * @brief Word, dword or qword. - */ - DOS_Z, - /** - * @brief Word, dword or qword. - */ - DOS_V, - /** - * @brief Dword or qword. - */ - DOS_Y, - /** - * @brief Oword or yword. - */ - DOS_X, - /** - * @brief Dword or qword, depending on the disassembler mode. - */ - DOS_RDQ, - /* - * @brief Byte, regardless of operand-size attribute. - */ - DOS_B, - /* - * @brief Word, regardless of operand-size attribute. - */ - DOS_W, - /* - * @brief Doubleword, regardless of operand-size attribute. - */ - DOS_D, - /* - * @brief Quadword, regardless of operand-size attribute. - */ - DOS_Q, - /* - * @brief 10-byte far pointer. - */ - DOS_T, - /** - * @brief TODO: - */ - DOS_O, - /* - * @brief Double-quadword, regardless of operand-size attribute. - */ - DOS_DQ, - /* - * @brief Quad-quadword, regardless of operand-size attribute. - */ - DOS_QQ, - /** - * @brief B sized register or D sized memory operand. - */ - DOS_BD = (DOS_B << 4) | DOS_D, - /** - * @brief B sized register or V sized memory operand. - */ - DOS_BV = (DOS_B << 4) | DOS_V, - /** - * @brief W sized register or D sized memory operand. - */ - DOS_WD = (DOS_W << 4) | DOS_D, - /** - * @brief W sized register or V sized memory operand. - */ - DOS_WV = (DOS_W << 4) | DOS_V, - /** - * @brief W sized register or Y sized memory operand. - */ - DOS_WY = (DOS_W << 4) | DOS_Y, - /** - * @brief D sized register or Y sized memory operand. - */ - DOS_DY = (DOS_D << 4) | DOS_Y, - /** - * @brief W sized register or O sized memory operand. - */ - DOS_WO = (DOS_W << 4) | DOS_O, - /** - * @brief D sized register or O sized memory operand. - */ - DOS_DO = (DOS_D << 4) | DOS_O, - /** - * @brief Q sized register or O sized memory operand. - */ - DOS_QO = (DOS_Q << 4) | DOS_O, -} VXDefinedOperandSize; - -/** - * @brief Values that represent optional flags in the instruction definition. - * Do not change the order or the values of this enum! - */ -typedef enum _VXInstructionDefinitionFlags /* : uint16_t */ -{ - /** - * @brief The instruction accepts the rex.b prefix value. - */ - IDF_ACCEPTS_REXB = 0x0001, - /** - * @brief The instruction accepts the rex.x prefix value. - */ - IDF_ACCEPTS_REXX = 0x0002, - /** - * @brief The instruction accepts the rex.r prefix value. - */ - IDF_ACCEPTS_REXR = 0x0004, - /** - * @brief The instruction accepts the rex.w prefix value. - */ - IDF_ACCEPTS_REXW = 0x0008, - /** - * @brief The instruction accepts the address size override prefix (0x67). - */ - IDF_ACCEPTS_ADDRESS_SIZE_PREFIX = 0x0010, - /** - * @brief The instruction accepts the operand size override prefix (0x66). - */ - IDF_ACCEPTS_OPERAND_SIZE_PREFIX = 0x0020, - /** - * @brief The instruction accepts the segment override prefix. - */ - IDF_ACCEPTS_SEGMENT_PREFIX = 0x0040, - /** - * @brief The instruction accepts the REP prefix. - */ - IDF_ACCEPTS_REP_PREFIX = 0x0080, - /** - * @brief The instruction accepts the vex.l prefix value. - */ - IDF_ACCEPTS_VEXL = 0x0100, - /** - * @brief The instruction is invalid in 64 bit mode. - */ - IDF_INVALID_64 = 0x0200, - /** - * @brief The instructions operand size defaults to quadword in 64 bit mode. - */ - IDF_DEFAULT_64 = 0x0400, - /** - * @brief The first operand of the instruction is accessed in write mode. - */ - IDF_OPERAND1_WRITE = 0x0800, - /** - * @brief The first operand of the instruction is accessed in read-write mode. - */ - IDF_OPERAND1_READWRITE = 0x1000, - /** - * @brief The second operand of the instruction is accessed in write mode. - */ - IDF_OPERAND2_WRITE = 0x2000, - /** - * @brief The second operand of the instruction is accessed in read-write mode. - */ - IDF_OPERAND2_READWRITE = 0x4000, - - IDF_FORCE_WORD = 0x7FFF -} VXInstructionDefinitionFlags; - -#pragma pack (push, 1) -/** - * @brief An operand definition. - */ -typedef struct _VXOperandDefinition -{ - /** - * @brief The defined operand type. - * @see VXDefinedOperandType - */ - uint8_t type; - /** - * @brief The defined operand size. - * @see VXDefinedOperandType - */ - uint8_t size; -} VXOperandDefinition; - -/** - * @brief An instruction definition. - */ -typedef struct _VXInstructionDefinition -{ - /** - * @brief The instruction mnemonic. - * @see VXInstructionMnemonic - */ - uint16_t mnemonic; - /** - * @brief The operand definitions for all four possible operands. - */ - VXOperandDefinition operand[4]; - /** - * @brief Additional flags for the instruction definition. - */ - uint16_t flags; -} VXInstructionDefinition; -#pragma pack (pop) - -#ifdef __cplusplus -} -#endif - -#endif // _VDE_VXOPCODETABLEC_H_ \ No newline at end of file diff --git a/Bindings/C/VXDisassemblerC.h b/Bindings/Cpp/VXDisassembler.hpp similarity index 76% rename from Bindings/C/VXDisassemblerC.h rename to Bindings/Cpp/VXDisassembler.hpp index 173e45f..c537e68 100644 --- a/Bindings/C/VXDisassemblerC.h +++ b/Bindings/Cpp/VXDisassembler.hpp @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : athre0z + Modifications : - Last change : 04. February 2015 + Last change : 29. October 2014 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,14 +28,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - **************************************************************************************************/ +**************************************************************************************************/ -#ifndef _VDE_VXDISASSEMBLERC_H_ -#define _VDE_VXDISASSEMBLERC_H_ +#pragma once -#include "VXDisassemblerTypesC.h" -#include "VXInstructionDecoderC.h" -#include "VXInstructionFormatterC.h" -#include "VXDisassemblerUtilsC.h" - -#endif /* _VDE_VXDISASSEMBLERC_H_ */ \ No newline at end of file +#include "VXDisassemblerTypes.hpp" +#include "VXInstructionDecoder.hpp" +#include "VXInstructionFormatter.hpp" +#include "VXDisassemblerUtils.hpp" diff --git a/Bindings/C/VXDisassemblerTypesC.h b/Bindings/Cpp/VXDisassemblerTypes.hpp similarity index 80% rename from Bindings/C/VXDisassemblerTypesC.h rename to Bindings/Cpp/VXDisassemblerTypes.hpp index 2667dd4..1e0d526 100644 --- a/Bindings/C/VXDisassemblerTypesC.h +++ b/Bindings/Cpp/VXDisassemblerTypes.hpp @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : athre0z + Modifications : - Last change : 04. February 2015 + Last change : 22. October 2014 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,23 +29,18 @@ * SOFTWARE. **************************************************************************************************/ - -#ifndef _VDE_VXDISASSEMBLERTYPESC_H_ -#define _VDE_VXDISASSEMBLERTYPESC_H_ +#pragma once #include -#include -#include "VXOpcodeTableC.h" +#include "VXOpcodeTable.hpp" -#ifdef __cplusplus -extern "C" +namespace Verteron { -#endif /** * @brief Values that represent additional flags of a decoded instruction. */ -typedef enum _VXInstructionFlags /* : uint32_t */ +enum InstructionFlags : uint32_t { IF_NONE = 0x00000000, /** @@ -127,157 +122,149 @@ typedef enum _VXInstructionFlags /* : uint32_t */ /** * @brief An error occured while decoding the instruction operands. */ - IF_ERROR_OPERAND = 0x01000000, - - IF_FORCE_DWORD = 0x7FFFFFFF -} VXInstructionFlags; + IF_ERROR_OPERAND = 0x01000000 +}; /** * @brief Values that represent a cpu register. */ -typedef enum _VXRegister /* : uint16_t */ +enum class VXRegister : uint16_t { - REG_NONE, + NONE, /* 8 bit general purpose registers */ - REG_AL, REG_CL, REG_DL, REG_BL, - REG_AH, REG_CH, REG_DH, REG_BH, - REG_SPL, REG_BPL, REG_SIL, REG_DIL, - REG_R8B, REG_R9B, REG_R10B, REG_R11B, - REG_R12B, REG_R13B, REG_R14B, REG_R15B, + AL, CL, DL, BL, + AH, CH, DH, BH, + SPL, BPL, SIL, DIL, + R8B, R9B, R10B, R11B, + R12B, R13B, R14B, R15B, /* 16 bit general purpose registers */ - REG_AX, REG_CX, REG_DX, REG_BX, - REG_SP, REG_BP, REG_SI, REG_DI, - REG_R8W, REG_R9W, REG_R10W, REG_R11W, - REG_R12W, REG_R13W, REG_R14W, REG_R15W, + AX, CX, DX, BX, + SP, BP, SI, DI, + R8W, R9W, R10W, R11W, + R12W, R13W, R14W, R15W, /* 32 bit general purpose registers */ - REG_EAX, REG_ECX, REG_EDX, REG_EBX, - REG_ESP, REG_EBP, REG_ESI, REG_EDI, - REG_R8D, REG_R9D, REG_R10D, REG_R11D, - REG_R12D, REG_R13D, REG_R14D, REG_R15D, + EAX, ECX, EDX, EBX, + ESP, EBP, ESI, EDI, + R8D, R9D, R10D, R11D, + R12D, R13D, R14D, R15D, /* 64 bit general purpose registers */ - REG_RAX, REG_RCX, REG_RDX, REG_RBX, - REG_RSP, REG_RBP, REG_RSI, REG_RDI, - REG_R8, REG_R9, REG_R10, REG_R11, - REG_R12, REG_R13, REG_R14, REG_R15, + RAX, RCX, RDX, RBX, + RSP, RBP, RSI, RDI, + R8, R9, R10, R11, + R12, R13, R14, R15, /* segment registers */ - REG_ES, REG_CS, REG_SS, - REG_DS, REG_FS, REG_GS, + ES, CS, SS, + DS, FS, GS, /* control registers */ - REG_CR0, REG_CR1, REG_CR2, REG_CR3, - REG_CR4, REG_CR5, REG_CR6, REG_CR7, - REG_CR8, REG_CR9, REG_CR10, REG_CR11, - REG_CR12, REG_CR13, REG_CR14, REG_CR15, + CR0, CR1, CR2, CR3, + CR4, CR5, CR6, CR7, + CR8, CR9, CR10, CR11, + CR12, CR13, CR14, CR15, /* debug registers */ - REG_DR0, REG_DR1, REG_DR2, REG_DR3, - REG_DR4, REG_DR5, REG_DR6, REG_DR7, - REG_DR8, REG_DR9, REG_DR10, REG_DR11, - REG_DR12, REG_DR13, REG_DR14, REG_DR15, + DR0, DR1, DR2, DR3, + DR4, DR5, DR6, DR7, + DR8, DR9, DR10, DR11, + DR12, DR13, DR14, DR15, /* mmx registers */ - REG_MM0, REG_MM1, REG_MM2, REG_MM3, - REG_MM4, REG_MM5, REG_MM6, REG_MM7, + MM0, MM1, MM2, MM3, + MM4, MM5, MM6, MM7, /* x87 registers */ - REG_ST0, REG_ST1, REG_ST2, REG_ST3, - REG_ST4, REG_ST5, REG_ST6, REG_ST7, + ST0, ST1, ST2, ST3, + ST4, ST5, ST6, ST7, /* extended multimedia registers */ - REG_XMM0, REG_XMM1, REG_XMM2, REG_XMM3, - REG_XMM4, REG_XMM5, REG_XMM6, REG_XMM7, - REG_XMM8, REG_XMM9, REG_XMM10, REG_XMM11, - REG_XMM12, REG_XMM13, REG_XMM14, REG_XMM15, + XMM0, XMM1, XMM2, XMM3, + XMM4, XMM5, XMM6, XMM7, + XMM8, XMM9, XMM10, XMM11, + XMM12, XMM13, XMM14, XMM15, /* 256 bit multimedia registers */ - REG_YMM0, REG_YMM1, REG_YMM2, REG_YMM3, - REG_YMM4, REG_YMM5, REG_YMM6, REG_YMM7, - REG_YMM8, REG_YMM9, REG_YMM10, REG_YMM11, - REG_YMM12, REG_YMM13, REG_YMM14, YMM15, + YMM0, YMM1, YMM2, YMM3, + YMM4, YMM5, YMM6, YMM7, + YMM8, YMM9, YMM10, YMM11, + YMM12, YMM13, YMM14, YMM15, /* instruction pointer register */ - REG_RIP, - - REG_FORCE_WORD = 0x7FFF -} VXRegister; + RIP +}; /** * @brief Values that represent the type of a decoded operand. */ -typedef enum _VXOperandType /*: uint8_t*/ +enum class VXOperandType : uint8_t { /** * @brief The operand is not used. */ - OPTYPE_NONE, + NONE, /** * @brief The operand is a register operand. */ - OPTYPE_REGISTER, + REGISTER, /** * @brief The operand is a memory operand. */ - OPTYPE_MEMORY, + MEMORY, /** * @brief The operand is a pointer operand. */ - OPTYPE_POINTER, + POINTER, /** * @brief The operand is an immediate operand. */ - OPTYPE_IMMEDIATE, + IMMEDIATE, /** * @brief The operand is a relative immediate operand. */ - OPTYPE_REL_IMMEDIATE, + REL_IMMEDIATE, /** * @brief The operand is a constant value. */ - OPTYPE_CONSTANT -} VXOperandType; + CONSTANT +}; /** * @brief Values that represent the operand access mode. */ -typedef enum _VXOperandAccessMode /* : uint8_t */ +enum class VXOperandAccessMode : uint8_t { - OPACCESSMODE_NA, + NA, /** * @brief The operand is accessed in read-only mode. */ - OPACCESSMODE_READ, + READ, /** * @brief The operand is accessed in write mode. */ - OPACCESSMODE_WRITE, + WRITE, /** * @brief The operand is accessed in read-write mode. */ - OPACCESSMODE_READWRITE -} VXOperandAccessMode; + READWRITE +}; /** * @brief This struct holds information about a decoded operand. */ -typedef struct _VXOperandInfo +struct VXOperandInfo { /** * @brief The type of the operand. - * @see VXOperandType */ - uint8_t type; + VXOperandType type; /** * @brief The size of the operand. */ uint16_t size; /** * @brief The operand access mode. - * @see VXOperandAccessMode */ - uint8_t access_mode; + VXOperandAccessMode access_mode; /** * @brief The base register. - * @see VXRegister */ - uint16_t base; + VXRegister base; /** * @brief The index register. - * @see VXRegister */ - uint16_t index; + VXRegister index; /** * @brief The scale factor. */ @@ -308,12 +295,12 @@ typedef struct _VXOperandInfo uint32_t off; } ptr; } lval; -} VXOperandInfo; +}; /** * @brief This struct holds information about a decoded instruction. */ -typedef struct _VXInstructionInfo +struct VXInstructionInfo { /** * @brief The instruction flags. @@ -321,9 +308,8 @@ typedef struct _VXInstructionInfo uint32_t flags; /** * @brief The instruction mnemonic. - * @see VXInstructionMnemonic */ - uint16_t mnemonic; + VXInstructionMnemonic mnemonic; /** * @brief The total length of the instruction. */ @@ -355,9 +341,8 @@ typedef struct _VXInstructionInfo /** * @brief The segment register. This value will default to @c NONE, if no segment register * prefix is present. - * @see VXRegister */ - uint16_t segment; + VXRegister segment; /** * @brief The rex prefix byte. */ @@ -539,10 +524,6 @@ typedef struct _VXInstructionInfo * This field is used to properly format relative instructions. */ uint64_t instrPointer; -} VXInstructionInfo; +}; -#ifdef __cplusplus } -#endif - -#endif /* _VDE_VXDISASSEMBLERTYPESC_H_ */ \ No newline at end of file diff --git a/VerteronDisassemblerEngine/VXDisassemblerUtils.cpp b/Bindings/Cpp/VXDisassemblerUtils.cpp similarity index 98% rename from VerteronDisassemblerEngine/VXDisassemblerUtils.cpp rename to Bindings/Cpp/VXDisassemblerUtils.cpp index f8d640f..1dad08f 100644 --- a/VerteronDisassemblerEngine/VXDisassemblerUtils.cpp +++ b/Bindings/Cpp/VXDisassemblerUtils.cpp @@ -29,7 +29,7 @@ * SOFTWARE. **************************************************************************************************/ -#include "VXDisassemblerUtils.h" +#include "VXDisassemblerUtils.hpp" #include namespace Verteron diff --git a/Bindings/C/VXDisassemblerUtilsC.h b/Bindings/Cpp/VXDisassemblerUtils.hpp similarity index 76% rename from Bindings/C/VXDisassemblerUtilsC.h rename to Bindings/Cpp/VXDisassemblerUtils.hpp index 9ab74ca..72086d2 100644 --- a/Bindings/C/VXDisassemblerUtilsC.h +++ b/Bindings/Cpp/VXDisassemblerUtils.hpp @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : athre0z + Modifications : - Last change : 04. February 2015 + Last change : 30. October 2014 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,26 +29,13 @@ * SOFTWARE. **************************************************************************************************/ - -#ifndef _VDE_VXDISASSEMBLERUTILSC_H_ -#define _VDE_VXDISASSEMBLERUTILSC_H_ - -#include "VXDisassemblerTypesC.h" -#include "VXInternalConfig.h" +#pragma once #include +#include "VXDisassemblerTypes.hpp" - -#ifdef __cplusplus -extern "C" +namespace Verteron { -#endif - -typedef struct _VXContextDescriptor -{ - uint8_t type; - void *ptr; -} VXContextDescriptor; /** * @brief Calculates the absolute target address of a relative instruction operand. @@ -56,12 +43,6 @@ typedef struct _VXContextDescriptor * @param operand The operand. * @return The absolute target address. */ -VX_EXPORT uint64_t VXCalcAbsoluteTarget( - const VXInstructionInfo *info, - const VXOperandInfo *operand); +uint64_t VDECalcAbsoluteTarget(const VXInstructionInfo &info, const VXOperandInfo &operand); -#ifdef __cplusplus } -#endif - -#endif /* _VDE_VXDISASSEMBLERUTILSC_H_ */ \ No newline at end of file diff --git a/VerteronDisassemblerEngine/VXInstructionDecoder.cpp b/Bindings/Cpp/VXInstructionDecoder.cpp similarity index 99% rename from VerteronDisassemblerEngine/VXInstructionDecoder.cpp rename to Bindings/Cpp/VXInstructionDecoder.cpp index d6537d8..1861388 100644 --- a/VerteronDisassemblerEngine/VXInstructionDecoder.cpp +++ b/Bindings/Cpp/VXInstructionDecoder.cpp @@ -29,7 +29,7 @@ * SOFTWARE. **************************************************************************************************/ -#include "VXInstructionDecoder.h" +#include "VXInstructionDecoder.hpp" #include namespace Verteron diff --git a/Bindings/Cpp/VXInstructionDecoder.hpp b/Bindings/Cpp/VXInstructionDecoder.hpp new file mode 100644 index 0000000..7ecf592 --- /dev/null +++ b/Bindings/Cpp/VXInstructionDecoder.hpp @@ -0,0 +1,718 @@ +/************************************************************************************************** + + Verteron Disassembler Engine + Version 1.0 + + Remarks : Freeware, Copyright must be included + + Original Author : Florian Bernd + Modifications : + + Last change : 29. October 2014 + + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + +**************************************************************************************************/ +#pragma once + +#include +#include +#include "VXDisassemblerTypes.hpp" + +namespace Verteron +{ + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief The base class for all data-source implementations. + */ +class VXBaseDataSource +{ +private: + uint8_t m_currentInput; +protected: + /** + * @brief Override this method in your custom data source implementations. + * Reads the next byte from the data source. This method increases the current + * input position by one. + * @return The current input byte. + */ + virtual uint8_t internalInputPeek() = 0; + /** + * @brief Override this method in your custom data source implementations. + * Reads the next byte from the data source. This method does NOT increase the + * current input position. + * @return The current input byte. + */ + virtual uint8_t internalInputNext() = 0; +protected: + /** + * @brief Default constructor. + */ + VXBaseDataSource() { }; +public: + /** + * @brief Destructor. + */ + virtual ~VXBaseDataSource() { }; +public: + /** + * @brief Reads the next byte from the data source. This method does NOT increase the + * current input position or the @c length field of the @c info parameter. + * @param info The instruction info. + * @return The current input byte. If the result is zero, you should always check the + * @c flags field of the @c info parameter for error flags. + * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. + */ + uint8_t inputPeek(VXInstructionInfo &info); + /** + * @brief Reads the next byte from the data source. This method increases the current + * input position and the @c length field of the @c info parameter. + * This method also appends the new byte to to @c data field of the @c info + * parameter. + * @param info The instruction info. + * @return The current input byte. If the result is zero, you should always check the + * @c flags field of the @c info parameter for error flags. + * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. + */ + uint8_t inputNext(VXInstructionInfo &info); + /** + * @brief Reads the next byte(s) from the data source. This method increases the current + * input position and the @c length field of the @c info parameter. + * This method also appends the new byte(s) to to @c data field of the @c info + * parameter. + * @param info The instruction info. + * @return The current input data. If the result is zero, you should always check the + * @c flags field of the @c info parameter for error flags. + * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. + */ + template + T inputNext(VXInstructionInfo &info); + /** + * @brief Returns the current input byte. The current input byte is set everytime the + * @c inputPeek or @c inputNext method is called. + * @return The current input byte. + */ + uint8_t inputCurrent() const; +public: + /** + * @brief Override this method in your custom data source implementations. + * Signals, if the end of the data source is reached. + * @return True if end of input, false if not. + */ + virtual bool isEndOfInput() const = 0; + /** + * @brief Override this method in your custom data source implementations. + * Returns the current input position. + * @return The current input position. + */ + virtual uint64_t getPosition() const = 0; + /** + * @brief Override this method in your custom data source implementations. + * Sets a new input position. + * @param position The new input position. + * @return Returns false, if the new position exceeds the maximum input length. + */ + virtual bool setPosition(uint64_t position) = 0; +}; + +inline uint8_t VXBaseDataSource::inputPeek(VXInstructionInfo &info) +{ + if (info.length == 15) + { + info.flags |= IF_ERROR_LENGTH; + return 0; + } + if (isEndOfInput()) + { + info.flags |= IF_ERROR_END_OF_INPUT; + return 0; + } + m_currentInput = internalInputPeek(); + return m_currentInput; +} + +inline uint8_t VXBaseDataSource::inputNext(VXInstructionInfo &info) +{ + if (info.length == 15) + { + info.flags |= IF_ERROR_LENGTH; + return 0; + } + if (isEndOfInput()) + { + info.flags |= IF_ERROR_END_OF_INPUT; + return 0; + } + m_currentInput = internalInputNext(); + info.data[info.length] = m_currentInput; + info.length++; + return m_currentInput; +} + +template +inline T VXBaseDataSource::inputNext(VXInstructionInfo &info) +{ + static_assert(std::is_integral::value, "integral type required"); + T result = 0; + for (unsigned i = 0; i < (sizeof(T) / sizeof(uint8_t)); ++i) + { + T b = inputNext(info); + if (!b && (info.flags & IF_ERROR_MASK)) + { + return 0; + } + result |= (b << (i * 8)); + } + return result; +} + +inline uint8_t VXBaseDataSource::inputCurrent() const +{ + return m_currentInput; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief A memory-buffer based data source for the @c VXInstructionDecoder class. + */ +class VXMemoryDataSource : public VXBaseDataSource +{ +private: + const void *m_inputBuffer; + uint64_t m_inputBufferLen; + uint64_t m_inputBufferPos; +protected: + /** + * @brief Reads the next byte from the data source. This method increases the current + * input position by one. + * @return The current input byte. + */ + uint8_t internalInputPeek() override; + /** + * @brief Reads the next byte from the data source. This method does NOT increase the + * current input position. + * @return The current input byte. + */ + uint8_t internalInputNext() override; +public: + /** + * @brief Constructor. + * @param buffer The input buffer. + * @param bufferLen The length of the input buffer. + */ + VXMemoryDataSource(const void* buffer, size_t bufferLen) + : m_inputBuffer(buffer) + , m_inputBufferLen(bufferLen) + , m_inputBufferPos(0) { }; +public: + /** + * @brief Signals, if the end of the data source is reached. + * @return True if end of input, false if not. + */ + bool isEndOfInput() const override; + /** + * @brief Returns the current input position. + * @return The current input position. + */ + uint64_t getPosition() const override; + /** + * @brief Sets a new input position. + * @param position The new input position. + * @return Returns false, if the new position exceeds the maximum input length. + */ + bool setPosition(uint64_t position) override; +}; + +inline uint8_t VXMemoryDataSource::internalInputPeek() +{ + return *(static_cast(m_inputBuffer) + m_inputBufferPos); +} + +inline uint8_t VXMemoryDataSource::internalInputNext() +{ + ++m_inputBufferPos; + return *(static_cast(m_inputBuffer) + m_inputBufferPos - 1); +} + +inline bool VXMemoryDataSource::isEndOfInput() const +{ + return (m_inputBufferPos >= m_inputBufferLen); +} + +inline uint64_t VXMemoryDataSource::getPosition() const +{ + return m_inputBufferPos; +} + +inline bool VXMemoryDataSource::setPosition(uint64_t position) +{ + m_inputBufferPos = position; + return isEndOfInput(); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief A stream based data source for the @c VXInstructionDecoder class. + */ +class VXStreamDataSource : public VXBaseDataSource +{ +private: + std::istream *m_inputStream; +protected: + /** + * @brief Reads the next byte from the data source. This method increases the current + * input position by one. + * @return The current input byte. + */ + uint8_t internalInputPeek() override; + /** + * @brief Reads the next byte from the data source. This method does NOT increase the + * current input position. + * @return The current input byte. + */ + uint8_t internalInputNext() override; +public: + /** + * @brief Constructor. + * @param stream The input stream. + */ + explicit VXStreamDataSource(std::istream *stream) + : m_inputStream(stream) { }; +public: + /** + * @brief Signals, if the end of the data source is reached. + * @return True if end of input, false if not. + */ + bool isEndOfInput() const override; + /** + * @brief Returns the current input position. + * @return The current input position. + */ + uint64_t getPosition() const override; + /** + * @brief Sets a new input position. + * @param position The new input position. + * @return Returns false, if the new position exceeds the maximum input length. + */ + bool setPosition(uint64_t position) override; +}; + +inline uint8_t VXStreamDataSource::internalInputPeek() +{ + if (!m_inputStream) + { + return 0; + } + return m_inputStream->peek(); +} + +inline uint8_t VXStreamDataSource::internalInputNext() +{ + if (!m_inputStream) + { + return 0; + } + return m_inputStream->get(); +} + +inline bool VXStreamDataSource::isEndOfInput() const +{ + if (!m_inputStream) + { + return true; + } + // We use good() instead of eof() to make sure the decoding will fail, if an stream internal + // error occured. + return !m_inputStream->good(); +} + +inline uint64_t VXStreamDataSource::getPosition() const +{ + if (!m_inputStream) + { + return 0; + } + return m_inputStream->tellg(); +} + +inline bool VXStreamDataSource::setPosition(uint64_t position) +{ + if (!m_inputStream) + { + return false; + } + m_inputStream->seekg(position); + return isEndOfInput(); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief Values that represent a disassembler mode. + */ +enum class VXDisassemblerMode : uint8_t +{ + M16BIT, + M32BIT, + M64BIT +}; + +/** + * @brief Values that represent an instruction-set vendor. + */ +enum class VXInstructionSetVendor : uint8_t +{ + ANY, + INTEL, + AMD +}; + +/** + * @brief The @c VXInstructionDecoder class decodes x86/x86-64 assembly instructions from a + * given data source. + */ +class VXInstructionDecoder +{ +private: + enum class RegisterClass : uint8_t + { + GENERAL_PURPOSE, + MMX, + CONTROL, + DEBUG, + SEGMENT, + XMM + }; +private: + VXBaseDataSource *m_dataSource; + VXDisassemblerMode m_disassemblerMode; + VXInstructionSetVendor m_preferredVendor; + uint64_t m_instructionPointer; +private: + /** + * @brief Reads the next byte from the data source. This method does NOT increase the + * current input position or the @c length field of the @c info parameter. + * @param info The instruction info. + * @return The current input byte. If the result is zero, you should always check the + * @c flags field of the @c info parameter for error flags. + * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. + */ + uint8_t inputPeek(VXInstructionInfo &info); + /** + * @brief Reads the next byte from the data source. This method increases the current + * input position and the @c length field of the @info parameter. + * This method also appends the new byte to to @c data field of the @c info + * parameter. + * @param info The instruction info. + * @return The current input byte. If the result is zero, you should always check the + * @c flags field of the @c info parameter for error flags. + * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. + */ + uint8_t inputNext(VXInstructionInfo &info); + /** + * @brief Reads the next byte(s) from the data source. This method increases the current + * input position and the @c length field of the @info parameter. + * This method also appends the new byte(s) to to @c data field of the @c info + * parameter. + * @param info The instruction info. + * @return The current input data. If the result is zero, you should always check the + * @c flags field of the @c info parameter for error flags. + * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. + */ + template + T inputNext(VXInstructionInfo &info); + /** + * @brief Returns the current input byte. The current input byte is set everytime the + * @c inputPeek or @c inputNext method is called. + * @return The current input byte. + */ + uint8_t inputCurrent() const; +private: + /** + * @brief Decodes a register operand. + * @param info The instruction info. + * @param operand The @c VXOperandInfo struct that receives the decoded data. + * @param registerClass The register class to use. + * @param registerId The register id. + * @param operandSize The defined size of the operand. + * @return True if it succeeds, false if it fails. + */ + bool decodeRegisterOperand(VXInstructionInfo &info, VXOperandInfo &operand, + RegisterClass registerClass, uint8_t registerId, VXDefinedOperandSize operandSize) const; + /** + * @brief Decodes a register/memory operand. + * @param info The instruction info. + * @param operand The @c VXOperandInfo struct that receives the decoded data. + * @param registerClass The register class to use. + * @param operandSize The defined size of the operand. + * @return True if it succeeds, false if it fails. + */ + bool decodeRegisterMemoryOperand(VXInstructionInfo &info, VXOperandInfo &operand, + RegisterClass registerClass, VXDefinedOperandSize operandSize); + /** + * @brief Decodes an immediate operand. + * @param info The instruction info. + * @param operand The @c VXOperandInfo struct that receives the decoded data. + * @param operandSize The defined size of the operand. + * @return True if it succeeds, false if it fails. + */ + bool decodeImmediate(VXInstructionInfo &info, VXOperandInfo &operand, + VXDefinedOperandSize operandSize); + /** + * @brief Decodes a displacement operand. + * @param info The instruction info. + * @param operand The @c VXOperandInfo struct that receives the decoded data. + * @param size The size of the displacement data. + * @return True if it succeeds, false if it fails. + */ + bool decodeDisplacement(VXInstructionInfo &info, VXOperandInfo &operand, uint8_t size); +private: + /** + * @brief Decodes the modrm field of the instruction. This method reads an additional + * input byte. + * @param The @c VXInstructionInfo struct that receives the decoded data. + * @return True if it succeeds, false if it fails. + */ + bool decodeModrm(VXInstructionInfo &info); + /** + * @brief Decodes the sib field of the instruction. This method reads an additional + * input byte. + * @param info The @c VXInstructionInfo struct that receives the decoded data. + * @return True if it succeeds, false if it fails. + */ + bool decodeSIB(VXInstructionInfo &info); + /** + * @brief Decodes vex prefix of the instruction. This method takes the current input byte + * to determine the vex prefix type and reads one or two additional input bytes + * on demand. + * @param info The @c VXInstructionInfo struct that receives the decoded data. + * @return True if it succeeds, false if it fails. + */ + bool decodeVex(VXInstructionInfo &info); +private: + /** + * @brief Returns the effective operand size. + * @param info The instruction info. + * @param operandSize The defined operand size. + * @return The effective operand size. + */ + uint16_t getEffectiveOperandSize(const VXInstructionInfo &info, + VXDefinedOperandSize operandSize) const; + /** + * @brief Decodes all instruction operands. + * @param info The @c VXInstructionInfo struct that receives the decoded data. + * @return True if it succeeds, false if it fails. + */ + bool decodeOperands(VXInstructionInfo &info); + /** + * @brief Decodes the specified instruction operand. + * @param info The instruction info. + * @param operand The @c VXOperandInfo struct that receives the decoded data. + * @param operandType The defined type of the operand. + * @param operandSize The defined size of the operand. + * @return True if it succeeds, false if it fails. + */ + bool decodeOperand(VXInstructionInfo &info, VXOperandInfo &operand, + VXDefinedOperandType operandType, VXDefinedOperandSize operandSize); +private: + /** + * @brief Resolves the effective operand and address mode of the instruction. + * This method requires a non-null value in the @c instrDefinition field of the + * @c info struct. + * @param info The @c VXInstructionInfo struct that receives the effective operand and + * address mode. + */ + void resolveOperandAndAddressMode(VXInstructionInfo &info) const; + /** + * @brief Calculates the effective REX/VEX.w, r, x, b, l values. + * This method requires a non-null value in the @c instrDefinition field of the + * @c info struct. + * @param info The @c VXInstructionInfo struct that receives the effective operand and + * address mode. + */ + void calculateEffectiveRexVexValues(VXInstructionInfo &info) const; +private: + /** + * @brief Collects and decodes optional instruction prefixes. + * @param info The @c VXInstructionInfo struct that receives the decoded data. + * @return True if it succeeds, false if it fails. + */ + bool decodePrefixes(VXInstructionInfo &info); + /** + * @brief Collects and decodes the instruction opcodes using the opcode tree. + * @param info The @c VXInstructionInfo struct that receives the decoded data. + * @return True if it succeeds, false if it fails. + */ + bool decodeOpcode(VXInstructionInfo &info); +public: + /** + * @brief Default constructor. + */ + VXInstructionDecoder(); + /** + * @brief Constructor. + * @param input A reference to the input data source. + * @param disassemblerMode The disasasembler mode. + * @param preferredVendor The preferred instruction-set vendor. + * @param instructionPointer The initial instruction pointer. + */ + explicit VXInstructionDecoder(VXBaseDataSource *input, + VXDisassemblerMode disassemblerMode = VXDisassemblerMode::M32BIT, + VXInstructionSetVendor preferredVendor = VXInstructionSetVendor::ANY, + uint64_t instructionPointer = 0); +public: + /** + * @brief Decodes the next instruction from the input data source. + * @param info The @c VXInstructionInfo struct that receives the information about the + * decoded instruction. + * @return This method returns false, if the current position has exceeded the maximum input + * length. + * In all other cases (valid and invalid instructions) the return value is true. + */ + bool decodeInstruction(VXInstructionInfo &info); +public: + /** + * @brief Returns a pointer to the current data source. + * @return A pointer to the current data source. + */ + VXBaseDataSource* getDataSource() const; + /** + * @brief Sets a new data source. + * @param input A reference to the new input data source. + */ + void setDataSource(VXBaseDataSource *input); + /** + * @brief Returns the current disassembler mode. + * @return The current disassembler mode. + */ + VXDisassemblerMode getDisassemblerMode() const; + /** + * @brief Sets the current disassembler mode. + * @param disassemblerMode The new disassembler mode. + */ + void setDisassemblerMode(VXDisassemblerMode disassemblerMode); + /** + * @brief Returns the preferred instruction-set vendor. + * @return The preferred instruction-set vendor. + */ + VXInstructionSetVendor getPreferredVendor() const; + /** + * @brief Sets the preferred instruction-set vendor. + * @param preferredVendor The new preferred instruction-set vendor. + */ + void setPreferredVendor(VXInstructionSetVendor preferredVendor); + /** + * @brief Returns the current instruction pointer. + * @return The current instruction pointer. + */ + uint64_t getInstructionPointer() const; + /** + * @brief Sets a new instruction pointer. + * @param instructionPointer The new instruction pointer. + */ + void setInstructionPointer(uint64_t instructionPointer); +}; + +inline uint8_t VXInstructionDecoder::inputPeek(VXInstructionInfo &info) +{ + if (!m_dataSource) + { + info.flags |= IF_ERROR_END_OF_INPUT; + return 0; + } + return m_dataSource->inputPeek(info); +} + +inline uint8_t VXInstructionDecoder::inputNext(VXInstructionInfo &info) +{ + if (!m_dataSource) + { + info.flags |= IF_ERROR_END_OF_INPUT; + return 0; + } + return m_dataSource->inputNext(info); +} + +template +inline T VXInstructionDecoder::inputNext(VXInstructionInfo &info) +{ + if (!m_dataSource) + { + info.flags |= IF_ERROR_END_OF_INPUT; + return 0; + } + return m_dataSource->inputNext(info); +} + +inline uint8_t VXInstructionDecoder::inputCurrent() const +{ + if (!m_dataSource) + { + return 0; + } + return m_dataSource->inputCurrent(); +} + +inline VXBaseDataSource* VXInstructionDecoder::getDataSource() const +{ + return m_dataSource; +} + +inline void VXInstructionDecoder::setDataSource(VXBaseDataSource *input) +{ + m_dataSource = input; +} + +inline VXDisassemblerMode VXInstructionDecoder::getDisassemblerMode() const +{ + return m_disassemblerMode; +} + +inline void VXInstructionDecoder::setDisassemblerMode(VXDisassemblerMode disassemblerMode) +{ + m_disassemblerMode = disassemblerMode; +} + +inline VXInstructionSetVendor VXInstructionDecoder::getPreferredVendor() const +{ + return m_preferredVendor; +} + +inline void VXInstructionDecoder::setPreferredVendor(VXInstructionSetVendor preferredVendor) +{ + m_preferredVendor = preferredVendor; +} + +inline uint64_t VXInstructionDecoder::getInstructionPointer() const +{ + return m_instructionPointer; +} + +inline void VXInstructionDecoder::setInstructionPointer(uint64_t instructionPointer) +{ + m_instructionPointer = instructionPointer; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +} diff --git a/VerteronDisassemblerEngine/VXInstructionFormatter.cpp b/Bindings/Cpp/VXInstructionFormatter.cpp similarity index 99% rename from VerteronDisassemblerEngine/VXInstructionFormatter.cpp rename to Bindings/Cpp/VXInstructionFormatter.cpp index b8ac894..a5e0d7f 100644 --- a/VerteronDisassemblerEngine/VXInstructionFormatter.cpp +++ b/Bindings/Cpp/VXInstructionFormatter.cpp @@ -29,8 +29,8 @@ * SOFTWARE. **************************************************************************************************/ -#include "VXInstructionFormatter.h" -#include "VXDisassemblerUtils.h" +#include "VXInstructionFormatter.hpp" +#include "VXDisassemblerUtils.hpp" #include #include #include diff --git a/Bindings/Cpp/VXInstructionFormatter.hpp b/Bindings/Cpp/VXInstructionFormatter.hpp new file mode 100644 index 0000000..b63b263 --- /dev/null +++ b/Bindings/Cpp/VXInstructionFormatter.hpp @@ -0,0 +1,320 @@ +/************************************************************************************************** + + Verteron Disassembler Engine + Version 1.0 + + Remarks : Freeware, Copyright must be included + + Original Author : Florian Bernd + Modifications : + + Last change : 22. October 2014 + + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + +**************************************************************************************************/ +#pragma once + +#include +#include +#include +#include "VXDisassemblerTypes.hpp" + +namespace Verteron +{ + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief Base class for all symbol resolver implementations. + */ +class VXBaseSymbolResolver +{ +public: + /** + * @brief Destructor. + */ + virtual ~VXBaseSymbolResolver(); +public: + /** + * @brief Resolves a symbol. + * @param info The instruction info. + * @param address The address. + * @param offset Reference to an unsigned 64 bit integer that receives an offset + * relative to the base address of the symbol. + * @return The name of the symbol, if the symbol was found, @c NULL if not. + */ + virtual const char* resolveSymbol(const VXInstructionInfo &info, uint64_t address, + uint64_t &offset); +}; + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief Base class for all instruction formatter implementations. + */ +class VXBaseInstructionFormatter +{ +private: + static const char *m_registerStrings[]; + VXBaseSymbolResolver *m_symbolResolver; + std::vector m_outputBuffer; + size_t m_outputStringLen; + bool m_outputUppercase; +protected: + /** + * @brief Clears the output string buffer. + */ + void outputClear(); + /** + * @brief Returns the content of the output string buffer. + * @return Pointer to the content of the ouput string buffer. + */ + const char* outputString(); + /** + * @brief Appends text to the ouput string buffer. + * @param text The text. + */ + void outputAppend(const char *text); + /** + * @brief Appends formatted text to the output string buffer. + * @param format The format string. + */ + void outputAppendFormatted(const char *format, ...); + /** + * @brief Changes automatic conversion of characters to uppercase. + * @param uppercase Set true to enable automatic uppercase conversion. + */ + void outputSetUppercase(bool uppercase); + /** + * @brief Appends a formatted address to the output string buffer. + * @param info The instruction info. + * @param address The address. + * @param resolveSymbols If this parameter is true, the method will try to display a + * smybol name instead of the numeric value. + */ + void outputAppendAddress(const VXInstructionInfo &info, uint64_t address, + bool resolveSymbols = true); + /** + * @brief Appends a formatted immediate value to the output string buffer. + * @param info The instruction info. + * @param operand The immediate operand. + * @param resolveSymbols If this parameter is true, the method will try to display a + * smybol name instead of the numeric value. + */ + void outputAppendImmediate(const VXInstructionInfo &info, const VXOperandInfo &operand, + bool resolveSymbols = false); + /** + * @brief Appends a formatted memory displacement value to the output string buffer. + * @param info The instruction info. + * @param operand The memory operand. + */ + void outputAppendDisplacement(const VXInstructionInfo &info, const VXOperandInfo &operand); +protected: + /** + * @brief Returns the string representation of a given register. + * @param reg The register. + * @return The string representation of the given register. + */ + const char* registerToString(VXRegister reg) const; + /** + * @brief Resolves a symbol. + * @param info The instruction info. + * @param address The address. + * @param offset Reference to an unsigned 64 bit integer that receives an offset + * relative to the base address of the symbol. + * @return The name of the symbol, if the symbol was found, @c NULL if not. + */ + const char* resolveSymbol(const VXInstructionInfo &info, uint64_t address, + uint64_t &offset) const; +protected: + /** + * @brief Override this method to implement a custom disassembly syntax. Use the + * @c outputAppend and @c outputAppendFormatted methods to fill the internal + * string buffer. + * @param info The instruction info. + */ + virtual void internalFormatInstruction(const VXInstructionInfo &info); + /** + * @brief Default constructor. + */ + VXBaseInstructionFormatter(); + /** + * @brief Constructor. + * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol + * resolver should be used. + */ + explicit VXBaseInstructionFormatter(VXBaseSymbolResolver *symbolResolver); +public: + /** + * @brief Destructor. + */ + virtual ~VXBaseInstructionFormatter(); +public: + /** + * @brief Formats a decoded instruction. + * @param info The instruction info. + * @return Pointer to the formatted instruction string. + */ + const char* formatInstruction(const VXInstructionInfo &info); +public: + /** + * @brief Returns a pointer to the current symbol resolver. + * @return Pointer to the current symbol resolver or @c NULL, if no symbol resolver is used. + */ + VXBaseSymbolResolver* getSymbolResolver() const; + /** + * @brief Sets a new symbol resolver. + * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol + * resolver should be used. + */ + void setSymbolResolver(VXBaseSymbolResolver *symbolResolver); +}; + +inline void VXBaseInstructionFormatter::outputSetUppercase(bool uppercase) +{ + m_outputUppercase = uppercase; +} + +inline char const* VXBaseInstructionFormatter::registerToString(VXRegister reg) const +{ + if (reg == VXRegister::NONE) + { + return "error"; + } + return m_registerStrings[static_cast(reg) - 1]; +} + +inline char const* VXBaseInstructionFormatter::resolveSymbol(const VXInstructionInfo &info, + uint64_t address, uint64_t &offset) const +{ + if (m_symbolResolver) + { + return m_symbolResolver->resolveSymbol(info, address, offset); + } + return nullptr; +} + +inline VXBaseSymbolResolver* VXBaseInstructionFormatter::getSymbolResolver() const +{ + return m_symbolResolver; +} + +inline void VXBaseInstructionFormatter::setSymbolResolver(VXBaseSymbolResolver *symbolResolver) +{ + m_symbolResolver = symbolResolver; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief Intel syntax instruction formatter. + */ +class VXIntelInstructionFormatter : public VXBaseInstructionFormatter +{ +private: + /** + * @brief Appends an operand cast to the output string buffer. + * @param info The instruction info. + * @param operand The operand. + */ + void outputAppendOperandCast(const VXInstructionInfo &info, const VXOperandInfo &operand); + /** + * @brief Formats the specified operand and appends the resulting string to the output + * buffer. + * @param info The instruction info. + * @param operand The operand. + */ + void formatOperand(const VXInstructionInfo &info, const VXOperandInfo &operand); +protected: + /** + * @brief Fills the internal string buffer with an intel style formatted instruction string. + * @param info The instruction info. + */ + void internalFormatInstruction(const VXInstructionInfo &info) override; +public: + /** + * @brief Default constructor. + */ + VXIntelInstructionFormatter(); + /** + * @brief Constructor. + * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol + * resolver should be used. + */ + explicit VXIntelInstructionFormatter(VXBaseSymbolResolver *symbolResolver); + /** + * @brief Destructor. + */ + ~VXIntelInstructionFormatter() override; +}; + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * @brief Simple symbol resolver that only matches exact addresses. + */ +class VXExactSymbolResolver : public VXBaseSymbolResolver +{ +private: + std::unordered_map m_symbolMap; +public: + /** + * @brief Destructor. + */ + ~VXExactSymbolResolver() override; +public: + /** + * @brief Resolves a symbol. + * @param info The instruction info. + * @param address The address. + * @param offset Reference to an unsigned 64 bit integer that receives an offset + * relative to the base address of the symbol. + * @return The name of the symbol, if the symbol was found, @c NULL if not. + */ + const char* resolveSymbol(const VXInstructionInfo &info, uint64_t address, + uint64_t &offset) override; +public: + /** + * @brief Query if the given address is a known symbol. + * @param address The address. + * @return True if the address is known, false if not. + */ + bool containsSymbol(uint64_t address) const; + /** + * @brief Adds or changes a symbol. + * @param address The address. + * @param name The symbol name. + */ + void setSymbol(uint64_t address, const char* name); + /** + * @brief Removes the symbol described by address. This will invalidate all char pointers + * to the specific symbol name. + * @param address The address. + */ + void removeSymbol(uint64_t address); + /** + * @brief Clears the symbol tree. + */ + void clear(); +}; + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +} diff --git a/VerteronDisassemblerEngine/VXOpcodeTable.cpp b/Bindings/Cpp/VXOpcodeTable.cpp similarity index 99% rename from VerteronDisassemblerEngine/VXOpcodeTable.cpp rename to Bindings/Cpp/VXOpcodeTable.cpp index 72438f2..5b6b5e8 100644 --- a/VerteronDisassemblerEngine/VXOpcodeTable.cpp +++ b/Bindings/Cpp/VXOpcodeTable.cpp @@ -29,7 +29,7 @@ * SOFTWARE. **************************************************************************************************/ -#include "VXOpcodeTable.h" +#include "VXOpcodeTable.hpp" namespace Verteron { diff --git a/Bindings/Cpp/VXOpcodeTable.hpp b/Bindings/Cpp/VXOpcodeTable.hpp new file mode 100644 index 0000000..bf13060 --- /dev/null +++ b/Bindings/Cpp/VXOpcodeTable.hpp @@ -0,0 +1,1753 @@ +/************************************************************************************************** + + Verteron Disassembler Engine + Version 1.0 + + Remarks : Freeware, Copyright must be included + + Original Author : Florian Bernd + Modifications : + + Last change : 29. October 2014 + + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + +**************************************************************************************************/ +#pragma once + +#include +#include + +namespace Verteron +{ + +/** + * @brief Values that represent an instruction mnemonic. + */ +enum class VXInstructionMnemonic : uint16_t +{ + /* 000 */ INVALID, + /* 001 */ AAA, + /* 002 */ AAD, + /* 003 */ AAM, + /* 004 */ AAS, + /* 005 */ ADC, + /* 006 */ ADD, + /* 007 */ ADDPD, + /* 008 */ ADDPS, + /* 009 */ ADDSD, + /* 00A */ ADDSS, + /* 00B */ ADDSUBPD, + /* 00C */ ADDSUBPS, + /* 00D */ AESDEC, + /* 00E */ AESDECLAST, + /* 00F */ AESENC, + /* 010 */ AESENCLAST, + /* 011 */ AESIMC, + /* 012 */ AESKEYGENASSIST, + /* 013 */ AND, + /* 014 */ ANDNPD, + /* 015 */ ANDNPS, + /* 016 */ ANDPD, + /* 017 */ ANDPS, + /* 018 */ ARPL, + /* 019 */ BLENDPD, + /* 01A */ BLENDPS, + /* 01B */ BLENDVPD, + /* 01C */ BLENDVPS, + /* 01D */ BOUND, + /* 01E */ BSF, + /* 01F */ BSR, + /* 020 */ BSWAP, + /* 021 */ BT, + /* 022 */ BTC, + /* 023 */ BTR, + /* 024 */ BTS, + /* 025 */ CALL, + /* 026 */ CBW, + /* 027 */ CDQ, + /* 028 */ CDQE, + /* 029 */ CLC, + /* 02A */ CLD, + /* 02B */ CLFLUSH, + /* 02C */ CLGI, + /* 02D */ CLI, + /* 02E */ CLTS, + /* 02F */ CMC, + /* 030 */ CMOVA, + /* 031 */ CMOVAE, + /* 032 */ CMOVB, + /* 033 */ CMOVBE, + /* 034 */ CMOVE, + /* 035 */ CMOVG, + /* 036 */ CMOVGE, + /* 037 */ CMOVL, + /* 038 */ CMOVLE, + /* 039 */ CMOVNE, + /* 03A */ CMOVNO, + /* 03B */ CMOVNP, + /* 03C */ CMOVNS, + /* 03D */ CMOVO, + /* 03E */ CMOVP, + /* 03F */ CMOVS, + /* 040 */ CMP, + /* 041 */ CMPPD, + /* 042 */ CMPPS, + /* 043 */ CMPSB, + /* 044 */ CMPSD, + /* 045 */ CMPSQ, + /* 046 */ CMPSS, + /* 047 */ CMPSW, + /* 048 */ CMPXCHG, + /* 049 */ CMPXCHG16B, + /* 04A */ CMPXCHG8B, + /* 04B */ COMISD, + /* 04C */ COMISS, + /* 04D */ CPUID, + /* 04E */ CQO, + /* 04F */ CRC32, + /* 050 */ CVTDQ2PD, + /* 051 */ CVTDQ2PS, + /* 052 */ CVTPD2DQ, + /* 053 */ CVTPD2PI, + /* 054 */ CVTPD2PS, + /* 055 */ CVTPI2PD, + /* 056 */ CVTPI2PS, + /* 057 */ CVTPS2DQ, + /* 058 */ CVTPS2PD, + /* 059 */ CVTPS2PI, + /* 05A */ CVTSD2SI, + /* 05B */ CVTSD2SS, + /* 05C */ CVTSI2SD, + /* 05D */ CVTSI2SS, + /* 05E */ CVTSS2SD, + /* 05F */ CVTSS2SI, + /* 060 */ CVTTPD2DQ, + /* 061 */ CVTTPD2PI, + /* 062 */ CVTTPS2DQ, + /* 063 */ CVTTPS2PI, + /* 064 */ CVTTSD2SI, + /* 065 */ CVTTSS2SI, + /* 066 */ CWD, + /* 067 */ CWDE, + /* 068 */ DAA, + /* 069 */ DAS, + /* 06A */ DEC, + /* 06B */ DIV, + /* 06C */ DIVPD, + /* 06D */ DIVPS, + /* 06E */ DIVSD, + /* 06F */ DIVSS, + /* 070 */ DPPD, + /* 071 */ DPPS, + /* 072 */ EMMS, + /* 073 */ ENTER, + /* 074 */ EXTRACTPS, + /* 075 */ F2XM1, + /* 076 */ FABS, + /* 077 */ FADD, + /* 078 */ FADDP, + /* 079 */ FBLD, + /* 07A */ FBSTP, + /* 07B */ FCHS, + /* 07C */ FCLEX, + /* 07D */ FCMOVB, + /* 07E */ FCMOVBE, + /* 07F */ FCMOVE, + /* 080 */ FCMOVNB, + /* 081 */ FCMOVNBE, + /* 082 */ FCMOVNE, + /* 083 */ FCMOVNU, + /* 084 */ FCMOVU, + /* 085 */ FCOM, + /* 086 */ FCOM2, + /* 087 */ FCOMI, + /* 088 */ FCOMIP, + /* 089 */ FCOMP, + /* 08A */ FCOMP3, + /* 08B */ FCOMP5, + /* 08C */ FCOMPP, + /* 08D */ FCOS, + /* 08E */ FDECSTP, + /* 08F */ FDIV, + /* 090 */ FDIVP, + /* 091 */ FDIVR, + /* 092 */ FDIVRP, + /* 093 */ FEMMS, + /* 094 */ FFREE, + /* 095 */ FFREEP, + /* 096 */ FIADD, + /* 097 */ FICOM, + /* 098 */ FICOMP, + /* 099 */ FIDIV, + /* 09A */ FIDIVR, + /* 09B */ FILD, + /* 09C */ FIMUL, + /* 09D */ FINCSTP, + /* 09E */ FIST, + /* 09F */ FISTP, + /* 0A0 */ FISTTP, + /* 0A1 */ FISUB, + /* 0A2 */ FISUBR, + /* 0A3 */ FLD, + /* 0A4 */ FLD1, + /* 0A5 */ FLDCW, + /* 0A6 */ FLDENV, + /* 0A7 */ FLDL2E, + /* 0A8 */ FLDL2T, + /* 0A9 */ FLDLG2, + /* 0AA */ FLDLN2, + /* 0AB */ FLDPI, + /* 0AC */ FLDZ, + /* 0AD */ FMUL, + /* 0AE */ FMULP, + /* 0AF */ FNDISI, + /* 0B0 */ FNENI, + /* 0B1 */ FNINIT, + /* 0B2 */ FNOP, + /* 0B3 */ FNSAVE, + /* 0B4 */ FNSETPM, + /* 0B5 */ FNSTCW, + /* 0B6 */ FNSTENV, + /* 0B7 */ FNSTSW, + /* 0B8 */ FPATAN, + /* 0B9 */ FPREM, + /* 0BA */ FPREM1, + /* 0BB */ FPTAN, + /* 0BC */ FRNDINT, + /* 0BD */ FRSTOR, + /* 0BE */ FRSTPM, + /* 0BF */ FSCALE, + /* 0C0 */ FSIN, + /* 0C1 */ FSINCOS, + /* 0C2 */ FSQRT, + /* 0C3 */ FST, + /* 0C4 */ FSTP, + /* 0C5 */ FSTP1, + /* 0C6 */ FSTP8, + /* 0C7 */ FSTP9, + /* 0C8 */ FSUB, + /* 0C9 */ FSUBP, + /* 0CA */ FSUBR, + /* 0CB */ FSUBRP, + /* 0CC */ FTST, + /* 0CD */ FUCOM, + /* 0CE */ FUCOMI, + /* 0CF */ FUCOMIP, + /* 0D0 */ FUCOMP, + /* 0D1 */ FUCOMPP, + /* 0D2 */ FXAM, + /* 0D3 */ FXCH, + /* 0D4 */ FXCH4, + /* 0D5 */ FXCH7, + /* 0D6 */ FXRSTOR, + /* 0D7 */ FXSAVE, + /* 0D8 */ FXTRACT, + /* 0D9 */ FYL2X, + /* 0DA */ FYL2XP1, + /* 0DB */ GETSEC, + /* 0DC */ HADDPD, + /* 0DD */ HADDPS, + /* 0DE */ HLT, + /* 0DF */ HSUBPD, + /* 0E0 */ HSUBPS, + /* 0E1 */ IDIV, + /* 0E2 */ IMUL, + /* 0E3 */ IN, + /* 0E4 */ INC, + /* 0E5 */ INSB, + /* 0E6 */ INSD, + /* 0E7 */ INSERTPS, + /* 0E8 */ INSW, + /* 0E9 */ INT, + /* 0EA */ INT1, + /* 0EB */ INT3, + /* 0EC */ INTO, + /* 0ED */ INVD, + /* 0EE */ INVEPT, + /* 0EF */ INVLPG, + /* 0F0 */ INVLPGA, + /* 0F1 */ INVVPID, + /* 0F2 */ IRETD, + /* 0F3 */ IRETQ, + /* 0F4 */ IRETW, + /* 0F5 */ JA, + /* 0F6 */ JB, + /* 0F7 */ JBE, + /* 0F8 */ JCXZ, + /* 0F9 */ JE, + /* 0FA */ JECXZ, + /* 0FB */ JG, + /* 0FC */ JGE, + /* 0FD */ JL, + /* 0FE */ JLE, + /* 0FF */ JMP, + /* 100 */ JNB, + /* 101 */ JNE, + /* 102 */ JNO, + /* 103 */ JNP, + /* 104 */ JNS, + /* 105 */ JO, + /* 106 */ JP, + /* 107 */ JRCXZ, + /* 108 */ JS, + /* 109 */ LAHF, + /* 10A */ LAR, + /* 10B */ LDDQU, + /* 10C */ LDMXCSR, + /* 10D */ LDS, + /* 10E */ LEA, + /* 10F */ LEAVE, + /* 110 */ LES, + /* 111 */ LFENCE, + /* 112 */ LFS, + /* 113 */ LGDT, + /* 114 */ LGS, + /* 115 */ LIDT, + /* 116 */ LLDT, + /* 117 */ LMSW, + /* 118 */ LOCK, + /* 119 */ LODSB, + /* 11A */ LODSD, + /* 11B */ LODSQ, + /* 11C */ LODSW, + /* 11D */ LOOP, + /* 11E */ LOOPE, + /* 11F */ LOOPNE, + /* 120 */ LSL, + /* 121 */ LSS, + /* 122 */ LTR, + /* 123 */ MASKMOVDQU, + /* 124 */ MASKMOVQ, + /* 125 */ MAXPD, + /* 126 */ MAXPS, + /* 127 */ MAXSD, + /* 128 */ MAXSS, + /* 129 */ MFENCE, + /* 12A */ MINPD, + /* 12B */ MINPS, + /* 12C */ MINSD, + /* 12D */ MINSS, + /* 12E */ MONITOR, + /* 12F */ MONTMUL, + /* 130 */ MOV, + /* 131 */ MOVAPD, + /* 132 */ MOVAPS, + /* 133 */ MOVBE, + /* 134 */ MOVD, + /* 135 */ MOVDDUP, + /* 136 */ MOVDQ2Q, + /* 137 */ MOVDQA, + /* 138 */ MOVDQU, + /* 139 */ MOVHLPS, + /* 13A */ MOVHPD, + /* 13B */ MOVHPS, + /* 13C */ MOVLHPS, + /* 13D */ MOVLPD, + /* 13E */ MOVLPS, + /* 13F */ MOVMSKPD, + /* 140 */ MOVMSKPS, + /* 141 */ MOVNTDQ, + /* 142 */ MOVNTDQA, + /* 143 */ MOVNTI, + /* 144 */ MOVNTPD, + /* 145 */ MOVNTPS, + /* 146 */ MOVNTQ, + /* 147 */ MOVQ, + /* 148 */ MOVQ2DQ, + /* 149 */ MOVSB, + /* 14A */ MOVSD, + /* 14B */ MOVSHDUP, + /* 14C */ MOVSLDUP, + /* 14D */ MOVSQ, + /* 14E */ MOVSS, + /* 14F */ MOVSW, + /* 150 */ MOVSX, + /* 151 */ MOVSXD, + /* 152 */ MOVUPD, + /* 153 */ MOVUPS, + /* 154 */ MOVZX, + /* 155 */ MPSADBW, + /* 156 */ MUL, + /* 157 */ MULPD, + /* 158 */ MULPS, + /* 159 */ MULSD, + /* 15A */ MULSS, + /* 15B */ MWAIT, + /* 15C */ NEG, + /* 15D */ NOP, + /* 15E */ NOT, + /* 15F */ OR, + /* 160 */ ORPD, + /* 161 */ ORPS, + /* 162 */ OUT, + /* 163 */ OUTSB, + /* 164 */ OUTSD, + /* 165 */ OUTSW, + /* 166 */ PABSB, + /* 167 */ PABSD, + /* 168 */ PABSW, + /* 169 */ PACKSSDW, + /* 16A */ PACKSSWB, + /* 16B */ PACKUSDW, + /* 16C */ PACKUSWB, + /* 16D */ PADDB, + /* 16E */ PADDD, + /* 16F */ PADDQ, + /* 170 */ PADDSB, + /* 171 */ PADDSW, + /* 172 */ PADDUSB, + /* 173 */ PADDUSW, + /* 174 */ PADDW, + /* 175 */ PALIGNR, + /* 176 */ PAND, + /* 177 */ PANDN, + /* 178 */ PAUSE, + /* 179 */ PAVGB, + /* 17A */ PAVGUSB, + /* 17B */ PAVGW, + /* 17C */ PBLENDVB, + /* 17D */ PBLENDW, + /* 17E */ PCLMULQDQ, + /* 17F */ PCMPEQB, + /* 180 */ PCMPEQD, + /* 181 */ PCMPEQQ, + /* 182 */ PCMPEQW, + /* 183 */ PCMPESTRI, + /* 184 */ PCMPESTRM, + /* 185 */ PCMPGTB, + /* 186 */ PCMPGTD, + /* 187 */ PCMPGTQ, + /* 188 */ PCMPGTW, + /* 189 */ PCMPISTRI, + /* 18A */ PCMPISTRM, + /* 18B */ PEXTRB, + /* 18C */ PEXTRD, + /* 18D */ PEXTRQ, + /* 18E */ PEXTRW, + /* 18F */ PF2ID, + /* 190 */ PF2IW, + /* 191 */ PFACC, + /* 192 */ PFADD, + /* 193 */ PFCMPEQ, + /* 194 */ PFCMPGE, + /* 195 */ PFCMPGT, + /* 196 */ PFMAX, + /* 197 */ PFMIN, + /* 198 */ PFMUL, + /* 199 */ PFNACC, + /* 19A */ PFPNACC, + /* 19B */ PFRCP, + /* 19C */ PFRCPIT1, + /* 19D */ PFRCPIT2, + /* 19E */ PFRSQIT1, + /* 19F */ PFRSQRT, + /* 1A0 */ PFSUB, + /* 1A1 */ PFSUBR, + /* 1A2 */ PHADDD, + /* 1A3 */ PHADDSW, + /* 1A4 */ PHADDW, + /* 1A5 */ PHMINPOSUW, + /* 1A6 */ PHSUBD, + /* 1A7 */ PHSUBSW, + /* 1A8 */ PHSUBW, + /* 1A9 */ PI2FD, + /* 1AA */ PI2FW, + /* 1AB */ PINSRB, + /* 1AC */ PINSRD, + /* 1AD */ PINSRQ, + /* 1AE */ PINSRW, + /* 1AF */ PMADDUBSW, + /* 1B0 */ PMADDWD, + /* 1B1 */ PMAXSB, + /* 1B2 */ PMAXSD, + /* 1B3 */ PMAXSW, + /* 1B4 */ PMAXUB, + /* 1B5 */ PMAXUD, + /* 1B6 */ PMAXUW, + /* 1B7 */ PMINSB, + /* 1B8 */ PMINSD, + /* 1B9 */ PMINSW, + /* 1BA */ PMINUB, + /* 1BB */ PMINUD, + /* 1BC */ PMINUW, + /* 1BD */ PMOVMSKB, + /* 1BE */ PMOVSXBD, + /* 1BF */ PMOVSXBQ, + /* 1C0 */ PMOVSXBW, + /* 1C1 */ PMOVSXDQ, + /* 1C2 */ PMOVSXWD, + /* 1C3 */ PMOVSXWQ, + /* 1C4 */ PMOVZXBD, + /* 1C5 */ PMOVZXBQ, + /* 1C6 */ PMOVZXBW, + /* 1C7 */ PMOVZXDQ, + /* 1C8 */ PMOVZXWD, + /* 1C9 */ PMOVZXWQ, + /* 1CA */ PMULDQ, + /* 1CB */ PMULHRSW, + /* 1CC */ PMULHRW, + /* 1CD */ PMULHUW, + /* 1CE */ PMULHW, + /* 1CF */ PMULLD, + /* 1D0 */ PMULLW, + /* 1D1 */ PMULUDQ, + /* 1D2 */ POP, + /* 1D3 */ POPA, + /* 1D4 */ POPAD, + /* 1D5 */ POPCNT, + /* 1D6 */ POPFD, + /* 1D7 */ POPFQ, + /* 1D8 */ POPFW, + /* 1D9 */ POR, + /* 1DA */ PREFETCH, + /* 1DB */ PREFETCHNTA, + /* 1DC */ PREFETCHT0, + /* 1DD */ PREFETCHT1, + /* 1DE */ PREFETCHT2, + /* 1DF */ PSADBW, + /* 1E0 */ PSHUFB, + /* 1E1 */ PSHUFD, + /* 1E2 */ PSHUFHW, + /* 1E3 */ PSHUFLW, + /* 1E4 */ PSHUFW, + /* 1E5 */ PSIGNB, + /* 1E6 */ PSIGND, + /* 1E7 */ PSIGNW, + /* 1E8 */ PSLLD, + /* 1E9 */ PSLLDQ, + /* 1EA */ PSLLQ, + /* 1EB */ PSLLW, + /* 1EC */ PSRAD, + /* 1ED */ PSRAW, + /* 1EE */ PSRLD, + /* 1EF */ PSRLDQ, + /* 1F0 */ PSRLQ, + /* 1F1 */ PSRLW, + /* 1F2 */ PSUBB, + /* 1F3 */ PSUBD, + /* 1F4 */ PSUBQ, + /* 1F5 */ PSUBSB, + /* 1F6 */ PSUBSW, + /* 1F7 */ PSUBUSB, + /* 1F8 */ PSUBUSW, + /* 1F9 */ PSUBW, + /* 1FA */ PSWAPD, + /* 1FB */ PTEST, + /* 1FC */ PUNPCKHBW, + /* 1FD */ PUNPCKHDQ, + /* 1FE */ PUNPCKHQDQ, + /* 1FF */ PUNPCKHWD, + /* 200 */ PUNPCKLBW, + /* 201 */ PUNPCKLDQ, + /* 202 */ PUNPCKLQDQ, + /* 203 */ PUNPCKLWD, + /* 204 */ PUSH, + /* 205 */ PUSHA, + /* 206 */ PUSHAD, + /* 207 */ PUSHFD, + /* 208 */ PUSHFQ, + /* 209 */ PUSHFW, + /* 20A */ PXOR, + /* 20B */ RCL, + /* 20C */ RCPPS, + /* 20D */ RCPSS, + /* 20E */ RCR, + /* 20F */ RDMSR, + /* 210 */ RDPMC, + /* 211 */ RDRAND, + /* 212 */ RDTSC, + /* 213 */ RDTSCP, + /* 214 */ REP, + /* 215 */ REPNE, + /* 216 */ RET, + /* 217 */ RETF, + /* 218 */ ROL, + /* 219 */ ROR, + /* 21A */ ROUNDPD, + /* 21B */ ROUNDPS, + /* 21C */ ROUNDSD, + /* 21D */ ROUNDSS, + /* 21E */ RSM, + /* 21F */ RSQRTPS, + /* 220 */ RSQRTSS, + /* 221 */ SAHF, + /* 222 */ SALC, + /* 223 */ SAR, + /* 224 */ SBB, + /* 225 */ SCASB, + /* 226 */ SCASD, + /* 227 */ SCASQ, + /* 228 */ SCASW, + /* 229 */ SETA, + /* 22A */ SETAE, + /* 22B */ SETB, + /* 22C */ SETBE, + /* 22D */ SETE, + /* 22E */ SETG, + /* 22F */ SETGE, + /* 230 */ SETL, + /* 231 */ SETLE, + /* 232 */ SETNE, + /* 233 */ SETNO, + /* 234 */ SETNP, + /* 235 */ SETNS, + /* 236 */ SETO, + /* 237 */ SETP, + /* 238 */ SETS, + /* 239 */ SFENCE, + /* 23A */ SGDT, + /* 23B */ SHL, + /* 23C */ SHLD, + /* 23D */ SHR, + /* 23E */ SHRD, + /* 23F */ SHUFPD, + /* 240 */ SHUFPS, + /* 241 */ SIDT, + /* 242 */ SKINIT, + /* 243 */ SLDT, + /* 244 */ SMSW, + /* 245 */ SQRTPD, + /* 246 */ SQRTPS, + /* 247 */ SQRTSD, + /* 248 */ SQRTSS, + /* 249 */ STC, + /* 24A */ STD, + /* 24B */ STGI, + /* 24C */ STI, + /* 24D */ STMXCSR, + /* 24E */ STOSB, + /* 24F */ STOSD, + /* 250 */ STOSQ, + /* 251 */ STOSW, + /* 252 */ STR, + /* 253 */ SUB, + /* 254 */ SUBPD, + /* 255 */ SUBPS, + /* 256 */ SUBSD, + /* 257 */ SUBSS, + /* 258 */ SWAPGS, + /* 259 */ SYSCALL, + /* 25A */ SYSENTER, + /* 25B */ SYSEXIT, + /* 25C */ SYSRET, + /* 25D */ TEST, + /* 25E */ UCOMISD, + /* 25F */ UCOMISS, + /* 260 */ UD2, + /* 261 */ UNPCKHPD, + /* 262 */ UNPCKHPS, + /* 263 */ UNPCKLPD, + /* 264 */ UNPCKLPS, + /* 265 */ VADDPD, + /* 266 */ VADDPS, + /* 267 */ VADDSD, + /* 268 */ VADDSS, + /* 269 */ VADDSUBPD, + /* 26A */ VADDSUBPS, + /* 26B */ VAESDEC, + /* 26C */ VAESDECLAST, + /* 26D */ VAESENC, + /* 26E */ VAESENCLAST, + /* 26F */ VAESIMC, + /* 270 */ VAESKEYGENASSIST, + /* 271 */ VANDNPD, + /* 272 */ VANDNPS, + /* 273 */ VANDPD, + /* 274 */ VANDPS, + /* 275 */ VBLENDPD, + /* 276 */ VBLENDPS, + /* 277 */ VBLENDVPD, + /* 278 */ VBLENDVPS, + /* 279 */ VBROADCASTSD, + /* 27A */ VBROADCASTSS, + /* 27B */ VCMPPD, + /* 27C */ VCMPPS, + /* 27D */ VCMPSD, + /* 27E */ VCMPSS, + /* 27F */ VCOMISD, + /* 280 */ VCOMISS, + /* 281 */ VCVTDQ2PD, + /* 282 */ VCVTDQ2PS, + /* 283 */ VCVTPD2DQ, + /* 284 */ VCVTPD2PS, + /* 285 */ VCVTPS2DQ, + /* 286 */ VCVTPS2PD, + /* 287 */ VCVTSD2SI, + /* 288 */ VCVTSD2SS, + /* 289 */ VCVTSI2SD, + /* 28A */ VCVTSI2SS, + /* 28B */ VCVTSS2SD, + /* 28C */ VCVTSS2SI, + /* 28D */ VCVTTPD2DQ, + /* 28E */ VCVTTPS2DQ, + /* 28F */ VCVTTSD2SI, + /* 290 */ VCVTTSS2SI, + /* 291 */ VDIVPD, + /* 292 */ VDIVPS, + /* 293 */ VDIVSD, + /* 294 */ VDIVSS, + /* 295 */ VDPPD, + /* 296 */ VDPPS, + /* 297 */ VERR, + /* 298 */ VERW, + /* 299 */ VEXTRACTF128, + /* 29A */ VEXTRACTPS, + /* 29B */ VHADDPD, + /* 29C */ VHADDPS, + /* 29D */ VHSUBPD, + /* 29E */ VHSUBPS, + /* 29F */ VINSERTF128, + /* 2A0 */ VINSERTPS, + /* 2A1 */ VLDDQU, + /* 2A2 */ VMASKMOVDQU, + /* 2A3 */ VMASKMOVPD, + /* 2A4 */ VMASKMOVPS, + /* 2A5 */ VMAXPD, + /* 2A6 */ VMAXPS, + /* 2A7 */ VMAXSD, + /* 2A8 */ VMAXSS, + /* 2A9 */ VMCALL, + /* 2AA */ VMCLEAR, + /* 2AB */ VMINPD, + /* 2AC */ VMINPS, + /* 2AD */ VMINSD, + /* 2AE */ VMINSS, + /* 2AF */ VMLAUNCH, + /* 2B0 */ VMLOAD, + /* 2B1 */ VMMCALL, + /* 2B2 */ VMOVAPD, + /* 2B3 */ VMOVAPS, + /* 2B4 */ VMOVD, + /* 2B5 */ VMOVDDUP, + /* 2B6 */ VMOVDQA, + /* 2B7 */ VMOVDQU, + /* 2B8 */ VMOVHLPS, + /* 2B9 */ VMOVHPD, + /* 2BA */ VMOVHPS, + /* 2BB */ VMOVLHPS, + /* 2BC */ VMOVLPD, + /* 2BD */ VMOVLPS, + /* 2BE */ VMOVMSKPD, + /* 2BF */ VMOVMSKPS, + /* 2C0 */ VMOVNTDQ, + /* 2C1 */ VMOVNTDQA, + /* 2C2 */ VMOVNTPD, + /* 2C3 */ VMOVNTPS, + /* 2C4 */ VMOVQ, + /* 2C5 */ VMOVSD, + /* 2C6 */ VMOVSHDUP, + /* 2C7 */ VMOVSLDUP, + /* 2C8 */ VMOVSS, + /* 2C9 */ VMOVUPD, + /* 2CA */ VMOVUPS, + /* 2CB */ VMPSADBW, + /* 2CC */ VMPTRLD, + /* 2CD */ VMPTRST, + /* 2CE */ VMREAD, + /* 2CF */ VMRESUME, + /* 2D0 */ VMRUN, + /* 2D1 */ VMSAVE, + /* 2D2 */ VMULPD, + /* 2D3 */ VMULPS, + /* 2D4 */ VMULSD, + /* 2D5 */ VMULSS, + /* 2D6 */ VMWRITE, + /* 2D7 */ VMXOFF, + /* 2D8 */ VMXON, + /* 2D9 */ VORPD, + /* 2DA */ VORPS, + /* 2DB */ VPABSB, + /* 2DC */ VPABSD, + /* 2DD */ VPABSW, + /* 2DE */ VPACKSSDW, + /* 2DF */ VPACKSSWB, + /* 2E0 */ VPACKUSDW, + /* 2E1 */ VPACKUSWB, + /* 2E2 */ VPADDB, + /* 2E3 */ VPADDD, + /* 2E4 */ VPADDQ, + /* 2E5 */ VPADDSB, + /* 2E6 */ VPADDSW, + /* 2E7 */ VPADDUSB, + /* 2E8 */ VPADDUSW, + /* 2E9 */ VPADDW, + /* 2EA */ VPALIGNR, + /* 2EB */ VPAND, + /* 2EC */ VPANDN, + /* 2ED */ VPAVGB, + /* 2EE */ VPAVGW, + /* 2EF */ VPBLENDVB, + /* 2F0 */ VPBLENDW, + /* 2F1 */ VPCLMULQDQ, + /* 2F2 */ VPCMPEQB, + /* 2F3 */ VPCMPEQD, + /* 2F4 */ VPCMPEQQ, + /* 2F5 */ VPCMPEQW, + /* 2F6 */ VPCMPESTRI, + /* 2F7 */ VPCMPESTRM, + /* 2F8 */ VPCMPGTB, + /* 2F9 */ VPCMPGTD, + /* 2FA */ VPCMPGTQ, + /* 2FB */ VPCMPGTW, + /* 2FC */ VPCMPISTRI, + /* 2FD */ VPCMPISTRM, + /* 2FE */ VPERM2F128, + /* 2FF */ VPERMILPD, + /* 300 */ VPERMILPS, + /* 301 */ VPEXTRB, + /* 302 */ VPEXTRD, + /* 303 */ VPEXTRQ, + /* 304 */ VPEXTRW, + /* 305 */ VPHADDD, + /* 306 */ VPHADDSW, + /* 307 */ VPHADDW, + /* 308 */ VPHMINPOSUW, + /* 309 */ VPHSUBD, + /* 30A */ VPHSUBSW, + /* 30B */ VPHSUBW, + /* 30C */ VPINSRB, + /* 30D */ VPINSRD, + /* 30E */ VPINSRQ, + /* 30F */ VPINSRW, + /* 310 */ VPMADDUBSW, + /* 311 */ VPMADDWD, + /* 312 */ VPMAXSB, + /* 313 */ VPMAXSD, + /* 314 */ VPMAXSW, + /* 315 */ VPMAXUB, + /* 316 */ VPMAXUD, + /* 317 */ VPMAXUW, + /* 318 */ VPMINSB, + /* 319 */ VPMINSD, + /* 31A */ VPMINSW, + /* 31B */ VPMINUB, + /* 31C */ VPMINUD, + /* 31D */ VPMINUW, + /* 31E */ VPMOVMSKB, + /* 31F */ VPMOVSXBD, + /* 320 */ VPMOVSXBQ, + /* 321 */ VPMOVSXBW, + /* 322 */ VPMOVSXWD, + /* 323 */ VPMOVSXWQ, + /* 324 */ VPMOVZXBD, + /* 325 */ VPMOVZXBQ, + /* 326 */ VPMOVZXBW, + /* 327 */ VPMOVZXDQ, + /* 328 */ VPMOVZXWD, + /* 329 */ VPMOVZXWQ, + /* 32A */ VPMULDQ, + /* 32B */ VPMULHRSW, + /* 32C */ VPMULHUW, + /* 32D */ VPMULHW, + /* 32E */ VPMULLD, + /* 32F */ VPMULLW, + /* 330 */ VPOR, + /* 331 */ VPSADBW, + /* 332 */ VPSHUFB, + /* 333 */ VPSHUFD, + /* 334 */ VPSHUFHW, + /* 335 */ VPSHUFLW, + /* 336 */ VPSIGNB, + /* 337 */ VPSIGND, + /* 338 */ VPSIGNW, + /* 339 */ VPSLLD, + /* 33A */ VPSLLDQ, + /* 33B */ VPSLLQ, + /* 33C */ VPSLLW, + /* 33D */ VPSRAD, + /* 33E */ VPSRAW, + /* 33F */ VPSRLD, + /* 340 */ VPSRLDQ, + /* 341 */ VPSRLQ, + /* 342 */ VPSRLW, + /* 343 */ VPSUBB, + /* 344 */ VPSUBD, + /* 345 */ VPSUBQ, + /* 346 */ VPSUBSB, + /* 347 */ VPSUBSW, + /* 348 */ VPSUBUSB, + /* 349 */ VPSUBUSW, + /* 34A */ VPSUBW, + /* 34B */ VPTEST, + /* 34C */ VPUNPCKHBW, + /* 34D */ VPUNPCKHDQ, + /* 34E */ VPUNPCKHQDQ, + /* 34F */ VPUNPCKHWD, + /* 350 */ VPUNPCKLBW, + /* 351 */ VPUNPCKLDQ, + /* 352 */ VPUNPCKLQDQ, + /* 353 */ VPUNPCKLWD, + /* 354 */ VPXOR, + /* 355 */ VRCPPS, + /* 356 */ VRCPSS, + /* 357 */ VROUNDPD, + /* 358 */ VROUNDPS, + /* 359 */ VROUNDSD, + /* 35A */ VROUNDSS, + /* 35B */ VRSQRTPS, + /* 35C */ VRSQRTSS, + /* 35D */ VSHUFPD, + /* 35E */ VSHUFPS, + /* 35F */ VSQRTPD, + /* 360 */ VSQRTPS, + /* 361 */ VSQRTSD, + /* 362 */ VSQRTSS, + /* 363 */ VSTMXCSR, + /* 364 */ VSUBPD, + /* 365 */ VSUBPS, + /* 366 */ VSUBSD, + /* 367 */ VSUBSS, + /* 368 */ VTESTPD, + /* 369 */ VTESTPS, + /* 36A */ VUCOMISD, + /* 36B */ VUCOMISS, + /* 36C */ VUNPCKHPD, + /* 36D */ VUNPCKHPS, + /* 36E */ VUNPCKLPD, + /* 36F */ VUNPCKLPS, + /* 370 */ VXORPD, + /* 371 */ VXORPS, + /* 372 */ VZEROALL, + /* 373 */ VZEROUPPER, + /* 374 */ WAIT, + /* 375 */ WBINVD, + /* 376 */ WRMSR, + /* 377 */ XADD, + /* 378 */ XCHG, + /* 379 */ XCRYPTCBC, + /* 37A */ XCRYPTCFB, + /* 37B */ XCRYPTCTR, + /* 37C */ XCRYPTECB, + /* 37D */ XCRYPTOFB, + /* 37E */ XGETBV, + /* 37F */ XLATB, + /* 380 */ XOR, + /* 381 */ XORPD, + /* 382 */ XORPS, + /* 383 */ XRSTOR, + /* 384 */ XSAVE, + /* 385 */ XSETBV, + /* 386 */ XSHA1, + /* 387 */ XSHA256, + /* 388 */ XSTORE, +}; + +/** + * @brief Defines an alias representing an opcode tree node. An opcode tree node is a 16 bit + * unsigned integer value with its first 4 bits reserved for the node type. + */ +typedef uint16_t VXOpcodeTreeNode; + +/** + * @brief Values that represent the type of an opcode tree node. + */ +enum class VXOpcodeTreeNodeType : uint8_t +{ + /** + * @brief Reference to a concrete instruction definition. + */ + INSTRUCTION_DEFINITION = 0, + /** + * @brief Reference to an opcode table. + */ + TABLE = 1, + /** + * @brief Reference to a modrm_mod switch table. + */ + MODRM_MOD = 2, + /** + * @brief Reference to a modrm_reg switch table. + */ + MODRM_REG = 3, + /** + * @brief Reference to a modrm_rm switch table. + */ + MODRM_RM = 4, + /** + * @brief Reference to a mandatory-prefix switch table. + */ + MANDATORY = 5, + /** + * @brief Reference to a x87 opcode table. + */ + X87 = 6, + /** + * @brief Reference to an address-size switch table. + */ + ADDRESS_SIZE = 7, + /** + * @brief Reference to an operand-size switch table. + */ + OPERAND_SIZE = 8, + /** + * @brief Reference to a cpu-mode switch table. + */ + MODE = 9, + /** + * @brief Reference to a vendor switch table. + */ + VENDOR = 10, + /** + * @brief Reference to a 3dnow! opcode table. + */ + AMD3DNOW = 11, + /** + * @brief Reference to a vex-prefix switch table. + */ + VEX = 12, + /** + * @brief Reference to a vex_w switch table. + */ + VEXW = 13, + /** + * @brief Reference to a vex_l switch table. + */ + VEXL = 14 +}; + +/** + * @brief Values that represent the type of an operand in the instruction definition. + */ +enum class VXDefinedOperandType : uint8_t +{ + /* + * @brief No operand. + */ + NONE, + /* + * @brief Direct address. The instruction has no ModR/M byte; the address of the operand is + * encoded in the instruction; no base register, index register, or scaling factor + * can be applied. + */ + A, + /* + * @brief The reg field of the ModR/M byte selects a control register. + */ + C, + /* + * @brief The reg field of the ModR/M byte selects a debug register. + */ + D, + /* + * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either + * a general-purpose register or a memory address. If it is a memory address, the + * address is computed from a segment register and any of the following values: + * a base register, an index register, a scaling factor, or a displacement. + */ + E, + /* + * @brief rFLAGS register. + */ + F, + /* + * @brief The reg field of the ModR/M byte selects a general register. + */ + G, + /* + * @brief The r/m field of the ModR/M byte always selects a general register, regardless of + * the mod field. + */ + H, + /* + * @brief Immediate data. The operand value is encoded in subsequent bytes of the + * instruction. + */ + I, + /* + * @brief Signed immediate data. The operand value is encoded in subsequent bytes of the + * instruction. + */ + sI, + /* + * @brief Constant immediate data value of 1. + */ + I1, + /* + * @brief The instruction contains a relative offset to be added to the instruction pointer + * register. + */ + J, + /* + * @brief Source operand is encoded in immediate byte (VEX only). + */ + L, + /* + * @brief The ModR/M byte may refer only to memory: mod != 11bin. + */ + M, + /* + * @brief Combination of M and R. + */ + MR, + /* + * @brief Combination of M and U. + */ + MU, + /* + * @brief The R/M field of the ModR/M byte selects a packed quadword MMX technology register. + */ + N, + /* + * @brief The instruction has no ModR/M byte; the offset of the operand is coded as a word, + * double word or quad word (depending on address size attribute) in the instruction. + * No base register, index register, or scaling factor can be applied. + */ + O, + /* + * @brief The reg field of the ModR/M byte selects a packed quadword MMX technology register. + */ + P, + /* + * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either + * an MMX technology register or a memory address. If it is a memory address, the + * address is computed from a segment register and any of the following values: + * a base register, an index register, a scaling factor, and a displacement. + */ + Q, + /* + * @brief The mod field of the ModR/M byte may refer only to a general register. + */ + R, + /* + * @brief The reg field of the ModR/M byte selects a segment register. + */ + S, + /* + * @brief The R/M field of the ModR/M byte selects a 128-bit XMM register. + */ + U, + /* + * @brief The reg field of the ModR/M byte selects a 128-bit XMM register. + */ + V, + /* + * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either + * a 128-bit XMM register or a memory address. If it is a memory address, the address + * is computed from a segment register and any of the following values: + * a base register, an index register, a scaling factor, and a displacement. + */ + W, + /** + * @brief Register 0. + */ + R0, + /** + * @brief Register 1. + */ + R1, + /** + * @brief Register 2. + */ + R2, + /** + * @brief Register 3. + */ + R3, + /** + * @brief Register 4. + */ + R4, + /** + * @brief Register 5. + */ + R5, + /** + * @brief Register 6. + */ + R6, + /** + * @brief Register 7. + */ + R7, + /** + * @brief AL register. + */ + AL, + /** + * @brief CL register. + */ + CL, + /** + * @brief DL register. + */ + DL, + /** + * @brief AX register. + */ + AX, + /** + * @brief CX register. + */ + CX, + /** + * @brief DX register. + */ + DX, + /** + * @brief EAX register. + */ + EAX, + /** + * @brief ECX register. + */ + ECX, + /** + * @brief EDX register. + */ + EDX, + /** + * @brief RAX register. + */ + RAX, + /** + * @brief RCX register. + */ + RCX, + /** + * @brief RDX register. + */ + RDX, + /** + * @brief ES segment register. + */ + ES, + /** + * @brief CS segment register. + */ + CS, + /** + * @brief SS segment register. + */ + SS, + /** + * @brief DS segment register. + */ + DS, + /** + * @brief FS segment register. + */ + FS, + /** + * @brief GS segment register. + */ + GS, + /** + * @brief Floating point register 0. + */ + ST0, + /** + * @brief Floating point register 1. + */ + ST1, + /** + * @brief Floating point register 2. + */ + ST2, + /** + * @brief Floating point register 3. + */ + ST3, + /** + * @brief Floating point register 4. + */ + ST4, + /** + * @brief Floating point register 5. + */ + ST5, + /** + * @brief Floating point register 6. + */ + ST6, + /** + * @brief Floating point register 7. + */ + ST7 +}; + +/** + * @brief Values that represent the size of an operand in the instruction definition. + * Do not change the order or the values of this enum! + */ +enum class VXDefinedOperandSize : uint8_t +{ + /** + * @brief No operand. + */ + NA = 0, + /** + * @brief Word, dword or qword. + */ + Z, + /** + * @brief Word, dword or qword. + */ + V, + /** + * @brief Dword or qword. + */ + Y, + /** + * @brief Oword or yword. + */ + X, + /** + * @brief Dword or qword, depending on the disassembler mode. + */ + RDQ, + /* + * @brief Byte, regardless of operand-size attribute. + */ + B, + /* + * @brief Word, regardless of operand-size attribute. + */ + W, + /* + * @brief Doubleword, regardless of operand-size attribute. + */ + D, + /* + * @brief Quadword, regardless of operand-size attribute. + */ + Q, + /* + * @brief 10-byte far pointer. + */ + T, + /** + * @brief TODO: + */ + O, + /* + * @brief Double-quadword, regardless of operand-size attribute. + */ + DQ, + /* + * @brief Quad-quadword, regardless of operand-size attribute. + */ + QQ, + /** + * @brief B sized register or D sized memory operand. + */ + BD = (static_cast(B) << 4) | static_cast(D), + /** + * @brief B sized register or V sized memory operand. + */ + BV = (static_cast(B) << 4) | static_cast(V), + /** + * @brief W sized register or D sized memory operand. + */ + WD = (static_cast(W) << 4) | static_cast(D), + /** + * @brief W sized register or V sized memory operand. + */ + WV = (static_cast(W) << 4) | static_cast(V), + /** + * @brief W sized register or Y sized memory operand. + */ + WY = (static_cast(W) << 4) | static_cast(Y), + /** + * @brief D sized register or Y sized memory operand. + */ + DY = (static_cast(D) << 4) | static_cast(Y), + /** + * @brief W sized register or O sized memory operand. + */ + WO = (static_cast(W) << 4) | static_cast(O), + /** + * @brief D sized register or O sized memory operand. + */ + DO = (static_cast(D) << 4) | static_cast(O), + /** + * @brief Q sized register or O sized memory operand. + */ + QO = (static_cast(Q) << 4) | static_cast(O), +}; + +/** + * @brief Values that represent optional flags in the instruction definition. + * Do not change the order or the values of this enum! + */ +enum VXInstructionDefinitionFlags : uint16_t +{ + /** + * @brief The instruction accepts the rex.b prefix value. + */ + IDF_ACCEPTS_REXB = 0x0001, + /** + * @brief The instruction accepts the rex.x prefix value. + */ + IDF_ACCEPTS_REXX = 0x0002, + /** + * @brief The instruction accepts the rex.r prefix value. + */ + IDF_ACCEPTS_REXR = 0x0004, + /** + * @brief The instruction accepts the rex.w prefix value. + */ + IDF_ACCEPTS_REXW = 0x0008, + /** + * @brief The instruction accepts the address size override prefix (0x67). + */ + IDF_ACCEPTS_ADDRESS_SIZE_PREFIX = 0x0010, + /** + * @brief The instruction accepts the operand size override prefix (0x66). + */ + IDF_ACCEPTS_OPERAND_SIZE_PREFIX = 0x0020, + /** + * @brief The instruction accepts the segment override prefix. + */ + IDF_ACCEPTS_SEGMENT_PREFIX = 0x0040, + /** + * @brief The instruction accepts the REP prefix. + */ + IDF_ACCEPTS_REP_PREFIX = 0x0080, + /** + * @brief The instruction accepts the vex.l prefix value. + */ + IDF_ACCEPTS_VEXL = 0x0100, + /** + * @brief The instruction is invalid in 64 bit mode. + */ + IDF_INVALID_64 = 0x0200, + /** + * @brief The instructions operand size defaults to quadword in 64 bit mode. + */ + IDF_DEFAULT_64 = 0x0400, + /** + * @brief The first operand of the instruction is accessed in write mode. + */ + IDF_OPERAND1_WRITE = 0x0800, + /** + * @brief The first operand of the instruction is accessed in read-write mode. + */ + IDF_OPERAND1_READWRITE = 0x1000, + /** + * @brief The second operand of the instruction is accessed in write mode. + */ + IDF_OPERAND2_WRITE = 0x2000, + /** + * @brief The second operand of the instruction is accessed in read-write mode. + */ + IDF_OPERAND2_READWRITE = 0x4000 +}; + +#pragma pack (push, 1) +/** + * @brief An operand definition. + */ +struct VXOperandDefinition +{ + /** + * @brief The defined operand type. + */ + VXDefinedOperandType type; + /** + * @brief The defined operand size. + */ + VXDefinedOperandSize size; +}; +/** + * @brief An instruction definition. + */ +struct VXInstructionDefinition +{ + /** + * @brief The instruction mnemonic. + */ + VXInstructionMnemonic mnemonic; + /** + * @brief The operand definitions for all four possible operands. + */ + VXOperandDefinition operand[4]; + /** + * @brief Additional flags for the instruction definition. + */ + uint16_t flags; +}; +#pragma pack (pop) + +namespace Internal +{ + +/** + * @brief Contains all opcode tables. + * Indexed by the numeric value of the opcode. + */ +extern const VXOpcodeTreeNode optreeTable[][256]; +/** + * @brief Contains all modrm_mod switch tables. + * Index values: + * 0 = [modrm_mod == !11] + * 1 = [modrm_mod == 11] + */ +extern const VXOpcodeTreeNode optreeModrmMod[][2]; +/** + * @brief Contains all modrm_reg switch tables. + * Indexed by the numeric value of the modrm_reg field. + */ +extern const VXOpcodeTreeNode optreeModrmReg[][8]; +/** + * @brief Contains all modrm_rm switch tables. + * Indexed by the numeric value of the modrm_rm field. + */ +extern const VXOpcodeTreeNode optreeModrmRm[][8]; +/** + * @brief Contains all mandatory-prefix switch tables. + * Index values: + * 0 = none + * 1 = F2 + * 2 = F3 + * 3 = 66 + */ +extern const VXOpcodeTreeNode optreeMandatory[][4]; +/** + * @brief Contains all x87 opcode tables. + * Indexed by the numeric value of the 6 lowest bits of the modrm byte (modrm_mod should + * always be 11). + */ +extern const VXOpcodeTreeNode optreeX87[][64]; +/** + * @brief Contains all address-size switch tables. + * Index values: + * 0 = 16 + * 1 = 32 + * 2 = 64 + */ +extern const VXOpcodeTreeNode optreeAddressSize[][3]; +/** + * @brief Contains all operand-size switch tables. + * Index values: + * 0 = 16 + * 1 = 32 + * 2 = 64 + */ +extern const VXOpcodeTreeNode optreeOperandSize[][3]; +/** + * @brief Contains all cpu-mode switch tables. + * Index values: + * 0 = [!= 64] + * 1 = 64 + */ +extern const VXOpcodeTreeNode optreeMode[][2]; +/** + * @brief Contains all vendor switch tables. + * Index values: + * 0 = AMD + * 1 = Intel + */ +extern const VXOpcodeTreeNode optreeVendor[][2]; +/** + * @brief Contains all 3dnow! switch tables. + * Indexed by the numeric value of the 3dnow! opcode. + */ +extern const VXOpcodeTreeNode optree3dnow[][256]; +/** + * @brief Contains all vex switch tables. + * Index values: + * 0 = none + * 1 = 0F + * 2 = 0F38 + * 3 = 0F3A + * 4 = 66 + * 5 = 66_0F + * 6 = 66_0F38 + * 7 = 66_0F3A + * 8 = F3 + * 9 = F3_0F + * A = F3_0F38 + * B = F3_0F3A + * C = F2 + * D = F2_0F + * E = F2_0F38 + * F = F2_0F3A + */ +extern const VXOpcodeTreeNode optreeVex[][16]; +/** + * @brief Contains all vex_w switch tables. + * Indexed by the numeric value of the vex_w field. + */ +extern const VXOpcodeTreeNode optreeVexW[][2]; +/** + * @brief Contains all vex_l switch tables. + * Indexed by the numeric value of the vex_l field. + */ +extern const VXOpcodeTreeNode optreeVexL[][2]; +/** + * @brief Contains all instruction definitions. + */ +extern const VXInstructionDefinition instrDefinitions[]; +/** + * @brief Contains all instruction mnemonic strings. + */ +extern const char* instrMnemonicStrings[]; + +/** + * @brief Returns the type of the specified opcode tree node. + * @param node The node. + * @return The type of the specified opcode tree node. + */ +inline VXOpcodeTreeNodeType VDEGetOpcodeNodeType(VXOpcodeTreeNode node) +{ + return static_cast((node >> 12) & 0x0F); +} + +/** + * @brief Returns the value of the specified opcode tree node. + * @param node The node. + * @return The value of the specified opcode tree node. + */ +inline uint16_t VDEGetOpcodeNodeValue(VXOpcodeTreeNode node) +{ + return (node & 0x0FFF); +} + +/** + * @brief Returns the root node of the opcode tree. + * @return The root node of the opcode tree. + */ +inline VXOpcodeTreeNode VDEGetOpcodeTreeRoot() +{ + return 0x1000; +} + +/** + * @brief Returns a child node of @c parent specified by @c index. + * @param parent The parent node. + * @param index The index of the child node to retrieve. + * @return The specified child node. + */ +inline VXOpcodeTreeNode VDEGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_t index) +{ + using namespace Internal; + VXOpcodeTreeNodeType nodeType = VDEGetOpcodeNodeType(parent); + uint16_t tableIndex = VDEGetOpcodeNodeValue(parent); + switch (nodeType) + { + case VXOpcodeTreeNodeType::TABLE: + assert(index < 256); + return optreeTable[tableIndex][index]; + case VXOpcodeTreeNodeType::MODRM_MOD: + assert(index < 2); + return optreeModrmMod[tableIndex][index]; + case VXOpcodeTreeNodeType::MODRM_REG: + assert(index < 8); + return optreeModrmReg[tableIndex][index]; + case VXOpcodeTreeNodeType::MODRM_RM: + assert(index < 8); + return optreeModrmRm[tableIndex][index]; + case VXOpcodeTreeNodeType::MANDATORY: + assert(index < 4); + return optreeMandatory[tableIndex][index]; + case VXOpcodeTreeNodeType::X87: + assert(index < 64); + return optreeX87[tableIndex][index]; + case VXOpcodeTreeNodeType::ADDRESS_SIZE: + assert(index < 3); + return optreeAddressSize[tableIndex][index]; + case VXOpcodeTreeNodeType::OPERAND_SIZE: + assert(index < 3); + return optreeOperandSize[tableIndex][index]; + case VXOpcodeTreeNodeType::MODE: + assert(index < 2); + return optreeMode[tableIndex][index]; + case VXOpcodeTreeNodeType::VENDOR: + assert(index < 3); + return optreeVendor[tableIndex][index]; + case VXOpcodeTreeNodeType::AMD3DNOW: + assert(index < 256); + return optree3dnow[tableIndex][index]; + case VXOpcodeTreeNodeType::VEX: + assert(index < 16); + return optreeVex[tableIndex][index]; + case VXOpcodeTreeNodeType::VEXW: + assert(index < 2); + return optreeVexW[tableIndex][index]; + case VXOpcodeTreeNodeType::VEXL: + assert(index < 2); + return optreeVexL[tableIndex][index]; + default: + assert(0); + } + return 0xFFFF; +} + +/** + * @brief Returns the instruction definition that is linked to the given @c node. + * @param node The instruction definition node. + * @return Pointer to the instruction definition. + */ +inline const VXInstructionDefinition* VDEGetInstructionDefinition(VXOpcodeTreeNode node) +{ + assert(VDEGetOpcodeNodeType(node) == VXOpcodeTreeNodeType::INSTRUCTION_DEFINITION); + return &instrDefinitions[node & 0x0FFF]; +} + +/** + * @brief Returns the specified instruction mnemonic string. + * @param mnemonic The mnemonic. + * @return The instruction mnemonic string. + */ +inline const char* VDEGetInstructionMnemonicString(VXInstructionMnemonic mnemonic) +{ + return instrMnemonicStrings[static_cast(mnemonic)]; +} + +/** + * @brief Returns the numeric value for a simple operand size definition. + * @param operandSize The defined operand size. + * @return The the numeric value for the simple operand size definition. + */ +inline uint16_t VDEGetSimpleOperandSize(VXDefinedOperandSize operandSize) +{ + static uint16_t operandSizes[8] = + { + 8, 16, 32, 64, 80, 12, 128, 256 + }; + uint16_t index = + static_cast(operandSize) - static_cast(VXDefinedOperandSize::B); + assert(index < 8); + return operandSizes[index]; +} + +/** + * @brief Returns the memory-size part of a complex operand size definition. + * @param operandSize The defined operand size. + * @return The memory-size part of the operand size definition. + */ +inline VXDefinedOperandSize VDEGetComplexOperandMemSize(VXDefinedOperandSize operandSize) +{ + return static_cast(static_cast(operandSize) & 0x0F); +} + +/** + * @brief Returns the register-size part of a complex operand size definition. + * @param operandSize The defined operand size. + * @return The register-size part of the operand size definition. + */ +inline VXDefinedOperandSize VDEGetComplexOperandRegSize(VXDefinedOperandSize operandSize) +{ + return static_cast((static_cast(operandSize) >> 4) & 0x0F); +} + +} + +} diff --git a/CMakeLists.txt b/CMakeLists.txt index f47e14d..5766517 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 2.8.12) project(VerteronDisassemblerEngine) +option(BUILD_SHARED "Build shared libraries rather than static ones" FALSE) option(BUILD_EXAMPLES "Build examples" TRUE) -option(BUILD_C_BINDINGS "Build C bindings" TRUE) # TODO: default to FALSE when ready +option(BUILD_CPP_BINDINGS "Build C++ bindings" TRUE) if (NOT CONFIGURED_ONCE) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR @@ -27,57 +28,62 @@ set(vde_headers "VerteronDisassemblerEngine/VXDisassemblerUtils.h" "VerteronDisassemblerEngine/VXInstructionDecoder.h" "VerteronDisassemblerEngine/VXInstructionFormatter.h" - "VerteronDisassemblerEngine/VXOpcodeTable.h") + "VerteronDisassemblerEngine/VXOpcodeTable.h" + "VerteronDisassemblerEngine/VXOpcodeTableInternal.h" + "VerteronDisassemblerEngine/VXInternalHelpers.h" + "VerteronDisassemblerEngine/VXInternalConfig.h") set(vde_sources - "VerteronDisassemblerEngine/VXDisassemblerUtils.cpp" - "VerteronDisassemblerEngine/VXInstructionFormatter.cpp" - "VerteronDisassemblerEngine/VXOpcodeTable.cpp" - "VerteronDisassemblerEngine/VXInstructionDecoder.cpp") + "VerteronDisassemblerEngine/VXDisassemblerUtils.c" + "VerteronDisassemblerEngine/VXInstructionFormatter.c" + "VerteronDisassemblerEngine/VXOpcodeTable.c" + "VerteronDisassemblerEngine/VXInstructionDecoder.c") -add_library("VerteronDisassemblerEngine" ${vde_headers} ${vde_sources}) +#if (BUILD_SHARED) +# add_definitions("-DVX_BUILD_SHARED") +# add_library("VerteronDisassemblerEngine" SHARED ${vde_headers} ${vde_sources}) +#else () + add_library("VerteronDisassemblerEngine" STATIC ${vde_headers} ${vde_sources}) +#endif () -# C bindings -if (BUILD_C_BINDINGS) - set(vdec_headers - "Bindings/C/VXDisassemblerC.h" - "Bindings/C/VXDisassemblerTypesC.h" - "Bindings/C/VXDisassemblerUtilsC.h" - "Bindings/C/VXInstructionDecoderC.h" - "Bindings/C/VXInstructionFormatterC.h" - "Bindings/C/VXOpcodeTableC.h" - "Bindings/C/VXOpcodeTableInternalC.h" - "Bindings/C/VXInternalHelpersC.h" - "Bindings/C/VXInternalConfig.h") - set(vdec_sources - "Bindings/C/VXDisassemblerUtilsC.c" - "Bindings/C/VXInstructionFormatterC.c" - "Bindings/C/VXOpcodeTableC.c" - "Bindings/C/VXInstructionDecoderC.c") - add_library("VerteronDisassemblerEngineC" ${vdec_headers} ${vdec_sources}) - target_link_libraries("VerteronDisassemblerEngineC" "VerteronDisassemblerEngine") +# C++ bindings +if (BUILD_CPP_BINDINGS) + set(vdecpp_headers + "Bindings/Cpp/VXDisassembler.hpp" + "Bindings/Cpp/VXDisassemblerTypes.hpp" + "Bindings/Cpp/VXDisassemblerUtils.hpp" + "Bindings/Cpp/VXInstructionDecoder.hpp" + "Bindings/Cpp/VXInstructionFormatter.hpp" + "Bindings/Cpp/VXOpcodeTable.hpp") + set(vdecpp_sources + "Bindings/Cpp/VXDisassemblerUtils.cpp" + "Bindings/Cpp/VXInstructionFormatter.cpp" + "Bindings/Cpp/VXOpcodeTable.cpp" + "Bindings/Cpp/VXInstructionDecoder.cpp") + add_library("VerteronDisassemblerEngineCpp" ${vdecpp_headers} ${vdecpp_sources}) + target_link_libraries("VerteronDisassemblerEngineCpp" "VerteronDisassemblerEngine") endif () # Examples if (BUILD_EXAMPLES) include_directories("VerteronDisassemblerEngine") - add_executable("CustomDataSource" "Examples/CustomDataSource/Main.cpp") + add_executable("CustomDataSource" "Examples/CustomDataSource/Main.c") target_link_libraries("CustomDataSource" "VerteronDisassemblerEngine") - add_executable("PerformanceTest" "Examples/PerformanceTest/Main.cpp") + add_executable("PerformanceTest" "Examples/PerformanceTest/Main.c") target_link_libraries("PerformanceTest" "VerteronDisassemblerEngine") - add_executable("SimpleDemo" "Examples/SimpleDemo/Main.cpp") + add_executable("SimpleDemo" "Examples/SimpleDemo/Main.c") target_link_libraries("SimpleDemo" "VerteronDisassemblerEngine") - if (BUILD_C_BINDINGS) - add_executable("CBindingsTest" "Examples/CBindings/test.c") - include_directories("Bindings/C") - target_link_libraries("CBindingsTest" "VerteronDisassemblerEngineC") + if (BUILD_CPP_BINDINGS) + add_executable("CppBindingsTest" "Examples/CppBindings/Main.cpp") + include_directories("Bindings/Cpp") + target_link_libraries("CppBindingsTest" "VerteronDisassemblerEngineCpp") endif () if (WIN32) - add_executable("SymbolResolver" "Examples/SymbolResolver/Main.cpp") + add_executable("SymbolResolver" "Examples/SymbolResolver/Main.c") target_link_libraries("SymbolResolver" "VerteronDisassemblerEngine") else () message(STATUS "Example 'SymbolResolver' not compatible with platform, ignoring.") diff --git a/Examples/SimpleDemo/Main.cpp b/Examples/CppBindings/Main.cpp similarity index 99% rename from Examples/SimpleDemo/Main.cpp rename to Examples/CppBindings/Main.cpp index cdc582d..3f67a61 100644 --- a/Examples/SimpleDemo/Main.cpp +++ b/Examples/CppBindings/Main.cpp @@ -32,7 +32,8 @@ #include #include #include -#include + +#include using namespace Verteron; diff --git a/Examples/CustomDataSource/CustomDataSource.vcxproj b/Examples/CustomDataSource/CustomDataSource.vcxproj deleted file mode 100644 index 6e9f686..0000000 --- a/Examples/CustomDataSource/CustomDataSource.vcxproj +++ /dev/null @@ -1,157 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {EB0F5A04-EE14-4779-9B29-322876CD45C8} - Win32Proj - CustomDataSource - 2 - Custom DataSource - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - true - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - false - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - false - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - - - - {f5c6f0a7-f75d-42bd-a8ab-a2d1d5f67099} - - - - - - \ No newline at end of file diff --git a/Examples/CustomDataSource/CustomDataSource.vcxproj.filters b/Examples/CustomDataSource/CustomDataSource.vcxproj.filters deleted file mode 100644 index d3e9077..0000000 --- a/Examples/CustomDataSource/CustomDataSource.vcxproj.filters +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Examples/CustomDataSource/Main.cpp b/Examples/CustomDataSource/Main.c similarity index 100% rename from Examples/CustomDataSource/Main.cpp rename to Examples/CustomDataSource/Main.c diff --git a/Examples/Examples.sln b/Examples/Examples.sln deleted file mode 100644 index a700b31..0000000 --- a/Examples/Examples.sln +++ /dev/null @@ -1,90 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "1 - Simple Demo", "SimpleDemo\SimpleDemo.vcxproj", "{BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2 - Custom DataSource", "CustomDataSource\CustomDataSource.vcxproj", "{EB0F5A04-EE14-4779-9B29-322876CD45C8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "3 - Symbol Resolver", "SymbolResolver\SymbolResolver.vcxproj", "{B6CA4362-2714-451C-8063-12195ABD7CD7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VerteronDisassemblerEngine", "..\VerteronDisassemblerEngine\VerteronDisassemblerEngine.vcxproj", "{F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "4 - Performance Test", "PerformanceTest\PerformanceTest.vcxproj", "{4A0B7BE7-72C9-4A95-90CA-D56C50F10401}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Mixed Platforms = Release|Mixed Platforms - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Debug|Win32.Build.0 = Debug|Win32 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Debug|x64.ActiveCfg = Debug|x64 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Debug|x64.Build.0 = Debug|x64 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Release|Mixed Platforms.Build.0 = Release|Win32 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Release|Win32.ActiveCfg = Release|Win32 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Release|Win32.Build.0 = Release|Win32 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Release|x64.ActiveCfg = Release|x64 - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}.Release|x64.Build.0 = Release|x64 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Debug|Win32.ActiveCfg = Debug|Win32 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Debug|Win32.Build.0 = Debug|Win32 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Debug|x64.ActiveCfg = Debug|x64 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Debug|x64.Build.0 = Debug|x64 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Release|Mixed Platforms.Build.0 = Release|Win32 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Release|Win32.ActiveCfg = Release|Win32 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Release|Win32.Build.0 = Release|Win32 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Release|x64.ActiveCfg = Release|x64 - {EB0F5A04-EE14-4779-9B29-322876CD45C8}.Release|x64.Build.0 = Release|x64 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Debug|Win32.ActiveCfg = Debug|Win32 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Debug|Win32.Build.0 = Debug|Win32 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Debug|x64.ActiveCfg = Debug|x64 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Debug|x64.Build.0 = Debug|x64 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Release|Mixed Platforms.Build.0 = Release|Win32 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Release|Win32.ActiveCfg = Release|Win32 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Release|Win32.Build.0 = Release|Win32 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Release|x64.ActiveCfg = Release|x64 - {B6CA4362-2714-451C-8063-12195ABD7CD7}.Release|x64.Build.0 = Release|x64 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|Win32.ActiveCfg = Debug|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|Win32.Build.0 = Debug|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|x64.ActiveCfg = Debug|x64 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|x64.Build.0 = Debug|x64 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|Mixed Platforms.Build.0 = Release|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|Win32.ActiveCfg = Release|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|Win32.Build.0 = Release|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|x64.ActiveCfg = Release|x64 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|x64.Build.0 = Release|x64 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Debug|Win32.ActiveCfg = Debug|Win32 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Debug|Win32.Build.0 = Debug|Win32 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Debug|x64.ActiveCfg = Debug|x64 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Debug|x64.Build.0 = Debug|x64 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Release|Mixed Platforms.Build.0 = Release|Win32 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Release|Win32.ActiveCfg = Release|Win32 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Release|Win32.Build.0 = Release|Win32 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Release|x64.ActiveCfg = Release|x64 - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Examples/PerformanceTest/Main.cpp b/Examples/PerformanceTest/Main.c similarity index 100% rename from Examples/PerformanceTest/Main.cpp rename to Examples/PerformanceTest/Main.c diff --git a/Examples/PerformanceTest/PerformanceTest.vcxproj b/Examples/PerformanceTest/PerformanceTest.vcxproj deleted file mode 100644 index 87e34c4..0000000 --- a/Examples/PerformanceTest/PerformanceTest.vcxproj +++ /dev/null @@ -1,157 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {4A0B7BE7-72C9-4A95-90CA-D56C50F10401} - Win32Proj - PerformanceTest - 4 - Performance Test - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - true - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - false - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - false - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - - - - {f5c6f0a7-f75d-42bd-a8ab-a2d1d5f67099} - - - - - - \ No newline at end of file diff --git a/Examples/PerformanceTest/PerformanceTest.vcxproj.filters b/Examples/PerformanceTest/PerformanceTest.vcxproj.filters deleted file mode 100644 index d3e9077..0000000 --- a/Examples/PerformanceTest/PerformanceTest.vcxproj.filters +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Examples/CBindings/test.c b/Examples/SimpleDemo/Main.c similarity index 99% rename from Examples/CBindings/test.c rename to Examples/SimpleDemo/Main.c index ae68857..a159526 100644 --- a/Examples/CBindings/test.c +++ b/Examples/SimpleDemo/Main.c @@ -30,7 +30,7 @@ **************************************************************************************************/ -#include +#include #include #include diff --git a/Examples/SimpleDemo/SimpleDemo.vcxproj b/Examples/SimpleDemo/SimpleDemo.vcxproj deleted file mode 100644 index 15332e3..0000000 --- a/Examples/SimpleDemo/SimpleDemo.vcxproj +++ /dev/null @@ -1,157 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {BC5CDE9B-9F84-453E-8131-B56F67FD0E4D} - Win32Proj - SimpleDemo - 1 - Simple Demo - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - true - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - false - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - false - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - - - - {f5c6f0a7-f75d-42bd-a8ab-a2d1d5f67099} - - - - - - \ No newline at end of file diff --git a/Examples/SimpleDemo/SimpleDemo.vcxproj.filters b/Examples/SimpleDemo/SimpleDemo.vcxproj.filters deleted file mode 100644 index d3e9077..0000000 --- a/Examples/SimpleDemo/SimpleDemo.vcxproj.filters +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Examples/SymbolResolver/Main.cpp b/Examples/SymbolResolver/Main.c similarity index 95% rename from Examples/SymbolResolver/Main.cpp rename to Examples/SymbolResolver/Main.c index 8e7cdc3..f73c8dc 100644 --- a/Examples/SymbolResolver/Main.cpp +++ b/Examples/SymbolResolver/Main.c @@ -29,27 +29,27 @@ * SOFTWARE. **************************************************************************************************/ -#include -#include -#include + #include #include -using namespace Verteron; - int main(int argc, char* argv[]) { + // TODO: port to C + /* + // Find module base in memory void *moduleBase = GetModuleHandle("kernel32.dll"); - uintptr_t baseAddress = reinterpret_cast(moduleBase); + uintptr_t baseAddress = (uintptr_t)moduleBase; + // Parse PE headers - PIMAGE_DOS_HEADER dosHeader = static_cast(moduleBase); + PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)moduleBase; if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE) { return 1; } - PIMAGE_NT_HEADERS ntHeaders = - reinterpret_cast(baseAddress + dosHeader->e_lfanew); + + PIMAGE_NT_HEADERS ntHeaders = (PIMAGE_NT_HEADERS)(baseAddress + dosHeader->e_lfanew); if (ntHeaders->Signature != IMAGE_NT_SIGNATURE) { return 1; @@ -187,5 +187,7 @@ int main(int argc, char* argv[]) sectionHeader++; } out.close(); + */ + return 0; } diff --git a/Examples/SymbolResolver/SymbolResolver.vcxproj b/Examples/SymbolResolver/SymbolResolver.vcxproj deleted file mode 100644 index adcc661..0000000 --- a/Examples/SymbolResolver/SymbolResolver.vcxproj +++ /dev/null @@ -1,157 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {B6CA4362-2714-451C-8063-12195ABD7CD7} - Win32Proj - SymbolResolver - 3 - Symbol Resolver - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - true - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - false - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - false - ..\..\VerteronDisassemblerEngine\;$(IncludePath) - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - - - - {f5c6f0a7-f75d-42bd-a8ab-a2d1d5f67099} - - - - - - \ No newline at end of file diff --git a/Examples/SymbolResolver/SymbolResolver.vcxproj.filters b/Examples/SymbolResolver/SymbolResolver.vcxproj.filters deleted file mode 100644 index d3e9077..0000000 --- a/Examples/SymbolResolver/SymbolResolver.vcxproj.filters +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/VerteronDisassemblerEngine.sln b/VerteronDisassemblerEngine.sln deleted file mode 100644 index c5db4b1..0000000 --- a/VerteronDisassemblerEngine.sln +++ /dev/null @@ -1,38 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VerteronDisassemblerEngine", "VerteronDisassemblerEngine\VerteronDisassemblerEngine.vcxproj", "{F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OptableGenerator", "OptableGenerator\OptableGenerator.vcxproj", "{EFA075B8-AFB9-4E06-99AD-BD58F50A9500}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|Win32.ActiveCfg = Debug|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|Win32.Build.0 = Debug|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|x64.ActiveCfg = Debug|x64 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Debug|x64.Build.0 = Debug|x64 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|Win32.ActiveCfg = Release|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|Win32.Build.0 = Release|Win32 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|x64.ActiveCfg = Release|x64 - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}.Release|x64.Build.0 = Release|x64 - {EFA075B8-AFB9-4E06-99AD-BD58F50A9500}.Debug|Win32.ActiveCfg = Debug|Win32 - {EFA075B8-AFB9-4E06-99AD-BD58F50A9500}.Debug|Win32.Build.0 = Debug|Win32 - {EFA075B8-AFB9-4E06-99AD-BD58F50A9500}.Debug|x64.ActiveCfg = Debug|x64 - {EFA075B8-AFB9-4E06-99AD-BD58F50A9500}.Debug|x64.Build.0 = Debug|x64 - {EFA075B8-AFB9-4E06-99AD-BD58F50A9500}.Release|Win32.ActiveCfg = Release|Win32 - {EFA075B8-AFB9-4E06-99AD-BD58F50A9500}.Release|Win32.Build.0 = Release|Win32 - {EFA075B8-AFB9-4E06-99AD-BD58F50A9500}.Release|x64.ActiveCfg = Release|x64 - {EFA075B8-AFB9-4E06-99AD-BD58F50A9500}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/VerteronDisassemblerEngine/VXDisassembler.h b/VerteronDisassemblerEngine/VXDisassembler.h index 271d8d9..1baf7c3 100644 --- a/VerteronDisassemblerEngine/VXDisassembler.h +++ b/VerteronDisassemblerEngine/VXDisassembler.h @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : + Modifications : athre0z - Last change : 29. October 2014 + Last change : 04. February 2015 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,10 +28,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. -**************************************************************************************************/ -#pragma once + **************************************************************************************************/ + +#ifndef _VDE_VXDISASSEMBLERC_H_ +#define _VDE_VXDISASSEMBLERC_H_ #include "VXDisassemblerTypes.h" #include "VXInstructionDecoder.h" #include "VXInstructionFormatter.h" #include "VXDisassemblerUtils.h" + +#endif /* _VDE_VXDISASSEMBLERC_H_ */ \ No newline at end of file diff --git a/VerteronDisassemblerEngine/VXDisassemblerTypes.h b/VerteronDisassemblerEngine/VXDisassemblerTypes.h index b4d97b9..ab16c5b 100644 --- a/VerteronDisassemblerEngine/VXDisassemblerTypes.h +++ b/VerteronDisassemblerEngine/VXDisassemblerTypes.h @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : + Modifications : athre0z - Last change : 22. October 2014 + Last change : 04. February 2015 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,18 +29,23 @@ * SOFTWARE. **************************************************************************************************/ -#pragma once + +#ifndef _VDE_VXDISASSEMBLERTYPESC_H_ +#define _VDE_VXDISASSEMBLERTYPESC_H_ #include +#include #include "VXOpcodeTable.h" -namespace Verteron +#ifdef __cplusplus +extern "C" { +#endif /** * @brief Values that represent additional flags of a decoded instruction. */ -enum InstructionFlags : uint32_t +typedef enum _VXInstructionFlags /* : uint32_t */ { IF_NONE = 0x00000000, /** @@ -122,149 +127,157 @@ enum InstructionFlags : uint32_t /** * @brief An error occured while decoding the instruction operands. */ - IF_ERROR_OPERAND = 0x01000000 -}; + IF_ERROR_OPERAND = 0x01000000, + + IF_FORCE_DWORD = 0x7FFFFFFF +} VXInstructionFlags; /** * @brief Values that represent a cpu register. */ -enum class VXRegister : uint16_t +typedef enum _VXRegister /* : uint16_t */ { - NONE, + REG_NONE, /* 8 bit general purpose registers */ - AL, CL, DL, BL, - AH, CH, DH, BH, - SPL, BPL, SIL, DIL, - R8B, R9B, R10B, R11B, - R12B, R13B, R14B, R15B, + REG_AL, REG_CL, REG_DL, REG_BL, + REG_AH, REG_CH, REG_DH, REG_BH, + REG_SPL, REG_BPL, REG_SIL, REG_DIL, + REG_R8B, REG_R9B, REG_R10B, REG_R11B, + REG_R12B, REG_R13B, REG_R14B, REG_R15B, /* 16 bit general purpose registers */ - AX, CX, DX, BX, - SP, BP, SI, DI, - R8W, R9W, R10W, R11W, - R12W, R13W, R14W, R15W, + REG_AX, REG_CX, REG_DX, REG_BX, + REG_SP, REG_BP, REG_SI, REG_DI, + REG_R8W, REG_R9W, REG_R10W, REG_R11W, + REG_R12W, REG_R13W, REG_R14W, REG_R15W, /* 32 bit general purpose registers */ - EAX, ECX, EDX, EBX, - ESP, EBP, ESI, EDI, - R8D, R9D, R10D, R11D, - R12D, R13D, R14D, R15D, + REG_EAX, REG_ECX, REG_EDX, REG_EBX, + REG_ESP, REG_EBP, REG_ESI, REG_EDI, + REG_R8D, REG_R9D, REG_R10D, REG_R11D, + REG_R12D, REG_R13D, REG_R14D, REG_R15D, /* 64 bit general purpose registers */ - RAX, RCX, RDX, RBX, - RSP, RBP, RSI, RDI, - R8, R9, R10, R11, - R12, R13, R14, R15, + REG_RAX, REG_RCX, REG_RDX, REG_RBX, + REG_RSP, REG_RBP, REG_RSI, REG_RDI, + REG_R8, REG_R9, REG_R10, REG_R11, + REG_R12, REG_R13, REG_R14, REG_R15, /* segment registers */ - ES, CS, SS, - DS, FS, GS, + REG_ES, REG_CS, REG_SS, + REG_DS, REG_FS, REG_GS, /* control registers */ - CR0, CR1, CR2, CR3, - CR4, CR5, CR6, CR7, - CR8, CR9, CR10, CR11, - CR12, CR13, CR14, CR15, + REG_CR0, REG_CR1, REG_CR2, REG_CR3, + REG_CR4, REG_CR5, REG_CR6, REG_CR7, + REG_CR8, REG_CR9, REG_CR10, REG_CR11, + REG_CR12, REG_CR13, REG_CR14, REG_CR15, /* debug registers */ - DR0, DR1, DR2, DR3, - DR4, DR5, DR6, DR7, - DR8, DR9, DR10, DR11, - DR12, DR13, DR14, DR15, + REG_DR0, REG_DR1, REG_DR2, REG_DR3, + REG_DR4, REG_DR5, REG_DR6, REG_DR7, + REG_DR8, REG_DR9, REG_DR10, REG_DR11, + REG_DR12, REG_DR13, REG_DR14, REG_DR15, /* mmx registers */ - MM0, MM1, MM2, MM3, - MM4, MM5, MM6, MM7, + REG_MM0, REG_MM1, REG_MM2, REG_MM3, + REG_MM4, REG_MM5, REG_MM6, REG_MM7, /* x87 registers */ - ST0, ST1, ST2, ST3, - ST4, ST5, ST6, ST7, + REG_ST0, REG_ST1, REG_ST2, REG_ST3, + REG_ST4, REG_ST5, REG_ST6, REG_ST7, /* extended multimedia registers */ - XMM0, XMM1, XMM2, XMM3, - XMM4, XMM5, XMM6, XMM7, - XMM8, XMM9, XMM10, XMM11, - XMM12, XMM13, XMM14, XMM15, + REG_XMM0, REG_XMM1, REG_XMM2, REG_XMM3, + REG_XMM4, REG_XMM5, REG_XMM6, REG_XMM7, + REG_XMM8, REG_XMM9, REG_XMM10, REG_XMM11, + REG_XMM12, REG_XMM13, REG_XMM14, REG_XMM15, /* 256 bit multimedia registers */ - YMM0, YMM1, YMM2, YMM3, - YMM4, YMM5, YMM6, YMM7, - YMM8, YMM9, YMM10, YMM11, - YMM12, YMM13, YMM14, YMM15, + REG_YMM0, REG_YMM1, REG_YMM2, REG_YMM3, + REG_YMM4, REG_YMM5, REG_YMM6, REG_YMM7, + REG_YMM8, REG_YMM9, REG_YMM10, REG_YMM11, + REG_YMM12, REG_YMM13, REG_YMM14, YMM15, /* instruction pointer register */ - RIP -}; + REG_RIP, + + REG_FORCE_WORD = 0x7FFF +} VXRegister; /** * @brief Values that represent the type of a decoded operand. */ -enum class VXOperandType : uint8_t +typedef enum _VXOperandType /*: uint8_t*/ { /** * @brief The operand is not used. */ - NONE, + OPTYPE_NONE, /** * @brief The operand is a register operand. */ - REGISTER, + OPTYPE_REGISTER, /** * @brief The operand is a memory operand. */ - MEMORY, + OPTYPE_MEMORY, /** * @brief The operand is a pointer operand. */ - POINTER, + OPTYPE_POINTER, /** * @brief The operand is an immediate operand. */ - IMMEDIATE, + OPTYPE_IMMEDIATE, /** * @brief The operand is a relative immediate operand. */ - REL_IMMEDIATE, + OPTYPE_REL_IMMEDIATE, /** * @brief The operand is a constant value. */ - CONSTANT -}; + OPTYPE_CONSTANT +} VXOperandType; /** * @brief Values that represent the operand access mode. */ -enum class VXOperandAccessMode : uint8_t +typedef enum _VXOperandAccessMode /* : uint8_t */ { - NA, + OPACCESSMODE_NA, /** * @brief The operand is accessed in read-only mode. */ - READ, + OPACCESSMODE_READ, /** * @brief The operand is accessed in write mode. */ - WRITE, + OPACCESSMODE_WRITE, /** * @brief The operand is accessed in read-write mode. */ - READWRITE -}; + OPACCESSMODE_READWRITE +} VXOperandAccessMode; /** * @brief This struct holds information about a decoded operand. */ -struct VXOperandInfo +typedef struct _VXOperandInfo { /** * @brief The type of the operand. + * @see VXOperandType */ - VXOperandType type; + uint8_t type; /** * @brief The size of the operand. */ uint16_t size; /** * @brief The operand access mode. + * @see VXOperandAccessMode */ - VXOperandAccessMode access_mode; + uint8_t access_mode; /** * @brief The base register. + * @see VXRegister */ - VXRegister base; + uint16_t base; /** * @brief The index register. + * @see VXRegister */ - VXRegister index; + uint16_t index; /** * @brief The scale factor. */ @@ -295,12 +308,12 @@ struct VXOperandInfo uint32_t off; } ptr; } lval; -}; +} VXOperandInfo; /** * @brief This struct holds information about a decoded instruction. */ -struct VXInstructionInfo +typedef struct _VXInstructionInfo { /** * @brief The instruction flags. @@ -308,8 +321,9 @@ struct VXInstructionInfo uint32_t flags; /** * @brief The instruction mnemonic. + * @see VXInstructionMnemonic */ - VXInstructionMnemonic mnemonic; + uint16_t mnemonic; /** * @brief The total length of the instruction. */ @@ -341,8 +355,9 @@ struct VXInstructionInfo /** * @brief The segment register. This value will default to @c NONE, if no segment register * prefix is present. + * @see VXRegister */ - VXRegister segment; + uint16_t segment; /** * @brief The rex prefix byte. */ @@ -524,6 +539,10 @@ struct VXInstructionInfo * This field is used to properly format relative instructions. */ uint64_t instrPointer; -}; +} VXInstructionInfo; +#ifdef __cplusplus } +#endif + +#endif /* _VDE_VXDISASSEMBLERTYPESC_H_ */ \ No newline at end of file diff --git a/Bindings/C/VXDisassemblerUtilsC.c b/VerteronDisassemblerEngine/VXDisassemblerUtils.c similarity index 98% rename from Bindings/C/VXDisassemblerUtilsC.c rename to VerteronDisassemblerEngine/VXDisassemblerUtils.c index 9ef2bbb..5c392a7 100644 --- a/Bindings/C/VXDisassemblerUtilsC.c +++ b/VerteronDisassemblerEngine/VXDisassemblerUtils.c @@ -30,7 +30,7 @@ **************************************************************************************************/ -#include "VXDisassemblerUtilsC.h" +#include "VXDisassemblerUtils.h" #include diff --git a/VerteronDisassemblerEngine/VXDisassemblerUtils.h b/VerteronDisassemblerEngine/VXDisassemblerUtils.h index e62d9b1..d259d36 100644 --- a/VerteronDisassemblerEngine/VXDisassemblerUtils.h +++ b/VerteronDisassemblerEngine/VXDisassemblerUtils.h @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : + Modifications : athre0z - Last change : 30. October 2014 + Last change : 04. February 2015 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,13 +29,26 @@ * SOFTWARE. **************************************************************************************************/ -#pragma once + +#ifndef _VDE_VXDISASSEMBLERUTILSC_H_ +#define _VDE_VXDISASSEMBLERUTILSC_H_ + +#include "VXDisassemblerTypes.h" +#include "VXInternalConfig.h" #include -#include "VXDisassemblerTypes.h" -namespace Verteron + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _VXContextDescriptor +{ + uint8_t type; + void *ptr; +} VXContextDescriptor; /** * @brief Calculates the absolute target address of a relative instruction operand. @@ -43,6 +56,12 @@ namespace Verteron * @param operand The operand. * @return The absolute target address. */ -uint64_t VDECalcAbsoluteTarget(const VXInstructionInfo &info, const VXOperandInfo &operand); +VX_EXPORT uint64_t VXCalcAbsoluteTarget( + const VXInstructionInfo *info, + const VXOperandInfo *operand); +#ifdef __cplusplus } +#endif + +#endif /* _VDE_VXDISASSEMBLERUTILSC_H_ */ \ No newline at end of file diff --git a/Bindings/C/VXInstructionDecoderC.c b/VerteronDisassemblerEngine/VXInstructionDecoder.c similarity index 99% rename from Bindings/C/VXInstructionDecoderC.c rename to VerteronDisassemblerEngine/VXInstructionDecoder.c index 7b2f675..51a10bd 100644 --- a/Bindings/C/VXInstructionDecoderC.c +++ b/VerteronDisassemblerEngine/VXInstructionDecoder.c @@ -30,9 +30,9 @@ **************************************************************************************************/ -#include "VXInstructionDecoderC.h" -#include "VXInternalHelpersC.h" -#include "VXOpcodeTableInternalC.h" +#include "VXInstructionDecoder.h" +#include "VXInternalHelpers.h" +#include "VXOpcodeTableInternal.h" #include #include @@ -1605,7 +1605,8 @@ static bool VXInstructionDecoder_DecodeOpcode(VXInstructionDecoderContext *ctx, if (info->instrDefinition->flags & IDF_OPERAND1_WRITE) { info->operand[0].access_mode = OPACCESSMODE_WRITE; - } else if (info->instrDefinition->flags & IDF_OPERAND1_READWRITE) + } + else if (info->instrDefinition->flags & IDF_OPERAND1_READWRITE) { info->operand[0].access_mode = OPACCESSMODE_READWRITE; } @@ -1615,7 +1616,8 @@ static bool VXInstructionDecoder_DecodeOpcode(VXInstructionDecoderContext *ctx, if (info->instrDefinition->flags & IDF_OPERAND2_WRITE) { info->operand[1].access_mode = OPACCESSMODE_WRITE; - } else if (info->instrDefinition->flags & IDF_OPERAND2_READWRITE) + } + else if (info->instrDefinition->flags & IDF_OPERAND2_READWRITE) { info->operand[1].access_mode = OPACCESSMODE_READWRITE; } @@ -1654,7 +1656,8 @@ static bool VXInstructionDecoder_DecodeOpcode(VXInstructionDecoderContext *ctx, // Set child node index for next iteration index = info->vex_m_mmmm + (info->vex_pp << 2); - } else + } + else { index = 0; } @@ -1672,6 +1675,7 @@ static bool VXInstructionDecoder_DecodeOpcode(VXInstructionDecoderContext *ctx, } node = VXGetOpcodeTreeChild(node, index); } while (nodeType != OTNT_INSTRUCTION_DEFINITION); + return false; } diff --git a/VerteronDisassemblerEngine/VXInstructionDecoder.h b/VerteronDisassemblerEngine/VXInstructionDecoder.h index 70b02c5..c19efc0 100644 --- a/VerteronDisassemblerEngine/VXInstructionDecoder.h +++ b/VerteronDisassemblerEngine/VXInstructionDecoder.h @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : + Modifications : athre0z - Last change : 29. October 2014 + Last change : 14. March 2015 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,690 +29,276 @@ * SOFTWARE. **************************************************************************************************/ -#pragma once -#include -#include +#ifndef _VDE_VXINSTRUCTIONDECODERC_H_ +#define _VDE_VXINSTRUCTIONDECODERC_H_ + #include "VXDisassemblerTypes.h" +#include "VXDisassemblerUtils.h" -namespace Verteron +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif -/////////////////////////////////////////////////////////////////////////////////////////////////// +/* VXBaseDataSource ============================================================================ */ + +typedef struct _VXBaseDataSourceContext { VXContextDescriptor d; } VXBaseDataSourceContext; /** - * @brief The base class for all data-source implementations. + * @brief Releases a data source. + * @param ctx The context to release. + * The context may no longer be used after it was released. */ -class VXBaseDataSource -{ -private: - uint8_t m_currentInput; -protected: - /** - * @brief Override this method in your custom data source implementations. - * Reads the next byte from the data source. This method increases the current - * input position by one. - * @return The current input byte. - */ - virtual uint8_t internalInputPeek() = 0; - /** - * @brief Override this method in your custom data source implementations. - * Reads the next byte from the data source. This method does NOT increase the - * current input position. - * @return The current input byte. - */ - virtual uint8_t internalInputNext() = 0; -protected: - /** - * @brief Default constructor. - */ - VXBaseDataSource() { }; -public: - /** - * @brief Destructor. - */ - virtual ~VXBaseDataSource() { }; -public: - /** - * @brief Reads the next byte from the data source. This method does NOT increase the - * current input position or the @c length field of the @c info parameter. - * @param info The instruction info. - * @return The current input byte. If the result is zero, you should always check the - * @c flags field of the @c info parameter for error flags. - * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. - */ - uint8_t inputPeek(VXInstructionInfo &info); - /** - * @brief Reads the next byte from the data source. This method increases the current - * input position and the @c length field of the @c info parameter. - * This method also appends the new byte to to @c data field of the @c info - * parameter. - * @param info The instruction info. - * @return The current input byte. If the result is zero, you should always check the - * @c flags field of the @c info parameter for error flags. - * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. - */ - uint8_t inputNext(VXInstructionInfo &info); - /** - * @brief Reads the next byte(s) from the data source. This method increases the current - * input position and the @c length field of the @c info parameter. - * This method also appends the new byte(s) to to @c data field of the @c info - * parameter. - * @param info The instruction info. - * @return The current input data. If the result is zero, you should always check the - * @c flags field of the @c info parameter for error flags. - * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. - */ - template - T inputNext(VXInstructionInfo &info); - /** - * @brief Returns the current input byte. The current input byte is set everytime the - * @c inputPeek or @c inputNext method is called. - * @return The current input byte. - */ - uint8_t inputCurrent() const; -public: - /** - * @brief Override this method in your custom data source implementations. - * Signals, if the end of the data source is reached. - * @return True if end of input, false if not. - */ - virtual bool isEndOfInput() const = 0; - /** - * @brief Override this method in your custom data source implementations. - * Returns the current input position. - * @return The current input position. - */ - virtual uint64_t getPosition() const = 0; - /** - * @brief Override this method in your custom data source implementations. - * Sets a new input position. - * @param position The new input position. - * @return Returns false, if the new position exceeds the maximum input length. - */ - virtual bool setPosition(uint64_t position) = 0; -}; - -inline uint8_t VXBaseDataSource::inputPeek(VXInstructionInfo &info) -{ - if (info.length == 15) - { - info.flags |= IF_ERROR_LENGTH; - return 0; - } - if (isEndOfInput()) - { - info.flags |= IF_ERROR_END_OF_INPUT; - return 0; - } - m_currentInput = internalInputPeek(); - return m_currentInput; -} - -inline uint8_t VXBaseDataSource::inputNext(VXInstructionInfo &info) -{ - if (info.length == 15) - { - info.flags |= IF_ERROR_LENGTH; - return 0; - } - if (isEndOfInput()) - { - info.flags |= IF_ERROR_END_OF_INPUT; - return 0; - } - m_currentInput = internalInputNext(); - info.data[info.length] = m_currentInput; - info.length++; - return m_currentInput; -} - -template -inline T VXBaseDataSource::inputNext(VXInstructionInfo &info) -{ - static_assert(std::is_integral::value, "integral type required"); - T result = 0; - for (unsigned i = 0; i < (sizeof(T) / sizeof(uint8_t)); ++i) - { - T b = inputNext(info); - if (!b && (info.flags & IF_ERROR_MASK)) - { - return 0; - } - result |= (b << (i * 8)); - } - return result; -} - -inline uint8_t VXBaseDataSource::inputCurrent() const -{ - return m_currentInput; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// +VX_EXPORT void VXBaseDataSource_Release( + VXBaseDataSourceContext *ctx); /** - * @brief A memory-buffer based data source for the @c VXInstructionDecoder class. + * @brief Reads the next byte from the data source without altering the current input position + * or the @c length field of the @c info parameter. + * @param ctx The data source context. + * @param info The instruction info struct. + * @return The current input byte. If the result is zero, you should always check the @c flags + * field of the @c info parameter for error flags. Possible error values are + * @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. */ -class VXMemoryDataSource : public VXBaseDataSource -{ -private: - const void *m_inputBuffer; - uint64_t m_inputBufferLen; - uint64_t m_inputBufferPos; -protected: - /** - * @brief Reads the next byte from the data source. This method increases the current - * input position by one. - * @return The current input byte. - */ - uint8_t internalInputPeek() override; - /** - * @brief Reads the next byte from the data source. This method does NOT increase the - * current input position. - * @return The current input byte. - */ - uint8_t internalInputNext() override; -public: - /** - * @brief Constructor. - * @param buffer The input buffer. - * @param bufferLen The length of the input buffer. - */ - VXMemoryDataSource(const void* buffer, size_t bufferLen) - : m_inputBuffer(buffer) - , m_inputBufferLen(bufferLen) - , m_inputBufferPos(0) { }; -public: - /** - * @brief Signals, if the end of the data source is reached. - * @return True if end of input, false if not. - */ - bool isEndOfInput() const override; - /** - * @brief Returns the current input position. - * @return The current input position. - */ - uint64_t getPosition() const override; - /** - * @brief Sets a new input position. - * @param position The new input position. - * @return Returns false, if the new position exceeds the maximum input length. - */ - bool setPosition(uint64_t position) override; -}; - -inline uint8_t VXMemoryDataSource::internalInputPeek() -{ - return *(static_cast(m_inputBuffer) + m_inputBufferPos); -} - -inline uint8_t VXMemoryDataSource::internalInputNext() -{ - ++m_inputBufferPos; - return *(static_cast(m_inputBuffer) + m_inputBufferPos - 1); -} - -inline bool VXMemoryDataSource::isEndOfInput() const -{ - return (m_inputBufferPos >= m_inputBufferLen); -} - -inline uint64_t VXMemoryDataSource::getPosition() const -{ - return m_inputBufferPos; -} - -inline bool VXMemoryDataSource::setPosition(uint64_t position) -{ - m_inputBufferPos = position; - return isEndOfInput(); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// +VX_EXPORT uint8_t VXBaseDataSource_InputPeek( + VXBaseDataSourceContext *ctx, + VXInstructionInfo *info); /** - * @brief A stream based data source for the @c VXInstructionDecoder class. + * @brief Reads the next byte from the data source. + * @param ctx The data soruce context. + * @param info The instruction info. + * @return The current input byte. If the result is zero, you should always check the + * @c flags field of the @c info parameter for error flags. + * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. + * This method increases the current input position and the @c length field of the @c info + * parameter. This function also appends the new byte to to @c data field of the @c info + * parameter. + */ +VX_EXPORT uint8_t VXBaseDataSource_InputNext8( + VXBaseDataSourceContext *ctx, + VXInstructionInfo *info); + +/** + * @copydoc VXBaseDataSource_InputNext8 */ -class VXStreamDataSource : public VXBaseDataSource -{ -private: - std::istream *m_inputStream; -protected: - /** - * @brief Reads the next byte from the data source. This method increases the current - * input position by one. - * @return The current input byte. - */ - uint8_t internalInputPeek() override; - /** - * @brief Reads the next byte from the data source. This method does NOT increase the - * current input position. - * @return The current input byte. - */ - uint8_t internalInputNext() override; -public: - /** - * @brief Constructor. - * @param stream The input stream. - */ - explicit VXStreamDataSource(std::istream *stream) - : m_inputStream(stream) { }; -public: - /** - * @brief Signals, if the end of the data source is reached. - * @return True if end of input, false if not. - */ - bool isEndOfInput() const override; - /** - * @brief Returns the current input position. - * @return The current input position. - */ - uint64_t getPosition() const override; - /** - * @brief Sets a new input position. - * @param position The new input position. - * @return Returns false, if the new position exceeds the maximum input length. - */ - bool setPosition(uint64_t position) override; -}; +VX_EXPORT uint16_t VXBaseDataSource_InputNext16( + VXBaseDataSourceContext *ctx, + VXInstructionInfo *info); -inline uint8_t VXStreamDataSource::internalInputPeek() -{ - if (!m_inputStream) - { - return 0; - } - return m_inputStream->peek(); -} +/** + * @copydoc VXBaseDataSource_InputNext8 + */ +VX_EXPORT uint32_t VXBaseDataSource_InputNext32( + VXBaseDataSourceContext *ctx, + VXInstructionInfo *info); -inline uint8_t VXStreamDataSource::internalInputNext() -{ - if (!m_inputStream) - { - return 0; - } - return m_inputStream->get(); -} +/** + * @copydoc VXBaseDataSource_InputNext8 + */ +VX_EXPORT uint64_t VXBaseDataSource_InputNext64( + VXBaseDataSourceContext *ctx, + VXInstructionInfo *info); -inline bool VXStreamDataSource::isEndOfInput() const -{ - if (!m_inputStream) - { - return true; - } - // We use good() instead of eof() to make sure the decoding will fail, if an stream internal - // error occured. - return !m_inputStream->good(); -} +/** + * @brief Returns the current input byte. + * @param ctx The data soruce context. + * @return The current input byte. + * The current input byte is set everytime the @c inputPeek or @c inputNext method is called. + */ +// TODO: check long descr +VX_EXPORT uint8_t VXBaseDataSource_InputCurrent( + const VXBaseDataSourceContext *ctx); -inline uint64_t VXStreamDataSource::getPosition() const -{ - if (!m_inputStream) - { - return 0; - } - return m_inputStream->tellg(); -} +/** + * @brief Queries if the end of the data source is reached. + * @param ctx The data soruce context. + * @return @c true if end of input, @c false if not. + */ +VX_EXPORT bool VXBaseDataSource_IsEndOfInput( + const VXBaseDataSourceContext *ctx); -inline bool VXStreamDataSource::setPosition(uint64_t position) -{ - if (!m_inputStream) - { - return false; - } - m_inputStream->seekg(position); - return isEndOfInput(); -} +/** + * @brief Returns the current input position. + * @param ctx The data soruce context. + * @return The current input position. + */ +VX_EXPORT uint64_t VXBaseDataSource_GetPosition( + const VXBaseDataSourceContext *ctx); -/////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Sets a new input position. + * @param ctx The data soruce context. + * @param position The new input position. + * @return @c false if the new position exceeds the maximum input length. + */ +VX_EXPORT bool VXBaseDataSource_SetPosition( + VXBaseDataSourceContext *ctx, + uint64_t position); + +/* VXMemoryDataSource ========================================================================== */ + +/** + * @brief Creates a memory data source. + * @param buffer The input buffer. + * @param bufferLen THe length of the input buffer. + * @return @c NULL if it fails, else a data source context. + * @see VXBaseDataSource_Release + */ +// TODO: verify return value +VX_EXPORT VXBaseDataSourceContext* VXMemoryDataSource_Create( + const void* buffer, + size_t bufferLen); + +/* Enums ======================================================================================= */ /** * @brief Values that represent a disassembler mode. */ -enum class VXDisassemblerMode : uint8_t +typedef enum _VXDisassemblerMode /* : uint8_t */ { - M16BIT, - M32BIT, - M64BIT -}; + DM_M16BIT, + DM_M32BIT, + DM_M64BIT +} VXDisassemblerMode; /** * @brief Values that represent an instruction-set vendor. */ -enum class VXInstructionSetVendor : uint8_t +typedef enum _VXInstructionSetVendor /* : uint8_t */ { - ANY, - INTEL, - AMD -}; + ISV_ANY, + ISV_INTEL, + ISV_AMD +} VXInstructionSetVendor; + +/* VXInstructionDecoder ======================================================================== */ + +typedef struct _VXInstructionDecoderContext +{ + VXContextDescriptor d; +} VXInstructionDecoderContext; /** - * @brief The @c VXInstructionDecoder class decodes x86/x86-64 assembly instructions from a - * given data source. + * @brief Creates an instruction decoder. + * @return @c NULL if it fails, else an instruction decoder context. + * @see VXInstructionDecoder_Release */ -class VXInstructionDecoder -{ -private: - enum class RegisterClass : uint8_t - { - GENERAL_PURPOSE, - MMX, - CONTROL, - DEBUG, - SEGMENT, - XMM - }; -private: - VXBaseDataSource *m_dataSource; - VXDisassemblerMode m_disassemblerMode; - VXInstructionSetVendor m_preferredVendor; - uint64_t m_instructionPointer; -private: - /** - * @brief Reads the next byte from the data source. This method does NOT increase the - * current input position or the @c length field of the @c info parameter. - * @param info The instruction info. - * @return The current input byte. If the result is zero, you should always check the - * @c flags field of the @c info parameter for error flags. - * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. - */ - uint8_t inputPeek(VXInstructionInfo &info); - /** - * @brief Reads the next byte from the data source. This method increases the current - * input position and the @c length field of the @info parameter. - * This method also appends the new byte to to @c data field of the @c info - * parameter. - * @param info The instruction info. - * @return The current input byte. If the result is zero, you should always check the - * @c flags field of the @c info parameter for error flags. - * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. - */ - uint8_t inputNext(VXInstructionInfo &info); - /** - * @brief Reads the next byte(s) from the data source. This method increases the current - * input position and the @c length field of the @info parameter. - * This method also appends the new byte(s) to to @c data field of the @c info - * parameter. - * @param info The instruction info. - * @return The current input data. If the result is zero, you should always check the - * @c flags field of the @c info parameter for error flags. - * Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. - */ - template - T inputNext(VXInstructionInfo &info); - /** - * @brief Returns the current input byte. The current input byte is set everytime the - * @c inputPeek or @c inputNext method is called. - * @return The current input byte. - */ - uint8_t inputCurrent() const; -private: - /** - * @brief Decodes a register operand. - * @param info The instruction info. - * @param operand The @c VXOperandInfo struct that receives the decoded data. - * @param registerClass The register class to use. - * @param registerId The register id. - * @param operandSize The defined size of the operand. - * @return True if it succeeds, false if it fails. - */ - bool decodeRegisterOperand(VXInstructionInfo &info, VXOperandInfo &operand, - RegisterClass registerClass, uint8_t registerId, VXDefinedOperandSize operandSize) const; - /** - * @brief Decodes a register/memory operand. - * @param info The instruction info. - * @param operand The @c VXOperandInfo struct that receives the decoded data. - * @param registerClass The register class to use. - * @param operandSize The defined size of the operand. - * @return True if it succeeds, false if it fails. - */ - bool decodeRegisterMemoryOperand(VXInstructionInfo &info, VXOperandInfo &operand, - RegisterClass registerClass, VXDefinedOperandSize operandSize); - /** - * @brief Decodes an immediate operand. - * @param info The instruction info. - * @param operand The @c VXOperandInfo struct that receives the decoded data. - * @param operandSize The defined size of the operand. - * @return True if it succeeds, false if it fails. - */ - bool decodeImmediate(VXInstructionInfo &info, VXOperandInfo &operand, - VXDefinedOperandSize operandSize); - /** - * @brief Decodes a displacement operand. - * @param info The instruction info. - * @param operand The @c VXOperandInfo struct that receives the decoded data. - * @param size The size of the displacement data. - * @return True if it succeeds, false if it fails. - */ - bool decodeDisplacement(VXInstructionInfo &info, VXOperandInfo &operand, uint8_t size); -private: - /** - * @brief Decodes the modrm field of the instruction. This method reads an additional - * input byte. - * @param The @c VXInstructionInfo struct that receives the decoded data. - * @return True if it succeeds, false if it fails. - */ - bool decodeModrm(VXInstructionInfo &info); - /** - * @brief Decodes the sib field of the instruction. This method reads an additional - * input byte. - * @param info The @c VXInstructionInfo struct that receives the decoded data. - * @return True if it succeeds, false if it fails. - */ - bool decodeSIB(VXInstructionInfo &info); - /** - * @brief Decodes vex prefix of the instruction. This method takes the current input byte - * to determine the vex prefix type and reads one or two additional input bytes - * on demand. - * @param info The @c VXInstructionInfo struct that receives the decoded data. - * @return True if it succeeds, false if it fails. - */ - bool decodeVex(VXInstructionInfo &info); -private: - /** - * @brief Returns the effective operand size. - * @param info The instruction info. - * @param operandSize The defined operand size. - * @return The effective operand size. - */ - uint16_t getEffectiveOperandSize(const VXInstructionInfo &info, - VXDefinedOperandSize operandSize) const; - /** - * @brief Decodes all instruction operands. - * @param info The @c VXInstructionInfo struct that receives the decoded data. - * @return True if it succeeds, false if it fails. - */ - bool decodeOperands(VXInstructionInfo &info); - /** - * @brief Decodes the specified instruction operand. - * @param info The instruction info. - * @param operand The @c VXOperandInfo struct that receives the decoded data. - * @param operandType The defined type of the operand. - * @param operandSize The defined size of the operand. - * @return True if it succeeds, false if it fails. - */ - bool decodeOperand(VXInstructionInfo &info, VXOperandInfo &operand, - VXDefinedOperandType operandType, VXDefinedOperandSize operandSize); -private: - /** - * @brief Resolves the effective operand and address mode of the instruction. - * This method requires a non-null value in the @c instrDefinition field of the - * @c info struct. - * @param info The @c VXInstructionInfo struct that receives the effective operand and - * address mode. - */ - void resolveOperandAndAddressMode(VXInstructionInfo &info) const; - /** - * @brief Calculates the effective REX/VEX.w, r, x, b, l values. - * This method requires a non-null value in the @c instrDefinition field of the - * @c info struct. - * @param info The @c VXInstructionInfo struct that receives the effective operand and - * address mode. - */ - void calculateEffectiveRexVexValues(VXInstructionInfo &info) const; -private: - /** - * @brief Collects and decodes optional instruction prefixes. - * @param info The @c VXInstructionInfo struct that receives the decoded data. - * @return True if it succeeds, false if it fails. - */ - bool decodePrefixes(VXInstructionInfo &info); - /** - * @brief Collects and decodes the instruction opcodes using the opcode tree. - * @param info The @c VXInstructionInfo struct that receives the decoded data. - * @return True if it succeeds, false if it fails. - */ - bool decodeOpcode(VXInstructionInfo &info); -public: - /** - * @brief Default constructor. - */ - VXInstructionDecoder(); - /** - * @brief Constructor. - * @param input A reference to the input data source. - * @param disassemblerMode The disasasembler mode. - * @param preferredVendor The preferred instruction-set vendor. - * @param instructionPointer The initial instruction pointer. - */ - explicit VXInstructionDecoder(VXBaseDataSource *input, - VXDisassemblerMode disassemblerMode = VXDisassemblerMode::M32BIT, - VXInstructionSetVendor preferredVendor = VXInstructionSetVendor::ANY, - uint64_t instructionPointer = 0); -public: - /** - * @brief Decodes the next instruction from the input data source. - * @param info The @c VXInstructionInfo struct that receives the information about the - * decoded instruction. - * @return This method returns false, if the current position has exceeded the maximum input - * length. - * In all other cases (valid and invalid instructions) the return value is true. - */ - bool decodeInstruction(VXInstructionInfo &info); -public: - /** - * @brief Returns a pointer to the current data source. - * @return A pointer to the current data source. - */ - VXBaseDataSource* getDataSource() const; - /** - * @brief Sets a new data source. - * @param input A reference to the new input data source. - */ - void setDataSource(VXBaseDataSource *input); - /** - * @brief Returns the current disassembler mode. - * @return The current disassembler mode. - */ - VXDisassemblerMode getDisassemblerMode() const; - /** - * @brief Sets the current disassembler mode. - * @param disassemblerMode The new disassembler mode. - */ - void setDisassemblerMode(VXDisassemblerMode disassemblerMode); - /** - * @brief Returns the preferred instruction-set vendor. - * @return The preferred instruction-set vendor. - */ - VXInstructionSetVendor getPreferredVendor() const; - /** - * @brief Sets the preferred instruction-set vendor. - * @param preferredVendor The new preferred instruction-set vendor. - */ - void setPreferredVendor(VXInstructionSetVendor preferredVendor); - /** - * @brief Returns the current instruction pointer. - * @return The current instruction pointer. - */ - uint64_t getInstructionPointer() const; - /** - * @brief Sets a new instruction pointer. - * @param instructionPointer The new instruction pointer. - */ - void setInstructionPointer(uint64_t instructionPointer); -}; +// TODO: verify return value +VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_Create(void); -inline uint8_t VXInstructionDecoder::inputPeek(VXInstructionInfo &info) -{ - if (!m_dataSource) - { - info.flags |= IF_ERROR_END_OF_INPUT; - return 0; - } - return m_dataSource->inputPeek(info); +/** + * @brief Creates an instruction decoder. + * @param input A reference to the input data source. + * @param disassemblerMode The disassembler mode. + * @param preferredVendor The preferred instruction-set vendor. + * @param instructionPointer The initial instruction pointer. + * @return @c NULL if it fails, else an instruction decoder context. + * @see VXInstructionDecoder_Release + */ +VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_CreateEx( + VXBaseDataSourceContext *input, + VXDisassemblerMode disassemblerMode, + VXInstructionSetVendor preferredVendor, + uint64_t instructionPointer); + +/** + * @brief Releases an instruction decoder. + * @param ctx The context of the instruction decoder to release. + */ +VX_EXPORT void VXInstructionDecoder_Release( + VXInstructionDecoderContext *ctx); + +/** + * @brief Decodes the next instruction from the input data source. + * @param ctx The instruction decoder context. + * @param info The @c VXInstructionInfo struct that receives the information about the decoded + * instruction. + * @return This function returns @c false if the current position exceeds the maximum input + * length. In all other cases (valid and invalid instructions) the return value is + * @c true. + */ +VX_EXPORT bool VXInstructionDecoder_DecodeInstruction( + VXInstructionDecoderContext *ctx, + VXInstructionInfo *info); + +/** + * @brief Returns a pointer to the current data source. + * @param ctx The instruction decoder context. + * @return The context of the data source. + */ +VX_EXPORT VXBaseDataSourceContext* VXInstructionDecoder_GetDataSource( + const VXInstructionDecoderContext *ctx); + +/** + * @brief Sets a new data source. + * @param ctx The instruction decoder context. + * @param input The context of the new input data source. + */ +VX_EXPORT void VXInstructionDecoder_SetDataSource( + VXInstructionDecoderContext *ctx, + VXBaseDataSourceContext *input); + +/** + * @brief Returns the current disassembler mode. + * @param ctx The instruction decoder context. + * @return The current disassembler mode. + */ +VX_EXPORT VXDisassemblerMode VXInstructionDecoder_GetDisassemblerMode( + const VXInstructionDecoderContext *ctx); + +/** + * @brief Sets the current disassembler mode. + * @param ctx The instruction decoder context. + * @param disassemblerMode The new disassembler mode. + */ +VX_EXPORT void VXInstructionDecoder_SetDisassemblerMode( + VXInstructionDecoderContext *ctx, + VXDisassemblerMode disassemblerMode); + +/** + * @brief Returns the preferred instruction-set vendor. + * @param ctx The instruction decoder context. + * @return The preferred instruction-set vendor. + */ +VX_EXPORT VXInstructionSetVendor VXInstructionDecoder_GetPreferredVendor( + const VXInstructionDecoderContext *ctx); + +/** + * @brief Sets the preferred instruction-set vendor. + * @param ctx The instruction decoder context. + * @param preferredVendor The new preferred instruction-set vendor. + */ +VX_EXPORT void VXInstructionDecoder_SetPreferredVendor( + VXInstructionDecoderContext *ctx, + VXInstructionSetVendor preferredVendor); + +/** + * @brief Returns the current instruction pointer. + * @param ctx The instruction decoder context. + * @return The current instruction pointer. + */ +VX_EXPORT uint64_t VXInstructionDecoder_GetInstructionPointer( + const VXInstructionDecoderContext *ctx); + +/** + * @brief Sets a new instruction pointer. + * @param ctx The instruction decoder context. + * @param instructionPointer The new instruction pointer. + */ +VX_EXPORT void VXInstructionDecoder_SetInstructionPointer( + VXInstructionDecoderContext *ctx, + uint64_t instructionPointer); + +/* ============================================================================================= */ + +#ifdef __cplusplus } +#endif -inline uint8_t VXInstructionDecoder::inputNext(VXInstructionInfo &info) -{ - if (!m_dataSource) - { - info.flags |= IF_ERROR_END_OF_INPUT; - return 0; - } - return m_dataSource->inputNext(info); -} - -template -inline T VXInstructionDecoder::inputNext(VXInstructionInfo &info) -{ - if (!m_dataSource) - { - info.flags |= IF_ERROR_END_OF_INPUT; - return 0; - } - return m_dataSource->inputNext(info); -} - -inline uint8_t VXInstructionDecoder::inputCurrent() const -{ - if (!m_dataSource) - { - return 0; - } - return m_dataSource->inputCurrent(); -} - -inline VXBaseDataSource* VXInstructionDecoder::getDataSource() const -{ - return m_dataSource; -} - -inline void VXInstructionDecoder::setDataSource(VXBaseDataSource *input) -{ - m_dataSource = input; -} - -inline VXDisassemblerMode VXInstructionDecoder::getDisassemblerMode() const -{ - return m_disassemblerMode; -} - -inline void VXInstructionDecoder::setDisassemblerMode(VXDisassemblerMode disassemblerMode) -{ - m_disassemblerMode = disassemblerMode; -} - -inline VXInstructionSetVendor VXInstructionDecoder::getPreferredVendor() const -{ - return m_preferredVendor; -} - -inline void VXInstructionDecoder::setPreferredVendor(VXInstructionSetVendor preferredVendor) -{ - m_preferredVendor = preferredVendor; -} - -inline uint64_t VXInstructionDecoder::getInstructionPointer() const -{ - return m_instructionPointer; -} - -inline void VXInstructionDecoder::setInstructionPointer(uint64_t instructionPointer) -{ - m_instructionPointer = instructionPointer; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - -} +#endif /* _VDE_VXINSTRUCTIONDECODERC_H_ */ diff --git a/Bindings/C/VXInstructionFormatterC.c b/VerteronDisassemblerEngine/VXInstructionFormatter.c similarity index 99% rename from Bindings/C/VXInstructionFormatterC.c rename to VerteronDisassemblerEngine/VXInstructionFormatter.c index 9af2ecb..9edd724 100644 --- a/Bindings/C/VXInstructionFormatterC.c +++ b/VerteronDisassemblerEngine/VXInstructionFormatter.c @@ -30,10 +30,10 @@ **************************************************************************************************/ -#include "VXInstructionFormatterC.h" -#include "VXDisassemblerUtilsC.h" -#include "VXInternalHelpersC.h" -#include "VXOpcodeTableInternalC.h" +#include "VXInstructionFormatter.h" +#include "VXDisassemblerUtils.h" +#include "VXInternalHelpers.h" +#include "VXOpcodeTableInternal.h" #include #include diff --git a/VerteronDisassemblerEngine/VXInstructionFormatter.h b/VerteronDisassemblerEngine/VXInstructionFormatter.h index 762eeab..43729e6 100644 --- a/VerteronDisassemblerEngine/VXInstructionFormatter.h +++ b/VerteronDisassemblerEngine/VXInstructionFormatter.h @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : + Modifications : athre0z - Last change : 22. October 2014 + Last change : 14. March 2015 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,292 +29,133 @@ * SOFTWARE. **************************************************************************************************/ -#pragma once -#include -#include -#include +#ifndef _VDE_VXINSTRUCTIONFORMATTERC_H_ +#define _VDE_VXINSTRUCTIONFORMATTERC_H_ + #include "VXDisassemblerTypes.h" +#include "VXDisassemblerUtils.h" -namespace Verteron +#ifdef __cplusplus +extern "C" { +#endif -/////////////////////////////////////////////////////////////////////////////////////////////////// +/* VXBaseSymbolResolver ======================================================================== */ + +typedef struct _VXBaseSymbolResolverContext +{ + VXContextDescriptor d; +} VXBaseSymbolResolverContext; /** - * @brief Base class for all symbol resolver implementations. + * @brief Releases a symbol resolver. + * @param ctx The context of the symbol resolver to free. + * The context may no longer used after it was released. */ -class VXBaseSymbolResolver -{ -public: - /** - * @brief Destructor. - */ - virtual ~VXBaseSymbolResolver(); -public: - /** - * @brief Resolves a symbol. - * @param info The instruction info. - * @param address The address. - * @param offset Reference to an unsigned 64 bit integer that receives an offset - * relative to the base address of the symbol. - * @return The name of the symbol, if the symbol was found, @c NULL if not. - */ - virtual const char* resolveSymbol(const VXInstructionInfo &info, uint64_t address, - uint64_t &offset); -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////// +VX_EXPORT void VXBaseSymbolResolver_Release( + VXBaseSymbolResolverContext *ctx); /** - * @brief Base class for all instruction formatter implementations. + * @brief Resolves a symbol. + * @param ctx The symbol resolver context. + * @param info The instruction info. + * @param address The address. + * @param offset Pointer to an unsigned 64 bit integer that receives an offset relative to + * the base address of the symbol. + * @return The name of the symbol if the symbol was found, else @c NULL. */ -class VXBaseInstructionFormatter -{ -private: - static const char *m_registerStrings[]; - VXBaseSymbolResolver *m_symbolResolver; - std::vector m_outputBuffer; - size_t m_outputStringLen; - bool m_outputUppercase; -protected: - /** - * @brief Clears the output string buffer. - */ - void outputClear(); - /** - * @brief Returns the content of the output string buffer. - * @return Pointer to the content of the ouput string buffer. - */ - const char* outputString(); - /** - * @brief Appends text to the ouput string buffer. - * @param text The text. - */ - void outputAppend(const char *text); - /** - * @brief Appends formatted text to the output string buffer. - * @param format The format string. - */ - void outputAppendFormatted(const char *format, ...); - /** - * @brief Changes automatic conversion of characters to uppercase. - * @param uppercase Set true to enable automatic uppercase conversion. - */ - void outputSetUppercase(bool uppercase); - /** - * @brief Appends a formatted address to the output string buffer. - * @param info The instruction info. - * @param address The address. - * @param resolveSymbols If this parameter is true, the method will try to display a - * smybol name instead of the numeric value. - */ - void outputAppendAddress(const VXInstructionInfo &info, uint64_t address, - bool resolveSymbols = true); - /** - * @brief Appends a formatted immediate value to the output string buffer. - * @param info The instruction info. - * @param operand The immediate operand. - * @param resolveSymbols If this parameter is true, the method will try to display a - * smybol name instead of the numeric value. - */ - void outputAppendImmediate(const VXInstructionInfo &info, const VXOperandInfo &operand, - bool resolveSymbols = false); - /** - * @brief Appends a formatted memory displacement value to the output string buffer. - * @param info The instruction info. - * @param operand The memory operand. - */ - void outputAppendDisplacement(const VXInstructionInfo &info, const VXOperandInfo &operand); -protected: - /** - * @brief Returns the string representation of a given register. - * @param reg The register. - * @return The string representation of the given register. - */ - const char* registerToString(VXRegister reg) const; - /** - * @brief Resolves a symbol. - * @param info The instruction info. - * @param address The address. - * @param offset Reference to an unsigned 64 bit integer that receives an offset - * relative to the base address of the symbol. - * @return The name of the symbol, if the symbol was found, @c NULL if not. - */ - const char* resolveSymbol(const VXInstructionInfo &info, uint64_t address, - uint64_t &offset) const; -protected: - /** - * @brief Override this method to implement a custom disassembly syntax. Use the - * @c outputAppend and @c outputAppendFormatted methods to fill the internal - * string buffer. - * @param info The instruction info. - */ - virtual void internalFormatInstruction(const VXInstructionInfo &info); - /** - * @brief Default constructor. - */ - VXBaseInstructionFormatter(); - /** - * @brief Constructor. - * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol - * resolver should be used. - */ - explicit VXBaseInstructionFormatter(VXBaseSymbolResolver *symbolResolver); -public: - /** - * @brief Destructor. - */ - virtual ~VXBaseInstructionFormatter(); -public: - /** - * @brief Formats a decoded instruction. - * @param info The instruction info. - * @return Pointer to the formatted instruction string. - */ - const char* formatInstruction(const VXInstructionInfo &info); -public: - /** - * @brief Returns a pointer to the current symbol resolver. - * @return Pointer to the current symbol resolver or @c NULL, if no symbol resolver is used. - */ - VXBaseSymbolResolver* getSymbolResolver() const; - /** - * @brief Sets a new symbol resolver. - * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol - * resolver should be used. - */ - void setSymbolResolver(VXBaseSymbolResolver *symbolResolver); -}; +VX_EXPORT const char* VXBaseSymbolResolver_ResolveSymbol( + VXBaseSymbolResolverContext *ctx, + const VXInstructionInfo *info, + uint64_t address, + uint64_t *offset); -inline void VXBaseInstructionFormatter::outputSetUppercase(bool uppercase) -{ - m_outputUppercase = uppercase; -} +/* VXCustomSymbolResolver ====================================================================== */ -inline char const* VXBaseInstructionFormatter::registerToString(VXRegister reg) const -{ - if (reg == VXRegister::NONE) - { - return "error"; - } - return m_registerStrings[static_cast(reg) - 1]; -} - -inline char const* VXBaseInstructionFormatter::resolveSymbol(const VXInstructionInfo &info, - uint64_t address, uint64_t &offset) const -{ - if (m_symbolResolver) - { - return m_symbolResolver->resolveSymbol(info, address, offset); - } - return nullptr; -} - -inline VXBaseSymbolResolver* VXBaseInstructionFormatter::getSymbolResolver() const -{ - return m_symbolResolver; -} - -inline void VXBaseInstructionFormatter::setSymbolResolver(VXBaseSymbolResolver *symbolResolver) -{ - m_symbolResolver = symbolResolver; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// +typedef const char* (*VXCustomSymbolResolver_ResolveSymbolCallback)( + const VXInstructionInfo *info, + uint64_t address, + uint64_t *offset, + void *userData); /** - * @brief Intel syntax instruction formatter. + * @brief Creates a custom symbol resolver. + * @param resolverCb The resolver callback consulted when symbols need to be resolved. + * @param userData A pointer to arbitrary data passed to the resolver callback. + * May also be @c NULL. + * @return @c NULL if it fails, else a symbol resolver context. */ -class VXIntelInstructionFormatter : public VXBaseInstructionFormatter -{ -private: - /** - * @brief Appends an operand cast to the output string buffer. - * @param info The instruction info. - * @param operand The operand. - */ - void outputAppendOperandCast(const VXInstructionInfo &info, const VXOperandInfo &operand); - /** - * @brief Formats the specified operand and appends the resulting string to the output - * buffer. - * @param info The instruction info. - * @param operand The operand. - */ - void formatOperand(const VXInstructionInfo &info, const VXOperandInfo &operand); -protected: - /** - * @brief Fills the internal string buffer with an intel style formatted instruction string. - * @param info The instruction info. - */ - void internalFormatInstruction(const VXInstructionInfo &info) override; -public: - /** - * @brief Default constructor. - */ - VXIntelInstructionFormatter(); - /** - * @brief Constructor. - * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol - * resolver should be used. - */ - explicit VXIntelInstructionFormatter(VXBaseSymbolResolver *symbolResolver); - /** - * @brief Destructor. - */ - ~VXIntelInstructionFormatter() override; -}; +VX_EXPORT VXBaseSymbolResolverContext* VXCustomSymbolResolver_Create( + VXCustomSymbolResolver_ResolveSymbolCallback resolverCb, + void *userData); -/////////////////////////////////////////////////////////////////////////////////////////////////// +/* VXBaseInstructionFormatter ================================================================== */ + +typedef struct _VXBaseInstructionFormatterContext +{ + VXContextDescriptor d; +} VXBaseInstructionFormatterContext; /** - * @brief Simple symbol resolver that only matches exact addresses. + * @brief Formats a decoded instruction. + * @param ctx The instruction formatter context. + * @param info The instruction info. + * @return Pointer to the formatted instruction string. This pointer remains valid until + * this function is called again or the context is released. */ -class VXExactSymbolResolver : public VXBaseSymbolResolver -{ -private: - std::unordered_map m_symbolMap; -public: - /** - * @brief Destructor. - */ - ~VXExactSymbolResolver() override; -public: - /** - * @brief Resolves a symbol. - * @param info The instruction info. - * @param address The address. - * @param offset Reference to an unsigned 64 bit integer that receives an offset - * relative to the base address of the symbol. - * @return The name of the symbol, if the symbol was found, @c NULL if not. - */ - const char* resolveSymbol(const VXInstructionInfo &info, uint64_t address, - uint64_t &offset) override; -public: - /** - * @brief Query if the given address is a known symbol. - * @param address The address. - * @return True if the address is known, false if not. - */ - bool containsSymbol(uint64_t address) const; - /** - * @brief Adds or changes a symbol. - * @param address The address. - * @param name The symbol name. - */ - void setSymbol(uint64_t address, const char* name); - /** - * @brief Removes the symbol described by address. This will invalidate all char pointers - * to the specific symbol name. - * @param address The address. - */ - void removeSymbol(uint64_t address); - /** - * @brief Clears the symbol tree. - */ - void clear(); -}; +VX_EXPORT const char* VXBaseInstructionFormatter_FormatInstruction( + VXBaseInstructionFormatterContext *ctx, + const VXInstructionInfo *info); -/////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Returns a pointer to the current symbol resolver. + * @param ctx The instruction formatter context. + * @return Pointer to the current symbol resolver or @c NULL if no symbol resolver is used. + */ +VX_EXPORT VXBaseSymbolResolverContext* VXBaseInstructionFormatter_GetSymbolResolver( + const VXBaseInstructionFormatterContext *ctx); +/** + * @brief Sets a new symbol resolver. + * @param ctx The instruction formatter context. + * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol + * resolver should be used. + */ +VX_EXPORT void VXBaseInstructionFormatter_SetSymbolResolver( + VXBaseInstructionFormatterContext *ctx, + VXBaseSymbolResolverContext *resolver); + +/** + * @brief Releases an instruction formatter. + * @param ctx The context of the instruction formatter to release. + * The context may no longer used after it has been released. + */ +VX_EXPORT void VXBaseInstructionFormatter_Release( + VXBaseInstructionFormatterContext *ctx); + +/* VXIntelInstructionFormatter ================================================================ */ + +/** + * @brief Creates an Intel-syntax instruction formatter. + * @return @c NULL if it fails, else an Intel instruction formatter context. + * @see VXBaseInstructionFormatter_Release + */ +VX_EXPORT VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_Create(void); + +/** + * @brief Creates an Intel-syntax instruction formatter. + * @param resolver The symbol resolver consulted to resolve symbols on formatting. + * @return @c NULL if it fails, else an Intel instruction formatter context. + * @see VXBaseInstructionFormatter_Release + */ +VX_EXPORT VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_CreateEx( + VXBaseSymbolResolverContext *resolver); + +/* ============================================================================================= */ + +#ifdef __cplusplus } +#endif + +#endif /* _VDE_VXINSTRUCTIONFORMATTERC_H_ */ \ No newline at end of file diff --git a/Bindings/C/VXInternalConfig.h b/VerteronDisassemblerEngine/VXInternalConfig.h similarity index 84% rename from Bindings/C/VXInternalConfig.h rename to VerteronDisassemblerEngine/VXInternalConfig.h index 260f008..536ed0c 100644 --- a/Bindings/C/VXInternalConfig.h +++ b/VerteronDisassemblerEngine/VXInternalConfig.h @@ -39,6 +39,14 @@ # define VX_INLINE extern inline #endif -#define VX_EXPORT +#ifdef VX_BUILD_SHARED /* set by CMake */ +# if defined(_MSC_VER) +# define VX_EXPORT __declspec(dllexport) +# elif defined(__GNUC__) || defined(__clang__) +# define VX_EXPORT __attribute__((dllexport)) +# endif +#else +# define VX_EXPORT +#endif #endif /* _VDE_VXINTERNALCONFIG_H_ */ \ No newline at end of file diff --git a/Bindings/C/VXInternalHelpersC.h b/VerteronDisassemblerEngine/VXInternalHelpers.h similarity index 98% rename from Bindings/C/VXInternalHelpersC.h rename to VerteronDisassemblerEngine/VXInternalHelpers.h index 0c63be2..9e17910 100644 --- a/Bindings/C/VXInternalHelpersC.h +++ b/VerteronDisassemblerEngine/VXInternalHelpers.h @@ -33,8 +33,8 @@ #ifndef _VDE_VXINTERNALHELPERS_H_ #define _VDE_VXINTERNALHELPERS_H_ -#include "VXInstructionDecoderC.h" -#include "VXInstructionFormatterC.h" +#include "VXInstructionDecoder.h" +#include "VXInstructionFormatter.h" #include "VXInternalConfig.h" #include diff --git a/Bindings/C/VXOpcodeTableC.c b/VerteronDisassemblerEngine/VXOpcodeTable.c similarity index 99% rename from Bindings/C/VXOpcodeTableC.c rename to VerteronDisassemblerEngine/VXOpcodeTable.c index c1a90ff..5a38d5e 100644 --- a/Bindings/C/VXOpcodeTableC.c +++ b/VerteronDisassemblerEngine/VXOpcodeTable.c @@ -30,7 +30,7 @@ **************************************************************************************************/ -#include "VXOpcodeTableC.h" +#include "VXOpcodeTable.h" #define VX_INVALID 0 #define VX_NODE(type, n) ((VXOpcodeTreeNode)type << 12 | (n)) diff --git a/VerteronDisassemblerEngine/VXOpcodeTable.h b/VerteronDisassemblerEngine/VXOpcodeTable.h index bf13060..f36cc41 100644 --- a/VerteronDisassemblerEngine/VXOpcodeTable.h +++ b/VerteronDisassemblerEngine/VXOpcodeTable.h @@ -6,9 +6,9 @@ Remarks : Freeware, Copyright must be included Original Author : Florian Bernd - Modifications : + Modifications : athre0z - Last change : 29. October 2014 + Last change : 04. February 2015 * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,925 +29,931 @@ * SOFTWARE. **************************************************************************************************/ -#pragma once + +#ifndef _VDE_VXOPCODETABLEC_H_ +#define _VDE_VXOPCODETABLEC_H_ #include -#include +#include -namespace Verteron +#ifdef __cplusplus +extern "C" { +#endif /** * @brief Values that represent an instruction mnemonic. */ -enum class VXInstructionMnemonic : uint16_t +typedef enum _VXInstructionMnemonic /* : uint16_t */ { - /* 000 */ INVALID, - /* 001 */ AAA, - /* 002 */ AAD, - /* 003 */ AAM, - /* 004 */ AAS, - /* 005 */ ADC, - /* 006 */ ADD, - /* 007 */ ADDPD, - /* 008 */ ADDPS, - /* 009 */ ADDSD, - /* 00A */ ADDSS, - /* 00B */ ADDSUBPD, - /* 00C */ ADDSUBPS, - /* 00D */ AESDEC, - /* 00E */ AESDECLAST, - /* 00F */ AESENC, - /* 010 */ AESENCLAST, - /* 011 */ AESIMC, - /* 012 */ AESKEYGENASSIST, - /* 013 */ AND, - /* 014 */ ANDNPD, - /* 015 */ ANDNPS, - /* 016 */ ANDPD, - /* 017 */ ANDPS, - /* 018 */ ARPL, - /* 019 */ BLENDPD, - /* 01A */ BLENDPS, - /* 01B */ BLENDVPD, - /* 01C */ BLENDVPS, - /* 01D */ BOUND, - /* 01E */ BSF, - /* 01F */ BSR, - /* 020 */ BSWAP, - /* 021 */ BT, - /* 022 */ BTC, - /* 023 */ BTR, - /* 024 */ BTS, - /* 025 */ CALL, - /* 026 */ CBW, - /* 027 */ CDQ, - /* 028 */ CDQE, - /* 029 */ CLC, - /* 02A */ CLD, - /* 02B */ CLFLUSH, - /* 02C */ CLGI, - /* 02D */ CLI, - /* 02E */ CLTS, - /* 02F */ CMC, - /* 030 */ CMOVA, - /* 031 */ CMOVAE, - /* 032 */ CMOVB, - /* 033 */ CMOVBE, - /* 034 */ CMOVE, - /* 035 */ CMOVG, - /* 036 */ CMOVGE, - /* 037 */ CMOVL, - /* 038 */ CMOVLE, - /* 039 */ CMOVNE, - /* 03A */ CMOVNO, - /* 03B */ CMOVNP, - /* 03C */ CMOVNS, - /* 03D */ CMOVO, - /* 03E */ CMOVP, - /* 03F */ CMOVS, - /* 040 */ CMP, - /* 041 */ CMPPD, - /* 042 */ CMPPS, - /* 043 */ CMPSB, - /* 044 */ CMPSD, - /* 045 */ CMPSQ, - /* 046 */ CMPSS, - /* 047 */ CMPSW, - /* 048 */ CMPXCHG, - /* 049 */ CMPXCHG16B, - /* 04A */ CMPXCHG8B, - /* 04B */ COMISD, - /* 04C */ COMISS, - /* 04D */ CPUID, - /* 04E */ CQO, - /* 04F */ CRC32, - /* 050 */ CVTDQ2PD, - /* 051 */ CVTDQ2PS, - /* 052 */ CVTPD2DQ, - /* 053 */ CVTPD2PI, - /* 054 */ CVTPD2PS, - /* 055 */ CVTPI2PD, - /* 056 */ CVTPI2PS, - /* 057 */ CVTPS2DQ, - /* 058 */ CVTPS2PD, - /* 059 */ CVTPS2PI, - /* 05A */ CVTSD2SI, - /* 05B */ CVTSD2SS, - /* 05C */ CVTSI2SD, - /* 05D */ CVTSI2SS, - /* 05E */ CVTSS2SD, - /* 05F */ CVTSS2SI, - /* 060 */ CVTTPD2DQ, - /* 061 */ CVTTPD2PI, - /* 062 */ CVTTPS2DQ, - /* 063 */ CVTTPS2PI, - /* 064 */ CVTTSD2SI, - /* 065 */ CVTTSS2SI, - /* 066 */ CWD, - /* 067 */ CWDE, - /* 068 */ DAA, - /* 069 */ DAS, - /* 06A */ DEC, - /* 06B */ DIV, - /* 06C */ DIVPD, - /* 06D */ DIVPS, - /* 06E */ DIVSD, - /* 06F */ DIVSS, - /* 070 */ DPPD, - /* 071 */ DPPS, - /* 072 */ EMMS, - /* 073 */ ENTER, - /* 074 */ EXTRACTPS, - /* 075 */ F2XM1, - /* 076 */ FABS, - /* 077 */ FADD, - /* 078 */ FADDP, - /* 079 */ FBLD, - /* 07A */ FBSTP, - /* 07B */ FCHS, - /* 07C */ FCLEX, - /* 07D */ FCMOVB, - /* 07E */ FCMOVBE, - /* 07F */ FCMOVE, - /* 080 */ FCMOVNB, - /* 081 */ FCMOVNBE, - /* 082 */ FCMOVNE, - /* 083 */ FCMOVNU, - /* 084 */ FCMOVU, - /* 085 */ FCOM, - /* 086 */ FCOM2, - /* 087 */ FCOMI, - /* 088 */ FCOMIP, - /* 089 */ FCOMP, - /* 08A */ FCOMP3, - /* 08B */ FCOMP5, - /* 08C */ FCOMPP, - /* 08D */ FCOS, - /* 08E */ FDECSTP, - /* 08F */ FDIV, - /* 090 */ FDIVP, - /* 091 */ FDIVR, - /* 092 */ FDIVRP, - /* 093 */ FEMMS, - /* 094 */ FFREE, - /* 095 */ FFREEP, - /* 096 */ FIADD, - /* 097 */ FICOM, - /* 098 */ FICOMP, - /* 099 */ FIDIV, - /* 09A */ FIDIVR, - /* 09B */ FILD, - /* 09C */ FIMUL, - /* 09D */ FINCSTP, - /* 09E */ FIST, - /* 09F */ FISTP, - /* 0A0 */ FISTTP, - /* 0A1 */ FISUB, - /* 0A2 */ FISUBR, - /* 0A3 */ FLD, - /* 0A4 */ FLD1, - /* 0A5 */ FLDCW, - /* 0A6 */ FLDENV, - /* 0A7 */ FLDL2E, - /* 0A8 */ FLDL2T, - /* 0A9 */ FLDLG2, - /* 0AA */ FLDLN2, - /* 0AB */ FLDPI, - /* 0AC */ FLDZ, - /* 0AD */ FMUL, - /* 0AE */ FMULP, - /* 0AF */ FNDISI, - /* 0B0 */ FNENI, - /* 0B1 */ FNINIT, - /* 0B2 */ FNOP, - /* 0B3 */ FNSAVE, - /* 0B4 */ FNSETPM, - /* 0B5 */ FNSTCW, - /* 0B6 */ FNSTENV, - /* 0B7 */ FNSTSW, - /* 0B8 */ FPATAN, - /* 0B9 */ FPREM, - /* 0BA */ FPREM1, - /* 0BB */ FPTAN, - /* 0BC */ FRNDINT, - /* 0BD */ FRSTOR, - /* 0BE */ FRSTPM, - /* 0BF */ FSCALE, - /* 0C0 */ FSIN, - /* 0C1 */ FSINCOS, - /* 0C2 */ FSQRT, - /* 0C3 */ FST, - /* 0C4 */ FSTP, - /* 0C5 */ FSTP1, - /* 0C6 */ FSTP8, - /* 0C7 */ FSTP9, - /* 0C8 */ FSUB, - /* 0C9 */ FSUBP, - /* 0CA */ FSUBR, - /* 0CB */ FSUBRP, - /* 0CC */ FTST, - /* 0CD */ FUCOM, - /* 0CE */ FUCOMI, - /* 0CF */ FUCOMIP, - /* 0D0 */ FUCOMP, - /* 0D1 */ FUCOMPP, - /* 0D2 */ FXAM, - /* 0D3 */ FXCH, - /* 0D4 */ FXCH4, - /* 0D5 */ FXCH7, - /* 0D6 */ FXRSTOR, - /* 0D7 */ FXSAVE, - /* 0D8 */ FXTRACT, - /* 0D9 */ FYL2X, - /* 0DA */ FYL2XP1, - /* 0DB */ GETSEC, - /* 0DC */ HADDPD, - /* 0DD */ HADDPS, - /* 0DE */ HLT, - /* 0DF */ HSUBPD, - /* 0E0 */ HSUBPS, - /* 0E1 */ IDIV, - /* 0E2 */ IMUL, - /* 0E3 */ IN, - /* 0E4 */ INC, - /* 0E5 */ INSB, - /* 0E6 */ INSD, - /* 0E7 */ INSERTPS, - /* 0E8 */ INSW, - /* 0E9 */ INT, - /* 0EA */ INT1, - /* 0EB */ INT3, - /* 0EC */ INTO, - /* 0ED */ INVD, - /* 0EE */ INVEPT, - /* 0EF */ INVLPG, - /* 0F0 */ INVLPGA, - /* 0F1 */ INVVPID, - /* 0F2 */ IRETD, - /* 0F3 */ IRETQ, - /* 0F4 */ IRETW, - /* 0F5 */ JA, - /* 0F6 */ JB, - /* 0F7 */ JBE, - /* 0F8 */ JCXZ, - /* 0F9 */ JE, - /* 0FA */ JECXZ, - /* 0FB */ JG, - /* 0FC */ JGE, - /* 0FD */ JL, - /* 0FE */ JLE, - /* 0FF */ JMP, - /* 100 */ JNB, - /* 101 */ JNE, - /* 102 */ JNO, - /* 103 */ JNP, - /* 104 */ JNS, - /* 105 */ JO, - /* 106 */ JP, - /* 107 */ JRCXZ, - /* 108 */ JS, - /* 109 */ LAHF, - /* 10A */ LAR, - /* 10B */ LDDQU, - /* 10C */ LDMXCSR, - /* 10D */ LDS, - /* 10E */ LEA, - /* 10F */ LEAVE, - /* 110 */ LES, - /* 111 */ LFENCE, - /* 112 */ LFS, - /* 113 */ LGDT, - /* 114 */ LGS, - /* 115 */ LIDT, - /* 116 */ LLDT, - /* 117 */ LMSW, - /* 118 */ LOCK, - /* 119 */ LODSB, - /* 11A */ LODSD, - /* 11B */ LODSQ, - /* 11C */ LODSW, - /* 11D */ LOOP, - /* 11E */ LOOPE, - /* 11F */ LOOPNE, - /* 120 */ LSL, - /* 121 */ LSS, - /* 122 */ LTR, - /* 123 */ MASKMOVDQU, - /* 124 */ MASKMOVQ, - /* 125 */ MAXPD, - /* 126 */ MAXPS, - /* 127 */ MAXSD, - /* 128 */ MAXSS, - /* 129 */ MFENCE, - /* 12A */ MINPD, - /* 12B */ MINPS, - /* 12C */ MINSD, - /* 12D */ MINSS, - /* 12E */ MONITOR, - /* 12F */ MONTMUL, - /* 130 */ MOV, - /* 131 */ MOVAPD, - /* 132 */ MOVAPS, - /* 133 */ MOVBE, - /* 134 */ MOVD, - /* 135 */ MOVDDUP, - /* 136 */ MOVDQ2Q, - /* 137 */ MOVDQA, - /* 138 */ MOVDQU, - /* 139 */ MOVHLPS, - /* 13A */ MOVHPD, - /* 13B */ MOVHPS, - /* 13C */ MOVLHPS, - /* 13D */ MOVLPD, - /* 13E */ MOVLPS, - /* 13F */ MOVMSKPD, - /* 140 */ MOVMSKPS, - /* 141 */ MOVNTDQ, - /* 142 */ MOVNTDQA, - /* 143 */ MOVNTI, - /* 144 */ MOVNTPD, - /* 145 */ MOVNTPS, - /* 146 */ MOVNTQ, - /* 147 */ MOVQ, - /* 148 */ MOVQ2DQ, - /* 149 */ MOVSB, - /* 14A */ MOVSD, - /* 14B */ MOVSHDUP, - /* 14C */ MOVSLDUP, - /* 14D */ MOVSQ, - /* 14E */ MOVSS, - /* 14F */ MOVSW, - /* 150 */ MOVSX, - /* 151 */ MOVSXD, - /* 152 */ MOVUPD, - /* 153 */ MOVUPS, - /* 154 */ MOVZX, - /* 155 */ MPSADBW, - /* 156 */ MUL, - /* 157 */ MULPD, - /* 158 */ MULPS, - /* 159 */ MULSD, - /* 15A */ MULSS, - /* 15B */ MWAIT, - /* 15C */ NEG, - /* 15D */ NOP, - /* 15E */ NOT, - /* 15F */ OR, - /* 160 */ ORPD, - /* 161 */ ORPS, - /* 162 */ OUT, - /* 163 */ OUTSB, - /* 164 */ OUTSD, - /* 165 */ OUTSW, - /* 166 */ PABSB, - /* 167 */ PABSD, - /* 168 */ PABSW, - /* 169 */ PACKSSDW, - /* 16A */ PACKSSWB, - /* 16B */ PACKUSDW, - /* 16C */ PACKUSWB, - /* 16D */ PADDB, - /* 16E */ PADDD, - /* 16F */ PADDQ, - /* 170 */ PADDSB, - /* 171 */ PADDSW, - /* 172 */ PADDUSB, - /* 173 */ PADDUSW, - /* 174 */ PADDW, - /* 175 */ PALIGNR, - /* 176 */ PAND, - /* 177 */ PANDN, - /* 178 */ PAUSE, - /* 179 */ PAVGB, - /* 17A */ PAVGUSB, - /* 17B */ PAVGW, - /* 17C */ PBLENDVB, - /* 17D */ PBLENDW, - /* 17E */ PCLMULQDQ, - /* 17F */ PCMPEQB, - /* 180 */ PCMPEQD, - /* 181 */ PCMPEQQ, - /* 182 */ PCMPEQW, - /* 183 */ PCMPESTRI, - /* 184 */ PCMPESTRM, - /* 185 */ PCMPGTB, - /* 186 */ PCMPGTD, - /* 187 */ PCMPGTQ, - /* 188 */ PCMPGTW, - /* 189 */ PCMPISTRI, - /* 18A */ PCMPISTRM, - /* 18B */ PEXTRB, - /* 18C */ PEXTRD, - /* 18D */ PEXTRQ, - /* 18E */ PEXTRW, - /* 18F */ PF2ID, - /* 190 */ PF2IW, - /* 191 */ PFACC, - /* 192 */ PFADD, - /* 193 */ PFCMPEQ, - /* 194 */ PFCMPGE, - /* 195 */ PFCMPGT, - /* 196 */ PFMAX, - /* 197 */ PFMIN, - /* 198 */ PFMUL, - /* 199 */ PFNACC, - /* 19A */ PFPNACC, - /* 19B */ PFRCP, - /* 19C */ PFRCPIT1, - /* 19D */ PFRCPIT2, - /* 19E */ PFRSQIT1, - /* 19F */ PFRSQRT, - /* 1A0 */ PFSUB, - /* 1A1 */ PFSUBR, - /* 1A2 */ PHADDD, - /* 1A3 */ PHADDSW, - /* 1A4 */ PHADDW, - /* 1A5 */ PHMINPOSUW, - /* 1A6 */ PHSUBD, - /* 1A7 */ PHSUBSW, - /* 1A8 */ PHSUBW, - /* 1A9 */ PI2FD, - /* 1AA */ PI2FW, - /* 1AB */ PINSRB, - /* 1AC */ PINSRD, - /* 1AD */ PINSRQ, - /* 1AE */ PINSRW, - /* 1AF */ PMADDUBSW, - /* 1B0 */ PMADDWD, - /* 1B1 */ PMAXSB, - /* 1B2 */ PMAXSD, - /* 1B3 */ PMAXSW, - /* 1B4 */ PMAXUB, - /* 1B5 */ PMAXUD, - /* 1B6 */ PMAXUW, - /* 1B7 */ PMINSB, - /* 1B8 */ PMINSD, - /* 1B9 */ PMINSW, - /* 1BA */ PMINUB, - /* 1BB */ PMINUD, - /* 1BC */ PMINUW, - /* 1BD */ PMOVMSKB, - /* 1BE */ PMOVSXBD, - /* 1BF */ PMOVSXBQ, - /* 1C0 */ PMOVSXBW, - /* 1C1 */ PMOVSXDQ, - /* 1C2 */ PMOVSXWD, - /* 1C3 */ PMOVSXWQ, - /* 1C4 */ PMOVZXBD, - /* 1C5 */ PMOVZXBQ, - /* 1C6 */ PMOVZXBW, - /* 1C7 */ PMOVZXDQ, - /* 1C8 */ PMOVZXWD, - /* 1C9 */ PMOVZXWQ, - /* 1CA */ PMULDQ, - /* 1CB */ PMULHRSW, - /* 1CC */ PMULHRW, - /* 1CD */ PMULHUW, - /* 1CE */ PMULHW, - /* 1CF */ PMULLD, - /* 1D0 */ PMULLW, - /* 1D1 */ PMULUDQ, - /* 1D2 */ POP, - /* 1D3 */ POPA, - /* 1D4 */ POPAD, - /* 1D5 */ POPCNT, - /* 1D6 */ POPFD, - /* 1D7 */ POPFQ, - /* 1D8 */ POPFW, - /* 1D9 */ POR, - /* 1DA */ PREFETCH, - /* 1DB */ PREFETCHNTA, - /* 1DC */ PREFETCHT0, - /* 1DD */ PREFETCHT1, - /* 1DE */ PREFETCHT2, - /* 1DF */ PSADBW, - /* 1E0 */ PSHUFB, - /* 1E1 */ PSHUFD, - /* 1E2 */ PSHUFHW, - /* 1E3 */ PSHUFLW, - /* 1E4 */ PSHUFW, - /* 1E5 */ PSIGNB, - /* 1E6 */ PSIGND, - /* 1E7 */ PSIGNW, - /* 1E8 */ PSLLD, - /* 1E9 */ PSLLDQ, - /* 1EA */ PSLLQ, - /* 1EB */ PSLLW, - /* 1EC */ PSRAD, - /* 1ED */ PSRAW, - /* 1EE */ PSRLD, - /* 1EF */ PSRLDQ, - /* 1F0 */ PSRLQ, - /* 1F1 */ PSRLW, - /* 1F2 */ PSUBB, - /* 1F3 */ PSUBD, - /* 1F4 */ PSUBQ, - /* 1F5 */ PSUBSB, - /* 1F6 */ PSUBSW, - /* 1F7 */ PSUBUSB, - /* 1F8 */ PSUBUSW, - /* 1F9 */ PSUBW, - /* 1FA */ PSWAPD, - /* 1FB */ PTEST, - /* 1FC */ PUNPCKHBW, - /* 1FD */ PUNPCKHDQ, - /* 1FE */ PUNPCKHQDQ, - /* 1FF */ PUNPCKHWD, - /* 200 */ PUNPCKLBW, - /* 201 */ PUNPCKLDQ, - /* 202 */ PUNPCKLQDQ, - /* 203 */ PUNPCKLWD, - /* 204 */ PUSH, - /* 205 */ PUSHA, - /* 206 */ PUSHAD, - /* 207 */ PUSHFD, - /* 208 */ PUSHFQ, - /* 209 */ PUSHFW, - /* 20A */ PXOR, - /* 20B */ RCL, - /* 20C */ RCPPS, - /* 20D */ RCPSS, - /* 20E */ RCR, - /* 20F */ RDMSR, - /* 210 */ RDPMC, - /* 211 */ RDRAND, - /* 212 */ RDTSC, - /* 213 */ RDTSCP, - /* 214 */ REP, - /* 215 */ REPNE, - /* 216 */ RET, - /* 217 */ RETF, - /* 218 */ ROL, - /* 219 */ ROR, - /* 21A */ ROUNDPD, - /* 21B */ ROUNDPS, - /* 21C */ ROUNDSD, - /* 21D */ ROUNDSS, - /* 21E */ RSM, - /* 21F */ RSQRTPS, - /* 220 */ RSQRTSS, - /* 221 */ SAHF, - /* 222 */ SALC, - /* 223 */ SAR, - /* 224 */ SBB, - /* 225 */ SCASB, - /* 226 */ SCASD, - /* 227 */ SCASQ, - /* 228 */ SCASW, - /* 229 */ SETA, - /* 22A */ SETAE, - /* 22B */ SETB, - /* 22C */ SETBE, - /* 22D */ SETE, - /* 22E */ SETG, - /* 22F */ SETGE, - /* 230 */ SETL, - /* 231 */ SETLE, - /* 232 */ SETNE, - /* 233 */ SETNO, - /* 234 */ SETNP, - /* 235 */ SETNS, - /* 236 */ SETO, - /* 237 */ SETP, - /* 238 */ SETS, - /* 239 */ SFENCE, - /* 23A */ SGDT, - /* 23B */ SHL, - /* 23C */ SHLD, - /* 23D */ SHR, - /* 23E */ SHRD, - /* 23F */ SHUFPD, - /* 240 */ SHUFPS, - /* 241 */ SIDT, - /* 242 */ SKINIT, - /* 243 */ SLDT, - /* 244 */ SMSW, - /* 245 */ SQRTPD, - /* 246 */ SQRTPS, - /* 247 */ SQRTSD, - /* 248 */ SQRTSS, - /* 249 */ STC, - /* 24A */ STD, - /* 24B */ STGI, - /* 24C */ STI, - /* 24D */ STMXCSR, - /* 24E */ STOSB, - /* 24F */ STOSD, - /* 250 */ STOSQ, - /* 251 */ STOSW, - /* 252 */ STR, - /* 253 */ SUB, - /* 254 */ SUBPD, - /* 255 */ SUBPS, - /* 256 */ SUBSD, - /* 257 */ SUBSS, - /* 258 */ SWAPGS, - /* 259 */ SYSCALL, - /* 25A */ SYSENTER, - /* 25B */ SYSEXIT, - /* 25C */ SYSRET, - /* 25D */ TEST, - /* 25E */ UCOMISD, - /* 25F */ UCOMISS, - /* 260 */ UD2, - /* 261 */ UNPCKHPD, - /* 262 */ UNPCKHPS, - /* 263 */ UNPCKLPD, - /* 264 */ UNPCKLPS, - /* 265 */ VADDPD, - /* 266 */ VADDPS, - /* 267 */ VADDSD, - /* 268 */ VADDSS, - /* 269 */ VADDSUBPD, - /* 26A */ VADDSUBPS, - /* 26B */ VAESDEC, - /* 26C */ VAESDECLAST, - /* 26D */ VAESENC, - /* 26E */ VAESENCLAST, - /* 26F */ VAESIMC, - /* 270 */ VAESKEYGENASSIST, - /* 271 */ VANDNPD, - /* 272 */ VANDNPS, - /* 273 */ VANDPD, - /* 274 */ VANDPS, - /* 275 */ VBLENDPD, - /* 276 */ VBLENDPS, - /* 277 */ VBLENDVPD, - /* 278 */ VBLENDVPS, - /* 279 */ VBROADCASTSD, - /* 27A */ VBROADCASTSS, - /* 27B */ VCMPPD, - /* 27C */ VCMPPS, - /* 27D */ VCMPSD, - /* 27E */ VCMPSS, - /* 27F */ VCOMISD, - /* 280 */ VCOMISS, - /* 281 */ VCVTDQ2PD, - /* 282 */ VCVTDQ2PS, - /* 283 */ VCVTPD2DQ, - /* 284 */ VCVTPD2PS, - /* 285 */ VCVTPS2DQ, - /* 286 */ VCVTPS2PD, - /* 287 */ VCVTSD2SI, - /* 288 */ VCVTSD2SS, - /* 289 */ VCVTSI2SD, - /* 28A */ VCVTSI2SS, - /* 28B */ VCVTSS2SD, - /* 28C */ VCVTSS2SI, - /* 28D */ VCVTTPD2DQ, - /* 28E */ VCVTTPS2DQ, - /* 28F */ VCVTTSD2SI, - /* 290 */ VCVTTSS2SI, - /* 291 */ VDIVPD, - /* 292 */ VDIVPS, - /* 293 */ VDIVSD, - /* 294 */ VDIVSS, - /* 295 */ VDPPD, - /* 296 */ VDPPS, - /* 297 */ VERR, - /* 298 */ VERW, - /* 299 */ VEXTRACTF128, - /* 29A */ VEXTRACTPS, - /* 29B */ VHADDPD, - /* 29C */ VHADDPS, - /* 29D */ VHSUBPD, - /* 29E */ VHSUBPS, - /* 29F */ VINSERTF128, - /* 2A0 */ VINSERTPS, - /* 2A1 */ VLDDQU, - /* 2A2 */ VMASKMOVDQU, - /* 2A3 */ VMASKMOVPD, - /* 2A4 */ VMASKMOVPS, - /* 2A5 */ VMAXPD, - /* 2A6 */ VMAXPS, - /* 2A7 */ VMAXSD, - /* 2A8 */ VMAXSS, - /* 2A9 */ VMCALL, - /* 2AA */ VMCLEAR, - /* 2AB */ VMINPD, - /* 2AC */ VMINPS, - /* 2AD */ VMINSD, - /* 2AE */ VMINSS, - /* 2AF */ VMLAUNCH, - /* 2B0 */ VMLOAD, - /* 2B1 */ VMMCALL, - /* 2B2 */ VMOVAPD, - /* 2B3 */ VMOVAPS, - /* 2B4 */ VMOVD, - /* 2B5 */ VMOVDDUP, - /* 2B6 */ VMOVDQA, - /* 2B7 */ VMOVDQU, - /* 2B8 */ VMOVHLPS, - /* 2B9 */ VMOVHPD, - /* 2BA */ VMOVHPS, - /* 2BB */ VMOVLHPS, - /* 2BC */ VMOVLPD, - /* 2BD */ VMOVLPS, - /* 2BE */ VMOVMSKPD, - /* 2BF */ VMOVMSKPS, - /* 2C0 */ VMOVNTDQ, - /* 2C1 */ VMOVNTDQA, - /* 2C2 */ VMOVNTPD, - /* 2C3 */ VMOVNTPS, - /* 2C4 */ VMOVQ, - /* 2C5 */ VMOVSD, - /* 2C6 */ VMOVSHDUP, - /* 2C7 */ VMOVSLDUP, - /* 2C8 */ VMOVSS, - /* 2C9 */ VMOVUPD, - /* 2CA */ VMOVUPS, - /* 2CB */ VMPSADBW, - /* 2CC */ VMPTRLD, - /* 2CD */ VMPTRST, - /* 2CE */ VMREAD, - /* 2CF */ VMRESUME, - /* 2D0 */ VMRUN, - /* 2D1 */ VMSAVE, - /* 2D2 */ VMULPD, - /* 2D3 */ VMULPS, - /* 2D4 */ VMULSD, - /* 2D5 */ VMULSS, - /* 2D6 */ VMWRITE, - /* 2D7 */ VMXOFF, - /* 2D8 */ VMXON, - /* 2D9 */ VORPD, - /* 2DA */ VORPS, - /* 2DB */ VPABSB, - /* 2DC */ VPABSD, - /* 2DD */ VPABSW, - /* 2DE */ VPACKSSDW, - /* 2DF */ VPACKSSWB, - /* 2E0 */ VPACKUSDW, - /* 2E1 */ VPACKUSWB, - /* 2E2 */ VPADDB, - /* 2E3 */ VPADDD, - /* 2E4 */ VPADDQ, - /* 2E5 */ VPADDSB, - /* 2E6 */ VPADDSW, - /* 2E7 */ VPADDUSB, - /* 2E8 */ VPADDUSW, - /* 2E9 */ VPADDW, - /* 2EA */ VPALIGNR, - /* 2EB */ VPAND, - /* 2EC */ VPANDN, - /* 2ED */ VPAVGB, - /* 2EE */ VPAVGW, - /* 2EF */ VPBLENDVB, - /* 2F0 */ VPBLENDW, - /* 2F1 */ VPCLMULQDQ, - /* 2F2 */ VPCMPEQB, - /* 2F3 */ VPCMPEQD, - /* 2F4 */ VPCMPEQQ, - /* 2F5 */ VPCMPEQW, - /* 2F6 */ VPCMPESTRI, - /* 2F7 */ VPCMPESTRM, - /* 2F8 */ VPCMPGTB, - /* 2F9 */ VPCMPGTD, - /* 2FA */ VPCMPGTQ, - /* 2FB */ VPCMPGTW, - /* 2FC */ VPCMPISTRI, - /* 2FD */ VPCMPISTRM, - /* 2FE */ VPERM2F128, - /* 2FF */ VPERMILPD, - /* 300 */ VPERMILPS, - /* 301 */ VPEXTRB, - /* 302 */ VPEXTRD, - /* 303 */ VPEXTRQ, - /* 304 */ VPEXTRW, - /* 305 */ VPHADDD, - /* 306 */ VPHADDSW, - /* 307 */ VPHADDW, - /* 308 */ VPHMINPOSUW, - /* 309 */ VPHSUBD, - /* 30A */ VPHSUBSW, - /* 30B */ VPHSUBW, - /* 30C */ VPINSRB, - /* 30D */ VPINSRD, - /* 30E */ VPINSRQ, - /* 30F */ VPINSRW, - /* 310 */ VPMADDUBSW, - /* 311 */ VPMADDWD, - /* 312 */ VPMAXSB, - /* 313 */ VPMAXSD, - /* 314 */ VPMAXSW, - /* 315 */ VPMAXUB, - /* 316 */ VPMAXUD, - /* 317 */ VPMAXUW, - /* 318 */ VPMINSB, - /* 319 */ VPMINSD, - /* 31A */ VPMINSW, - /* 31B */ VPMINUB, - /* 31C */ VPMINUD, - /* 31D */ VPMINUW, - /* 31E */ VPMOVMSKB, - /* 31F */ VPMOVSXBD, - /* 320 */ VPMOVSXBQ, - /* 321 */ VPMOVSXBW, - /* 322 */ VPMOVSXWD, - /* 323 */ VPMOVSXWQ, - /* 324 */ VPMOVZXBD, - /* 325 */ VPMOVZXBQ, - /* 326 */ VPMOVZXBW, - /* 327 */ VPMOVZXDQ, - /* 328 */ VPMOVZXWD, - /* 329 */ VPMOVZXWQ, - /* 32A */ VPMULDQ, - /* 32B */ VPMULHRSW, - /* 32C */ VPMULHUW, - /* 32D */ VPMULHW, - /* 32E */ VPMULLD, - /* 32F */ VPMULLW, - /* 330 */ VPOR, - /* 331 */ VPSADBW, - /* 332 */ VPSHUFB, - /* 333 */ VPSHUFD, - /* 334 */ VPSHUFHW, - /* 335 */ VPSHUFLW, - /* 336 */ VPSIGNB, - /* 337 */ VPSIGND, - /* 338 */ VPSIGNW, - /* 339 */ VPSLLD, - /* 33A */ VPSLLDQ, - /* 33B */ VPSLLQ, - /* 33C */ VPSLLW, - /* 33D */ VPSRAD, - /* 33E */ VPSRAW, - /* 33F */ VPSRLD, - /* 340 */ VPSRLDQ, - /* 341 */ VPSRLQ, - /* 342 */ VPSRLW, - /* 343 */ VPSUBB, - /* 344 */ VPSUBD, - /* 345 */ VPSUBQ, - /* 346 */ VPSUBSB, - /* 347 */ VPSUBSW, - /* 348 */ VPSUBUSB, - /* 349 */ VPSUBUSW, - /* 34A */ VPSUBW, - /* 34B */ VPTEST, - /* 34C */ VPUNPCKHBW, - /* 34D */ VPUNPCKHDQ, - /* 34E */ VPUNPCKHQDQ, - /* 34F */ VPUNPCKHWD, - /* 350 */ VPUNPCKLBW, - /* 351 */ VPUNPCKLDQ, - /* 352 */ VPUNPCKLQDQ, - /* 353 */ VPUNPCKLWD, - /* 354 */ VPXOR, - /* 355 */ VRCPPS, - /* 356 */ VRCPSS, - /* 357 */ VROUNDPD, - /* 358 */ VROUNDPS, - /* 359 */ VROUNDSD, - /* 35A */ VROUNDSS, - /* 35B */ VRSQRTPS, - /* 35C */ VRSQRTSS, - /* 35D */ VSHUFPD, - /* 35E */ VSHUFPS, - /* 35F */ VSQRTPD, - /* 360 */ VSQRTPS, - /* 361 */ VSQRTSD, - /* 362 */ VSQRTSS, - /* 363 */ VSTMXCSR, - /* 364 */ VSUBPD, - /* 365 */ VSUBPS, - /* 366 */ VSUBSD, - /* 367 */ VSUBSS, - /* 368 */ VTESTPD, - /* 369 */ VTESTPS, - /* 36A */ VUCOMISD, - /* 36B */ VUCOMISS, - /* 36C */ VUNPCKHPD, - /* 36D */ VUNPCKHPS, - /* 36E */ VUNPCKLPD, - /* 36F */ VUNPCKLPS, - /* 370 */ VXORPD, - /* 371 */ VXORPS, - /* 372 */ VZEROALL, - /* 373 */ VZEROUPPER, - /* 374 */ WAIT, - /* 375 */ WBINVD, - /* 376 */ WRMSR, - /* 377 */ XADD, - /* 378 */ XCHG, - /* 379 */ XCRYPTCBC, - /* 37A */ XCRYPTCFB, - /* 37B */ XCRYPTCTR, - /* 37C */ XCRYPTECB, - /* 37D */ XCRYPTOFB, - /* 37E */ XGETBV, - /* 37F */ XLATB, - /* 380 */ XOR, - /* 381 */ XORPD, - /* 382 */ XORPS, - /* 383 */ XRSTOR, - /* 384 */ XSAVE, - /* 385 */ XSETBV, - /* 386 */ XSHA1, - /* 387 */ XSHA256, - /* 388 */ XSTORE, -}; + /* 000 */ MNEM_INVALID, + /* 001 */ MNEM_AAA, + /* 002 */ MNEM_AAD, + /* 003 */ MNEM_AAM, + /* 004 */ MNEM_AAS, + /* 005 */ MNEM_ADC, + /* 006 */ MNEM_ADD, + /* 007 */ MNEM_ADDPD, + /* 008 */ MNEM_ADDPS, + /* 009 */ MNEM_ADDSD, + /* 00A */ MNEM_ADDSS, + /* 00B */ MNEM_ADDSUBPD, + /* 00C */ MNEM_ADDSUBPS, + /* 00D */ MNEM_AESDEC, + /* 00E */ MNEM_AESDECLAST, + /* 00F */ MNEM_AESENC, + /* 010 */ MNEM_AESENCLAST, + /* 011 */ MNEM_AESIMC, + /* 012 */ MNEM_AESKEYGENASSIST, + /* 013 */ MNEM_AND, + /* 014 */ MNEM_ANDNPD, + /* 015 */ MNEM_ANDNPS, + /* 016 */ MNEM_ANDPD, + /* 017 */ MNEM_ANDPS, + /* 018 */ MNEM_ARPL, + /* 019 */ MNEM_BLENDPD, + /* 01A */ MNEM_BLENDPS, + /* 01B */ MNEM_BLENDVPD, + /* 01C */ MNEM_BLENDVPS, + /* 01D */ MNEM_BOUND, + /* 01E */ MNEM_BSF, + /* 01F */ MNEM_BSR, + /* 020 */ MNEM_BSWAP, + /* 021 */ MNEM_BT, + /* 022 */ MNEM_BTC, + /* 023 */ MNEM_BTR, + /* 024 */ MNEM_BTS, + /* 025 */ MNEM_CALL, + /* 026 */ MNEM_CBW, + /* 027 */ MNEM_CDQ, + /* 028 */ MNEM_CDQE, + /* 029 */ MNEM_CLC, + /* 02A */ MNEM_CLD, + /* 02B */ MNEM_CLFLUSH, + /* 02C */ MNEM_CLGI, + /* 02D */ MNEM_CLI, + /* 02E */ MNEM_CLTS, + /* 02F */ MNEM_CMC, + /* 030 */ MNEM_CMOVA, + /* 031 */ MNEM_CMOVAE, + /* 032 */ MNEM_CMOVB, + /* 033 */ MNEM_CMOVBE, + /* 034 */ MNEM_CMOVE, + /* 035 */ MNEM_CMOVG, + /* 036 */ MNEM_CMOVGE, + /* 037 */ MNEM_CMOVL, + /* 038 */ MNEM_CMOVLE, + /* 039 */ MNEM_CMOVNE, + /* 03A */ MNEM_CMOVNO, + /* 03B */ MNEM_CMOVNP, + /* 03C */ MNEM_CMOVNS, + /* 03D */ MNEM_CMOVO, + /* 03E */ MNEM_CMOVP, + /* 03F */ MNEM_CMOVS, + /* 040 */ MNEM_CMP, + /* 041 */ MNEM_CMPPD, + /* 042 */ MNEM_CMPPS, + /* 043 */ MNEM_CMPSB, + /* 044 */ MNEM_CMPSD, + /* 045 */ MNEM_CMPSQ, + /* 046 */ MNEM_CMPSS, + /* 047 */ MNEM_CMPSW, + /* 048 */ MNEM_CMPXCHG, + /* 049 */ MNEM_CMPXCHG16B, + /* 04A */ MNEM_CMPXCHG8B, + /* 04B */ MNEM_COMISD, + /* 04C */ MNEM_COMISS, + /* 04D */ MNEM_CPUID, + /* 04E */ MNEM_CQO, + /* 04F */ MNEM_CRC32, + /* 050 */ MNEM_CVTDQ2PD, + /* 051 */ MNEM_CVTDQ2PS, + /* 052 */ MNEM_CVTPD2DQ, + /* 053 */ MNEM_CVTPD2PI, + /* 054 */ MNEM_CVTPD2PS, + /* 055 */ MNEM_CVTPI2PD, + /* 056 */ MNEM_CVTPI2PS, + /* 057 */ MNEM_CVTPS2DQ, + /* 058 */ MNEM_CVTPS2PD, + /* 059 */ MNEM_CVTPS2PI, + /* 05A */ MNEM_CVTSD2SI, + /* 05B */ MNEM_CVTSD2SS, + /* 05C */ MNEM_CVTSI2SD, + /* 05D */ MNEM_CVTSI2SS, + /* 05E */ MNEM_CVTSS2SD, + /* 05F */ MNEM_CVTSS2SI, + /* 060 */ MNEM_CVTTPD2DQ, + /* 061 */ MNEM_CVTTPD2PI, + /* 062 */ MNEM_CVTTPS2DQ, + /* 063 */ MNEM_CVTTPS2PI, + /* 064 */ MNEM_CVTTSD2SI, + /* 065 */ MNEM_CVTTSS2SI, + /* 066 */ MNEM_CWD, + /* 067 */ MNEM_CWDE, + /* 068 */ MNEM_DAA, + /* 069 */ MNEM_DAS, + /* 06A */ MNEM_DEC, + /* 06B */ MNEM_DIV, + /* 06C */ MNEM_DIVPD, + /* 06D */ MNEM_DIVPS, + /* 06E */ MNEM_DIVSD, + /* 06F */ MNEM_DIVSS, + /* 070 */ MNEM_DPPD, + /* 071 */ MNEM_DPPS, + /* 072 */ MNEM_EMMS, + /* 073 */ MNEM_ENTER, + /* 074 */ MNEM_EXTRACTPS, + /* 075 */ MNEM_F2XM1, + /* 076 */ MNEM_FABS, + /* 077 */ MNEM_FADD, + /* 078 */ MNEM_FADDP, + /* 079 */ MNEM_FBLD, + /* 07A */ MNEM_FBSTP, + /* 07B */ MNEM_FCHS, + /* 07C */ MNEM_FCLEX, + /* 07D */ MNEM_FCMOVB, + /* 07E */ MNEM_FCMOVBE, + /* 07F */ MNEM_FCMOVE, + /* 080 */ MNEM_FCMOVNB, + /* 081 */ MNEM_FCMOVNBE, + /* 082 */ MNEM_FCMOVNE, + /* 083 */ MNEM_FCMOVNU, + /* 084 */ MNEM_FCMOVU, + /* 085 */ MNEM_FCOM, + /* 086 */ MNEM_FCOM2, + /* 087 */ MNEM_FCOMI, + /* 088 */ MNEM_FCOMIP, + /* 089 */ MNEM_FCOMP, + /* 08A */ MNEM_FCOMP3, + /* 08B */ MNEM_FCOMP5, + /* 08C */ MNEM_FCOMPP, + /* 08D */ MNEM_FCOS, + /* 08E */ MNEM_FDECSTP, + /* 08F */ MNEM_FDIV, + /* 090 */ MNEM_FDIVP, + /* 091 */ MNEM_FDIVR, + /* 092 */ MNEM_FDIVRP, + /* 093 */ MNEM_FEMMS, + /* 094 */ MNEM_FFREE, + /* 095 */ MNEM_FFREEP, + /* 096 */ MNEM_FIADD, + /* 097 */ MNEM_FICOM, + /* 098 */ MNEM_FICOMP, + /* 099 */ MNEM_FIDIV, + /* 09A */ MNEM_FIDIVR, + /* 09B */ MNEM_FILD, + /* 09C */ MNEM_FIMUL, + /* 09D */ MNEM_FINCSTP, + /* 09E */ MNEM_FIST, + /* 09F */ MNEM_FISTP, + /* 0A0 */ MNEM_FISTTP, + /* 0A1 */ MNEM_FISUB, + /* 0A2 */ MNEM_FISUBR, + /* 0A3 */ MNEM_FLD, + /* 0A4 */ MNEM_FLD1, + /* 0A5 */ MNEM_FLDCW, + /* 0A6 */ MNEM_FLDENV, + /* 0A7 */ MNEM_FLDL2E, + /* 0A8 */ MNEM_FLDL2T, + /* 0A9 */ MNEM_FLDLG2, + /* 0AA */ MNEM_FLDLN2, + /* 0AB */ MNEM_FLDPI, + /* 0AC */ MNEM_FLDZ, + /* 0AD */ MNEM_FMUL, + /* 0AE */ MNEM_FMULP, + /* 0AF */ MNEM_FNDISI, + /* 0B0 */ MNEM_FNENI, + /* 0B1 */ MNEM_FNINIT, + /* 0B2 */ MNEM_FNOP, + /* 0B3 */ MNEM_FNSAVE, + /* 0B4 */ MNEM_FNSETPM, + /* 0B5 */ MNEM_FNSTCW, + /* 0B6 */ MNEM_FNSTENV, + /* 0B7 */ MNEM_FNSTSW, + /* 0B8 */ MNEM_FPATAN, + /* 0B9 */ MNEM_FPREM, + /* 0BA */ MNEM_FPREM1, + /* 0BB */ MNEM_FPTAN, + /* 0BC */ MNEM_FRNDINT, + /* 0BD */ MNEM_FRSTOR, + /* 0BE */ MNEM_FRSTPM, + /* 0BF */ MNEM_FSCALE, + /* 0C0 */ MNEM_FSIN, + /* 0C1 */ MNEM_FSINCOS, + /* 0C2 */ MNEM_FSQRT, + /* 0C3 */ MNEM_FST, + /* 0C4 */ MNEM_FSTP, + /* 0C5 */ MNEM_FSTP1, + /* 0C6 */ MNEM_FSTP8, + /* 0C7 */ MNEM_FSTP9, + /* 0C8 */ MNEM_FSUB, + /* 0C9 */ MNEM_FSUBP, + /* 0CA */ MNEM_FSUBR, + /* 0CB */ MNEM_FSUBRP, + /* 0CC */ MNEM_FTST, + /* 0CD */ MNEM_FUCOM, + /* 0CE */ MNEM_FUCOMI, + /* 0CF */ MNEM_FUCOMIP, + /* 0D0 */ MNEM_FUCOMP, + /* 0D1 */ MNEM_FUCOMPP, + /* 0D2 */ MNEM_FXAM, + /* 0D3 */ MNEM_FXCH, + /* 0D4 */ MNEM_FXCH4, + /* 0D5 */ MNEM_FXCH7, + /* 0D6 */ MNEM_FXRSTOR, + /* 0D7 */ MNEM_FXSAVE, + /* 0D8 */ MNEM_FXTRACT, + /* 0D9 */ MNEM_FYL2X, + /* 0DA */ MNEM_FYL2XP1, + /* 0DB */ MNEM_GETSEC, + /* 0DC */ MNEM_HADDPD, + /* 0DD */ MNEM_HADDPS, + /* 0DE */ MNEM_HLT, + /* 0DF */ MNEM_HSUBPD, + /* 0E0 */ MNEM_HSUBPS, + /* 0E1 */ MNEM_IDIV, + /* 0E2 */ MNEM_IMUL, + /* 0E3 */ MNEM_IN, + /* 0E4 */ MNEM_INC, + /* 0E5 */ MNEM_INSB, + /* 0E6 */ MNEM_INSD, + /* 0E7 */ MNEM_INSERTPS, + /* 0E8 */ MNEM_INSW, + /* 0E9 */ MNEM_INT, + /* 0EA */ MNEM_INT1, + /* 0EB */ MNEM_INT3, + /* 0EC */ MNEM_INTO, + /* 0ED */ MNEM_INVD, + /* 0EE */ MNEM_INVEPT, + /* 0EF */ MNEM_INVLPG, + /* 0F0 */ MNEM_INVLPGA, + /* 0F1 */ MNEM_INVVPID, + /* 0F2 */ MNEM_IRETD, + /* 0F3 */ MNEM_IRETQ, + /* 0F4 */ MNEM_IRETW, + /* 0F5 */ MNEM_JA, + /* 0F6 */ MNEM_JB, + /* 0F7 */ MNEM_JBE, + /* 0F8 */ MNEM_JCXZ, + /* 0F9 */ MNEM_JE, + /* 0FA */ MNEM_JECXZ, + /* 0FB */ MNEM_JG, + /* 0FC */ MNEM_JGE, + /* 0FD */ MNEM_JL, + /* 0FE */ MNEM_JLE, + /* 0FF */ MNEM_JMP, + /* 100 */ MNEM_JNB, + /* 101 */ MNEM_JNE, + /* 102 */ MNEM_JNO, + /* 103 */ MNEM_JNP, + /* 104 */ MNEM_JNS, + /* 105 */ MNEM_JO, + /* 106 */ MNEM_JP, + /* 107 */ MNEM_JRCXZ, + /* 108 */ MNEM_JS, + /* 109 */ MNEM_LAHF, + /* 10A */ MNEM_LAR, + /* 10B */ MNEM_LDDQU, + /* 10C */ MNEM_LDMXCSR, + /* 10D */ MNEM_LDS, + /* 10E */ MNEM_LEA, + /* 10F */ MNEM_LEAVE, + /* 110 */ MNEM_LES, + /* 111 */ MNEM_LFENCE, + /* 112 */ MNEM_LFS, + /* 113 */ MNEM_LGDT, + /* 114 */ MNEM_LGS, + /* 115 */ MNEM_LIDT, + /* 116 */ MNEM_LLDT, + /* 117 */ MNEM_LMSW, + /* 118 */ MNEM_LOCK, + /* 119 */ MNEM_LODSB, + /* 11A */ MNEM_LODSD, + /* 11B */ MNEM_LODSQ, + /* 11C */ MNEM_LODSW, + /* 11D */ MNEM_LOOP, + /* 11E */ MNEM_LOOPE, + /* 11F */ MNEM_LOOPNE, + /* 120 */ MNEM_LSL, + /* 121 */ MNEM_LSS, + /* 122 */ MNEM_LTR, + /* 123 */ MNEM_MASKMOVDQU, + /* 124 */ MNEM_MASKMOVQ, + /* 125 */ MNEM_MAXPD, + /* 126 */ MNEM_MAXPS, + /* 127 */ MNEM_MAXSD, + /* 128 */ MNEM_MAXSS, + /* 129 */ MNEM_MFENCE, + /* 12A */ MNEM_MINPD, + /* 12B */ MNEM_MINPS, + /* 12C */ MNEM_MINSD, + /* 12D */ MNEM_MINSS, + /* 12E */ MNEM_MONITOR, + /* 12F */ MNEM_MONTMUL, + /* 130 */ MNEM_MOV, + /* 131 */ MNEM_MOVAPD, + /* 132 */ MNEM_MOVAPS, + /* 133 */ MNEM_MOVBE, + /* 134 */ MNEM_MOVD, + /* 135 */ MNEM_MOVDDUP, + /* 136 */ MNEM_MOVDQ2Q, + /* 137 */ MNEM_MOVDQA, + /* 138 */ MNEM_MOVDQU, + /* 139 */ MNEM_MOVHLPS, + /* 13A */ MNEM_MOVHPD, + /* 13B */ MNEM_MOVHPS, + /* 13C */ MNEM_MOVLHPS, + /* 13D */ MNEM_MOVLPD, + /* 13E */ MNEM_MOVLPS, + /* 13F */ MNEM_MOVMSKPD, + /* 140 */ MNEM_MOVMSKPS, + /* 141 */ MNEM_MOVNTDQ, + /* 142 */ MNEM_MOVNTDQA, + /* 143 */ MNEM_MOVNTI, + /* 144 */ MNEM_MOVNTPD, + /* 145 */ MNEM_MOVNTPS, + /* 146 */ MNEM_MOVNTQ, + /* 147 */ MNEM_MOVQ, + /* 148 */ MNEM_MOVQ2DQ, + /* 149 */ MNEM_MOVSB, + /* 14A */ MNEM_MOVSD, + /* 14B */ MNEM_MOVSHDUP, + /* 14C */ MNEM_MOVSLDUP, + /* 14D */ MNEM_MOVSQ, + /* 14E */ MNEM_MOVSS, + /* 14F */ MNEM_MOVSW, + /* 150 */ MNEM_MOVSX, + /* 151 */ MNEM_MOVSXD, + /* 152 */ MNEM_MOVUPD, + /* 153 */ MNEM_MOVUPS, + /* 154 */ MNEM_MOVZX, + /* 155 */ MNEM_MPSADBW, + /* 156 */ MNEM_MUL, + /* 157 */ MNEM_MULPD, + /* 158 */ MNEM_MULPS, + /* 159 */ MNEM_MULSD, + /* 15A */ MNEM_MULSS, + /* 15B */ MNEM_MWAIT, + /* 15C */ MNEM_NEG, + /* 15D */ MNEM_NOP, + /* 15E */ MNEM_NOT, + /* 15F */ MNEM_OR, + /* 160 */ MNEM_ORPD, + /* 161 */ MNEM_ORPS, + /* 162 */ MNEM_OUT, + /* 163 */ MNEM_OUTSB, + /* 164 */ MNEM_OUTSD, + /* 165 */ MNEM_OUTSW, + /* 166 */ MNEM_PABSB, + /* 167 */ MNEM_PABSD, + /* 168 */ MNEM_PABSW, + /* 169 */ MNEM_PACKSSDW, + /* 16A */ MNEM_PACKSSWB, + /* 16B */ MNEM_PACKUSDW, + /* 16C */ MNEM_PACKUSWB, + /* 16D */ MNEM_PADDB, + /* 16E */ MNEM_PADDD, + /* 16F */ MNEM_PADDQ, + /* 170 */ MNEM_PADDSB, + /* 171 */ MNEM_PADDSW, + /* 172 */ MNEM_PADDUSB, + /* 173 */ MNEM_PADDUSW, + /* 174 */ MNEM_PADDW, + /* 175 */ MNEM_PALIGNR, + /* 176 */ MNEM_PAND, + /* 177 */ MNEM_PANDN, + /* 178 */ MNEM_PAUSE, + /* 179 */ MNEM_PAVGB, + /* 17A */ MNEM_PAVGUSB, + /* 17B */ MNEM_PAVGW, + /* 17C */ MNEM_PBLENDVB, + /* 17D */ MNEM_PBLENDW, + /* 17E */ MNEM_PCLMULQDQ, + /* 17F */ MNEM_PCMPEQB, + /* 180 */ MNEM_PCMPEQD, + /* 181 */ MNEM_PCMPEQQ, + /* 182 */ MNEM_PCMPEQW, + /* 183 */ MNEM_PCMPESTRI, + /* 184 */ MNEM_PCMPESTRM, + /* 185 */ MNEM_PCMPGTB, + /* 186 */ MNEM_PCMPGTD, + /* 187 */ MNEM_PCMPGTQ, + /* 188 */ MNEM_PCMPGTW, + /* 189 */ MNEM_PCMPISTRI, + /* 18A */ MNEM_PCMPISTRM, + /* 18B */ MNEM_PEXTRB, + /* 18C */ MNEM_PEXTRD, + /* 18D */ MNEM_PEXTRQ, + /* 18E */ MNEM_PEXTRW, + /* 18F */ MNEM_PF2ID, + /* 190 */ MNEM_PF2IW, + /* 191 */ MNEM_PFACC, + /* 192 */ MNEM_PFADD, + /* 193 */ MNEM_PFCMPEQ, + /* 194 */ MNEM_PFCMPGE, + /* 195 */ MNEM_PFCMPGT, + /* 196 */ MNEM_PFMAX, + /* 197 */ MNEM_PFMIN, + /* 198 */ MNEM_PFMUL, + /* 199 */ MNEM_PFNACC, + /* 19A */ MNEM_PFPNACC, + /* 19B */ MNEM_PFRCP, + /* 19C */ MNEM_PFRCPIT1, + /* 19D */ MNEM_PFRCPIT2, + /* 19E */ MNEM_PFRSQIT1, + /* 19F */ MNEM_PFRSQRT, + /* 1A0 */ MNEM_PFSUB, + /* 1A1 */ MNEM_PFSUBR, + /* 1A2 */ MNEM_PHADDD, + /* 1A3 */ MNEM_PHADDSW, + /* 1A4 */ MNEM_PHADDW, + /* 1A5 */ MNEM_PHMINPOSUW, + /* 1A6 */ MNEM_PHSUBD, + /* 1A7 */ MNEM_PHSUBSW, + /* 1A8 */ MNEM_PHSUBW, + /* 1A9 */ MNEM_PI2FD, + /* 1AA */ MNEM_PI2FW, + /* 1AB */ MNEM_PINSRB, + /* 1AC */ MNEM_PINSRD, + /* 1AD */ MNEM_PINSRQ, + /* 1AE */ MNEM_PINSRW, + /* 1AF */ MNEM_PMADDUBSW, + /* 1B0 */ MNEM_PMADDWD, + /* 1B1 */ MNEM_PMAXSB, + /* 1B2 */ MNEM_PMAXSD, + /* 1B3 */ MNEM_PMAXSW, + /* 1B4 */ MNEM_PMAXUB, + /* 1B5 */ MNEM_PMAXUD, + /* 1B6 */ MNEM_PMAXUW, + /* 1B7 */ MNEM_PMINSB, + /* 1B8 */ MNEM_PMINSD, + /* 1B9 */ MNEM_PMINSW, + /* 1BA */ MNEM_PMINUB, + /* 1BB */ MNEM_PMINUD, + /* 1BC */ MNEM_PMINUW, + /* 1BD */ MNEM_PMOVMSKB, + /* 1BE */ MNEM_PMOVSXBD, + /* 1BF */ MNEM_PMOVSXBQ, + /* 1C0 */ MNEM_PMOVSXBW, + /* 1C1 */ MNEM_PMOVSXDQ, + /* 1C2 */ MNEM_PMOVSXWD, + /* 1C3 */ MNEM_PMOVSXWQ, + /* 1C4 */ MNEM_PMOVZXBD, + /* 1C5 */ MNEM_PMOVZXBQ, + /* 1C6 */ MNEM_PMOVZXBW, + /* 1C7 */ MNEM_PMOVZXDQ, + /* 1C8 */ MNEM_PMOVZXWD, + /* 1C9 */ MNEM_PMOVZXWQ, + /* 1CA */ MNEM_PMULDQ, + /* 1CB */ MNEM_PMULHRSW, + /* 1CC */ MNEM_PMULHRW, + /* 1CD */ MNEM_PMULHUW, + /* 1CE */ MNEM_PMULHW, + /* 1CF */ MNEM_PMULLD, + /* 1D0 */ MNEM_PMULLW, + /* 1D1 */ MNEM_PMULUDQ, + /* 1D2 */ MNEM_POP, + /* 1D3 */ MNEM_POPA, + /* 1D4 */ MNEM_POPAD, + /* 1D5 */ MNEM_POPCNT, + /* 1D6 */ MNEM_POPFD, + /* 1D7 */ MNEM_POPFQ, + /* 1D8 */ MNEM_POPFW, + /* 1D9 */ MNEM_POR, + /* 1DA */ MNEM_PREFETCH, + /* 1DB */ MNEM_PREFETCHNTA, + /* 1DC */ MNEM_PREFETCHT0, + /* 1DD */ MNEM_PREFETCHT1, + /* 1DE */ MNEM_PREFETCHT2, + /* 1DF */ MNEM_PSADBW, + /* 1E0 */ MNEM_PSHUFB, + /* 1E1 */ MNEM_PSHUFD, + /* 1E2 */ MNEM_PSHUFHW, + /* 1E3 */ MNEM_PSHUFLW, + /* 1E4 */ MNEM_PSHUFW, + /* 1E5 */ MNEM_PSIGNB, + /* 1E6 */ MNEM_PSIGND, + /* 1E7 */ MNEM_PSIGNW, + /* 1E8 */ MNEM_PSLLD, + /* 1E9 */ MNEM_PSLLDQ, + /* 1EA */ MNEM_PSLLQ, + /* 1EB */ MNEM_PSLLW, + /* 1EC */ MNEM_PSRAD, + /* 1ED */ MNEM_PSRAW, + /* 1EE */ MNEM_PSRLD, + /* 1EF */ MNEM_PSRLDQ, + /* 1F0 */ MNEM_PSRLQ, + /* 1F1 */ MNEM_PSRLW, + /* 1F2 */ MNEM_PSUBB, + /* 1F3 */ MNEM_PSUBD, + /* 1F4 */ MNEM_PSUBQ, + /* 1F5 */ MNEM_PSUBSB, + /* 1F6 */ MNEM_PSUBSW, + /* 1F7 */ MNEM_PSUBUSB, + /* 1F8 */ MNEM_PSUBUSW, + /* 1F9 */ MNEM_PSUBW, + /* 1FA */ MNEM_PSWAPD, + /* 1FB */ MNEM_PTEST, + /* 1FC */ MNEM_PUNPCKHBW, + /* 1FD */ MNEM_PUNPCKHDQ, + /* 1FE */ MNEM_PUNPCKHQDQ, + /* 1FF */ MNEM_PUNPCKHWD, + /* 200 */ MNEM_PUNPCKLBW, + /* 201 */ MNEM_PUNPCKLDQ, + /* 202 */ MNEM_PUNPCKLQDQ, + /* 203 */ MNEM_PUNPCKLWD, + /* 204 */ MNEM_PUSH, + /* 205 */ MNEM_PUSHA, + /* 206 */ MNEM_PUSHAD, + /* 207 */ MNEM_PUSHFD, + /* 208 */ MNEM_PUSHFQ, + /* 209 */ MNEM_PUSHFW, + /* 20A */ MNEM_PXOR, + /* 20B */ MNEM_RCL, + /* 20C */ MNEM_RCPPS, + /* 20D */ MNEM_RCPSS, + /* 20E */ MNEM_RCR, + /* 20F */ MNEM_RDMSR, + /* 210 */ MNEM_RDPMC, + /* 211 */ MNEM_RDRAND, + /* 212 */ MNEM_RDTSC, + /* 213 */ MNEM_RDTSCP, + /* 214 */ MNEM_REP, + /* 215 */ MNEM_REPNE, + /* 216 */ MNEM_RET, + /* 217 */ MNEM_RETF, + /* 218 */ MNEM_ROL, + /* 219 */ MNEM_ROR, + /* 21A */ MNEM_ROUNDPD, + /* 21B */ MNEM_ROUNDPS, + /* 21C */ MNEM_ROUNDSD, + /* 21D */ MNEM_ROUNDSS, + /* 21E */ MNEM_RSM, + /* 21F */ MNEM_RSQRTPS, + /* 220 */ MNEM_RSQRTSS, + /* 221 */ MNEM_SAHF, + /* 222 */ MNEM_SALC, + /* 223 */ MNEM_SAR, + /* 224 */ MNEM_SBB, + /* 225 */ MNEM_SCASB, + /* 226 */ MNEM_SCASD, + /* 227 */ MNEM_SCASQ, + /* 228 */ MNEM_SCASW, + /* 229 */ MNEM_SETA, + /* 22A */ MNEM_SETAE, + /* 22B */ MNEM_SETB, + /* 22C */ MNEM_SETBE, + /* 22D */ MNEM_SETE, + /* 22E */ MNEM_SETG, + /* 22F */ MNEM_SETGE, + /* 230 */ MNEM_SETL, + /* 231 */ MNEM_SETLE, + /* 232 */ MNEM_SETNE, + /* 233 */ MNEM_SETNO, + /* 234 */ MNEM_SETNP, + /* 235 */ MNEM_SETNS, + /* 236 */ MNEM_SETO, + /* 237 */ MNEM_SETP, + /* 238 */ MNEM_SETS, + /* 239 */ MNEM_SFENCE, + /* 23A */ MNEM_SGDT, + /* 23B */ MNEM_SHL, + /* 23C */ MNEM_SHLD, + /* 23D */ MNEM_SHR, + /* 23E */ MNEM_SHRD, + /* 23F */ MNEM_SHUFPD, + /* 240 */ MNEM_SHUFPS, + /* 241 */ MNEM_SIDT, + /* 242 */ MNEM_SKINIT, + /* 243 */ MNEM_SLDT, + /* 244 */ MNEM_SMSW, + /* 245 */ MNEM_SQRTPD, + /* 246 */ MNEM_SQRTPS, + /* 247 */ MNEM_SQRTSD, + /* 248 */ MNEM_SQRTSS, + /* 249 */ MNEM_STC, + /* 24A */ MNEM_STD, + /* 24B */ MNEM_STGI, + /* 24C */ MNEM_STI, + /* 24D */ MNEM_STMXCSR, + /* 24E */ MNEM_STOSB, + /* 24F */ MNEM_STOSD, + /* 250 */ MNEM_STOSQ, + /* 251 */ MNEM_STOSW, + /* 252 */ MNEM_STR, + /* 253 */ MNEM_SUB, + /* 254 */ MNEM_SUBPD, + /* 255 */ MNEM_SUBPS, + /* 256 */ MNEM_SUBSD, + /* 257 */ MNEM_SUBSS, + /* 258 */ MNEM_SWAPGS, + /* 259 */ MNEM_SYSCALL, + /* 25A */ MNEM_SYSENTER, + /* 25B */ MNEM_SYSEXIT, + /* 25C */ MNEM_SYSRET, + /* 25D */ MNEM_TEST, + /* 25E */ MNEM_UCOMISD, + /* 25F */ MNEM_UCOMISS, + /* 260 */ MNEM_UD2, + /* 261 */ MNEM_UNPCKHPD, + /* 262 */ MNEM_UNPCKHPS, + /* 263 */ MNEM_UNPCKLPD, + /* 264 */ MNEM_UNPCKLPS, + /* 265 */ MNEM_VADDPD, + /* 266 */ MNEM_VADDPS, + /* 267 */ MNEM_VADDSD, + /* 268 */ MNEM_VADDSS, + /* 269 */ MNEM_VADDSUBPD, + /* 26A */ MNEM_VADDSUBPS, + /* 26B */ MNEM_VAESDEC, + /* 26C */ MNEM_VAESDECLAST, + /* 26D */ MNEM_VAESENC, + /* 26E */ MNEM_VAESENCLAST, + /* 26F */ MNEM_VAESIMC, + /* 270 */ MNEM_VAESKEYGENASSIST, + /* 271 */ MNEM_VANDNPD, + /* 272 */ MNEM_VANDNPS, + /* 273 */ MNEM_VANDPD, + /* 274 */ MNEM_VANDPS, + /* 275 */ MNEM_VBLENDPD, + /* 276 */ MNEM_VBLENDPS, + /* 277 */ MNEM_VBLENDVPD, + /* 278 */ MNEM_VBLENDVPS, + /* 279 */ MNEM_VBROADCASTSD, + /* 27A */ MNEM_VBROADCASTSS, + /* 27B */ MNEM_VCMPPD, + /* 27C */ MNEM_VCMPPS, + /* 27D */ MNEM_VCMPSD, + /* 27E */ MNEM_VCMPSS, + /* 27F */ MNEM_VCOMISD, + /* 280 */ MNEM_VCOMISS, + /* 281 */ MNEM_VCVTDQ2PD, + /* 282 */ MNEM_VCVTDQ2PS, + /* 283 */ MNEM_VCVTPD2DQ, + /* 284 */ MNEM_VCVTPD2PS, + /* 285 */ MNEM_VCVTPS2DQ, + /* 286 */ MNEM_VCVTPS2PD, + /* 287 */ MNEM_VCVTSD2SI, + /* 288 */ MNEM_VCVTSD2SS, + /* 289 */ MNEM_VCVTSI2SD, + /* 28A */ MNEM_VCVTSI2SS, + /* 28B */ MNEM_VCVTSS2SD, + /* 28C */ MNEM_VCVTSS2SI, + /* 28D */ MNEM_VCVTTPD2DQ, + /* 28E */ MNEM_VCVTTPS2DQ, + /* 28F */ MNEM_VCVTTSD2SI, + /* 290 */ MNEM_VCVTTSS2SI, + /* 291 */ MNEM_VDIVPD, + /* 292 */ MNEM_VDIVPS, + /* 293 */ MNEM_VDIVSD, + /* 294 */ MNEM_VDIVSS, + /* 295 */ MNEM_VDPPD, + /* 296 */ MNEM_VDPPS, + /* 297 */ MNEM_VERR, + /* 298 */ MNEM_VERW, + /* 299 */ MNEM_VEXTRACTF128, + /* 29A */ MNEM_VEXTRACTPS, + /* 29B */ MNEM_VHADDPD, + /* 29C */ MNEM_VHADDPS, + /* 29D */ MNEM_VHSUBPD, + /* 29E */ MNEM_VHSUBPS, + /* 29F */ MNEM_VINSERTF128, + /* 2A0 */ MNEM_VINSERTPS, + /* 2A1 */ MNEM_VLDDQU, + /* 2A2 */ MNEM_VMASKMOVDQU, + /* 2A3 */ MNEM_VMASKMOVPD, + /* 2A4 */ MNEM_VMASKMOVPS, + /* 2A5 */ MNEM_VMAXPD, + /* 2A6 */ MNEM_VMAXPS, + /* 2A7 */ MNEM_VMAXSD, + /* 2A8 */ MNEM_VMAXSS, + /* 2A9 */ MNEM_VMCALL, + /* 2AA */ MNEM_VMCLEAR, + /* 2AB */ MNEM_VMINPD, + /* 2AC */ MNEM_VMINPS, + /* 2AD */ MNEM_VMINSD, + /* 2AE */ MNEM_VMINSS, + /* 2AF */ MNEM_VMLAUNCH, + /* 2B0 */ MNEM_VMLOAD, + /* 2B1 */ MNEM_VMMCALL, + /* 2B2 */ MNEM_VMOVAPD, + /* 2B3 */ MNEM_VMOVAPS, + /* 2B4 */ MNEM_VMOVD, + /* 2B5 */ MNEM_VMOVDDUP, + /* 2B6 */ MNEM_VMOVDQA, + /* 2B7 */ MNEM_VMOVDQU, + /* 2B8 */ MNEM_VMOVHLPS, + /* 2B9 */ MNEM_VMOVHPD, + /* 2BA */ MNEM_VMOVHPS, + /* 2BB */ MNEM_VMOVLHPS, + /* 2BC */ MNEM_VMOVLPD, + /* 2BD */ MNEM_VMOVLPS, + /* 2BE */ MNEM_VMOVMSKPD, + /* 2BF */ MNEM_VMOVMSKPS, + /* 2C0 */ MNEM_VMOVNTDQ, + /* 2C1 */ MNEM_VMOVNTDQA, + /* 2C2 */ MNEM_VMOVNTPD, + /* 2C3 */ MNEM_VMOVNTPS, + /* 2C4 */ MNEM_VMOVQ, + /* 2C5 */ MNEM_VMOVSD, + /* 2C6 */ MNEM_VMOVSHDUP, + /* 2C7 */ MNEM_VMOVSLDUP, + /* 2C8 */ MNEM_VMOVSS, + /* 2C9 */ MNEM_VMOVUPD, + /* 2CA */ MNEM_VMOVUPS, + /* 2CB */ MNEM_VMPSADBW, + /* 2CC */ MNEM_VMPTRLD, + /* 2CD */ MNEM_VMPTRST, + /* 2CE */ MNEM_VMREAD, + /* 2CF */ MNEM_VMRESUME, + /* 2D0 */ MNEM_VMRUN, + /* 2D1 */ MNEM_VMSAVE, + /* 2D2 */ MNEM_VMULPD, + /* 2D3 */ MNEM_VMULPS, + /* 2D4 */ MNEM_VMULSD, + /* 2D5 */ MNEM_VMULSS, + /* 2D6 */ MNEM_VMWRITE, + /* 2D7 */ MNEM_VMXOFF, + /* 2D8 */ MNEM_VMXON, + /* 2D9 */ MNEM_VORPD, + /* 2DA */ MNEM_VORPS, + /* 2DB */ MNEM_VPABSB, + /* 2DC */ MNEM_VPABSD, + /* 2DD */ MNEM_VPABSW, + /* 2DE */ MNEM_VPACKSSDW, + /* 2DF */ MNEM_VPACKSSWB, + /* 2E0 */ MNEM_VPACKUSDW, + /* 2E1 */ MNEM_VPACKUSWB, + /* 2E2 */ MNEM_VPADDB, + /* 2E3 */ MNEM_VPADDD, + /* 2E4 */ MNEM_VPADDQ, + /* 2E5 */ MNEM_VPADDSB, + /* 2E6 */ MNEM_VPADDSW, + /* 2E7 */ MNEM_VPADDUSB, + /* 2E8 */ MNEM_VPADDUSW, + /* 2E9 */ MNEM_VPADDW, + /* 2EA */ MNEM_VPALIGNR, + /* 2EB */ MNEM_VPAND, + /* 2EC */ MNEM_VPANDN, + /* 2ED */ MNEM_VPAVGB, + /* 2EE */ MNEM_VPAVGW, + /* 2EF */ MNEM_VPBLENDVB, + /* 2F0 */ MNEM_VPBLENDW, + /* 2F1 */ MNEM_VPCLMULQDQ, + /* 2F2 */ MNEM_VPCMPEQB, + /* 2F3 */ MNEM_VPCMPEQD, + /* 2F4 */ MNEM_VPCMPEQQ, + /* 2F5 */ MNEM_VPCMPEQW, + /* 2F6 */ MNEM_VPCMPESTRI, + /* 2F7 */ MNEM_VPCMPESTRM, + /* 2F8 */ MNEM_VPCMPGTB, + /* 2F9 */ MNEM_VPCMPGTD, + /* 2FA */ MNEM_VPCMPGTQ, + /* 2FB */ MNEM_VPCMPGTW, + /* 2FC */ MNEM_VPCMPISTRI, + /* 2FD */ MNEM_VPCMPISTRM, + /* 2FE */ MNEM_VPERM2F128, + /* 2FF */ MNEM_VPERMILPD, + /* 300 */ MNEM_VPERMILPS, + /* 301 */ MNEM_VPEXTRB, + /* 302 */ MNEM_VPEXTRD, + /* 303 */ MNEM_VPEXTRQ, + /* 304 */ MNEM_VPEXTRW, + /* 305 */ MNEM_VPHADDD, + /* 306 */ MNEM_VPHADDSW, + /* 307 */ MNEM_VPHADDW, + /* 308 */ MNEM_VPHMINPOSUW, + /* 309 */ MNEM_VPHSUBD, + /* 30A */ MNEM_VPHSUBSW, + /* 30B */ MNEM_VPHSUBW, + /* 30C */ MNEM_VPINSRB, + /* 30D */ MNEM_VPINSRD, + /* 30E */ MNEM_VPINSRQ, + /* 30F */ MNEM_VPINSRW, + /* 310 */ MNEM_VPMADDUBSW, + /* 311 */ MNEM_VPMADDWD, + /* 312 */ MNEM_VPMAXSB, + /* 313 */ MNEM_VPMAXSD, + /* 314 */ MNEM_VPMAXSW, + /* 315 */ MNEM_VPMAXUB, + /* 316 */ MNEM_VPMAXUD, + /* 317 */ MNEM_VPMAXUW, + /* 318 */ MNEM_VPMINSB, + /* 319 */ MNEM_VPMINSD, + /* 31A */ MNEM_VPMINSW, + /* 31B */ MNEM_VPMINUB, + /* 31C */ MNEM_VPMINUD, + /* 31D */ MNEM_VPMINUW, + /* 31E */ MNEM_VPMOVMSKB, + /* 31F */ MNEM_VPMOVSXBD, + /* 320 */ MNEM_VPMOVSXBQ, + /* 321 */ MNEM_VPMOVSXBW, + /* 322 */ MNEM_VPMOVSXWD, + /* 323 */ MNEM_VPMOVSXWQ, + /* 324 */ MNEM_VPMOVZXBD, + /* 325 */ MNEM_VPMOVZXBQ, + /* 326 */ MNEM_VPMOVZXBW, + /* 327 */ MNEM_VPMOVZXDQ, + /* 328 */ MNEM_VPMOVZXWD, + /* 329 */ MNEM_VPMOVZXWQ, + /* 32A */ MNEM_VPMULDQ, + /* 32B */ MNEM_VPMULHRSW, + /* 32C */ MNEM_VPMULHUW, + /* 32D */ MNEM_VPMULHW, + /* 32E */ MNEM_VPMULLD, + /* 32F */ MNEM_VPMULLW, + /* 330 */ MNEM_VPOR, + /* 331 */ MNEM_VPSADBW, + /* 332 */ MNEM_VPSHUFB, + /* 333 */ MNEM_VPSHUFD, + /* 334 */ MNEM_VPSHUFHW, + /* 335 */ MNEM_VPSHUFLW, + /* 336 */ MNEM_VPSIGNB, + /* 337 */ MNEM_VPSIGND, + /* 338 */ MNEM_VPSIGNW, + /* 339 */ MNEM_VPSLLD, + /* 33A */ MNEM_VPSLLDQ, + /* 33B */ MNEM_VPSLLQ, + /* 33C */ MNEM_VPSLLW, + /* 33D */ MNEM_VPSRAD, + /* 33E */ MNEM_VPSRAW, + /* 33F */ MNEM_VPSRLD, + /* 340 */ MNEM_VPSRLDQ, + /* 341 */ MNEM_VPSRLQ, + /* 342 */ MNEM_VPSRLW, + /* 343 */ MNEM_VPSUBB, + /* 344 */ MNEM_VPSUBD, + /* 345 */ MNEM_VPSUBQ, + /* 346 */ MNEM_VPSUBSB, + /* 347 */ MNEM_VPSUBSW, + /* 348 */ MNEM_VPSUBUSB, + /* 349 */ MNEM_VPSUBUSW, + /* 34A */ MNEM_VPSUBW, + /* 34B */ MNEM_VPTEST, + /* 34C */ MNEM_VPUNPCKHBW, + /* 34D */ MNEM_VPUNPCKHDQ, + /* 34E */ MNEM_VPUNPCKHQDQ, + /* 34F */ MNEM_VPUNPCKHWD, + /* 350 */ MNEM_VPUNPCKLBW, + /* 351 */ MNEM_VPUNPCKLDQ, + /* 352 */ MNEM_VPUNPCKLQDQ, + /* 353 */ MNEM_VPUNPCKLWD, + /* 354 */ MNEM_VPXOR, + /* 355 */ MNEM_VRCPPS, + /* 356 */ MNEM_VRCPSS, + /* 357 */ MNEM_VROUNDPD, + /* 358 */ MNEM_VROUNDPS, + /* 359 */ MNEM_VROUNDSD, + /* 35A */ MNEM_VROUNDSS, + /* 35B */ MNEM_VRSQRTPS, + /* 35C */ MNEM_VRSQRTSS, + /* 35D */ MNEM_VSHUFPD, + /* 35E */ MNEM_VSHUFPS, + /* 35F */ MNEM_VSQRTPD, + /* 360 */ MNEM_VSQRTPS, + /* 361 */ MNEM_VSQRTSD, + /* 362 */ MNEM_VSQRTSS, + /* 363 */ MNEM_VSTMXCSR, + /* 364 */ MNEM_VSUBPD, + /* 365 */ MNEM_VSUBPS, + /* 366 */ MNEM_VSUBSD, + /* 367 */ MNEM_VSUBSS, + /* 368 */ MNEM_VTESTPD, + /* 369 */ MNEM_VTESTPS, + /* 36A */ MNEM_VUCOMISD, + /* 36B */ MNEM_VUCOMISS, + /* 36C */ MNEM_VUNPCKHPD, + /* 36D */ MNEM_VUNPCKHPS, + /* 36E */ MNEM_VUNPCKLPD, + /* 36F */ MNEM_VUNPCKLPS, + /* 370 */ MNEM_VXORPD, + /* 371 */ MNEM_VXORPS, + /* 372 */ MNEM_VZEROALL, + /* 373 */ MNEM_VZEROUPPER, + /* 374 */ MNEM_WAIT, + /* 375 */ MNEM_WBINVD, + /* 376 */ MNEM_WRMSR, + /* 377 */ MNEM_XADD, + /* 378 */ MNEM_XCHG, + /* 379 */ MNEM_XCRYPTCBC, + /* 37A */ MNEM_XCRYPTCFB, + /* 37B */ MNEM_XCRYPTCTR, + /* 37C */ MNEM_XCRYPTECB, + /* 37D */ MNEM_XCRYPTOFB, + /* 37E */ MNEM_XGETBV, + /* 37F */ MNEM_XLATB, + /* 380 */ MNEM_XOR, + /* 381 */ MNEM_XORPD, + /* 382 */ MNEM_XORPS, + /* 383 */ MNEM_XRSTOR, + /* 384 */ MNEM_XSAVE, + /* 385 */ MNEM_XSETBV, + /* 386 */ MNEM_XSHA1, + /* 387 */ MNEM_XSHA256, + /* 388 */ MNEM_XSTORE, + + MNEM_FORCE_WORD = 0x7FFF +} VXInstructionMnemonic; /** * @brief Defines an alias representing an opcode tree node. An opcode tree node is a 16 bit @@ -958,435 +964,435 @@ typedef uint16_t VXOpcodeTreeNode; /** * @brief Values that represent the type of an opcode tree node. */ -enum class VXOpcodeTreeNodeType : uint8_t +typedef enum _VXOpcodeTreeNodeType /* : uint8_t */ { /** * @brief Reference to a concrete instruction definition. */ - INSTRUCTION_DEFINITION = 0, + OTNT_INSTRUCTION_DEFINITION = 0, /** * @brief Reference to an opcode table. */ - TABLE = 1, + OTNT_TABLE = 1, /** * @brief Reference to a modrm_mod switch table. */ - MODRM_MOD = 2, + OTNT_MODRM_MOD = 2, /** * @brief Reference to a modrm_reg switch table. */ - MODRM_REG = 3, + OTNT_MODRM_REG = 3, /** * @brief Reference to a modrm_rm switch table. */ - MODRM_RM = 4, + OTNT_MODRM_RM = 4, /** * @brief Reference to a mandatory-prefix switch table. */ - MANDATORY = 5, + OTNT_MANDATORY = 5, /** * @brief Reference to a x87 opcode table. */ - X87 = 6, + OTNT_X87 = 6, /** * @brief Reference to an address-size switch table. */ - ADDRESS_SIZE = 7, + OTNT_ADDRESS_SIZE = 7, /** * @brief Reference to an operand-size switch table. */ - OPERAND_SIZE = 8, + OTNT_OPERAND_SIZE = 8, /** * @brief Reference to a cpu-mode switch table. */ - MODE = 9, + OTNT_MODE = 9, /** * @brief Reference to a vendor switch table. */ - VENDOR = 10, + OTNT_VENDOR = 10, /** * @brief Reference to a 3dnow! opcode table. */ - AMD3DNOW = 11, + OTNT_AMD3DNOW = 11, /** * @brief Reference to a vex-prefix switch table. */ - VEX = 12, + OTNT_VEX = 12, /** * @brief Reference to a vex_w switch table. */ - VEXW = 13, + OTNT_VEXW = 13, /** * @brief Reference to a vex_l switch table. */ - VEXL = 14 -}; + OTNT_VEXL = 14 +} VXOpcodeTreeNodeType; /** * @brief Values that represent the type of an operand in the instruction definition. */ -enum class VXDefinedOperandType : uint8_t +typedef enum _VXDefinedOperandType /* : uint8_t */ { /* * @brief No operand. */ - NONE, + DOT_NONE, /* * @brief Direct address. The instruction has no ModR/M byte; the address of the operand is * encoded in the instruction; no base register, index register, or scaling factor * can be applied. */ - A, + DOT_A, /* * @brief The reg field of the ModR/M byte selects a control register. */ - C, + DOT_C, /* * @brief The reg field of the ModR/M byte selects a debug register. */ - D, + DOT_D, /* * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either * a general-purpose register or a memory address. If it is a memory address, the * address is computed from a segment register and any of the following values: * a base register, an index register, a scaling factor, or a displacement. */ - E, + DOT_E, /* * @brief rFLAGS register. */ - F, + DOT_F, /* * @brief The reg field of the ModR/M byte selects a general register. */ - G, + DOT_G, /* * @brief The r/m field of the ModR/M byte always selects a general register, regardless of * the mod field. */ - H, + DOT_H, /* * @brief Immediate data. The operand value is encoded in subsequent bytes of the * instruction. */ - I, + DOT_I, /* * @brief Signed immediate data. The operand value is encoded in subsequent bytes of the * instruction. */ - sI, + DOT_sI, /* * @brief Constant immediate data value of 1. */ - I1, + DOT_I1, /* * @brief The instruction contains a relative offset to be added to the instruction pointer * register. */ - J, + DOT_J, /* * @brief Source operand is encoded in immediate byte (VEX only). */ - L, + DOT_L, /* * @brief The ModR/M byte may refer only to memory: mod != 11bin. */ - M, + DOT_M, /* * @brief Combination of M and R. */ - MR, + DOT_MR, /* * @brief Combination of M and U. */ - MU, + DOT_MU, /* * @brief The R/M field of the ModR/M byte selects a packed quadword MMX technology register. */ - N, + DOT_N, /* * @brief The instruction has no ModR/M byte; the offset of the operand is coded as a word, * double word or quad word (depending on address size attribute) in the instruction. * No base register, index register, or scaling factor can be applied. */ - O, + DOT_O, /* * @brief The reg field of the ModR/M byte selects a packed quadword MMX technology register. */ - P, + DOT_P, /* * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either * an MMX technology register or a memory address. If it is a memory address, the * address is computed from a segment register and any of the following values: * a base register, an index register, a scaling factor, and a displacement. */ - Q, + DOT_Q, /* * @brief The mod field of the ModR/M byte may refer only to a general register. */ - R, + DOT_R, /* * @brief The reg field of the ModR/M byte selects a segment register. */ - S, + DOT_S, /* * @brief The R/M field of the ModR/M byte selects a 128-bit XMM register. */ - U, + DOT_U, /* * @brief The reg field of the ModR/M byte selects a 128-bit XMM register. */ - V, + DOT_V, /* * @brief A ModR/M byte follows the opcode and specifies the operand. The operand is either * a 128-bit XMM register or a memory address. If it is a memory address, the address * is computed from a segment register and any of the following values: * a base register, an index register, a scaling factor, and a displacement. */ - W, + DOT_W, /** * @brief Register 0. */ - R0, + DOT_R0, /** * @brief Register 1. */ - R1, + DOT_R1, /** * @brief Register 2. */ - R2, + DOT_R2, /** * @brief Register 3. */ - R3, + DOT_R3, /** * @brief Register 4. */ - R4, + DOT_R4, /** * @brief Register 5. */ - R5, + DOT_R5, /** * @brief Register 6. */ - R6, + DOT_R6, /** * @brief Register 7. */ - R7, + DOT_R7, /** * @brief AL register. */ - AL, + DOT_AL, /** * @brief CL register. */ - CL, + DOT_CL, /** * @brief DL register. */ - DL, + DOT_DL, /** * @brief AX register. */ - AX, + DOT_AX, /** * @brief CX register. */ - CX, + DOT_CX, /** * @brief DX register. */ - DX, + DOT_DX, /** * @brief EAX register. */ - EAX, + DOT_EAX, /** * @brief ECX register. */ - ECX, + DOT_ECX, /** * @brief EDX register. */ - EDX, + DOT_EDX, /** * @brief RAX register. */ - RAX, + DOT_RAX, /** * @brief RCX register. */ - RCX, + DOT_RCX, /** * @brief RDX register. */ - RDX, + DOT_RDX, /** * @brief ES segment register. */ - ES, + DOT_ES, /** * @brief CS segment register. */ - CS, + DOT_CS, /** * @brief SS segment register. */ - SS, + DOT_SS, /** * @brief DS segment register. */ - DS, + DOT_DS, /** * @brief FS segment register. */ - FS, + DOT_FS, /** * @brief GS segment register. */ - GS, + DOT_GS, /** * @brief Floating point register 0. */ - ST0, + DOT_ST0, /** * @brief Floating point register 1. */ - ST1, + DOT_ST1, /** * @brief Floating point register 2. */ - ST2, + DOT_ST2, /** * @brief Floating point register 3. */ - ST3, + DOT_ST3, /** * @brief Floating point register 4. */ - ST4, + DOT_ST4, /** * @brief Floating point register 5. */ - ST5, + DOT_ST5, /** * @brief Floating point register 6. */ - ST6, + DOT_ST6, /** * @brief Floating point register 7. */ - ST7 -}; + DOT_ST7 +} VXDefinedOperandType; /** * @brief Values that represent the size of an operand in the instruction definition. * Do not change the order or the values of this enum! */ -enum class VXDefinedOperandSize : uint8_t +typedef enum _VXDefinedOperandSize /* : uint8_t */ { /** * @brief No operand. */ - NA = 0, + DOS_NA = 0, /** * @brief Word, dword or qword. */ - Z, + DOS_Z, /** * @brief Word, dword or qword. */ - V, + DOS_V, /** * @brief Dword or qword. */ - Y, + DOS_Y, /** * @brief Oword or yword. */ - X, + DOS_X, /** * @brief Dword or qword, depending on the disassembler mode. */ - RDQ, + DOS_RDQ, /* * @brief Byte, regardless of operand-size attribute. */ - B, + DOS_B, /* * @brief Word, regardless of operand-size attribute. */ - W, + DOS_W, /* * @brief Doubleword, regardless of operand-size attribute. */ - D, + DOS_D, /* * @brief Quadword, regardless of operand-size attribute. */ - Q, + DOS_Q, /* * @brief 10-byte far pointer. */ - T, + DOS_T, /** * @brief TODO: */ - O, + DOS_O, /* * @brief Double-quadword, regardless of operand-size attribute. */ - DQ, + DOS_DQ, /* * @brief Quad-quadword, regardless of operand-size attribute. */ - QQ, + DOS_QQ, /** * @brief B sized register or D sized memory operand. */ - BD = (static_cast(B) << 4) | static_cast(D), + DOS_BD = (DOS_B << 4) | DOS_D, /** * @brief B sized register or V sized memory operand. */ - BV = (static_cast(B) << 4) | static_cast(V), + DOS_BV = (DOS_B << 4) | DOS_V, /** * @brief W sized register or D sized memory operand. */ - WD = (static_cast(W) << 4) | static_cast(D), + DOS_WD = (DOS_W << 4) | DOS_D, /** * @brief W sized register or V sized memory operand. */ - WV = (static_cast(W) << 4) | static_cast(V), + DOS_WV = (DOS_W << 4) | DOS_V, /** * @brief W sized register or Y sized memory operand. */ - WY = (static_cast(W) << 4) | static_cast(Y), + DOS_WY = (DOS_W << 4) | DOS_Y, /** * @brief D sized register or Y sized memory operand. */ - DY = (static_cast(D) << 4) | static_cast(Y), + DOS_DY = (DOS_D << 4) | DOS_Y, /** * @brief W sized register or O sized memory operand. */ - WO = (static_cast(W) << 4) | static_cast(O), + DOS_WO = (DOS_W << 4) | DOS_O, /** * @brief D sized register or O sized memory operand. */ - DO = (static_cast(D) << 4) | static_cast(O), + DOS_DO = (DOS_D << 4) | DOS_O, /** * @brief Q sized register or O sized memory operand. */ - QO = (static_cast(Q) << 4) | static_cast(O), -}; + DOS_QO = (DOS_Q << 4) | DOS_O, +} VXDefinedOperandSize; /** * @brief Values that represent optional flags in the instruction definition. * Do not change the order or the values of this enum! */ -enum VXInstructionDefinitionFlags : uint16_t +typedef enum _VXInstructionDefinitionFlags /* : uint16_t */ { /** * @brief The instruction accepts the rex.b prefix value. @@ -1447,33 +1453,39 @@ enum VXInstructionDefinitionFlags : uint16_t /** * @brief The second operand of the instruction is accessed in read-write mode. */ - IDF_OPERAND2_READWRITE = 0x4000 -}; + IDF_OPERAND2_READWRITE = 0x4000, + + IDF_FORCE_WORD = 0x7FFF +} VXInstructionDefinitionFlags; #pragma pack (push, 1) /** * @brief An operand definition. */ -struct VXOperandDefinition +typedef struct _VXOperandDefinition { /** * @brief The defined operand type. + * @see VXDefinedOperandType */ - VXDefinedOperandType type; + uint8_t type; /** * @brief The defined operand size. + * @see VXDefinedOperandType */ - VXDefinedOperandSize size; -}; + uint8_t size; +} VXOperandDefinition; + /** * @brief An instruction definition. */ -struct VXInstructionDefinition +typedef struct _VXInstructionDefinition { /** * @brief The instruction mnemonic. + * @see VXInstructionMnemonic */ - VXInstructionMnemonic mnemonic; + uint16_t mnemonic; /** * @brief The operand definitions for all four possible operands. */ @@ -1482,272 +1494,11 @@ struct VXInstructionDefinition * @brief Additional flags for the instruction definition. */ uint16_t flags; -}; +} VXInstructionDefinition; #pragma pack (pop) -namespace Internal -{ - -/** - * @brief Contains all opcode tables. - * Indexed by the numeric value of the opcode. - */ -extern const VXOpcodeTreeNode optreeTable[][256]; -/** - * @brief Contains all modrm_mod switch tables. - * Index values: - * 0 = [modrm_mod == !11] - * 1 = [modrm_mod == 11] - */ -extern const VXOpcodeTreeNode optreeModrmMod[][2]; -/** - * @brief Contains all modrm_reg switch tables. - * Indexed by the numeric value of the modrm_reg field. - */ -extern const VXOpcodeTreeNode optreeModrmReg[][8]; -/** - * @brief Contains all modrm_rm switch tables. - * Indexed by the numeric value of the modrm_rm field. - */ -extern const VXOpcodeTreeNode optreeModrmRm[][8]; -/** - * @brief Contains all mandatory-prefix switch tables. - * Index values: - * 0 = none - * 1 = F2 - * 2 = F3 - * 3 = 66 - */ -extern const VXOpcodeTreeNode optreeMandatory[][4]; -/** - * @brief Contains all x87 opcode tables. - * Indexed by the numeric value of the 6 lowest bits of the modrm byte (modrm_mod should - * always be 11). - */ -extern const VXOpcodeTreeNode optreeX87[][64]; -/** - * @brief Contains all address-size switch tables. - * Index values: - * 0 = 16 - * 1 = 32 - * 2 = 64 - */ -extern const VXOpcodeTreeNode optreeAddressSize[][3]; -/** - * @brief Contains all operand-size switch tables. - * Index values: - * 0 = 16 - * 1 = 32 - * 2 = 64 - */ -extern const VXOpcodeTreeNode optreeOperandSize[][3]; -/** - * @brief Contains all cpu-mode switch tables. - * Index values: - * 0 = [!= 64] - * 1 = 64 - */ -extern const VXOpcodeTreeNode optreeMode[][2]; -/** - * @brief Contains all vendor switch tables. - * Index values: - * 0 = AMD - * 1 = Intel - */ -extern const VXOpcodeTreeNode optreeVendor[][2]; -/** - * @brief Contains all 3dnow! switch tables. - * Indexed by the numeric value of the 3dnow! opcode. - */ -extern const VXOpcodeTreeNode optree3dnow[][256]; -/** - * @brief Contains all vex switch tables. - * Index values: - * 0 = none - * 1 = 0F - * 2 = 0F38 - * 3 = 0F3A - * 4 = 66 - * 5 = 66_0F - * 6 = 66_0F38 - * 7 = 66_0F3A - * 8 = F3 - * 9 = F3_0F - * A = F3_0F38 - * B = F3_0F3A - * C = F2 - * D = F2_0F - * E = F2_0F38 - * F = F2_0F3A - */ -extern const VXOpcodeTreeNode optreeVex[][16]; -/** - * @brief Contains all vex_w switch tables. - * Indexed by the numeric value of the vex_w field. - */ -extern const VXOpcodeTreeNode optreeVexW[][2]; -/** - * @brief Contains all vex_l switch tables. - * Indexed by the numeric value of the vex_l field. - */ -extern const VXOpcodeTreeNode optreeVexL[][2]; -/** - * @brief Contains all instruction definitions. - */ -extern const VXInstructionDefinition instrDefinitions[]; -/** - * @brief Contains all instruction mnemonic strings. - */ -extern const char* instrMnemonicStrings[]; - -/** - * @brief Returns the type of the specified opcode tree node. - * @param node The node. - * @return The type of the specified opcode tree node. - */ -inline VXOpcodeTreeNodeType VDEGetOpcodeNodeType(VXOpcodeTreeNode node) -{ - return static_cast((node >> 12) & 0x0F); -} - -/** - * @brief Returns the value of the specified opcode tree node. - * @param node The node. - * @return The value of the specified opcode tree node. - */ -inline uint16_t VDEGetOpcodeNodeValue(VXOpcodeTreeNode node) -{ - return (node & 0x0FFF); +#ifdef __cplusplus } +#endif -/** - * @brief Returns the root node of the opcode tree. - * @return The root node of the opcode tree. - */ -inline VXOpcodeTreeNode VDEGetOpcodeTreeRoot() -{ - return 0x1000; -} - -/** - * @brief Returns a child node of @c parent specified by @c index. - * @param parent The parent node. - * @param index The index of the child node to retrieve. - * @return The specified child node. - */ -inline VXOpcodeTreeNode VDEGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_t index) -{ - using namespace Internal; - VXOpcodeTreeNodeType nodeType = VDEGetOpcodeNodeType(parent); - uint16_t tableIndex = VDEGetOpcodeNodeValue(parent); - switch (nodeType) - { - case VXOpcodeTreeNodeType::TABLE: - assert(index < 256); - return optreeTable[tableIndex][index]; - case VXOpcodeTreeNodeType::MODRM_MOD: - assert(index < 2); - return optreeModrmMod[tableIndex][index]; - case VXOpcodeTreeNodeType::MODRM_REG: - assert(index < 8); - return optreeModrmReg[tableIndex][index]; - case VXOpcodeTreeNodeType::MODRM_RM: - assert(index < 8); - return optreeModrmRm[tableIndex][index]; - case VXOpcodeTreeNodeType::MANDATORY: - assert(index < 4); - return optreeMandatory[tableIndex][index]; - case VXOpcodeTreeNodeType::X87: - assert(index < 64); - return optreeX87[tableIndex][index]; - case VXOpcodeTreeNodeType::ADDRESS_SIZE: - assert(index < 3); - return optreeAddressSize[tableIndex][index]; - case VXOpcodeTreeNodeType::OPERAND_SIZE: - assert(index < 3); - return optreeOperandSize[tableIndex][index]; - case VXOpcodeTreeNodeType::MODE: - assert(index < 2); - return optreeMode[tableIndex][index]; - case VXOpcodeTreeNodeType::VENDOR: - assert(index < 3); - return optreeVendor[tableIndex][index]; - case VXOpcodeTreeNodeType::AMD3DNOW: - assert(index < 256); - return optree3dnow[tableIndex][index]; - case VXOpcodeTreeNodeType::VEX: - assert(index < 16); - return optreeVex[tableIndex][index]; - case VXOpcodeTreeNodeType::VEXW: - assert(index < 2); - return optreeVexW[tableIndex][index]; - case VXOpcodeTreeNodeType::VEXL: - assert(index < 2); - return optreeVexL[tableIndex][index]; - default: - assert(0); - } - return 0xFFFF; -} - -/** - * @brief Returns the instruction definition that is linked to the given @c node. - * @param node The instruction definition node. - * @return Pointer to the instruction definition. - */ -inline const VXInstructionDefinition* VDEGetInstructionDefinition(VXOpcodeTreeNode node) -{ - assert(VDEGetOpcodeNodeType(node) == VXOpcodeTreeNodeType::INSTRUCTION_DEFINITION); - return &instrDefinitions[node & 0x0FFF]; -} - -/** - * @brief Returns the specified instruction mnemonic string. - * @param mnemonic The mnemonic. - * @return The instruction mnemonic string. - */ -inline const char* VDEGetInstructionMnemonicString(VXInstructionMnemonic mnemonic) -{ - return instrMnemonicStrings[static_cast(mnemonic)]; -} - -/** - * @brief Returns the numeric value for a simple operand size definition. - * @param operandSize The defined operand size. - * @return The the numeric value for the simple operand size definition. - */ -inline uint16_t VDEGetSimpleOperandSize(VXDefinedOperandSize operandSize) -{ - static uint16_t operandSizes[8] = - { - 8, 16, 32, 64, 80, 12, 128, 256 - }; - uint16_t index = - static_cast(operandSize) - static_cast(VXDefinedOperandSize::B); - assert(index < 8); - return operandSizes[index]; -} - -/** - * @brief Returns the memory-size part of a complex operand size definition. - * @param operandSize The defined operand size. - * @return The memory-size part of the operand size definition. - */ -inline VXDefinedOperandSize VDEGetComplexOperandMemSize(VXDefinedOperandSize operandSize) -{ - return static_cast(static_cast(operandSize) & 0x0F); -} - -/** - * @brief Returns the register-size part of a complex operand size definition. - * @param operandSize The defined operand size. - * @return The register-size part of the operand size definition. - */ -inline VXDefinedOperandSize VDEGetComplexOperandRegSize(VXDefinedOperandSize operandSize) -{ - return static_cast((static_cast(operandSize) >> 4) & 0x0F); -} - -} - -} +#endif // _VDE_VXOPCODETABLEC_H_ \ No newline at end of file diff --git a/Bindings/C/VXOpcodeTableInternalC.h b/VerteronDisassemblerEngine/VXOpcodeTableInternal.h similarity index 99% rename from Bindings/C/VXOpcodeTableInternalC.h rename to VerteronDisassemblerEngine/VXOpcodeTableInternal.h index 54e1614..06c4c08 100644 --- a/Bindings/C/VXOpcodeTableInternalC.h +++ b/VerteronDisassemblerEngine/VXOpcodeTableInternal.h @@ -34,7 +34,7 @@ #define _VDE_VXOPCODETABLEINTERNAL_H_ #include -#include "VXOpcodeTableC.h" +#include "VXOpcodeTable.h" /** * @brief Contains all opcode tables. diff --git a/VerteronDisassemblerEngine/VerteronDisassemblerEngine.vcxproj b/VerteronDisassemblerEngine/VerteronDisassemblerEngine.vcxproj deleted file mode 100644 index 0628199..0000000 --- a/VerteronDisassemblerEngine/VerteronDisassemblerEngine.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - {F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099} - Win32Proj - VerteronDisassemblerEngine - - - - StaticLibrary - true - v120 - Unicode - - - StaticLibrary - true - v120 - Unicode - - - StaticLibrary - false - v120 - true - Unicode - - - StaticLibrary - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - - \ No newline at end of file diff --git a/VerteronDisassemblerEngine/VerteronDisassemblerEngine.vcxproj.filters b/VerteronDisassemblerEngine/VerteronDisassemblerEngine.vcxproj.filters deleted file mode 100644 index e106092..0000000 --- a/VerteronDisassemblerEngine/VerteronDisassemblerEngine.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file