Skip to content

Instantly share code, notes, and snippets.

@dogtopus
Created February 8, 2018 05:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dogtopus/a9eee9e9f513d4975ea5cac252d406cc to your computer and use it in GitHub Desktop.
Save dogtopus/a9eee9e9f513d4975ea5cac252d406cc to your computer and use it in GitHub Desktop.
Fix RGSS3A headers scrambled by Fux2Pack
#!/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.')
@dogtopusfans
Copy link

感谢,特意注册来谢谢。这个代码太好用了!

@dogtopusfans
Copy link

天了!如有神助,感谢啊,太好用了!

@DeathPayner
Copy link

感谢大佬!太好用了

@rinimabi412
Copy link

非常感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment