From a running thread I want to be able to report the remaining stack
size available (for debugging purposes).
I tried the following code which gets the current stack pointer from
ESP, and attempted to get the stacklimit from the TIB.
PNT_TIB ptib = 0;
PVOID currentEsp = 0;
return (char*)currentEsp - (char*)ptib->StackLimit;
The problem is that the stack limit in the TIB is the currently
committed low stack address, rather than the brick wall at which a stack
overflow would occur.
I know that the TIB contains the StackBase address as well, so I could
just report the amount of stack USED by returning StackBase-currentEsp,
but I'd v. much prefer to report the amount of stack left.
Does anyone know how to dig out the relevant information?