From a10cf47a9701a4d0be83940a23a8edf9a5ed7b5e Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Tue, 6 Sep 2016 11:54:01 +0200 Subject: Properly uses cmake to link with distorm3. --- CMakeLists.txt | 3 +++ CMakeModules/distorm3Config.cmake | 10 ++++++++++ disasm/CMakeLists.txt | 10 +++++----- disasm/disasm.cpp | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 CMakeModules/distorm3Config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 36ad668..d226fea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.5.2) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) + project(openwar) add_subdirectory(fusion-utils) diff --git a/CMakeModules/distorm3Config.cmake b/CMakeModules/distorm3Config.cmake new file mode 100644 index 0000000..692e5d3 --- /dev/null +++ b/CMakeModules/distorm3Config.cmake @@ -0,0 +1,10 @@ + +add_library(distorm3 UNKNOWN IMPORTED) + +find_library(distorm3_LIBRARY NAMES "distorm3") + +set_property(TARGET distorm3 PROPERTY IMPORTED_LOCATION "${distorm3_LIBRARY}") + +find_path(distorm3_INCLUDE_DIR NAMES "distorm.h") + +set_property(TARGET distorm3 PROPERTY INCLUDE_DIRECTORIES ${distorm3_INCLUDE_DIR}) diff --git a/disasm/CMakeLists.txt b/disasm/CMakeLists.txt index e433d10..e9cd3d2 100644 --- a/disasm/CMakeLists.txt +++ b/disasm/CMakeLists.txt @@ -5,12 +5,12 @@ add_executable(disasm find_package(Boost COMPONENTS filesystem program_options system REQUIRED) +find_package(distorm3 REQUIRED CONFIG) + target_link_libraries(disasm PRIVATE le - PRIVATE ${Boost_LIBRARIES} + PRIVATE Boost::program_options + PRIVATE Boost::system + PRIVATE Boost::filesystem PRIVATE distorm3 ) - -target_include_directories(disasm - PRIVATE ${Boost_INCLUDE_DIRS} -) \ No newline at end of file diff --git a/disasm/disasm.cpp b/disasm/disasm.cpp index 862813c..09b9b02 100644 --- a/disasm/disasm.cpp +++ b/disasm/disasm.cpp @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) { auto index = eip_object.page_table_index; auto page = x.object_page_table.entries[index]; - binparse::Offset32 offset = x.le_offset + x.le_header.data_page_offset; + binparse::Offset32 offset = x.le_header.data_page_offset; auto result = distorm_decode64(0x00010000, code.data() + offset, x.object_table.entries[1].nr_page_table_entries * x.le_header.page_size, Decode32Bits, instructions.data(), instructions.size(), &read_inst); -- cgit v1.2.3-70-g09d2