39 lines
816 B
Python
39 lines
816 B
Python
#!/usr/bin/env python3
|
|
import sys
|
|
|
|
desp = 0x2000
|
|
numBytes = 0x2000
|
|
firstByte = desp + 0x200
|
|
lastByte = desp + numBytes - 1
|
|
checksum1 = desp + 0x270
|
|
checksum2 = desp + 0x271
|
|
|
|
def calc_checksum(buffer):
|
|
total = 0
|
|
for i in range(firstByte, lastByte + 1):
|
|
if i not in (checksum1, checksum2):
|
|
total += buffer[i]
|
|
total += 3328
|
|
buffer[checksum1] = total % 256
|
|
buffer[checksum2] = (total >> 8) % 256
|
|
|
|
if len(sys.argv) != 3:
|
|
print("Uso: python3 revert_2934.py save_in.srm save_out.srm")
|
|
sys.exit(1)
|
|
|
|
infile = sys.argv[1]
|
|
outfile = sys.argv[2]
|
|
|
|
with open(infile, "rb") as f:
|
|
buf = bytearray(f.read())
|
|
|
|
# revertir el posible flag del armario
|
|
buf[0x02934] = 0xEE # valor original
|
|
|
|
calc_checksum(buf)
|
|
|
|
with open(outfile, "wb") as f:
|
|
f.write(buf)
|
|
|
|
print("Hecho:", outfile)
|