mirror of
https://github.com/QuasarApp/pe-parse.git
synced 2025-04-26 04:14:32 +00:00
Fix peaddrconv example compilation failure (#158)
Add option to build examples with main CMake. Build examples in CI now. Add target alias with prefix for main pe-parse library.
This commit is contained in:
parent
41a08eb3ee
commit
94bd12ac53
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -64,6 +64,7 @@ jobs:
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
|
||||
-DBUILD_SHARED_LIBS=${{ matrix.build-shared }} \
|
||||
-DPEPARSE_ENABLE_TESTING=ON \
|
||||
-DPEPARSE_ENABLE_EXAMPLES=ON \
|
||||
${SANITIZER_FLAG} \
|
||||
..
|
||||
cmake --build .
|
||||
@ -126,6 +127,7 @@ jobs:
|
||||
-A ${{ matrix.build-arch }} `
|
||||
-DBUILD_SHARED_LIBS=${{ matrix.build-shared }} `
|
||||
-DPEPARSE_ENABLE_TESTING=ON `
|
||||
-DPEPARSE_ENABLE_EXAMPLES=ON `
|
||||
$Env:SANITIZER_FLAG `
|
||||
..
|
||||
cmake --build . --config ${{ matrix.build-type }}
|
||||
|
@ -64,6 +64,12 @@ message(STATUS "Build Shared: ${BUILD_SHARED_LIBS} ${BUILD_SHARED_LIBS_MESSAGE}"
|
||||
message(STATUS "Build Command Line Tools: ${BUILD_COMMAND_LINE_TOOLS}")
|
||||
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
option(PEPARSE_ENABLE_EXAMPLES "Enable building examples" OFF)
|
||||
if (PEPARSE_ENABLE_EXAMPLES)
|
||||
message(STATUS "Building Examples")
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
option(PEPARSE_ENABLE_TESTING "Enable building tests" OFF)
|
||||
if (PEPARSE_ENABLE_TESTING)
|
||||
enable_testing()
|
||||
|
@ -94,6 +94,10 @@ You can build the (catch2-based) tests by adding `-DPEPARSE_ENABLE_TESTING=ON` d
|
||||
|
||||
To run the full test suite with the [Corkami test suite](https://github.com/corkami/pocs/tree/master/PE), you must clone the submodule with `git submodule update --init`.
|
||||
|
||||
## Examples
|
||||
|
||||
You can build the included examples by adding `-DPEPARSE_ENABLE_EXAMPLES=ON` during CMake configuration.
|
||||
|
||||
## Building with Sanitizers
|
||||
|
||||
If you are familiar with C++ sanitizers and any specific development environment requirements for them (compiler, instrumented standard library, etc.), you can choose to compile with any of the following sanitizers: `Address`, `HWAddress`, `Undefined`, `Memory`, `MemoryWithOrigins`, `Leak`, `Address,Undefined`.
|
||||
|
1
examples/CMakeLists.txt
Normal file
1
examples/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(peaddrconv)
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
|
||||
project(peaddrconv)
|
||||
|
||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Default install directory" FORCE)
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Default install directory" FORCE)
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
@ -35,7 +35,9 @@ else ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
find_package(pe-parse REQUIRED)
|
||||
if (NOT TARGET pe-parse::pe-parse)
|
||||
find_package(pe-parse REQUIRED)
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
target_link_libraries(${PROJECT_NAME} pe-parse::pe-parse)
|
||||
|
@ -53,11 +53,12 @@ bool convertAddress(ParsedPeRef &pe,
|
||||
std::uintptr_t highest_offset;
|
||||
};
|
||||
|
||||
auto L_getSectionAddressLimits = [](void *N,
|
||||
peparse::VA secBase,
|
||||
std::string &secName,
|
||||
peparse::image_section_header s,
|
||||
peparse::bounded_buffer *data) -> int {
|
||||
auto L_getSectionAddressLimits =
|
||||
[](void *N,
|
||||
const peparse::VA &secBase,
|
||||
const std::string &secName,
|
||||
const peparse::image_section_header &s,
|
||||
const peparse::bounded_buffer *data) -> int {
|
||||
static_cast<void>(secBase);
|
||||
static_cast<void>(secName);
|
||||
static_cast<void>(data);
|
||||
@ -113,10 +114,10 @@ bool convertAddress(ParsedPeRef &pe,
|
||||
};
|
||||
|
||||
auto L_inspectSection = [](void *N,
|
||||
peparse::VA secBase,
|
||||
std::string &secName,
|
||||
peparse::image_section_header s,
|
||||
peparse::bounded_buffer *data) -> int {
|
||||
const peparse::VA &secBase,
|
||||
const std::string &secName,
|
||||
const peparse::image_section_header &s,
|
||||
const peparse::bounded_buffer *data) -> int {
|
||||
static_cast<void>(secBase);
|
||||
static_cast<void>(secName);
|
||||
static_cast<void>(data);
|
||||
@ -186,10 +187,10 @@ bool convertAddress(ParsedPeRef &pe,
|
||||
};
|
||||
|
||||
auto L_inspectSection = [](void *N,
|
||||
peparse::VA secBase,
|
||||
std::string &secName,
|
||||
peparse::image_section_header s,
|
||||
peparse::bounded_buffer *data) -> int {
|
||||
const peparse::VA &secBase,
|
||||
const std::string &secName,
|
||||
const peparse::image_section_header &s,
|
||||
const peparse::bounded_buffer *data) -> int {
|
||||
static_cast<void>(secBase);
|
||||
static_cast<void>(secName);
|
||||
static_cast<void>(data);
|
||||
|
@ -25,6 +25,7 @@ else()
|
||||
endif()
|
||||
|
||||
add_library(${PROJECT_NAME} ${PEPARSERLIB_SOURCEFILES})
|
||||
add_library(pe-parse::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
|
||||
if(PEPARSE_LIBRARY_WARNINGS)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE PEPARSE_LIBRARY_WARNINGS=1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user