Updated CMake file and Zydis features

This commit is contained in:
flobernd 2017-06-21 18:25:53 +02:00
parent dc62509b9b
commit bd38d86986
4 changed files with 29 additions and 16 deletions

View File

@ -10,12 +10,15 @@ option(ZYDIS_BUILD_SHARED_LIBS
option(ZYDIS_FORCE_SHARED_CRT
"Forces shared linkage against the CRT even when building a static library. MSVC only."
OFF)
option(ZYDIS_FEATURE_IMPLICITLY_USED_REGISTERS
"Include information about implicitly used registers"
OFF)
option(ZYDIS_FEATURE_AFFECTED_FLAGS
option(ZYDIS_FEATURE_EVEX
"Enable EVEX encoded instructions"
ON)
option(ZYDIS_FEATURE_MVEX
"Enable MVEX encoded instructions"
ON)
option(ZYDIS_FEATURE_FLAGS
"Include information about affected flags"
OFF)
ON)
option(ZYDIS_FEATURE_CPUID
"Include information about CPUID feature-flags"
OFF)
@ -79,11 +82,14 @@ target_include_directories("Zydis" PUBLIC "include/" ${PROJECT_BINARY_DIR})
target_compile_definitions("Zydis" PRIVATE "_CRT_SECURE_NO_WARNINGS" "ZYDIS_EXPORTS")
generate_export_header("Zydis" BASE_NAME "ZYDIS" EXPORT_FILE_NAME "ZydisExportConfig.h")
if (ZYDIS_FEATURE_IMPLICITLY_USED_REGISTERS)
target_compile_definitions("Zydis" PRIVATE "ZYDIS_ENABLE_FEATURE_IMPLICITLY_USED_REGISTERS")
if (ZYDIS_FEATURE_EVEX)
target_compile_definitions("Zydis" PRIVATE "ZYDIS_ENABLE_FEATURE_EVEX")
endif ()
if (ZYDIS_FEATURE_AFFECTED_FLAGS)
target_compile_definitions("Zydis" PRIVATE "ZYDIS_ENABLE_FEATURE_AFFECTED_FLAGS")
if (ZYDIS_FEATURE_MVEX)
target_compile_definitions("Zydis" PRIVATE "ZYDIS_ENABLE_FEATURE_MVEX")
endif ()
if (ZYDIS_FEATURE_FLAGS)
target_compile_definitions("Zydis" PRIVATE "ZYDIS_ENABLE_FEATURE_FLAGS")
endif ()
if (ZYDIS_FEATURE_CPUID)
target_compile_definitions("Zydis" PRIVATE "ZYDIS_ENABLE_FEATURE_CPUID")

View File

@ -270,7 +270,7 @@ ZYDIS_EXPORT int16_t ZydisRegisterGetId(ZydisRegister reg);
ZYDIS_EXPORT ZydisRegisterClass ZydisRegisterGetClass(ZydisRegister reg);
/**
* @brief Returns the width of the specified register mode.
* @brief Returns the width of the specified register.
*
* @param reg The register.
*

View File

@ -103,8 +103,9 @@ typedef uint8_t ZydisFeature;
*/
enum ZydisFeatures
{
ZYDIS_FEATURE_IMPLICITLY_USED_REGISTERS,
ZYDIS_FEATURE_AFFECTED_FLAGS,
ZYDIS_FEATURE_EVEX,
ZYDIS_FEATURE_MVEX,
ZYDIS_FEATURE_FLAGS,
ZYDIS_FEATURE_CPUID
};

View File

@ -39,14 +39,20 @@ ZydisBool ZydisIsFeatureEnabled(ZydisFeature feature)
{
switch (feature)
{
case ZYDIS_FEATURE_IMPLICITLY_USED_REGISTERS:
#ifdef ZYDIS_ENABLE_FEATURE_IMPLICITLY_USED_REGISTERS
case ZYDIS_FEATURE_EVEX:
#ifdef ZYDIS_ENABLE_FEATURE_EVEX
return ZYDIS_TRUE;
#else
return ZYDIS_FALSE;
#endif
case ZYDIS_FEATURE_AFFECTED_FLAGS:
#ifdef ZYDIS_ENABLE_FEATURE_AFFECTED_FLAGS
case ZYDIS_FEATURE_MVEX:
#ifdef ZYDIS_ENABLE_FEATURE_MVEX
return ZYDIS_TRUE;
#else
return ZYDIS_FALSE;
#endif
case ZYDIS_FEATURE_FLAGS:
#ifdef ZYDIS_ENABLE_FEATURE_FLAGS
return ZYDIS_TRUE;
#else
return ZYDIS_FALSE;