Getting the size of the callstack

2019-04-09 23:10发布

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?

2条回答
Ridiculous、
2楼-- · 2019-04-09 23:15

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.

查看更多
登录 后发表回答