Getting the size of the callstack

夙愿已清 提交于 2019-12-06 05:42:06

问题


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?


回答1:


You can try using VirtualQuery twice.

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.

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.




回答2:


StackWalk64()

http://msdn.microsoft.com/en-us/library/ms680650



来源:https://stackoverflow.com/questions/7490095/getting-the-size-of-the-callstack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!