mirror of https://github.com/x64dbg/zydis
Updated encoder to a lot of previous refactorings
This commit is contained in:
parent
26a971f624
commit
41776bac29
|
@ -107,7 +107,7 @@ endif ()
|
||||||
|
|
||||||
if (ZYDIS_FEATURE_ENCODER)
|
if (ZYDIS_FEATURE_ENCODER)
|
||||||
target_sources("Zydis"
|
target_sources("Zydis"
|
||||||
PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include/Encoder.h"
|
PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include/Zydis/Encoder.h"
|
||||||
PRIVATE "src/Encoder.c")
|
PRIVATE "src/Encoder.c")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <Zydis/Defines.h>
|
#include <Zydis/Defines.h>
|
||||||
#include <Zydis/Types.h>
|
#include <Zydis/Types.h>
|
||||||
#include <Zydis/Status.h>
|
#include <Zydis/Status.h>
|
||||||
#include <Zydis/InstructionInfo.h>
|
#include <Zydis/DecoderTypes.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -55,21 +55,67 @@ extern "C" {
|
||||||
ZYDIS_ATTRIB_HAS_BRANCH_NOT_TAKEN \
|
ZYDIS_ATTRIB_HAS_BRANCH_NOT_TAKEN \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* ============================================================================================== */
|
||||||
|
/* Structs */
|
||||||
|
/* ============================================================================================== */
|
||||||
|
|
||||||
|
typedef struct ZydisEncoderOperand_
|
||||||
|
{
|
||||||
|
ZydisOperandType type;
|
||||||
|
ZydisRegister reg;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ZydisRegister segment;
|
||||||
|
ZydisRegister base;
|
||||||
|
ZydisRegister index;
|
||||||
|
uint8_t scale;
|
||||||
|
uint8_t dispSize;
|
||||||
|
int64_t disp;
|
||||||
|
} mem;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint16_t segment;
|
||||||
|
uint32_t offset;
|
||||||
|
} ptr;
|
||||||
|
uint8_t immSize;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
uint64_t u;
|
||||||
|
int64_t s;
|
||||||
|
} imm;
|
||||||
|
} ZydisEncoderOperand;
|
||||||
|
|
||||||
|
typedef struct ZydisEncoderRequest_
|
||||||
|
{
|
||||||
|
ZydisMachineMode machineMode;
|
||||||
|
ZydisInstructionMnemonic mnemonic;
|
||||||
|
ZydisInstructionAttributes attributes;
|
||||||
|
ZydisInstructionEncoding encoding;
|
||||||
|
uint8_t operandCount;
|
||||||
|
ZydisEncoderOperand operands[10];
|
||||||
|
|
||||||
|
// TODO: AVX stuff
|
||||||
|
// TODO: MVEX stuff
|
||||||
|
} ZydisEncoderRequest;
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
/* Exported functions */
|
/* Exported functions */
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
|
ZYDIS_EXPORT ZydisStatus ZydisEncoderRequestFromDecodedInstruction(
|
||||||
|
const ZydisDecodedInstruction* in, ZydisEncoderRequest* out);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Encodes the given instruction info to byte-code.
|
* @brief Encodes the given instruction info to byte-code.
|
||||||
*
|
*
|
||||||
* @param buffer A pointer to the output buffer.
|
* @param buffer A pointer to the output buffer.
|
||||||
* @param bufferLen The length of the output buffer.
|
* @param bufferLen The length of the output buffer.
|
||||||
* @param info A pointer to the @c ZydisInstructionInfo struct to be encoded.
|
* @param request A pointer to the @c ZydisEncoderRequest encode.
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisEncoderEncodeInstruction(void* buffer, size_t* bufferLen,
|
ZYDIS_EXPORT ZydisStatus ZydisEncoderEncodeInstruction(void* buffer, size_t* bufferLen,
|
||||||
ZydisInstructionInfo* info);
|
ZydisEncoderRequest* request);
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,12 @@ enum ZydisStatusCode
|
||||||
*/
|
*/
|
||||||
ZYDIS_STATUS_INVALID_MASK,
|
ZYDIS_STATUS_INVALID_MASK,
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------ */
|
||||||
|
/* Encoder */
|
||||||
|
/* ------------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION,
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------------------------ */
|
||||||
/* Formatter */
|
/* Formatter */
|
||||||
/* ------------------------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------------------------ */
|
||||||
|
|
602
src/Encoder.c
602
src/Encoder.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue