如果我想修改我的DLL,我该怎么做呢? [英] If I want to rebase my DLL's, how do I go about doing it?

查看:128
本文介绍了如果我想修改我的DLL,我该怎么做呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是此问题的延续。



我正在测试是否重新使用.NET DLL,而NGENning它们将为终端服务器上的内存提供更多的共享代码。



但是,我的计划似乎有缺陷,这似乎找不到一种工作方法来找出一组工作地址。



我以为我可以做的是如下:


  1. 只需构建和更改所有内容

  2. 启动程序,确保所有的DLL已被加载

  3. 使用 LISTDLLS / R PROGRAMNAME以获取正在运行的实例的当前使用地址列表

  4. 使用重映射为新基础的那些DLL的地址,对于这些dll的地址

  5. UN-NGEN everyt铰链,并从1开始

然而,这已经变成了一个Schrödinger练习,因为重新定位一些DLL的行为显然会改变加载顺序或操作系统如何重定位其他DLL。


$例如,假设在初始运行后,我有一个列表,表示DLL,A,B和C需要在地址1000,2000和3000.没有提到DLL D,E和F ,它们也是同一系统的一部分。大概这些被加载在他们当前的基地址,否则我会假设LISTDLLS会告诉我这个。



所以我更改A,B,C的地址,重复一切,现在DLL C,D和E已经重新定位。 A和B现在可以,E和F现在被搬迁了,C仍在被洗牌。



我意识到这个练习有点徒劳,因为不管我在机器上找到的东西,使用和注入到目标终端服务器上的DLL可能会打扰这张照片,但我认为如果我至少可以确定一些DLL可能位于其规定的基地址,那么同一程序的多个实例之间的共享代码将会上升。只是说,只是为了不需要提醒我:)



由于所有我们的DLL的原始基址是默认的,这意味着每个DLL(可能除了第一个加载之外)被重新定位,因此映射到页面文件,我认为将有一个潜在的收益高于0。



任何建议?

解决方案

您可以使用DUMPBIN(在Visual Studio中)找到一个DLL的首选加载地址和内存范围,并进行规划基于这些数字。



dumpbin / headers会给你:

  7DC90000图像基础(7DC90000至7DD5FFFF)

如果您根据首选加载地址计划,您应该没有问题。


This is a continuation of this question.

I'm in the process of testing whether rebasing the .NET DLLs, and NGENning them will provide me with more shared code in memory on terminal servers.

However, my plan seems to have a flaw, and it's that I seem unable to find a working method to figure out a working set of addresses.

What I thought I could do was as follows:

  1. Just build and NGEN everything
  2. Start the program, ensuring all the DLL's have been loaded
  3. Use LISTDLLS /R PROGRAMNAME to get a list of current in-use addresses for the running instance
  4. Use the addresses of those DLL's that was remapped as the new base-address for those dll's
  5. UN-NGEN everything, and start back at 1

However, this has turned into a Schrödinger exercise because the act of rebasing some DLLs apparently either change the load order or how the operating system relocates other DLLs.

For instance, let's say that after the initial run I have a list that says that DLLs A, B and C needs to be at address 1000, 2000 and 3000. There's no mention of DLL D, E and F, which are also part of the same system. Presumably these were loaded at their current baseaddress, otherwise I would assume LISTDLLS would tell me about that.

So I change the address of A, B, C, repeat everything, and now DLL C, D and E have been relocated. A and B are now OK, E and F now became relocated, and C is still being shuffled around.

I realize that this exercise is somewhat a futile one, since regardless of what I figure out on my machine, DLLs being used and injected on the target terminal server might disturb this picture but I thought that if I could at least make sure some of the DLLs could be located at their prescribed base address then the amount of shared code between multiple instances of the same program would go up. Just saying, just so that there is no need to "remind" me of that :)

Since the original base addresses of all our DLLs was the default, which meant every DLL (possibly except the first one loaded) was relocated, and thus mapped to the page file, I would think that there would be a potential gain above 0.

Any advice?

解决方案

You can find out a DLLs preferred loading address and memory ranges using DUMPBIN (comes within Visual Studio) and do your planning based on those numbers.

dumpbin /headers would give you:

 7DC90000 image base (7DC90000 to 7DD5FFFF)

If you plan according to preferred loading addresses you should have no problems.

这篇关于如果我想修改我的DLL,我该怎么做呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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