I have a very compute-intensive module in which I\'ve added stack-tracing to be able to find specific problems. Although the application is allowed to run slower when this
Found it, the following code does the trick:
#include <windows.h>
#include <winnt.h>
struct _TEB
{
NT_TIB NtTib;
// Ignore rest of struct
};
void *startOfStack;
startOfStack = NtCurrentTeb()->NtTib.StackBase;
std::cout << "startOfStack = " << startOfStack << std::endl;
I looked to the definition of NtCurrentTeb() in winnt.h and it looks like this is a very low level function, so it will probably be fast enough to get what I want.
it should be __readgsqword
instead of __readfsqword
on 64-bit.