Fixed encoder header

This commit is contained in:
Joel Höner 2017-07-06 13:12:43 +02:00
parent 57059d4e0d
commit 6bd79283e0
3 changed files with 25 additions and 13 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
include(GenerateExportHeader)
include(GNUInstallDirs)
@ -9,6 +9,12 @@ project(Zydis VERSION 2.0)
# =============================================================================================== #
# Features
option(ZYDIS_FEATURE_DECODER
"Enable instruction decoding and formtting functionality"
ON)
option(ZYDIS_FEATURE_ENCODER
"Enable instruction encoding functionality"
OFF)
option(ZYDIS_FEATURE_EVEX
"Enable support for EVEX instructions"
ON)
@ -21,12 +27,6 @@ option(ZYDIS_FEATURE_FLAGS
option(ZYDIS_FEATURE_CPUID
"Include information about CPUID feature-flags"
OFF)
option(ZYDIS_FEATURE_DECODER
"Enable instruction decoding and formtting functionality"
ON)
option(ZYDIS_FEATURE_ENCODER
"Enable instruction encoding functionality"
OFF)
# Build configuration
option(ZYDIS_BUILD_EXAMPLES
@ -69,6 +69,14 @@ target_include_directories("Zydis"
target_compile_definitions("Zydis" PRIVATE "_CRT_SECURE_NO_WARNINGS" "ZYDIS_EXPORTS")
generate_export_header("Zydis" BASE_NAME "ZYDIS" EXPORT_FILE_NAME "ZydisExportConfig.h")
if (NOT ZYDIS_FEATURE_ENCODER AND NOT ZYDIS_FEATURE_DECODER)
message(
FATAL_ERROR
"\nIt's dangerous to go alone! Take at least one of these:\n"
"[ ] ZYDIS_FEATURE_ENCODER [ ] ZYDIS_FEATURE_DECODER"
)
endif ()
if (ZYDIS_FEATURE_EVEX)
target_compile_definitions("Zydis" PUBLIC "ZYDIS_ENABLE_FEATURE_EVEX")
endif ()

View File

@ -28,9 +28,11 @@
#define ZYDIS_ENCODER_H
#include <Zydis/Defines.h>
#include <Zydis/Types.h>
#include <Zydis/Status.h>
#include <Zydis/DecoderTypes.h>
#include <Zydis/SharedTypes.h>
#ifdef ZYDIS_ENABLE_FEATURE_DECODER
# include <Zydis/DecoderTypes.h>
#endif
#ifdef __cplusplus
extern "C" {
@ -88,11 +90,11 @@ typedef struct ZydisEncoderOperand_
typedef struct ZydisEncoderRequest_
{
ZydisMachineMode machineMode;
ZydisInstructionMnemonic mnemonic;
ZydisMnemonic mnemonic;
ZydisInstructionAttributes attributes;
ZydisInstructionEncoding encoding;
uint8_t operandCount;
ZydisEncoderOperand operands[10];
ZydisEncoderOperand operands[5];
// TODO: AVX stuff
// TODO: MVEX stuff
@ -102,8 +104,10 @@ typedef struct ZydisEncoderRequest_
/* Exported functions */
/* ============================================================================================== */
ZYDIS_EXPORT ZydisStatus ZydisEncoderRequestFromDecodedInstruction(
#ifdef ZYDIS_ENABLE_FEATURE_DECODER
ZYDIS_EXPORT ZydisStatus ZydisEncoderDecodedInstructionToRequest(
const ZydisDecodedInstruction* in, ZydisEncoderRequest* out);
#endif
/**
* @brief Encodes the given instruction info to byte-code.

View File

@ -73,7 +73,7 @@ typedef struct ZydisEncodableInstruction_
uint8_t evexB ZYDIS_BITFIELD( 2);
uint8_t evexZ ZYDIS_BITFIELD( 2);
uint8_t mvexE ZYDIS_BITFIELD( 2);
} filterIndizes;
} filters;
} ZydisEncodableInstruction;
/* ---------------------------------------------------------------------------------------------- */