被重新设定DLL(或提供合适的默认加载地址)值得的麻烦? [英] Is rebasing DLLs (or providing an appropriate default load address) worth the trouble?

查看:192
本文介绍了被重新设定DLL(或提供合适的默认加载地址)值得的麻烦?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

衍合一个DLL手段来解决了DLL这样,它的pferred负载ADRESS $ P $是,装载机实际上是能够在加载DLL的加载地址。

Rebasing a DLL means to fix up the DLL such, that it's preferred load adress is the load address that the Loader is actually able to load the DLL at.

这既可以通过工具,如 Rebase.exe 或你所有的(自己的)的DLL指定默认加载地址,使他们适合的实现可执行的过程。

This can either be achieved by a tool such as Rebase.exe or by specifying default load addresses for all your (own) dlls so that they "fit" in your executable process.

管理DLL基地址这种方式来加快应用程序负载的关键所在。 (或者说,我明白了。)

The whole point of managing the DLL base addresses this way is to speed up application loads. (Or so I understand.)

问题现在是:是否值得麻烦

我按里氏/ Nazarre必须通过C / C ++ 书 Windows和他们强烈建议 [ A] 确保负载地址的所有匹配,使装载机没有变基加载的DLL。

I have the book Windows via C/C++ by Richter/Nazarre and they strongly recommend[a] making sure that the load addresses all match up so that the Loader doesn't have to rebase the loaded DLLs.

他们没有然而,争论,如果这加快了应用程序加载时间任何显著量。

They fail to argue however, if this speeds up application load times to any significant amount.

此外,随着 ASLR 似乎值得怀疑,这有什么价值可言,由于负载地址将被随机反正

Also, with ASLR it seems dubious that this has any value at all, since the load addresses will be randomized anyway.

是否有任何确凿的事实的在此PRO /缺点是什么?

Are there any hard facts on the pro/cons of this?

[一]:在我WVC ++ / 5版是在标题的衍合模块的章节和在页面上568ff结合组件的。第20章的 DLL的先进技术

[a]: In my WvC++/5th ed it is in the sections titled Rebasing Modules and Binding Modules on pages 568ff. in Chapter 20, DLL Advanced Techniques.

推荐答案

我想,以提供一个回答自己,虽然<一个href=\"http://stackoverflow.com/questions/3969190/is-rebasing-dlls-or-providing-an-appropriate-default-load-address-worth-the-tro/3970288#3970288\">answers汉斯帕桑特和其他人所描述的权衡已经pretty很好。

I'd like to provide one answer myself, although the answers of Hans Passant and others are describing the tradeoffs already pretty well.

最近与我们的应用程序的DLL基地不会忽略摆弄之后,我将在这里给我的结论是:

After recently fiddling with DLL base adresses in our application, I will here give my conclusion:

我认为,除非你能证明,否则,提供的DLL使用非默认基址是徒劳无益的。这包括衍合我的DLL。

I think that, unless you can prove otherwise, providing DLLs with a non-default Base Address is an exercise in futility. This includes rebasing my DLLs.


  • 有关的这些DLL我控制的,给出的平均应用,每个DLL将被加载到内存中只有一次,无论如何,所以上的页面文件的负荷应该是最小的。 (不过看到米哈尔伯尔的有关终端服务器环境的另一个答案的评论。)

  • For the DLLs I control, given the average application, each DLL will be loaded into memory only once anyway, so the load on the paging file should be minimal. (But see the comment of Michal Burr in another answer about Terminal Server environment.)

如果DLL被提供有一个固定的基地址(无衍合)它实际上将增加的地址空间碎片,如迟早这些地址将不再匹配。在我们的应用程序,我们给了所有dll一个固定的地址(对于其他传统的原因,而不是因为地址空间碎片),而无需使用rebase.exe这的显著的增加​​地址空间碎片对我们来说,因为你真的不能手动得到这个权利。

If DLLs are provided with a fixed base address (without rebasing) it will actually increase address space fragmentation, as sooner or later these addresses won't match anymore. In our app we had given all DLLs a fixed base address (for other legacy reasons, and not because of address space fragmentation) without using rebase.exe and this significantly increased address space fragmentation for us because you really can't get this right manually.

衍合(通过rebase.exe)的不便宜的。这是一个必须维护和检查构建过程又迈进了一步,所以它有一定的好处。

Rebasing (via rebase.exe) is not cheap. It is another step in the build process that has to be maintained and checked, so it has to have some benefit.

一个大的应用程序始终都有某些DLL加载所在的基地址不匹配,因为有的挂钩的DLL(AV)和因为你不衍合第三方的DLL(或至少我不会)

A large application will always have some DLLs loaded where the base address does not match, because of some hook DLLs (AV) and because you don't rebase 3rd party DLLs (or at least I wouldn't).

如果您是使用RAM磁盘分页文件,你实际上可能是,如果加载的DLL得到换出更好: - )

If you're using a RAM disk for the paging file, you might actually be better of if loaded DLLs get paged out :-)

所以,综上所述,我认为重订基的是不值得的麻烦的特殊情况除外,如系统DLL。

So to sum up, I think that rebasing isn't worth the trouble except for special cases like the system DLLs.

我想补充一个历史片,我在旧的新发现:的如何做Windows 95的底垫中的DLL - ?

I'd like to add a historical piece that I found on Old New Thing: How did Windows 95 rebase DLLs? --

当一个DLL需要进行重订,Windows 95的只会做出说明
  DLL的新基地地址,但不会做别的了。真正的
  当DLL的网页,最终得到了在换工作的事情。该
  原始页面被换出的磁盘,然后修复起坐涂在
  苍蝇对原始页面,从而重新定位它。固定式页面
  然后映射到进程的地址空间及节目是
  继续下去了。

When a DLL needed to be rebased, Windows 95 would merely make a note of the DLL's new base address, but wouldn't do much else. The real work happened when the pages of the DLL ultimately got swapped in. The raw page was swapped off the disk, then the fix-ups were applied on the fly to the raw page, thereby relocating it. The fixed-up page was then mapped into the process's address space and the program was allowed to continue.

综观这一过程是如何完成(阅读整个事情),我个人怀疑的一部分,重订基期是邪恶的立场追溯到Win9x的和内存不足的情况​​的昔日。

Looking at how this process is done (read the whole thing), I personally suspect that part of the "rebasing is evil" stance dates back to the olden days of Win9x and low memory conditions.

这篇关于被重新设定DLL(或提供合适的默认加载地址)值得的麻烦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