Windows 初始执行上下文

发布于 2024-11-08 02:04:29 字数 77 浏览 9 评论 0原文

一旦Windows将可执行文件加载到内存中并将执行转移到入口点,寄存器和堆栈中的值是否有意义?如果是这样,我在哪里可以找到有关它的更多信息?

Once Windows has loaded an executable in memory and transfert execution to the entry point, do values in registers and stack are meaningful? If so, where can I find more informations about it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

命比纸薄 2024-11-15 02:04:29

正式地,PE文件入口点的寄存器没有定义值。您应该使用 API(例如 GetCommandLine)来检索所需的信息。然而,由于最终将控制权转移到入口点的内核函数与以前相比并没有太大变化,一些PE加壳程序和恶意软件开始依赖它的特性。两个或多或少可靠的寄存器是:

  • EAX 指向应用程序的入口点(因为内核函数使用 call eax 跳转到它)

  • EBX指向进程环境块(PEB)。

Officially, the registers at the entry point of PE file do not have defined values. You're supposed to use APIs, such as GetCommandLine to retrieve the information you need. However, since the kernel function that eventually transfers control to the entry point did not change much from the old days, some PE packers and malware started to rely on its peculiarities. The two more or less reliable registers are:

  • EAX points to the entry point of the application (because the kernel function uses call eax to jump to it)

  • EBX points to the Process Environment Block (PEB).

念三年u 2024-11-15 02:04:29

《Windows 内部原理第五版》第 5 章详细介绍了 Windows 创建进程的机制。这将为您提供有关 Windows 在内存中加载可执行文件并将执行转移到入口点的更多信息。

我找到了这个最新的参考资料,其中介绍了如何在各种操作系统和各种编译器的各种调用约定中使用寄存器。它非常详细,而且看起来很全面:
Agner Fog 的调用约定文档

Chapter 5 of Windows Internals Fifth Edition covers the mechanism of Windows creating a process in detail. That would give you more information about Windows loading an executable in memory and transferring execution to the entry point.

I found this up-to-date reference that covers how registers are used in various calling conventions on various operating systems and by various compilers. It's quite detailed, and seems comprehensive:
Agner Fog's Calling Conventions document

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文