From b9ed7a7b051513f64bfa7bf29ffaaaeaf6eea7ad Mon Sep 17 00:00:00 2001 From: Simon Jackson Date: Mon, 30 Mar 2026 00:55:39 +0100 Subject: [PATCH] feat: commit RDPWrapOffsetFinder binaries to tools/ and use them in CI instead of downloading at build time --- .github/workflows/publish-ini.yml | 60 +++--------- .github/workflows/update-finder-tools.yml | 111 ++++++++++++++++++++++ tools/RDPWrapOffsetFinder/README.md | 35 +++++++ 3 files changed, 159 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/update-finder-tools.yml create mode 100644 tools/RDPWrapOffsetFinder/README.md diff --git a/.github/workflows/publish-ini.yml b/.github/workflows/publish-ini.yml index ac0a2a7..2824531 100644 --- a/.github/workflows/publish-ini.yml +++ b/.github/workflows/publish-ini.yml @@ -5,6 +5,7 @@ on: branches: [main, master] paths: - 'res/rdpwrap.ini' + - 'tools/RDPWrapOffsetFinder/**' - '.github/workflows/publish-ini.yml' workflow_dispatch: @@ -58,55 +59,22 @@ jobs: echo "stamp=$stamp" >> $env:GITHUB_OUTPUT echo "inidate=$iniDate" >> $env:GITHUB_OUTPUT - # ── Download the latest RDPWrapOffsetFinder release zip from llccd ────── - - name: Download RDPWrapOffsetFinder + # ── Stage RDPWrapOffsetFinder from committed tools/ ────────────────────── + - name: Stage RDPWrapOffsetFinder from tools/ id: finder shell: pwsh run: | - $zip = "RDPWrapOffsetFinder.zip" + $version = (Get-Content tools/RDPWrapOffsetFinder/VERSION -Raw).Trim() - # Resolve the real latest-release download URL via the GitHub API - $apiUrl = "https://api.github.com/repos/llccd/RDPWrapOffsetFinder/releases/latest" - $release = Invoke-RestMethod -Uri $apiUrl -Headers @{ "User-Agent" = "rdpwrap-ci" } - $asset = $release.assets | Where-Object { $_.name -like "*.zip" } | Select-Object -First 1 - if (-not $asset) { throw "No zip asset found in latest RDPWrapOffsetFinder release" } - - Write-Host "Downloading $($asset.browser_download_url)" - Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $zip - - # Expand the archive - Expand-Archive -Path $zip -DestinationPath .\finder -Force - - # Diagnostic: show what we got - Write-Host "Zip contents:" - Get-ChildItem -Recurse .\finder | Select-Object FullName - - # Helper: find a file by name pattern, preferring arch-specific subdirs - function Find-Binary($pattern, $archHint) { - $hits = Get-ChildItem -Recurse -Filter $pattern .\finder - # prefer paths that contain the arch hint - $match = $hits | Where-Object { $_.FullName -match $archHint } | Select-Object -First 1 - if (-not $match) { $match = $hits | Select-Object -First 1 } - return $match - } - - $x64exe = Find-Binary "RDPWrapOffsetFinder*.exe" "x64" - $x86exe = Find-Binary "RDPWrapOffsetFinder*.exe" "x86|Win32|32" - $x64dll = Find-Binary "Zydis*.dll" "x64" - $x86dll = Find-Binary "Zydis*.dll" "x86|Win32|32" - - # If only one exe/dll variant exists, use it for both architectures - if (-not $x86exe) { $x86exe = $x64exe } - if (-not $x86dll) { $x86dll = $x64dll } - if (-not $x64exe) { throw "Could not locate RDPWrapOffsetFinder exe in zip" } - if (-not $x64dll) { throw "Could not locate Zydis dll in zip" } + Copy-Item tools/RDPWrapOffsetFinder/x64/RDPWrapOffsetFinder.exe .\RDPWrapOffsetFinder_x64.exe + Copy-Item tools/RDPWrapOffsetFinder/x64/Zydis.dll .\Zydis_x64.dll + Copy-Item tools/RDPWrapOffsetFinder/x86/RDPWrapOffsetFinder.exe .\RDPWrapOffsetFinder_x86.exe + Copy-Item tools/RDPWrapOffsetFinder/x86/Zydis.dll .\Zydis_x86.dll - Copy-Item $x64exe.FullName .\RDPWrapOffsetFinder_x64.exe - Copy-Item $x86exe.FullName .\RDPWrapOffsetFinder_x86.exe - Copy-Item $x64dll.FullName .\Zydis_x64.dll - Copy-Item $x86dll.FullName .\Zydis_x86.dll + Write-Host "Staged finder tools (version $version):" + Get-Item .\RDPWrapOffsetFinder_*.exe, .\Zydis_*.dll | Format-Table Name, Length - echo "finder_ver=$($release.tag_name)" >> $env:GITHUB_OUTPUT + echo "finder_ver=$version" >> $env:GITHUB_OUTPUT # ── Download the latest rdpWrapper GUI app from sergiye ───────────────── - name: Download rdpWrapper (sergiye) @@ -148,8 +116,7 @@ jobs: - name: Create distribution bundles shell: pwsh run: | - # RDPWrapper.zip - complete install package. - # Contains both arch DLLs, both arch wrapper exes, latest INI, and scripts. + # RDPWrapper.zip - complete install package $d = ".\bundle_wrapper" New-Item -ItemType Directory -Path $d -Force | Out-Null Copy-Item .\rdpwrap_x64.dll "$d\rdpwrap_x64.dll" @@ -163,8 +130,7 @@ jobs: Compress-Archive -Path "$d\*" -DestinationPath ".\RDPWrapper.zip" -Force Remove-Item $d -Recurse -Force - # RDPWrapOffsetFinder.zip - offset finder with per-arch subfolders. - # Extract x64\ or x86\ folder and run RDPWrapOffsetFinder.exe directly. + # RDPWrapOffsetFinder.zip - offset finder with per-arch subfolders $f = ".\bundle_finder" foreach ($arch in @('x64', 'x86')) { $dir = "$f\$arch" diff --git a/.github/workflows/update-finder-tools.yml b/.github/workflows/update-finder-tools.yml new file mode 100644 index 0000000..ed0a6f0 --- /dev/null +++ b/.github/workflows/update-finder-tools.yml @@ -0,0 +1,111 @@ +name: Update RDPWrapOffsetFinder tools + +# Run manually to pull a new version of llccd/RDPWrapOffsetFinder into tools/. +# The workflow commits the updated binaries and opens a pull request. +on: + workflow_dispatch: + inputs: + tag: + description: "llccd release tag to fetch (leave blank for latest)" + required: false + default: "" + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + +permissions: + contents: write + pull-requests: write + +jobs: + update: + runs-on: windows-2022 + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Download and extract RDPWrapOffsetFinder + id: fetch + shell: pwsh + run: | + $tag = "${{ github.event.inputs.tag }}" + if ($tag -eq "") { + $apiUrl = "https://api.github.com/repos/llccd/RDPWrapOffsetFinder/releases/latest" + } else { + $apiUrl = "https://api.github.com/repos/llccd/RDPWrapOffsetFinder/releases/tags/$tag" + } + + $release = Invoke-RestMethod -Uri $apiUrl -Headers @{ "User-Agent" = "rdpwrap-ci" } + $version = $release.tag_name + Write-Host "Fetching version $version" + + $asset = $release.assets | Where-Object { $_.name -like "*.zip" } | Select-Object -First 1 + if (-not $asset) { throw "No zip asset found in release $version" } + + Invoke-WebRequest -Uri $asset.browser_download_url -OutFile finder.zip + Expand-Archive -Path finder.zip -DestinationPath .\finder -Force + + Write-Host "Zip contents:" + Get-ChildItem -Recurse .\finder | Select-Object FullName + + function Get-Bin($pattern, $hint) { + $hits = Get-ChildItem -Recurse -Filter $pattern .\finder + $m = $hits | Where-Object { $_.FullName -match $hint } | Select-Object -First 1 + if (-not $m) { $m = $hits | Select-Object -First 1 } + return $m + } + + $x64exe = Get-Bin "RDPWrapOffsetFinder*.exe" "x64" + $x86exe = Get-Bin "RDPWrapOffsetFinder*.exe" "x86|Win32|32" + $x64dll = Get-Bin "Zydis*.dll" "x64" + $x86dll = Get-Bin "Zydis*.dll" "x86|Win32|32" + + if (-not $x86exe) { $x86exe = $x64exe } + if (-not $x86dll) { $x86dll = $x64dll } + if (-not $x64exe) { throw "Could not locate exe" } + if (-not $x64dll) { throw "Could not locate dll" } + + New-Item -ItemType Directory -Path tools\RDPWrapOffsetFinder\x64 -Force | Out-Null + New-Item -ItemType Directory -Path tools\RDPWrapOffsetFinder\x86 -Force | Out-Null + + Copy-Item $x64exe.FullName tools\RDPWrapOffsetFinder\x64\RDPWrapOffsetFinder.exe -Force + Copy-Item $x64dll.FullName tools\RDPWrapOffsetFinder\x64\Zydis.dll -Force + Copy-Item $x86exe.FullName tools\RDPWrapOffsetFinder\x86\RDPWrapOffsetFinder.exe -Force + Copy-Item $x86dll.FullName tools\RDPWrapOffsetFinder\x86\Zydis.dll -Force + Set-Content -Path tools\RDPWrapOffsetFinder\VERSION -Value $version + + Write-Host "Staged tools:" + Get-ChildItem -Recurse tools\RDPWrapOffsetFinder | Select-Object FullName, Length + + echo "version=$version" >> $env:GITHUB_OUTPUT + + - name: Commit and push to a new branch + shell: pwsh + run: | + $version = "${{ steps.fetch.outputs.version }}" + $branch = "chore/update-finder-tools-$version" + + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git checkout -b $branch + git add tools/RDPWrapOffsetFinder + git diff --cached --quiet && { Write-Host "No changes - tools already up to date"; exit 0 } + git commit -m "chore: update RDPWrapOffsetFinder tools to $version" + git push origin $branch + echo "branch=$branch" >> $env:GITHUB_OUTPUT + id: push + + - name: Create pull request + if: steps.push.outputs.branch != '' + shell: pwsh + run: | + $version = "${{ steps.fetch.outputs.version }}" + $branch = "${{ steps.push.outputs.branch }}" + gh pr create ` + --title "chore: update RDPWrapOffsetFinder tools to $version" ` + --body "Automated update of the committed RDPWrapOffsetFinder binaries in ``tools/RDPWrapOffsetFinder/`` to upstream release $version.`` Triggered manually via the Update RDPWrapOffsetFinder tools workflow.`` Merge to include the updated binaries in the next INI release." ` + --base master ` + --head $branch + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/tools/RDPWrapOffsetFinder/README.md b/tools/RDPWrapOffsetFinder/README.md new file mode 100644 index 0000000..e19777d --- /dev/null +++ b/tools/RDPWrapOffsetFinder/README.md @@ -0,0 +1,35 @@ +# RDPWrapOffsetFinder + +Pre-built binaries of [llccd/RDPWrapOffsetFinder](https://github.com/llccd/RDPWrapOffsetFinder), +committed here so that the CI pipeline and releases are self-contained and +reproducible without depending on an external release being available at build time. + +## Contents + +``` +x64/ + RDPWrapOffsetFinder.exe # x86-64 build + Zydis.dll # required runtime (x64) +x86/ + RDPWrapOffsetFinder.exe # x86 32-bit build + Zydis.dll # required runtime (x86) +VERSION # version tag of the upstream release +``` + +## Usage + +Extract the appropriate arch folder and run: + +``` +.\RDPWrapOffsetFinder.exe C:\Windows\System32\termsrv.dll +``` + +The output `[10.0.xxxxx.xxxxx]` section can be appended to `res/rdpwrap.ini` +and submitted as a pull request. + +## Updating + +To update the binaries when llccd releases a new version, trigger the +`Update RDPWrapOffsetFinder tools` workflow from the Actions tab +(`.github/workflows/update-finder-tools.yml`). +It will download the latest release, update this folder, and open a pull request.