thpatch / thcrap

Touhou Community Reliant Automatic Patcher
https://www.thpatch.net
The Unlicense
573 stars 42 forks source link

thcrap_tsa: Support translation of hardcoded strings #15

Closed nmlgc closed 11 years ago

nmlgc commented 11 years ago

Hardcoded strings

Description

"Hardcoded strings" here means "immutable strings stored at a constant address in memory". This allows us to do a lookup solely based on the address.

Prerequisites

None. Also needs to work with #3, though.

Implementation

This consists of four parts:

  1. Basic lookup function based on a string's address
  2. Hooks for TextOut, MessageBox and possibly other Win32 API functions calling the lookup function
  3. Breakpoint to call the lookup function (unnecessary; hardcoded strings are either fully constant (which means our hooks take care of them anyway) or format strings (see below).)
  4. Custom sprintf handler

No. 4 is necessary because some of these hardcoded strings are sprintf format strings, and we shouldn't trust on the game's own buffers being large enough.

nmlgc commented 11 years ago

Marked as a bug because the "buffer overflow fixes" in base_tsa actually remove a sprintf call, breaking a lot of result screens in the process:

Here's some breakage in the "overall" result screen.