Hi,

I have a multi-thread programs, and if I want to check the size of
memory that has been allocated in the stack in one of the thread. Is
there any fucntion avaiable in VC6.0?

Thanks in advance!

Re: Is there any function that I can use to check the current stack size in VC6.0 by Scherbina

Scherbina
Sat Nov 26 17:47:11 CST 2005

Hello, Kimso.

Nope, AFAIR there is no documented way to retrieve stack size. As for
undocumented ways, information about stack is stored in Thread Environment
Block (TEB). For more information take a look at:
http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/NT%20Objects/Thread/TEB.html

On how to retrieve TEB you may find in this article:
http://www.codeproject.com/win32/Remote.asp

--
Scherbina Vladimir

<kimso.zhao@gmail.com> wrote in message
news:1133046510.283537.194150@g43g2000cwa.googlegroups.com...
> Hi,
>
> I have a multi-thread programs, and if I want to check the size of
> memory that has been allocated in the stack in one of the thread. Is
> there any fucntion avaiable in VC6.0?
>
> Thanks in advance!
>



Re: Is there any function that I can use to check the current stack size in VC6.0 by kimso

kimso
Sat Nov 26 18:43:11 CST 2005

Thanks for your links.

Now I can use the code "struct _TEB* pTEB = NtCurrentTeb();" to get
the current TEB.
But when I tried to access any member of struct _TEB (e.g.
"pTEB->DeallocationStack;"), I can't get the code compiled. And get an
error like "error C2227: left of '->DeallocationStack' must point to
class/struct/union". How to get through this?

And here is the struct _TEB declaration I found from the link you
provided, only the member I think related to stack information are
listed. I can't find any furthur information about each member. Do you
have any idea about which is what I want (current stack size), and how
to print it? Sorry I don't know much about "PVOID".

typedef struct _TEB {
...

PVOID DeallocationStack;
...

PVOID StackCommit;
PVOID StackCommitMax;
PVOID StackReserved;
...
}TEB, *PTEB;

Thanks very much!