From bd38d8698630b53b973febe2d6677cd2e4ea0723 Mon Sep 17 00:00:00 2001 From: flobernd Date: Wed, 21 Jun 2017 18:25:53 +0200 Subject: [PATCH] Updated CMake file and Zydis features --- CMakeLists.txt | 24 +++++++++++++++--------- include/Zydis/Register.h | 2 +- include/Zydis/Zydis.h | 5 +++-- src/Zydis.c | 14 ++++++++++---- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e6204b..6120173 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/include/Zydis/Register.h b/include/Zydis/Register.h index d35a455..0976059 100644 --- a/include/Zydis/Register.h +++ b/include/Zydis/Register.h @@ -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. * diff --git a/include/Zydis/Zydis.h b/include/Zydis/Zydis.h index 5afc7a4..8c5543c 100644 --- a/include/Zydis/Zydis.h +++ b/include/Zydis/Zydis.h @@ -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 }; diff --git a/src/Zydis.c b/src/Zydis.c index 8d3eef8..cb260dd 100644 --- a/src/Zydis.c +++ b/src/Zydis.c @@ -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;