aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/detours
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/detours')
-rw-r--r--vcpkg/ports/detours/find-jmp-bounds-arm64.patch24
-rw-r--r--vcpkg/ports/detours/portfile.cmake36
-rw-r--r--vcpkg/ports/detours/usage7
-rw-r--r--vcpkg/ports/detours/vcpkg.json9
4 files changed, 76 insertions, 0 deletions
diff --git a/vcpkg/ports/detours/find-jmp-bounds-arm64.patch b/vcpkg/ports/detours/find-jmp-bounds-arm64.patch
new file mode 100644
index 0000000..21390ce
--- /dev/null
+++ b/vcpkg/ports/detours/find-jmp-bounds-arm64.patch
@@ -0,0 +1,24 @@
+diff --git a/src/detours.cpp b/src/detours.cpp
+index 8345c4d..3cd0e9d 100644
+--- a/src/detours.cpp
++++ b/src/detours.cpp
+@@ -974,6 +974,19 @@ inline PBYTE detour_skip_jmp(PBYTE pbCode, PVOID *ppGlobals)
+ return pbCode;
+ }
+
++inline void detour_find_jmp_bounds(PBYTE pbCode,
++ PDETOUR_TRAMPOLINE *ppLower,
++ PDETOUR_TRAMPOLINE *ppUpper)
++{
++ // We have to place trampolines within +/- 2GB of code.
++ ULONG_PTR lo = detour_2gb_below((ULONG_PTR)pbCode);
++ ULONG_PTR hi = detour_2gb_above((ULONG_PTR)pbCode);
++ DETOUR_TRACE(("[%p..%p..%p]\n", lo, pbCode, hi));
++
++ *ppLower = (PDETOUR_TRAMPOLINE)lo;
++ *ppUpper = (PDETOUR_TRAMPOLINE)hi;
++}
++
+ inline BOOL detour_does_code_end_function(PBYTE pbCode)
+ {
+ ULONG Opcode = fetch_opcode(pbCode);
diff --git a/vcpkg/ports/detours/portfile.cmake b/vcpkg/ports/detours/portfile.cmake
new file mode 100644
index 0000000..7b573e8
--- /dev/null
+++ b/vcpkg/ports/detours/portfile.cmake
@@ -0,0 +1,36 @@
+vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO microsoft/Detours
+ REF v4.0.1
+ SHA512 0a9c21b8222329add2de190d2e94d99195dfa55de5a914b75d380ffe0fb787b12e016d0723ca821001af0168fd1643ffd2455298bf3de5fdc155b3393a3ccc87
+ HEAD_REF master
+ PATCHES
+ find-jmp-bounds-arm64.patch
+)
+
+vcpkg_build_nmake(
+ SOURCE_PATH "${SOURCE_PATH}"
+ PROJECT_SUBPATH "src"
+ PROJECT_NAME "Makefile"
+ OPTIONS "PROCESSOR_ARCHITECTURE=${VCPKG_TARGET_ARCHITECTURE}"
+ OPTIONS_RELEASE "DETOURS_CONFIG=Release"
+ OPTIONS_DEBUG "DETOURS_CONFIG=Debug"
+)
+
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
+ file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/lib.${VCPKG_TARGET_ARCHITECTURE}Release/" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
+endif()
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
+ file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/lib.${VCPKG_TARGET_ARCHITECTURE}Debug/" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
+endif()
+
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
+ file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/include/" DESTINATION "${CURRENT_PACKAGES_DIR}/include" RENAME detours)
+else()
+ file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/include/" DESTINATION "${CURRENT_PACKAGES_DIR}/include" RENAME detours)
+endif()
+
+file(INSTALL "${SOURCE_PATH}/LICENSE.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
+file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
diff --git a/vcpkg/ports/detours/usage b/vcpkg/ports/detours/usage
new file mode 100644
index 0000000..00f978f
--- /dev/null
+++ b/vcpkg/ports/detours/usage
@@ -0,0 +1,7 @@
+detours can be used from CMake via:
+
+ find_path(DETOURS_INCLUDE_DIRS "detours/detours.h")
+ find_library(DETOURS_LIBRARY detours REQUIRED)
+
+ target_include_directories(main PRIVATE ${DETOURS_INCLUDE_DIRS})
+ target_link_libraries(main PRIVATE ${DETOURS_LIBRARY})
diff --git a/vcpkg/ports/detours/vcpkg.json b/vcpkg/ports/detours/vcpkg.json
new file mode 100644
index 0000000..b0f745d
--- /dev/null
+++ b/vcpkg/ports/detours/vcpkg.json
@@ -0,0 +1,9 @@
+{
+ "name": "detours",
+ "version": "4.0.1",
+ "port-version": 8,
+ "description": "Detours is a software package for monitoring and instrumenting API calls on Windows.",
+ "homepage": "https://github.com/microsoft/Detours",
+ "license": "MIT",
+ "supports": "windows & !uwp"
+}