Project name changed and C-Bindings reverted

* Changed project name to Zydis
  * Removed Zydis (former VX) prefix from classes and enums
  * Renamed Verteron namespace to Zydis
* Reverted C-Bindings back to the old solution
  * C-Bindings are now based on the C++ source again (and not the other way around)
This commit is contained in:
flobernd 2015-05-16 05:05:17 +02:00
parent de31261273
commit 4676a8b2d7
41 changed files with 12863 additions and 26570 deletions

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 19. March 2015
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,14 +26,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
***************************************************************************************************/
#include <ZyDisDisassembler.h>
#ifndef _ZYDIS_DISASSEMBLER_H_
#define _ZYDIS_DISASSEMBLER_H_
int main(int argc, char* argv[])
{
ZYDIS_UNUSED(argc); ZYDIS_UNUSED(argv);
#include "ZydisTypes.h"
#include "ZydisInstructionDecoder.h"
#include "ZydisInstructionFormatter.h"
#include "ZydisSymbolResolver.h"
#include "ZydisUtils.h"
// TODO:
return 0;
}
#endif /* _ZYDIS_DISASSEMBLER_H_ */

View File

@ -0,0 +1,259 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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.
***************************************************************************************************/
#include "ZydisInstructionDecoder.h"
#include "ZydisInstructionDecoder.hpp"
#include "ZydisTypes.hpp"
/* Helpers ===================================================================================== */
namespace
{
inline Zydis::BaseInput* ZydisBaseInput_CppPtr(
ZydisBaseInputContext *ctx)
{
return reinterpret_cast<Zydis::BaseInput*>(ctx);
}
inline const Zydis::BaseInput* ZydisBaseInput_CppPtr(
const ZydisBaseInputContext *ctx)
{
return reinterpret_cast<const Zydis::BaseInput*>(ctx);
}
inline ZydisBaseInputContext* ZydisBaseInput_CPtr(
Zydis::BaseInput *ptr)
{
return reinterpret_cast<ZydisBaseInputContext*>(ptr);
}
inline const ZydisBaseInputContext* ZydisBaseInput_CPtr(
const Zydis::BaseInput *ptr)
{
return reinterpret_cast<const ZydisBaseInputContext*>(ptr);
}
inline Zydis::InstructionInfo* ZydisInstructionInfo_CppPtr(
ZydisInstructionInfo *ptr)
{
static_assert(sizeof(*ptr) == sizeof(Zydis::InstructionInfo), "broken struct");
return reinterpret_cast<Zydis::InstructionInfo*>(ptr);
}
inline const Zydis::InstructionInfo* ZydisInstructionInfo_CppPtr(
const ZydisInstructionInfo *ptr)
{
static_assert(sizeof(*ptr) == sizeof(Zydis::InstructionInfo), "broken struct");
return reinterpret_cast<const Zydis::InstructionInfo*>(ptr);
}
inline ZydisInstructionDecoderContext* ZydisInstructionDecoder_CPtr(
Zydis::InstructionDecoder *ptr)
{
return reinterpret_cast<ZydisInstructionDecoderContext*>(ptr);
}
inline const ZydisInstructionDecoderContext* ZydisInstructionDecoder_CPtr(
const Zydis::InstructionDecoder *ptr)
{
return reinterpret_cast<const ZydisInstructionDecoderContext*>(ptr);
}
inline Zydis::InstructionDecoder* ZydisInstructionDecoder_CppPtr(
ZydisInstructionDecoderContext *ctx)
{
return reinterpret_cast<Zydis::InstructionDecoder*>(ctx);
}
inline const Zydis::InstructionDecoder* ZydisInstructionDecoder_CppPtr(
const ZydisInstructionDecoderContext *ctx)
{
return reinterpret_cast<const Zydis::InstructionDecoder*>(ctx);
}
inline Zydis::DisassemblerMode ZydisDisassemblerMode_CppRepr(
ZydisDisassemblerMode val)
{
return static_cast<Zydis::DisassemblerMode>(val);
}
inline ZydisDisassemblerMode ZydisDisassemblerMode_CRepr(
Zydis::DisassemblerMode val)
{
return static_cast<ZydisDisassemblerMode>(val);
}
inline Zydis::InstructionSetVendor ZydisInstructionSetVendor_CppRepr(
ZydisInstructionSetVendor val)
{
return static_cast<Zydis::InstructionSetVendor>(val);
}
inline ZydisInstructionSetVendor ZydisInstructionSetVendor_CRepr(
Zydis::InstructionSetVendor val)
{
return static_cast<ZydisInstructionSetVendor>(val);
}
}
/* BaseInput ============================================================================ */
void ZydisBaseInput_Release(ZydisBaseInputContext *ctx)
{
delete ZydisBaseInput_CppPtr(ctx);
}
uint8_t ZydisBaseInput_InputPeek(ZydisBaseInputContext *ctx, ZydisInstructionInfo *info)
{
return ZydisBaseInput_CppPtr(ctx)->inputPeek(*ZydisInstructionInfo_CppPtr(info));
}
uint8_t ZydisBaseInput_InputNext(ZydisBaseInputContext *ctx, ZydisInstructionInfo *info)
{
return ZydisBaseInput_CppPtr(ctx)->inputNext(*ZydisInstructionInfo_CppPtr(info));
}
uint8_t ZydisBaseInput_InputCurrent(const ZydisBaseInputContext *ctx)
{
return ZydisBaseInput_CppPtr(ctx)->inputCurrent();
}
bool ZydisBaseInput_IsEndOfInput(const ZydisBaseInputContext *ctx)
{
return ZydisBaseInput_CppPtr(ctx)->isEndOfInput();
}
uint64_t ZydisBaseInput_GetPosition(const ZydisBaseInputContext *ctx)
{
return ZydisBaseInput_CppPtr(ctx)->getPosition();
}
bool ZydisBaseInput_SetPosition(ZydisBaseInputContext *ctx, uint64_t position)
{
return ZydisBaseInput_CppPtr(ctx)->setPosition(position);
}
/* MemoryInput ========================================================================== */
ZydisBaseInputContext* ZydisMemoryInput_Create(const void* buffer, size_t bufferLen)
{
return reinterpret_cast<ZydisBaseInputContext*>(
new Zydis::MemoryInput(buffer, bufferLen));
}
/* InstructionDecoder ======================================================================== */
ZydisInstructionDecoderContext* ZydisInstructionDecoder_Create()
{
return reinterpret_cast<ZydisInstructionDecoderContext*>(new Zydis::InstructionDecoder);
}
ZydisInstructionDecoderContext* ZydisInstructionDecoder_CreateEx(
ZydisBaseInputContext *input,
ZydisDisassemblerMode disassemblerMode,
ZydisInstructionSetVendor preferredVendor,
uint64_t instructionPointer)
{
return ZydisInstructionDecoder_CPtr(new Zydis::InstructionDecoder(
ZydisBaseInput_CppPtr(input),
ZydisDisassemblerMode_CppRepr(disassemblerMode),
ZydisInstructionSetVendor_CppRepr(preferredVendor),
instructionPointer));
}
void ZydisInstructionDecoder_Release(ZydisInstructionDecoderContext *ctx)
{
delete ZydisInstructionDecoder_CppPtr(ctx);
}
bool ZydisInstructionDecoder_DecodeInstruction(
ZydisInstructionDecoderContext *ctx, ZydisInstructionInfo *info)
{
return ZydisInstructionDecoder_CppPtr(ctx)->decodeInstruction(
*ZydisInstructionInfo_CppPtr(info));
}
ZydisBaseInputContext* ZydisInstructionDecoder_GetDataSource(
const ZydisInstructionDecoderContext *ctx)
{
return ZydisBaseInput_CPtr(ZydisInstructionDecoder_CppPtr(ctx)->getDataSource());
}
void ZydisInstructionDecoder_SetDataSource(
ZydisInstructionDecoderContext *ctx, ZydisBaseInputContext *input)
{
ZydisInstructionDecoder_CppPtr(ctx)->setDataSource(ZydisBaseInput_CppPtr(input));
}
ZydisDisassemblerMode ZydisInstructionDecoder_GetDisassemblerMode(
ZydisInstructionDecoderContext *ctx)
{
return ZydisDisassemblerMode_CRepr(ZydisInstructionDecoder_CppPtr(ctx)->getDisassemblerMode());
}
void ZydisInstructionDecoder_SetDisassemblerMode(
ZydisInstructionDecoderContext *ctx,
ZydisDisassemblerMode disassemblerMode)
{
ZydisInstructionDecoder_CppPtr(ctx)->setDisassemblerMode(
ZydisDisassemblerMode_CppRepr(disassemblerMode));
}
ZydisInstructionSetVendor ZydisInstructionDecoder_GetPreferredVendor(
const ZydisInstructionDecoderContext *ctx)
{
return ZydisInstructionSetVendor_CRepr(
ZydisInstructionDecoder_CppPtr(ctx)->getPreferredVendor());
}
void ZydisInstructionDecoder_SetPreferredVendor(
ZydisInstructionDecoderContext *ctx,
ZydisInstructionSetVendor preferredVendor)
{
return ZydisInstructionDecoder_CppPtr(ctx)->setPreferredVendor(
ZydisInstructionSetVendor_CppRepr(preferredVendor));
}
uint64_t ZydisInstructionDecoder_GetInstructionPointer(
ZydisInstructionDecoderContext *ctx)
{
return ZydisInstructionDecoder_CppPtr(ctx)->getInstructionPointer();
}
void ZydisInstructionDecoder_SetInstructionPointer(
ZydisInstructionDecoderContext *ctx,
uint64_t instructionPointer)
{
ZydisInstructionDecoder_CppPtr(ctx)->setInstructionPointer(instructionPointer);
}
/* ============================================================================================= */

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 14. March 2015
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,14 +26,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
***************************************************************************************************/
#ifndef _VDE_ZyDisINSTRUCTIONDECODERC_H_
#define _VDE_ZyDisINSTRUCTIONDECODERC_H_
#include "ZyDisDisassemblerTypes.h"
#include "ZyDisDisassemblerUtils.h"
#ifndef _ZYDIS_INSTRUCTIONDECODER_H_
#define _ZYDIS_INSTRUCTIONDECODER_H_
#include "ZydisTypes.h"
#include <stdbool.h>
#include <stddef.h>
@ -44,24 +40,16 @@ extern "C"
{
#endif
/* ZyDisBaseDataSource ============================================================================ */
/* BaseInput ============================================================================ */
typedef struct _ZyDisBaseDataSourceContext { ZyDisContextDescriptor d; } ZyDisBaseDataSourceContext;
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);
typedef struct _ZydisBaseInputContext { int a; } ZydisBaseInputContext;
/**
* @brief Releases a data source.
* @param ctx The context to release.
* The context may no longer be used after it was released.
*/
ZYDIS_EXPORT void ZyDisBaseDataSource_Release(
ZyDisBaseDataSourceContext *ctx);
void ZydisBaseInput_Release(ZydisBaseInputContext *ctx);
/**
* @brief Reads the next byte from the data source without altering the current input position
@ -72,9 +60,7 @@ ZYDIS_EXPORT void ZyDisBaseDataSource_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.
*/
ZYDIS_EXPORT uint8_t ZyDisBaseDataSource_InputPeek(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
uint8_t ZydisBaseInput_InputPeek(ZydisBaseInputContext *ctx, ZydisInstructionInfo *info);
/**
* @brief Reads the next byte from the data source.
@ -87,30 +73,7 @@ ZYDIS_EXPORT uint8_t ZyDisBaseDataSource_InputPeek(
* parameter. This function also appends the new byte to to @c data field of the @c info
* parameter.
*/
ZYDIS_EXPORT uint8_t ZyDisBaseDataSource_InputNext8(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
/**
* @copydoc ZyDisBaseDataSource_InputNext8
*/
ZYDIS_EXPORT uint16_t ZyDisBaseDataSource_InputNext16(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
/**
* @copydoc ZyDisBaseDataSource_InputNext8
*/
ZYDIS_EXPORT uint32_t ZyDisBaseDataSource_InputNext32(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
/**
* @copydoc ZyDisBaseDataSource_InputNext8
*/
ZYDIS_EXPORT uint64_t ZyDisBaseDataSource_InputNext64(
ZyDisBaseDataSourceContext *ctx,
ZyDisInstructionInfo *info);
uint8_t ZydisBaseInput_InputNext(ZydisBaseInputContext *ctx, ZydisInstructionInfo *info);
/**
* @brief Returns the current input byte.
@ -119,24 +82,21 @@ ZYDIS_EXPORT uint64_t ZyDisBaseDataSource_InputNext64(
* The current input byte is set everytime the @c inputPeek or @c inputNext method is called.
*/
// TODO: check long descr
ZYDIS_EXPORT uint8_t ZyDisBaseDataSource_InputCurrent(
const ZyDisBaseDataSourceContext *ctx);
uint8_t ZydisBaseInput_InputCurrent(const ZydisBaseInputContext *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.
*/
ZYDIS_EXPORT bool ZyDisBaseDataSource_IsEndOfInput(
const ZyDisBaseDataSourceContext *ctx);
bool ZydisBaseInput_IsEndOfInput(const ZydisBaseInputContext *ctx);
/**
* @brief Returns the current input position.
* @param ctx The data soruce context.
* @return The current input position.
*/
ZYDIS_EXPORT uint64_t ZyDisBaseDataSource_GetPosition(
const ZyDisBaseDataSourceContext *ctx);
uint64_t ZydisBaseInput_GetPosition(const ZydisBaseInputContext *ctx);
/**
* @brief Sets a new input position.
@ -144,81 +104,53 @@ ZYDIS_EXPORT uint64_t ZyDisBaseDataSource_GetPosition(
* @param position The new input position.
* @return @c false if the new position exceeds the maximum input length.
*/
ZYDIS_EXPORT bool ZyDisBaseDataSource_SetPosition(
ZyDisBaseDataSourceContext *ctx,
uint64_t position);
bool ZydisBaseInput_SetPosition(ZydisBaseInputContext *ctx, uint64_t position);
/* ZyDisMemoryDataSource ========================================================================== */
/* MemoryInput ========================================================================== */
/**
* @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 ZyDisBaseDataSource_Release
* @see BaseInput_Release
*/
ZYDIS_EXPORT ZyDisBaseDataSourceContext* ZyDisMemoryDataSource_Create(
const void* buffer,
size_t bufferLen);
/* ZyDisCustomDataSource ========================================================================== */
/**
* @brief Creates a custom daat source.
* @param ctx The context.
* @param inputPeekCb The callback peeking the next input byte.
* @param inputNextCb The callback consuming the next input byte.
* @param isEndOfInputCb The callback determining if the end of input was reached.
* @param getPositionCb The callback obtaining the current input position.
* @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 ZyDisBaseDataSource_Release
*/
ZYDIS_EXPORT ZyDisBaseDataSourceContext* ZyDisCustomDataSource_Create(
ZyDisBaseDataSource_InputCallback inputPeekCb,
ZyDisBaseDataSource_InputCallback inputNextCb,
ZyDisBaseDataSource_IsEndOfInputCallback isEndOfInputCb,
ZyDisBaseDataSource_GetPositionCallback getPositionCb,
ZyDisBaseDataSource_SetPositionCallback setPositionCb,
ZyDisBaseDataSource_DestructionCallback destructionCb);
// TODO: verify return value
ZydisBaseInputContext* ZydisMemoryInput_Create(const void* buffer, size_t bufferLen);
/* Enums ======================================================================================= */
/**
* @brief Values that represent a disassembler mode.
*/
typedef enum _ZyDisDisassemblerMode /* : uint8_t */
typedef enum _ZydisDisassemblerMode /* : uint8_t */
{
DM_M16BIT,
DM_M32BIT,
DM_M64BIT
} ZyDisDisassemblerMode;
} ZydisDisassemblerMode;
/**
* @brief Values that represent an instruction-set vendor.
*/
typedef enum _ZyDisInstructionSetVendor /* : uint8_t */
typedef enum _ZydisInstructionSetVendor /* : uint8_t */
{
ISV_ANY,
ISV_INTEL,
ISV_AMD
} ZyDisInstructionSetVendor;
} ZydisInstructionSetVendor;
/* ZyDisInstructionDecoder ======================================================================== */
/* InstructionDecoder ======================================================================== */
typedef struct _ZyDisInstructionDecoderContext
{
ZyDisContextDescriptor d;
} ZyDisInstructionDecoderContext;
typedef struct _ZydisInstructionDecoderContext { int a; } ZydisInstructionDecoderContext;
/**
* @brief Creates an instruction decoder.
* @return @c NULL if it fails, else an instruction decoder context.
* @see ZyDisInstructionDecoder_Release
* @see InstructionDecoder_Release
*/
// TODO: verify return value
ZYDIS_EXPORT ZyDisInstructionDecoderContext* ZyDisInstructionDecoder_Create(void);
ZydisInstructionDecoderContext* ZydisInstructionDecoder_Create(void);
/**
* @brief Creates an instruction decoder.
@ -227,100 +159,89 @@ ZYDIS_EXPORT ZyDisInstructionDecoderContext* ZyDisInstructionDecoder_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 ZyDisInstructionDecoder_Release
* @see InstructionDecoder_Release
*/
ZYDIS_EXPORT ZyDisInstructionDecoderContext* ZyDisInstructionDecoder_CreateEx(
ZyDisBaseDataSourceContext *input,
ZyDisDisassemblerMode disassemblerMode,
ZyDisInstructionSetVendor preferredVendor,
ZydisInstructionDecoderContext* ZydisInstructionDecoder_CreateEx(ZydisBaseInputContext *input,
ZydisDisassemblerMode disassemblerMode, ZydisInstructionSetVendor preferredVendor,
uint64_t instructionPointer);
/**
* @brief Releases an instruction decoder.
* @param ctx The context of the instruction decoder to release.
*/
ZYDIS_EXPORT void ZyDisInstructionDecoder_Release(
ZyDisInstructionDecoderContext *ctx);
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 ZyDisInstructionInfo 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.
*/
ZYDIS_EXPORT bool ZyDisInstructionDecoder_DecodeInstruction(
ZyDisInstructionDecoderContext *ctx,
ZyDisInstructionInfo *info);
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.
*/
ZYDIS_EXPORT ZyDisBaseDataSourceContext* ZyDisInstructionDecoder_GetDataSource(
const ZyDisInstructionDecoderContext *ctx);
ZydisBaseInputContext* 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.
*/
ZYDIS_EXPORT void ZyDisInstructionDecoder_SetDataSource(
ZyDisInstructionDecoderContext *ctx,
ZyDisBaseDataSourceContext *input);
void ZydisInstructionDecoder_SetDataSource(ZydisInstructionDecoderContext *ctx,
ZydisBaseInputContext *input);
/**
* @brief Returns the current disassembler mode.
* @param ctx The instruction decoder context.
* @return The current disassembler mode.
*/
ZYDIS_EXPORT ZyDisDisassemblerMode ZyDisInstructionDecoder_GetDisassemblerMode(
const ZyDisInstructionDecoderContext *ctx);
ZydisDisassemblerMode ZydisInstructionDecoder_GetDisassemblerMode(ZydisInstructionDecoderContext *ctx);
/**
* @brief Sets the current disassembler mode.
* @param ctx The instruction decoder context.
* @param disassemblerMode The new disassembler mode.
*/
ZYDIS_EXPORT void ZyDisInstructionDecoder_SetDisassemblerMode(
ZyDisInstructionDecoderContext *ctx,
ZyDisDisassemblerMode disassemblerMode);
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.
*/
ZYDIS_EXPORT ZyDisInstructionSetVendor ZyDisInstructionDecoder_GetPreferredVendor(
const ZyDisInstructionDecoderContext *ctx);
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.
*/
ZYDIS_EXPORT void ZyDisInstructionDecoder_SetPreferredVendor(
ZyDisInstructionDecoderContext *ctx,
ZyDisInstructionSetVendor preferredVendor);
void ZydisInstructionDecoder_SetPreferredVendor(ZydisInstructionDecoderContext *ctx,
ZydisInstructionSetVendor preferredVendor);
/**
* @brief Returns the current instruction pointer.
* @param ctx The instruction decoder context.
* @return The current instruction pointer.
*/
ZYDIS_EXPORT uint64_t ZyDisInstructionDecoder_GetInstructionPointer(
const ZyDisInstructionDecoderContext *ctx);
uint64_t ZydisInstructionDecoder_GetInstructionPointer(ZydisInstructionDecoderContext *ctx);
/**
* @brief Sets a new instruction pointer.
* @param ctx The instruction decoder context.
* @param instructionPointer The new instruction pointer.
*/
ZYDIS_EXPORT void ZyDisInstructionDecoder_SetInstructionPointer(
ZyDisInstructionDecoderContext *ctx,
void ZydisInstructionDecoder_SetInstructionPointer(ZydisInstructionDecoderContext *ctx,
uint64_t instructionPointer);
/* ============================================================================================= */
@ -329,4 +250,4 @@ ZYDIS_EXPORT void ZyDisInstructionDecoder_SetInstructionPointer(
}
#endif
#endif /* _VDE_ZyDisINSTRUCTIONDECODERC_H_ */
#endif /* _ZYDIS_INSTRUCTIONDECODER_H_ */

View File

@ -0,0 +1,251 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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.
***************************************************************************************************/
#include "ZydisInstructionFormatter.h"
#include "ZydisInstructionFormatter.hpp"
/* Helpers ===================================================================================== */
namespace
{
inline Zydis::BaseSymbolResolver* ZydisBaseSymbolResolver_CppPtr(
ZydisBaseSymbolResolverContext *ctx)
{
return reinterpret_cast<Zydis::BaseSymbolResolver*>(ctx);
}
inline const Zydis::BaseSymbolResolver* ZydisBaseSymbolResolver_CppPtr(
const ZydisBaseSymbolResolverContext *ctx)
{
return reinterpret_cast<const Zydis::BaseSymbolResolver*>(ctx);
}
inline ZydisBaseSymbolResolverContext* ZydisBaseSymbolResolver_CPtr(
Zydis::BaseSymbolResolver *ptr)
{
return reinterpret_cast<ZydisBaseSymbolResolverContext*>(ptr);
}
inline const ZydisBaseSymbolResolverContext* ZydisBaseSymbolResolver_CPtr(
const Zydis::BaseSymbolResolver *ptr)
{
return reinterpret_cast<const ZydisBaseSymbolResolverContext*>(ptr);
}
inline Zydis::ExactSymbolResolver* ZydisExactSymbolResolver_CppPtr(
ZydisBaseSymbolResolverContext *ctx)
{
return reinterpret_cast<Zydis::ExactSymbolResolver*>(ctx);
}
inline const Zydis::ExactSymbolResolver* ZydisExactSymbolResolver_CppPtr(
const ZydisBaseSymbolResolverContext *ctx)
{
return reinterpret_cast<const Zydis::ExactSymbolResolver*>(ctx);
}
inline ZydisBaseSymbolResolverContext* ZydisExactSymbolResolver_CPtr(
Zydis::ExactSymbolResolver *ptr)
{
return reinterpret_cast<ZydisBaseSymbolResolverContext*>(ptr);
}
inline const ZydisBaseSymbolResolverContext* ZydisExactSymbolResolver_CPtr(
const Zydis::ExactSymbolResolver *ptr)
{
return reinterpret_cast<const ZydisBaseSymbolResolverContext*>(ptr);
}
inline Zydis::InstructionInfo* ZydisInstructionInfo_CppPtr(
ZydisInstructionInfo *ptr)
{
static_assert(sizeof(*ptr) == sizeof(Zydis::InstructionInfo), "broken struct");
return reinterpret_cast<Zydis::InstructionInfo*>(ptr);
}
inline const Zydis::InstructionInfo* ZydisInstructionInfo_CppPtr(
const ZydisInstructionInfo *ptr)
{
static_assert(sizeof(*ptr) == sizeof(Zydis::InstructionInfo), "broken struct");
return reinterpret_cast<const Zydis::InstructionInfo*>(ptr);
}
inline ZydisInstructionInfo* ZydisInstructionInfo_CPtr(
Zydis::InstructionInfo *ptr)
{
return reinterpret_cast<ZydisInstructionInfo*>(ptr);
}
inline const ZydisInstructionInfo* ZydisInstructionInfo_CPtr(
const Zydis::InstructionInfo *ptr)
{
return reinterpret_cast<const ZydisInstructionInfo*>(ptr);
}
inline Zydis::BaseInstructionFormatter* ZydisBaseInstructionFormatter_CppPtr(
ZydisBaseInstructionFormatterContext *ctx)
{
return reinterpret_cast<Zydis::BaseInstructionFormatter*>(ctx);
}
inline const Zydis::BaseInstructionFormatter* ZydisBaseInstructionFormatter_CppPtr(
const ZydisBaseInstructionFormatterContext *ctx)
{
return reinterpret_cast<const Zydis::BaseInstructionFormatter*>(ctx);
}
inline Zydis::BaseInstructionFormatter* ZydisIntelInstructionFormatter_CppPtr(
ZydisBaseInstructionFormatterContext *ctx)
{
return reinterpret_cast<Zydis::BaseInstructionFormatter*>(ctx);
}
inline const Zydis::BaseInstructionFormatter* ZydisIntelInstructionFormatter_CppPtr(
const ZydisBaseInstructionFormatterContext *ctx)
{
return reinterpret_cast<const Zydis::BaseInstructionFormatter*>(ctx);
}
inline ZydisBaseInstructionFormatterContext* ZydisIntelInstructionFormatter_CPtr(
Zydis::BaseInstructionFormatter *ctx)
{
return reinterpret_cast<ZydisBaseInstructionFormatterContext*>(ctx);
}
inline const ZydisBaseInstructionFormatterContext* ZydisIntelInstructionFormatter_CPtr(
const Zydis::BaseInstructionFormatter *ctx)
{
return reinterpret_cast<const ZydisBaseInstructionFormatterContext*>(ctx);
}
}
/* BaseSymbolResolver ======================================================================== */
void ZydisBaseSymbolResolver_Release(
ZydisBaseSymbolResolverContext *ctx)
{
delete ZydisBaseSymbolResolver_CppPtr(ctx);
}
const char* ZydisBaseSymbolResolver_ResolveSymbol(
ZydisBaseSymbolResolverContext *ctx,
const ZydisInstructionInfo *info,
uint64_t address,
uint64_t *offset)
{
return ZydisBaseSymbolResolver_CppPtr(ctx)->resolveSymbol(
*ZydisInstructionInfo_CppPtr(info),
address,
*offset);
}
/* ExactSymbolResolver ======================================================================= */
ZydisBaseSymbolResolverContext* ZydisExactSymbolResolver_Create(void)
{
return ZydisExactSymbolResolver_CPtr(new Zydis::ExactSymbolResolver);
}
bool EZydisxactSymbolResolver_ContainsSymbol(
ZydisBaseSymbolResolverContext *ctx,
uint64_t address)
{
return ZydisExactSymbolResolver_CppPtr(ctx)->containsSymbol(address);
}
void ZydisExactSymbolResolverContext_SetSymbol(
ZydisBaseSymbolResolverContext *ctx,
uint64_t address,
const char* name)
{
ZydisExactSymbolResolver_CppPtr(ctx)->setSymbol(address, name);
}
void ZydisExactSymbolResolverContext_RemoveSymbol(
ZydisBaseSymbolResolverContext *ctx,
uint64_t address)
{
ZydisExactSymbolResolver_CppPtr(ctx)->removeSymbol(address);
}
void ZydisExactSymbolResolverContext_Clear(
ZydisBaseSymbolResolverContext *ctx)
{
ZydisExactSymbolResolver_CppPtr(ctx)->clear();
}
/* BaseInstructionFormatter ================================================================== */
const char* ZydisBaseInstructionFormatter_FormatInstruction(
ZydisBaseInstructionFormatterContext *ctx,
const ZydisInstructionInfo *info)
{
return ZydisBaseInstructionFormatter_CppPtr(ctx)->formatInstruction(
*ZydisInstructionInfo_CppPtr(info));
}
ZydisBaseSymbolResolverContext* ZydisBaseInstructionFormatter_GetSymbolResolver(
const ZydisBaseInstructionFormatterContext *ctx)
{
return ZydisBaseSymbolResolver_CPtr(
ZydisBaseInstructionFormatter_CppPtr(ctx)->getSymbolResolver());
}
void ZydisBaseInstructionFormatter_SetSymbolResolver(
ZydisBaseInstructionFormatterContext *ctx,
ZydisBaseSymbolResolverContext *resolver)
{
ZydisBaseInstructionFormatter_CppPtr(ctx)->setSymbolResolver(
ZydisBaseSymbolResolver_CppPtr(resolver));
}
void ZydisBaseInstructionFormatter_Release(
ZydisBaseInstructionFormatterContext *ctx)
{
delete ZydisBaseInstructionFormatter_CppPtr(ctx);
}
/* IntelInstructionFormatter ================================================================ */
ZydisBaseInstructionFormatterContext* ZydisIntelInstructionFormatter_Create(void)
{
return ZydisIntelInstructionFormatter_CPtr(new Zydis::IntelInstructionFormatter);
}
ZydisBaseInstructionFormatterContext* ZydisIntelInstructionFormatter_CreateEx(
ZydisBaseSymbolResolverContext *resolver)
{
return ZydisIntelInstructionFormatter_CPtr(new Zydis::IntelInstructionFormatter(
ZydisBaseSymbolResolver_CppPtr(resolver)));
}
/* ============================================================================================= */

View File

@ -0,0 +1,104 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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 _ZYDIS_INSTRUCTIONFORMATTER_H_
#define _ZYDIS_INSTRUCTIONFORMATTER_H_
#include "ZydisTypes.h"
#include "ZydisSymbolResolver.h"
#ifdef __cplusplus
extern "C"
{
#endif
/* BaseInstructionFormatter ================================================================== */
typedef struct _ZydisBaseInstructionFormatterContext {int a;} ZydisBaseInstructionFormatterContext;
/**
* @brief Formats a decoded instruction.
* @param ctx The instruction formatter context.
* @param info The instruction info.
* @return Pointer to the formatted instruction string. This pointer remains valid until
* this function is called again or the context is released.
*/
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.
*/
ZydisBaseSymbolResolverContext* ZydisBaseInstructionFormatter_GetSymbolResolver(
const ZydisBaseInstructionFormatterContext *ctx);
/**
* @brief Sets a new symbol resolver.
* @param ctx The instruction formatter context.
* @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol
* resolver should be used.
*/
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.
*/
void ZydisBaseInstructionFormatter_Release(ZydisBaseInstructionFormatterContext *ctx);
/* IntelInstructionFormatter ================================================================ */
/**
* @brief Creates an Intel-syntax instruction formatter.
* @return @c NULL if it fails, else an Intel instruction formatter context.
* @see BaseInstructionFormatter_Release
*/
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 BaseInstructionFormatter_Release
*/
ZydisBaseInstructionFormatterContext* ZydisIntelInstructionFormatter_CreateEx(
ZydisBaseSymbolResolverContext *resolver);
/* ============================================================================================= */
#ifdef __cplusplus
}
#endif
#endif /* _ZYDIS_INSTRUCTIONFORMATTER_H_ */

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 19. March 2015
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,14 +26,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
***************************************************************************************************/
#include <ZyDisDisassembler.h>
int main(int argc, char* argv[])
{
ZYDIS_UNUSED(argc); ZYDIS_UNUSED(argv);
// TODO:
return 0;
}
#include "ZydisOpcodeTable.h"
#include "ZydisOpcodeTable.hpp"

View File

@ -0,0 +1,961 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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 _ZYDIS_OPCODETABLE_H_
#define _ZYDIS_OPCODETABLE_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Values that represent an instruction mnemonic.
*/
typedef enum _ZydisInstructionMnemonic /* : uint16_t */
{
/* 000 */ ZYDIS_MNEM_INVALID,
/* 001 */ ZYDIS_MNEM_AAA,
/* 002 */ ZYDIS_MNEM_AAD,
/* 003 */ ZYDIS_MNEM_AAM,
/* 004 */ ZYDIS_MNEM_AAS,
/* 005 */ ZYDIS_MNEM_ADC,
/* 006 */ ZYDIS_MNEM_ADD,
/* 007 */ ZYDIS_MNEM_ADDPD,
/* 008 */ ZYDIS_MNEM_ADDPS,
/* 009 */ ZYDIS_MNEM_ADDSD,
/* 00A */ ZYDIS_MNEM_ADDSS,
/* 00B */ ZYDIS_MNEM_ADDSUBPD,
/* 00C */ ZYDIS_MNEM_ADDSUBPS,
/* 00D */ ZYDIS_MNEM_AESDEC,
/* 00E */ ZYDIS_MNEM_AESDECLAST,
/* 00F */ ZYDIS_MNEM_AESENC,
/* 010 */ ZYDIS_MNEM_AESENCLAST,
/* 011 */ ZYDIS_MNEM_AESIMC,
/* 012 */ ZYDIS_MNEM_AESKEYGENASSIST,
/* 013 */ ZYDIS_MNEM_AND,
/* 014 */ ZYDIS_MNEM_ANDNPD,
/* 015 */ ZYDIS_MNEM_ANDNPS,
/* 016 */ ZYDIS_MNEM_ANDPD,
/* 017 */ ZYDIS_MNEM_ANDPS,
/*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 ZYDIS_MNEM_SETBE,
/* 22D */ ZYDIS_MNEM_SETE,
/* 22E */ ZYDIS_MNEM_SETG,
/* 22F */ ZYDIS_MNEM_SETGE,
/* 230 */ ZYDIS_MNEM_SETL,
/* 231 */ ZYDIS_MNEM_SETLE,
/* 232 */ ZYDIS_MNEM_SETNE,
/* 233 */ ZYDIS_MNEM_SETNO,
/* 234 */ ZYDIS_MNEM_SETNP,
/* 235 */ ZYDIS_MNEM_SETNS,
/* 236 */ ZYDIS_MNEM_SETO,
/* 237 */ ZYDIS_MNEM_SETP,
/* 238 */ ZYDIS_MNEM_SETS,
/* 239 */ ZYDIS_MNEM_SFENCE,
/* 23A */ ZYDIS_MNEM_SGDT,
/* 23B */ ZYDIS_MNEM_SHL,
/* 23C */ ZYDIS_MNEM_SHLD,
/* 23D */ ZYDIS_MNEM_SHR,
/* 23E */ ZYDIS_MNEM_SHRD,
/* 23F */ ZYDIS_MNEM_SHUFPD,
/* 240 */ ZYDIS_MNEM_SHUFPS,
/* 241 */ ZYDIS_MNEM_SIDT,
/* 242 */ ZYDIS_MNEM_SKINIT,
/* 243 */ ZYDIS_MNEM_SLDT,
/* 244 */ ZYDIS_MNEM_SMSW,
/* 245 */ ZYDIS_MNEM_SQRTPD,
/* 246 */ ZYDIS_MNEM_SQRTPS,
/* 247 */ ZYDIS_MNEM_SQRTSD,
/* 248 */ ZYDIS_MNEM_SQRTSS,
/* 249 */ ZYDIS_MNEM_STC,
/* 24A */ ZYDIS_MNEM_STD,
/* 24B */ ZYDIS_MNEM_STGI,
/* 24C */ ZYDIS_MNEM_STI,
/* 24D */ ZYDIS_MNEM_STMXCSR,
/* 24E */ ZYDIS_MNEM_STOSB,
/* 24F */ ZYDIS_MNEM_STOSD,
/* 250 */ ZYDIS_MNEM_STOSQ,
/* 251 */ ZYDIS_MNEM_STOSW,
/* 252 */ ZYDIS_MNEM_STR,
/* 253 */ ZYDIS_MNEM_SUB,
/* 254 */ ZYDIS_MNEM_SUBPD,
/* 255 */ ZYDIS_MNEM_SUBPS,
/* 256 */ ZYDIS_MNEM_SUBSD,
/* 257 */ ZYDIS_MNEM_SUBSS,
/* 258 */ ZYDIS_MNEM_SWAPGS,
/* 259 */ ZYDIS_MNEM_SYSCALL,
/* 25A */ ZYDIS_MNEM_SYSENTER,
/* 25B */ ZYDIS_MNEM_SYSEXIT,
/* 25C */ ZYDIS_MNEM_SYSRET,
/* 25D */ ZYDIS_MNEM_TEST,
/* 25E */ ZYDIS_MNEM_UCOMISD,
/* 25F */ ZYDIS_MNEM_UCOMISS,
/* 260 */ ZYDIS_MNEM_UD2,
/* 261 */ ZYDIS_MNEM_UNPCKHPD,
/* 262 */ ZYDIS_MNEM_UNPCKHPS,
/* 263 */ ZYDIS_MNEM_UNPCKLPD,
/* 264 */ ZYDIS_MNEM_UNPCKLPS,
/* 265 */ ZYDIS_MNEM_VADDPD,
/* 266 */ ZYDIS_MNEM_VADDPS,
/* 267 */ ZYDIS_MNEM_VADDSD,
/* 268 */ ZYDIS_MNEM_VADDSS,
/* 269 */ ZYDIS_MNEM_VADDSUBPD,
/* 26A */ ZYDIS_MNEM_VADDSUBPS,
/* 26B */ ZYDIS_MNEM_VAESDEC,
/* 26C */ ZYDIS_MNEM_VAESDECLAST,
/* 26D */ ZYDIS_MNEM_VAESENC,
/* 26E */ ZYDIS_MNEM_VAESENCLAST,
/* 26F */ ZYDIS_MNEM_VAESIMC,
/* 270 */ ZYDIS_MNEM_VAESKEYGENASSIST,
/* 271 */ ZYDIS_MNEM_VANDNPD,
/* 272 */ ZYDIS_MNEM_VANDNPS,
/* 273 */ ZYDIS_MNEM_VANDPD,
/* 274 */ ZYDIS_MNEM_VANDPS,
/* 275 */ ZYDIS_MNEM_VBLENDPD,
/* 276 */ ZYDIS_MNEM_VBLENDPS,
/* 277 */ ZYDIS_MNEM_VBLENDVPD,
/* 278 */ ZYDIS_MNEM_VBLENDVPS,
/* 279 */ ZYDIS_MNEM_VBROADCASTSD,
/* 27A */ ZYDIS_M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IS_MNEM_VZEROUPPER,
/* 374 */ ZYDIS_MNEM_WAIT,
/* 375 */ ZYDIS_MNEM_WBINVD,
/* 376 */ ZYDIS_MNEM_WRMSR,
/* 377 */ ZYDIS_MNEM_XADD,
/* 378 */ ZYDIS_MNEM_XCHG,
/* 379 */ ZYDIS_MNEM_XCRYPTCBC,
/* 37A */ ZYDIS_MNEM_XCRYPTCFB,
/* 37B */ ZYDIS_MNEM_XCRYPTCTR,
/* 37C */ ZYDIS_MNEM_XCRYPTECB,
/* 37D */ ZYDIS_MNEM_XCRYPTOFB,
/* 37E */ ZYDIS_MNEM_XGETBV,
/* 37F */ ZYDIS_MNEM_XLATB,
/* 380 */ ZYDIS_MNEM_XOR,
/* 381 */ ZYDIS_MNEM_XORPD,
/* 382 */ ZYDIS_MNEM_XORPS,
/* 383 */ ZYDIS_MNEM_XRSTOR,
/* 384 */ ZYDIS_MNEM_XSAVE,
/* 385 */ ZYDIS_MNEM_XSETBV,
/* 386 */ ZYDIS_MNEM_XSHA1,
/* 387 */ ZYDIS_MNEM_XSHA256,
/* 388 */ ZYDIS_MNEM_XSTORE,
ZYDIS_MNEM_FORCE_WORD = 0x7FFF
} ZydisInstructionMnemonic;
/* TODO: Port instruction definition types */
#ifdef __cplusplus
}
#endif
#endif // _ZYDIS_OPCODETABLE_H_

View File

@ -0,0 +1,144 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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.
***************************************************************************************************/
#include "ZydisSymbolResolver.h"
#include <ZydisSymbolResolver.hpp>
/* CustomSymbolResolver ========================================================================= */
inline Zydis::BaseSymbolResolver* ZydisBaseSymbolResolver_CppPtr(
ZydisBaseSymbolResolverContext *ctx)
{
return reinterpret_cast<Zydis::BaseSymbolResolver*>(ctx);
}
inline const Zydis::BaseSymbolResolver* ZydisBaseSymbolResolver_CppPtr(
const ZydisBaseSymbolResolverContext *ctx)
{
return reinterpret_cast<const Zydis::BaseSymbolResolver*>(ctx);
}
inline ZydisBaseSymbolResolverContext* ZydisBaseSymbolResolver_CPtr(
Zydis::BaseSymbolResolver *ptr)
{
return reinterpret_cast<ZydisBaseSymbolResolverContext*>(ptr);
}
inline const ZydisBaseSymbolResolverContext* ZydisBaseSymbolResolver_CPtr(
const Zydis::BaseSymbolResolver *ptr)
{
return reinterpret_cast<const ZydisBaseSymbolResolverContext*>(ptr);
}
inline Zydis::InstructionInfo* ZydisInstructionInfo_CppPtr(
ZydisInstructionInfo *ptr)
{
static_assert(sizeof(*ptr) == sizeof(Zydis::InstructionInfo), "broken struct");
return reinterpret_cast<Zydis::InstructionInfo*>(ptr);
}
inline const Zydis::InstructionInfo* ZydisInstructionInfo_CppPtr(
const ZydisInstructionInfo *ptr)
{
static_assert(sizeof(*ptr) == sizeof(Zydis::InstructionInfo), "broken struct");
return reinterpret_cast<const Zydis::InstructionInfo*>(ptr);
}
inline ZydisInstructionInfo* ZydisInstructionInfo_CPtr(
Zydis::InstructionInfo *ptr)
{
return reinterpret_cast<ZydisInstructionInfo*>(ptr);
}
inline const ZydisInstructionInfo* ZydisInstructionInfo_CPtr(
const Zydis::InstructionInfo *ptr)
{
return reinterpret_cast<const ZydisInstructionInfo*>(ptr);
}
/* Internal helper class ----------------------------------------------------------------------- */
namespace
{
class ZydisCustomSymbolResolver : public Zydis::BaseSymbolResolver
{
ZydisResolveSymbol_t m_resolverCb;
void* m_userData;
public:
/**
* @brief Constructor.
* @param resolverCb The resolver callback.
* @param userData User provided pointer to arbitrary data passed to resolve callback.
*/
ZydisCustomSymbolResolver(ZydisResolveSymbol_t resolverCb, void *userData);
/**
* @brief Destructor.
*/
~ZydisCustomSymbolResolver() override = default;
public:
/**
* @brief Resolves a symbol.
* @param info The instruction info.
* @param address The address.
* @param offset Reference to an unsigned 64 bit integer that receives an offset
* relative to the base address of the symbol.
* @return The name of the symbol, if the symbol was found, @c NULL if not.
*/
const char* resolveSymbol(const Zydis::InstructionInfo &info, uint64_t address,
uint64_t &offset) override;
};
ZydisCustomSymbolResolver::ZydisCustomSymbolResolver(ZydisResolveSymbol_t resolverCb,
void *userData)
: m_resolverCb(resolverCb)
, m_userData(userData)
{
}
const char* ZydisCustomSymbolResolver::resolveSymbol(
const Zydis::InstructionInfo &info, uint64_t address, uint64_t &offset)
{
return m_resolverCb(ZydisInstructionInfo_CPtr(&info), address, &offset, m_userData);
}
} // anon namespace
/* C API implementation ------------------------------------------------------------------------ */
ZydisBaseSymbolResolverContext* ZydisCustomSymbolResolver_Create(
ZydisResolveSymbol_t resolverCb,
void *userData)
{
return ZydisBaseSymbolResolver_CPtr(new ZydisCustomSymbolResolver(resolverCb, userData));
}
/* ============================================================================================= */

View File

@ -0,0 +1,126 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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 _ZYDIS_SYMBOLRESOLVER_H_
#define _ZYDIS_SYMBOLRESOLVER_H_
#include "ZydisTypes.h"
#ifdef __cplusplus
extern "C"
{
#endif
/* BaseSymbolResolver ======================================================================== */
typedef struct _ZydisBaseSymbolResolverContext { int a; } 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.
*/
void ZydisBaseSymbolResolver_Release(ZydisBaseSymbolResolverContext *ctx);
/**
* @brief Resolves a symbol.
* @param ctx The symbol resolver context.
* @param info The instruction info.
* @param address The address.
* @param offset Pointer to an unsigned 64 bit integer that receives an offset relative to
* the base address of the symbol.
* @return The name of the symbol if the symbol was found, else @c NULL.
*/
const char* ZydisBaseSymbolResolver_ResolveSymbol(ZydisBaseSymbolResolverContext *ctx,
const ZydisInstructionInfo *info, uint64_t address, uint64_t *offset);
/* ExactSymbolResolver ======================================================================= */
/**
* @brief Creates an exact symbol resolver.
* @return @c NULL if it fails, else a symbol resolver context.
* @see BaseSymbolResolver_Release
* An exact resolver is a simple symbol resolver that only matches exact addresses.
*/
// TODO: verify return value
ZydisBaseSymbolResolverContext* ZydisExactSymbolResolver_Create(void);
/**
* @brief Query if the given address is a known symbol.
* @param ctx The exact symbol resolver context.
* @param address The address.
* @return @c true if the address is known, @c false if not.
*/
bool ZydisExactSymbolResolver_ContainsSymbol(ZydisBaseSymbolResolverContext *ctx, uint64_t address);
/**
* @brief Adds or changes a symbol.
* @param ctx The exact symbol resolver context.
* @param address The address.
* @param name The symbol name.
*/
void ZydisExactSymbolResolverContext_SetSymbol(ZydisBaseSymbolResolverContext *ctx,
uint64_t address, const char* name);
/**
* @brief Removes the symbol described by address.
* @param ctx The exact symbol resolver context.
* @param address The address.
* This will invalidate all char-pointers to the affected symbol name.
*/
void ZydisExactSymbolResolverContext_RemoveSymbol(ZydisBaseSymbolResolverContext *ctx,
uint64_t address);
/**
* @brief Clears the symbol tree.
* @param ctx The exact symbol resolver context.
*/
void ExactSymbolResolverContext_Clear(ZydisBaseSymbolResolverContext *ctx);
/* CustomSymbolResolver ====================================================================== */
typedef const char* (*ZydisResolveSymbol_t)(const ZydisInstructionInfo *info, uint64_t address,
uint64_t *offset, void *userData);
/**
* @brief Creates a custom symbol resolver.
* @param resolverCb The resolver callback consulted when symbols need to be resolved.
* @param userData A pointer to arbitrary data passed to the resolver callback.
* May also be @c NULL.
* @return @c NULL if it fails, else a symbol resolver context.
*/
ZydisBaseSymbolResolverContext* CustomSymbolResolver_Create(ZydisResolveSymbol_t resolverCb,
void *userData);
#ifdef __cplusplus
}
#endif
#endif /* _ZYDIS_SYMBOLRESOLVER_H_ */

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 04. February 2015
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,14 +26,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
***************************************************************************************************/
#ifndef _VDE_ZyDisDISASSEMBLERTYPESC_H_
#define _VDE_ZyDisDISASSEMBLERTYPESC_H_
#ifndef _ZYDIS_TYPES_H_
#define _ZYDIS_TYPES_H_
#include <stdint.h>
#include <stdbool.h>
#include "ZyDisOpcodeTable.h"
#include "ZydisOpcodeTable.h"
#ifdef __cplusplus
extern "C"
@ -45,218 +43,218 @@ extern "C"
/**
* @brief Values that represent additional flags of a decoded instruction.
*/
typedef enum _ZyDisInstructionFlags /* : uint32_t */
typedef enum _ZydisInstructionFlags /* : uint32_t */
{
IF_NONE = 0x00000000,
ZYDIS_IF_NONE = 0x00000000,
/**
* @brief The instruction was decoded in 16 bit disassembler mode.
*/
IF_DISASSEMBLER_MODE_16 = 0x00000001,
ZYDIS_IF_DISASSEMBLER_MODE_16 = 0x00000001,
/**
* @brief The instruction was decoded in 32 bit disassembler mode.
*/
IF_DISASSEMBLER_MODE_32 = 0x00000002,
ZYDIS_IF_DISASSEMBLER_MODE_32 = 0x00000002,
/**
* @brief The instruction was decoded in 64 bit disassembler mode.
*/
IF_DISASSEMBLER_MODE_64 = 0x00000004,
ZYDIS_IF_DISASSEMBLER_MODE_64 = 0x00000004,
/**
* @brief The instruction has a segment prefix (0x26, 0x2E, 0x36, 0x3E, 0x64, 0x65).
*/
IF_PREFIX_SEGMENT = 0x00000008,
ZYDIS_IF_PREFIX_SEGMENT = 0x00000008,
/**
* @brief The instruction has a lock prefix (0xF0).
*/
IF_PREFIX_LOCK = 0x00000010,
ZYDIS_IF_PREFIX_LOCK = 0x00000010,
/**
* @brief The instruction has a repne prefix (0xF2).
*/
IF_PREFIX_REPNE = 0x00000020,
ZYDIS_IF_PREFIX_REPNE = 0x00000020,
/**
* @brief The instruction has a rep prefix (0xF3).
*/
IF_PREFIX_REP = 0x00000040,
ZYDIS_IF_PREFIX_REP = 0x00000040,
/**
* @brief The instruction has an operand size prefix (0x66).
*/
IF_PREFIX_OPERAND_SIZE = 0x00000080,
ZYDIS_IF_PREFIX_OPERAND_SIZE = 0x00000080,
/**
* @brief The instruction has an address size prefix (0x67).
*/
IF_PREFIX_ADDRESS_SIZE = 0x00000100,
ZYDIS_IF_PREFIX_ADDRESS_SIZE = 0x00000100,
/**
* @brief The instruction has a rex prefix (0x40 - 0x4F).
*/
IF_PREFIX_REX = 0x00000200,
ZYDIS_IF_PREFIX_REX = 0x00000200,
/**
* @brief The instruction has a vex prefix (0xC4 or 0xC5).
*/
IF_PREFIX_VEX = 0x00000400,
ZYDIS_IF_PREFIX_VEX = 0x00000400,
/**
* @brief The instruction has a modrm byte.
*/
IF_MODRM = 0x00000800,
ZYDIS_IF_MODRM = 0x00000800,
/**
* @brief The instruction has a sib byte.
*/
IF_SIB = 0x00001000,
ZYDIS_IF_SIB = 0x00001000,
/**
* @brief The instruction has an operand with a relative address.
*/
IF_RELATIVE = 0x00002000,
ZYDIS_IF_RELATIVE = 0x00002000,
/**
* @brief An error occured while decoding the instruction.
*/
IF_ERROR_MASK = 0xFFF00000,
ZYDIS_IF_ERROR_MASK = 0xFFF00000,
/**
* @brief End of input reached while decoding the instruction.
*/
IF_ERROR_END_OF_INPUT = 0x00100000,
ZYDIS_IF_ERROR_END_OF_INPUT = 0x00100000,
/**
* @brief The instruction length has exceeded the maximum of 15 bytes.
*/
IF_ERROR_LENGTH = 0x00200000,
ZYDIS_IF_ERROR_LENGTH = 0x00200000,
/**
* @brief The instruction is invalid.
*/
IF_ERROR_INVALID = 0x00400000,
ZYDIS_IF_ERROR_INVALID = 0x00400000,
/**
* @brief The instruction is invalid in 64 bit mode.
*/
IF_ERROR_INVALID_64 = 0x00800000,
ZYDIS_IF_ERROR_INVALID_64 = 0x00800000,
/**
* @brief An error occured while decoding the instruction operands.
*/
IF_ERROR_OPERAND = 0x01000000,
ZYDIS_IF_ERROR_OPERAND = 0x01000000,
IF_FORCE_DWORD = 0x7FFFFFFF
} ZyDisInstructionFlags;
ZYDIS_IF_FORCE_DWORD = 0x7FFFFFFF
} ZydisInstructionFlags;
/**
* @brief Values that represent a cpu register.
*/
typedef enum _ZyDisRegister /* : uint16_t */
typedef enum _ZydisRegister /* : uint16_t */
{
REG_NONE,
ZYDIS_REG_NONE,
/* 8 bit general purpose registers */
REG_AL, REG_CL, REG_DL, REG_BL,
REG_AH, REG_CH, REG_DH, REG_BH,
REG_SPL, REG_BPL, REG_SIL, REG_DIL,
REG_R8B, REG_R9B, REG_R10B, REG_R11B,
REG_R12B, REG_R13B, REG_R14B, REG_R15B,
ZYDIS_REG_AL, ZYDIS_REG_CL, ZYDIS_REG_DL, ZYDIS_REG_BL,
ZYDIS_REG_AH, ZYDIS_REG_CH, ZYDIS_REG_DH, ZYDIS_REG_BH,
ZYDIS_REG_SPL, ZYDIS_REG_BPL, ZYDIS_REG_SIL, ZYDIS_REG_DIL,
ZYDIS_REG_R8B, ZYDIS_REG_R9B, ZYDIS_REG_R10B, ZYDIS_REG_R11B,
ZYDIS_REG_R12B, ZYDIS_REG_R13B, ZYDIS_REG_R14B, ZYDIS_REG_R15B,
/* 16 bit general purpose registers */
REG_AX, REG_CX, REG_DX, REG_BX,
REG_SP, REG_BP, REG_SI, REG_DI,
REG_R8W, REG_R9W, REG_R10W, REG_R11W,
REG_R12W, REG_R13W, REG_R14W, REG_R15W,
ZYDIS_REG_AX, ZYDIS_REG_CX, ZYDIS_REG_DX, ZYDIS_REG_BX,
ZYDIS_REG_SP, ZYDIS_REG_BP, ZYDIS_REG_SI, ZYDIS_REG_DI,
ZYDIS_REG_R8W, ZYDIS_REG_R9W, ZYDIS_REG_R10W, ZYDIS_REG_R11W,
ZYDIS_REG_R12W, ZYDIS_REG_R13W, ZYDIS_REG_R14W, ZYDIS_REG_R15W,
/* 32 bit general purpose registers */
REG_EAX, REG_ECX, REG_EDX, REG_EBX,
REG_ESP, REG_EBP, REG_ESI, REG_EDI,
REG_R8D, REG_R9D, REG_R10D, REG_R11D,
REG_R12D, REG_R13D, REG_R14D, REG_R15D,
ZYDIS_REG_EAX, ZYDIS_REG_ECX, ZYDIS_REG_EDX, ZYDIS_REG_EBX,
ZYDIS_REG_ESP, ZYDIS_REG_EBP, ZYDIS_REG_ESI, ZYDIS_REG_EDI,
ZYDIS_REG_R8D, ZYDIS_REG_R9D, ZYDIS_REG_R10D, ZYDIS_REG_R11D,
ZYDIS_REG_R12D, ZYDIS_REG_R13D, ZYDIS_REG_R14D, ZYDIS_REG_R15D,
/* 64 bit general purpose registers */
REG_RAX, REG_RCX, REG_RDX, REG_RBX,
REG_RSP, REG_RBP, REG_RSI, REG_RDI,
REG_R8, REG_R9, REG_R10, REG_R11,
REG_R12, REG_R13, REG_R14, REG_R15,
ZYDIS_REG_RAX, ZYDIS_REG_RCX, ZYDIS_REG_RDX, ZYDIS_REG_RBX,
ZYDIS_REG_RSP, ZYDIS_REG_RBP, ZYDIS_REG_RSI, ZYDIS_REG_RDI,
ZYDIS_REG_R8, ZYDIS_REG_R9, ZYDIS_REG_R10, ZYDIS_REG_R11,
ZYDIS_REG_R12, ZYDIS_REG_R13, ZYDIS_REG_R14, ZYDIS_REG_R15,
/* segment registers */
REG_ES, REG_CS, REG_SS,
REG_DS, REG_FS, REG_GS,
ZYDIS_REG_ES, ZYDIS_REG_CS, ZYDIS_REG_SS,
ZYDIS_REG_DS, ZYDIS_REG_FS, ZYDIS_REG_GS,
/* control registers */
REG_CR0, REG_CR1, REG_CR2, REG_CR3,
REG_CR4, REG_CR5, REG_CR6, REG_CR7,
REG_CR8, REG_CR9, REG_CR10, REG_CR11,
REG_CR12, REG_CR13, REG_CR14, REG_CR15,
ZYDIS_REG_CR0, ZYDIS_REG_CR1, ZYDIS_REG_CR2, ZYDIS_REG_CR3,
ZYDIS_REG_CR4, ZYDIS_REG_CR5, ZYDIS_REG_CR6, ZYDIS_REG_CR7,
ZYDIS_REG_CR8, ZYDIS_REG_CR9, ZYDIS_REG_CR10, ZYDIS_REG_CR11,
ZYDIS_REG_CR12, ZYDIS_REG_CR13, ZYDIS_REG_CR14, ZYDIS_REG_CR15,
/* debug registers */
REG_DR0, REG_DR1, REG_DR2, REG_DR3,
REG_DR4, REG_DR5, REG_DR6, REG_DR7,
REG_DR8, REG_DR9, REG_DR10, REG_DR11,
REG_DR12, REG_DR13, REG_DR14, REG_DR15,
ZYDIS_REG_DR0, ZYDIS_REG_DR1, ZYDIS_REG_DR2, ZYDIS_REG_DR3,
ZYDIS_REG_DR4, ZYDIS_REG_DR5, ZYDIS_REG_DR6, ZYDIS_REG_DR7,
ZYDIS_REG_DR8, ZYDIS_REG_DR9, ZYDIS_REG_DR10, ZYDIS_REG_DR11,
ZYDIS_REG_DR12, ZYDIS_REG_DR13, ZYDIS_REG_DR14, ZYDIS_REG_DR15,
/* mmx registers */
REG_MM0, REG_MM1, REG_MM2, REG_MM3,
REG_MM4, REG_MM5, REG_MM6, REG_MM7,
ZYDIS_REG_MM0, ZYDIS_REG_MM1, ZYDIS_REG_MM2, ZYDIS_REG_MM3,
ZYDIS_REG_MM4, ZYDIS_REG_MM5, ZYDIS_REG_MM6, ZYDIS_REG_MM7,
/* x87 registers */
REG_ST0, REG_ST1, REG_ST2, REG_ST3,
REG_ST4, REG_ST5, REG_ST6, REG_ST7,
ZYDIS_REG_ST0, ZYDIS_REG_ST1, ZYDIS_REG_ST2, ZYDIS_REG_ST3,
ZYDIS_REG_ST4, ZYDIS_REG_ST5, ZYDIS_REG_ST6, ZYDIS_REG_ST7,
/* extended multimedia registers */
REG_XMM0, REG_XMM1, REG_XMM2, REG_XMM3,
REG_XMM4, REG_XMM5, REG_XMM6, REG_XMM7,
REG_XMM8, REG_XMM9, REG_XMM10, REG_XMM11,
REG_XMM12, REG_XMM13, REG_XMM14, REG_XMM15,
ZYDIS_REG_XMM0, ZYDIS_REG_XMM1, ZYDIS_REG_XMM2, ZYDIS_REG_XMM3,
ZYDIS_REG_XMM4, ZYDIS_REG_XMM5, ZYDIS_REG_XMM6, ZYDIS_REG_XMM7,
ZYDIS_REG_XMM8, ZYDIS_REG_XMM9, ZYDIS_REG_XMM10, ZYDIS_REG_XMM11,
ZYDIS_REG_XMM12, ZYDIS_REG_XMM13, ZYDIS_REG_XMM14, ZYDIS_REG_XMM15,
/* 256 bit multimedia registers */
REG_YMM0, REG_YMM1, REG_YMM2, REG_YMM3,
REG_YMM4, REG_YMM5, REG_YMM6, REG_YMM7,
REG_YMM8, REG_YMM9, REG_YMM10, REG_YMM11,
REG_YMM12, REG_YMM13, REG_YMM14, YMM15,
ZYDIS_REG_YMM0, ZYDIS_REG_YMM1, ZYDIS_REG_YMM2, ZYDIS_REG_YMM3,
ZYDIS_REG_YMM4, ZYDIS_REG_YMM5, ZYDIS_REG_YMM6, ZYDIS_REG_YMM7,
ZYDIS_REG_YMM8, ZYDIS_REG_YMM9, ZYDIS_REG_YMM10, ZYDIS_REG_YMM11,
ZYDIS_REG_YMM12, ZYDIS_REG_YMM13, ZYDIS_REG_YMM14, YMM15,
/* instruction pointer register */
REG_RIP,
ZYDIS_REG_RIP,
REG_FORCE_WORD = 0x7FFF
} ZyDisRegister;
ZYDIS_REG_FORCE_WORD = 0x7FFF
} ZydisRegister;
/**
* @brief Values that represent the type of a decoded operand.
*/
typedef enum _ZyDisOperandType /*: uint8_t*/
typedef enum _ZydisOperandType /*: uint8_t*/
{
/**
* @brief The operand is not used.
*/
OPTYPE_NONE,
ZYDIS_OPTYPE_NONE,
/**
* @brief The operand is a register operand.
*/
OPTYPE_REGISTER,
ZYDIS_OPTYPE_REGISTER,
/**
* @brief The operand is a memory operand.
*/
OPTYPE_MEMORY,
ZYDIS_OPTYPE_MEMORY,
/**
* @brief The operand is a pointer operand.
*/
OPTYPE_POINTER,
ZYDIS_OPTYPE_POINTER,
/**
* @brief The operand is an immediate operand.
*/
OPTYPE_IMMEDIATE,
ZYDIS_OPTYPE_IMMEDIATE,
/**
* @brief The operand is a relative immediate operand.
*/
OPTYPE_REL_IMMEDIATE,
ZYDIS_OPTYPE_REL_IMMEDIATE,
/**
* @brief The operand is a constant value.
*/
OPTYPE_CONSTANT
} ZyDisOperandType;
ZYDIS_OPTYPE_CONSTANT
} ZydisOperandType;
/**
* @brief Values that represent the operand access mode.
*/
typedef enum _ZyDisOperandAccessMode /* : uint8_t */
typedef enum _ZydisOperandAccessMode /* : uint8_t */
{
OPACCESSMODE_NA,
ZYDIS_OPACCESSMODE_NA,
/**
* @brief The operand is accessed in read-only mode.
*/
OPACCESSMODE_READ,
ZYDIS_OPACCESSMODE_READ,
/**
* @brief The operand is accessed in write mode.
*/
OPACCESSMODE_WRITE,
ZYDIS_OPACCESSMODE_WRITE,
/**
* @brief The operand is accessed in read-write mode.
*/
OPACCESSMODE_READWRITE
} ZyDisOperandAccessMode;
ZYDIS_OPACCESSMODE_READWRITE
} ZydisOperandAccessMode;
/**
* @brief This struct holds information about a decoded operand.
*/
typedef struct _ZyDisOperandInfo
typedef struct _ZydisOperandInfo
{
/**
* @brief The type of the operand.
* @see ZyDisOperandType
* @see ZydisOperandType
*/
uint8_t type;
/**
@ -265,17 +263,17 @@ typedef struct _ZyDisOperandInfo
uint16_t size;
/**
* @brief The operand access mode.
* @see ZyDisOperandAccessMode
* @see ZydisOperandAccessMode
*/
uint8_t access_mode;
/**
* @brief The base register.
* @see ZyDisRegister
* @see ZydisRegister
*/
uint16_t base;
/**
* @brief The index register.
* @see ZyDisRegister
* @see ZydisRegister
*/
uint16_t index;
/**
@ -308,12 +306,12 @@ typedef struct _ZyDisOperandInfo
uint32_t off;
} ptr;
} lval;
} ZyDisOperandInfo;
} ZydisOperandInfo;
/**
* @brief This struct holds information about a decoded instruction.
*/
typedef struct _ZyDisInstructionInfo
typedef struct _ZydisInstructionInfo
{
/**
* @brief The instruction flags.
@ -321,7 +319,7 @@ typedef struct _ZyDisInstructionInfo
uint32_t flags;
/**
* @brief The instruction mnemonic.
* @see ZyDisInstructionMnemonic
* @see ZydisInstructionMnemonic
*/
uint16_t mnemonic;
/**
@ -351,11 +349,11 @@ typedef struct _ZyDisInstructionInfo
/**
* @brief The decoded operands.
*/
ZyDisOperandInfo operand[4];
ZydisOperandInfo operand[4];
/**
* @brief The segment register. This value will default to @c NONE, if no segment register
* prefix is present.
* @see ZyDisRegister
* @see ZydisRegister
*/
uint16_t segment;
/**
@ -527,7 +525,7 @@ typedef struct _ZyDisInstructionInfo
/**
* @brief The instruction definition.
*/
const ZyDisInstructionDefinition *instrDefinition;
const void* instrDefinition; /* TODO: Port instruction definition types */
/**
* @brief The instruction address points to the current instruction (relative to the
* initial instruction pointer).
@ -539,10 +537,10 @@ typedef struct _ZyDisInstructionInfo
* This field is used to properly format relative instructions.
*/
uint64_t instrPointer;
} ZyDisInstructionInfo;
} ZydisInstructionInfo;
#ifdef __cplusplus
}
#endif
#endif /* _VDE_ZyDisDISASSEMBLERTYPESC_H_ */
#endif /* _ZYDIS_TYPES_H_ */

