News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Defining an explicit address for a function

Started by Matt.J, January 15, 2011, 02:21:50 AM

Previous topic - Next topic

Matt.J

Hello,

Is it possible within MASM to define the placement (address) of a function? e.g, foo() to be located at RVA 0x12345

dedndave

that kind of stuff is kind of frowned on in here

clive

The first question would be why would you need that level of control?

In 32-bit code you could direct the linker to base the executable at a specific address, provided the system can loaded it where you want, for DLL's the system is likely to want to rebase the code.

In 16-bit code you should be able to specify absolute addresses, but that's not particularly useful as things are usually loaded at arbitrary addresses. Mostly it could be used to specify things in the BIOS ROM, or the BIOS data area, or video buffer.
It could be a random act of randomness. Those happen a lot as well.

Matt.J

Although irrelevant; I'm writing a video emulation layer for an old game.

As I said, defining the relative address of a function; not the load address.

clive

It's going to be hard to do. You could certainly pad the gap between subroutines to achieve certain goal addresses. You might be able to use the AT directive with the segment definitions, or define multiple segments with specific alignments, say 0x400, 0x1000, 0x10000, within an executable.

Specifically why do the addresses need to be fixed in this manner? Are you trying to achieve some interlinking between some other system/user components? Or splicing some new code into an existing application or DLL?
It could be a random act of randomness. Those happen a lot as well.

redskull

Strange women, lying in ponds, distributing swords, is no basis for a system of government