altered directory structure to use C implementation of library as the default

This commit is contained in:
Ende! 2015-03-16 16:37:15 +01:00
parent 30b60c7dc4
commit c912af00f9
44 changed files with 4483 additions and 5405 deletions

View File

@ -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 <stdbool.h>
#include <stddef.h>
#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_ */

View File

@ -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_ */

File diff suppressed because it is too large Load Diff

View File

@ -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_ */
#include "VXDisassemblerTypes.hpp"
#include "VXInstructionDecoder.hpp"
#include "VXInstructionFormatter.hpp"
#include "VXDisassemblerUtils.hpp"

View File

@ -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 <stdint.h>
#include <stdbool.h>
#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_ */

View File

@ -29,7 +29,7 @@
* SOFTWARE.
**************************************************************************************************/
#include "VXDisassemblerUtils.h"
#include "VXDisassemblerUtils.hpp"
#include <cassert>
namespace Verteron

View File

@ -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 <stdint.h>
#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_ */

View File

@ -29,7 +29,7 @@
* SOFTWARE.
**************************************************************************************************/
#include "VXInstructionDecoder.h"
#include "VXInstructionDecoder.hpp"
#include <cstring>
namespace Verteron

View File

@ -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 <type_traits>
#include <istream>
#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 <typename T>
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 <typename T>
inline T VXBaseDataSource::inputNext(VXInstructionInfo &info)
{
static_assert(std::is_integral<T>::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<const uint8_t*>(m_inputBuffer) + m_inputBufferPos);
}
inline uint8_t VXMemoryDataSource::internalInputNext()
{
++m_inputBufferPos;
return *(static_cast<const uint8_t*>(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 <typename T>
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 <typename T>
inline T VXInstructionDecoder::inputNext(VXInstructionInfo &info)
{
if (!m_dataSource)
{
info.flags |= IF_ERROR_END_OF_INPUT;
return 0;
}
return m_dataSource->inputNext<T>(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;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
}

View File

@ -29,8 +29,8 @@
* SOFTWARE.
**************************************************************************************************/
#include "VXInstructionFormatter.h"
#include "VXDisassemblerUtils.h"
#include "VXInstructionFormatter.hpp"
#include "VXDisassemblerUtils.hpp"
#include <cstdarg>
#include <cctype>
#include <cstring>

View File

@ -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 <vector>
#include <unordered_map>
#include <string>
#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<char> 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<uint16_t>(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<uint64_t, std::string> 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();
};
///////////////////////////////////////////////////////////////////////////////////////////////////
}

View File

@ -29,7 +29,7 @@
* SOFTWARE.
**************************************************************************************************/
#include "VXOpcodeTable.h"
#include "VXOpcodeTable.hpp"
namespace Verteron
{

File diff suppressed because it is too large Load Diff

View File

@ -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.")

View File

@ -32,7 +32,8 @@
#include <stdint.h>
#include <iostream>
#include <iomanip>
#include <VXDisassembler.h>
#include <VXDisassembler.hpp>
using namespace Verteron;

View File

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EB0F5A04-EE14-4779-9B29-322876CD45C8}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>CustomDataSource</RootNamespace>
<ProjectName>2 - Custom DataSource</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VerteronDisassemblerEngine\VerteronDisassemblerEngine.vcxproj">
<Project>{f5c6f0a7-f75d-42bd-a8ab-a2d1d5f67099}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
</Project>

View File

@ -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

View File

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4A0B7BE7-72C9-4A95-90CA-D56C50F10401}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PerformanceTest</RootNamespace>
<ProjectName>4 - Performance Test</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VerteronDisassemblerEngine\VerteronDisassemblerEngine.vcxproj">
<Project>{f5c6f0a7-f75d-42bd-a8ab-a2d1d5f67099}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
</Project>

View File

@ -30,7 +30,7 @@
**************************************************************************************************/
#include <VXDisassemblerC.h>
#include <VXDisassembler.h>
#include <stdio.h>
#include <stdint.h>

View File

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{BC5CDE9B-9F84-453E-8131-B56F67FD0E4D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>SimpleDemo</RootNamespace>
<ProjectName>1 - Simple Demo</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VerteronDisassemblerEngine\VerteronDisassemblerEngine.vcxproj">
<Project>{f5c6f0a7-f75d-42bd-a8ab-a2d1d5f67099}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
</Project>

View File

@ -29,27 +29,27 @@
* SOFTWARE.
**************************************************************************************************/
#include <fstream>
#include <iomanip>
#include <string>
#include <VXDisassembler.h>
#include <Windows.h>
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<uintptr_t>(moduleBase);
uintptr_t baseAddress = (uintptr_t)moduleBase;
// Parse PE headers
PIMAGE_DOS_HEADER dosHeader = static_cast<PIMAGE_DOS_HEADER>(moduleBase);
PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)moduleBase;
if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE)
{
return 1;
}
PIMAGE_NT_HEADERS ntHeaders =
reinterpret_cast<PIMAGE_NT_HEADERS>(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;
}

