堆栈和堆栈基地址

发布于 2024-09-08 12:53:45 字数 786 浏览 3 评论 0原文

MEMORY_BASIC_INFORMATION 结构中发现两个 PVOID 变量,分别称为BaseAddressAllocationBase

我正在读一本关于线程的书,它详细介绍了如何将堆栈空间留在堆栈上,但是有些东西我不确定我是否理解正确。

上面提到的结构体中的BaseAddress,它是指向当前线程栈中的最高地址还是最低地址呢?由于堆栈向下增长,最低的将位于顶部,最高的将位于底部。

AllocationBaseBaseAddress 字段之间到底有什么区别?我觉得 MSDN 文档解释得不是很清楚,所以我希望有人能澄清一下?

在我的书中,它还说“AllocationBase”地址与 TEB 结构中的“DeallocationStack”字段相同,它指向堆栈的末尾,我认为这是最高地址,但是由于它的 BASE,我猜它应该是最低地址,因为堆栈向下增长。所以我有点困惑什么是什么?

根据页面,“DeallocationStack”为:最大堆栈大小存储在 DeallocationStack 字段中

有人可以帮助我理解我的困惑吗?

In the MEMORY_BASIC_INFORMATION structure one finds two PVOID variables, called BaseAddress and AllocationBaserespectively.

I'm reading a book on Threading and its going over how to get the stackspace left on the stack in quite some detail, however there's something I'm not sure I understand correctly.

The BaseAddress in the structure mentioned above, does it point to the highest address in the current thread stack or the lowest address? Since the stack grows downwards, the lowest would be at the top and the highest at the bottom.

What exactly is the difference between the AllocationBase and BaseAddress field? I don't find the MSDN documentation very explanatory, so I'm hoping someone can clarify a bit more?

In my book it also says that the 'AllocationBase' address is the same as the 'DeallocationStack' field in the TEB structure, which it says points to the end of the stack, which I thought was the highest address, however since its BASE, I'm guessing it should be the lowest address, as the stack grows downward. So I'm kind of confused as to what's what?

Per this page, 'DeallocationStack' is: The maximum stack size is stored in the field DeallocationStack

Can someone help me understand my confusion?

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

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

发布评论

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

评论(1

机场等船 2024-09-15 12:53:45

在 MEMORY_BASIC_INFORMATION 结构中:

  • BaseAddress - 查询的内存页的地址 ( VirtualQuery(LPCVOID lpAddress,... )。
  • AllocationBase - 分配的内存块的开头。它是用于释放。 BaseAddress >= AllocationBase

如果您正在查询堆栈,则 AllocationBase 将是堆栈的最低地址(堆栈顶部)。

In MEMORY_BASIC_INFORMATION structure:

  • BaseAddress - the address of the queried memory page ( VirtualQuery(LPCVOID lpAddress,... ).
  • AllocationBase - the beginning of the allocated memory block. It is used for deallocation. BaseAddress >= AllocationBase.

If you are querying stack then AllocationBase will be the lowest address of the stack (the stack top).

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