Error attempting to list files
Opened this issue · 10 comments
Running with python 3.6.2 in Arch Linux.
$ python -m ggdump ThimbleweedPark.ggpack1 "*.png"
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.6/site-packages/ggdump/__main__.py", line 63, in <module>
main()
File "/usr/lib/python3.6/site-packages/ggdump/__main__.py", line 51, in main
gg_dir.prepare_index()
File "/usr/lib/python3.6/site-packages/ggdump/ggdump.py", line 67, in prepare_index
offset = struct.unpack('<i', ibuf[plo:plo+4])[0]
struct.error: unpack requires a bytes object of length 4
Same running Python 3.6.3 on Windows.
>python -m ggdump ThimbleweedPark.ggpack1 "*.png"
Traceback (most recent call last):
File "C:\Python\Python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python\Python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python\Python36-32\lib\site-packages\ggdump\__main__.py", line 63, in <module>
main()
File "C:\Python\Python36-32\lib\site-packages\ggdump\__main__.py", line 51, in main
gg_dir.prepare_index()
File "C:\Python\Python36-32\lib\site-packages\ggdump\ggdump.py", line 67, in prepare_index
offset = struct.unpack('<i', ibuf[plo:plo+4])[0]
struct.error: unpack requires a buffer of 4 bytes
Thanks for the reports. Maybe you could try with ggpack files from an older build of the game. The format might have slightly changed, and this code is far from robust.
With version 1420.955 of Thimbleweed Park, you need to do one extra step in the function decode_unbreakable_xor()
before returning. Like this:
for i in range(5, buf_len - 5, 16):
buffer[i] = buffer[i] ^ 0x0D
for i in range(6, buf_len - 6, 16):
buffer[i] = buffer[i] ^ 0x0D
In other words, go through the decoded array one 16-byte block at a time, and in each block, XOR every sixth and seventh byte with 0x0D
.
This works, thanks very much.
jmh79: Good job! Would you mind sending a pr?
I've actually never done that, but I guess I could give it a shot.
Looks like its changed again in .958. I cant get it to decode in the latest version.
I had a very quick look at the exe in IDA and to my untrained eye the decoding function looks unchanged between the old and this new version.
I think the magic_bytes value may have changed slightly "4FD0 A0AC 4A56 B9E5 9379 45A5 C1CB 3193" it was 4A5B in the older versions and it appears to be 4A56 now. But I'm not good enough with disassembly to solve this.
Never mind, sorted it. I dont think magic_byes changed.
To fix, on line 142:
Change eax = eax * 0x6D
To eax = eax * -0x53
Would you might making PR for these changes and one you posted into another thread?