Platform SDK: Debugging and Error Handling |
The ReBaseImage function is used to change the load address for the specified image, which reduces the required load time for a DLL.
Alternatively, you can use the Rebase tool.
BOOL ReBaseImage( PSTR CurrentImageName, PSTR SymbolPath, BOOL fReBase, BOOL fRebaseSysfileOk, BOOL fGoingDown, ULONG CheckImageSize, ULONG *OldImageSize, ULONG_PTR *OldImageBase, ULONG *NewImageSize, ULONG_PTR *NewImageBase, ULONG TimeStamp );
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
The ReBaseImage function changes the desired load address for the specified image. This operation involves reading the entire image and updating all fixups, debugging information, checksum, and time stamp values. You can rebase an image to reduce the required load time for its DLLs. If an application can rely on a DLL being loaded at the desired load address, then the system loader does not have to relocate the image. The image is simply loaded into the application's virtual address space and the DllMain function is called, if one is present.
A well-behaved application has its DLLs rebased so they each fall within a unique range of the virtual address space. The system DLLs are currently based in memory from 0x70000000 to 0x78000000 (0x68000000 to 0x78000000 on MIPS). Therefore, you should base your DLLs from 0x60000000 to 0x68000000. One possible scheme is to choose a base address based on the first letter of the DLL name, as shown in the following table.
First Letter | Base Address |
---|---|
A - C | 0x60000000 |
D - F | 0x61000000 |
G - I | 0x62000000 |
J - L | 0x63000000 |
M - O | 0x64000000 |
P - R | 0x65000000 |
S - U | 0x66000000 |
V - X | 0x67000000 |
Y - Z | 0x68000000 |
By using these suggestions with the ReBaseImage function, each DLL in an application can be assigned a unique base address. This process can be part of the build process or part of the final release procedure for the application.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in Imagehlp.h.
Library: Use Imagehlp.lib.