RAD Studio (Common)
ContentsIndex
PreviousUpNext
Image base address
Type  
Parameter  
Syntax  
{$IMAGEBASE number}  
Default  
{$IMAGEBASE $00400000}  
Scope  
Global  

The $IMAGEBASE directive controls the default load address for an application, DLL, or package. The number argument must be a 32-bit integer value that specifies image base address. The number argument must be greater than or equal to $00010000, and the lower 16 bits of the argument are ignored and should be zero. The number must be a multiple of 64K (that is, a hex number must have zeros as the last 4 digits) otherwise it will be rounded down to the nearest multiple, and you will receive a compiler message. 

When a module (application or library) is loaded into the address space of a process, Windows will attempt to place the module at its default image base address. If that does not succeed, that is if the given address range is already reserved by another module, the module is relocated to an address determined at runtime by Windows. 

There is seldom, if ever, any reason to change the image base address of an application. For a library, however, it is recommended that you use the $IMAGEBASE directive to specify a non-default image base address, since the default image base address of $00400000 will almost certainly never be available. The recommended address range of DLL images is $40000000 to $7FFFFFFF. Addresses in this range are always available to a process in both Windows NT/2000 and Windows 95/98. 

When Windows succeeds in loading a DLL (or package) at its image base address, the load time is decreased because relocation fix-ups do not have to be applied. Furthermore, when the given address range is available in multiple processes that use the library, code portions of the DLL's image can be shared among the processes, thus reducing load time and memory consumption.

Note: Note: The $IMAGEBASE directive overrides any value supplied with the -K command line compiler directive option.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!