堆栈和堆栈基地址
在 MEMORY_BASIC_INFORMATION 结构中发现两个 PVOID 变量,分别称为BaseAddress
和AllocationBase
。
我正在读一本关于线程的书,它详细介绍了如何将堆栈空间留在堆栈上,但是有些东西我不确定我是否理解正确。
上面提到的结构体中的BaseAddress,它是指向当前线程栈中的最高地址还是最低地址呢?由于堆栈向下增长,最低的将位于顶部,最高的将位于底部。
AllocationBase
和 BaseAddress
字段之间到底有什么区别?我觉得 MSDN 文档解释得不是很清楚,所以我希望有人能澄清一下?
在我的书中,它还说“AllocationBase”地址与 TEB 结构中的“DeallocationStack”字段相同,它指向堆栈的末尾,我认为这是最高地址,但是由于它的 BASE,我猜它应该是最低地址,因为堆栈向下增长。所以我有点困惑什么是什么?
根据此页面,“DeallocationStack”为:最大堆栈大小存储在 DeallocationStack 字段中
有人可以帮助我理解我的困惑吗?
In the MEMORY_BASIC_INFORMATION structure one finds two PVOID variables, called BaseAddress
and AllocationBase
respectively.
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 MEMORY_BASIC_INFORMATION 结构中:
如果您正在查询堆栈,则 AllocationBase 将是堆栈的最低地址(堆栈顶部)。
In
MEMORY_BASIC_INFORMATION
structure:If you are querying stack then AllocationBase will be the lowest address of the stack (the stack top).