changed VX prefix to ZyDis (scriptually)

This commit is contained in:
athre0z 2015-05-12 03:42:25 +02:00
parent 7e26fa1683
commit de31261273
31 changed files with 15129 additions and 15129 deletions

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
#pragma once
#include "VXDisassemblerTypes.hpp"
#include "VXInstructionDecoder.hpp"
#include "VXInstructionFormatter.hpp"
#include "VXDisassemblerUtils.hpp"
#include "ZyDisDisassemblerTypes.hpp"
#include "ZyDisInstructionDecoder.hpp"
#include "ZyDisInstructionFormatter.hpp"
#include "ZyDisDisassemblerUtils.hpp"

View File

@ -32,7 +32,7 @@
#pragma once
#include <stdint.h>
#include "VXOpcodeTable.hpp"
#include "ZyDisOpcodeTable.hpp"
namespace Verteron
{
@ -128,7 +128,7 @@ enum InstructionFlags : uint32_t
/**
* @brief Values that represent a cpu register.
*/
enum class VXRegister : uint16_t
enum class ZyDisRegister : uint16_t
{
NONE,
/* 8 bit general purpose registers */
@ -188,7 +188,7 @@ enum class VXRegister : uint16_t
/**
* @brief Values that represent the type of a decoded operand.
*/
enum class VXOperandType : uint8_t
enum class ZyDisOperandType : uint8_t
{
/**
* @brief The operand is not used.
@ -223,7 +223,7 @@ enum class VXOperandType : uint8_t
/**
* @brief Values that represent the operand access mode.
*/
enum class VXOperandAccessMode : uint8_t
enum class ZyDisOperandAccessMode : uint8_t
{
NA,
/**
@ -243,12 +243,12 @@ enum class VXOperandAccessMode : uint8_t
/**
* @brief This struct holds information about a decoded operand.
*/
struct VXOperandInfo
struct ZyDisOperandInfo
{
/**
* @brief The type of the operand.
*/
VXOperandType type;
ZyDisOperandType type;
/**
* @brief The size of the operand.
*/
@ -256,15 +256,15 @@ struct VXOperandInfo
/**
* @brief The operand access mode.
*/
VXOperandAccessMode access_mode;
ZyDisOperandAccessMode access_mode;
/**
* @brief The base register.
*/
VXRegister base;
ZyDisRegister base;
/**
* @brief The index register.
*/
VXRegister index;
ZyDisRegister index;
/**
* @brief The scale factor.
*/
@ -300,7 +300,7 @@ struct VXOperandInfo
/**
* @brief This struct holds information about a decoded instruction.
*/
struct VXInstructionInfo
struct ZyDisInstructionInfo
{
/**
* @brief The instruction flags.
@ -309,7 +309,7 @@ struct VXInstructionInfo
/**
* @brief The instruction mnemonic.
*/
VXInstructionMnemonic mnemonic;
ZyDisInstructionMnemonic mnemonic;
/**
* @brief The total length of the instruction.
*/
@ -337,12 +337,12 @@ struct VXInstructionInfo
/**
* @brief The decoded operands.
*/
VXOperandInfo operand[4];
ZyDisOperandInfo operand[4];
/**
* @brief The segment register. This value will default to @c NONE, if no segment register
* prefix is present.
*/
VXRegister segment;
ZyDisRegister segment;
/**
* @brief The rex prefix byte.
*/
@ -512,7 +512,7 @@ struct VXInstructionInfo
/**
* @brief The instruction definition.
*/
const VXInstructionDefinition *instrDefinition;
const ZyDisInstructionDefinition *instrDefinition;
/**
* @brief The instruction address points to the current instruction (relative to the
* initial instruction pointer).

View File

@ -29,16 +29,16 @@
* SOFTWARE.
**************************************************************************************************/
#include "VXDisassemblerUtils.hpp"
#include "ZyDisDisassemblerUtils.hpp"
#include <cassert>
namespace Verteron
{
uint64_t VDECalcAbsoluteTarget(const VXInstructionInfo &info, const VXOperandInfo &operand)
uint64_t VDECalcAbsoluteTarget(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &operand)
{
assert((operand.type == VXOperandType::REL_IMMEDIATE) ||
((operand.type == VXOperandType::MEMORY) && (operand.base == VXRegister::RIP)));
assert((operand.type == ZyDisOperandType::REL_IMMEDIATE) ||
((operand.type == ZyDisOperandType::MEMORY) && (operand.base == ZyDisRegister::RIP)));
uint64_t truncMask = 0xFFFFFFFFFFFFFFFFull;
if (!(info.flags & IF_DISASSEMBLER_MODE_64))
@ -46,7 +46,7 @@ uint64_t VDECalcAbsoluteTarget(const VXInstructionInfo &info, const VXOperandInf
truncMask >>= (64 - info.operand_mode);
}
uint16_t size = operand.size;
if ((operand.type == VXOperandType::MEMORY) && (operand.base == VXRegister::RIP))
if ((operand.type == ZyDisOperandType::MEMORY) && (operand.base == ZyDisRegister::RIP))
{
size = operand.offset;
}

View File

@ -32,7 +32,7 @@
#pragma once
#include <stdint.h>
#include "VXDisassemblerTypes.hpp"
#include "ZyDisDisassemblerTypes.hpp"
namespace Verteron
{
@ -43,6 +43,6 @@ namespace Verteron
* @param operand The operand.
* @return The absolute target address.
*/
uint64_t VDECalcAbsoluteTarget(const VXInstructionInfo &info, const VXOperandInfo &operand);
uint64_t VDECalcAbsoluteTarget(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &operand);
}

View File

@ -33,7 +33,7 @@
#include <type_traits>
#include <istream>
#include "VXDisassemblerTypes.hpp"
#include "ZyDisDisassemblerTypes.hpp"
namespace Verteron
{
@ -43,7 +43,7 @@ namespace Verteron
/**
* @brief The base class for all data-source implementations.
*/
class VXBaseDataSource
class ZyDisBaseDataSource
{
private:
uint8_t m_currentInput;
@ -66,12 +66,12 @@ protected:
/**
* @brief Default constructor.
*/
VXBaseDataSource() { };
ZyDisBaseDataSource() { };
public:
/**
* @brief Destructor.
*/
virtual ~VXBaseDataSource() { };
virtual ~ZyDisBaseDataSource() { };
public:
/**
* @brief Reads the next byte from the data source. This method does NOT increase the
@ -81,7 +81,7 @@ public:
* @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);
uint8_t inputPeek(ZyDisInstructionInfo &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.
@ -92,7 +92,7 @@ public:
* @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);
uint8_t inputNext(ZyDisInstructionInfo &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.
@ -104,7 +104,7 @@ public:
* Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH.
*/
template <typename T>
T inputNext(VXInstructionInfo &info);
T inputNext(ZyDisInstructionInfo &info);
/**
* @brief Returns the current input byte. The current input byte is set everytime the
* @c inputPeek or @c inputNext method is called.
@ -133,7 +133,7 @@ public:
virtual bool setPosition(uint64_t position) = 0;
};
inline uint8_t VXBaseDataSource::inputPeek(VXInstructionInfo &info)
inline uint8_t ZyDisBaseDataSource::inputPeek(ZyDisInstructionInfo &info)
{
if (info.length == 15)
{
@ -149,7 +149,7 @@ inline uint8_t VXBaseDataSource::inputPeek(VXInstructionInfo &info)
return m_currentInput;
}
inline uint8_t VXBaseDataSource::inputNext(VXInstructionInfo &info)
inline uint8_t ZyDisBaseDataSource::inputNext(ZyDisInstructionInfo &info)
{
if (info.length == 15)
{
@ -168,7 +168,7 @@ inline uint8_t VXBaseDataSource::inputNext(VXInstructionInfo &info)
}
template <typename T>
inline T VXBaseDataSource::inputNext(VXInstructionInfo &info)
inline T ZyDisBaseDataSource::inputNext(ZyDisInstructionInfo &info)
{
static_assert(std::is_integral<T>::value, "integral type required");
T result = 0;
@ -184,7 +184,7 @@ inline T VXBaseDataSource::inputNext(VXInstructionInfo &info)
return result;
}
inline uint8_t VXBaseDataSource::inputCurrent() const
inline uint8_t ZyDisBaseDataSource::inputCurrent() const
{
return m_currentInput;
}
@ -192,9 +192,9 @@ inline uint8_t VXBaseDataSource::inputCurrent() const
///////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @brief A memory-buffer based data source for the @c VXInstructionDecoder class.
* @brief A memory-buffer based data source for the @c ZyDisInstructionDecoder class.
*/
class VXMemoryDataSource : public VXBaseDataSource
class ZyDisMemoryDataSource : public ZyDisBaseDataSource
{
private:
const void *m_inputBuffer;
@ -219,7 +219,7 @@ public:
* @param buffer The input buffer.
* @param bufferLen The length of the input buffer.
*/
VXMemoryDataSource(const void* buffer, size_t bufferLen)
ZyDisMemoryDataSource(const void* buffer, size_t bufferLen)
: m_inputBuffer(buffer)
, m_inputBufferLen(bufferLen)
, m_inputBufferPos(0) { };
@ -242,28 +242,28 @@ public:
bool setPosition(uint64_t position) override;
};
inline uint8_t VXMemoryDataSource::internalInputPeek()
inline uint8_t ZyDisMemoryDataSource::internalInputPeek()
{
return *(static_cast<const uint8_t*>(m_inputBuffer) + m_inputBufferPos);
}
inline uint8_t VXMemoryDataSource::internalInputNext()
inline uint8_t ZyDisMemoryDataSource::internalInputNext()
{
++m_inputBufferPos;
return *(static_cast<const uint8_t*>(m_inputBuffer) + m_inputBufferPos - 1);
}
inline bool VXMemoryDataSource::isEndOfInput() const
inline bool ZyDisMemoryDataSource::isEndOfInput() const
{
return (m_inputBufferPos >= m_inputBufferLen);
}
inline uint64_t VXMemoryDataSource::getPosition() const
inline uint64_t ZyDisMemoryDataSource::getPosition() const
{
return m_inputBufferPos;
}
inline bool VXMemoryDataSource::setPosition(uint64_t position)
inline bool ZyDisMemoryDataSource::setPosition(uint64_t position)
{
m_inputBufferPos = position;
return isEndOfInput();
@ -272,9 +272,9 @@ inline bool VXMemoryDataSource::setPosition(uint64_t position)
///////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @brief A stream based data source for the @c VXInstructionDecoder class.
* @brief A stream based data source for the @c ZyDisInstructionDecoder class.
*/
class VXStreamDataSource : public VXBaseDataSource
class ZyDisStreamDataSource : public ZyDisBaseDataSource
{
private:
std::istream *m_inputStream;
@ -296,7 +296,7 @@ public:
* @brief Constructor.
* @param stream The input stream.
*/
explicit VXStreamDataSource(std::istream *stream)
explicit ZyDisStreamDataSource(std::istream *stream)
: m_inputStream(stream) { };
public:
/**
@ -317,7 +317,7 @@ public:
bool setPosition(uint64_t position) override;
};
inline uint8_t VXStreamDataSource::internalInputPeek()
inline uint8_t ZyDisStreamDataSource::internalInputPeek()
{
if (!m_inputStream)
{
@ -326,7 +326,7 @@ inline uint8_t VXStreamDataSource::internalInputPeek()
return static_cast<uint8_t>(m_inputStream->peek());
}
inline uint8_t VXStreamDataSource::internalInputNext()
inline uint8_t ZyDisStreamDataSource::internalInputNext()
{
if (!m_inputStream)
{
@ -335,7 +335,7 @@ inline uint8_t VXStreamDataSource::internalInputNext()
return static_cast<uint8_t>(m_inputStream->get());
}
inline bool VXStreamDataSource::isEndOfInput() const
inline bool ZyDisStreamDataSource::isEndOfInput() const
{
if (!m_inputStream)
{
@ -346,7 +346,7 @@ inline bool VXStreamDataSource::isEndOfInput() const
return !m_inputStream->good();
}
inline uint64_t VXStreamDataSource::getPosition() const
inline uint64_t ZyDisStreamDataSource::getPosition() const
{
if (!m_inputStream)
{
@ -355,7 +355,7 @@ inline uint64_t VXStreamDataSource::getPosition() const
return m_inputStream->tellg();
}
inline bool VXStreamDataSource::setPosition(uint64_t position)
inline bool ZyDisStreamDataSource::setPosition(uint64_t position)
{
if (!m_inputStream)
{
@ -370,7 +370,7 @@ inline bool VXStreamDataSource::setPosition(uint64_t position)
/**
* @brief Values that represent a disassembler mode.
*/
enum class VXDisassemblerMode : uint8_t
enum class ZyDisDisassemblerMode : uint8_t
{
M16BIT,
M32BIT,
@ -380,7 +380,7 @@ enum class VXDisassemblerMode : uint8_t
/**
* @brief Values that represent an instruction-set vendor.
*/
enum class VXInstructionSetVendor : uint8_t
enum class ZyDisInstructionSetVendor : uint8_t
{
ANY,
INTEL,
@ -388,10 +388,10 @@ enum class VXInstructionSetVendor : uint8_t
};
/**
* @brief The @c VXInstructionDecoder class decodes x86/x86-64 assembly instructions from a
* @brief The @c ZyDisInstructionDecoder class decodes x86/x86-64 assembly instructions from a
* given data source.
*/
class VXInstructionDecoder
class ZyDisInstructionDecoder
{
private:
enum class RegisterClass : uint8_t
@ -404,9 +404,9 @@ private:
XMM
};
private:
VXBaseDataSource *m_dataSource;
VXDisassemblerMode m_disassemblerMode;
VXInstructionSetVendor m_preferredVendor;
ZyDisBaseDataSource *m_dataSource;
ZyDisDisassemblerMode m_disassemblerMode;
ZyDisInstructionSetVendor m_preferredVendor;
uint64_t m_instructionPointer;
private:
/**
@ -417,7 +417,7 @@ private:
* @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);
uint8_t inputPeek(ZyDisInstructionInfo &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.
@ -428,7 +428,7 @@ private:
* @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);
uint8_t inputNext(ZyDisInstructionInfo &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.
@ -440,7 +440,7 @@ private:
* Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH.
*/
template <typename T>
T inputNext(VXInstructionInfo &info);
T inputNext(ZyDisInstructionInfo &info);
/**
* @brief Returns the current input byte. The current input byte is set everytime the
* @c inputPeek or @c inputNext method is called.
@ -451,64 +451,64 @@ private:
/**
* @brief Decodes a register operand.
* @param info The instruction info.
* @param operand The @c VXOperandInfo struct that receives the decoded data.
* @param operand The @c ZyDisOperandInfo 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;
bool decodeRegisterOperand(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand,
RegisterClass registerClass, uint8_t registerId, ZyDisDefinedOperandSize 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 operand The @c ZyDisOperandInfo 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);
bool decodeRegisterMemoryOperand(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand,
RegisterClass registerClass, ZyDisDefinedOperandSize operandSize);
/**
* @brief Decodes an immediate operand.
* @param info The instruction info.
* @param operand The @c VXOperandInfo struct that receives the decoded data.
* @param operand The @c ZyDisOperandInfo 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);
bool decodeImmediate(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand,
ZyDisDefinedOperandSize operandSize);
/**
* @brief Decodes a displacement operand.
* @param info The instruction info.
* @param operand The @c VXOperandInfo struct that receives the decoded data.
* @param operand The @c ZyDisOperandInfo 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);
bool decodeDisplacement(ZyDisInstructionInfo &info, ZyDisOperandInfo &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.
* @param The @c ZyDisInstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeModrm(VXInstructionInfo &info);
bool decodeModrm(ZyDisInstructionInfo &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.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeSIB(VXInstructionInfo &info);
bool decodeSIB(ZyDisInstructionInfo &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.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeVex(VXInstructionInfo &info);
bool decodeVex(ZyDisInstructionInfo &info);
private:
/**
* @brief Returns the effective operand size.
@ -516,59 +516,59 @@ private:
* @param operandSize The defined operand size.
* @return The effective operand size.
*/
uint16_t getEffectiveOperandSize(const VXInstructionInfo &info,
VXDefinedOperandSize operandSize) const;
uint16_t getEffectiveOperandSize(const ZyDisInstructionInfo &info,
ZyDisDefinedOperandSize operandSize) const;
/**
* @brief Decodes all instruction operands.
* @param info The @c VXInstructionInfo struct that receives the decoded data.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeOperands(VXInstructionInfo &info);
bool decodeOperands(ZyDisInstructionInfo &info);
/**
* @brief Decodes the specified instruction operand.
* @param info The instruction info.
* @param operand The @c VXOperandInfo struct that receives the decoded data.
* @param operand The @c ZyDisOperandInfo 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);
bool decodeOperand(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand,
ZyDisDefinedOperandType operandType, ZyDisDefinedOperandSize 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
* @param info The @c ZyDisInstructionInfo struct that receives the effective operand and
* address mode.
*/
void resolveOperandAndAddressMode(VXInstructionInfo &info) const;
void resolveOperandAndAddressMode(ZyDisInstructionInfo &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
* @param info The @c ZyDisInstructionInfo struct that receives the effective operand and
* address mode.
*/
void calculateEffectiveRexVexValues(VXInstructionInfo &info) const;
void calculateEffectiveRexVexValues(ZyDisInstructionInfo &info) const;
private:
/**
* @brief Collects and decodes optional instruction prefixes.
* @param info The @c VXInstructionInfo struct that receives the decoded data.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodePrefixes(VXInstructionInfo &info);
bool decodePrefixes(ZyDisInstructionInfo &info);
/**
* @brief Collects and decodes the instruction opcodes using the opcode tree.
* @param info The @c VXInstructionInfo struct that receives the decoded data.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeOpcode(VXInstructionInfo &info);
bool decodeOpcode(ZyDisInstructionInfo &info);
public:
/**
* @brief Default constructor.
*/
VXInstructionDecoder();
ZyDisInstructionDecoder();
/**
* @brief Constructor.
* @param input A reference to the input data source.
@ -576,51 +576,51 @@ public:
* @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,
explicit ZyDisInstructionDecoder(ZyDisBaseDataSource *input,
ZyDisDisassemblerMode disassemblerMode = ZyDisDisassemblerMode::M32BIT,
ZyDisInstructionSetVendor preferredVendor = ZyDisInstructionSetVendor::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
* @param info The @c ZyDisInstructionInfo 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);
bool decodeInstruction(ZyDisInstructionInfo &info);
public:
/**
* @brief Returns a pointer to the current data source.
* @return A pointer to the current data source.
*/
VXBaseDataSource* getDataSource() const;
ZyDisBaseDataSource* getDataSource() const;
/**
* @brief Sets a new data source.
* @param input A reference to the new input data source.
*/
void setDataSource(VXBaseDataSource *input);
void setDataSource(ZyDisBaseDataSource *input);
/**
* @brief Returns the current disassembler mode.
* @return The current disassembler mode.
*/
VXDisassemblerMode getDisassemblerMode() const;
ZyDisDisassemblerMode getDisassemblerMode() const;
/**
* @brief Sets the current disassembler mode.
* @param disassemblerMode The new disassembler mode.
*/
void setDisassemblerMode(VXDisassemblerMode disassemblerMode);
void setDisassemblerMode(ZyDisDisassemblerMode disassemblerMode);
/**
* @brief Returns the preferred instruction-set vendor.
* @return The preferred instruction-set vendor.
*/
VXInstructionSetVendor getPreferredVendor() const;
ZyDisInstructionSetVendor getPreferredVendor() const;
/**
* @brief Sets the preferred instruction-set vendor.
* @param preferredVendor The new preferred instruction-set vendor.
*/
void setPreferredVendor(VXInstructionSetVendor preferredVendor);
void setPreferredVendor(ZyDisInstructionSetVendor preferredVendor);
/**
* @brief Returns the current instruction pointer.
* @return The current instruction pointer.
@ -633,7 +633,7 @@ public:
void setInstructionPointer(uint64_t instructionPointer);
};
inline uint8_t VXInstructionDecoder::inputPeek(VXInstructionInfo &info)
inline uint8_t ZyDisInstructionDecoder::inputPeek(ZyDisInstructionInfo &info)
{
if (!m_dataSource)
{
@ -643,7 +643,7 @@ inline uint8_t VXInstructionDecoder::inputPeek(VXInstructionInfo &info)
return m_dataSource->inputPeek(info);
}
inline uint8_t VXInstructionDecoder::inputNext(VXInstructionInfo &info)
inline uint8_t ZyDisInstructionDecoder::inputNext(ZyDisInstructionInfo &info)
{
if (!m_dataSource)
{
@ -654,7 +654,7 @@ inline uint8_t VXInstructionDecoder::inputNext(VXInstructionInfo &info)
}
template <typename T>
inline T VXInstructionDecoder::inputNext(VXInstructionInfo &info)
inline T ZyDisInstructionDecoder::inputNext(ZyDisInstructionInfo &info)
{
if (!m_dataSource)
{
@ -664,7 +664,7 @@ inline T VXInstructionDecoder::inputNext(VXInstructionInfo &info)
return m_dataSource->inputNext<T>(info);
}
inline uint8_t VXInstructionDecoder::inputCurrent() const
inline uint8_t ZyDisInstructionDecoder::inputCurrent() const
{
if (!m_dataSource)
{
@ -673,42 +673,42 @@ inline uint8_t VXInstructionDecoder::inputCurrent() const
return m_dataSource->inputCurrent();
}
inline VXBaseDataSource* VXInstructionDecoder::getDataSource() const
inline ZyDisBaseDataSource* ZyDisInstructionDecoder::getDataSource() const
{
return m_dataSource;
}
inline void VXInstructionDecoder::setDataSource(VXBaseDataSource *input)
inline void ZyDisInstructionDecoder::setDataSource(ZyDisBaseDataSource *input)
{
m_dataSource = input;
}
inline VXDisassemblerMode VXInstructionDecoder::getDisassemblerMode() const
inline ZyDisDisassemblerMode ZyDisInstructionDecoder::getDisassemblerMode() const
{
return m_disassemblerMode;
}
inline void VXInstructionDecoder::setDisassemblerMode(VXDisassemblerMode disassemblerMode)
inline void ZyDisInstructionDecoder::setDisassemblerMode(ZyDisDisassemblerMode disassemblerMode)
{
m_disassemblerMode = disassemblerMode;
}
inline VXInstructionSetVendor VXInstructionDecoder::getPreferredVendor() const
inline ZyDisInstructionSetVendor ZyDisInstructionDecoder::getPreferredVendor() const
{
return m_preferredVendor;
}
inline void VXInstructionDecoder::setPreferredVendor(VXInstructionSetVendor preferredVendor)
inline void ZyDisInstructionDecoder::setPreferredVendor(ZyDisInstructionSetVendor preferredVendor)
{
m_preferredVendor = preferredVendor;
}
inline uint64_t VXInstructionDecoder::getInstructionPointer() const
inline uint64_t ZyDisInstructionDecoder::getInstructionPointer() const
{
return m_instructionPointer;
}
inline void VXInstructionDecoder::setInstructionPointer(uint64_t instructionPointer)
inline void ZyDisInstructionDecoder::setInstructionPointer(uint64_t instructionPointer)
{
m_instructionPointer = instructionPointer;
}

View File

@ -29,8 +29,8 @@
* SOFTWARE.
**************************************************************************************************/
#include "VXInstructionFormatter.hpp"
#include "VXDisassemblerUtils.hpp"
#include "ZyDisInstructionFormatter.hpp"
#include "ZyDisDisassemblerUtils.hpp"
#include <cstdarg>
#include <cctype>
#include <cstring>
@ -42,12 +42,12 @@ namespace Verteron
///////////////////////////////////////////////////////////////////////////////////////////////////
VXBaseSymbolResolver::~VXBaseSymbolResolver()
ZyDisBaseSymbolResolver::~ZyDisBaseSymbolResolver()
{
}
const char* VXBaseSymbolResolver::resolveSymbol(const VXInstructionInfo &info, uint64_t address,
const char* ZyDisBaseSymbolResolver::resolveSymbol(const ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset)
{
return nullptr;
@ -55,7 +55,7 @@ const char* VXBaseSymbolResolver::resolveSymbol(const VXInstructionInfo &info, u
///////////////////////////////////////////////////////////////////////////////////////////////////
const char* VXBaseInstructionFormatter::m_registerStrings[] =
const char* ZyDisBaseInstructionFormatter::m_registerStrings[] =
{
/* 8 bit general purpose registers */
"al", "cl", "dl", "bl",
@ -111,12 +111,12 @@ const char* VXBaseInstructionFormatter::m_registerStrings[] =
"rip"
};
void VXBaseInstructionFormatter::internalFormatInstruction(const VXInstructionInfo &info)
void ZyDisBaseInstructionFormatter::internalFormatInstruction(const ZyDisInstructionInfo &info)
{
// Nothing to do here
}
VXBaseInstructionFormatter::VXBaseInstructionFormatter()
ZyDisBaseInstructionFormatter::ZyDisBaseInstructionFormatter()
: m_symbolResolver(nullptr)
, m_outputStringLen(0)
, m_outputUppercase(false)
@ -124,7 +124,7 @@ VXBaseInstructionFormatter::VXBaseInstructionFormatter()
}
VXBaseInstructionFormatter::VXBaseInstructionFormatter(VXBaseSymbolResolver *symbolResolver)
ZyDisBaseInstructionFormatter::ZyDisBaseInstructionFormatter(ZyDisBaseSymbolResolver *symbolResolver)
: m_symbolResolver(symbolResolver)
, m_outputStringLen(0)
, m_outputUppercase(false)
@ -132,7 +132,7 @@ VXBaseInstructionFormatter::VXBaseInstructionFormatter(VXBaseSymbolResolver *sym
}
const char* VXBaseInstructionFormatter::formatInstruction(const VXInstructionInfo &info)
const char* ZyDisBaseInstructionFormatter::formatInstruction(const ZyDisInstructionInfo &info)
{
// Clears the internal string buffer
outputClear();
@ -147,22 +147,22 @@ const char* VXBaseInstructionFormatter::formatInstruction(const VXInstructionInf
return outputString();
}
VXBaseInstructionFormatter::~VXBaseInstructionFormatter()
ZyDisBaseInstructionFormatter::~ZyDisBaseInstructionFormatter()
{
}
void VXBaseInstructionFormatter::outputClear()
void ZyDisBaseInstructionFormatter::outputClear()
{
m_outputStringLen = 0;
}
char const* VXBaseInstructionFormatter::outputString()
char const* ZyDisBaseInstructionFormatter::outputString()
{
return &m_outputBuffer[0];
}
void VXBaseInstructionFormatter::outputAppend(char const *text)
void ZyDisBaseInstructionFormatter::outputAppend(char const *text)
{
// Get the string length including the null-terminator char
size_t strLen = strlen(text) + 1;
@ -191,7 +191,7 @@ char const* VXBaseInstructionFormatter::outputString()
}
}
void VXBaseInstructionFormatter::outputAppendFormatted(char const *format, ...)
void ZyDisBaseInstructionFormatter::outputAppendFormatted(char const *format, ...)
{
va_list arguments;
va_start(arguments, format);
@ -233,7 +233,7 @@ char const* VXBaseInstructionFormatter::outputString()
va_end(arguments);
}
void VXBaseInstructionFormatter::outputAppendAddress(const VXInstructionInfo &info,
void ZyDisBaseInstructionFormatter::outputAppendAddress(const ZyDisInstructionInfo &info,
uint64_t address, bool resolveSymbols)
{
uint64_t offset = 0;
@ -269,10 +269,10 @@ void VXBaseInstructionFormatter::outputAppendAddress(const VXInstructionInfo &in
}
}
void VXBaseInstructionFormatter::outputAppendImmediate(const VXInstructionInfo &info,
const VXOperandInfo &operand, bool resolveSymbols)
void ZyDisBaseInstructionFormatter::outputAppendImmediate(const ZyDisInstructionInfo &info,
const ZyDisOperandInfo &operand, bool resolveSymbols)
{
assert(operand.type == VXOperandType::IMMEDIATE);
assert(operand.type == ZyDisOperandType::IMMEDIATE);
uint64_t value = 0;
if (operand.signed_lval && (operand.size != info.operand_mode))
{
@ -329,11 +329,11 @@ void VXBaseInstructionFormatter::outputAppendImmediate(const VXInstructionInfo &
}
}
void VXBaseInstructionFormatter::outputAppendDisplacement(const VXInstructionInfo &info,
const VXOperandInfo &operand)
void ZyDisBaseInstructionFormatter::outputAppendDisplacement(const ZyDisInstructionInfo &info,
const ZyDisOperandInfo &operand)
{
assert(operand.offset > 0);
if ((operand.base == VXRegister::NONE) && (operand.index == VXRegister::NONE))
if ((operand.base == ZyDisRegister::NONE) && (operand.index == ZyDisRegister::NONE))
{
// Assume the displacement value is unsigned
assert(operand.scale == 0);
@ -378,16 +378,16 @@ void VXBaseInstructionFormatter::outputAppendDisplacement(const VXInstructionInf
outputAppendFormatted("-%.2lX", -value);
} else
{
outputAppendFormatted("%s%.2lX", (operand.base != VXRegister::NONE ||
operand.index != VXRegister::NONE) ? "+" : "", value);
outputAppendFormatted("%s%.2lX", (operand.base != ZyDisRegister::NONE ||
operand.index != ZyDisRegister::NONE) ? "+" : "", value);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
void VXIntelInstructionFormatter::outputAppendOperandCast(const VXInstructionInfo &info,
const VXOperandInfo &operand)
void ZyDisIntelInstructionFormatter::outputAppendOperandCast(const ZyDisInstructionInfo &info,
const ZyDisOperandInfo &operand)
{
switch(operand.size)
{
@ -417,33 +417,33 @@ void VXIntelInstructionFormatter::outputAppendOperandCast(const VXInstructionInf
}
}
void VXIntelInstructionFormatter::formatOperand(const VXInstructionInfo &info,
const VXOperandInfo &operand)
void ZyDisIntelInstructionFormatter::formatOperand(const ZyDisInstructionInfo &info,
const ZyDisOperandInfo &operand)
{
switch (operand.type)
{
case VXOperandType::REGISTER:
case ZyDisOperandType::REGISTER:
outputAppend(registerToString(operand.base));
break;
case VXOperandType::MEMORY:
case ZyDisOperandType::MEMORY:
if (info.flags & IF_PREFIX_SEGMENT)
{
outputAppendFormatted("%s:", registerToString(info.segment));
}
outputAppend("[");
if (operand.base == VXRegister::RIP)
if (operand.base == ZyDisRegister::RIP)
{
// TODO: Add option
outputAppendAddress(info, VDECalcAbsoluteTarget(info, operand), true);
} else
{
if (operand.base != VXRegister::NONE)
if (operand.base != ZyDisRegister::NONE)
{
outputAppend(registerToString(operand.base));
}
if (operand.index != VXRegister::NONE)
if (operand.index != ZyDisRegister::NONE)
{
outputAppendFormatted("%s%s", operand.base != VXRegister::NONE ? "+" : "",
outputAppendFormatted("%s%s", operand.base != ZyDisRegister::NONE ? "+" : "",
registerToString(operand.index));
if (operand.scale)
{
@ -457,7 +457,7 @@ void VXIntelInstructionFormatter::formatOperand(const VXInstructionInfo &info,
}
outputAppend("]");
break;
case VXOperandType::POINTER:
case ZyDisOperandType::POINTER:
// TODO: resolve symbols
switch (operand.size)
{
@ -472,12 +472,12 @@ void VXIntelInstructionFormatter::formatOperand(const VXInstructionInfo &info,
assert(0);
}
break;
case VXOperandType::IMMEDIATE:
case ZyDisOperandType::IMMEDIATE:
{
outputAppendImmediate(info, operand, true);
}
break;
case VXOperandType::REL_IMMEDIATE:
case ZyDisOperandType::REL_IMMEDIATE:
{
if (operand.size == 8)
{
@ -486,7 +486,7 @@ void VXIntelInstructionFormatter::formatOperand(const VXInstructionInfo &info,
outputAppendAddress(info, VDECalcAbsoluteTarget(info, operand), true);
}
break;
case VXOperandType::CONSTANT:
case ZyDisOperandType::CONSTANT:
outputAppendFormatted("%.2X", operand.lval.udword);
break;
default:
@ -495,7 +495,7 @@ void VXIntelInstructionFormatter::formatOperand(const VXInstructionInfo &info,
}
}
void VXIntelInstructionFormatter::internalFormatInstruction(const VXInstructionInfo &info)
void ZyDisIntelInstructionFormatter::internalFormatInstruction(const ZyDisInstructionInfo &info)
{
// Append string prefixes
if (info.flags & IF_PREFIX_LOCK)
@ -512,30 +512,30 @@ void VXIntelInstructionFormatter::internalFormatInstruction(const VXInstructionI
// Append the instruction mnemonic
outputAppend(Internal::VDEGetInstructionMnemonicString(info.mnemonic));
// Append the first operand
if (info.operand[0].type != VXOperandType::NONE)
if (info.operand[0].type != ZyDisOperandType::NONE)
{
outputAppend(" ");
bool cast = false;
if (info.operand[0].type == VXOperandType::MEMORY)
if (info.operand[0].type == ZyDisOperandType::MEMORY)
{
if (info.operand[1].type == VXOperandType::IMMEDIATE ||
info.operand[1].type == VXOperandType::CONSTANT ||
info.operand[1].type == VXOperandType::NONE ||
if (info.operand[1].type == ZyDisOperandType::IMMEDIATE ||
info.operand[1].type == ZyDisOperandType::CONSTANT ||
info.operand[1].type == ZyDisOperandType::NONE ||
(info.operand[0].size != info.operand[1].size))
{
cast = true;
} else if (info.operand[1].type == VXOperandType::REGISTER &&
info.operand[1].base == VXRegister::CL)
} else if (info.operand[1].type == ZyDisOperandType::REGISTER &&
info.operand[1].base == ZyDisRegister::CL)
{
switch (info.mnemonic)
{
case VXInstructionMnemonic::RCL:
case VXInstructionMnemonic::ROL:
case VXInstructionMnemonic::ROR:
case VXInstructionMnemonic::RCR:
case VXInstructionMnemonic::SHL:
case VXInstructionMnemonic::SHR:
case VXInstructionMnemonic::SAR:
case ZyDisInstructionMnemonic::RCL:
case ZyDisInstructionMnemonic::ROL:
case ZyDisInstructionMnemonic::ROR:
case ZyDisInstructionMnemonic::RCR:
case ZyDisInstructionMnemonic::SHL:
case ZyDisInstructionMnemonic::SHR:
case ZyDisInstructionMnemonic::SAR:
cast = true;
break;
default:
@ -550,19 +550,19 @@ void VXIntelInstructionFormatter::internalFormatInstruction(const VXInstructionI
formatOperand(info, info.operand[0]);
}
// Append the second operand
if (info.operand[1].type != VXOperandType::NONE)
if (info.operand[1].type != ZyDisOperandType::NONE)
{
outputAppend(", ");
bool cast = false;
if (info.operand[1].type == VXOperandType::MEMORY &&
if (info.operand[1].type == ZyDisOperandType::MEMORY &&
info.operand[0].size != info.operand[1].size &&
((info.operand[0].type != VXOperandType::REGISTER) ||
((info.operand[0].base != VXRegister::ES) &&
(info.operand[0].base != VXRegister::CS) &&
(info.operand[0].base != VXRegister::SS) &&
(info.operand[0].base != VXRegister::DS) &&
(info.operand[0].base != VXRegister::FS) &&
(info.operand[0].base != VXRegister::GS))))
((info.operand[0].type != ZyDisOperandType::REGISTER) ||
((info.operand[0].base != ZyDisRegister::ES) &&
(info.operand[0].base != ZyDisRegister::CS) &&
(info.operand[0].base != ZyDisRegister::SS) &&
(info.operand[0].base != ZyDisRegister::DS) &&
(info.operand[0].base != ZyDisRegister::FS) &&
(info.operand[0].base != ZyDisRegister::GS))))
{
cast = true;
}
@ -573,11 +573,11 @@ void VXIntelInstructionFormatter::internalFormatInstruction(const VXInstructionI
formatOperand(info, info.operand[1]);
}
// Append the third operand
if (info.operand[2].type != VXOperandType::NONE)
if (info.operand[2].type != ZyDisOperandType::NONE)
{
outputAppend(", ");
bool cast = false;
if (info.operand[2].type == VXOperandType::MEMORY &&
if (info.operand[2].type == ZyDisOperandType::MEMORY &&
(info.operand[2].size != info.operand[1].size))
{
cast = true;
@ -589,38 +589,38 @@ void VXIntelInstructionFormatter::internalFormatInstruction(const VXInstructionI
formatOperand(info, info.operand[2]);
}
// Append the fourth operand
if (info.operand[3].type != VXOperandType::NONE)
if (info.operand[3].type != ZyDisOperandType::NONE)
{
outputAppend(", ");
formatOperand(info, info.operand[3]);
}
}
VXIntelInstructionFormatter::VXIntelInstructionFormatter()
: VXBaseInstructionFormatter()
ZyDisIntelInstructionFormatter::ZyDisIntelInstructionFormatter()
: ZyDisBaseInstructionFormatter()
{
}
VXIntelInstructionFormatter::VXIntelInstructionFormatter(VXBaseSymbolResolver* symbolResolver)
: VXBaseInstructionFormatter(symbolResolver)
ZyDisIntelInstructionFormatter::ZyDisIntelInstructionFormatter(ZyDisBaseSymbolResolver* symbolResolver)
: ZyDisBaseInstructionFormatter(symbolResolver)
{
}
VXIntelInstructionFormatter::~VXIntelInstructionFormatter()
ZyDisIntelInstructionFormatter::~ZyDisIntelInstructionFormatter()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////
VXExactSymbolResolver::~VXExactSymbolResolver()
ZyDisExactSymbolResolver::~ZyDisExactSymbolResolver()
{
}
const char* VXExactSymbolResolver::resolveSymbol(const VXInstructionInfo &info, uint64_t address,
const char* ZyDisExactSymbolResolver::resolveSymbol(const ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset)
{
std::unordered_map<uint64_t, std::string>::const_iterator iterator = m_symbolMap.find(address);
@ -632,23 +632,23 @@ const char* VXExactSymbolResolver::resolveSymbol(const VXInstructionInfo &info,
return nullptr;
}
bool VXExactSymbolResolver::containsSymbol(uint64_t address) const
bool ZyDisExactSymbolResolver::containsSymbol(uint64_t address) const
{
std::unordered_map<uint64_t, std::string>::const_iterator iterator = m_symbolMap.find(address);
return (iterator != m_symbolMap.end());
}
void VXExactSymbolResolver::setSymbol(uint64_t address, const char* name)
void ZyDisExactSymbolResolver::setSymbol(uint64_t address, const char* name)
{
m_symbolMap[address].assign(name);
}
void VXExactSymbolResolver::removeSymbol(uint64_t address)
void ZyDisExactSymbolResolver::removeSymbol(uint64_t address)
{
m_symbolMap.erase(address);
}
void VXExactSymbolResolver::clear()
void ZyDisExactSymbolResolver::clear()
{
m_symbolMap.clear();
}

View File

@ -34,7 +34,7 @@
#include <vector>
#include <unordered_map>
#include <string>
#include "VXDisassemblerTypes.hpp"
#include "ZyDisDisassemblerTypes.hpp"
namespace Verteron
{
@ -44,13 +44,13 @@ namespace Verteron
/**
* @brief Base class for all symbol resolver implementations.
*/
class VXBaseSymbolResolver
class ZyDisBaseSymbolResolver
{
public:
/**
* @brief Destructor.
*/
virtual ~VXBaseSymbolResolver();
virtual ~ZyDisBaseSymbolResolver();
public:
/**
* @brief Resolves a symbol.
@ -60,7 +60,7 @@ public:
* 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,
virtual const char* resolveSymbol(const ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset);
};
@ -69,11 +69,11 @@ public:
/**
* @brief Base class for all instruction formatter implementations.
*/
class VXBaseInstructionFormatter
class ZyDisBaseInstructionFormatter
{
private:
static const char *m_registerStrings[];
VXBaseSymbolResolver *m_symbolResolver;
ZyDisBaseSymbolResolver *m_symbolResolver;
std::vector<char> m_outputBuffer;
size_t m_outputStringLen;
bool m_outputUppercase;
@ -109,7 +109,7 @@ protected:
* @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,
void outputAppendAddress(const ZyDisInstructionInfo &info, uint64_t address,
bool resolveSymbols = true);
/**
* @brief Appends a formatted immediate value to the output string buffer.
@ -118,21 +118,21 @@ protected:
* @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,
void outputAppendImmediate(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &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);
void outputAppendDisplacement(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &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;
const char* registerToString(ZyDisRegister reg) const;
/**
* @brief Resolves a symbol.
* @param info The instruction info.
@ -141,7 +141,7 @@ protected:
* 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,
const char* resolveSymbol(const ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset) const;
protected:
/**
@ -150,58 +150,58 @@ protected:
* string buffer.
* @param info The instruction info.
*/
virtual void internalFormatInstruction(const VXInstructionInfo &info);
virtual void internalFormatInstruction(const ZyDisInstructionInfo &info);
/**
* @brief Default constructor.
*/
VXBaseInstructionFormatter();
ZyDisBaseInstructionFormatter();
/**
* @brief Constructor.
* @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol
* resolver should be used.
*/
explicit VXBaseInstructionFormatter(VXBaseSymbolResolver *symbolResolver);
explicit ZyDisBaseInstructionFormatter(ZyDisBaseSymbolResolver *symbolResolver);
public:
/**
* @brief Destructor.
*/
virtual ~VXBaseInstructionFormatter();
virtual ~ZyDisBaseInstructionFormatter();
public:
/**
* @brief Formats a decoded instruction.
* @param info The instruction info.
* @return Pointer to the formatted instruction string.
*/
const char* formatInstruction(const VXInstructionInfo &info);
const char* formatInstruction(const ZyDisInstructionInfo &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;
ZyDisBaseSymbolResolver* 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);
void setSymbolResolver(ZyDisBaseSymbolResolver *symbolResolver);
};
inline void VXBaseInstructionFormatter::outputSetUppercase(bool uppercase)
inline void ZyDisBaseInstructionFormatter::outputSetUppercase(bool uppercase)
{
m_outputUppercase = uppercase;
}
inline char const* VXBaseInstructionFormatter::registerToString(VXRegister reg) const
inline char const* ZyDisBaseInstructionFormatter::registerToString(ZyDisRegister reg) const
{
if (reg == VXRegister::NONE)
if (reg == ZyDisRegister::NONE)
{
return "error";
}
return m_registerStrings[static_cast<uint16_t>(reg) - 1];
}
inline char const* VXBaseInstructionFormatter::resolveSymbol(const VXInstructionInfo &info,
inline char const* ZyDisBaseInstructionFormatter::resolveSymbol(const ZyDisInstructionInfo &info,
uint64_t address, uint64_t &offset) const
{
if (m_symbolResolver)
@ -211,12 +211,12 @@ inline char const* VXBaseInstructionFormatter::resolveSymbol(const VXInstruction
return nullptr;
}
inline VXBaseSymbolResolver* VXBaseInstructionFormatter::getSymbolResolver() const
inline ZyDisBaseSymbolResolver* ZyDisBaseInstructionFormatter::getSymbolResolver() const
{
return m_symbolResolver;
}
inline void VXBaseInstructionFormatter::setSymbolResolver(VXBaseSymbolResolver *symbolResolver)
inline void ZyDisBaseInstructionFormatter::setSymbolResolver(ZyDisBaseSymbolResolver *symbolResolver)
{
m_symbolResolver = symbolResolver;
}
@ -226,7 +226,7 @@ inline void VXBaseInstructionFormatter::setSymbolResolver(VXBaseSymbolResolver *
/**
* @brief Intel syntax instruction formatter.
*/
class VXIntelInstructionFormatter : public VXBaseInstructionFormatter
class ZyDisIntelInstructionFormatter : public ZyDisBaseInstructionFormatter
{
private:
/**
@ -234,35 +234,35 @@ private:
* @param info The instruction info.
* @param operand The operand.
*/
void outputAppendOperandCast(const VXInstructionInfo &info, const VXOperandInfo &operand);
void outputAppendOperandCast(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &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);
void formatOperand(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &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;
void internalFormatInstruction(const ZyDisInstructionInfo &info) override;
public:
/**
* @brief Default constructor.
*/
VXIntelInstructionFormatter();
ZyDisIntelInstructionFormatter();
/**
* @brief Constructor.
* @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol
* resolver should be used.
*/
explicit VXIntelInstructionFormatter(VXBaseSymbolResolver *symbolResolver);
explicit ZyDisIntelInstructionFormatter(ZyDisBaseSymbolResolver *symbolResolver);
/**
* @brief Destructor.
*/
~VXIntelInstructionFormatter() override;
~ZyDisIntelInstructionFormatter() override;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -270,7 +270,7 @@ public:
/**
* @brief Simple symbol resolver that only matches exact addresses.
*/
class VXExactSymbolResolver : public VXBaseSymbolResolver
class ZyDisExactSymbolResolver : public ZyDisBaseSymbolResolver
{
private:
std::unordered_map<uint64_t, std::string> m_symbolMap;
@ -278,7 +278,7 @@ public:
/**
* @brief Destructor.
*/
~VXExactSymbolResolver() override;
~ZyDisExactSymbolResolver() override;
public:
/**
* @brief Resolves a symbol.
@ -288,7 +288,7 @@ public:
* 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,
const char* resolveSymbol(const ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset) override;
public:
/**

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@ namespace Verteron
/**
* @brief Values that represent an instruction mnemonic.
*/
enum class VXInstructionMnemonic : uint16_t
enum class ZyDisInstructionMnemonic : uint16_t
{
/* 000 */ INVALID,
/* 001 */ AAA,
@ -922,8 +922,8 @@ enum class VXInstructionMnemonic : uint16_t
/* 36D */ VUNPCKHPS,
/* 36E */ VUNPCKLPD,
/* 36F */ VUNPCKLPS,
/* 370 */ VXORPD,
/* 371 */ VXORPS,
/* 370 */ ZyDisORPD,
/* 371 */ ZyDisORPS,
/* 372 */ VZEROALL,
/* 373 */ VZEROUPPER,
/* 374 */ WAIT,
@ -953,12 +953,12 @@ enum class VXInstructionMnemonic : uint16_t
* @brief Defines an alias representing an opcode tree node. An opcode tree node is a 16 bit
* unsigned integer value with its first 4 bits reserved for the node type.
*/
typedef uint16_t VXOpcodeTreeNode;
typedef uint16_t ZyDisOpcodeTreeNode;
/**
* @brief Values that represent the type of an opcode tree node.
*/
enum class VXOpcodeTreeNodeType : uint8_t
enum class ZyDisOpcodeTreeNodeType : uint8_t
{
/**
* @brief Reference to a concrete instruction definition.
@ -1025,7 +1025,7 @@ enum class VXOpcodeTreeNodeType : uint8_t
/**
* @brief Values that represent the type of an operand in the instruction definition.
*/
enum class VXDefinedOperandType : uint8_t
enum class ZyDisDefinedOperandType : uint8_t
{
/*
* @brief No operand.
@ -1286,7 +1286,7 @@ enum class VXDefinedOperandType : uint8_t
* @brief Values that represent the size of an operand in the instruction definition.
* Do not change the order or the values of this enum!
*/
enum class VXDefinedOperandSize : uint8_t
enum class ZyDisDefinedOperandSize : uint8_t
{
/**
* @brief No operand.
@ -1386,7 +1386,7 @@ enum class VXDefinedOperandSize : uint8_t
* @brief Values that represent optional flags in the instruction definition.
* Do not change the order or the values of this enum!
*/
enum VXInstructionDefinitionFlags : uint16_t
enum ZyDisInstructionDefinitionFlags : uint16_t
{
/**
* @brief The instruction accepts the rex.b prefix value.
@ -1454,30 +1454,30 @@ enum VXInstructionDefinitionFlags : uint16_t
/**
* @brief An operand definition.
*/
struct VXOperandDefinition
struct ZyDisOperandDefinition
{
/**
* @brief The defined operand type.
*/
VXDefinedOperandType type;
ZyDisDefinedOperandType type;
/**
* @brief The defined operand size.
*/
VXDefinedOperandSize size;
ZyDisDefinedOperandSize size;
};
/**
* @brief An instruction definition.
*/
struct VXInstructionDefinition
struct ZyDisInstructionDefinition
{
/**
* @brief The instruction mnemonic.
*/
VXInstructionMnemonic mnemonic;
ZyDisInstructionMnemonic mnemonic;
/**
* @brief The operand definitions for all four possible operands.
*/
VXOperandDefinition operand[4];
ZyDisOperandDefinition operand[4];
/**
* @brief Additional flags for the instruction definition.
*/
@ -1492,24 +1492,24 @@ namespace Internal
* @brief Contains all opcode tables.
* Indexed by the numeric value of the opcode.
*/
extern const VXOpcodeTreeNode optreeTable[][256];
extern const ZyDisOpcodeTreeNode optreeTable[][256];
/**
* @brief Contains all modrm_mod switch tables.
* Index values:
* 0 = [modrm_mod == !11]
* 1 = [modrm_mod == 11]
*/
extern const VXOpcodeTreeNode optreeModrmMod[][2];
extern const ZyDisOpcodeTreeNode optreeModrmMod[][2];
/**
* @brief Contains all modrm_reg switch tables.
* Indexed by the numeric value of the modrm_reg field.
*/
extern const VXOpcodeTreeNode optreeModrmReg[][8];
extern const ZyDisOpcodeTreeNode optreeModrmReg[][8];
/**
* @brief Contains all modrm_rm switch tables.
* Indexed by the numeric value of the modrm_rm field.
*/
extern const VXOpcodeTreeNode optreeModrmRm[][8];
extern const ZyDisOpcodeTreeNode optreeModrmRm[][8];
/**
* @brief Contains all mandatory-prefix switch tables.
* Index values:
@ -1518,13 +1518,13 @@ extern const VXOpcodeTreeNode optreeModrmRm[][8];
* 2 = F3
* 3 = 66
*/
extern const VXOpcodeTreeNode optreeMandatory[][4];
extern const ZyDisOpcodeTreeNode optreeMandatory[][4];
/**
* @brief Contains all x87 opcode tables.
* Indexed by the numeric value of the 6 lowest bits of the modrm byte (modrm_mod should
* always be 11).
*/
extern const VXOpcodeTreeNode optreeX87[][64];
extern const ZyDisOpcodeTreeNode optreeX87[][64];
/**
* @brief Contains all address-size switch tables.
* Index values:
@ -1532,7 +1532,7 @@ extern const VXOpcodeTreeNode optreeX87[][64];
* 1 = 32
* 2 = 64
*/
extern const VXOpcodeTreeNode optreeAddressSize[][3];
extern const ZyDisOpcodeTreeNode optreeAddressSize[][3];
/**
* @brief Contains all operand-size switch tables.
* Index values:
@ -1540,26 +1540,26 @@ extern const VXOpcodeTreeNode optreeAddressSize[][3];
* 1 = 32
* 2 = 64
*/
extern const VXOpcodeTreeNode optreeOperandSize[][3];
extern const ZyDisOpcodeTreeNode optreeOperandSize[][3];
/**
* @brief Contains all cpu-mode switch tables.
* Index values:
* 0 = [!= 64]
* 1 = 64
*/
extern const VXOpcodeTreeNode optreeMode[][2];
extern const ZyDisOpcodeTreeNode optreeMode[][2];
/**
* @brief Contains all vendor switch tables.
* Index values:
* 0 = AMD
* 1 = Intel
*/
extern const VXOpcodeTreeNode optreeVendor[][2];
extern const ZyDisOpcodeTreeNode optreeVendor[][2];
/**
* @brief Contains all 3dnow! switch tables.
* Indexed by the numeric value of the 3dnow! opcode.
*/
extern const VXOpcodeTreeNode optree3dnow[][256];
extern const ZyDisOpcodeTreeNode optree3dnow[][256];
/**
* @brief Contains all vex switch tables.
* Index values:
@ -1580,21 +1580,21 @@ extern const VXOpcodeTreeNode optree3dnow[][256];
* E = F2_0F38
* F = F2_0F3A
*/
extern const VXOpcodeTreeNode optreeVex[][16];
extern const ZyDisOpcodeTreeNode optreeVex[][16];
/**
* @brief Contains all vex_w switch tables.
* Indexed by the numeric value of the vex_w field.
*/
extern const VXOpcodeTreeNode optreeVexW[][2];
extern const ZyDisOpcodeTreeNode optreeVexW[][2];
/**
* @brief Contains all vex_l switch tables.
* Indexed by the numeric value of the vex_l field.
*/
extern const VXOpcodeTreeNode optreeVexL[][2];
extern const ZyDisOpcodeTreeNode optreeVexL[][2];
/**
* @brief Contains all instruction definitions.
*/
extern const VXInstructionDefinition instrDefinitions[];
extern const ZyDisInstructionDefinition instrDefinitions[];
/**
* @brief Contains all instruction mnemonic strings.
*/
@ -1605,9 +1605,9 @@ extern const char* instrMnemonicStrings[];
* @param node The node.
* @return The type of the specified opcode tree node.
*/
inline VXOpcodeTreeNodeType VDEGetOpcodeNodeType(VXOpcodeTreeNode node)
inline ZyDisOpcodeTreeNodeType VDEGetOpcodeNodeType(ZyDisOpcodeTreeNode node)
{
return static_cast<VXOpcodeTreeNodeType>((node >> 12) & 0x0F);
return static_cast<ZyDisOpcodeTreeNodeType>((node >> 12) & 0x0F);
}
/**
@ -1615,7 +1615,7 @@ inline VXOpcodeTreeNodeType VDEGetOpcodeNodeType(VXOpcodeTreeNode node)
* @param node The node.
* @return The value of the specified opcode tree node.
*/
inline uint16_t VDEGetOpcodeNodeValue(VXOpcodeTreeNode node)
inline uint16_t VDEGetOpcodeNodeValue(ZyDisOpcodeTreeNode node)
{
return (node & 0x0FFF);
}
@ -1624,7 +1624,7 @@ inline uint16_t VDEGetOpcodeNodeValue(VXOpcodeTreeNode node)
* @brief Returns the root node of the opcode tree.
* @return The root node of the opcode tree.
*/
inline VXOpcodeTreeNode VDEGetOpcodeTreeRoot()
inline ZyDisOpcodeTreeNode VDEGetOpcodeTreeRoot()
{
return 0x1000;
}
@ -1635,53 +1635,53 @@ inline VXOpcodeTreeNode VDEGetOpcodeTreeRoot()
* @param index The index of the child node to retrieve.
* @return The specified child node.
*/
inline VXOpcodeTreeNode VDEGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_t index)
inline ZyDisOpcodeTreeNode VDEGetOpcodeTreeChild(ZyDisOpcodeTreeNode parent, uint16_t index)
{
using namespace Internal;
VXOpcodeTreeNodeType nodeType = VDEGetOpcodeNodeType(parent);
ZyDisOpcodeTreeNodeType nodeType = VDEGetOpcodeNodeType(parent);
uint16_t tableIndex = VDEGetOpcodeNodeValue(parent);
switch (nodeType)
{
case VXOpcodeTreeNodeType::TABLE:
case ZyDisOpcodeTreeNodeType::TABLE:
assert(index < 256);
return optreeTable[tableIndex][index];
case VXOpcodeTreeNodeType::MODRM_MOD:
case ZyDisOpcodeTreeNodeType::MODRM_MOD:
assert(index < 2);
return optreeModrmMod[tableIndex][index];
case VXOpcodeTreeNodeType::MODRM_REG:
case ZyDisOpcodeTreeNodeType::MODRM_REG:
assert(index < 8);
return optreeModrmReg[tableIndex][index];
case VXOpcodeTreeNodeType::MODRM_RM:
case ZyDisOpcodeTreeNodeType::MODRM_RM:
assert(index < 8);
return optreeModrmRm[tableIndex][index];
case VXOpcodeTreeNodeType::MANDATORY:
case ZyDisOpcodeTreeNodeType::MANDATORY:
assert(index < 4);
return optreeMandatory[tableIndex][index];
case VXOpcodeTreeNodeType::X87:
case ZyDisOpcodeTreeNodeType::X87:
assert(index < 64);
return optreeX87[tableIndex][index];
case VXOpcodeTreeNodeType::ADDRESS_SIZE:
case ZyDisOpcodeTreeNodeType::ADDRESS_SIZE:
assert(index < 3);
return optreeAddressSize[tableIndex][index];
case VXOpcodeTreeNodeType::OPERAND_SIZE:
case ZyDisOpcodeTreeNodeType::OPERAND_SIZE:
assert(index < 3);
return optreeOperandSize[tableIndex][index];
case VXOpcodeTreeNodeType::MODE:
case ZyDisOpcodeTreeNodeType::MODE:
assert(index < 2);
return optreeMode[tableIndex][index];
case VXOpcodeTreeNodeType::VENDOR:
case ZyDisOpcodeTreeNodeType::VENDOR:
assert(index < 3);
return optreeVendor[tableIndex][index];
case VXOpcodeTreeNodeType::AMD3DNOW:
case ZyDisOpcodeTreeNodeType::AMD3DNOW:
assert(index < 256);
return optree3dnow[tableIndex][index];
case VXOpcodeTreeNodeType::VEX:
case ZyDisOpcodeTreeNodeType::VEX:
assert(index < 16);
return optreeVex[tableIndex][index];
case VXOpcodeTreeNodeType::VEXW:
case ZyDisOpcodeTreeNodeType::VEXW:
assert(index < 2);
return optreeVexW[tableIndex][index];
case VXOpcodeTreeNodeType::VEXL:
case ZyDisOpcodeTreeNodeType::VEXL:
assert(index < 2);
return optreeVexL[tableIndex][index];
default:
@ -1695,9 +1695,9 @@ inline VXOpcodeTreeNode VDEGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_t
* @param node The instruction definition node.
* @return Pointer to the instruction definition.
*/
inline const VXInstructionDefinition* VDEGetInstructionDefinition(VXOpcodeTreeNode node)
inline const ZyDisInstructionDefinition* VDEGetInstructionDefinition(ZyDisOpcodeTreeNode node)
{
assert(VDEGetOpcodeNodeType(node) == VXOpcodeTreeNodeType::INSTRUCTION_DEFINITION);
assert(VDEGetOpcodeNodeType(node) == ZyDisOpcodeTreeNodeType::INSTRUCTION_DEFINITION);
return &instrDefinitions[node & 0x0FFF];
}
@ -1706,7 +1706,7 @@ inline const VXInstructionDefinition* VDEGetInstructionDefinition(VXOpcodeTreeNo
* @param mnemonic The mnemonic.
* @return The instruction mnemonic string.
*/
inline const char* VDEGetInstructionMnemonicString(VXInstructionMnemonic mnemonic)
inline const char* VDEGetInstructionMnemonicString(ZyDisInstructionMnemonic mnemonic)
{
return instrMnemonicStrings[static_cast<uint16_t>(mnemonic)];
}
@ -1716,14 +1716,14 @@ inline const char* VDEGetInstructionMnemonicString(VXInstructionMnemonic mnemoni
* @param operandSize The defined operand size.
* @return The the numeric value for the simple operand size definition.
*/
inline uint16_t VDEGetSimpleOperandSize(VXDefinedOperandSize operandSize)
inline uint16_t VDEGetSimpleOperandSize(ZyDisDefinedOperandSize operandSize)
{
static uint16_t operandSizes[8] =
{
8, 16, 32, 64, 80, 12, 128, 256
};
uint16_t index =
static_cast<uint8_t>(operandSize) - static_cast<uint8_t>(VXDefinedOperandSize::B);
static_cast<uint8_t>(operandSize) - static_cast<uint8_t>(ZyDisDefinedOperandSize::B);
assert(index < 8);
return operandSizes[index];
}
@ -1733,9 +1733,9 @@ inline uint16_t VDEGetSimpleOperandSize(VXDefinedOperandSize operandSize)
* @param operandSize The defined operand size.
* @return The memory-size part of the operand size definition.
*/
inline VXDefinedOperandSize VDEGetComplexOperandMemSize(VXDefinedOperandSize operandSize)
inline ZyDisDefinedOperandSize VDEGetComplexOperandMemSize(ZyDisDefinedOperandSize operandSize)
{
return static_cast<VXDefinedOperandSize>(static_cast<uint8_t>(operandSize) & 0x0F);
return static_cast<ZyDisDefinedOperandSize>(static_cast<uint8_t>(operandSize) & 0x0F);
}
/**
@ -1743,9 +1743,9 @@ inline VXDefinedOperandSize VDEGetComplexOperandMemSize(VXDefinedOperandSize ope
* @param operandSize The defined operand size.
* @return The register-size part of the operand size definition.
*/
inline VXDefinedOperandSize VDEGetComplexOperandRegSize(VXDefinedOperandSize operandSize)
inline ZyDisDefinedOperandSize VDEGetComplexOperandRegSize(ZyDisDefinedOperandSize operandSize)
{
return static_cast<VXDefinedOperandSize>((static_cast<uint8_t>(operandSize) >> 4) & 0x0F);
return static_cast<ZyDisDefinedOperandSize>((static_cast<uint8_t>(operandSize) >> 4) & 0x0F);
}
}

View File

@ -44,42 +44,42 @@ endif ()
# Library
set(vde_headers
"VerteronDisassemblerEngine/VXDisassembler.h"
"VerteronDisassemblerEngine/VXDisassemblerTypes.h"
"VerteronDisassemblerEngine/VXDisassemblerUtils.h"
"VerteronDisassemblerEngine/VXInstructionDecoder.h"
"VerteronDisassemblerEngine/VXInstructionFormatter.h"
"VerteronDisassemblerEngine/VXOpcodeTable.h"
"VerteronDisassemblerEngine/VXOpcodeTableInternal.h"
"VerteronDisassemblerEngine/VXInternalHelpers.h"
"VerteronDisassemblerEngine/VXInternalConfig.h")
"VerteronDisassemblerEngine/ZyDisDisassembler.h"
"VerteronDisassemblerEngine/ZyDisDisassemblerTypes.h"
"VerteronDisassemblerEngine/ZyDisDisassemblerUtils.h"
"VerteronDisassemblerEngine/ZyDisInstructionDecoder.h"
"VerteronDisassemblerEngine/ZyDisInstructionFormatter.h"
"VerteronDisassemblerEngine/ZyDisOpcodeTable.h"
"VerteronDisassemblerEngine/ZyDisOpcodeTableInternal.h"
"VerteronDisassemblerEngine/ZyDisInternalHelpers.h"
"VerteronDisassemblerEngine/ZyDisInternalConfig.h")
set(vde_sources
"VerteronDisassemblerEngine/VXDisassemblerUtils.c"
"VerteronDisassemblerEngine/VXInstructionFormatter.c"
"VerteronDisassemblerEngine/VXOpcodeTable.c"
"VerteronDisassemblerEngine/VXInstructionDecoder.c")
"VerteronDisassemblerEngine/ZyDisDisassemblerUtils.c"
"VerteronDisassemblerEngine/ZyDisInstructionFormatter.c"
"VerteronDisassemblerEngine/ZyDisOpcodeTable.c"
"VerteronDisassemblerEngine/ZyDisInstructionDecoder.c")
add_library("VerteronDisassemblerEngine" ${vde_headers} ${vde_sources})
generate_export_header(
"VerteronDisassemblerEngine"
BASE_NAME "VX"
EXPORT_FILE_NAME "VXExportConfig.h")
BASE_NAME "ZyDis"
EXPORT_FILE_NAME "ZyDisExportConfig.h")
include_directories(${PROJECT_BINARY_DIR})
# 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")
"Bindings/Cpp/ZyDisDisassembler.hpp"
"Bindings/Cpp/ZyDisDisassemblerTypes.hpp"
"Bindings/Cpp/ZyDisDisassemblerUtils.hpp"
"Bindings/Cpp/ZyDisInstructionDecoder.hpp"
"Bindings/Cpp/ZyDisInstructionFormatter.hpp"
"Bindings/Cpp/ZyDisOpcodeTable.hpp")
set(vdecpp_sources
"Bindings/Cpp/VXDisassemblerUtils.cpp"
"Bindings/Cpp/VXInstructionFormatter.cpp"
"Bindings/Cpp/VXOpcodeTable.cpp"
"Bindings/Cpp/VXInstructionDecoder.cpp")
"Bindings/Cpp/ZyDisDisassemblerUtils.cpp"
"Bindings/Cpp/ZyDisInstructionFormatter.cpp"
"Bindings/Cpp/ZyDisOpcodeTable.cpp"
"Bindings/Cpp/ZyDisInstructionDecoder.cpp")
add_library("VerteronDisassemblerEngineCpp" ${vdecpp_headers} ${vdecpp_sources})
target_link_libraries("VerteronDisassemblerEngineCpp" "VerteronDisassemblerEngine")
endif ()

View File

@ -33,7 +33,7 @@
#include <iostream>
#include <iomanip>
#include <VXDisassembler.hpp>
#include <ZyDisDisassembler.hpp>
using namespace Verteron;

View File

@ -30,11 +30,11 @@
**************************************************************************************************/
#include <VXDisassembler.h>
#include <ZyDisDisassembler.h>
int main(int argc, char* argv[])
{
VX_UNUSED(argc); VX_UNUSED(argv);
ZYDIS_UNUSED(argc); ZYDIS_UNUSED(argv);
// TODO:
return 0;

View File

@ -30,11 +30,11 @@
**************************************************************************************************/
#include <VXDisassembler.h>
#include <ZyDisDisassembler.h>
int main(int argc, char* argv[])
{
VX_UNUSED(argc); VX_UNUSED(argv);
ZYDIS_UNUSED(argc); ZYDIS_UNUSED(argv);
// TODO:
return 0;

View File

@ -30,7 +30,7 @@
**************************************************************************************************/
#include <VXDisassembler.h>
#include <ZyDisDisassembler.h>
#include <stdio.h>
#include <stdint.h>
@ -64,24 +64,24 @@ int main()
0x5F, 0x41, 0x5E, 0x41, 0x5D, 0x41, 0x5C, 0x5F, 0xC3
};
VXInstructionInfo info;
VXInstructionDecoderContext* decoder = NULL;
VXBaseInstructionFormatterContext* formatter = NULL;
VXBaseDataSourceContext* input32 = NULL;
VXBaseDataSourceContext* input64 = NULL;
ZyDisInstructionInfo info;
ZyDisInstructionDecoderContext* decoder = NULL;
ZyDisBaseInstructionFormatterContext* formatter = NULL;
ZyDisBaseDataSourceContext* input32 = NULL;
ZyDisBaseDataSourceContext* input64 = NULL;
decoder = VXInstructionDecoder_Create();
formatter = VXIntelInstructionFormatter_Create();
decoder = ZyDisInstructionDecoder_Create();
formatter = ZyDisIntelInstructionFormatter_Create();
input32 = VXMemoryDataSource_Create(&data32[0], sizeof(data32));
input64 = VXMemoryDataSource_Create(&data64[0], sizeof(data64));
input32 = ZyDisMemoryDataSource_Create(&data32[0], sizeof(data32));
input64 = ZyDisMemoryDataSource_Create(&data64[0], sizeof(data64));
VXInstructionDecoder_SetDisassemblerMode(decoder, DM_M32BIT);
VXInstructionDecoder_SetDataSource(decoder, input32);
VXInstructionDecoder_SetInstructionPointer(decoder, 0x77091852);
ZyDisInstructionDecoder_SetDisassemblerMode(decoder, DM_M32BIT);
ZyDisInstructionDecoder_SetDataSource(decoder, input32);
ZyDisInstructionDecoder_SetInstructionPointer(decoder, 0x77091852);
puts("32 bit test ...\n\n");
while (VXInstructionDecoder_DecodeInstruction(decoder, &info))
while (ZyDisInstructionDecoder_DecodeInstruction(decoder, &info))
{
printf("%08X ", (uint32_t)(info.instrAddress & 0xFFFFFFFF));
if (info.flags & IF_ERROR_MASK)
@ -90,17 +90,17 @@ int main()
}
else
{
printf("%s\n", VXBaseInstructionFormatter_FormatInstruction(formatter, &info));
printf("%s\n", ZyDisBaseInstructionFormatter_FormatInstruction(formatter, &info));
}
}
puts("\n");
VXInstructionDecoder_SetDisassemblerMode(decoder, DM_M64BIT);
VXInstructionDecoder_SetDataSource(decoder, input64);
VXInstructionDecoder_SetInstructionPointer(decoder, 0x00007FFA39A81930ull);
ZyDisInstructionDecoder_SetDisassemblerMode(decoder, DM_M64BIT);
ZyDisInstructionDecoder_SetDataSource(decoder, input64);
ZyDisInstructionDecoder_SetInstructionPointer(decoder, 0x00007FFA39A81930ull);
puts("64 bit test ...\n\n");
while (VXInstructionDecoder_DecodeInstruction(decoder, &info))
while (ZyDisInstructionDecoder_DecodeInstruction(decoder, &info))
{
printf("%016llX ", info.instrAddress);
if (info.flags & IF_ERROR_MASK)
@ -109,14 +109,14 @@ int main()
}
else
{
printf("%s\n", VXBaseInstructionFormatter_FormatInstruction(formatter, &info));
printf("%s\n", ZyDisBaseInstructionFormatter_FormatInstruction(formatter, &info));
}
}
VXBaseDataSource_Release(input32);
VXBaseDataSource_Release(input64);
VXBaseInstructionFormatter_Release(formatter);
VXInstructionDecoder_Release(decoder);
ZyDisBaseDataSource_Release(input32);
ZyDisBaseDataSource_Release(input64);
ZyDisBaseInstructionFormatter_Release(formatter);
ZyDisInstructionDecoder_Release(decoder);
getchar();
return 0;

View File

@ -30,12 +30,12 @@
**************************************************************************************************/
#include <VXDisassembler.h>
#include <ZyDisDisassembler.h>
#include <Windows.h>
int main(int argc, char* argv[])
{
VX_UNUSED(argc); VX_UNUSED(argv);
ZYDIS_UNUSED(argc); ZYDIS_UNUSED(argv);
// TODO: port to C
/*
@ -57,14 +57,14 @@ int main(int argc, char* argv[])
return 1;
}
// Initialize disassembler
VXInstructionInfo info;
VXInstructionDecoder decoder;
VXExactSymbolResolver resolver;
VXIntelInstructionFormatter formatter;
ZyDisInstructionInfo info;
ZyDisInstructionDecoder decoder;
ZyDisExactSymbolResolver resolver;
ZyDisIntelInstructionFormatter formatter;
#ifdef _M_X64
decoder.setDisassemblerMode(VXDisassemblerMode::M64BIT);
decoder.setDisassemblerMode(ZyDisDisassemblerMode::M64BIT);
#else
decoder.setDisassemblerMode(VXDisassemblerMode::M32BIT);
decoder.setDisassemblerMode(ZyDisDisassemblerMode::M32BIT);
#endif
formatter.setSymbolResolver(&resolver);
// Initialize output stream
@ -81,7 +81,7 @@ int main(int argc, char* argv[])
{
if (sectionHeader->Characteristics & IMAGE_SCN_CNT_CODE)
{
VXMemoryDataSource input(reinterpret_cast<const void*>(
ZyDisMemoryDataSource input(reinterpret_cast<const void*>(
baseAddress + sectionHeader->VirtualAddress), sectionHeader->SizeOfRawData);
decoder.setDataSource(&input);
decoder.setInstructionPointer(baseAddress + sectionHeader->VirtualAddress);
@ -94,31 +94,31 @@ int main(int argc, char* argv[])
}
switch (info.mnemonic)
{
case VXInstructionMnemonic::CALL:
case ZyDisInstructionMnemonic::CALL:
resolver.setSymbol(VDECalcAbsoluteTarget(info, info.operand[0]),
std::string("sub_" + std::to_string(subCount)).c_str());
subCount++;
break;
case VXInstructionMnemonic::JMP:
case VXInstructionMnemonic::JO:
case VXInstructionMnemonic::JNO:
case VXInstructionMnemonic::JB:
case VXInstructionMnemonic::JNB:
case VXInstructionMnemonic::JE:
case VXInstructionMnemonic::JNE:
case VXInstructionMnemonic::JBE:
case VXInstructionMnemonic::JA:
case VXInstructionMnemonic::JS:
case VXInstructionMnemonic::JNS:
case VXInstructionMnemonic::JP:
case VXInstructionMnemonic::JNP:
case VXInstructionMnemonic::JL:
case VXInstructionMnemonic::JGE:
case VXInstructionMnemonic::JLE:
case VXInstructionMnemonic::JG:
case VXInstructionMnemonic::JCXZ:
case VXInstructionMnemonic::JECXZ:
case VXInstructionMnemonic::JRCXZ:
case ZyDisInstructionMnemonic::JMP:
case ZyDisInstructionMnemonic::JO:
case ZyDisInstructionMnemonic::JNO:
case ZyDisInstructionMnemonic::JB:
case ZyDisInstructionMnemonic::JNB:
case ZyDisInstructionMnemonic::JE:
case ZyDisInstructionMnemonic::JNE:
case ZyDisInstructionMnemonic::JBE:
case ZyDisInstructionMnemonic::JA:
case ZyDisInstructionMnemonic::JS:
case ZyDisInstructionMnemonic::JNS:
case ZyDisInstructionMnemonic::JP:
case ZyDisInstructionMnemonic::JNP:
case ZyDisInstructionMnemonic::JL:
case ZyDisInstructionMnemonic::JGE:
case ZyDisInstructionMnemonic::JLE:
case ZyDisInstructionMnemonic::JG:
case ZyDisInstructionMnemonic::JCXZ:
case ZyDisInstructionMnemonic::JECXZ:
case ZyDisInstructionMnemonic::JRCXZ:
resolver.setSymbol(VDECalcAbsoluteTarget(info, info.operand[0]),
std::string("loc_" + std::to_string(locCount)).c_str());
locCount++;
@ -162,7 +162,7 @@ int main(int argc, char* argv[])
{
if (sectionHeader->Characteristics & IMAGE_SCN_CNT_CODE)
{
VXMemoryDataSource input(reinterpret_cast<const void*>(
ZyDisMemoryDataSource input(reinterpret_cast<const void*>(
baseAddress + sectionHeader->VirtualAddress), sectionHeader->SizeOfRawData);
decoder.setDataSource(&input);
decoder.setInstructionPointer(baseAddress + sectionHeader->VirtualAddress);

View File

@ -1,197 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : athre0z
Modifications :
Last change : 19. 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_VXINTERNALHELPERS_H_
#define _VDE_VXINTERNALHELPERS_H_
#include "VXInstructionDecoder.h"
#include "VXInstructionFormatter.h"
#include "VXInternalConfig.h"
#include <assert.h>
/* Types IDs =================================================================================== */
typedef enum _VXTypeId
{
TYPE_BASEDATASOURCE,
TYPE_MEMORYDATASOURCE,
TYPE_CUSTOMDATASOURCE,
TYPE_INSTRUCTIONDECODER,
TYPE_BASESYMBOLRESOLVER,
TYPE_CUSTOMSYMBOLRESOLVER,
TYPE_BASEINSTRUCTIONFORMATTER,
TYPE_INTELINSTRUCTIONFORMATTER,
TYPE_CUSTOMINSTRUCTIONFORMATTER,
} VXTypeId;
/* Context conversion helpers ================================================================== */
VX_INLINE struct _VXBaseDataSource* VXBaseDataSource_thiz(
VXBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_BASEDATASOURCE
|| ctx->d.type == TYPE_MEMORYDATASOURCE
|| ctx->d.type == TYPE_CUSTOMDATASOURCE);
return (struct _VXBaseDataSource*)ctx->d.ptr;
}
VX_INLINE const struct _VXBaseDataSource* VXBaseDataSource_cthiz(
const VXBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_BASEDATASOURCE
|| ctx->d.type == TYPE_MEMORYDATASOURCE
|| ctx->d.type == TYPE_CUSTOMDATASOURCE);
return (const struct _VXBaseDataSource*)ctx->d.ptr;
}
VX_INLINE struct _VXMemoryDataSource* VXMemoryDataSource_thiz(
VXBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_MEMORYDATASOURCE);
return (struct _VXMemoryDataSource*)ctx->d.ptr;
}
VX_INLINE const struct _VXMemoryDataSource* VXMemoryDataSource_cthiz(
const VXBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_MEMORYDATASOURCE);
return (const struct _VXMemoryDataSource*)ctx->d.ptr;
}
VX_INLINE struct _VXCustomDataSource* VXCustomDataSource_thiz(
VXBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMDATASOURCE);
return (struct _VXCustomDataSource*)ctx->d.ptr;
}
VX_INLINE const struct _VXCustomDataSource* VXCustomDataSource_cthiz(
const VXBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMDATASOURCE);
return (const struct _VXCustomDataSource*)ctx->d.ptr;
}
VX_INLINE struct _VXInstructionDecoder* VXInstructionDecoder_thiz(
VXInstructionDecoderContext *ctx)
{
assert(ctx->d.type == TYPE_INSTRUCTIONDECODER);
return (struct _VXInstructionDecoder*)ctx->d.ptr;
}
VX_INLINE const struct _VXInstructionDecoder* VXInstructionDecoder_cthiz(
const VXInstructionDecoderContext *ctx)
{
assert(ctx->d.type == TYPE_INSTRUCTIONDECODER);
return (const struct _VXInstructionDecoder*)ctx->d.ptr;
}
VX_INLINE struct _VXBaseSymbolResolver* VXBaseSymbolResolver_thiz(
VXBaseSymbolResolverContext *ctx)
{
assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER
|| ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (struct _VXBaseSymbolResolver*)ctx->d.ptr;
}
VX_INLINE const struct _VXBaseSymbolResolver* VXBaseSymbolResolver_cthiz(
const VXBaseSymbolResolverContext *ctx)
{
assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER
|| ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (const struct _VXBaseSymbolResolver*)ctx->d.ptr;
}
VX_INLINE struct _VXCustomSymbolResolver* VXCustomSymbolResolver_thiz(
VXBaseSymbolResolverContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (struct _VXCustomSymbolResolver*)ctx->d.ptr;
}
VX_INLINE const struct _VXCustomSymbolResolver* VXCustomSymbolResolver_cthiz(
const VXBaseSymbolResolverContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (const struct _VXCustomSymbolResolver*)ctx->d.ptr;
}
VX_INLINE struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_thiz(
VXBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER
|| ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER
|| ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
return (struct _VXBaseInstructionFormatter*)ctx->d.ptr;
}
VX_INLINE const struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_cthiz(
const VXBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER
|| ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER
|| ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
return (const struct _VXBaseInstructionFormatter*)ctx->d.ptr;
}
VX_INLINE struct _VXIntelInstructionFormatter* VXIntelInstructionFormatter_thiz(
VXBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER);
return (struct _VXIntelInstructionFormatter*)ctx->d.ptr;
}
VX_INLINE const struct _VXIntelInstructionFormatter* VXIntelInstructionFormatter_cthiz(
const VXBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER);
return (const struct _VXIntelInstructionFormatter*)ctx->d.ptr;
}
VX_INLINE struct _VXCustomInstructionFormatter* VXCustomInstructionFormatter_thiz(
VXBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
return (struct _VXCustomInstructionFormatter*)ctx->d.ptr;
}
VX_INLINE const struct _VXCustomInstructionFormatter* VXCustomInstructionFormatter_cthiz(
const VXBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
return (struct _VXCustomInstructionFormatter*)ctx->d.ptr;
}
/* ============================================================================================= */
#endif /* _VDE_VXINTERNALHELPERS_H_ */

View File

@ -30,12 +30,12 @@
**************************************************************************************************/
#ifndef _VDE_VXDISASSEMBLERC_H_
#define _VDE_VXDISASSEMBLERC_H_
#ifndef _VDE_ZyDisDISASSEMBLERC_H_
#define _VDE_ZyDisDISASSEMBLERC_H_
#include "VXDisassemblerTypes.h"
#include "VXInstructionDecoder.h"
#include "VXInstructionFormatter.h"
#include "VXDisassemblerUtils.h"
#include "ZyDisDisassemblerTypes.h"
#include "ZyDisInstructionDecoder.h"
#include "ZyDisInstructionFormatter.h"
#include "ZyDisDisassemblerUtils.h"
#endif /* _VDE_VXDISASSEMBLERC_H_ */
#endif /* _VDE_ZyDisDISASSEMBLERC_H_ */

View File

@ -30,12 +30,12 @@
**************************************************************************************************/
#ifndef _VDE_VXDISASSEMBLERTYPESC_H_
#define _VDE_VXDISASSEMBLERTYPESC_H_
#ifndef _VDE_ZyDisDISASSEMBLERTYPESC_H_
#define _VDE_ZyDisDISASSEMBLERTYPESC_H_
#include <stdint.h>
#include <stdbool.h>
#include "VXOpcodeTable.h"
#include "ZyDisOpcodeTable.h"
#ifdef __cplusplus
extern "C"
@ -45,7 +45,7 @@ extern "C"
/**
* @brief Values that represent additional flags of a decoded instruction.
*/
typedef enum _VXInstructionFlags /* : uint32_t */
typedef enum _ZyDisInstructionFlags /* : uint32_t */
{
IF_NONE = 0x00000000,
/**
@ -130,12 +130,12 @@ typedef enum _VXInstructionFlags /* : uint32_t */
IF_ERROR_OPERAND = 0x01000000,
IF_FORCE_DWORD = 0x7FFFFFFF
} VXInstructionFlags;
} ZyDisInstructionFlags;
/**
* @brief Values that represent a cpu register.
*/
typedef enum _VXRegister /* : uint16_t */
typedef enum _ZyDisRegister /* : uint16_t */
{
REG_NONE,
/* 8 bit general purpose registers */
@ -192,12 +192,12 @@ typedef enum _VXRegister /* : uint16_t */
REG_RIP,
REG_FORCE_WORD = 0x7FFF
} VXRegister;
} ZyDisRegister;
/**
* @brief Values that represent the type of a decoded operand.
*/
typedef enum _VXOperandType /*: uint8_t*/
typedef enum _ZyDisOperandType /*: uint8_t*/
{
/**
* @brief The operand is not used.
@ -227,12 +227,12 @@ typedef enum _VXOperandType /*: uint8_t*/
* @brief The operand is a constant value.
*/
OPTYPE_CONSTANT
} VXOperandType;
} ZyDisOperandType;
/**
* @brief Values that represent the operand access mode.
*/
typedef enum _VXOperandAccessMode /* : uint8_t */
typedef enum _ZyDisOperandAccessMode /* : uint8_t */
{
OPACCESSMODE_NA,
/**
@ -247,16 +247,16 @@ typedef enum _VXOperandAccessMode /* : uint8_t */
* @brief The operand is accessed in read-write mode.
*/
OPACCESSMODE_READWRITE
} VXOperandAccessMode;
} ZyDisOperandAccessMode;
/**
* @brief This struct holds information about a decoded operand.
*/
typedef struct _VXOperandInfo
typedef struct _ZyDisOperandInfo
{
/**
* @brief The type of the operand.
* @see VXOperandType
* @see ZyDisOperandType
*/
uint8_t type;
/**
@ -265,17 +265,17 @@ typedef struct _VXOperandInfo
uint16_t size;
/**
* @brief The operand access mode.
* @see VXOperandAccessMode
* @see ZyDisOperandAccessMode
*/
uint8_t access_mode;
/**
* @brief The base register.
* @see VXRegister
* @see ZyDisRegister
*/
uint16_t base;
/**
* @brief The index register.
* @see VXRegister
* @see ZyDisRegister
*/
uint16_t index;
/**
@ -308,12 +308,12 @@ typedef struct _VXOperandInfo
uint32_t off;
} ptr;
} lval;
} VXOperandInfo;
} ZyDisOperandInfo;
/**
* @brief This struct holds information about a decoded instruction.
*/
typedef struct _VXInstructionInfo
typedef struct _ZyDisInstructionInfo
{
/**
* @brief The instruction flags.
@ -321,7 +321,7 @@ typedef struct _VXInstructionInfo
uint32_t flags;
/**
* @brief The instruction mnemonic.
* @see VXInstructionMnemonic
* @see ZyDisInstructionMnemonic
*/
uint16_t mnemonic;
/**
@ -351,11 +351,11 @@ typedef struct _VXInstructionInfo
/**
* @brief The decoded operands.
*/
VXOperandInfo operand[4];
ZyDisOperandInfo operand[4];
/**
* @brief The segment register. This value will default to @c NONE, if no segment register
* prefix is present.
* @see VXRegister
* @see ZyDisRegister
*/
uint16_t segment;
/**
@ -527,7 +527,7 @@ typedef struct _VXInstructionInfo
/**
* @brief The instruction definition.
*/
const VXInstructionDefinition *instrDefinition;
const ZyDisInstructionDefinition *instrDefinition;
/**
* @brief The instruction address points to the current instruction (relative to the
* initial instruction pointer).
@ -539,10 +539,10 @@ typedef struct _VXInstructionInfo
* This field is used to properly format relative instructions.
*/
uint64_t instrPointer;
} VXInstructionInfo;
} ZyDisInstructionInfo;
#ifdef __cplusplus
}
#endif
#endif /* _VDE_VXDISASSEMBLERTYPESC_H_ */
#endif /* _VDE_ZyDisDISASSEMBLERTYPESC_H_ */

View File

@ -30,11 +30,11 @@
**************************************************************************************************/
#include "VXDisassemblerUtils.h"
#include "ZyDisDisassemblerUtils.h"
#include <assert.h>
uint64_t VXCalcAbsoluteTarget(const VXInstructionInfo *info, const VXOperandInfo *operand)
uint64_t ZyDisCalcAbsoluteTarget(const ZyDisInstructionInfo *info, const ZyDisOperandInfo *operand)
{
assert((operand->type == OPTYPE_REL_IMMEDIATE) ||
((operand->type == OPTYPE_MEMORY) && (operand->base == REG_RIP)));

View File

@ -30,11 +30,11 @@
**************************************************************************************************/
#ifndef _VDE_VXDISASSEMBLERUTILSC_H_
#define _VDE_VXDISASSEMBLERUTILSC_H_
#ifndef _VDE_ZyDisDISASSEMBLERUTILSC_H_
#define _VDE_ZyDisDISASSEMBLERUTILSC_H_
#include "VXDisassemblerTypes.h"
#include "VXInternalConfig.h"
#include "ZyDisDisassemblerTypes.h"
#include "ZyDisInternalConfig.h"
#include <stdint.h>
@ -44,11 +44,11 @@ extern "C"
{
#endif
typedef struct _VXContextDescriptor
typedef struct _ZyDisContextDescriptor
{
uint8_t type;
void *ptr;
} VXContextDescriptor;
} ZyDisContextDescriptor;
/**
* @brief Calculates the absolute target address of a relative instruction operand.
@ -56,12 +56,12 @@ typedef struct _VXContextDescriptor
* @param operand The operand.
* @return The absolute target address.
*/
VX_EXPORT uint64_t VXCalcAbsoluteTarget(
const VXInstructionInfo *info,
const VXOperandInfo *operand);
ZYDIS_EXPORT uint64_t ZyDisCalcAbsoluteTarget(
const ZyDisInstructionInfo *info,
const ZyDisOperandInfo *operand);
#ifdef __cplusplus
}
#endif
#endif /* _VDE_VXDISASSEMBLERUTILSC_H_ */
#endif /* _VDE_ZyDisDISASSEMBLERUTILSC_H_ */

View File

@ -30,11 +30,11 @@
**************************************************************************************************/
#ifndef _VDE_VXINSTRUCTIONDECODERC_H_
#define _VDE_VXINSTRUCTIONDECODERC_H_
#ifndef _VDE_ZyDisINSTRUCTIONDECODERC_H_
#define _VDE_ZyDisINSTRUCTIONDECODERC_H_
#include "VXDisassemblerTypes.h"
#include "VXDisassemblerUtils.h"
#include "ZyDisDisassemblerTypes.h"
#include "ZyDisDisassemblerUtils.h"
#include <stdbool.h>
#include <stddef.h>
@ -44,24 +44,24 @@ extern "C"
{
#endif
/* VXBaseDataSource ============================================================================ */
/* ZyDisBaseDataSource ============================================================================ */
typedef struct _VXBaseDataSourceContext { VXContextDescriptor d; } VXBaseDataSourceContext;
typedef struct _ZyDisBaseDataSourceContext { ZyDisContextDescriptor d; } ZyDisBaseDataSourceContext;
typedef void(*VXBaseDataSource_DestructionCallback)(VXBaseDataSourceContext *ctx);
typedef uint8_t(*VXBaseDataSource_InputCallback)(VXBaseDataSourceContext *ctx);
typedef bool(*VXBaseDataSource_IsEndOfInputCallback)(const VXBaseDataSourceContext *ctx);
typedef uint64_t(*VXBaseDataSource_GetPositionCallback)(const VXBaseDataSourceContext *ctx);
typedef bool(*VXBaseDataSource_SetPositionCallback)(
VXBaseDataSourceContext *ctx, uint64_t position);
typedef void(*ZyDisBaseDataSource_DestructionCallback)(ZyDisBaseDataSourceContext *ctx);
typedef uint8_t(*ZyDisBaseDataSource_InputCallback)(ZyDisBaseDataSourceContext *ctx);
typedef bool(*ZyDisBaseDataSource_IsEndOfInputCallback)(const ZyDisBaseDataSourceContext *ctx);
typedef uint64_t(*ZyDisBaseDataSource_GetPositionCallback)(const ZyDisBaseDataSourceContext *ctx);
typedef bool(*ZyDisBaseDataSource_SetPositionCallback)(
ZyDisBaseDataSourceContext *ctx, uint64_t position);
/**
* @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);
ZYDIS_EXPORT void ZyDisBaseDataSource_Release(
ZyDisBaseDataSourceContext *ctx);
/**
* @brief Reads the next byte from the data source without altering the current input position
@ -72,9 +72,9 @@ VX_EXPORT void VXBaseDataSource_Release(
* 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);
ZYDIS_EXPORT uint8_t ZyDisBaseDataSource_InputPeek(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
/**
* @brief Reads the next byte from the data source.
@ -87,30 +87,30 @@ VX_EXPORT uint8_t VXBaseDataSource_InputPeek(
* 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);
ZYDIS_EXPORT uint8_t ZyDisBaseDataSource_InputNext8(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
/**
* @copydoc VXBaseDataSource_InputNext8
* @copydoc ZyDisBaseDataSource_InputNext8
*/
VX_EXPORT uint16_t VXBaseDataSource_InputNext16(
VXBaseDataSourceContext *ctx,
VXInstructionInfo *info);
ZYDIS_EXPORT uint16_t ZyDisBaseDataSource_InputNext16(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
/**
* @copydoc VXBaseDataSource_InputNext8
* @copydoc ZyDisBaseDataSource_InputNext8
*/
VX_EXPORT uint32_t VXBaseDataSource_InputNext32(
VXBaseDataSourceContext *ctx,
VXInstructionInfo *info);
ZYDIS_EXPORT uint32_t ZyDisBaseDataSource_InputNext32(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
/**
* @copydoc VXBaseDataSource_InputNext8
* @copydoc ZyDisBaseDataSource_InputNext8
*/
VX_EXPORT uint64_t VXBaseDataSource_InputNext64(
VXBaseDataSourceContext *ctx,
VXInstructionInfo *info);
ZYDIS_EXPORT uint64_t ZyDisBaseDataSource_InputNext64(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
/**
* @brief Returns the current input byte.
@ -119,24 +119,24 @@ VX_EXPORT uint64_t VXBaseDataSource_InputNext64(
* 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);
ZYDIS_EXPORT uint8_t ZyDisBaseDataSource_InputCurrent(
const ZyDisBaseDataSourceContext *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);
ZYDIS_EXPORT bool ZyDisBaseDataSource_IsEndOfInput(
const ZyDisBaseDataSourceContext *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);
ZYDIS_EXPORT uint64_t ZyDisBaseDataSource_GetPosition(
const ZyDisBaseDataSourceContext *ctx);
/**
* @brief Sets a new input position.
@ -144,24 +144,24 @@ VX_EXPORT uint64_t VXBaseDataSource_GetPosition(
* @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,
ZYDIS_EXPORT bool ZyDisBaseDataSource_SetPosition(
ZyDisBaseDataSourceContext *ctx,
uint64_t position);
/* VXMemoryDataSource ========================================================================== */
/* ZyDisMemoryDataSource ========================================================================== */
/**
* @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
* @see ZyDisBaseDataSource_Release
*/
VX_EXPORT VXBaseDataSourceContext* VXMemoryDataSource_Create(
ZYDIS_EXPORT ZyDisBaseDataSourceContext* ZyDisMemoryDataSource_Create(
const void* buffer,
size_t bufferLen);
/* VXCustomDataSource ========================================================================== */
/* ZyDisCustomDataSource ========================================================================== */
/**
* @brief Creates a custom daat source.
@ -173,52 +173,52 @@ VX_EXPORT VXBaseDataSourceContext* VXMemoryDataSource_Create(
* @param setPositionCb The callback setting the current input position.
* @param destructionCb The destruction callback. May be @c NULL.
* @return @c NULL if it fails, else a data source context.
* @see VXBaseDataSource_Release
* @see ZyDisBaseDataSource_Release
*/
VX_EXPORT VXBaseDataSourceContext* VXCustomDataSource_Create(
VXBaseDataSource_InputCallback inputPeekCb,
VXBaseDataSource_InputCallback inputNextCb,
VXBaseDataSource_IsEndOfInputCallback isEndOfInputCb,
VXBaseDataSource_GetPositionCallback getPositionCb,
VXBaseDataSource_SetPositionCallback setPositionCb,
VXBaseDataSource_DestructionCallback destructionCb);
ZYDIS_EXPORT ZyDisBaseDataSourceContext* ZyDisCustomDataSource_Create(
ZyDisBaseDataSource_InputCallback inputPeekCb,
ZyDisBaseDataSource_InputCallback inputNextCb,
ZyDisBaseDataSource_IsEndOfInputCallback isEndOfInputCb,
ZyDisBaseDataSource_GetPositionCallback getPositionCb,
ZyDisBaseDataSource_SetPositionCallback setPositionCb,
ZyDisBaseDataSource_DestructionCallback destructionCb);
/* Enums ======================================================================================= */
/**
* @brief Values that represent a disassembler mode.
*/
typedef enum _VXDisassemblerMode /* : uint8_t */
typedef enum _ZyDisDisassemblerMode /* : uint8_t */
{
DM_M16BIT,
DM_M32BIT,
DM_M64BIT
} VXDisassemblerMode;
} ZyDisDisassemblerMode;
/**
* @brief Values that represent an instruction-set vendor.
*/
typedef enum _VXInstructionSetVendor /* : uint8_t */
typedef enum _ZyDisInstructionSetVendor /* : uint8_t */
{
ISV_ANY,
ISV_INTEL,
ISV_AMD
} VXInstructionSetVendor;
} ZyDisInstructionSetVendor;
/* VXInstructionDecoder ======================================================================== */
/* ZyDisInstructionDecoder ======================================================================== */
typedef struct _VXInstructionDecoderContext
typedef struct _ZyDisInstructionDecoderContext
{
VXContextDescriptor d;
} VXInstructionDecoderContext;
ZyDisContextDescriptor d;
} ZyDisInstructionDecoderContext;
/**
* @brief Creates an instruction decoder.
* @return @c NULL if it fails, else an instruction decoder context.
* @see VXInstructionDecoder_Release
* @see ZyDisInstructionDecoder_Release
*/
// TODO: verify return value
VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_Create(void);
ZYDIS_EXPORT ZyDisInstructionDecoderContext* ZyDisInstructionDecoder_Create(void);
/**
* @brief Creates an instruction decoder.
@ -227,100 +227,100 @@ VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_Create(void);
* @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
* @see ZyDisInstructionDecoder_Release
*/
VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_CreateEx(
VXBaseDataSourceContext *input,
VXDisassemblerMode disassemblerMode,
VXInstructionSetVendor preferredVendor,
ZYDIS_EXPORT ZyDisInstructionDecoderContext* ZyDisInstructionDecoder_CreateEx(
ZyDisBaseDataSourceContext *input,
ZyDisDisassemblerMode disassemblerMode,
ZyDisInstructionSetVendor 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);
ZYDIS_EXPORT void ZyDisInstructionDecoder_Release(
ZyDisInstructionDecoderContext *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
* @param info The @c ZyDisInstructionInfo 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);
ZYDIS_EXPORT bool ZyDisInstructionDecoder_DecodeInstruction(
ZyDisInstructionDecoderContext *ctx,
ZyDisInstructionInfo *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);
ZYDIS_EXPORT ZyDisBaseDataSourceContext* ZyDisInstructionDecoder_GetDataSource(
const ZyDisInstructionDecoderContext *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);
ZYDIS_EXPORT void ZyDisInstructionDecoder_SetDataSource(
ZyDisInstructionDecoderContext *ctx,
ZyDisBaseDataSourceContext *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);
ZYDIS_EXPORT ZyDisDisassemblerMode ZyDisInstructionDecoder_GetDisassemblerMode(
const ZyDisInstructionDecoderContext *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);
ZYDIS_EXPORT void ZyDisInstructionDecoder_SetDisassemblerMode(
ZyDisInstructionDecoderContext *ctx,
ZyDisDisassemblerMode 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);
ZYDIS_EXPORT ZyDisInstructionSetVendor ZyDisInstructionDecoder_GetPreferredVendor(
const ZyDisInstructionDecoderContext *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);
ZYDIS_EXPORT void ZyDisInstructionDecoder_SetPreferredVendor(
ZyDisInstructionDecoderContext *ctx,
ZyDisInstructionSetVendor 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);
ZYDIS_EXPORT uint64_t ZyDisInstructionDecoder_GetInstructionPointer(
const ZyDisInstructionDecoderContext *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,
ZYDIS_EXPORT void ZyDisInstructionDecoder_SetInstructionPointer(
ZyDisInstructionDecoderContext *ctx,
uint64_t instructionPointer);
/* ============================================================================================= */
@ -329,4 +329,4 @@ VX_EXPORT void VXInstructionDecoder_SetInstructionPointer(
}
#endif
#endif /* _VDE_VXINSTRUCTIONDECODERC_H_ */
#endif /* _VDE_ZyDisINSTRUCTIONDECODERC_H_ */

View File

@ -30,31 +30,31 @@
**************************************************************************************************/
#ifndef _VDE_VXINSTRUCTIONFORMATTERC_H_
#define _VDE_VXINSTRUCTIONFORMATTERC_H_
#ifndef _VDE_ZyDisINSTRUCTIONFORMATTERC_H_
#define _VDE_ZyDisINSTRUCTIONFORMATTERC_H_
#include "VXDisassemblerTypes.h"
#include "VXDisassemblerUtils.h"
#include "ZyDisDisassemblerTypes.h"
#include "ZyDisDisassemblerUtils.h"
#ifdef __cplusplus
extern "C"
{
#endif
/* VXBaseSymbolResolver ======================================================================== */
/* ZyDisBaseSymbolResolver ======================================================================== */
typedef struct _VXBaseSymbolResolverContext
typedef struct _ZyDisBaseSymbolResolverContext
{
VXContextDescriptor d;
} VXBaseSymbolResolverContext;
ZyDisContextDescriptor d;
} ZyDisBaseSymbolResolverContext;
/**
* @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);
ZYDIS_EXPORT void ZyDisBaseSymbolResolver_Release(
ZyDisBaseSymbolResolverContext *ctx);
/**
* @brief Resolves a symbol.
@ -65,16 +65,16 @@ VX_EXPORT void VXBaseSymbolResolver_Release(
* 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,
ZYDIS_EXPORT const char* ZyDisBaseSymbolResolver_ResolveSymbol(
ZyDisBaseSymbolResolverContext *ctx,
const ZyDisInstructionInfo *info,
uint64_t address,
uint64_t *offset);
/* VXCustomSymbolResolver ====================================================================== */
/* ZyDisCustomSymbolResolver ====================================================================== */
typedef const char* (*VXCustomSymbolResolver_ResolveSymbolCallback)(
const VXInstructionInfo *info,
typedef const char* (*ZyDisCustomSymbolResolver_ResolveSymbolCallback)(
const ZyDisInstructionInfo *info,
uint64_t address,
uint64_t *offset,
void *userData);
@ -86,19 +86,19 @@ typedef const char* (*VXCustomSymbolResolver_ResolveSymbolCallback)(
* May also be @c NULL.
* @return @c NULL if it fails, else a symbol resolver context.
*/
VX_EXPORT VXBaseSymbolResolverContext* VXCustomSymbolResolver_Create(
VXCustomSymbolResolver_ResolveSymbolCallback resolverCb,
ZYDIS_EXPORT ZyDisBaseSymbolResolverContext* ZyDisCustomSymbolResolver_Create(
ZyDisCustomSymbolResolver_ResolveSymbolCallback resolverCb,
void *userData);
/* VXBaseInstructionFormatter ================================================================== */
/* ZyDisBaseInstructionFormatter ================================================================== */
typedef struct _VXBaseInstructionFormatterContext
typedef struct _ZyDisBaseInstructionFormatterContext
{
VXContextDescriptor d;
} VXBaseInstructionFormatterContext;
ZyDisContextDescriptor d;
} ZyDisBaseInstructionFormatterContext;
typedef void(*VXBaseInstructionFormatter_InternalFormatInstructionCallback)(
VXBaseInstructionFormatterContext *ctx, const VXInstructionInfo *info);
typedef void(*ZyDisBaseInstructionFormatter_InternalFormatInstructionCallback)(
ZyDisBaseInstructionFormatterContext *ctx, const ZyDisInstructionInfo *info);
/**
* @brief Formats a decoded instruction.
@ -107,17 +107,17 @@ typedef void(*VXBaseInstructionFormatter_InternalFormatInstructionCallback)(
* @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);
ZYDIS_EXPORT const char* ZyDisBaseInstructionFormatter_FormatInstruction(
ZyDisBaseInstructionFormatterContext *ctx,
const ZyDisInstructionInfo *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);
ZYDIS_EXPORT ZyDisBaseSymbolResolverContext* ZyDisBaseInstructionFormatter_GetSymbolResolver(
const ZyDisBaseInstructionFormatterContext *ctx);
/**
* @brief Sets a new symbol resolver.
@ -125,45 +125,45 @@ VX_EXPORT VXBaseSymbolResolverContext* VXBaseInstructionFormatter_GetSymbolResol
* @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);
ZYDIS_EXPORT void ZyDisBaseInstructionFormatter_SetSymbolResolver(
ZyDisBaseInstructionFormatterContext *ctx,
ZyDisBaseSymbolResolverContext *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);
ZYDIS_EXPORT void ZyDisBaseInstructionFormatter_Release(
ZyDisBaseInstructionFormatterContext *ctx);
/* VXIntelInstructionFormatter ================================================================= */
/* ZyDisIntelInstructionFormatter ================================================================= */
/**
* @brief Creates an Intel-syntax instruction formatter.
* @return @c NULL if it fails, else an Intel instruction formatter context.
* @see VXBaseInstructionFormatter_Release
* @see ZyDisBaseInstructionFormatter_Release
*/
VX_EXPORT VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_Create(void);
ZYDIS_EXPORT ZyDisBaseInstructionFormatterContext* ZyDisIntelInstructionFormatter_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
* @see ZyDisBaseInstructionFormatter_Release
*/
VX_EXPORT VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_CreateEx(
VXBaseSymbolResolverContext *resolver);
ZYDIS_EXPORT ZyDisBaseInstructionFormatterContext* ZyDisIntelInstructionFormatter_CreateEx(
ZyDisBaseSymbolResolverContext *resolver);
/* VXCustomInstructionFormatter ================================================================ */
/* ZyDisCustomInstructionFormatter ================================================================ */
/**
* @brief Creats a custom instruction formatter.
* @param formatInsnCb The callback formatting the instruction.
* @return @c NULL if it fails, else a custom instruction formatter context.
*/
VX_EXPORT VXBaseInstructionFormatterContext* VXCustomInstructionFormatter_Create(
VXBaseInstructionFormatter_InternalFormatInstructionCallback formatInsnCb);
ZYDIS_EXPORT ZyDisBaseInstructionFormatterContext* ZyDisCustomInstructionFormatter_Create(
ZyDisBaseInstructionFormatter_InternalFormatInstructionCallback formatInsnCb);
/* ============================================================================================= */
@ -171,4 +171,4 @@ VX_EXPORT VXBaseInstructionFormatterContext* VXCustomInstructionFormatter_Create
}
#endif
#endif /* _VDE_VXINSTRUCTIONFORMATTERC_H_ */
#endif /* _VDE_ZyDisINSTRUCTIONFORMATTERC_H_ */

View File

@ -34,17 +34,17 @@
* Include CMake generated header defining macros im-/exporting functions statically or
* dynamically depending what the user requested from CMake.
*/
#include "VXExportConfig.h"
#include "ZyDisExportConfig.h"
#ifndef _VDE_VXINTERNALCONFIG_H_
#define _VDE_VXINTERNALCONFIG_H_
#ifndef _VDE_ZyDisINTERNALCONFIG_H_
#define _VDE_ZyDisINTERNALCONFIG_H_
#ifdef _MSC_VER
# define VX_INLINE __inline
# define ZYDIS_INLINE __inline
#else
# define VX_INLINE static inline
# define ZYDIS_INLINE static inline
#endif
#define VX_UNUSED(x) ((void)x)
#define ZYDIS_UNUSED(x) ((void)x)
#endif /* _VDE_VXINTERNALCONFIG_H_ */
#endif /* _VDE_ZyDisINTERNALCONFIG_H_ */

View File

@ -0,0 +1,197 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : athre0z
Modifications :
Last change : 19. 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_ZyDisINTERNALHELPERS_H_
#define _VDE_ZyDisINTERNALHELPERS_H_
#include "ZyDisInstructionDecoder.h"
#include "ZyDisInstructionFormatter.h"
#include "ZyDisInternalConfig.h"
#include <assert.h>
/* Types IDs =================================================================================== */
typedef enum _ZyDisTypeId
{
TYPE_BASEDATASOURCE,
TYPE_MEMORYDATASOURCE,
TYPE_CUSTOMDATASOURCE,
TYPE_INSTRUCTIONDECODER,
TYPE_BASESYMBOLRESOLVER,
TYPE_CUSTOMSYMBOLRESOLVER,
TYPE_BASEINSTRUCTIONFORMATTER,
TYPE_INTELINSTRUCTIONFORMATTER,
TYPE_CUSTOMINSTRUCTIONFORMATTER,
} ZyDisTypeId;
/* Context conversion helpers ================================================================== */
ZYDIS_INLINE struct _ZyDisBaseDataSource* ZyDisBaseDataSource_thiz(
ZyDisBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_BASEDATASOURCE
|| ctx->d.type == TYPE_MEMORYDATASOURCE
|| ctx->d.type == TYPE_CUSTOMDATASOURCE);
return (struct _ZyDisBaseDataSource*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisBaseDataSource* ZyDisBaseDataSource_cthiz(
const ZyDisBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_BASEDATASOURCE
|| ctx->d.type == TYPE_MEMORYDATASOURCE
|| ctx->d.type == TYPE_CUSTOMDATASOURCE);
return (const struct _ZyDisBaseDataSource*)ctx->d.ptr;
}
ZYDIS_INLINE struct _ZyDisMemoryDataSource* ZyDisMemoryDataSource_thiz(
ZyDisBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_MEMORYDATASOURCE);
return (struct _ZyDisMemoryDataSource*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisMemoryDataSource* ZyDisMemoryDataSource_cthiz(
const ZyDisBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_MEMORYDATASOURCE);
return (const struct _ZyDisMemoryDataSource*)ctx->d.ptr;
}
ZYDIS_INLINE struct _ZyDisCustomDataSource* ZyDisCustomDataSource_thiz(
ZyDisBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMDATASOURCE);
return (struct _ZyDisCustomDataSource*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisCustomDataSource* ZyDisCustomDataSource_cthiz(
const ZyDisBaseDataSourceContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMDATASOURCE);
return (const struct _ZyDisCustomDataSource*)ctx->d.ptr;
}
ZYDIS_INLINE struct _ZyDisInstructionDecoder* ZyDisInstructionDecoder_thiz(
ZyDisInstructionDecoderContext *ctx)
{
assert(ctx->d.type == TYPE_INSTRUCTIONDECODER);
return (struct _ZyDisInstructionDecoder*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisInstructionDecoder* ZyDisInstructionDecoder_cthiz(
const ZyDisInstructionDecoderContext *ctx)
{
assert(ctx->d.type == TYPE_INSTRUCTIONDECODER);
return (const struct _ZyDisInstructionDecoder*)ctx->d.ptr;
}
ZYDIS_INLINE struct _ZyDisBaseSymbolResolver* ZyDisBaseSymbolResolver_thiz(
ZyDisBaseSymbolResolverContext *ctx)
{
assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER
|| ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (struct _ZyDisBaseSymbolResolver*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisBaseSymbolResolver* ZyDisBaseSymbolResolver_cthiz(
const ZyDisBaseSymbolResolverContext *ctx)
{
assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER
|| ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (const struct _ZyDisBaseSymbolResolver*)ctx->d.ptr;
}
ZYDIS_INLINE struct _ZyDisCustomSymbolResolver* ZyDisCustomSymbolResolver_thiz(
ZyDisBaseSymbolResolverContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (struct _ZyDisCustomSymbolResolver*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisCustomSymbolResolver* ZyDisCustomSymbolResolver_cthiz(
const ZyDisBaseSymbolResolverContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (const struct _ZyDisCustomSymbolResolver*)ctx->d.ptr;
}
ZYDIS_INLINE struct _ZyDisBaseInstructionFormatter* ZyDisBaseInstructionFormatter_thiz(
ZyDisBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER
|| ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER
|| ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
return (struct _ZyDisBaseInstructionFormatter*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisBaseInstructionFormatter* ZyDisBaseInstructionFormatter_cthiz(
const ZyDisBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER
|| ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER
|| ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
return (const struct _ZyDisBaseInstructionFormatter*)ctx->d.ptr;
}
ZYDIS_INLINE struct _ZyDisIntelInstructionFormatter* ZyDisIntelInstructionFormatter_thiz(
ZyDisBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER);
return (struct _ZyDisIntelInstructionFormatter*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisIntelInstructionFormatter* ZyDisIntelInstructionFormatter_cthiz(
const ZyDisBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER);
return (const struct _ZyDisIntelInstructionFormatter*)ctx->d.ptr;
}
ZYDIS_INLINE struct _ZyDisCustomInstructionFormatter* ZyDisCustomInstructionFormatter_thiz(
ZyDisBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
return (struct _ZyDisCustomInstructionFormatter*)ctx->d.ptr;
}
ZYDIS_INLINE const struct _ZyDisCustomInstructionFormatter* ZyDisCustomInstructionFormatter_cthiz(
const ZyDisBaseInstructionFormatterContext *ctx)
{
assert(ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
return (struct _ZyDisCustomInstructionFormatter*)ctx->d.ptr;
}
/* ============================================================================================= */
#endif /* _VDE_ZyDisINTERNALHELPERS_H_ */

View File

@ -30,8 +30,8 @@
**************************************************************************************************/
#ifndef _VDE_VXOPCODETABLEC_H_
#define _VDE_VXOPCODETABLEC_H_
#ifndef _VDE_ZyDisOPCODETABLEC_H_
#define _VDE_ZyDisOPCODETABLEC_H_
#include <stdint.h>
#include <assert.h>
@ -44,7 +44,7 @@ extern "C"
/**
* @brief Values that represent an instruction mnemonic.
*/
typedef enum _VXInstructionMnemonic /* : uint16_t */
typedef enum _ZyDisInstructionMnemonic /* : uint16_t */
{
/* 000 */ MNEM_INVALID,
/* 001 */ MNEM_AAA,
@ -926,8 +926,8 @@ typedef enum _VXInstructionMnemonic /* : uint16_t */
/* 36D */ MNEM_VUNPCKHPS,
/* 36E */ MNEM_VUNPCKLPD,
/* 36F */ MNEM_VUNPCKLPS,
/* 370 */ MNEM_VXORPD,
/* 371 */ MNEM_VXORPS,
/* 370 */ MNEM_ZyDisORPD,
/* 371 */ MNEM_ZyDisORPS,
/* 372 */ MNEM_VZEROALL,
/* 373 */ MNEM_VZEROUPPER,
/* 374 */ MNEM_WAIT,
@ -953,18 +953,18 @@ typedef enum _VXInstructionMnemonic /* : uint16_t */
/* 388 */ MNEM_XSTORE,
MNEM_FORCE_WORD = 0x7FFF
} VXInstructionMnemonic;
} ZyDisInstructionMnemonic;
/**
* @brief Defines an alias representing an opcode tree node. An opcode tree node is a 16 bit
* unsigned integer value with its first 4 bits reserved for the node type.
*/
typedef uint16_t VXOpcodeTreeNode;
typedef uint16_t ZyDisOpcodeTreeNode;
/**
* @brief Values that represent the type of an opcode tree node.
*/
typedef enum _VXOpcodeTreeNodeType /* : uint8_t */
typedef enum _ZyDisOpcodeTreeNodeType /* : uint8_t */
{
/**
* @brief Reference to a concrete instruction definition.
@ -1026,12 +1026,12 @@ typedef enum _VXOpcodeTreeNodeType /* : uint8_t */
* @brief Reference to a vex_l switch table.
*/
OTNT_VEXL = 14
} VXOpcodeTreeNodeType;
} ZyDisOpcodeTreeNodeType;
/**
* @brief Values that represent the type of an operand in the instruction definition.
*/
typedef enum _VXDefinedOperandType /* : uint8_t */
typedef enum _ZyDisDefinedOperandType /* : uint8_t */
{
/*
* @brief No operand.
@ -1286,13 +1286,13 @@ typedef enum _VXDefinedOperandType /* : uint8_t */
* @brief Floating point register 7.
*/
DOT_ST7
} VXDefinedOperandType;
} ZyDisDefinedOperandType;
/**
* @brief Values that represent the size of an operand in the instruction definition.
* Do not change the order or the values of this enum!
*/
typedef enum _VXDefinedOperandSize /* : uint8_t */
typedef enum _ZyDisDefinedOperandSize /* : uint8_t */
{
/**
* @brief No operand.
@ -1386,13 +1386,13 @@ typedef enum _VXDefinedOperandSize /* : uint8_t */
* @brief Q sized register or O sized memory operand.
*/
DOS_QO = (DOS_Q << 4) | DOS_O,
} VXDefinedOperandSize;
} ZyDisDefinedOperandSize;
/**
* @brief Values that represent optional flags in the instruction definition.
* Do not change the order or the values of this enum!
*/
typedef enum _VXInstructionDefinitionFlags /* : uint16_t */
typedef enum _ZyDisInstructionDefinitionFlags /* : uint16_t */
{
/**
* @brief The instruction accepts the rex.b prefix value.
@ -1456,49 +1456,49 @@ typedef enum _VXInstructionDefinitionFlags /* : uint16_t */
IDF_OPERAND2_READWRITE = 0x4000,
IDF_FORCE_WORD = 0x7FFF
} VXInstructionDefinitionFlags;
} ZyDisInstructionDefinitionFlags;
#pragma pack (push, 1)
/**
* @brief An operand definition.
*/
typedef struct _VXOperandDefinition
typedef struct _ZyDisOperandDefinition
{
/**
* @brief The defined operand type.
* @see VXDefinedOperandType
* @see ZyDisDefinedOperandType
*/
uint8_t type;
/**
* @brief The defined operand size.
* @see VXDefinedOperandType
* @see ZyDisDefinedOperandType
*/
uint8_t size;
} VXOperandDefinition;
} ZyDisOperandDefinition;
/**
* @brief An instruction definition.
*/
typedef struct _VXInstructionDefinition
typedef struct _ZyDisInstructionDefinition
{
/**
* @brief The instruction mnemonic.
* @see VXInstructionMnemonic
* @see ZyDisInstructionMnemonic
*/
uint16_t mnemonic;
/**
* @brief The operand definitions for all four possible operands.
*/
VXOperandDefinition operand[4];
ZyDisOperandDefinition operand[4];
/**
* @brief Additional flags for the instruction definition.
*/
uint16_t flags;
} VXInstructionDefinition;
} ZyDisInstructionDefinition;
#pragma pack (pop)
#ifdef __cplusplus
}
#endif
#endif // _VDE_VXOPCODETABLEC_H_
#endif // _VDE_ZyDisOPCODETABLEC_H_

View File

@ -30,17 +30,17 @@
**************************************************************************************************/
#ifndef _VDE_VXOPCODETABLEINTERNAL_H_
#define _VDE_VXOPCODETABLEINTERNAL_H_
#ifndef _VDE_ZyDisOPCODETABLEINTERNAL_H_
#define _VDE_ZyDisOPCODETABLEINTERNAL_H_
#include <stdint.h>
#include "VXOpcodeTable.h"
#include "ZyDisOpcodeTable.h"
/**
* @brief Contains all opcode tables.
* Indexed by the numeric value of the opcode.
*/
extern const VXOpcodeTreeNode vxOptreeTable[][256];
extern const ZyDisOpcodeTreeNode vxOptreeTable[][256];
/**
* @brief Contains all modrm_mod switch tables.
@ -48,19 +48,19 @@ extern const VXOpcodeTreeNode vxOptreeTable[][256];
* 0 = [modrm_mod == !11]
* 1 = [modrm_mod == 11]
*/
extern const VXOpcodeTreeNode vxOptreeModrmMod[][2];
extern const ZyDisOpcodeTreeNode vxOptreeModrmMod[][2];
/**
* @brief Contains all modrm_reg switch tables.
* Indexed by the numeric value of the modrm_reg field.
*/
extern const VXOpcodeTreeNode vxOptreeModrmReg[][8];
extern const ZyDisOpcodeTreeNode vxOptreeModrmReg[][8];
/**
* @brief Contains all modrm_rm switch tables.
* Indexed by the numeric value of the modrm_rm field.
*/
extern const VXOpcodeTreeNode vxOptreeModrmRm[][8];
extern const ZyDisOpcodeTreeNode vxOptreeModrmRm[][8];
/**
* @brief Contains all mandatory-prefix switch tables.
@ -70,14 +70,14 @@ extern const VXOpcodeTreeNode vxOptreeModrmRm[][8];
* 2 = F3
* 3 = 66
*/
extern const VXOpcodeTreeNode vxOptreeMandatory[][4];
extern const ZyDisOpcodeTreeNode vxOptreeMandatory[][4];
/**
* @brief Contains all x87 opcode tables.
* Indexed by the numeric value of the 6 lowest bits of the modrm byte (modrm_mod should
* always be 11).
*/
extern const VXOpcodeTreeNode vxOptreeX87[][64];
extern const ZyDisOpcodeTreeNode vxOptreeX87[][64];
/**
* @brief Contains all address-size switch tables.
@ -86,7 +86,7 @@ extern const VXOpcodeTreeNode vxOptreeX87[][64];
* 1 = 32
* 2 = 64
*/
extern const VXOpcodeTreeNode vxOptreeAddressSize[][3];
extern const ZyDisOpcodeTreeNode vxOptreeAddressSize[][3];
/**
* @brief Contains all operand-size switch tables.
@ -95,7 +95,7 @@ extern const VXOpcodeTreeNode vxOptreeAddressSize[][3];
* 1 = 32
* 2 = 64
*/
extern const VXOpcodeTreeNode vxOptreeOperandSize[][3];
extern const ZyDisOpcodeTreeNode vxOptreeOperandSize[][3];
/**
* @brief Contains all cpu-mode switch tables.
@ -103,7 +103,7 @@ extern const VXOpcodeTreeNode vxOptreeOperandSize[][3];
* 0 = [!= 64]
* 1 = 64
*/
extern const VXOpcodeTreeNode vxOptreeMode[][2];
extern const ZyDisOpcodeTreeNode vxOptreeMode[][2];
/**
* @brief Contains all vendor switch tables.
@ -111,13 +111,13 @@ extern const VXOpcodeTreeNode vxOptreeMode[][2];
* 0 = AMD
* 1 = Intel
*/
extern const VXOpcodeTreeNode vxOptreeVendor[][2];
extern const ZyDisOpcodeTreeNode vxOptreeVendor[][2];
/**
* @brief Contains all 3DNow! switch tables.
* Indexed by the numeric value of the 3DNow! opcode.
*/
extern const VXOpcodeTreeNode vxOptree3dnow[][256];
extern const ZyDisOpcodeTreeNode vxOptree3dnow[][256];
/**
* @brief Contains all vex switch tables.
@ -139,24 +139,24 @@ extern const VXOpcodeTreeNode vxOptree3dnow[][256];
* E = F2_0F38
* F = F2_0F3A
*/
extern const VXOpcodeTreeNode vxOptreeVex[][16];
extern const ZyDisOpcodeTreeNode vxOptreeVex[][16];
/**
* @brief Contains all vex_w switch tables.
* Indexed by the numeric value of the vex_w field.
*/
extern const VXOpcodeTreeNode vxOptreeVexW[][2];
extern const ZyDisOpcodeTreeNode vxOptreeVexW[][2];
/**
* @brief Contains all vex_l switch tables.
* Indexed by the numeric value of the vex_l field.
*/
extern const VXOpcodeTreeNode vxOptreeVexL[][2];
extern const ZyDisOpcodeTreeNode vxOptreeVexL[][2];
/**
* @brief Contains all instruction definitions.
*/
extern const VXInstructionDefinition vxInstrDefinitions[];
extern const ZyDisInstructionDefinition vxInstrDefinitions[];
/**
* @brief Contains all instruction mnemonic strings.
@ -168,9 +168,9 @@ extern const char* vxInstrMnemonicStrings[];
* @param node The node.
* @return The type of the specified opcode tree node.
*/
VX_INLINE VXOpcodeTreeNodeType VXGetOpcodeNodeType(VXOpcodeTreeNode node)
ZYDIS_INLINE ZyDisOpcodeTreeNodeType ZyDisGetOpcodeNodeType(ZyDisOpcodeTreeNode node)
{
return (VXOpcodeTreeNodeType)((node >> 12) & 0x0F);
return (ZyDisOpcodeTreeNodeType)((node >> 12) & 0x0F);
}
/**
@ -178,7 +178,7 @@ VX_INLINE VXOpcodeTreeNodeType VXGetOpcodeNodeType(VXOpcodeTreeNode node)
* @param node The node.
* @return The value of the specified opcode tree node.
*/
VX_INLINE uint16_t VXGetOpcodeNodeValue(VXOpcodeTreeNode node)
ZYDIS_INLINE uint16_t ZyDisGetOpcodeNodeValue(ZyDisOpcodeTreeNode node)
{
return (node & 0x0FFF);
}
@ -187,7 +187,7 @@ VX_INLINE uint16_t VXGetOpcodeNodeValue(VXOpcodeTreeNode node)
* @brief Returns the root node of the opcode tree.
* @return The root node of the opcode tree.
*/
VX_INLINE VXOpcodeTreeNode VXGetOpcodeTreeRoot()
ZYDIS_INLINE ZyDisOpcodeTreeNode ZyDisGetOpcodeTreeRoot()
{
return 0x1000;
}
@ -198,10 +198,10 @@ VX_INLINE VXOpcodeTreeNode VXGetOpcodeTreeRoot()
* @param index The index of the child node to retrieve.
* @return The specified child node.
*/
VX_INLINE VXOpcodeTreeNode VXGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_t index)
ZYDIS_INLINE ZyDisOpcodeTreeNode ZyDisGetOpcodeTreeChild(ZyDisOpcodeTreeNode parent, uint16_t index)
{
VXOpcodeTreeNodeType nodeType = VXGetOpcodeNodeType(parent);
uint16_t tableIndex = VXGetOpcodeNodeValue(parent);
ZyDisOpcodeTreeNodeType nodeType = ZyDisGetOpcodeNodeType(parent);
uint16_t tableIndex = ZyDisGetOpcodeNodeValue(parent);
switch (nodeType)
{
case OTNT_TABLE:
@ -257,9 +257,9 @@ VX_INLINE VXOpcodeTreeNode VXGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_
* @param node The instruction definition node.
* @return Pointer to the instruction definition.
*/
VX_INLINE const VXInstructionDefinition* VXGetInstructionDefinition(VXOpcodeTreeNode node)
ZYDIS_INLINE const ZyDisInstructionDefinition* ZyDisGetInstructionDefinition(ZyDisOpcodeTreeNode node)
{
assert(VXGetOpcodeNodeType(node) == OTNT_INSTRUCTION_DEFINITION);
assert(ZyDisGetOpcodeNodeType(node) == OTNT_INSTRUCTION_DEFINITION);
return &vxInstrDefinitions[node & 0x0FFF];
}
@ -268,7 +268,7 @@ VX_INLINE const VXInstructionDefinition* VXGetInstructionDefinition(VXOpcodeTree
* @param mnemonic The mnemonic.
* @return The instruction mnemonic string.
*/
VX_INLINE const char* VXGetInstructionMnemonicString(VXInstructionMnemonic mnemonic)
ZYDIS_INLINE const char* ZyDisGetInstructionMnemonicString(ZyDisInstructionMnemonic mnemonic)
{
return vxInstrMnemonicStrings[(uint16_t)mnemonic];
}
@ -278,7 +278,7 @@ VX_INLINE const char* VXGetInstructionMnemonicString(VXInstructionMnemonic mnemo
* @param operandSize The defined operand size.
* @return The the numeric value for the simple operand size definition.
*/
VX_INLINE uint16_t VXGetSimpleOperandSize(VXDefinedOperandSize operandSize)
ZYDIS_INLINE uint16_t ZyDisGetSimpleOperandSize(ZyDisDefinedOperandSize operandSize)
{
static const uint16_t operandSizes[8] =
{
@ -295,9 +295,9 @@ VX_INLINE uint16_t VXGetSimpleOperandSize(VXDefinedOperandSize operandSize)
* @param operandSize The defined operand size.
* @return The memory-size part of the operand size definition.
*/
VX_INLINE VXDefinedOperandSize VXGetComplexOperandMemSize(VXDefinedOperandSize operandSize)
ZYDIS_INLINE ZyDisDefinedOperandSize ZyDisGetComplexOperandMemSize(ZyDisDefinedOperandSize operandSize)
{
return (VXDefinedOperandSize)(operandSize & 0x0F);
return (ZyDisDefinedOperandSize)(operandSize & 0x0F);
}
/**
@ -305,9 +305,9 @@ VX_INLINE VXDefinedOperandSize VXGetComplexOperandMemSize(VXDefinedOperandSize o
* @param operandSize The defined operand size.
* @return The register-size part of the operand size definition.
*/
VX_INLINE VXDefinedOperandSize VXGetComplexOperandRegSize(VXDefinedOperandSize operandSize)
ZYDIS_INLINE ZyDisDefinedOperandSize ZyDisGetComplexOperandRegSize(ZyDisDefinedOperandSize operandSize)
{
return (VXDefinedOperandSize)((operandSize >> 4) & 0x0F);
return (ZyDisDefinedOperandSize)((operandSize >> 4) & 0x0F);
}
#endif // _VDE_VXOPCODETABLEINTERNAL_H_
#endif // _VDE_ZyDisOPCODETABLEINTERNAL_H_