How do I read the PE header of a module loaded in memory?

两盒软妹~` 提交于 2019-12-07 05:22:16

问题


I'm experimenting with memory access in .NET. At the moment, I have a managed program that starts an unmanaged process and retrieves the BaseAddress of one of its loaded modules (a DLL). What I would like to do is somehow read the PE header of the loaded module so that I can later retrieve the addresses of its exports.

Unfortunately, I can't find any good information about this. Any ideas?


回答1:


This is a good starting point for the PE file format.

You can P/Invoke ReadProcessMemory from the base address you have to copy the headers into your process. You'll need to parse the memory you read into the various PE headers. The first header is the IMAGE_DOS_HEADER, which will point you to the IMAGE_NT_HEADERS. You can then use the IMAGE_OPTIONAL_HEADER in the IMAGE_NT_HEADERS to find the location of the IMAGE_EXPORT_DIRECTORY in the binary.



来源:https://stackoverflow.com/questions/1563134/how-do-i-read-the-pe-header-of-a-module-loaded-in-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!