883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
15 lines
975 B
Python
15 lines
975 B
Python
import hashlib,sys,tempfile,unittest
|
|
from pathlib import Path
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from windows_image_profile import source_bytes,prepare,PIN
|
|
class Image(unittest.TestCase):
|
|
def test_only_relocation_header_changes_and_original_identity_is_recoverable(self):
|
|
original=(Path(__file__).resolve().parents[1]/'runtime/vm-build-share/Forever-Octo-Linux-20261022-r3/runtime/native-client/_classic_beta_/WowB.exe').read_bytes()
|
|
with tempfile.TemporaryDirectory()as folder:
|
|
p=Path(folder)/'WowB.exe';p.write_bytes(original);receipt=prepare(p);patched=p.read_bytes()
|
|
self.assertEqual(hashlib.sha256(original).hexdigest(),PIN);self.assertEqual(source_bytes(patched),original)
|
|
self.assertLessEqual(sum(a!=b for a,b in zip(original,patched)),2);self.assertNotEqual(receipt['patched_sha256'],PIN)
|
|
bad=bytearray(patched);bad[-1]^=1
|
|
with self.assertRaises(ValueError):source_bytes(bad)
|
|
if __name__=='__main__':unittest.main()
|