exe 的工作原理以及如何调用 dll 和 exe 文件寻址
- 基于 Windows 的可执行文件如何工作?
- 如何找到可执行文件的起始地址?
- 对于任何文件执行,地址存储在哪里以及我们如何读取这些地址?
- 任何 dll 或 exe 文件的调用和 ret 是如何工作的?
给我一些使用 ida pro 反汇编程序的提示。
- How does a Windows-based executable file works?
- How is the starting address found in the executable file?
- For any file execution where are the addresses stored and how can we read those addresses?
- How the call and ret for any dll or exe file works?
Give me tips to use ida pro disassembler.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
程序的虚拟起始地址记录在可执行文件的标头中。任何了解这些结构的标头查看器程序都可以轻松显示它们,例如 HT (http://hte.sf.net/)——仅举一例。 IDAPro 可能有类似的东西。
The virtual start address of the program is recorded in the executable's header. Any header viewer program that understands the structure of these can easily show them, such as HT (http://hte.sf.net/) — just to name one. IDAPro may have something similar.
这实际上取决于它是 DLL 还是 EXE。
当 Windows 模块加载器完成加载 DLL 时,它会使用
DLL_PROCESS_ATTACH
参数调用 DLL 的起始地址(称为“DllMain”)(请参阅 DllMain 的文档 )。如果 DllMain 返回 1,加载程序将继续。然而,当您启动 EXE 时,系统会生成一个新进程并将 ntdll.dll 映射到该进程的地址空间,然后生成从 NTDLL 的起始地址运行的主线程。然后,该线程执行更多初始化,加载 EXE 文件(以及其导入表中列出的任何 DLL)并调用由 EXE 起始地址标识的函数。当该函数返回时,NTDLL 会调用 NtTerminateProcess 来终止所有正在运行的线程并关闭进程。
这个 EXE 启动过程可能很难用用户模式调试器观察到;一些调试器很难在进程初始化的早期阶段进行中断。
This actually does depend on whether it's a DLL or an EXE in question.
When Windows' module loader finishes loading a DLL, it calls the start address (known as 'DllMain') of the DLL with the
DLL_PROCESS_ATTACH
parameter ( see the documentation of DllMain ). If DllMain returns 1, the loader continues on.However when you launch an EXE, the system spawns a new process and maps ntdll.dll into that process' address space, then spawns the main thread running from NTDLL's start address. That thread then performs more initialisation, loads the EXE file (plus any DLLs listed in its import table) and calls the function identified by the EXE's start address. When that function returns, NTDLL then calls
NtTerminateProcess
which kills all running threads and closes the process.This EXE launching process may be difficult to observe with a user-mode debugger; some debuggers struggle to break in those early stages of process initialisation.