mirror of https://github.com/x64dbg/zydis
Preparations for optional feature support
This commit is contained in:
parent
52dd9fac89
commit
a6e76d81b4
|
@ -5,12 +5,23 @@ include(GenerateExportHeader)
|
||||||
project(Zydis)
|
project(Zydis)
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build shared libraries rather than static ones" FALSE)
|
option(BUILD_SHARED_LIBS
|
||||||
|
"Build shared libraries rather than static ones"
|
||||||
|
FALSE)
|
||||||
option(FORCE_SHARED_CRT
|
option(FORCE_SHARED_CRT
|
||||||
"Forces shared linkage against the CRT even when building a static library"
|
"Forces shared linkage against the CRT even when building a static library"
|
||||||
FALSE)
|
FALSE)
|
||||||
|
option(FEATURE_IMPLICITLY_USED_REGISTERS
|
||||||
|
"Include information about implicitly used registers"
|
||||||
|
TRUE)
|
||||||
|
option(FEATURE_AFFECTED_FLAGS
|
||||||
|
"Include information about affected flags"
|
||||||
|
TRUE)
|
||||||
|
option(FEATURE_CPUID
|
||||||
|
"Include information about CPUID feature-flags"
|
||||||
|
FALSE)
|
||||||
option(BUILD_EXAMPLES "Build examples" TRUE)
|
option(BUILD_EXAMPLES "Build examples" TRUE)
|
||||||
option(BUILD_TOOLS "Build tools")
|
option(BUILD_TOOLS "Build tools" TRUE)
|
||||||
|
|
||||||
if (NOT CONFIGURED_ONCE)
|
if (NOT CONFIGURED_ONCE)
|
||||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
||||||
|
@ -32,7 +43,7 @@ if (("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") AND NOT FORCE_SHARED_CRT)
|
||||||
if(${flag_var} MATCHES "/MD")
|
if(${flag_var} MATCHES "/MD")
|
||||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||||
endif ()
|
endif ()
|
||||||
endforeach(flag_var)
|
endforeach ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Library
|
# Library
|
||||||
|
@ -41,6 +52,7 @@ set(headers
|
||||||
"include/Zydis/Defines.h"
|
"include/Zydis/Defines.h"
|
||||||
"include/Zydis/Formatter.h"
|
"include/Zydis/Formatter.h"
|
||||||
"include/Zydis/Input.h"
|
"include/Zydis/Input.h"
|
||||||
|
"include/Zydis/InstructionDetails.h"
|
||||||
"include/Zydis/InstructionInfo.h"
|
"include/Zydis/InstructionInfo.h"
|
||||||
"include/Zydis/Mnemonic.h"
|
"include/Zydis/Mnemonic.h"
|
||||||
"include/Zydis/Register.h"
|
"include/Zydis/Register.h"
|
||||||
|
@ -53,6 +65,7 @@ set(sources
|
||||||
"src/Decoder.c"
|
"src/Decoder.c"
|
||||||
"src/Formatter.c"
|
"src/Formatter.c"
|
||||||
"src/Input.c"
|
"src/Input.c"
|
||||||
|
"src/InstructionDetails.c"
|
||||||
"src/InstructionTable.c"
|
"src/InstructionTable.c"
|
||||||
"src/Mnemonic.c"
|
"src/Mnemonic.c"
|
||||||
"src/Register.c"
|
"src/Register.c"
|
||||||
|
|
|
@ -37,27 +37,21 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
/* Operand utils */
|
/* Utils */
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
|
||||||
/* Exported functions */
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calculates the absolute target-address of an relative instruction operand.
|
* @brief Calculates the absolute target-address of an relative instruction operand.
|
||||||
*
|
*
|
||||||
* @param info A pointer to the instruction-info struct.
|
* @param info A pointer to the instruction-info struct.
|
||||||
* @param operand A pointer to the operand-info struct.
|
* @param operand A pointer to the operand-info struct.
|
||||||
* @param address A pointer to the memory address that receives the absolute target-address.
|
* @param address A pointer to the memory that receives the absolute target-address.
|
||||||
*
|
*
|
||||||
* @return A zydis status code
|
* @return A zydis status code
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisUtilsCalcAbsoluteTargetAddress(const ZydisInstructionInfo* info,
|
ZYDIS_EXPORT ZydisStatus ZydisUtilsCalcAbsoluteTargetAddress(const ZydisInstructionInfo* info,
|
||||||
const ZydisOperandInfo* operand, uint64_t* address);
|
const ZydisOperandInfo* operand, uint64_t* address);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -87,6 +87,25 @@ extern "C" {
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ============================================================================================== */
|
||||||
|
/* Enums and types */
|
||||||
|
/* ============================================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Defines the zydis feature datatype.
|
||||||
|
*/
|
||||||
|
typedef uint8_t ZydisFeature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Values that represent zydis features.
|
||||||
|
*/
|
||||||
|
enum ZydisFeatures
|
||||||
|
{
|
||||||
|
ZYDIS_FEATURE_IMPLICITLY_USED_REGISTERS,
|
||||||
|
ZYDIS_FEATURE_AFFECTED_FLAGS,
|
||||||
|
ZYDIS_FEATURE_CPUID
|
||||||
|
};
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
/* Exported functions */
|
/* Exported functions */
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
@ -101,6 +120,15 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT uint64_t ZydisGetVersion();
|
ZYDIS_EXPORT uint64_t ZydisGetVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks, if the specified feature is enabled in the current zydis library instance.
|
||||||
|
*
|
||||||
|
* @param feature The feature.
|
||||||
|
*
|
||||||
|
* @return @c True if the feature is enabled, @c false if not.
|
||||||
|
*/
|
||||||
|
ZYDIS_EXPORT bool ZydisIsFeatureEnabled(ZydisFeature feature);
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
26
src/Zydis.c
26
src/Zydis.c
|
@ -35,4 +35,30 @@ uint64_t ZydisGetVersion()
|
||||||
return ZYDIS_VERSION;
|
return ZYDIS_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZydisIsFeatureEnabled(ZydisFeature feature)
|
||||||
|
{
|
||||||
|
switch (feature)
|
||||||
|
{
|
||||||
|
case ZYDIS_FEATURE_IMPLICITLY_USED_REGISTERS:
|
||||||
|
#ifdef ZYDIS_ENABLE_FEATURE_IMPLICITLY_USED_REGISTERS
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
case ZYDIS_FEATURE_AFFECTED_FLAGS:
|
||||||
|
#ifdef ZYDIS_ENABLE_FEATURE_AFFECTED_FLAGS
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
case ZYDIS_FEATURE_CPUID:
|
||||||
|
#ifdef ZYDIS_ENABLE_FEATURE_CPUID
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
Loading…
Reference in New Issue