获取调用堆栈的大小 [英] Getting the size of the callstack

查看:144
本文介绍了获取调用堆栈的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在C ++中获取调用堆栈的大小(以字节为单位)?

或者至少是它的底部地址(然后我可以从ESP寄存器中减去它?

Is there a way to get the size of the callstack (in bytes) in C++?
Or at least the bottom address of it (and then I can subtract it from the ESP register?

推荐答案

您可以尝试使用 VirtualQuery 两次。

您第一次可以使用栈上任何值的地址以获取提交的堆栈空间的基址和大小(以字节为单位)。

The first time you can use the address of any value on the stack to get the base address and size (in bytes) of the committed stack space.

从基地址中减去大小,然后再次调用VirtualQuery

Subtract the size from the base address and call VirtualQuery again. This way you get the space reserved for the stack.

添加两个尺寸,以获得堆叠总大小。

Adding the two sizes you obtain the total stack size.

这篇关于获取调用堆栈的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