假设我有3个模块,一个user.exe,另外两个是A.dll,B.dll。
在编译链接各个模块时,我利用VS默认的base address,这样user.exe的默认基地址是0x00400000h,A或B的基地址是0x10000000h。这样,当加载器加载User.exe(它同时隐式链接A,B)。这样,A,B就会有一个被迫改变默认的基地址;从而导致映像文件里的机器代码指令(包含的硬编码地址)与加载后的不一样,从而需要调整(效率就会降低)。
我知道在vs中编译链接的时候可以利用 set baseaddress 修改。但是,假设我的可执行模块需要更多的dll时,我就希望利用工具(rebase)来修改。不过不会用!
请各位大虾帮忙!谢谢。
ps:M i c r o s o f t在销售Wi n d o w s操作系统之前,在操作系统提供的所有文件上运行了R e b a s e程序,因此,如果将它们映射到单个地址空间中,所有的操作系统模块都不会重叠。

解决方案 »

  1.   

    怎么用记不得了,Windows核心编程里面有
      

  2.   

    rebase是一个SDK工具。用法执行一下就会显示
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin>rebase
    usage: REBASE [switches]
                  [-R image-root [-G filename] [-O filename] [-N filename]]
                  image-names...              One of -b and -i switches are mandatory.              [-a] Does nothing
                  [-b InitialBase] specify initial base address
                  [-c coffbase_filename] generate coffbase.txt
                      -C includes filename extensions, -c does not
                  [-d] top down rebase
                  [-e SizeAdjustment] specify extra size to allow for image growth
                  [-f] Strip relocs after rebasing the image
                  [-i coffbase_filename] get base addresses from coffbase_filename
                  [-l logFilePath] write image bases to log file.
                  [-p] Does nothing
                  [-q] minimal output
                  [-s] just sum image range
                  [-u symbol_dir] Update debug info in .DBG along this path
                  [-v] verbose output
                  [-x symbol_dir] Same as -u
                  [-z] allow system file rebasing
                  [-?] display this message              [-R image_root] set image root for use by -G, -O, -N
                  [-G filename] group images together in address space
                  [-O filename] overlay images in address space
                  [-N filename] leave images at their origional address
                      -G, -O, -N, may occur multiple times.  File "filename"
                      contains a list of files (relative to "image-root")              'image-names' can be either a file (foo.dll) or files (*.dll)
                                or a file that lists other files (@files.txt).
                                If you want to rebase to a fixed address (ala QFE)
                                use the @@files.txt format where files.txt contains
                                address/size combos in addition to the filename
    参考
    Using the Rebase utility in project makefileOptimizing DLL Loads
    Rebasing Win32 DLLs: The Whole Story
      

  3.   

    jiangsheng:
    您能把我的例子用Rebase命令写出来吗?
    比如
    C:\***>rebase -d A.dll B.dll大体是这样吗?或者正确的怎么个格式啊?
    Thanks
      

  4.   

    Rebase.exe -b 0x400000 C:\Temp MyApp.exe A.dll   B.dll