46
Bindings/C/ZydisUtils.cpp Normal file
View File

@ -0,0 +1,46 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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.
***************************************************************************************************/
#include "ZydisUtils.h"
#include "ZydisUtils.hpp"
static_assert(
sizeof(ZydisInstructionInfo) == sizeof(Zydis::InstructionInfo),
"struct size mismatch");
static_assert(
sizeof(ZydisOperandInfo) == sizeof(Zydis::OperandInfo),
"struct size mismatch");
uint64_t ZydisCalcAbsoluteTarget(const ZydisInstructionInfo *info, const ZydisOperandInfo *operand)
{
return Zydis::CalcAbsoluteTarget(
*reinterpret_cast<const Zydis::InstructionInfo*>(info),
*reinterpret_cast<const Zydis::OperandInfo*>(operand));
}

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 04. February 2015
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,40 +26,29 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
***************************************************************************************************/
#ifndef _VDE_ZyDisDISASSEMBLERUTILSC_H_
#define _VDE_ZyDisDISASSEMBLERUTILSC_H_
#include "ZyDisDisassemblerTypes.h"
#include "ZyDisInternalConfig.h"
#ifndef _ZYDIS_UTILS_H_
#define _ZYDIS_UTILS_H_
#include <stdint.h>
#include "ZydisTypes.h"
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct _ZyDisContextDescriptor
{
uint8_t type;
void *ptr;
} ZyDisContextDescriptor;
/**
* @brief Calculates the absolute target address of a relative instruction operand.
* @param info The instruction info.
* @param operand The operand.
* @return The absolute target address.
*/
ZYDIS_EXPORT uint64_t ZyDisCalcAbsoluteTarget(
const ZyDisInstructionInfo *info,
const ZyDisOperandInfo *operand);
uint64_t ZydisCalcAbsoluteTarget(const ZydisInstructionInfo* info, const ZydisOperandInfo* operand);
#ifdef __cplusplus
}
#endif
#endif /* _VDE_ZyDisDISASSEMBLERUTILSC_H_ */
#endif /* _ZYDIS_UTILS_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)
include(GenerateExportHeader)
project(VerteronDisassemblerEngine)
project(ZyanDisassemblerEngine)
option(BUILD_SHARED_LIBS "Build shared libraries rather than static ones" FALSE)
option(FORCE_SHARED_CRT

View File

@ -0,0 +1,86 @@
#include <Zydis.h>
#include <stdio.h>
#include <stdint.h>
int main()
{
uint8_t data32[] =
{
0x8B, 0xFF, 0x55, 0x8B, 0xEC, 0x6A, 0xFE, 0x68, 0xD8, 0x18, 0x09, 0x77, 0x68, 0x85, 0xD2,
0x09, 0x77, 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x50, 0x83, 0xEC, 0x14, 0x53, 0x56, 0x57,
0xA1, 0x68, 0xEE, 0x13, 0x77, 0x31, 0x45, 0xF8, 0x33, 0xC5, 0x50, 0x8D, 0x45, 0xF0, 0x64,
0xA3, 0x00, 0x00, 0x00, 0x00, 0x89, 0x65, 0xE8, 0xC7, 0x45, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x8B, 0x5D, 0x08, 0xF6, 0xC3, 0x04, 0x0F, 0x85, 0x57, 0x74, 0x00, 0x00, 0x53, 0x6A, 0x00,
0xFF, 0x35, 0xA0, 0xE3, 0x13, 0x77, 0xFF, 0x15, 0x00, 0x10, 0x14, 0x77, 0x85, 0xC0, 0x0F,
0x84, 0xC6, 0x48, 0x04, 0x00, 0xC7, 0x45, 0x08, 0x00, 0x00, 0x00, 0x00, 0xC7, 0x45, 0xFC,
0xFE, 0xFF, 0xFF, 0xFF, 0x33, 0xC0, 0x8B, 0x4D, 0xF0, 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00,
0x00, 0x59, 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC2, 0x04, 0x00
};
uint8_t data64[] =
{
0x48, 0x89, 0x5C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x89, 0x4C, 0x24, 0x08, 0x57,
0x41, 0x54, 0x41, 0x55, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x40, 0x4C, 0x8B, 0xF2,
0x8B, 0xD9, 0x48, 0xC7, 0x44, 0x24, 0x20, 0x00, 0x00, 0x00, 0x00, 0x33, 0xF6, 0x48, 0x89,
0x74, 0x24, 0x30, 0x45, 0x33, 0xFF, 0xF7, 0xC1, 0x8D, 0xF0, 0xFF, 0xFF, 0x0F, 0x85, 0xAA,
0x53, 0x08, 0x00, 0xF6, 0xC1, 0x40, 0x8B, 0xFE, 0x41, 0xBD, 0x08, 0x00, 0x00, 0x00, 0x41,
0x0F, 0x45, 0xFD, 0xF6, 0xC1, 0x02, 0x48, 0x8B, 0x0D, 0x10, 0xD4, 0x0E, 0x00, 0x0F, 0x85,
0x40, 0xE1, 0x01, 0x00, 0x8B, 0x15, 0x4C, 0xD5, 0x0E, 0x00, 0x81, 0xC2, 0x00, 0x00, 0x14,
0x00, 0x0B, 0xD7, 0x4D, 0x8B, 0xC6, 0xFF, 0x15, 0x3B, 0x2F, 0x10, 0x00, 0x48, 0x8B, 0xD8,
0x48, 0x85, 0xC0, 0x0F, 0x84, 0x93, 0x78, 0x0A, 0x00, 0x48, 0x8B, 0xC3, 0x48, 0x8B, 0x5C,
0x24, 0x78, 0x48, 0x8B, 0xB4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x48, 0x83, 0xC4, 0x40, 0x41,
0x5F, 0x41, 0x5E, 0x41, 0x5D, 0x41, 0x5C, 0x5F, 0xC3
};
ZydisInstructionInfo info;
ZydisInstructionDecoderContext* decoder = NULL;
ZydisBaseInstructionFormatterContext* formatter = NULL;
ZydisBaseInputContext* input32 = NULL;
ZydisBaseInputContext* input64 = NULL;
decoder = ZydisInstructionDecoder_Create();
formatter = ZydisIntelInstructionFormatter_Create();
input32 = ZydisMemoryInput_Create(&data32[0], sizeof(data32));
input64 = ZydisMemoryInput_Create(&data64[0], sizeof(data64));
ZydisInstructionDecoder_SetDisassemblerMode(decoder, DM_M32BIT);
ZydisInstructionDecoder_SetDataSource(decoder, input32);
ZydisInstructionDecoder_SetInstructionPointer(decoder, 0x77091852);
puts("32 bit test ...\n\n");
while (ZydisInstructionDecoder_DecodeInstruction(decoder, &info))
{
printf("%08X ", (uint32_t)(info.instrAddress & 0xFFFFFFFF));
if (info.flags & ZYDIS_IF_ERROR_MASK)
{
printf("db %02X\n", info.data[0]);
}
else
{
printf("%s\n", ZydisBaseInstructionFormatter_FormatInstruction(formatter, &info));
}
}
puts("\n");
ZydisInstructionDecoder_SetDisassemblerMode(decoder, DM_M64BIT);
ZydisInstructionDecoder_SetDataSource(decoder, input64);
ZydisInstructionDecoder_SetInstructionPointer(decoder, 0x00007FFA39A81930ull);
puts("64 bit test ...\n\n");
while (ZydisInstructionDecoder_DecodeInstruction(decoder, &info))
{
printf("%016llX ", info.instrAddress);
if (info.flags & ZYDIS_IF_ERROR_MASK)
{
printf("db %02X", info.data[0]);
}
else
{
printf("%s\n", ZydisBaseInstructionFormatter_FormatInstruction(formatter, &info));
}
}
getchar();
return 0;
}

View File

@ -1,115 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 29. October 2014
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#include <stdint.h>
#include <iostream>
#include <iomanip>
#include <ZyDisDisassembler.hpp>
using namespace Verteron;
int main(int argc, char* argv[])
{
(void)argc; (void)argv;
uint8_t data32[] =
{
0x8B, 0xFF, 0x55, 0x8B, 0xEC, 0x6A, 0xFE, 0x68, 0xD8, 0x18, 0x09, 0x77, 0x68, 0x85, 0xD2,
0x09, 0x77, 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x50, 0x83, 0xEC, 0x14, 0x53, 0x56, 0x57,
0xA1, 0x68, 0xEE, 0x13, 0x77, 0x31, 0x45, 0xF8, 0x33, 0xC5, 0x50, 0x8D, 0x45, 0xF0, 0x64,
0xA3, 0x00, 0x00, 0x00, 0x00, 0x89, 0x65, 0xE8, 0xC7, 0x45, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x8B, 0x5D, 0x08, 0xF6, 0xC3, 0x04, 0x0F, 0x85, 0x57, 0x74, 0x00, 0x00, 0x53, 0x6A, 0x00,
0xFF, 0x35, 0xA0, 0xE3, 0x13, 0x77, 0xFF, 0x15, 0x00, 0x10, 0x14, 0x77, 0x85, 0xC0, 0x0F,
0x84, 0xC6, 0x48, 0x04, 0x00, 0xC7, 0x45, 0x08, 0x00, 0x00, 0x00, 0x00, 0xC7, 0x45, 0xFC,
0xFE, 0xFF, 0xFF, 0xFF, 0x33, 0xC0, 0x8B, 0x4D, 0xF0, 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00,
0x00, 0x59, 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC2, 0x04, 0x00
};
uint8_t data64[] =
{
0x48, 0x89, 0x5C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x89, 0x4C, 0x24, 0x08, 0x57,
0x41, 0x54, 0x41, 0x55, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x40, 0x4C, 0x8B, 0xF2,
0x8B, 0xD9, 0x48, 0xC7, 0x44, 0x24, 0x20, 0x00, 0x00, 0x00, 0x00, 0x33, 0xF6, 0x48, 0x89,
0x74, 0x24, 0x30, 0x45, 0x33, 0xFF, 0xF7, 0xC1, 0x8D, 0xF0, 0xFF, 0xFF, 0x0F, 0x85, 0xAA,
0x53, 0x08, 0x00, 0xF6, 0xC1, 0x40, 0x8B, 0xFE, 0x41, 0xBD, 0x08, 0x00, 0x00, 0x00, 0x41,
0x0F, 0x45, 0xFD, 0xF6, 0xC1, 0x02, 0x48, 0x8B, 0x0D, 0x10, 0xD4, 0x0E, 0x00, 0x0F, 0x85,
0x40, 0xE1, 0x01, 0x00, 0x8B, 0x15, 0x4C, 0xD5, 0x0E, 0x00, 0x81, 0xC2, 0x00, 0x00, 0x14,
0x00, 0x0B, 0xD7, 0x4D, 0x8B, 0xC6, 0xFF, 0x15, 0x3B, 0x2F, 0x10, 0x00, 0x48, 0x8B, 0xD8,
0x48, 0x85, 0xC0, 0x0F, 0x84, 0x93, 0x78, 0x0A, 0x00, 0x48, 0x8B, 0xC3, 0x48, 0x8B, 0x5C,
0x24, 0x78, 0x48, 0x8B, 0xB4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x48, 0x83, 0xC4, 0x40, 0x41,
0x5F, 0x41, 0x5E, 0x41, 0x5D, 0x41, 0x5C, 0x5F, 0xC3
};
VXInstructionInfo info;
VXInstructionDecoder decoder;
VXIntelInstructionFormatter formatter;
VXMemoryDataSource input32(&data32[0], sizeof(data32));
VXMemoryDataSource input64(&data64[0], sizeof(data64));
decoder.setDisassemblerMode(VXDisassemblerMode::M32BIT);
decoder.setDataSource(&input32);
decoder.setInstructionPointer(0x77091852);
std::cout << "32 bit test ..." << std::endl << std::endl;
while (decoder.decodeInstruction(info))
{
std::cout << std::hex << std::setw(8) << std::setfill('0') << std::uppercase
<< info.instrAddress << " ";
if (info.flags & IF_ERROR_MASK)
{
std::cout << "db " << std::setw(2) << info.data[0];
} else
{
std::cout << formatter.formatInstruction(info) << std::endl;
}
}
std::cout << std::endl;
decoder.setDisassemblerMode(VXDisassemblerMode::M64BIT);
decoder.setDataSource(&input64);
decoder.setInstructionPointer(0x00007FFA39A81930ull);
std::cout << "64 bit test ..." << std::endl << std::endl;
while (decoder.decodeInstruction(info))
{
std::cout << std::hex << std::setw(16) << std::setfill('0') << std::uppercase
<< info.instrAddress << " ";
if (info.flags & IF_ERROR_MASK)
{
std::cout << "db " << std::setw(2) << info.data[0];
} else
{
std::cout << formatter.formatInstruction(info) << std::endl;
}
}
std::cin.get();
return 0;
}

View File

@ -1,123 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 04. February 2015
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#include <ZyDisDisassembler.h>
#include <stdio.h>
#include <stdint.h>
int main()
{
uint8_t data32[] =
{
0x8B, 0xFF, 0x55, 0x8B, 0xEC, 0x6A, 0xFE, 0x68, 0xD8, 0x18, 0x09, 0x77, 0x68, 0x85, 0xD2,
0x09, 0x77, 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x50, 0x83, 0xEC, 0x14, 0x53, 0x56, 0x57,
0xA1, 0x68, 0xEE, 0x13, 0x77, 0x31, 0x45, 0xF8, 0x33, 0xC5, 0x50, 0x8D, 0x45, 0xF0, 0x64,
0xA3, 0x00, 0x00, 0x00, 0x00, 0x89, 0x65, 0xE8, 0xC7, 0x45, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x8B, 0x5D, 0x08, 0xF6, 0xC3, 0x04, 0x0F, 0x85, 0x57, 0x74, 0x00, 0x00, 0x53, 0x6A, 0x00,
0xFF, 0x35, 0xA0, 0xE3, 0x13, 0x77, 0xFF, 0x15, 0x00, 0x10, 0x14, 0x77, 0x85, 0xC0, 0x0F,
0x84, 0xC6, 0x48, 0x04, 0x00, 0xC7, 0x45, 0x08, 0x00, 0x00, 0x00, 0x00, 0xC7, 0x45, 0xFC,
0xFE, 0xFF, 0xFF, 0xFF, 0x33, 0xC0, 0x8B, 0x4D, 0xF0, 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00,
0x00, 0x59, 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC2, 0x04, 0x00
};
uint8_t data64[] =
{
0x48, 0x89, 0x5C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x89, 0x4C, 0x24, 0x08, 0x57,
0x41, 0x54, 0x41, 0x55, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x40, 0x4C, 0x8B, 0xF2,
0x8B, 0xD9, 0x48, 0xC7, 0x44, 0x24, 0x20, 0x00, 0x00, 0x00, 0x00, 0x33, 0xF6, 0x48, 0x89,
0x74, 0x24, 0x30, 0x45, 0x33, 0xFF, 0xF7, 0xC1, 0x8D, 0xF0, 0xFF, 0xFF, 0x0F, 0x85, 0xAA,
0x53, 0x08, 0x00, 0xF6, 0xC1, 0x40, 0x8B, 0xFE, 0x41, 0xBD, 0x08, 0x00, 0x00, 0x00, 0x41,
0x0F, 0x45, 0xFD, 0xF6, 0xC1, 0x02, 0x48, 0x8B, 0x0D, 0x10, 0xD4, 0x0E, 0x00, 0x0F, 0x85,
0x40, 0xE1, 0x01, 0x00, 0x8B, 0x15, 0x4C, 0xD5, 0x0E, 0x00, 0x81, 0xC2, 0x00, 0x00, 0x14,
0x00, 0x0B, 0xD7, 0x4D, 0x8B, 0xC6, 0xFF, 0x15, 0x3B, 0x2F, 0x10, 0x00, 0x48, 0x8B, 0xD8,
0x48, 0x85, 0xC0, 0x0F, 0x84, 0x93, 0x78, 0x0A, 0x00, 0x48, 0x8B, 0xC3, 0x48, 0x8B, 0x5C,
0x24, 0x78, 0x48, 0x8B, 0xB4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x48, 0x83, 0xC4, 0x40, 0x41,
0x5F, 0x41, 0x5E, 0x41, 0x5D, 0x41, 0x5C, 0x5F, 0xC3
};
ZyDisInstructionInfo info;
ZyDisInstructionDecoderContext* decoder = NULL;
ZyDisBaseInstructionFormatterContext* formatter = NULL;
ZyDisBaseDataSourceContext* input32 = NULL;
ZyDisBaseDataSourceContext* input64 = NULL;
decoder = ZyDisInstructionDecoder_Create();
formatter = ZyDisIntelInstructionFormatter_Create();
input32 = ZyDisMemoryDataSource_Create(&data32[0], sizeof(data32));
input64 = ZyDisMemoryDataSource_Create(&data64[0], sizeof(data64));
ZyDisInstructionDecoder_SetDisassemblerMode(decoder, DM_M32BIT);
ZyDisInstructionDecoder_SetDataSource(decoder, input32);
ZyDisInstructionDecoder_SetInstructionPointer(decoder, 0x77091852);
puts("32 bit test ...\n\n");
while (ZyDisInstructionDecoder_DecodeInstruction(decoder, &info))
{
printf("%08X ", (uint32_t)(info.instrAddress & 0xFFFFFFFF));
if (info.flags & IF_ERROR_MASK)
{
printf("db %02X\n", info.data[0]);
}
else
{
printf("%s\n", ZyDisBaseInstructionFormatter_FormatInstruction(formatter, &info));
}
}
puts("\n");
ZyDisInstructionDecoder_SetDisassemblerMode(decoder, DM_M64BIT);
ZyDisInstructionDecoder_SetDataSource(decoder, input64);
ZyDisInstructionDecoder_SetInstructionPointer(decoder, 0x00007FFA39A81930ull);
puts("64 bit test ...\n\n");
while (ZyDisInstructionDecoder_DecodeInstruction(decoder, &info))
{
printf("%016llX ", info.instrAddress);
if (info.flags & IF_ERROR_MASK)
{
printf("db %02X", info.data[0]);
}
else
{
printf("%s\n", ZyDisBaseInstructionFormatter_FormatInstruction(formatter, &info));
}
}
ZyDisBaseDataSource_Release(input32);
ZyDisBaseDataSource_Release(input64);
ZyDisBaseInstructionFormatter_Release(formatter);
ZyDisInstructionDecoder_Release(decoder);
getchar();
return 0;
}

View File

@ -1,195 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
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.
**************************************************************************************************/
#include <ZyDisDisassembler.h>
#include <Windows.h>
int main(int argc, char* argv[])
{
ZYDIS_UNUSED(argc); ZYDIS_UNUSED(argv);
// TODO: port to C
/*
// Find module base in memory
void *moduleBase = GetModuleHandle("kernel32.dll");
uintptr_t baseAddress = (uintptr_t)moduleBase;
// Parse PE headers
PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)moduleBase;
if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE)
{
return 1;
}
PIMAGE_NT_HEADERS ntHeaders = (PIMAGE_NT_HEADERS)(baseAddress + dosHeader->e_lfanew);
if (ntHeaders->Signature != IMAGE_NT_SIGNATURE)
{
return 1;
}
// Initialize disassembler
ZyDisInstructionInfo info;
ZyDisInstructionDecoder decoder;
ZyDisExactSymbolResolver resolver;
ZyDisIntelInstructionFormatter formatter;
#ifdef _M_X64
decoder.setDisassemblerMode(ZyDisDisassemblerMode::M64BIT);
#else
decoder.setDisassemblerMode(ZyDisDisassemblerMode::M32BIT);
#endif
formatter.setSymbolResolver(&resolver);
// Initialize output stream
std::ofstream out;
out.open(".\\output.txt");
// Find all call and jump targets
uint64_t subCount = 0;
uint64_t locCount = 0;
PIMAGE_SECTION_HEADER sectionHeader =
reinterpret_cast<PIMAGE_SECTION_HEADER>(
reinterpret_cast<uintptr_t>(ntHeaders) + sizeof(IMAGE_NT_HEADERS)
+ ntHeaders->FileHeader.SizeOfOptionalHeader - sizeof(IMAGE_OPTIONAL_HEADER));
for (unsigned int i = 0; i < ntHeaders->FileHeader.NumberOfSections; ++i)
{
if (sectionHeader->Characteristics & IMAGE_SCN_CNT_CODE)
{
ZyDisMemoryDataSource input(reinterpret_cast<const void*>(
baseAddress + sectionHeader->VirtualAddress), sectionHeader->SizeOfRawData);
decoder.setDataSource(&input);
decoder.setInstructionPointer(baseAddress + sectionHeader->VirtualAddress);
while (decoder.decodeInstruction(info))
{
// Skip invalid and non-relative instructions
if ((info.flags & IF_ERROR_MASK) || !(info.flags & IF_RELATIVE))
{
continue;
}
switch (info.mnemonic)
{
case ZyDisInstructionMnemonic::CALL:
resolver.setSymbol(VDECalcAbsoluteTarget(info, info.operand[0]),
std::string("sub_" + std::to_string(subCount)).c_str());
subCount++;
break;
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++;
break;
default:
break;
}
}
}
sectionHeader++;
}
// Add entry point symbol
resolver.setSymbol(baseAddress + ntHeaders->OptionalHeader.AddressOfEntryPoint, "EntryPoint");
// Add exported symbols
if (ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress > 0)
{
PIMAGE_EXPORT_DIRECTORY exports =
reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>(reinterpret_cast<LPBYTE>(baseAddress) +
ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
PDWORD address =
reinterpret_cast<PDWORD>(reinterpret_cast<LPBYTE>(baseAddress) +
exports->AddressOfFunctions);
PDWORD name =
reinterpret_cast<PDWORD>(reinterpret_cast<LPBYTE>(baseAddress) +
exports->AddressOfNames);
PWORD ordinal =
reinterpret_cast<PWORD>(reinterpret_cast<LPBYTE>(baseAddress) +
exports->AddressOfNameOrdinals);
for(unsigned int i = 0; i < exports->NumberOfNames; ++i)
{
resolver.setSymbol(baseAddress + address[ordinal[i]],
reinterpret_cast<char*>(baseAddress) + name[i]);
}
}
// Disassemble
sectionHeader =
reinterpret_cast<PIMAGE_SECTION_HEADER>(
reinterpret_cast<uintptr_t>(ntHeaders) + sizeof(IMAGE_NT_HEADERS)
+ ntHeaders->FileHeader.SizeOfOptionalHeader - sizeof(IMAGE_OPTIONAL_HEADER));
for (unsigned int i = 0; i < ntHeaders->FileHeader.NumberOfSections; ++i)
{
if (sectionHeader->Characteristics & IMAGE_SCN_CNT_CODE)
{
ZyDisMemoryDataSource input(reinterpret_cast<const void*>(
baseAddress + sectionHeader->VirtualAddress), sectionHeader->SizeOfRawData);
decoder.setDataSource(&input);
decoder.setInstructionPointer(baseAddress + sectionHeader->VirtualAddress);
while (decoder.decodeInstruction(info))
{
uint64_t offset;
const char *symbol = resolver.resolveSymbol(info, info.instrAddress, offset);
if (symbol)
{
out << symbol << ": " << std::endl;
}
out << " " << std::hex << std::setw(16) << std::setfill('0')
<< info.instrAddress << " ";
if (info.flags & IF_ERROR_MASK)
{
out << "db " << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(info.data[0]) << std::endl;
} else
{
out << formatter.formatInstruction(info) << std::endl;
}
}
}
sectionHeader++;
}
out.close();
*/
return 0;
}

View File

@ -1,4 +1,4 @@
Verteron Disassembler Engine (VDE)
Zyan Disassembler Engine (Zydis)
==================================
Fast and lightweight x86/x86-64 disassembler library.
@ -18,15 +18,15 @@ Fast and lightweight x86/x86-64 disassembler library.
## Quick Example ##
The following example program uses VDE to disassemble a given memory buffer and prints the output to the console.
The following example program uses Zydis to disassemble a given memory buffer and prints the output to the console.
```C++
#include <tchar.h>
#include <iostream>
#include <stdint.h>
#include "VXDisassembler.h"
#include "Zydis.hpp"
using namespace Verteron;
using namespace Zydis;
int _tmain(int argc, _TCHAR* argv[])
{
@ -34,13 +34,13 @@ int _tmain(int argc, _TCHAR* argv[])
{
0x90, 0xE9, 0x00, 0x00, 0x00, 0x00, 0xC3
};
VXMemoryDataSource input(&data[0], sizeof(data));
VXInstructionInfo info;
VXInstructionDecoder decoder;
decoder.setDisassemblerMode(VXDisassemblerMode::M32BIT);
MemoryInput input(&data[0], sizeof(data));
InstructionInfo info;
InstructionDecoder decoder;
decoder.setDisassemblerMode(ZydisMode::M32BIT);
decoder.setDataSource(&input);
decoder.setInstructionPointer(0);
VXIntelInstructionFormatter formatter;
IntelInstructionFormatter formatter;
while (decoder.decodeInstruction(info))
{
std::cout << formatter.formatInstruction(info) << std::endl;
@ -50,8 +50,8 @@ int _tmain(int argc, _TCHAR* argv[])
## Compilation ##
- While VDE supports other compilers in theory, compilation has not been tested with any compiler other than MSVC12 (Visual Studio 2013)
- While Zydis supports other compilers in theory, compilation has not been tested with any compiler other than MSVC12 (Visual Studio 2013)
- Multi-compiler support might be added in the future
## License ##
Verteron Disassembler Engine is licensed under the MIT License. Dependencies are under their respective licenses.
Zyan Disassembler Engine is licensed under the MIT License. Dependencies are under their respective licenses.

View File

@ -1,41 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 04. February 2015
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#ifndef _VDE_ZyDisDISASSEMBLERC_H_
#define _VDE_ZyDisDISASSEMBLERC_H_
#include "ZyDisDisassemblerTypes.h"
#include "ZyDisInstructionDecoder.h"
#include "ZyDisInstructionFormatter.h"
#include "ZyDisDisassemblerUtils.h"
#endif /* _VDE_ZyDisDISASSEMBLERC_H_ */

View File

@ -1,74 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 13. 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.
**************************************************************************************************/
#include "ZyDisDisassemblerUtils.h"
#include <assert.h>
uint64_t ZyDisCalcAbsoluteTarget(const ZyDisInstructionInfo *info, const ZyDisOperandInfo *operand)
{
assert((operand->type == OPTYPE_REL_IMMEDIATE) ||
((operand->type == OPTYPE_MEMORY) && (operand->base == REG_RIP)));
uint64_t truncMask = 0xFFFFFFFFFFFFFFFFull;
if (!(info->flags & IF_DISASSEMBLER_MODE_64))
{
truncMask >>= (64 - info->operand_mode);
}
uint16_t size = operand->size;
if ((operand->type == OPTYPE_MEMORY) && (operand->base == REG_RIP))
{
size = operand->offset;
}
switch (size)
{
case 8:
return (info->instrPointer + operand->lval.sbyte) & truncMask;
case 16:
{
uint32_t delta = operand->lval.sword & truncMask;
if ((info->instrPointer + delta) > 0xFFFF)
{
return (info->instrPointer & 0xF0000) + ((info->instrPointer + delta) & 0xFFFF);
}
return info->instrPointer + delta;
}
case 32:
return (info->instrPointer + operand->lval.sdword) & truncMask;
default:
assert(0);
}
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,174 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
Last change : 14. March 2015
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#ifndef _VDE_ZyDisINSTRUCTIONFORMATTERC_H_
#define _VDE_ZyDisINSTRUCTIONFORMATTERC_H_
#include "ZyDisDisassemblerTypes.h"
#include "ZyDisDisassemblerUtils.h"
#ifdef __cplusplus
extern "C"
{
#endif
/* ZyDisBaseSymbolResolver ======================================================================== */
typedef struct _ZyDisBaseSymbolResolverContext
{
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.
*/
ZYDIS_EXPORT void ZyDisBaseSymbolResolver_Release(
ZyDisBaseSymbolResolverContext *ctx);
/**
* @brief Resolves a symbol.
* @param ctx The symbol resolver context.
* @param info The instruction info.
* @param address The address.
* @param offset Pointer to an unsigned 64 bit integer that receives an offset relative to
* the base address of the symbol.
* @return The name of the symbol if the symbol was found, else @c NULL.
*/
ZYDIS_EXPORT const char* ZyDisBaseSymbolResolver_ResolveSymbol(
ZyDisBaseSymbolResolverContext *ctx,
const ZyDisInstructionInfo *info,
uint64_t address,
uint64_t *offset);
/* ZyDisCustomSymbolResolver ====================================================================== */
typedef const char* (*ZyDisCustomSymbolResolver_ResolveSymbolCallback)(
const ZyDisInstructionInfo *info,
uint64_t address,
uint64_t *offset,
void *userData);
/**
* @brief Creates a custom symbol resolver.
* @param resolverCb The resolver callback consulted when symbols need to be resolved.
* @param userData A pointer to arbitrary data passed to the resolver callback.
* May also be @c NULL.
* @return @c NULL if it fails, else a symbol resolver context.
*/
ZYDIS_EXPORT ZyDisBaseSymbolResolverContext* ZyDisCustomSymbolResolver_Create(
ZyDisCustomSymbolResolver_ResolveSymbolCallback resolverCb,
void *userData);
/* ZyDisBaseInstructionFormatter ================================================================== */
typedef struct _ZyDisBaseInstructionFormatterContext
{
ZyDisContextDescriptor d;
} ZyDisBaseInstructionFormatterContext;
typedef void(*ZyDisBaseInstructionFormatter_InternalFormatInstructionCallback)(
ZyDisBaseInstructionFormatterContext *ctx, const ZyDisInstructionInfo *info);
/**
* @brief Formats a decoded instruction.
* @param ctx The instruction formatter context.
* @param info The instruction info.
* @return Pointer to the formatted instruction string. This pointer remains valid until
* this function is called again or the context is released.
*/
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.
*/
ZYDIS_EXPORT ZyDisBaseSymbolResolverContext* ZyDisBaseInstructionFormatter_GetSymbolResolver(
const ZyDisBaseInstructionFormatterContext *ctx);
/**
* @brief Sets a new symbol resolver.
* @param ctx The instruction formatter context.
* @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol
* resolver should be used.
*/
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.
*/
ZYDIS_EXPORT void ZyDisBaseInstructionFormatter_Release(
ZyDisBaseInstructionFormatterContext *ctx);
/* ZyDisIntelInstructionFormatter ================================================================= */
/**
* @brief Creates an Intel-syntax instruction formatter.
* @return @c NULL if it fails, else an Intel instruction formatter context.
* @see ZyDisBaseInstructionFormatter_Release
*/
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 ZyDisBaseInstructionFormatter_Release
*/
ZYDIS_EXPORT ZyDisBaseInstructionFormatterContext* ZyDisIntelInstructionFormatter_CreateEx(
ZyDisBaseSymbolResolverContext *resolver);
/* 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.
*/
ZYDIS_EXPORT ZyDisBaseInstructionFormatterContext* ZyDisCustomInstructionFormatter_Create(
ZyDisBaseInstructionFormatter_InternalFormatInstructionCallback formatInsnCb);
/* ============================================================================================= */
#ifdef __cplusplus
}
#endif
#endif /* _VDE_ZyDisINSTRUCTIONFORMATTERC_H_ */

View File

@ -1,50 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : athre0z
Modifications :
Last change : 16. 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.
**************************************************************************************************/
/*
* Include CMake generated header defining macros im-/exporting functions statically or
* dynamically depending what the user requested from CMake.
*/
#include "ZyDisExportConfig.h"
#ifndef _VDE_ZyDisINTERNALCONFIG_H_
#define _VDE_ZyDisINTERNALCONFIG_H_
#ifdef _MSC_VER
# define ZYDIS_INLINE __inline
#else
# define ZYDIS_INLINE static inline
#endif
#define ZYDIS_UNUSED(x) ((void)x)
#endif /* _VDE_ZyDisINTERNALCONFIG_H_ */

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,313 +0,0 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : athre0z
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_ZyDisOPCODETABLEINTERNAL_H_
#define _VDE_ZyDisOPCODETABLEINTERNAL_H_
#include <stdint.h>
#include "ZyDisOpcodeTable.h"
/**
* @brief Contains all opcode tables.
* Indexed by the numeric value of the opcode.
*/
extern const ZyDisOpcodeTreeNode vxOptreeTable[][256];
/**
* @brief Contains all modrm_mod switch tables.
* Index values:
* 0 = [modrm_mod == !11]
* 1 = [modrm_mod == 11]
*/
extern const ZyDisOpcodeTreeNode vxOptreeModrmMod[][2];
/**
* @brief Contains all modrm_reg switch tables.
* Indexed by the numeric value of the modrm_reg field.
*/
extern const ZyDisOpcodeTreeNode vxOptreeModrmReg[][8];
/**
* @brief Contains all modrm_rm switch tables.
* Indexed by the numeric value of the modrm_rm field.
*/
extern const ZyDisOpcodeTreeNode vxOptreeModrmRm[][8];
/**
* @brief Contains all mandatory-prefix switch tables.
* Index values:
* 0 = none
* 1 = F2
* 2 = F3
* 3 = 66
*/
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 ZyDisOpcodeTreeNode vxOptreeX87[][64];
/**
* @brief Contains all address-size switch tables.
* Index values:
* 0 = 16
* 1 = 32
* 2 = 64
*/
extern const ZyDisOpcodeTreeNode vxOptreeAddressSize[][3];
/**
* @brief Contains all operand-size switch tables.
* Index values:
* 0 = 16
* 1 = 32
* 2 = 64
*/
extern const ZyDisOpcodeTreeNode vxOptreeOperandSize[][3];
/**
* @brief Contains all cpu-mode switch tables.
* Index values:
* 0 = [!= 64]
* 1 = 64
*/
extern const ZyDisOpcodeTreeNode vxOptreeMode[][2];
/**
* @brief Contains all vendor switch tables.
* Index values:
* 0 = AMD
* 1 = Intel
*/
extern const ZyDisOpcodeTreeNode vxOptreeVendor[][2];
/**
* @brief Contains all 3DNow! switch tables.
* Indexed by the numeric value of the 3DNow! opcode.
*/
extern const ZyDisOpcodeTreeNode vxOptree3dnow[][256];
/**
* @brief Contains all vex switch tables.
* Index values:
* 0 = none
* 1 = 0F
* 2 = 0F38
* 3 = 0F3A
* 4 = 66
* 5 = 66_0F
* 6 = 66_0F38
* 7 = 66_0F3A
* 8 = F3
* 9 = F3_0F
* A = F3_0F38
* B = F3_0F3A
* C = F2
* D = F2_0F
* E = F2_0F38
* F = F2_0F3A
*/
extern const ZyDisOpcodeTreeNode vxOptreeVex[][16];
/**
* @brief Contains all vex_w switch tables.
* Indexed by the numeric value of the vex_w field.
*/
extern const ZyDisOpcodeTreeNode vxOptreeVexW[][2];
/**
* @brief Contains all vex_l switch tables.
* Indexed by the numeric value of the vex_l field.
*/
extern const ZyDisOpcodeTreeNode vxOptreeVexL[][2];
/**
* @brief Contains all instruction definitions.
*/
extern const ZyDisInstructionDefinition vxInstrDefinitions[];
/**
* @brief Contains all instruction mnemonic strings.
*/
extern const char* vxInstrMnemonicStrings[];
/**
* @brief Returns the type of the specified opcode tree node.
* @param node The node.
* @return The type of the specified opcode tree node.
*/
ZYDIS_INLINE ZyDisOpcodeTreeNodeType ZyDisGetOpcodeNodeType(ZyDisOpcodeTreeNode node)
{
return (ZyDisOpcodeTreeNodeType)((node >> 12) & 0x0F);
}
/**
* @brief Returns the value of the specified opcode tree node.
* @param node The node.
* @return The value of the specified opcode tree node.
*/
ZYDIS_INLINE uint16_t ZyDisGetOpcodeNodeValue(ZyDisOpcodeTreeNode node)
{
return (node & 0x0FFF);
}
/**
* @brief Returns the root node of the opcode tree.
* @return The root node of the opcode tree.
*/
ZYDIS_INLINE ZyDisOpcodeTreeNode ZyDisGetOpcodeTreeRoot()
{
return 0x1000;
}
/**
* @brief Returns a child node of @c parent specified by @c index.
* @param parent The parent node.
* @param index The index of the child node to retrieve.
* @return The specified child node.
*/
ZYDIS_INLINE ZyDisOpcodeTreeNode ZyDisGetOpcodeTreeChild(ZyDisOpcodeTreeNode parent, uint16_t index)
{
ZyDisOpcodeTreeNodeType nodeType = ZyDisGetOpcodeNodeType(parent);
uint16_t tableIndex = ZyDisGetOpcodeNodeValue(parent);
switch (nodeType)
{
case OTNT_TABLE:
assert(index < 256);
return vxOptreeTable[tableIndex][index];
case OTNT_MODRM_MOD:
assert(index < 2);
return vxOptreeModrmMod[tableIndex][index];
case OTNT_MODRM_REG:
assert(index < 8);
return vxOptreeModrmReg[tableIndex][index];
case OTNT_MODRM_RM:
assert(index < 8);
return vxOptreeModrmRm[tableIndex][index];
case OTNT_MANDATORY:
assert(index < 4);
return vxOptreeMandatory[tableIndex][index];
case OTNT_X87:
assert(index < 64);
return vxOptreeX87[tableIndex][index];
case OTNT_ADDRESS_SIZE:
assert(index < 3);
return vxOptreeAddressSize[tableIndex][index];
case OTNT_OPERAND_SIZE:
assert(index < 3);
return vxOptreeOperandSize[tableIndex][index];
case OTNT_MODE:
assert(index < 2);
return vxOptreeMode[tableIndex][index];
case OTNT_VENDOR:
assert(index < 3);
return vxOptreeVendor[tableIndex][index];
case OTNT_AMD3DNOW:
assert(index < 256);
return vxOptree3dnow[tableIndex][index];
case OTNT_VEX:
assert(index < 16);
return vxOptreeVex[tableIndex][index];
case OTNT_VEXW:
assert(index < 2);
return vxOptreeVexW[tableIndex][index];
case OTNT_VEXL:
assert(index < 2);
return vxOptreeVexL[tableIndex][index];
default:
assert(0);
}
return 0xFFFF;
}
/**
* @brief Returns the instruction definition that is linked to the given @c node.
* @param node The instruction definition node.
* @return Pointer to the instruction definition.
*/
ZYDIS_INLINE const ZyDisInstructionDefinition* ZyDisGetInstructionDefinition(ZyDisOpcodeTreeNode node)
{
assert(ZyDisGetOpcodeNodeType(node) == OTNT_INSTRUCTION_DEFINITION);
return &vxInstrDefinitions[node & 0x0FFF];
}
/**
* @brief Returns the specified instruction mnemonic string.
* @param mnemonic The mnemonic.
* @return The instruction mnemonic string.
*/
ZYDIS_INLINE const char* ZyDisGetInstructionMnemonicString(ZyDisInstructionMnemonic mnemonic)
{
return vxInstrMnemonicStrings[(uint16_t)mnemonic];
}
/**
* @brief Returns the numeric value for a simple operand size definition.
* @param operandSize The defined operand size.
* @return The the numeric value for the simple operand size definition.
*/
ZYDIS_INLINE uint16_t ZyDisGetSimpleOperandSize(ZyDisDefinedOperandSize operandSize)
{
static const uint16_t operandSizes[8] =
{
8, 16, 32, 64, 80, 12, 128, 256
};
uint16_t index = (uint16_t)(operandSize - DOS_B);
assert(index < 8);
return operandSizes[index];
}
/**
* @brief Returns the memory-size part of a complex operand size definition.
* @param operandSize The defined operand size.
* @return The memory-size part of the operand size definition.
*/
ZYDIS_INLINE ZyDisDefinedOperandSize ZyDisGetComplexOperandMemSize(ZyDisDefinedOperandSize operandSize)
{
return (ZyDisDefinedOperandSize)(operandSize & 0x0F);
}
/**
* @brief Returns the register-size part of a complex operand size definition.
* @param operandSize The defined operand size.
* @return The register-size part of the operand size definition.
*/
ZYDIS_INLINE ZyDisDefinedOperandSize ZyDisGetComplexOperandRegSize(ZyDisDefinedOperandSize operandSize)
{
return (ZyDisDefinedOperandSize)((operandSize >> 4) & 0x0F);
}
#endif // _VDE_ZyDisOPCODETABLEINTERNAL_H_

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 29. October 2014
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,11 +26,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
***************************************************************************************************/
#pragma once
#ifndef _ZYDIS_DISASSEMBLER_HPP_
#define _ZYDIS_DISASSEMBLER_HPP_
#include "ZyDisDisassemblerTypes.hpp"
#include "ZyDisInstructionDecoder.hpp"
#include "ZyDisInstructionFormatter.hpp"
#include "ZyDisDisassemblerUtils.hpp"
#include "ZydisInstructionDecoder.hpp"
#include "ZydisInstructionFormatter.hpp"
#include "ZydisSymbolResolver.hpp"
#include "ZydisUtils.hpp"
#endif /*_ZYDIS_DISASSEMBLER_HPP_ */

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 29. October 2014
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,22 +26,24 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#pragma once
***************************************************************************************************/
#ifndef _ZYDIS_INSTRUCTIONDECODER_HPP_
#define _ZYDIS_INSTRUCTIONDECODER_HPP_
#include <type_traits>
#include <istream>
#include "ZyDisDisassemblerTypes.hpp"
#include "ZydisTypes.hpp"
namespace Verteron
namespace Zydis
{
///////////////////////////////////////////////////////////////////////////////////////////////////
/* BaseInput ==================================================================================== */
/**
* @brief The base class for all data-source implementations.
*/
class ZyDisBaseDataSource
class BaseInput
{
private:
uint8_t m_currentInput;
@ -66,12 +66,12 @@ protected:
/**
* @brief Default constructor.
*/
ZyDisBaseDataSource() { };
BaseInput() { };
public:
/**
* @brief Destructor.
*/
virtual ~ZyDisBaseDataSource() { };
virtual ~BaseInput() { };
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(ZyDisInstructionInfo &info);
uint8_t inputPeek(InstructionInfo& 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(ZyDisInstructionInfo &info);
uint8_t inputNext(InstructionInfo& 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(ZyDisInstructionInfo &info);
T inputNext(InstructionInfo& 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 ZyDisBaseDataSource::inputPeek(ZyDisInstructionInfo &info)
inline uint8_t BaseInput::inputPeek(InstructionInfo& info)
{
if (info.length == 15)
{
@ -149,7 +149,7 @@ inline uint8_t ZyDisBaseDataSource::inputPeek(ZyDisInstructionInfo &info)
return m_currentInput;
}
inline uint8_t ZyDisBaseDataSource::inputNext(ZyDisInstructionInfo &info)
inline uint8_t BaseInput::inputNext(InstructionInfo& info)
{
if (info.length == 15)
{
@ -168,14 +168,14 @@ inline uint8_t ZyDisBaseDataSource::inputNext(ZyDisInstructionInfo &info)
}
template <typename T>
inline T ZyDisBaseDataSource::inputNext(ZyDisInstructionInfo &info)
inline T BaseInput::inputNext(InstructionInfo& info)
{
static_assert(std::is_integral<T>::value, "integral type required");
T result = 0;
for (unsigned i = 0; i < (sizeof(T) / sizeof(uint8_t)); ++i)
{
T b = inputNext(info);
if (!b && (info.flags & IF_ERROR_MASK))
if (!b&& (info.flags& IF_ERROR_MASK))
{
return 0;
}
@ -184,20 +184,20 @@ inline T ZyDisBaseDataSource::inputNext(ZyDisInstructionInfo &info)
return result;
}
inline uint8_t ZyDisBaseDataSource::inputCurrent() const
inline uint8_t BaseInput::inputCurrent() const
{
return m_currentInput;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/* MemoryInput ================================================================================== */
/**
* @brief A memory-buffer based data source for the @c ZyDisInstructionDecoder class.
* @brief A memory-buffer based data source for the @c InstructionDecoder class.
*/
class ZyDisMemoryDataSource : public ZyDisBaseDataSource
class MemoryInput : public BaseInput
{
private:
const void *m_inputBuffer;
const void* m_inputBuffer;
uint64_t m_inputBufferLen;
uint64_t m_inputBufferPos;
protected:
@ -219,7 +219,7 @@ public:
* @param buffer The input buffer.
* @param bufferLen The length of the input buffer.
*/
ZyDisMemoryDataSource(const void* buffer, size_t bufferLen)
MemoryInput(const void* buffer, size_t bufferLen)
: m_inputBuffer(buffer)
, m_inputBufferLen(bufferLen)
, m_inputBufferPos(0) { };
@ -242,42 +242,42 @@ public:
bool setPosition(uint64_t position) override;
};
inline uint8_t ZyDisMemoryDataSource::internalInputPeek()
inline uint8_t MemoryInput::internalInputPeek()
{
return *(static_cast<const uint8_t*>(m_inputBuffer) + m_inputBufferPos);
}
inline uint8_t ZyDisMemoryDataSource::internalInputNext()
inline uint8_t MemoryInput::internalInputNext()
{
++m_inputBufferPos;
return *(static_cast<const uint8_t*>(m_inputBuffer) + m_inputBufferPos - 1);
}
inline bool ZyDisMemoryDataSource::isEndOfInput() const
inline bool MemoryInput::isEndOfInput() const
{
return (m_inputBufferPos >= m_inputBufferLen);
}
inline uint64_t ZyDisMemoryDataSource::getPosition() const
inline uint64_t MemoryInput::getPosition() const
{
return m_inputBufferPos;
}
inline bool ZyDisMemoryDataSource::setPosition(uint64_t position)
inline bool MemoryInput::setPosition(uint64_t position)
{
m_inputBufferPos = position;
return isEndOfInput();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/* StreamInput ================================================================================== */
/**
* @brief A stream based data source for the @c ZyDisInstructionDecoder class.
* @brief A stream based data source for the @c InstructionDecoder class.
*/
class ZyDisStreamDataSource : public ZyDisBaseDataSource
class StreamInput : public BaseInput
{
private:
std::istream *m_inputStream;
std::istream* m_inputStream;
protected:
/**
* @brief Reads the next byte from the data source. This method increases the current
@ -296,7 +296,7 @@ public:
* @brief Constructor.
* @param stream The input stream.
*/
explicit ZyDisStreamDataSource(std::istream *stream)
explicit StreamInput(std::istream* stream)
: m_inputStream(stream) { };
public:
/**
@ -317,7 +317,7 @@ public:
bool setPosition(uint64_t position) override;
};
inline uint8_t ZyDisStreamDataSource::internalInputPeek()
inline uint8_t StreamInput::internalInputPeek()
{
if (!m_inputStream)
{
@ -326,7 +326,7 @@ inline uint8_t ZyDisStreamDataSource::internalInputPeek()
return static_cast<uint8_t>(m_inputStream->peek());
}
inline uint8_t ZyDisStreamDataSource::internalInputNext()
inline uint8_t StreamInput::internalInputNext()
{
if (!m_inputStream)
{
@ -335,7 +335,7 @@ inline uint8_t ZyDisStreamDataSource::internalInputNext()
return static_cast<uint8_t>(m_inputStream->get());
}
inline bool ZyDisStreamDataSource::isEndOfInput() const
inline bool StreamInput::isEndOfInput() const
{
if (!m_inputStream)
{
@ -346,7 +346,7 @@ inline bool ZyDisStreamDataSource::isEndOfInput() const
return !m_inputStream->good();
}
inline uint64_t ZyDisStreamDataSource::getPosition() const
inline uint64_t StreamInput::getPosition() const
{
if (!m_inputStream)
{
@ -355,7 +355,7 @@ inline uint64_t ZyDisStreamDataSource::getPosition() const
return m_inputStream->tellg();
}
inline bool ZyDisStreamDataSource::setPosition(uint64_t position)
inline bool StreamInput::setPosition(uint64_t position)
{
if (!m_inputStream)
{
@ -365,12 +365,12 @@ inline bool ZyDisStreamDataSource::setPosition(uint64_t position)
return isEndOfInput();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/* Enums ======================================================================================== */
/**
* @brief Values that represent a disassembler mode.
*/
enum class ZyDisDisassemblerMode : uint8_t
enum class DisassemblerMode : uint8_t
{
M16BIT,
M32BIT,
@ -380,18 +380,20 @@ enum class ZyDisDisassemblerMode : uint8_t
/**
* @brief Values that represent an instruction-set vendor.
*/
enum class ZyDisInstructionSetVendor : uint8_t
enum class InstructionSetVendor : uint8_t
{
ANY,
INTEL,
AMD
};
/* InstructionDecoder =========================================================================== */
/**
* @brief The @c ZyDisInstructionDecoder class decodes x86/x86-64 assembly instructions from a
* @brief The @c InstructionDecoder class decodes x86/x86-64 assembly instructions from a
* given data source.
*/
class ZyDisInstructionDecoder
class InstructionDecoder
{
private:
enum class RegisterClass : uint8_t
@ -404,10 +406,10 @@ private:
XMM
};
private:
ZyDisBaseDataSource *m_dataSource;
ZyDisDisassemblerMode m_disassemblerMode;
ZyDisInstructionSetVendor m_preferredVendor;
uint64_t m_instructionPointer;
BaseInput* m_input;
DisassemblerMode m_disassemblerMode;
InstructionSetVendor m_preferredVendor;
uint64_t m_instructionPointer;
private:
/**
* @brief Reads the next byte from the data source. This method does NOT increase the
@ -417,7 +419,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(ZyDisInstructionInfo &info);
uint8_t inputPeek(InstructionInfo& 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 +430,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(ZyDisInstructionInfo &info);
uint8_t inputNext(InstructionInfo& 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 +442,7 @@ private:
* Possible error values are @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH.
*/
template <typename T>
T inputNext(ZyDisInstructionInfo &info);
T inputNext(InstructionInfo& 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 +453,64 @@ private:
/**
* @brief Decodes a register operand.
* @param info The instruction info.
* @param operand The @c ZyDisOperandInfo struct that receives the decoded data.
* @param operand The @c OperandInfo 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(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand,
RegisterClass registerClass, uint8_t registerId, ZyDisDefinedOperandSize operandSize) const;
bool decodeRegisterOperand(InstructionInfo& info, OperandInfo& operand,
RegisterClass registerClass, uint8_t registerId, DefinedOperandSize operandSize) const;
/**
* @brief Decodes a register/memory operand.
* @param info The instruction info.
* @param operand The @c ZyDisOperandInfo struct that receives the decoded data.
* @param operand The @c OperandInfo 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(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand,
RegisterClass registerClass, ZyDisDefinedOperandSize operandSize);
bool decodeRegisterMemoryOperand(InstructionInfo& info, OperandInfo& operand,
RegisterClass registerClass, DefinedOperandSize operandSize);
/**
* @brief Decodes an immediate operand.
* @param info The instruction info.
* @param operand The @c ZyDisOperandInfo struct that receives the decoded data.
* @param operand The @c OperandInfo 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(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand,
ZyDisDefinedOperandSize operandSize);
bool decodeImmediate(InstructionInfo& info, OperandInfo& operand,
DefinedOperandSize operandSize);
/**
* @brief Decodes a displacement operand.
* @param info The instruction info.
* @param operand The @c ZyDisOperandInfo struct that receives the decoded data.
* @param operand The @c OperandInfo 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(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand, uint8_t size);
bool decodeDisplacement(InstructionInfo& info, OperandInfo& operand, uint8_t size);
private:
/**
* @brief Decodes the modrm field of the instruction. This method reads an additional
* input byte.
* @param The @c ZyDisInstructionInfo struct that receives the decoded data.
* @param The @c InstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeModrm(ZyDisInstructionInfo &info);
bool decodeModrm(InstructionInfo& info);
/**
* @brief Decodes the sib field of the instruction. This method reads an additional
* input byte.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @param info The @c InstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeSIB(ZyDisInstructionInfo &info);
bool decodeSIB(InstructionInfo& 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 ZyDisInstructionInfo struct that receives the decoded data.
* @param info The @c InstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeVex(ZyDisInstructionInfo &info);
bool decodeVex(InstructionInfo& info);
private:
/**
* @brief Returns the effective operand size.
@ -516,59 +518,59 @@ private:
* @param operandSize The defined operand size.
* @return The effective operand size.
*/
uint16_t getEffectiveOperandSize(const ZyDisInstructionInfo &info,
ZyDisDefinedOperandSize operandSize) const;
uint16_t getEffectiveOperandSize(const InstructionInfo& info,
DefinedOperandSize operandSize) const;
/**
* @brief Decodes all instruction operands.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @param info The @c InstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeOperands(ZyDisInstructionInfo &info);
bool decodeOperands(InstructionInfo& info);
/**
* @brief Decodes the specified instruction operand.
* @param info The instruction info.
* @param operand The @c ZyDisOperandInfo struct that receives the decoded data.
* @param operand The @c OperandInfo 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(ZyDisInstructionInfo &info, ZyDisOperandInfo &operand,
ZyDisDefinedOperandType operandType, ZyDisDefinedOperandSize operandSize);
bool decodeOperand(InstructionInfo& info, OperandInfo& operand,
DefinedOperandType operandType, DefinedOperandSize 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 ZyDisInstructionInfo struct that receives the effective operand and
* @param info The @c InstructionInfo struct that receives the effective operand and
* address mode.
*/
void resolveOperandAndAddressMode(ZyDisInstructionInfo &info) const;
void resolveOperandAndAddressMode(InstructionInfo& 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 ZyDisInstructionInfo struct that receives the effective operand and
* @param info The @c InstructionInfo struct that receives the effective operand and
* address mode.
*/
void calculateEffectiveRexVexValues(ZyDisInstructionInfo &info) const;
void calculateEffectiveRexVexValues(InstructionInfo& info) const;
private:
/**
* @brief Collects and decodes optional instruction prefixes.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @param info The @c InstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodePrefixes(ZyDisInstructionInfo &info);
bool decodePrefixes(InstructionInfo& info);
/**
* @brief Collects and decodes the instruction opcodes using the opcode tree.
* @param info The @c ZyDisInstructionInfo struct that receives the decoded data.
* @param info The @c InstructionInfo struct that receives the decoded data.
* @return True if it succeeds, false if it fails.
*/
bool decodeOpcode(ZyDisInstructionInfo &info);
bool decodeOpcode(InstructionInfo& info);
public:
/**
* @brief Default constructor.
*/
ZyDisInstructionDecoder();
InstructionDecoder();
/**
* @brief Constructor.
* @param input A reference to the input data source.
@ -576,51 +578,51 @@ public:
* @param preferredVendor The preferred instruction-set vendor.
* @param instructionPointer The initial instruction pointer.
*/
explicit ZyDisInstructionDecoder(ZyDisBaseDataSource *input,
ZyDisDisassemblerMode disassemblerMode = ZyDisDisassemblerMode::M32BIT,
ZyDisInstructionSetVendor preferredVendor = ZyDisInstructionSetVendor::ANY,
explicit InstructionDecoder(BaseInput* input,
DisassemblerMode disassemblerMode = DisassemblerMode::M32BIT,
InstructionSetVendor preferredVendor = InstructionSetVendor::ANY,
uint64_t instructionPointer = 0);
public:
/**
* @brief Decodes the next instruction from the input data source.
* @param info The @c ZyDisInstructionInfo struct that receives the information about the
* @param info The @c InstructionInfo 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(ZyDisInstructionInfo &info);
bool decodeInstruction(InstructionInfo& info);
public:
/**
* @brief Returns a pointer to the current data source.
* @return A pointer to the current data source.
*/
ZyDisBaseDataSource* getDataSource() const;
BaseInput* getDataSource() const;
/**
* @brief Sets a new data source.
* @param input A reference to the new input data source.
*/
void setDataSource(ZyDisBaseDataSource *input);
void setDataSource(BaseInput* input);
/**
* @brief Returns the current disassembler mode.
* @return The current disassembler mode.
*/
ZyDisDisassemblerMode getDisassemblerMode() const;
DisassemblerMode getDisassemblerMode() const;
/**
* @brief Sets the current disassembler mode.
* @param disassemblerMode The new disassembler mode.
*/
void setDisassemblerMode(ZyDisDisassemblerMode disassemblerMode);
void setDisassemblerMode(DisassemblerMode disassemblerMode);
/**
* @brief Returns the preferred instruction-set vendor.
* @return The preferred instruction-set vendor.
*/
ZyDisInstructionSetVendor getPreferredVendor() const;
InstructionSetVendor getPreferredVendor() const;
/**
* @brief Sets the preferred instruction-set vendor.
* @param preferredVendor The new preferred instruction-set vendor.
*/
void setPreferredVendor(ZyDisInstructionSetVendor preferredVendor);
void setPreferredVendor(InstructionSetVendor preferredVendor);
/**
* @brief Returns the current instruction pointer.
* @return The current instruction pointer.
@ -633,86 +635,88 @@ public:
void setInstructionPointer(uint64_t instructionPointer);
};
inline uint8_t ZyDisInstructionDecoder::inputPeek(ZyDisInstructionInfo &info)
inline uint8_t InstructionDecoder::inputPeek(InstructionInfo& info)
{
if (!m_dataSource)
if (!m_input)
{
info.flags |= IF_ERROR_END_OF_INPUT;
return 0;
}
return m_dataSource->inputPeek(info);
return m_input->inputPeek(info);
}
inline uint8_t ZyDisInstructionDecoder::inputNext(ZyDisInstructionInfo &info)
inline uint8_t InstructionDecoder::inputNext(InstructionInfo& info)
{
if (!m_dataSource)
if (!m_input)
{
info.flags |= IF_ERROR_END_OF_INPUT;
return 0;
}
return m_dataSource->inputNext(info);
return m_input->inputNext(info);
}
template <typename T>
inline T ZyDisInstructionDecoder::inputNext(ZyDisInstructionInfo &info)
inline T InstructionDecoder::inputNext(InstructionInfo& info)
{
if (!m_dataSource)
if (!m_input)
{
info.flags |= IF_ERROR_END_OF_INPUT;
return 0;
}
return m_dataSource->inputNext<T>(info);
return m_input->inputNext<T>(info);
}
inline uint8_t ZyDisInstructionDecoder::inputCurrent() const
inline uint8_t InstructionDecoder::inputCurrent() const
{
if (!m_dataSource)
if (!m_input)
{
return 0;
}
return m_dataSource->inputCurrent();
return m_input->inputCurrent();
}
inline ZyDisBaseDataSource* ZyDisInstructionDecoder::getDataSource() const
inline BaseInput *InstructionDecoder::getDataSource() const
{
return m_dataSource;
return m_input;
}
inline void ZyDisInstructionDecoder::setDataSource(ZyDisBaseDataSource *input)
inline void InstructionDecoder::setDataSource(BaseInput* input)
{
m_dataSource = input;
m_input = input;
}
inline ZyDisDisassemblerMode ZyDisInstructionDecoder::getDisassemblerMode() const
inline DisassemblerMode InstructionDecoder::getDisassemblerMode() const
{
return m_disassemblerMode;
}
inline void ZyDisInstructionDecoder::setDisassemblerMode(ZyDisDisassemblerMode disassemblerMode)
inline void InstructionDecoder::setDisassemblerMode(DisassemblerMode disassemblerMode)
{
m_disassemblerMode = disassemblerMode;
}
inline ZyDisInstructionSetVendor ZyDisInstructionDecoder::getPreferredVendor() const
inline InstructionSetVendor InstructionDecoder::getPreferredVendor() const
{
return m_preferredVendor;
}
inline void ZyDisInstructionDecoder::setPreferredVendor(ZyDisInstructionSetVendor preferredVendor)
inline void InstructionDecoder::setPreferredVendor(InstructionSetVendor preferredVendor)
{
m_preferredVendor = preferredVendor;
}
inline uint64_t ZyDisInstructionDecoder::getInstructionPointer() const
inline uint64_t InstructionDecoder::getInstructionPointer() const
{
return m_instructionPointer;
}
inline void ZyDisInstructionDecoder::setInstructionPointer(uint64_t instructionPointer)
inline void InstructionDecoder::setInstructionPointer(uint64_t instructionPointer)
{
m_instructionPointer = instructionPointer;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/* ============================================================================================== */
}
#endif /* _ZYDIS_INSTRUCTIONDECODER_HPP_ */

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 22. October 2014
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,34 +26,20 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#include "ZyDisInstructionFormatter.hpp"
#include "ZyDisDisassemblerUtils.hpp"
***************************************************************************************************/
#include "ZydisInstructionFormatter.hpp"
#include "ZydisUtils.hpp"
#include <cstdarg>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <string>
namespace Verteron
namespace Zydis
{
///////////////////////////////////////////////////////////////////////////////////////////////////
/* BaseInstructionFormatter ================================================================ */
ZyDisBaseSymbolResolver::~ZyDisBaseSymbolResolver()
{
}
const char* ZyDisBaseSymbolResolver::resolveSymbol(const ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset)
{
return nullptr;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
const char* ZyDisBaseInstructionFormatter::m_registerStrings[] =
const char *BaseInstructionFormatter::m_registerStrings[] =
{
/* 8 bit general purpose registers */
"al", "cl", "dl", "bl",
@ -111,12 +95,12 @@ const char* ZyDisBaseInstructionFormatter::m_registerStrings[] =
"rip"
};
void ZyDisBaseInstructionFormatter::internalFormatInstruction(const ZyDisInstructionInfo &info)
void BaseInstructionFormatter::internalFormatInstruction(const InstructionInfo& /*info*/)
{
// Nothing to do here
}
ZyDisBaseInstructionFormatter::ZyDisBaseInstructionFormatter()
BaseInstructionFormatter::BaseInstructionFormatter()
: m_symbolResolver(nullptr)
, m_outputStringLen(0)
, m_outputUppercase(false)
@ -124,7 +108,8 @@ ZyDisBaseInstructionFormatter::ZyDisBaseInstructionFormatter()
}
ZyDisBaseInstructionFormatter::ZyDisBaseInstructionFormatter(ZyDisBaseSymbolResolver *symbolResolver)
BaseInstructionFormatter::BaseInstructionFormatter(
BaseSymbolResolver *symbolResolver)
: m_symbolResolver(symbolResolver)
, m_outputStringLen(0)
, m_outputUppercase(false)
@ -132,7 +117,7 @@ ZyDisBaseInstructionFormatter::ZyDisBaseInstructionFormatter(ZyDisBaseSymbolReso
}
const char* ZyDisBaseInstructionFormatter::formatInstruction(const ZyDisInstructionInfo &info)
const char *BaseInstructionFormatter::formatInstruction(const InstructionInfo& info)
{
// Clears the internal string buffer
outputClear();
@ -141,28 +126,28 @@ const char* ZyDisBaseInstructionFormatter::formatInstruction(const ZyDisInstruct
if (m_outputBuffer.size() == 0)
{
// The basic instruction formatter only returns the instruction menmonic.
return Internal::VDEGetInstructionMnemonicString(info.mnemonic);
return Internal::GetInstructionMnemonicString(info.mnemonic);
}
// Return the formatted instruction string
return outputString();
}
ZyDisBaseInstructionFormatter::~ZyDisBaseInstructionFormatter()
BaseInstructionFormatter::~BaseInstructionFormatter()
{
}
void ZyDisBaseInstructionFormatter::outputClear()
void BaseInstructionFormatter::outputClear()
{
m_outputStringLen = 0;
}
char const* ZyDisBaseInstructionFormatter::outputString()
char const *BaseInstructionFormatter::outputString()
{
return &m_outputBuffer[0];
return& m_outputBuffer[0];
}
void ZyDisBaseInstructionFormatter::outputAppend(char const *text)
void BaseInstructionFormatter::outputAppend(char const *text)
{
// Get the string length including the null-terminator char
size_t strLen = strlen(text) + 1;
@ -191,7 +176,7 @@ char const* ZyDisBaseInstructionFormatter::outputString()
}
}
void ZyDisBaseInstructionFormatter::outputAppendFormatted(char const *format, ...)
void BaseInstructionFormatter::outputAppendFormatted(char const *format, ...)
{
va_list arguments;
va_start(arguments, format);
@ -218,7 +203,7 @@ char const* ZyDisBaseInstructionFormatter::outputString()
// Write the formatted text to the output buffer
assert((bufLen - offset) > 0);
strLen =
std::vsnprintf(&m_outputBuffer[offset], bufLen - offset, format, arguments);
vsnprintf_s(&m_outputBuffer[offset], bufLen - offset, _TRUNCATE, format, arguments);
} while (strLen < 0);
// Increase the string length
m_outputStringLen = offset + strLen + 1;
@ -233,11 +218,11 @@ char const* ZyDisBaseInstructionFormatter::outputString()
va_end(arguments);
}
void ZyDisBaseInstructionFormatter::outputAppendAddress(const ZyDisInstructionInfo &info,
void BaseInstructionFormatter::outputAppendAddress(const InstructionInfo& info,
uint64_t address, bool resolveSymbols)
{
uint64_t offset = 0;
const char* name = nullptr;
const char *name = nullptr;
if (resolveSymbols)
{
name = resolveSymbol(info, address, offset);
@ -253,13 +238,13 @@ void ZyDisBaseInstructionFormatter::outputAppendAddress(const ZyDisInstructionIn
}
} else
{
if (info.flags & IF_DISASSEMBLER_MODE_16)
if (info.flags& IF_DISASSEMBLER_MODE_16)
{
outputAppendFormatted("%.4X", address);
} else if (info.flags & IF_DISASSEMBLER_MODE_32)
} else if (info.flags& IF_DISASSEMBLER_MODE_32)
{
outputAppendFormatted("%.8lX", address);
} else if (info.flags & IF_DISASSEMBLER_MODE_64)
} else if (info.flags& IF_DISASSEMBLER_MODE_64)
{
outputAppendFormatted("%.16llX", address);
} else
@ -269,12 +254,12 @@ void ZyDisBaseInstructionFormatter::outputAppendAddress(const ZyDisInstructionIn
}
}
void ZyDisBaseInstructionFormatter::outputAppendImmediate(const ZyDisInstructionInfo &info,
const ZyDisOperandInfo &operand, bool resolveSymbols)
void BaseInstructionFormatter::outputAppendImmediate(const InstructionInfo& info,
const OperandInfo& operand, bool resolveSymbols)
{
assert(operand.type == ZyDisOperandType::IMMEDIATE);
assert(operand.type == OperandType::IMMEDIATE);
uint64_t value = 0;
if (operand.signed_lval && (operand.size != info.operand_mode))
if (operand.signed_lval&& (operand.size != info.operand_mode))
{
if (operand.size == 8)
{
@ -286,7 +271,7 @@ void ZyDisBaseInstructionFormatter::outputAppendImmediate(const ZyDisInstruction
}
if (info.operand_mode < 64)
{
value = value & ((1ull << info.operand_mode) - 1ull);
value = value& ((1ull << info.operand_mode) - 1ull);
}
} else
{
@ -309,7 +294,7 @@ void ZyDisBaseInstructionFormatter::outputAppendImmediate(const ZyDisInstruction
}
}
uint64_t offset = 0;
const char* name = nullptr;
const char *name = nullptr;
if (resolveSymbols)
{
name = resolveSymbol(info, value, offset);
@ -329,11 +314,10 @@ void ZyDisBaseInstructionFormatter::outputAppendImmediate(const ZyDisInstruction
}
}
void ZyDisBaseInstructionFormatter::outputAppendDisplacement(const ZyDisInstructionInfo &info,
const ZyDisOperandInfo &operand)
void BaseInstructionFormatter::outputAppendDisplacement(const OperandInfo& operand)
{
assert(operand.offset > 0);
if ((operand.base == ZyDisRegister::NONE) && (operand.index == ZyDisRegister::NONE))
if ((operand.base == Register::NONE)&& (operand.index == Register::NONE))
{
// Assume the displacement value is unsigned
assert(operand.scale == 0);
@ -378,16 +362,15 @@ void ZyDisBaseInstructionFormatter::outputAppendDisplacement(const ZyDisInstruct
outputAppendFormatted("-%.2lX", -value);
} else
{
outputAppendFormatted("%s%.2lX", (operand.base != ZyDisRegister::NONE ||
operand.index != ZyDisRegister::NONE) ? "+" : "", value);
outputAppendFormatted("%s%.2lX", (operand.base != Register::NONE ||
operand.index != Register::NONE) ? "+" : "", value);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/* IntelInstructionFormatter =============================================================== */
void ZyDisIntelInstructionFormatter::outputAppendOperandCast(const ZyDisInstructionInfo &info,
const ZyDisOperandInfo &operand)
void IntelInstructionFormatter::outputAppendOperandCast(const OperandInfo& operand)
{
switch(operand.size)
{
@ -417,33 +400,33 @@ void ZyDisIntelInstructionFormatter::outputAppendOperandCast(const ZyDisInstruct
}
}
void ZyDisIntelInstructionFormatter::formatOperand(const ZyDisInstructionInfo &info,
const ZyDisOperandInfo &operand)
void IntelInstructionFormatter::formatOperand(const InstructionInfo& info,
const OperandInfo& operand)
{
switch (operand.type)
{
case ZyDisOperandType::REGISTER:
case OperandType::REGISTER:
outputAppend(registerToString(operand.base));
break;
case ZyDisOperandType::MEMORY:
if (info.flags & IF_PREFIX_SEGMENT)
case OperandType::MEMORY:
if (info.flags& IF_PREFIX_SEGMENT)
{
outputAppendFormatted("%s:", registerToString(info.segment));
}
outputAppend("[");
if (operand.base == ZyDisRegister::RIP)
if (operand.base == Register::RIP)
{
// TODO: Add option
outputAppendAddress(info, VDECalcAbsoluteTarget(info, operand), true);
outputAppendAddress(info, CalcAbsoluteTarget(info, operand), true);
} else
{
if (operand.base != ZyDisRegister::NONE)
if (operand.base != Register::NONE)
{
outputAppend(registerToString(operand.base));
}
if (operand.index != ZyDisRegister::NONE)
if (operand.index != Register::NONE)
{
outputAppendFormatted("%s%s", operand.base != ZyDisRegister::NONE ? "+" : "",
outputAppendFormatted("%s%s", operand.base != Register::NONE ? "+" : "",
registerToString(operand.index));
if (operand.scale)
{
@ -452,18 +435,18 @@ void ZyDisIntelInstructionFormatter::formatOperand(const ZyDisInstructionInfo &i
}
if (operand.offset)
{
outputAppendDisplacement(info, operand);
outputAppendDisplacement(operand);
}
}
outputAppend("]");
break;
case ZyDisOperandType::POINTER:
case OperandType::POINTER:
// TODO: resolve symbols
switch (operand.size)
{
case 32:
outputAppendFormatted("word %.4X:%.4X", operand.lval.ptr.seg,
operand.lval.ptr.off & 0xFFFF);
operand.lval.ptr.off& 0xFFFF);
break;
case 48:
outputAppendFormatted("dword %.4X:%.8lX", operand.lval.ptr.seg, operand.lval.ptr.off);
@ -472,21 +455,21 @@ void ZyDisIntelInstructionFormatter::formatOperand(const ZyDisInstructionInfo &i
assert(0);
}
break;
case ZyDisOperandType::IMMEDIATE:
case OperandType::IMMEDIATE:
{
outputAppendImmediate(info, operand, true);
}
break;
case ZyDisOperandType::REL_IMMEDIATE:
case OperandType::REL_IMMEDIATE:
{
if (operand.size == 8)
{
outputAppend("short ");
}
outputAppendAddress(info, VDECalcAbsoluteTarget(info, operand), true);
outputAppendAddress(info, CalcAbsoluteTarget(info, operand), true);
}
break;
case ZyDisOperandType::CONSTANT:
case OperandType::CONSTANT:
outputAppendFormatted("%.2X", operand.lval.udword);
break;
default:
@ -495,47 +478,47 @@ void ZyDisIntelInstructionFormatter::formatOperand(const ZyDisInstructionInfo &i
}
}
void ZyDisIntelInstructionFormatter::internalFormatInstruction(const ZyDisInstructionInfo &info)
void IntelInstructionFormatter::internalFormatInstruction(const InstructionInfo& info)
{
// Append string prefixes
if (info.flags & IF_PREFIX_LOCK)
if (info.flags& IF_PREFIX_LOCK)
{
outputAppend("lock ");
}
if (info.flags & IF_PREFIX_REP)
if (info.flags& IF_PREFIX_REP)
{
outputAppend("rep ");
} else if (info.flags & IF_PREFIX_REPNE)
} else if (info.flags& IF_PREFIX_REPNE)
{
outputAppend("repne ");
}
// Append the instruction mnemonic
outputAppend(Internal::VDEGetInstructionMnemonicString(info.mnemonic));
outputAppend(Internal::GetInstructionMnemonicString(info.mnemonic));
// Append the first operand
if (info.operand[0].type != ZyDisOperandType::NONE)
if (info.operand[0].type != OperandType::NONE)
{
outputAppend(" ");
bool cast = false;
if (info.operand[0].type == ZyDisOperandType::MEMORY)
if (info.operand[0].type == OperandType::MEMORY)
{
if (info.operand[1].type == ZyDisOperandType::IMMEDIATE ||
info.operand[1].type == ZyDisOperandType::CONSTANT ||
info.operand[1].type == ZyDisOperandType::NONE ||
if (info.operand[1].type == OperandType::IMMEDIATE ||
info.operand[1].type == OperandType::CONSTANT ||
info.operand[1].type == OperandType::NONE ||
(info.operand[0].size != info.operand[1].size))
{
cast = true;
} else if (info.operand[1].type == ZyDisOperandType::REGISTER &&
info.operand[1].base == ZyDisRegister::CL)
} else if (info.operand[1].type == OperandType::REGISTER&&
info.operand[1].base == Register::CL)
{
switch (info.mnemonic)
{
case ZyDisInstructionMnemonic::RCL:
case ZyDisInstructionMnemonic::ROL:
case ZyDisInstructionMnemonic::ROR:
case ZyDisInstructionMnemonic::RCR:
case ZyDisInstructionMnemonic::SHL:
case ZyDisInstructionMnemonic::SHR:
case ZyDisInstructionMnemonic::SAR:
case InstructionMnemonic::RCL:
case InstructionMnemonic::ROL:
case InstructionMnemonic::ROR:
case InstructionMnemonic::RCR:
case InstructionMnemonic::SHL:
case InstructionMnemonic::SHR:
case InstructionMnemonic::SAR:
cast = true;
break;
default:
@ -545,114 +528,75 @@ void ZyDisIntelInstructionFormatter::internalFormatInstruction(const ZyDisInstru
}
if (cast)
{
outputAppendOperandCast(info, info.operand[0]);
outputAppendOperandCast(info.operand[0]);
}
formatOperand(info, info.operand[0]);
}
// Append the second operand
if (info.operand[1].type != ZyDisOperandType::NONE)
if (info.operand[1].type != OperandType::NONE)
{
outputAppend(", ");
bool cast = false;
if (info.operand[1].type == ZyDisOperandType::MEMORY &&
info.operand[0].size != info.operand[1].size &&
((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))))
if (info.operand[1].type == OperandType::MEMORY&&
info.operand[0].size != info.operand[1].size&&
((info.operand[0].type != OperandType::REGISTER) ||
((info.operand[0].base != Register::ES)&&
(info.operand[0].base != Register::CS)&&
(info.operand[0].base != Register::SS)&&
(info.operand[0].base != Register::DS)&&
(info.operand[0].base != Register::FS)&&
(info.operand[0].base != Register::GS))))
{
cast = true;
}
if (cast)
{
outputAppendOperandCast(info, info.operand[1]);
outputAppendOperandCast(info.operand[1]);
}
formatOperand(info, info.operand[1]);
}
// Append the third operand
if (info.operand[2].type != ZyDisOperandType::NONE)
if (info.operand[2].type != OperandType::NONE)
{
outputAppend(", ");
bool cast = false;
if (info.operand[2].type == ZyDisOperandType::MEMORY &&
if (info.operand[2].type == OperandType::MEMORY&&
(info.operand[2].size != info.operand[1].size))
{
cast = true;
}
if (cast)
{
outputAppendOperandCast(info, info.operand[2]);
outputAppendOperandCast(info.operand[2]);
}
formatOperand(info, info.operand[2]);
}
// Append the fourth operand
if (info.operand[3].type != ZyDisOperandType::NONE)
if (info.operand[3].type != OperandType::NONE)
{
outputAppend(", ");
formatOperand(info, info.operand[3]);
}
}
ZyDisIntelInstructionFormatter::ZyDisIntelInstructionFormatter()
: ZyDisBaseInstructionFormatter()
IntelInstructionFormatter::IntelInstructionFormatter()
: BaseInstructionFormatter()
{
}
ZyDisIntelInstructionFormatter::ZyDisIntelInstructionFormatter(ZyDisBaseSymbolResolver* symbolResolver)
: ZyDisBaseInstructionFormatter(symbolResolver)
IntelInstructionFormatter::IntelInstructionFormatter(
BaseSymbolResolver *symbolResolver)
: BaseInstructionFormatter(symbolResolver)
{
}
ZyDisIntelInstructionFormatter::~ZyDisIntelInstructionFormatter()
IntelInstructionFormatter::~IntelInstructionFormatter()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/* ============================================================================================== */
ZyDisExactSymbolResolver::~ZyDisExactSymbolResolver()
{
}
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);
if (iterator != m_symbolMap.cend())
{
offset = 0;
return iterator->second.c_str();
}
return nullptr;
}
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 ZyDisExactSymbolResolver::setSymbol(uint64_t address, const char* name)
{
m_symbolMap[address].assign(name);
}
void ZyDisExactSymbolResolver::removeSymbol(uint64_t address)
{
m_symbolMap.erase(address);
}
void ZyDisExactSymbolResolver::clear()
{
m_symbolMap.clear();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
}
}

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 22. October 2014
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,55 +26,31 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#pragma once
***************************************************************************************************/
#ifndef _ZYDIS_INSTRUCTIONFORMATTER_HPP_
#define _ZYDIS_INSTRUCTIONFORMATTER_HPP_
#include <vector>
#include <unordered_map>
#include <string>
#include "ZyDisDisassemblerTypes.hpp"
#include "ZydisTypes.hpp"
#include "ZydisSymbolResolver.hpp"
namespace Verteron
namespace Zydis
{
///////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @brief Base class for all symbol resolver implementations.
*/
class ZyDisBaseSymbolResolver
{
public:
/**
* @brief Destructor.
*/
virtual ~ZyDisBaseSymbolResolver();
public:
/**
* @brief Resolves a symbol.
* @param info The instruction info.
* @param address The address.
* @param offset Reference to an unsigned 64 bit integer that receives an offset
* relative to the base address of the symbol.
* @return The name of the symbol, if the symbol was found, @c NULL if not.
*/
virtual const char* resolveSymbol(const ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset);
};
///////////////////////////////////////////////////////////////////////////////////////////////////
/* BaseInstructionFormatter ===================================================================== */
/**
* @brief Base class for all instruction formatter implementations.
*/
class ZyDisBaseInstructionFormatter
class BaseInstructionFormatter
{
private:
static const char *m_registerStrings[];
ZyDisBaseSymbolResolver *m_symbolResolver;
std::vector<char> m_outputBuffer;
size_t m_outputStringLen;
bool m_outputUppercase;
static const char* m_registerStrings[];
BaseSymbolResolver* m_symbolResolver;
std::vector<char> m_outputBuffer;
size_t m_outputStringLen;
bool m_outputUppercase;
protected:
/**
* @brief Clears the output string buffer.
@ -91,12 +65,12 @@ protected:
* @brief Appends text to the ouput string buffer.
* @param text The text.
*/
void outputAppend(const char *text);
void outputAppend(const char* text);
/**
* @brief Appends formatted text to the output string buffer.
* @param format The format string.
*/
void outputAppendFormatted(const char *format, ...);
void outputAppendFormatted(const char* format, ...);
/**
* @brief Changes automatic conversion of characters to uppercase.
* @param uppercase Set true to enable automatic uppercase conversion.
@ -109,7 +83,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 ZyDisInstructionInfo &info, uint64_t address,
void outputAppendAddress(const InstructionInfo& info, uint64_t address,
bool resolveSymbols = true);
/**
* @brief Appends a formatted immediate value to the output string buffer.
@ -118,21 +92,20 @@ 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 ZyDisInstructionInfo &info, const ZyDisOperandInfo &operand,
void outputAppendImmediate(const InstructionInfo& info, const OperandInfo& 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 ZyDisInstructionInfo &info, const ZyDisOperandInfo &operand);
void outputAppendDisplacement(const OperandInfo& 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(ZyDisRegister reg) const;
const char *registerToString(Register reg) const;
/**
* @brief Resolves a symbol.
* @param info The instruction info.
@ -141,8 +114,8 @@ 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 ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset) const;
const char* resolveSymbol(const InstructionInfo& info, uint64_t address,
uint64_t& offset) const;
protected:
/**
* @brief Override this method to implement a custom disassembly syntax. Use the
@ -150,59 +123,59 @@ protected:
* string buffer.
* @param info The instruction info.
*/
virtual void internalFormatInstruction(const ZyDisInstructionInfo &info);
virtual void internalFormatInstruction(const InstructionInfo& info);
/**
* @brief Default constructor.
*/
ZyDisBaseInstructionFormatter();
BaseInstructionFormatter();
/**
* @brief Constructor.
* @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol
* resolver should be used.
*/
explicit ZyDisBaseInstructionFormatter(ZyDisBaseSymbolResolver *symbolResolver);
explicit BaseInstructionFormatter(BaseSymbolResolver* symbolResolver);
public:
/**
* @brief Destructor.
*/
virtual ~ZyDisBaseInstructionFormatter();
virtual ~BaseInstructionFormatter();
public:
/**
* @brief Formats a decoded instruction.
* @param info The instruction info.
* @return Pointer to the formatted instruction string.
*/
const char* formatInstruction(const ZyDisInstructionInfo &info);
const char *formatInstruction(const InstructionInfo& 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.
*/
ZyDisBaseSymbolResolver* getSymbolResolver() const;
BaseSymbolResolver* 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(ZyDisBaseSymbolResolver *symbolResolver);
void setSymbolResolver(BaseSymbolResolver* symbolResolver);
};
inline void ZyDisBaseInstructionFormatter::outputSetUppercase(bool uppercase)
inline void BaseInstructionFormatter::outputSetUppercase(bool uppercase)
{
m_outputUppercase = uppercase;
}
inline char const* ZyDisBaseInstructionFormatter::registerToString(ZyDisRegister reg) const
inline char const *BaseInstructionFormatter::registerToString(Register reg) const
{
if (reg == ZyDisRegister::NONE)
if (reg == Register::NONE)
{
return "error";
}
return m_registerStrings[static_cast<uint16_t>(reg) - 1];
}
inline char const* ZyDisBaseInstructionFormatter::resolveSymbol(const ZyDisInstructionInfo &info,
uint64_t address, uint64_t &offset) const
inline char const* BaseInstructionFormatter::resolveSymbol(const InstructionInfo& info,
uint64_t address, uint64_t& offset) const
{
if (m_symbolResolver)
{
@ -211,110 +184,62 @@ inline char const* ZyDisBaseInstructionFormatter::resolveSymbol(const ZyDisInstr
return nullptr;
}
inline ZyDisBaseSymbolResolver* ZyDisBaseInstructionFormatter::getSymbolResolver() const
inline BaseSymbolResolver* BaseInstructionFormatter::getSymbolResolver() const
{
return m_symbolResolver;
}
inline void ZyDisBaseInstructionFormatter::setSymbolResolver(ZyDisBaseSymbolResolver *symbolResolver)
inline void BaseInstructionFormatter::setSymbolResolver(
BaseSymbolResolver* symbolResolver)
{
m_symbolResolver = symbolResolver;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/* IntelInstructionFormatter ==================================================================== */
/**
* @brief Intel syntax instruction formatter.
*/
class ZyDisIntelInstructionFormatter : public ZyDisBaseInstructionFormatter
class IntelInstructionFormatter : public BaseInstructionFormatter
{
private:
/**
* @brief Appends an operand cast to the output string buffer.
* @param info The instruction info.
* @param operand The operand.
*/
void outputAppendOperandCast(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &operand);
void outputAppendOperandCast(const OperandInfo& 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 ZyDisInstructionInfo &info, const ZyDisOperandInfo &operand);
void formatOperand(const InstructionInfo& info, const OperandInfo& operand);
protected:
/**
* @brief Fills the internal string buffer with an intel style formatted instruction string.
* @param info The instruction info.
*/
void internalFormatInstruction(const ZyDisInstructionInfo &info) override;
void internalFormatInstruction(const InstructionInfo& info) override;
public:
/**
* @brief Default constructor.
*/
ZyDisIntelInstructionFormatter();
IntelInstructionFormatter();
/**
* @brief Constructor.
* @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol
* resolver should be used.
*/
explicit ZyDisIntelInstructionFormatter(ZyDisBaseSymbolResolver *symbolResolver);
explicit IntelInstructionFormatter(BaseSymbolResolver* symbolResolver);
/**
* @brief Destructor.
*/
~ZyDisIntelInstructionFormatter() override;
~IntelInstructionFormatter() override;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @brief Simple symbol resolver that only matches exact addresses.
*/
class ZyDisExactSymbolResolver : public ZyDisBaseSymbolResolver
{
private:
std::unordered_map<uint64_t, std::string> m_symbolMap;
public:
/**
* @brief Destructor.
*/
~ZyDisExactSymbolResolver() override;
public:
/**
* @brief Resolves a symbol.
* @param info The instruction info.
* @param address The address.
* @param offset Reference to an unsigned 64 bit integer that receives an offset
* relative to the base address of the symbol.
* @return The name of the symbol, if the symbol was found, @c NULL if not.
*/
const char* resolveSymbol(const ZyDisInstructionInfo &info, uint64_t address,
uint64_t &offset) override;
public:
/**
* @brief Query if the given address is a known symbol.
* @param address The address.
* @return True if the address is known, false if not.
*/
bool containsSymbol(uint64_t address) const;
/**
* @brief Adds or changes a symbol.
* @param address The address.
* @param name The symbol name.
*/
void setSymbol(uint64_t address, const char* name);
/**
* @brief Removes the symbol described by address. This will invalidate all char pointers
* to the specific symbol name.
* @param address The address.
*/
void removeSymbol(uint64_t address);
/**
* @brief Clears the symbol tree.
*/
void clear();
};
///////////////////////////////////////////////////////////////////////////////////////////////////
/* ============================================================================================== */
}
#endif /* _ZYDIS_INSTRUCTIONFORMATTER_HPP_ */

9654
Zydis/ZydisOpcodeTable.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 29. October 2014
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,19 +26,21 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#pragma once
***************************************************************************************************/
#ifndef _ZYDIS_OPCODETABLE_HPP_
#define _ZYDIS_OPCODETABLE_HPP_
#include <stdint.h>
#include <cassert>
namespace Verteron
namespace Zydis
{
/**
* @brief Values that represent an instruction mnemonic.
*/
enum class ZyDisInstructionMnemonic : uint16_t
enum class InstructionMnemonic : uint16_t
{
/* 000 */ INVALID,
/* 001 */ AAA,
@ -922,8 +922,8 @@ enum class ZyDisInstructionMnemonic : uint16_t
/* 36D */ VUNPCKHPS,
/* 36E */ VUNPCKLPD,
/* 36F */ VUNPCKLPS,
/* 370 */ ZyDisORPD,
/* 371 */ ZyDisORPS,
/* 370 */ VXORPD,
/* 371 */ VXORPS,
/* 372 */ VZEROALL,
/* 373 */ VZEROUPPER,
/* 374 */ WAIT,
@ -953,12 +953,12 @@ enum class ZyDisInstructionMnemonic : 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 ZyDisOpcodeTreeNode;
typedef uint16_t OpcodeTreeNode;
/**
* @brief Values that represent the type of an opcode tree node.
*/
enum class ZyDisOpcodeTreeNodeType : uint8_t
enum class OpcodeTreeNodeType : uint8_t
{
/**
* @brief Reference to a concrete instruction definition.
@ -1025,7 +1025,7 @@ enum class ZyDisOpcodeTreeNodeType : uint8_t
/**
* @brief Values that represent the type of an operand in the instruction definition.
*/
enum class ZyDisDefinedOperandType : uint8_t
enum class DefinedOperandType : uint8_t
{
/*
* @brief No operand.
@ -1286,7 +1286,7 @@ enum class ZyDisDefinedOperandType : 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 ZyDisDefinedOperandSize : uint8_t
enum class DefinedOperandSize : uint8_t
{
/**
* @brief No operand.
@ -1386,7 +1386,7 @@ enum class ZyDisDefinedOperandSize : uint8_t
* @brief Values that represent optional flags in the instruction definition.
* Do not change the order or the values of this enum!
*/
enum ZyDisInstructionDefinitionFlags : uint16_t
enum InstructionDefinitionFlags : uint16_t
{
/**
* @brief The instruction accepts the rex.b prefix value.
@ -1454,30 +1454,30 @@ enum ZyDisInstructionDefinitionFlags : uint16_t
/**
* @brief An operand definition.
*/
struct ZyDisOperandDefinition
struct OperandDefinition
{
/**
* @brief The defined operand type.
*/
ZyDisDefinedOperandType type;
DefinedOperandType type;
/**
* @brief The defined operand size.
*/
ZyDisDefinedOperandSize size;
DefinedOperandSize size;
};
/**
* @brief An instruction definition.
*/
struct ZyDisInstructionDefinition
struct InstructionDefinition
{
/**
* @brief The instruction mnemonic.
*/
ZyDisInstructionMnemonic mnemonic;
InstructionMnemonic mnemonic;
/**
* @brief The operand definitions for all four possible operands.
*/
ZyDisOperandDefinition operand[4];
OperandDefinition 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 ZyDisOpcodeTreeNode optreeTable[][256];
extern const OpcodeTreeNode optreeTable[][256];
/**
* @brief Contains all modrm_mod switch tables.
* Index values:
* 0 = [modrm_mod == !11]
* 1 = [modrm_mod == 11]
*/
extern const ZyDisOpcodeTreeNode optreeModrmMod[][2];
extern const OpcodeTreeNode optreeModrmMod[][2];
/**
* @brief Contains all modrm_reg switch tables.
* Indexed by the numeric value of the modrm_reg field.
*/
extern const ZyDisOpcodeTreeNode optreeModrmReg[][8];
extern const OpcodeTreeNode optreeModrmReg[][8];
/**
* @brief Contains all modrm_rm switch tables.
* Indexed by the numeric value of the modrm_rm field.
*/
extern const ZyDisOpcodeTreeNode optreeModrmRm[][8];
extern const OpcodeTreeNode optreeModrmRm[][8];
/**
* @brief Contains all mandatory-prefix switch tables.
* Index values:
@ -1518,13 +1518,13 @@ extern const ZyDisOpcodeTreeNode optreeModrmRm[][8];
* 2 = F3
* 3 = 66
*/
extern const ZyDisOpcodeTreeNode optreeMandatory[][4];
extern const OpcodeTreeNode 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 ZyDisOpcodeTreeNode optreeX87[][64];
extern const OpcodeTreeNode optreeX87[][64];
/**
* @brief Contains all address-size switch tables.
* Index values:
@ -1532,7 +1532,7 @@ extern const ZyDisOpcodeTreeNode optreeX87[][64];
* 1 = 32
* 2 = 64
*/
extern const ZyDisOpcodeTreeNode optreeAddressSize[][3];
extern const OpcodeTreeNode optreeAddressSize[][3];
/**
* @brief Contains all operand-size switch tables.
* Index values:
@ -1540,26 +1540,26 @@ extern const ZyDisOpcodeTreeNode optreeAddressSize[][3];
* 1 = 32
* 2 = 64
*/
extern const ZyDisOpcodeTreeNode optreeOperandSize[][3];
extern const OpcodeTreeNode optreeOperandSize[][3];
/**
* @brief Contains all cpu-mode switch tables.
* Index values:
* 0 = [!= 64]
* 1 = 64
*/
extern const ZyDisOpcodeTreeNode optreeMode[][2];
extern const OpcodeTreeNode optreeMode[][2];
/**
* @brief Contains all vendor switch tables.
* Index values:
* 0 = AMD
* 1 = Intel
*/
extern const ZyDisOpcodeTreeNode optreeVendor[][2];
extern const OpcodeTreeNode optreeVendor[][2];
/**
* @brief Contains all 3dnow! switch tables.
* Indexed by the numeric value of the 3dnow! opcode.
*/
extern const ZyDisOpcodeTreeNode optree3dnow[][256];
extern const OpcodeTreeNode optree3dnow[][256];
/**
* @brief Contains all vex switch tables.
* Index values:
@ -1580,21 +1580,21 @@ extern const ZyDisOpcodeTreeNode optree3dnow[][256];
* E = F2_0F38
* F = F2_0F3A
*/
extern const ZyDisOpcodeTreeNode optreeVex[][16];
extern const OpcodeTreeNode optreeVex[][16];
/**
* @brief Contains all vex_w switch tables.
* Indexed by the numeric value of the vex_w field.
*/
extern const ZyDisOpcodeTreeNode optreeVexW[][2];
extern const OpcodeTreeNode optreeVexW[][2];
/**
* @brief Contains all vex_l switch tables.
* Indexed by the numeric value of the vex_l field.
*/
extern const ZyDisOpcodeTreeNode optreeVexL[][2];
extern const OpcodeTreeNode optreeVexL[][2];
/**
* @brief Contains all instruction definitions.
*/
extern const ZyDisInstructionDefinition instrDefinitions[];
extern const InstructionDefinition 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 ZyDisOpcodeTreeNodeType VDEGetOpcodeNodeType(ZyDisOpcodeTreeNode node)
inline OpcodeTreeNodeType GetOpcodeNodeType(OpcodeTreeNode node)
{
return static_cast<ZyDisOpcodeTreeNodeType>((node >> 12) & 0x0F);
return static_cast<OpcodeTreeNodeType>((node >> 12)& 0x0F);
}
/**
@ -1615,16 +1615,16 @@ inline ZyDisOpcodeTreeNodeType VDEGetOpcodeNodeType(ZyDisOpcodeTreeNode node)
* @param node The node.
* @return The value of the specified opcode tree node.
*/
inline uint16_t VDEGetOpcodeNodeValue(ZyDisOpcodeTreeNode node)
inline uint16_t GetOpcodeNodeValue(OpcodeTreeNode node)
{
return (node & 0x0FFF);
return (node& 0x0FFF);
}
/**
* @brief Returns the root node of the opcode tree.
* @return The root node of the opcode tree.
*/
inline ZyDisOpcodeTreeNode VDEGetOpcodeTreeRoot()
inline OpcodeTreeNode GetOpcodeTreeRoot()
{
return 0x1000;
}
@ -1635,53 +1635,53 @@ inline ZyDisOpcodeTreeNode VDEGetOpcodeTreeRoot()
* @param index The index of the child node to retrieve.
* @return The specified child node.
*/
inline ZyDisOpcodeTreeNode VDEGetOpcodeTreeChild(ZyDisOpcodeTreeNode parent, uint16_t index)
inline OpcodeTreeNode GetOpcodeTreeChild(OpcodeTreeNode parent, uint16_t index)
{
using namespace Internal;
ZyDisOpcodeTreeNodeType nodeType = VDEGetOpcodeNodeType(parent);
uint16_t tableIndex = VDEGetOpcodeNodeValue(parent);
OpcodeTreeNodeType nodeType = GetOpcodeNodeType(parent);
uint16_t tableIndex = GetOpcodeNodeValue(parent);
switch (nodeType)
{
case ZyDisOpcodeTreeNodeType::TABLE:
case OpcodeTreeNodeType::TABLE:
assert(index < 256);
return optreeTable[tableIndex][index];
case ZyDisOpcodeTreeNodeType::MODRM_MOD:
case OpcodeTreeNodeType::MODRM_MOD:
assert(index < 2);
return optreeModrmMod[tableIndex][index];
case ZyDisOpcodeTreeNodeType::MODRM_REG:
case OpcodeTreeNodeType::MODRM_REG:
assert(index < 8);
return optreeModrmReg[tableIndex][index];
case ZyDisOpcodeTreeNodeType::MODRM_RM:
case OpcodeTreeNodeType::MODRM_RM:
assert(index < 8);
return optreeModrmRm[tableIndex][index];
case ZyDisOpcodeTreeNodeType::MANDATORY:
case OpcodeTreeNodeType::MANDATORY:
assert(index < 4);
return optreeMandatory[tableIndex][index];
case ZyDisOpcodeTreeNodeType::X87:
case OpcodeTreeNodeType::X87:
assert(index < 64);
return optreeX87[tableIndex][index];
case ZyDisOpcodeTreeNodeType::ADDRESS_SIZE:
case OpcodeTreeNodeType::ADDRESS_SIZE:
assert(index < 3);
return optreeAddressSize[tableIndex][index];
case ZyDisOpcodeTreeNodeType::OPERAND_SIZE:
case OpcodeTreeNodeType::OPERAND_SIZE:
assert(index < 3);
return optreeOperandSize[tableIndex][index];
case ZyDisOpcodeTreeNodeType::MODE:
case OpcodeTreeNodeType::MODE:
assert(index < 2);
return optreeMode[tableIndex][index];
case ZyDisOpcodeTreeNodeType::VENDOR:
case OpcodeTreeNodeType::VENDOR:
assert(index < 3);
return optreeVendor[tableIndex][index];
case ZyDisOpcodeTreeNodeType::AMD3DNOW:
case OpcodeTreeNodeType::AMD3DNOW:
assert(index < 256);
return optree3dnow[tableIndex][index];
case ZyDisOpcodeTreeNodeType::VEX:
case OpcodeTreeNodeType::VEX:
assert(index < 16);
return optreeVex[tableIndex][index];
case ZyDisOpcodeTreeNodeType::VEXW:
case OpcodeTreeNodeType::VEXW:
assert(index < 2);
return optreeVexW[tableIndex][index];
case ZyDisOpcodeTreeNodeType::VEXL:
case OpcodeTreeNodeType::VEXL:
assert(index < 2);
return optreeVexL[tableIndex][index];
default:
@ -1695,10 +1695,10 @@ inline ZyDisOpcodeTreeNode VDEGetOpcodeTreeChild(ZyDisOpcodeTreeNode parent, uin
* @param node The instruction definition node.
* @return Pointer to the instruction definition.
*/
inline const ZyDisInstructionDefinition* VDEGetInstructionDefinition(ZyDisOpcodeTreeNode node)
inline const InstructionDefinition* GetInstructionDefinition(OpcodeTreeNode node)
{
assert(VDEGetOpcodeNodeType(node) == ZyDisOpcodeTreeNodeType::INSTRUCTION_DEFINITION);
return &instrDefinitions[node & 0x0FFF];
assert(GetOpcodeNodeType(node) == OpcodeTreeNodeType::INSTRUCTION_DEFINITION);
return& instrDefinitions[node& 0x0FFF];
}
/**
@ -1706,7 +1706,7 @@ inline const ZyDisInstructionDefinition* VDEGetInstructionDefinition(ZyDisOpcode
* @param mnemonic The mnemonic.
* @return The instruction mnemonic string.
*/
inline const char* VDEGetInstructionMnemonicString(ZyDisInstructionMnemonic mnemonic)
inline const char* GetInstructionMnemonicString(InstructionMnemonic mnemonic)
{
return instrMnemonicStrings[static_cast<uint16_t>(mnemonic)];
}
@ -1716,14 +1716,14 @@ inline const char* VDEGetInstructionMnemonicString(ZyDisInstructionMnemonic mnem
* @param operandSize The defined operand size.
* @return The the numeric value for the simple operand size definition.
*/
inline uint16_t VDEGetSimpleOperandSize(ZyDisDefinedOperandSize operandSize)
inline uint16_t GetSimpleOperandSize(DefinedOperandSize 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>(ZyDisDefinedOperandSize::B);
static_cast<uint8_t>(operandSize) - static_cast<uint8_t>(DefinedOperandSize::B);
assert(index < 8);
return operandSizes[index];
}
@ -1733,9 +1733,9 @@ inline uint16_t VDEGetSimpleOperandSize(ZyDisDefinedOperandSize operandSize)
* @param operandSize The defined operand size.
* @return The memory-size part of the operand size definition.
*/
inline ZyDisDefinedOperandSize VDEGetComplexOperandMemSize(ZyDisDefinedOperandSize operandSize)
inline DefinedOperandSize GetComplexOperandMemSize(DefinedOperandSize operandSize)
{
return static_cast<ZyDisDefinedOperandSize>(static_cast<uint8_t>(operandSize) & 0x0F);
return static_cast<DefinedOperandSize>(static_cast<uint8_t>(operandSize)& 0x0F);
}
/**
@ -1743,11 +1743,13 @@ inline ZyDisDefinedOperandSize VDEGetComplexOperandMemSize(ZyDisDefinedOperandSi
* @param operandSize The defined operand size.
* @return The register-size part of the operand size definition.
*/
inline ZyDisDefinedOperandSize VDEGetComplexOperandRegSize(ZyDisDefinedOperandSize operandSize)
inline DefinedOperandSize GetComplexOperandRegSize(DefinedOperandSize operandSize)
{
return static_cast<ZyDisDefinedOperandSize>((static_cast<uint8_t>(operandSize) >> 4) & 0x0F);
return static_cast<DefinedOperandSize>((static_cast<uint8_t>(operandSize) >> 4)& 0x0F);
}
}
}
#endif /* _ZYDIS_OPCODETABLE_HPP_ */

View File

@ -0,0 +1,91 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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.
***************************************************************************************************/
#include "ZydisSymbolResolver.hpp"
namespace Zydis
{
/* BaseSymbolResolver ====================================================================== */
BaseSymbolResolver::~BaseSymbolResolver()
{
}
const char *BaseSymbolResolver::resolveSymbol(const InstructionInfo& info,
uint64_t address, uint64_t& offset)
{
return nullptr;
}
/* ExactSymbolResolver ===================================================================== */
ExactSymbolResolver::~ExactSymbolResolver()
{
}
const char *ExactSymbolResolver::resolveSymbol(const InstructionInfo& info,
uint64_t address, uint64_t& offset)
{
std::unordered_map<uint64_t, std::string>::const_iterator iterator = m_symbolMap.find(address);
if (iterator != m_symbolMap.cend())
{
offset = 0;
return iterator->second.c_str();
}
return nullptr;
}
bool ExactSymbolResolver::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 ExactSymbolResolver::setSymbol(uint64_t address, const char *name)
{
m_symbolMap[address].assign(name);
}
void ExactSymbolResolver::removeSymbol(uint64_t address)
{
m_symbolMap.erase(address);
}
void ExactSymbolResolver::clear()
{
m_symbolMap.clear();
}
/* ============================================================================================== */
}

View File

@ -0,0 +1,119 @@
/***************************************************************************************************
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications : Joel Höner
* 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 _ZYDIS_SYMBOLRESOLVER_HPP_
#define _ZYDIS_SYMBOLRESOLVER_HPP_
#include <unordered_map>
#include "ZydisTypes.hpp"
namespace Zydis
{
/* BaseSymbolResolver =========================================================================== */
/**
* @brief Base class for all symbol resolver implementations.
*/
class BaseSymbolResolver
{
public:
/**
* @brief Destructor.
*/
virtual ~BaseSymbolResolver();
public:
/**
* @brief Resolves a symbol.
* @param info The instruction info.
* @param address The address.
* @param offset Reference to an unsigned 64 bit integer that receives an offset
* relative to the base address of the symbol.
* @return The name of the symbol, if the symbol was found, @c NULL if not.
*/
virtual const char *resolveSymbol(const InstructionInfo& info, uint64_t address,
uint64_t& offset);
};
/* ExactSymbolResolver ========================================================================== */
/**
* @brief Simple symbol resolver that only matches exact addresses.
*/
class ExactSymbolResolver : public BaseSymbolResolver
{
private:
std::unordered_map<uint64_t, std::string> m_symbolMap;
public:
/**
* @brief Destructor.
*/
~ExactSymbolResolver() override;
public:
/**
* @brief Resolves a symbol.
* @param info The instruction info.
* @param address The address.
* @param offset Reference to an unsigned 64 bit integer that receives an offset
* relative to the base address of the symbol.
* @return The name of the symbol, if the symbol was found, @c NULL if not.
*/
const char* resolveSymbol(const InstructionInfo& info, uint64_t address,
uint64_t& offset) override;
public:
/**
* @brief Query if the given address is a known symbol.
* @param address The address.
* @return True if the address is known, false if not.
*/
bool containsSymbol(uint64_t address) const;
/**
* @brief Adds or changes a symbol.
* @param address The address.
* @param name The symbol name.
*/
void setSymbol(uint64_t address, const char *name);
/**
* @brief Removes the symbol described by address. This will invalidate all char pointers
* to the specific symbol name.
* @param address The address.
*/
void removeSymbol(uint64_t address);
/**
* @brief Clears the symbol tree.
*/
void clear();
};
/* ============================================================================================== */
}
#endif /* _ZYDIS_SYMBOLRESOLVER_HPP_ */

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 22. October 2014
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,15 +26,19 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#pragma once
***************************************************************************************************/
#ifndef _ZYDIS_TYPES_HPP_
#define _ZYDIS_TYPES_HPP_
#include <stdint.h>
#include "ZyDisOpcodeTable.hpp"
#include "ZydisOpcodeTable.hpp"
namespace Verteron
namespace Zydis
{
/* InstructionFlags ============================================================================= */
/**
* @brief Values that represent additional flags of a decoded instruction.
*/
@ -125,10 +127,12 @@ enum InstructionFlags : uint32_t
IF_ERROR_OPERAND = 0x01000000
};
/* Register ===================================================================================== */
/**
* @brief Values that represent a cpu register.
*/
enum class ZyDisRegister : uint16_t
enum class Register : uint16_t
{
NONE,
/* 8 bit general purpose registers */
@ -185,10 +189,12 @@ enum class ZyDisRegister : uint16_t
RIP
};
/* OperandType ================================================================================== */
/**
* @brief Values that represent the type of a decoded operand.
*/
enum class ZyDisOperandType : uint8_t
enum class OperandType : uint8_t
{
/**
* @brief The operand is not used.
@ -220,10 +226,12 @@ enum class ZyDisOperandType : uint8_t
CONSTANT
};
/* ZydisOperandAccessMode ============================================================================ */
/**
* @brief Values that represent the operand access mode.
*/
enum class ZyDisOperandAccessMode : uint8_t
enum class OperandAccessMode : uint8_t
{
NA,
/**
@ -240,15 +248,17 @@ enum class ZyDisOperandAccessMode : uint8_t
READWRITE
};
/* OperandInfo ================================================================================== */
/**
* @brief This struct holds information about a decoded operand.
*/
struct ZyDisOperandInfo
struct OperandInfo
{
/**
* @brief The type of the operand.
*/
ZyDisOperandType type;
OperandType type;
/**
* @brief The size of the operand.
*/
@ -256,15 +266,15 @@ struct ZyDisOperandInfo
/**
* @brief The operand access mode.
*/
ZyDisOperandAccessMode access_mode;
OperandAccessMode access_mode;
/**
* @brief The base register.
*/
ZyDisRegister base;
Register base;
/**
* @brief The index register.
*/
ZyDisRegister index;
Register index;
/**
* @brief The scale factor.
*/
@ -297,10 +307,12 @@ struct ZyDisOperandInfo
} lval;
};
/* InstructionInfo ============================================================================== */
/**
* @brief This struct holds information about a decoded instruction.
*/
struct ZyDisInstructionInfo
struct InstructionInfo
{
/**
* @brief The instruction flags.
@ -309,7 +321,7 @@ struct ZyDisInstructionInfo
/**
* @brief The instruction mnemonic.
*/
ZyDisInstructionMnemonic mnemonic;
InstructionMnemonic mnemonic;
/**
* @brief The total length of the instruction.
*/
@ -337,12 +349,12 @@ struct ZyDisInstructionInfo
/**
* @brief The decoded operands.
*/
ZyDisOperandInfo operand[4];
OperandInfo operand[4];
/**
* @brief The segment register. This value will default to @c NONE, if no segment register
* prefix is present.
*/
ZyDisRegister segment;
Register segment;
/**
* @brief The rex prefix byte.
*/
@ -512,7 +524,7 @@ struct ZyDisInstructionInfo
/**
* @brief The instruction definition.
*/
const ZyDisInstructionDefinition *instrDefinition;
const InstructionDefinition* instrDefinition;
/**
* @brief The instruction address points to the current instruction (relative to the
* initial instruction pointer).
@ -527,3 +539,5 @@ struct ZyDisInstructionInfo
};
}
#endif /* _ZYDIS_TYPES_HPP_ */

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 30. October 2014
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,47 +26,48 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#include "ZyDisDisassemblerUtils.hpp"
***************************************************************************************************/
#include "ZydisUtils.hpp"
#include <cassert>
namespace Verteron
namespace Zydis
{
uint64_t VDECalcAbsoluteTarget(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &operand)
uint64_t CalcAbsoluteTarget(const InstructionInfo& info, const OperandInfo& operand)
{
assert((operand.type == ZyDisOperandType::REL_IMMEDIATE) ||
((operand.type == ZyDisOperandType::MEMORY) && (operand.base == ZyDisRegister::RIP)));
assert((operand.type == OperandType::REL_IMMEDIATE) ||
((operand.type == OperandType::MEMORY)&& (operand.base == Register::RIP)));
uint64_t truncMask = 0xFFFFFFFFFFFFFFFFull;
if (!(info.flags & IF_DISASSEMBLER_MODE_64))
if (!(info.flags& IF_DISASSEMBLER_MODE_64))
{
truncMask >>= (64 - info.operand_mode);
}
uint16_t size = operand.size;
if ((operand.type == ZyDisOperandType::MEMORY) && (operand.base == ZyDisRegister::RIP))
if ((operand.type == OperandType::MEMORY)&& (operand.base == Register::RIP))
{
size = operand.offset;
}
switch (size)
{
case 8:
return (info.instrPointer + operand.lval.sbyte) & truncMask;
return (info.instrPointer + operand.lval.sbyte)& truncMask;
case 16:
{
uint32_t delta = operand.lval.sword & truncMask;
uint32_t delta = operand.lval.sword& truncMask;
if ((info.instrPointer + delta) > 0xFFFF)
{
return (info.instrPointer & 0xF0000) + ((info.instrPointer + delta) & 0xFFFF);
return (info.instrPointer& 0xF0000) + ((info.instrPointer + delta)& 0xFFFF);
}
return info.instrPointer + delta;
}
case 32:
return (info.instrPointer + operand.lval.sdword) & truncMask;
return (info.instrPointer + operand.lval.sdword)& truncMask;
default:
assert(0);
}
return 0;
}
}
}

View File

@ -1,14 +1,12 @@
/**************************************************************************************************
/***************************************************************************************************
Verteron Disassembler Engine
Zyan Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : Florian Bernd
Modifications :
Last change : 30. October 2014
Modifications : Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -16,10 +14,10 @@
* 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
@ -28,13 +26,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**************************************************************************************************/
#pragma once
***************************************************************************************************/
#ifndef _ZYDIS_UTILS_HPP_
#define _ZYDIS_UTILS_HPP_
#include <stdint.h>
#include "ZyDisDisassemblerTypes.hpp"
#include "ZydisTypes.hpp"
namespace Verteron
namespace Zydis
{
/**
@ -43,6 +43,8 @@ namespace Verteron
* @param operand The operand.
* @return The absolute target address.
*/
uint64_t VDECalcAbsoluteTarget(const ZyDisInstructionInfo &info, const ZyDisOperandInfo &operand);
uint64_t CalcAbsoluteTarget(const InstructionInfo& info, const OperandInfo& operand);
}
#endif /* _ZYDIS_UTILS_HPP_ */