Getting a module's base address and bound
Posted on 2007-08-09
How can I obtain a module's base address and bound in memory? I have a DLL that I wrote, which is being loaded by an EXE (that I did *not* write) as a CBT Hook. I want to muddle with the memory of the EXE and alter a few instructions. I know the pattern I'm searching for and what I want to replace it with, but can't figure out how to obtain the base address to start searching from on-the-fly, as well as the ending address for that EXE module.
I want to dynamically find the base address and bound somehow, since the default base address specified in the PE header isn't always available and Windows can shift things around.