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

前端 未结 3 2120
走了就别回头了
走了就别回头了 2021-02-12 08:16

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:32

    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

提交回复
热议问题