os_query_stackBottom() how does it work?

mclysenk at mtu.edu mclysenk at mtu.edu
Mon May 8 07:09:50 PDT 2006


In article <e3mf16$1g83$1 at digitaldaemon.com>, Chad J says...
>
>/**********************************************
>  * Determine "bottom" of stack (actually the top on Win32 systems).
>  */
>
>void *os_query_stackBottom()
>{
>     asm
>     {
>	naked			;
>	mov	EAX,FS:4	;
>	ret			;
>     }
>}
>

That snippet of code is pulling out the bottom of the stack from the Thread
Execution Block (TEB).  The TEB is stored in process' memory and is also
mirrored in the FS segment.  FS:0 is the top of the structured exception handler
chain, FS:4 is the bottom of the stack and FS:8 is the top of the stack.

As for Windows CE, you'll probably have to do some snooping on your own.  The
MSDN would probably be a good place to start.





More information about the Digitalmars-d mailing list