From: "Dan Sugalski" <[EMAIL PROTECTED]>

> So, could someone with some windows experience go digging and find
> out how one would:
>
> 1) Find the address of the base of a thread's stack
> 3) Find out what a thread's current stack pointer is

I would do 1), 3)  this way ...

 thdl = _beginthreadex(NULL, 0, thread_function, &arg, CREATE_SUSPENDED,
&thraddr);

#if defined(_X86_)
    ctx.ContextFlags = CONTEXT_FULL;
#elif defined(_ALPHA_)
    ctx.ContextFlags = CONTEXT_INTEGER;
#else
    /* _MIPS_ and etc */
#endif

 GetThreadContext(thdl, &ctx);

#if defined(_X86_)
    current_stack_ptr = ctx.Esp;
#elif defined(_ALPHA_)
    current_stack_ptr = ctx.IntSp;
#else
    /* _MIPS_ and etc */
#endif

 VirtualQuery((LPCVOID)current_stack_ptr, &mbi, sizeof(mbi));
 stack_allocbase_addr = mbi.AllocationBase;

> 2) Find out how big a thread's stack is

By default, OS reserves 1 MB of memory for a thread's stack. One can specify
a different size with a linker option or a STACKSIZE statement in the .DEF
file. So it's, sort of, up to us how big a thread stack is. No problem here.

>                                          Dan

0x4C56

Reply via email to