Can I get the limits of the stack in C / C++?

前端 未结 3 910
时光说笑
时光说笑 2021-02-12 08:10

My question is pretty simple and straightforward: if I have e.g. 1MB of RAM assigned to the program\'s stack, can I get the addresses of the start and the end, or the start and

3条回答
  •  天涯浪人
    2021-02-12 08:46

    GetCurrentThreadStackLimits seems to do what you're looking for, getting the lower/upper boundaries of the stack into pointer addresses:

    ULONG_PTR lowLimit;
    ULONG_PTR highLimit;
    GetCurrentThreadStackLimits(&lowLimit, &highLimit);
    

    Looks like it is only available on Windows 8 and Server 2012 though.

    Check the MSDN

提交回复
热议问题