Skip to content

Commit 6ccab4e

Browse files
committed
Add in-place repatching unit test and Heavyweight Electron pipeline validation
1 parent 08d241d commit 6ccab4e

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,28 @@ jobs:
8080
# Perform the definitive check
8181
cmp final_rust.exe final_cs.exe
8282
echo "SUCCESS: Bit-for-bit compatibility achieved!"
83+
84+
- name: Heavyweight Real-World Validation (Electron Browser Shell)
85+
working-directory: verification_env
86+
run: |
87+
echo "--> Downloading standalone Electron x64 binary..."
88+
curl -L https://github.com/electron/electron/releases/download/v28.2.0/electron-v28.2.0-win32-x64.zip -o electron_bin.zip
89+
unzip electron_bin.zip electron.exe
90+
91+
echo "--> Executing Heavyweight Binary Parity Test (electron.exe)"
92+
93+
# Rust side
94+
cp electron.exe target_electron.exe
95+
../target/release/gpupatch target_electron.exe rust_electron.exe
96+
97+
# C# Side (Restoring target path so names match)
98+
cp electron.exe target_electron.exe
99+
dotnet exec ${{ env.TOOL_DLL }} target_electron.exe --enable
100+
mv target_electron.exe cs_electron.exe
101+
102+
echo "--> Electron Validation Finalization:"
103+
sha256sum rust_electron.exe
104+
sha256sum cs_electron.exe
105+
106+
cmp rust_electron.exe cs_electron.exe
107+
echo "EPIC SUCCESS: Deep compatibility verified on heavyweight Chromium shell!"

src/main.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,4 +553,30 @@ mod tests {
553553

554554
assert_eq!(p1, p2, "Deterministic patching failed");
555555
}
556+
557+
#[test]
558+
fn test_inplace_repatching() {
559+
let mock = create_mock_pe();
560+
561+
// 1. First pass: appends the section
562+
let patched_v1 = patch_pe(&mock, false, "app.exe").unwrap();
563+
let pe_ptr = read_u32(&patched_v1, 0x3C) as usize;
564+
let coff = pe_ptr + 4;
565+
assert_eq!(read_u16(&patched_v1, coff + 2), 2, "Should have generated section");
566+
567+
// 2. Second pass: updates it to disabled. It must NOT add another section!
568+
let patched_v2 = patch_pe(&patched_v1, true, "app.exe").unwrap();
569+
let pe_ptr2 = read_u32(&patched_v2, 0x3C) as usize;
570+
assert_eq!(read_u16(&patched_v2, pe_ptr2 + 6), 2, "Should have kept 2 sections (in-place edit)");
571+
572+
// 3. Verify it's actually disabled (value is 0)
573+
// In our mock, target_val sits at the beginning of new section's raw data.
574+
// The new section's raw data is appended at 1024.
575+
assert_eq!(read_u32(&patched_v2, 1024), 0, "Symbol value should have been toggled to 0");
576+
577+
// 4. Third pass: toggle back to enabled.
578+
let patched_v3 = patch_pe(&patched_v2, false, "app.exe").unwrap();
579+
assert_eq!(read_u32(&patched_v3, 1024), 1, "Symbol value should have been toggled back to 1");
580+
assert_eq!(read_u16(&patched_v3, pe_ptr2 + 6), 2, "Section count remains 2");
581+
}
556582
}

0 commit comments

Comments
 (0)