如果我想变基我的DLL的,我怎么去这样做呢?我的、我想、这样做、我怎么

2023-09-03 05:33:05 作者:南简

这是一个延续的这个问题。

我在测试的过程中是否衍合的.NET的DLL,并NGENning他们会为我提供更多的共享code在内存中的终端服务器上。

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:

只需建立和NGEN一切 启动该程序,以确保所有的DLL已经被加载 使用 listdlls的 / R PROGRAMNAME获取当前列表中对正在运行的实例 - 使用地址 使用那些被重新映射作为新的基地址为这些DLL的DLL的的地址 UN-NGEN的一切,并开始回到1 Just build and NGEN everything Start the program, ensuring all the DLL's have been loaded Use LISTDLLS /R PROGRAMNAME to get a list of current in-use addresses for the running instance Use the addresses of those DLL's that was remapped as the new base-address for those dll's UN-NGEN everything, and start back at 1

不过,这已经变成了一个薛定谔的工作,因为重订基期的行为某些DLL显然要么改变加载顺序或操作系统如何重新定位等的DLL。

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.

例如,让我们说,在最初的运行之后我有一个列表,指出DLL的A,B和C必须是在地址1000,2000和3000有没有提到DLL D,E和F,它们是也有一部分相同的系统的。 presumably这些被装在其当前baseaddress,否则我会假设listdlls的会告诉我有关。

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.

于是我改变A,B,C的地址,重复的一切,现在DLL C,D和E已搬迁。 A和B,现在好了,E和F,现在变成了搬迁,和C仍在抛去。

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.

我认识到,这项工作是有点徒劳的,因为不管是什么我找出我的机器上,正在使用中,注入的目标终端服务器上的DLL可能会扰乱这幅画,但我想,如果我至少可以确保一些dll的可以位于其prescribed基地则地址的同一程序会上涨的多个实例之间共享code量。只是说,就这样,没有必要提醒那我:)

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 :)

因为我们所有的DLL文件的原始基地址是默认的,这意味着每一个DLL(可能除了第一个加载)搬迁,并因此映射到页面文件,我认为会有潜在收益高于0。

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.

任何意见?

推荐答案

您可以根据这些数据找出一个DLL文件preferred加载地址,并使用DUMPBIN内存范围(涉及Visual Studio中),做你的规划。

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 /头会给你:

dumpbin /headers would give you:

 7DC90000 image base (7DC90000 to 7DD5FFFF)

如果您打算按照preferred加载地址,你应该没有问题。

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