LabWindows/CVI

取消
显示结果 
搜索替代 
您的意思是: 

How can I change the Base Address of a DLL?

DLLs created with LabWindows/CVI will always use the same base address 0x10000000.
Even the system DLLs like CVIRTE, CVIAUTO, GPIB-32, VISA32, etc. always use this base address.
So anytime, a CVI application is using more than one DLL, the DLLs need to be relocated by the system. Especially, as DLLs created with LabWindows/CVI use a large import section, the relocation will take a while.
A simple solution could be, that LabWindows/CVI offers a linker option to select the base address of DLLs. This will certainly speed up LabWindows/CVI applications.

BR,

Dieter Pawelczak
0 项奖励
1 条消息(共 3 条)
5,670 次查看
You can use rebase.exe which ships with MSVC and the SDK. I have included the file with this message.

I have included the documentation from the SDK on how to use it..

Chris

--
Rebase
Rebase is a command-line tool that you can use to specify the base addresses for the DLLs that your application uses.

The base address of a DLL is the location in virtual memory where the loader attempts to place the DLL. It is generally specified at link time. If a DLL cannot load at its base address because the memory is already occupied, the loader places the DLL elsewhere in virtual memory, then updates all calls into the DLL to reflect the new base address. Making these changes can be time consuming, because the image must be copied to the pagefile and modified for the new address. If you have a large application that uses many DLLs, it is important for each DLL to have a different base address to minimize load time. You will receive the following warning from the loader if a DLL is relocated:

LDR: Automatic DLL Relocation in ProcessName.
LDR: DLL ImageName base ImageBase relocated due to collision with ExistingImage.

When you pass all the DLLs for your application to Rebase, it bases each DLL at a unique address. You should not pass your .EXE file to Rebase. It is the first thing to be loaded, so there is no chance that something else can already be loaded at its default load address.

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.

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


It is best to base DLLs from the top of the address range down, instead of from the bottom up. Dynamic memory is allocated from the bottom up and if a DLL tries to load where dynamic memory has been allocated, it will be relocated, just as if a DLL was loaded at that address.

To use Rebase to base your DLLs, use the following syntax:

rebase [options] image-names
Rebase has the following command-line options:

-b initial_base
Specify initial base address. It is mandatory that you use either the -b or -i option.
-i coffbase_filename
Read base addresses from the file coffbase_filename. It is mandatory that you use either the -b or -i option.
-c coffbase_filename
Write the list of base addresses to the file coffbase_filename. The filename extension is not included. Use -C to include filename extensions.
-d
Perform a top-down rebase.
-l logFilePath
Write image bases to log file.
-z
Allow rebasing the system file.
-R image_root
Set a root directory for use by the -G, -O, -N options.
-G filename
Group specified images together in address space. May be used multiple times. Specify a root directory with the -R option.
-N filename
Leave specified images at their original addresses. May be used multiple times. Specify a root directory with the -R option.
-O filename
Overlay images in address space. May be used multiple times. Specify a root directory with the -R option.
-x symbol_dir
Extract debug information into separate .DBG file before rebasing. Use symbol_dir to place the .DBG files are placed in the directories symbol_dir\EXE or symbol_dir\DLL, depending on whether the source is an .EXE file or a .DLL file. To specify the current directory for the symbol directory, use a period (.).
-p
Used with the -x option. Remove private debug information when creating .DBG files.
-a
Used with the -x option. Extract all debug information into the .DBG files.
-f
Strip relocations after rebasing the image. Causes failure to load.
-s
Just sum image range.
-q
Minimal output.
-v
Verbose output.
-?
Display command-line syntax.
0 项奖励
2 条消息(共 3 条)
5,670 次查看
In the Dec. 2000 Windows Developer's Journal (www.wdj.com)
Thiadmer Riemersma wrote an article on a utility he wrote
called, Libase, that works similar to MS's rebase utility
but its more flexible i.e. it allows 256 different base
addresses instead of just the 9 allowed by MS rebase.

You can find the article here:
http://www.wdj.com/articles/2000/0012/0012b/0012b.htm?topic=articles
and the source code for libase here:
ftp://ftp.wdj.com/pub/2000/dec2000.zip


"dieterp" wrote in message
news:5065000000080000006D1D0000-986697009000@quiq.com...
> DLLs created with LabWindows/CVI will always use the same base address
> 0x10000000.
> Even the system DLLs like CVIRTE, CVIAUTO, GPIB-32, VISA32, etc.
> always use this base address.
> So anytime, a CVI application
is using more than one DLL, the DLLs
> need to be relocated by the system. Especially, as DLLs created with
> LabWindows/CVI use a large import section, the relocation will take a
> while.
> A simple solution could be, that LabWindows/CVI offers a linker option
> to select the base address of DLLs. This will certainly speed up
> LabWindows/CVI applications.
>
> BR,
>
> Dieter Pawelczak
0 项奖励
3 条消息(共 3 条)
5,670 次查看