You can use VirtualQuery twice.
For 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 reserved stack space.
Subtract the size from the base address and call VirtualQuery again. This way you get the space reserved for the stack.
By adding two sizes, you get the total stack size.
source share