从exe/pdb获取可执行代码的信息
我需要从经典的 win32 exe/dll 文件中提取代码(但不是数据!)。 很明显,我不能仅通过提取代码段内容来做到这一点(因为代码段还包含数据 - 例如跳转表),并且我需要编译器的一些帮助。
*.map 文件很好,但它们只包含函数的地址,即我能做的最安全的事情就是从该地址开始并处理直到第一个返回/跳转指令(因为函数的一部分可以提到数据)
*。 pdb 文件更好,但我不确定使用什么工具来提取这样的信息——我查看了 DbgHelp 和 DIA SDK,后一个似乎是正确的工具,但它看起来不太简单。 所以我的问题:
- 据您所知,只能通过 DbgHelp 提取有关代码/数据位置(地址+长度)的信息吗?
- 如果 DIA SDK 是唯一的方法,我知道我应该调用什么来获取这样的信息吗? (那个COM东西相当重)
- 还有其他方法吗?
当然,我首先关心的是 Visual Studio、C/C++ 源代码编译。
感谢您的任何提示。
I need to extract code (but not data!) from classic win32 exe/dll files. It's clear I can't do this only with extraction of code segment content (because code segment contains also the data -- jump tables for example) and that I need some help from compiler.
*.map files are nice but they only contain addresses of functions, i.e. the safest thing I can do is to start at that address and to process until the first return / jump instruction (because part of the function could be mentioned data)
*.pdb files are better but I'm not sure what tools to use to extract information like this -- I took a look at DbgHelp and DIA SDK, the latter one seems to be the right tool but it doesn't look very simple. So my question/questions:
- To your knowledge, it is possible to extract information about code/data position (address + length) only via DbgHelp?
- If the DIA SDK is the only way, any idea what should I call for getting information like that? (that COM stuff is pretty heavy)
- Is there any other way?
Of course my concern is about Visual Studio, C/C++ source compilation in the first place.
Thanks for any hint.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有一个 PDB 提取器可供下载:http://undocumented.rawol.com。 当您使用 /type 选项时,它可以提取所有信息。 这里还有一篇关于 PDB 查看器的文章: http://www.codeproject.com/KB /bugs/PdbParser.aspx 但它提取的信息较少。
这两个实用程序都附带源代码。
There is a PDB extractor for download at the page here: http://undocumented.rawol.com. It can extract all information when you use the /type option. There is also an article with PDB viewer here: http://www.codeproject.com/KB/bugs/PdbParser.aspx but it extracts less information.
Both utilities come with source code.
好吧,前几天我碰巧读到 DIA 在 C# 中更容易使用(链接到一个简单程序的源代码); 我的谷歌搜索中不断出现的另一个程序是 PDB Cracker,它也有源代码,并且可能与您的预期应用更相关。
Well, I just happened to read the other day that DIA is a lot easier to use from C# (links to source for a simple program); another program that keeps coming up on my google searches is PDB Cracker, which also has source code, and is probably more relevant to your intended application.