37{
40
46
47
48#if defined(_M_IX86)
53#elif defined(_M_AMD64)
58#elif defined(_M_ARM)
63#elif defined(_M_ARM64)
68#else
69#error "Unknown architecture"
70#endif
71
72#define STACKWALK_MAX_NAMELEN 512
76 LONG RecursionDepth = 0;
78
79
80
85 {
87 {
89 {
91 break;
92 }
93 }
94 else
95 {
96 RecursionDepth = 0;
97 }
98
100 {
101 xfprintf(output,
"FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name" NEWLINE);
103 }
104
109
114
117
123 }
124
125 UCHAR stackData[0x10 * 10];
127#if defined(_M_IX86)
129#elif defined(_M_AMD64)
131#elif defined(_M_ARM) || defined(_M_ARM64)
133#else
134#error Unknown architecture
135#endif
137 return;
138
140 for (
size_t n = 0;
n <
sizeof(stackData);
n += 0x10)
141 {
142 char HexData1[] = "?? ?? ?? ?? ?? ?? ?? ??";
143 char HexData2[] = "?? ?? ?? ?? ?? ?? ?? ??";
144 char AsciiData1[] = "????????";
145 char AsciiData2[] = "????????";
146
147 for (
size_t j = 0;
j < 8; ++
j)
148 {
151 {
152 HexData1[
j * 3] =
ToChar(stackData[
idx] >> 4);
153 HexData1[
j * 3 + 1] =
ToChar(stackData[
idx] & 0xf);
155 }
158 {
159 HexData2[
j * 3] =
ToChar(stackData[
idx] >> 4);
160 HexData2[
j * 3 + 1] =
ToChar(stackData[
idx] & 0xf);
162 }
163 }
164
165 xfprintf(output,
"%p %s - %s %s%s" NEWLINE, stackPointer+
n, HexData1, HexData2, AsciiData1, AsciiData2);
166 }
167}
char * strcpy(char *DstString, const char *SrcString)
BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, PSYMBOL_INFO Symbol)
#define ReadProcessMemory(a, b, c, d, e)
#define IMAGE_FILE_MACHINE_ARMNT
PVOID WINAPI SymFunctionTableAccess64(HANDLE, DWORD64)
DWORD64 WINAPI SymGetModuleBase64(HANDLE, DWORD64)
struct _SYMBOL_INFO SYMBOL_INFO
#define IMAGE_FILE_MACHINE_ARM64
BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULE64 ModuleInfo)
BOOL WINAPI StackWalk64(DWORD MachineType, HANDLE hProcess, HANDLE hThread, LPSTACKFRAME64 frame, PVOID ctx, PREAD_PROCESS_MEMORY_ROUTINE64 f_read_mem, PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, PTRANSLATE_ADDRESS_ROUTINE64 f_xlat_adr)
void xfprintf(FILE *stream, const char *fmt,...)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
#define IMAGE_FILE_MACHINE_AMD64
#define IMAGE_FILE_MACHINE_I386
#define STACK_MAX_RECURSION_DEPTH
#define STACKWALK_MAX_NAMELEN
static char ToChar(UCHAR data)