From: Pavel Lebedinsky [MSFT] on 10 May 2007 03:17 StackBase is the last committed page on the stack (the page below it should have PAGE_GUARD attribute). Most stacks have a bunch of reserved pages below the guard page so more pages can be commited as necessary. Stack overflow will only be raised when a new guard page cannot be committed. In debugger you can find the actual base of the stack (the bottommost MEM_RESERVED page) by looking at @$teb->DeallocationStack. The only supported way to get it programmatically is by doing VirtualQuery on a stack address and walking downwards until you find the first MEM_FREE page. Note that the system will actually raise a stack overflow several pages before you get to the bottom, to make sure any possible exception handlers have enough stack space to run.. The following page says that the stack can grow down to DeallocationBase minus two pages, but I think the difference is larger on recent OSes (plus it can be additionally increased with SetStackSizeGuarantee): http://msdn2.microsoft.com/en-us/library/ms686774.aspx In short, I don't think there's an easy way to get the actual available stack space, but using VirtualQuery you should be able to get an answer that is pretty close (to within a few pages). -- This posting is provided "AS IS" with no warranties, and confers no rights. "Skywing [MVP]" wrote: > Look at the difference between the current stack pointer and > (PNT_TIB)NtCurrentTeb()->StackLimit. > >> >> is there any way to query the remaining stack size of a thread?
First
|
Prev
|
Pages: 1 2 Prev: [dhcp] how to start dhcp programmly Next: Getting process id from process handle |