Open nmlgc opened 6 years ago
crash is at strncmp
, presumably because of second argument (ESI: 0x00000001
).
one level up the stack is 44858D
(which I dubbed versioncmp
). Looks like it's compares it's arguments against contents of th08_0100d.ver
from the dat. The check always succeeds if pointer to file contents is NULL, but here it seems that the pointer is 0x00000001 in this case. That pointer is located at this + 0x360
. Additionally, size of the file is stored at this + 0x35C
.
another level up is 45A5E0
(score_load
), which checks the score file and recreates it, if it has errors. The object used as this
in versioncmp
call is 17CE758
.
Conclusion: pointer to th08_0100d.ver
contents is at 17CEAB8
. Something corrupts that memory.
Will do further investigation with a debugger later.
The scorefile has a sort of checksum in it that is used to validate which version the scorefile was made in. The game will loop through th08_0100d.ver until it finds a line that matches the checksum in the scorefile. That's it, the game reaching the end of the file will not stop it from continuing to loop, then reading past the file and reaching invalid memory. https://github.com/thpatch/thcrap-tsa/commit/cc8f8dbf90add9eebc50a7366d9dd9f97af6af10 will even write a valid checksum if the one in the scorefile is invalid
Here's a
score.dat
for TH08 that crashes the game on startup:Other games might be affected by similar ZUN bugs.
We probably can't restore those in case of a corruption, but it would be nice to print a more specific error, with the option of creating a new score file, rather than just crashing and forcing players to debug the issue themselves.
Bonus points for actually preventing the root cause.