查找DLL在内存中的地址
我刚刚进入低级编程(读/写内存之类的事情)并且遇到了一个我找不到答案的问题。
我想要读取的信息有一个与内存中加载的 DLL 相关的地址,例如,它位于 mydll.dll + 0x01234567。 我遇到的问题是 dll 在内存中移动,但偏移量保持不变。 有没有办法找出这个dll在内存中的位置。
我目前正在尝试最好在 C# 中执行此操作,但我将感谢大多数高级语言的帮助。
I have just been getting into low level programming (reading/writing to memory that sort of thing) and have run into an issue i cannot find an answer to.
The piece of information i want to read from has an address that is relative to a DLL loaded in memory e,g, it is at mydll.dll + 0x01234567. the problem im having is that the dll moves around in memory but the offset stays the same. Is there anyway to find out the location of this dll in memory.
I am currently trying to do this preferably in c# but i would be grateful for help in most highish level languages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试了 Rob Walker 建议的方法,但无法使其工作(我认为它不起作用,因为该 dll 是作为另一个可执行文件的一部分加载的,因此无法轻易找到它)。
然而,我确实发现了一个对我有用的解决方案,所以这里是:
我创建了一个 Process 类型的对象,
现在您拥有了模块,您可以执行 dllbaseAdressIWant.BaseAddress 来获取值。
希望这可以帮助
i tried the method Rob Walker suggested and could not get it to work (i think it did not work because the dll was loaded as part of another executable so it could not be found so easily).
I did however discover a solution that worked for me so here it is:
i created an object of type Process
now you have the module you can just do dllbaseAdressIWant.BaseAddress to get the value.
Hope this helps
从 Win32 角度来看,您需要使用 GetModuleHandle 和 GetModuleInformation 函数。 这些使您可以按名称查找模块句柄,然后检索信息,包括有关该句柄的基地址。
使用标准 P/Invoke 包装器来包装这些 API 应该很简单。
From a Win32 perspective you need to use the GetModuleHandle and GetModuleInformation functions. These let you look the module handle up by name, and then retrieve information, including the base address about that handle.
It should be straight forward to wrap these APIs using the standard P/Invoke wrappers.