thpatch / thcrap

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

Support dynamic base addresses #3

Closed nmlgc closed 11 years ago

nmlgc commented 11 years ago

Dynamic base addresses

Description

Right now, thcrap_loader, the binary hack system and the breakpoint system all assume a game's main module to be loaded at a constant place in memory. Thus, a game loaded to a dynamic base address essentially can't be patched at all.

This feature is required for supporting Hopeless Masquerade and the PC-98 games at all.

Prerequisites

None.

Implementation

Riatre commented 11 years ago

Would you like to explain why we need a scheme using PE section names? I think finding the base address by module name(maybe NULL for main exe module) then using RVA to locate is enough for binhack and breakpoint addresses, at least on Windows. For PC-98 DOS, there are even no PE sections.

nmlgc commented 11 years ago

Yeah, you're right. I was under the impression that base address randomization could also randomly move the individual PE sections, but after some research (which I admittedly haven't done when posting the implementation part), that doesn't seem to be the case.

On PC-98 DOS, I have verified that, I just wasn't so sure about Windows. So, RVA is the way to go.