Skip to content

Commit 3c57ee3

Browse files
committed
Add detours patch that restores to the pre-vcpkg version
1 parent c61fde9 commit 3c57ee3

File tree

7 files changed

+4406
-0
lines changed

7 files changed

+4406
-0
lines changed

src/VcpkgPortOverlay/CreatePortOverlay.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,26 @@ function Add-PatchToPort
236236
Add-PatchToPortFile -Port $Port -PatchName $PatchName
237237
}
238238

239+
# Copies a patch to a port
240+
function Copy-PatchToPort
241+
{
242+
param(
243+
[Parameter(Mandatory)]
244+
[string]$Port,
245+
[Parameter(Mandatory)]
246+
[string]$PatchPath, # overlay relative directory
247+
[Parameter(Mandatory)]
248+
[string]$PatchName
249+
)
250+
251+
$portSource = Join-Path $OverlayRoot $PatchPath $PatchName
252+
253+
$portDir = Join-Path $OverlayRoot $Port
254+
Copy-Item -Path $portSource -Destination (Join-Path $portDir $PatchName)
255+
256+
Add-PatchToPortFile -Port $Port -PatchName $PatchName
257+
}
258+
239259
# Sets the value of an existing function parameter.
240260
# For example, REF in vcpkg_from_github
241261
function Set-ParameterInPortFile
@@ -302,6 +322,9 @@ function Update-PortVersion
302322
New-PortOverlay cpprestsdk -Version 2.10.18 -PortVersion 4
303323
Add-PatchToPort cpprestsdk -PatchRepo 'microsoft/winget-cli' -PatchCommit '888b4ed8f4f7d25cb05a47210e083fe29348163b' -PatchName 'add-server-certificate-validation.patch' -PatchRoot 'src/cpprestsdk/cpprestsdk'
304324

325+
New-PortOverlay detours -Version 4.0.1 -PortVersion 8
326+
Copy-PatchToPort detours -PatchPath 'detours_manual' -PatchName 'undockedregfreewinrt-version.patch'
327+
305328
New-PortOverlay libyaml -Version 0.2.5 -PortVersion 5
306329
Update-PortSource libyaml -Commit '840b65c40675e2d06bf40405ad3f12dec7f35923' -SourceHash 'de85560312d53a007a2ddf1fe403676bbd34620480b1ba446b8c16bb366524ba7a6ed08f6316dd783bf980d9e26603a9efc82f134eb0235917b3be1d3eb4b302'
307330
Update-PortVersion libyaml
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/src/detours.cpp b/src/detours.cpp
2+
index 8345c4d..3cd0e9d 100644
3+
--- a/src/detours.cpp
4+
+++ b/src/detours.cpp
5+
@@ -974,6 +974,19 @@ inline PBYTE detour_skip_jmp(PBYTE pbCode, PVOID *ppGlobals)
6+
return pbCode;
7+
}
8+
9+
+inline void detour_find_jmp_bounds(PBYTE pbCode,
10+
+ PDETOUR_TRAMPOLINE *ppLower,
11+
+ PDETOUR_TRAMPOLINE *ppUpper)
12+
+{
13+
+ // We have to place trampolines within +/- 2GB of code.
14+
+ ULONG_PTR lo = detour_2gb_below((ULONG_PTR)pbCode);
15+
+ ULONG_PTR hi = detour_2gb_above((ULONG_PTR)pbCode);
16+
+ DETOUR_TRACE(("[%p..%p..%p]\n", lo, pbCode, hi));
17+
+
18+
+ *ppLower = (PDETOUR_TRAMPOLINE)lo;
19+
+ *ppUpper = (PDETOUR_TRAMPOLINE)hi;
20+
+}
21+
+
22+
inline BOOL detour_does_code_end_function(PBYTE pbCode)
23+
{
24+
ULONG Opcode = fetch_opcode(pbCode);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
2+
3+
vcpkg_from_github(
4+
OUT_SOURCE_PATH SOURCE_PATH
5+
REPO microsoft/Detours
6+
REF v4.0.1
7+
SHA512 0a9c21b8222329add2de190d2e94d99195dfa55de5a914b75d380ffe0fb787b12e016d0723ca821001af0168fd1643ffd2455298bf3de5fdc155b3393a3ccc87
8+
HEAD_REF master
9+
PATCHES
10+
find-jmp-bounds-arm64.patch
11+
undockedregfreewinrt-version.patch
12+
)
13+
14+
vcpkg_build_nmake(
15+
SOURCE_PATH "${SOURCE_PATH}"
16+
PROJECT_SUBPATH "src"
17+
PROJECT_NAME "Makefile"
18+
OPTIONS "PROCESSOR_ARCHITECTURE=${VCPKG_TARGET_ARCHITECTURE}"
19+
OPTIONS_RELEASE "DETOURS_CONFIG=Release"
20+
OPTIONS_DEBUG "DETOURS_CONFIG=Debug"
21+
)
22+
23+
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
24+
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/lib.${VCPKG_TARGET_ARCHITECTURE}Release/" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
25+
endif()
26+
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
27+
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/lib.${VCPKG_TARGET_ARCHITECTURE}Debug/" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
28+
endif()
29+
30+
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
31+
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/include/" DESTINATION "${CURRENT_PACKAGES_DIR}/include" RENAME detours)
32+
else()
33+
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/include/" DESTINATION "${CURRENT_PACKAGES_DIR}/include" RENAME detours)
34+
endif()
35+
36+
file(INSTALL "${SOURCE_PATH}/LICENSE.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
37+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

0 commit comments

Comments
 (0)