Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ settings.json
[Rr]eleases/
x64/
x86/
arm64/
AnyCPU/
Fuzzing/
bld/
Expand Down
49 changes: 45 additions & 4 deletions src/VcpkgPortOverlay/CreatePortOverlay.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,44 @@ function Add-PatchToPortFile
$modifiedPortFile | Out-File $portFilePath
}

# Removes all patches from portfile.cmake
function Remove-PortPatches
{
param(
[Parameter(Mandatory)]
[string]$Port
)

# Look for the line that says "PATCHES"

$portFilePath = Join-Path $OverlayRoot $Port "portfile.cmake"
$originalPortFile = Get-Content $portFilePath

$modifiedPortFile = @()
foreach ($line in $originalPortFile)
{
if ($line.TrimEnd().EndsWith("PATCHES"))
{
$foundPatches = $true
}
elseif ($line -eq ")")
{
$foundParen = $true
$modifiedPortFile += $line
}
elseif ($foundPatches -and -not $foundParen)
{
# Drop line
}
else
{
$modifiedPortFile += $line
}
}

$modifiedPortFile | Out-File $portFilePath
}

# Adds a patch to a port
function Add-PatchToPort
{
Expand Down Expand Up @@ -275,13 +313,12 @@ function Update-PortSource
[Parameter(Mandatory)]
[string]$Commit,
[Parameter(Mandatory)]
[string]$SourceHash
[string]$SourceHash,
[string]$RefPattern = '[0-9a-f]{40}( #.*)?$'
)

$portDir = Join-Path $OverlayRoot $Port

# For the REF, we also delete any comments after it that may say the wrong version
Set-ParameterInPortFile $Port -ParameterName 'REF' -CurrentValuePattern '[0-9a-f]{40}( #.*)?$' -NewValue "$Commit # Unreleased"
Set-ParameterInPortFile $Port -ParameterName 'REF' -CurrentValuePattern $RefPattern -NewValue "$Commit # Unreleased"
Set-ParameterInPortFile $Port -ParameterName 'SHA512' -CurrentValuePattern '[0-9a-f]{128}' -NewValue $SourceHash
}

Expand All @@ -302,6 +339,10 @@ function Update-PortVersion
New-PortOverlay cpprestsdk -Version 2.10.18 -PortVersion 4
Add-PatchToPort cpprestsdk -PatchRepo 'microsoft/winget-cli' -PatchCommit '888b4ed8f4f7d25cb05a47210e083fe29348163b' -PatchName 'add-server-certificate-validation.patch' -PatchRoot 'src/cpprestsdk/cpprestsdk'

New-PortOverlay detours -Version 4.0.1 -PortVersion 8
Update-PortSource detours -RefPattern 'v4.0.1' -Commit '404c153ff390cb14f1787c7feeb4908c6d79b0ab' -SourceHash '1f3f26657927fa153116dce13dbfa3319ea368e6c9017f4999b6ec24d6356c335b3d5326718d3ec707b92832763ffea092088df52596f016d7ca9b8127f7033d'
Remove-PortPatches detours

New-PortOverlay libyaml -Version 0.2.5 -PortVersion 5
Update-PortSource libyaml -Commit '840b65c40675e2d06bf40405ad3f12dec7f35923' -SourceHash 'de85560312d53a007a2ddf1fe403676bbd34620480b1ba446b8c16bb366524ba7a6ed08f6316dd783bf980d9e26603a9efc82f134eb0235917b3be1d3eb4b302'
Update-PortVersion libyaml
13 changes: 12 additions & 1 deletion src/VcpkgPortOverlay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ Note that we use v2.10.18, which is not the latest.

Changes:
* Add patch file: `add-server-certificate-validation.patch`
Patch source: https://github.com/microsoft/winget-cli/commit/888b4ed8f4f7d25cb05a47210e083fe29348163b
* Patch source: https://github.com/microsoft/winget-cli/commit/888b4ed8f4f7d25cb05a47210e083fe29348163b

## detours

We use the version used by UndockedRegFreeWinRT (https://github.com/microsoft/winget-cli/tree/release-v1.10/src/Xlang/UndockedRegFreeWinRT/src/UndockedRegFreeWinRT/detours).
The only official release of detours (4.0.1) does not include complete support for ARM64.
While the exact version that we pulled from UndockedRegFreeWinRT is unclear (https://github.com/microsoft/xlang/pull/644), through manually comparing versions it is equivalent to
https://github.com/microsoft/Detours/commit/404c153ff390cb14f1787c7feeb4908c6d79b0ab (only some whitespace changes are present).

Changes:
* New source commit: https://github.com/microsoft/Detours/commit/404c153ff390cb14f1787c7feeb4908c6d79b0ab
* Remove the patch on the official port as it is already present in the newer commit

## libyaml

Expand Down
24 changes: 24 additions & 0 deletions src/VcpkgPortOverlay/detours/find-jmp-bounds-arm64.patch
Original file line number Diff line number Diff line change
@@ -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);
34 changes: 34 additions & 0 deletions src/VcpkgPortOverlay/detours/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO microsoft/Detours
REF 404c153ff390cb14f1787c7feeb4908c6d79b0ab # Unreleased
SHA512 1f3f26657927fa153116dce13dbfa3319ea368e6c9017f4999b6ec24d6356c335b3d5326718d3ec707b92832763ffea092088df52596f016d7ca9b8127f7033d
HEAD_REF master
)

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}")
7 changes: 7 additions & 0 deletions src/VcpkgPortOverlay/detours/usage
Original file line number Diff line number Diff line change
@@ -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})
9 changes: 9 additions & 0 deletions src/VcpkgPortOverlay/detours/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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"
}