Th13/Binary hacks

From Touhou Patch Center
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Bugs

Safe sprintf (call #1)
(sprintf_call_1)
Address
v1.00c0x46ea5f
Code
50
e8 [strings_vsprintf]
8985 7cffffff
89bd 78ffffff
push eax
call [strings_vsprintf]
mov dword ptr ss:[ebp-0x84],eax
mov dword ptr ss:[ebp-0x88],edi
Safe sprintf (call #2)
(sprintf_call_2)
Address
v1.00c0x46e914
Code
50
e8 [strings_vsprintf]
8985 78ffffff
push eax
call [strings_vsprintf]
mov dword ptr ss:[ebp-0x88],eax
Safe sprintf (call #3)
(sprintf_call_3)
Address
v1.00c0x46e99f
Code
50
e8 [strings_vsprintf]
8985 74ffffff
push eax
call [strings_vsprintf]
mov dword ptr ss:[ebp-0x8c],eax
Safe sprintf (replace pointer)
(sprintf_rep)
Address
v1.00c0x46e94c, 0x46ea0c, 0x46eac9
Code
8b
mov ebx, dword ptr ss:[

Logging

Restore the game's built-in logging
(log_restore)
Description Very useful for debugging.
Address
v1.00c0x475030
Code
e9 [log_printf]
jmp [log_printf]

Textbox size

Correct text length calculation for Fairy Wars-style text boxes
(fw_textbox_size)
Description Same hack as for th128.
Address
v1.00a0x428e49, 0x42906b
v1.00b0x428ee9, 0x42910b
v1.00c0x428eb9, 0x4290db
Code
90
90
56
e8 [GetTextExtent]
89c1
nop
nop
push esi
call [GetTextExtent]
mov ecx, eax

Spells

Spell card alignment
(spell_align)
Description The last three instructions would be unnecessary, but are, again, required for this to work with gensokyo.org's English patch.
Address
v1.00c0x46e9cb
Code
ff75 10
c1e9 0c
83e1 01
51
ff75 0c
ff75 08
ff35 10c34d00
ffb5 74ffffff
e8 [GetTextExtentForFont]
83c0 08
50
db04e4
58
v1.00c79 06 d805 b0ea4a00 dee9
push dword ptr ss:[ebp+0x10]        ; Optimized original code
shr ecx,0x0c
and ecx,00000001
push ecx
push dword ptr ss:[ebp+0x0c]
push dword ptr ss:[ebp+8]
push dword ptr ds:[th13.font_spell] ; Spell card alignment
push dword ptr ss:[ebp-0x8c]
call [GetTextExtentForFont]
add eax,8
push eax
fild dword ptr ss:[esp]
pop eax

jns short +6                        ; gensokyo.org
fadd dword ptr ds:[th13.4aeab0]
fsubp st(1),st

Player data

Remove spell "alignment" in the result screen
(result_spell_align)
Description When kept short, it also works with gensokyo.org's patch.
Address
v1.00c0x46eac3
Code
31c0
xor eax,eax

Compatibility

Remove English patch font creation
(unpatch_fonts)
Description At this position, the English patch jumps to its font creation code, located in th13e.dll. Since we don't patch the import table of this DLL, its CreateFontA calls are still mapped to the actual system function, effectively ignoring thcrap's own font settings. This hack simply re-inserts the original game code from that position.
Address
v1.00c0x45ad24
Code
68 e4cc4a00
6a 11
6a 04
push th13.04acce4
push 11
push 4
Remove English patch replacement for the resolution dialog
(unpatch_dialog)
Description Come on. You could have just replaced the pointer directly instead of ripping out the original function call and replacing it with your dummy function that... replaces the pointer. -.-
Address
v1.00c0x45c3a1
Code
ff15 f8214a00
call [DialogBoxParamA]
Remove English patch text formatting tag parsing
(unpatch_layout)
Description It's not because we don't like your formatting tags, it's because you don't give us any chance to parse our own... which requires the exact absence of any binary hacks jumping into a different module. And well, pixel definitions are just not the way to go for an open, multilingual system.
Address
v1.00c0x45afbe
Code
75 77
8b4d 18
51
56
ff15 18204a00
8b45 0c
53
03c0
57
8945 e4
6a 04
83c0 02
50
jnz short +0x77
mov ecx,dword ptr ss:[arg.5]
push ecx
push esi
call [SetTextColor]
mov eax,dword ptr ss:[arg.2]
push ebx
add eax,eax
push edi
mov dword ptr ss:[local.7],eax
push 4
add eax,2
push eax

Hardcoded strings

One hack per hardcoded string. Wonderful!

Remove English patch hardcoded string replacements (Result Known Spell)
(unpatch_strings_result_known_spell)
Address
v1.00cRx53ced
Code
68 4cc84a00
push th13.004ac84c
Remove English patch hardcoded string replacements (Result Unknown Spell)
(unpatch_strings_result_unknown_spell)
Address
v1.00cRx53d54
Code
68 60c84a00
push th13.004ac860