#include <toolhelp.h> |
BOOL StackTraceFirst(lpste, htask) | |||||
STACKTRACEENTRY FAR* lpste; | /* address of stack-frame structure | */ | |||
HTASK htask; | /* handle of task, */ |
The StackTraceFirst function fills the specified structure with information that describes the first stack frame for the given task.
lpste
Points to a STACKTRACEENTRY structure to receive information about the task's first stack frame. The STACKTRACEENTRY structure has the following form:
#include <toolhelp.h>
typedef struct tagSTACKTRACEENTRY { /* ste */
DWORD dwSize;
HTASK hTask;
WORD wSS;
WORD wBP;
WORD wCS;
WORD wIP;
HMODULE hModule;
WORD wSegment;
WORD wFlags;
} STACKTRACEENTRY;
For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.
htask
Identifies the task whose stack information is to be described.
The return value is nonzero if the function is successful. Otherwise, it is zero.
The StackTraceFirst function can be used to begin a stack trace of any task except the current task. When a task is inactive, the kernel maintains its state, including its current stack, stack pointer, CS and IP values, and BP value. The kernel does not maintain these values for the current task. Therefore, when a stack trace is done on the current task, the application must use the StackTraceCSIPFirst function to begin a stack trace. An application can continue to trace through the stack by using the StackTraceNext function.
Before calling StackTraceFirst, an application must initialize the STACKTRACEENTRY structure and specify its size, in bytes, in the dwSize member.