Th13/Binary hacks

From Touhou Patch Center
Jump to: navigation, search

Bugs

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

Logging

Restore the game's built-in logging
(log_restore)
Description Very useful for debugging.
Address
v1.00c0x475030
Code
  1. e9 [log_printf]
  1. 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
  1. 90
  2. 90
  3. 56
  4. e8 [GetTextExtent]
  5. 89c1
  1. nop
  2. nop
  3. push esi
  4. call [GetTextExtent]
  5. 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
  1. ff75 10
  2. c1e9 0c
  3. 83e1 01
  4. 51
  5. ff75 0c
  6. ff75 08
  7. ff35 10c34d00
  8. ffb5 74ffffff
  9. e8 [GetTextExtentForFont]
  10. 83c0 08
  11. 50
  12. db04e4
  13. 58
  14. v1.00c79 06 d805 b0ea4a00 dee9
  1. push dword ptr ss:[ebp+0x10]        ; Optimized original code
  2. shr ecx,0x0c
  3. and ecx,00000001
  4. push ecx
  5. push dword ptr ss:[ebp+0x0c]
  6. push dword ptr ss:[ebp+8]
  7. push dword ptr ds:[th13.font_spell] ; Spell card alignment
  8. push dword ptr ss:[ebp-0x8c]
  9. call [GetTextExtentForFont]
  10. add eax,8
  11. push eax
  12. fild dword ptr ss:[esp]
  13. pop eax
  14.  
  15. jns short +6                        ; gensokyo.org
  16. fadd dword ptr ds:[th13.4aeab0]
  17. 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
  1. 31c0
  1. 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
  1. 68 e4cc4a00
  2. 6a 11
  3. 6a 04
  1. push th13.04acce4
  2. push 11
  3. 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
  1. ff15 f8214a00
  1. 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
  1. 75 77
  2. 8b4d 18
  3. 51
  4. 56
  5. ff15 18204a00
  6. 8b45 0c
  7. 53
  8. 03c0
  9. 57
  10. 8945 e4
  11. 6a 04
  12. 83c0 02
  13. 50
  1. jnz short +0x77
  2. mov ecx,dword ptr ss:[arg.5]
  3. push ecx
  4. push esi
  5. call [SetTextColor]
  6. mov eax,dword ptr ss:[arg.2]
  7. push ebx
  8. add eax,eax
  9. push edi
  10. mov dword ptr ss:[local.7],eax
  11. push 4
  12. add eax,2
  13. 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
  1. 68 4cc84a00
  1. push th13.004ac84c
Remove English patch hardcoded string replacements (Result Unknown Spell)
(unpatch_strings_result_unknown_spell)
Address
v1.00cRx53d54
Code
  1. 68 60c84a00
  1. push th13.004ac860