Created
February 8, 2018 05:25
-
-
Save dogtopus/a9eee9e9f513d4975ea5cac252d406cc to your computer and use it in GitHub Desktop.
Fix RGSS3A headers scrambled by Fux2Pack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import struct | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
print('Usage:', sys.argv[0], '<fux2packedrgss3a>') | |
sys.exit(1) | |
hdr = struct.Struct('<8sI') | |
with open(sys.argv[1], 'rb+') as f: | |
header = hdr.unpack_from(f.read(12)) | |
if header[0] != b'Fux2Pack': | |
print('No fuxxed pack to fsck. Stop') | |
sys.exit(1) | |
# Old and good number theory | |
metadata_key = ((header[1] - 3) * 0x38E38E39) & 0xffffffff | |
print(hex(header[1]), '->', hex(metadata_key)) | |
f.seek(0) | |
f.write(hdr.pack(b'RGSSAD\x00\x03', metadata_key)) | |
print('Fscked. Good luck.') |
天了!如有神助,感谢啊,太好用了!
感谢大佬!太好用了
非常感谢
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
感谢,特意注册来谢谢。这个代码太好用了!