|
| 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!" |
0 commit comments