View File

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B6CA4362-2714-451C-8063-12195ABD7CD7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>SymbolResolver</RootNamespace>
<ProjectName>3 - Symbol Resolver</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\..\VerteronDisassemblerEngine\;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VerteronDisassemblerEngine\VerteronDisassemblerEngine.vcxproj">
<Project>{f5c6f0a7-f75d-42bd-a8ab-a2d1d5f67099}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
</Project>

View File

@ -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

View File

@ -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_ */

View File

@ -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 <stdint.h>
#include <stdbool.h>
#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_ */

View File

@ -30,7 +30,7 @@
**************************************************************************************************/
#include "VXDisassemblerUtilsC.h"
#include "VXDisassemblerUtils.h"
#include <assert.h>

View File

@ -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 <stdint.h>
#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_ */

View File

@ -30,9 +30,9 @@
**************************************************************************************************/
#include "VXInstructionDecoderC.h"
#include "VXInternalHelpersC.h"
#include "VXOpcodeTableInternalC.h"
#include "VXInstructionDecoder.h"
#include "VXInternalHelpers.h"
#include "VXOpcodeTableInternal.h"
#include <string.h>
#include <stdlib.h>
@ -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;
}

View File

@ -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 <type_traits>
#include <istream>
#ifndef _VDE_VXINSTRUCTIONDECODERC_H_
#define _VDE_VXINSTRUCTIONDECODERC_H_
#include "VXDisassemblerTypes.h"
#include "VXDisassemblerUtils.h"
namespace Verteron
#include <stdbool.h>
#include <stddef.h>
#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 <typename T>
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 <typename T>
inline T VXBaseDataSource::inputNext(VXInstructionInfo &info)
{
static_assert(std::is_integral<T>::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<const uint8_t*>(m_inputBuffer) + m_inputBufferPos);
}
inline uint8_t VXMemoryDataSource::internalInputNext()
{
++m_inputBufferPos;
return *(static_cast<const uint8_t*>(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 <typename T>
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 <typename T>
inline T VXInstructionDecoder::inputNext(VXInstructionInfo &info)
{
if (!m_dataSource)
{
info.flags |= IF_ERROR_END_OF_INPUT;
return 0;
}
return m_dataSource->inputNext<T>(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_ */

View File

@ -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 <stdarg.h>
#include <stdlib.h>

View File

@ -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 <vector>
#include <unordered_map>
#include <string>
#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<char> 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<uint16_t>(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<uint64_t, std::string> 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_ */

View File

@ -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_ */

View File

@ -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 <assert.h>

View File

@ -30,7 +30,7 @@
**************************************************************************************************/
#include "VXOpcodeTableC.h"
#include "VXOpcodeTable.h"
#define VX_INVALID 0
#define VX_NODE(type, n) ((VXOpcodeTreeNode)type << 12 | (n))

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@
#define _VDE_VXOPCODETABLEINTERNAL_H_
#include <stdint.h>
#include "VXOpcodeTableC.h"
#include "VXOpcodeTable.h"
/**
* @brief Contains all opcode tables.

View File

@ -1,147 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="VXDisassembler.h" />
<ClInclude Include="VXDisassemblerUtils.h" />
<ClInclude Include="VXDisassemblerTypes.h" />
<ClInclude Include="VXInstructionDecoder.h" />
<ClInclude Include="VXInstructionFormatter.h" />
<ClInclude Include="VXOpcodeTable.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="VXDisassemblerUtils.cpp" />
<ClCompile Include="VXInstructionDecoder.cpp" />
<ClCompile Include="VXInstructionFormatter.cpp" />
<ClCompile Include="VXOpcodeTable.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F5C6F0A7-F75D-42BD-A8AB-A2D1D5F67099}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>VerteronDisassemblerEngine</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="VXDisassembler.h" />
<ClInclude Include="VXDisassemblerTypes.h" />
<ClInclude Include="VXDisassemblerUtils.h" />
<ClInclude Include="VXInstructionDecoder.h" />
<ClInclude Include="VXInstructionFormatter.h" />
<ClInclude Include="VXOpcodeTable.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="VXDisassemblerUtils.cpp" />
<ClCompile Include="VXInstructionDecoder.cpp" />
<ClCompile Include="VXInstructionFormatter.cpp" />
<ClCompile Include="VXOpcodeTable.cpp" />
</ItemGroup>
</Project>