Skip to content

Commit 08d241d

Browse files
committed
feat: implement PE file patcher for NVIDIA and AMD GPU enablement exports
0 parents  commit 08d241d

5 files changed

Lines changed: 665 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Rust PE Patcher Verification
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build-and-verify:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Source
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Rust Toolchain
21+
uses: actions-rs/toolchain@v1
22+
with:
23+
toolchain: stable
24+
override: true
25+
26+
- name: Install .NET Core SDK
27+
uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: 8.0.x
30+
31+
- name: Build Rust Package
32+
run: cargo build --release
33+
34+
- name: Run Embedded Rust Unit Tests
35+
run: cargo test --verbose
36+
37+
- name: Download and Setup Original C# Tool Verification
38+
run: |
39+
mkdir -p verification_env
40+
cd verification_env
41+
curl -L https://www.nuget.org/api/v2/package/Topten.nvpatch -o nvpatch_pkg.zip
42+
unzip nvpatch_pkg.zip -d tool_extracted
43+
44+
# Fetch the bundled sample EXE to use as standard test file
45+
cp tool_extracted/tools/net8.0/any/Topten.nvpatch.exe ./subject.exe
46+
47+
# Set the Path to original tool's DLL
48+
echo "TOOL_DLL=$(pwd)/tool_extracted/tools/net8.0/any/Topten.nvpatch.dll" >> $GITHUB_ENV
49+
50+
- name: Perform End-to-End Binary Comparison Matrix
51+
working-directory: verification_env
52+
run: |
53+
# Prepare distinct workspace for parity test
54+
cp subject.exe rust_input.exe
55+
cp subject.exe cs_input.exe
56+
57+
echo "--> Running Rust Implementation"
58+
../target/release/gpupatch rust_input.exe rust_output.exe
59+
60+
echo "--> Running Reference C# Implementation"
61+
# We pass the filename first to mirror the C# tool's argument bug correctly for parity
62+
dotnet exec ${{ env.TOOL_DLL }} cs_input.exe --enable
63+
mv cs_input.exe cs_output.exe
64+
65+
# Normalize potential filename difference internally in the output binaries for 100% identity check
66+
# Actually, by passing the exact input filenames we named, they embed custom strings.
67+
# Let's use a standardized filename so the embedded string remains exactly equal!
68+
69+
cp subject.exe target.exe
70+
../target/release/gpupatch target.exe final_rust.exe
71+
72+
cp subject.exe target.exe
73+
dotnet exec ${{ env.TOOL_DLL }} target.exe --enable
74+
mv target.exe final_cs.exe
75+
76+
echo "--> Validation Results:"
77+
sha256sum final_rust.exe
78+
sha256sum final_cs.exe
79+
80+
# Perform the definitive check
81+
cmp final_rust.exe final_cs.exe
82+
echo "SUCCESS: Bit-for-bit compatibility achieved!"

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/target
2+
csharp-original/
3+
nvpatch-rs/
4+
5+
# Verification and temporary analysis files
6+
scratch/
7+
nvpatch.zip
8+
nvpatch_dotnet_pkg/
9+
10+
# IDE and OS garbage
11+
.DS_Store
12+
Thumbs.db
13+
.vscode/
14+
.idea/

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "gpupatch"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]

0 commit comments

Comments
 (0)