ReactOS 0.4.15-dev-7889-g76290a6
drwtsn32.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ModuleData
 
struct  ThreadData
 
class  DumpData
 

Macros

#define NEWLINE   "\r\n"
 

Typedefs

typedef std::vector< ModuleDataModuleList
 
typedef std::map< DWORD, ThreadDataThreadMap
 

Functions

void xfprintf (FILE *stream, const char *fmt,...)
 
bool UpdateFromEvent (DEBUG_EVENT &evt, DumpData &data)
 
void PrintSystemInfo (FILE *output, DumpData &data)
 
void BeginStackBacktrace (DumpData &data)
 
void PrintStackBacktrace (FILE *output, DumpData &data, ThreadData &thread)
 
void EndStackBacktrace (DumpData &data)
 

Macro Definition Documentation

◆ NEWLINE

#define NEWLINE   "\r\n"

Definition at line 53 of file drwtsn32.h.

Typedef Documentation

◆ ModuleList

typedef std::vector<ModuleData> ModuleList

Definition at line 33 of file drwtsn32.h.

◆ ThreadMap

typedef std::map<DWORD, ThreadData> ThreadMap

Definition at line 34 of file drwtsn32.h.

Function Documentation

◆ BeginStackBacktrace()

void BeginStackBacktrace ( DumpData data)

Definition at line 14 of file stacktrace.cpp.

15{
16 DWORD symOptions = SymGetOptions();
18 SymSetOptions(symOptions);
19 SymInitialize(data.ProcessHandle, NULL, TRUE);
20}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
BOOL WINAPI SymInitialize(HANDLE hProcess, PCSTR UserSearchPath, BOOL fInvadeProcess)
Definition: dbghelp.c:534
#define SYMOPT_AUTO_PUBLICS
Definition: compat.h:994
#define SYMOPT_DEFERRED_LOADS
Definition: compat.h:989
#define SYMOPT_UNDNAME
Definition: compat.h:988
DWORD WINAPI SymSetOptions(DWORD opts)
Definition: dbghelp.c:585
DWORD WINAPI SymGetOptions(void)
Definition: dbghelp.c:600
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

Referenced by PrintBugreport().

◆ EndStackBacktrace()

void EndStackBacktrace ( DumpData data)

Definition at line 22 of file stacktrace.cpp.

23{
24 SymCleanup(data.ProcessHandle);
25}
BOOL WINAPI SymCleanup(HANDLE hProcess)
Definition: dbghelp.c:557

Referenced by PrintBugreport().

◆ PrintStackBacktrace()

void PrintStackBacktrace ( FILE output,
DumpData data,
ThreadData thread 
)

Definition at line 36 of file stacktrace.cpp.

37{
38 DWORD MachineType;
39 STACKFRAME64 StackFrame = { { 0 } };
40
41 StackFrame.AddrPC.Mode = AddrModeFlat;
42 StackFrame.AddrReturn.Mode = AddrModeFlat;
43 StackFrame.AddrFrame.Mode = AddrModeFlat;
44 StackFrame.AddrStack.Mode = AddrModeFlat;
45 StackFrame.AddrBStore.Mode = AddrModeFlat;
46
47
48#if defined(_M_IX86)
49 MachineType = IMAGE_FILE_MACHINE_I386;
50 StackFrame.AddrPC.Offset = thread.Context.Eip;
51 StackFrame.AddrStack.Offset = thread.Context.Esp;
52 StackFrame.AddrFrame.Offset = thread.Context.Ebp;
53#elif defined(_M_AMD64)
54 MachineType = IMAGE_FILE_MACHINE_AMD64;
55 StackFrame.AddrPC.Offset = thread.Context.Rip;
56 StackFrame.AddrStack.Offset = thread.Context.Rsp;
57 StackFrame.AddrFrame.Offset = thread.Context.Rbp;
58#elif defined(_M_ARM)
59 MachineType = IMAGE_FILE_MACHINE_ARMNT;
60 StackFrame.AddrPC.Offset = thread.Context.Pc;
61 StackFrame.AddrStack.Offset = thread.Context.Sp;
62 StackFrame.AddrFrame.Offset = thread.Context.R11;
63#elif defined(_M_ARM64)
64 MachineType = IMAGE_FILE_MACHINE_ARM64;
65 StackFrame.AddrPC.Offset = thread.Context.Pc;
66 StackFrame.AddrStack.Offset = thread.Context.Sp;
67 StackFrame.AddrFrame.Offset = thread.Context.u.s.Fp;
68#else
69#error "Unknown architecture"
70#endif
71
72#define STACKWALK_MAX_NAMELEN 512
73 char buf[sizeof(SYMBOL_INFO) + STACKWALK_MAX_NAMELEN] = {0};
74 SYMBOL_INFO* sym = (SYMBOL_INFO *)buf;
75 IMAGEHLP_MODULE64 Module = { 0 };
76 LONG RecursionDepth = 0;
77 sym->SizeOfStruct = sizeof(sym);
78
79 /* FIXME: dump x bytes at PC here + disasm it! */
80
81 xfprintf(output, NEWLINE "*----> Stack Back Trace <----*" NEWLINE NEWLINE);
82 bool first = true;
83 while (StackWalk64(MachineType, data.ProcessHandle, thread.Handle, &StackFrame, &thread.Context,
85 {
86 if (StackFrame.AddrPC.Offset == StackFrame.AddrReturn.Offset)
87 {
88 if (RecursionDepth++ > STACK_MAX_RECURSION_DEPTH)
89 {
90 xfprintf(output, "- Aborting stackwalk -" NEWLINE);
91 break;
92 }
93 }
94 else
95 {
96 RecursionDepth = 0;
97 }
98
99 if (first)
100 {
101 xfprintf(output, "FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name" NEWLINE);
102 first = false;
103 }
104
105 Module.SizeOfStruct = sizeof(Module);
106 DWORD64 ModBase = SymGetModuleBase64(data.ProcessHandle, StackFrame.AddrPC.Offset);
107 if (!ModBase || !SymGetModuleInfo64(data.ProcessHandle, ModBase, &Module))
108 strcpy(Module.ModuleName, "<nomod>");
109
110 memset(sym, '\0', sizeof(*sym) + STACKWALK_MAX_NAMELEN);
111 sym->SizeOfStruct = sizeof(*sym);
113 DWORD64 displacement = 0;
114
115 if (!StackFrame.AddrPC.Offset || !SymFromAddr(data.ProcessHandle, StackFrame.AddrPC.Offset, &displacement, sym))
116 strcpy(sym->Name, "<nosymbols>");
117
118 xfprintf(output, "%p %p %p %p %p %p %s!%s +0x%I64x" NEWLINE,
119 (ULONG_PTR)StackFrame.AddrFrame.Offset, (ULONG_PTR)StackFrame.AddrPC.Offset,
120 (ULONG_PTR)StackFrame.Params[0], (ULONG_PTR)StackFrame.Params[1],
121 (ULONG_PTR)StackFrame.Params[2], (ULONG_PTR)StackFrame.Params[3],
122 Module.ModuleName, sym->Name, displacement);
123 }
124
125 UCHAR stackData[0x10 * 10];
126 SIZE_T sizeRead;
127#if defined(_M_IX86)
128 ULONG_PTR stackPointer = thread.Context.Esp;
129#elif defined(_M_AMD64)
130 ULONG_PTR stackPointer = thread.Context.Rsp;
131#elif defined(_M_ARM) || defined(_M_ARM64)
132 ULONG_PTR stackPointer = thread.Context.Sp;
133#else
134#error Unknown architecture
135#endif
136 if (!ReadProcessMemory(data.ProcessHandle, (PVOID)stackPointer, stackData, sizeof(stackData), &sizeRead))
137 return;
138
139 xfprintf(output, NEWLINE "*----> Raw Stack Dump <----*" NEWLINE NEWLINE);
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 {
149 size_t idx = j + n;
150 if (idx < sizeRead)
151 {
152 HexData1[j * 3] = ToChar(stackData[idx] >> 4);
153 HexData1[j * 3 + 1] = ToChar(stackData[idx] & 0xf);
154 AsciiData1[j] = isprint(stackData[idx]) ? stackData[idx] : '.';
155 }
156 idx += 8;
157 if (idx < sizeRead)
158 {
159 HexData2[j * 3] = ToChar(stackData[idx] >> 4);
160 HexData2[j * 3 + 1] = ToChar(stackData[idx] & 0xf);
161 AsciiData2[j] = isprint(stackData[idx]) ? stackData[idx] : '.';
162 }
163 }
164
165 xfprintf(output, "%p %s - %s %s%s" NEWLINE, stackPointer+n, HexData1, HexData2, AsciiData1, AsciiData2);
166 }
167}
#define isprint(c)
Definition: acclib.h:73
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static HANDLE thread
Definition: service.c:33
unsigned int idx
Definition: utils.c:41
BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, PSYMBOL_INFO Symbol)
Definition: symbol.c:1263
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define IMAGE_FILE_MACHINE_ARMNT
Definition: compat.h:127
PVOID WINAPI SymFunctionTableAccess64(HANDLE, DWORD64)
Definition: module.c:1371
DWORD64 WINAPI SymGetModuleBase64(HANDLE, DWORD64)
Definition: module.c:1313
@ AddrModeFlat
Definition: compat.h:1159
struct _SYMBOL_INFO SYMBOL_INFO
#define IMAGE_FILE_MACHINE_ARM64
Definition: compat.h:129
BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULE64 ModuleInfo)
Definition: module.c:1219
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)
Definition: stack.c:210
#define NEWLINE
Definition: drwtsn32.h:53
void xfprintf(FILE *stream, const char *fmt,...)
Definition: main.cpp:34
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const GLint * first
Definition: glext.h:5794
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
Definition: glfuncs.h:250
#define IMAGE_FILE_MACHINE_AMD64
Definition: ntimage.h:17
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
long LONG
Definition: pedump.c:60
#define memset(x, y, z)
Definition: compat.h:39
#define STACK_MAX_RECURSION_DEPTH
Definition: stacktrace.cpp:11
#define STACKWALK_MAX_NAMELEN
static char ToChar(UCHAR data)
Definition: stacktrace.cpp:27
DWORD SizeOfStruct
Definition: compat.h:1238
CHAR ModuleName[32]
Definition: compat.h:1245
ADDRESS64 AddrBStore
Definition: compat.h:1405
ADDRESS64 AddrStack
Definition: compat.h:1404
ADDRESS64 AddrFrame
Definition: compat.h:1403
ADDRESS64 AddrPC
Definition: compat.h:1401
DWORD64 Params[4]
Definition: compat.h:1407
ADDRESS64 AddrReturn
Definition: compat.h:1402
ULONG SizeOfStruct
Definition: compat.h:1038
CHAR Name[1]
Definition: compat.h:1052
ULONG MaxNameLen
Definition: compat.h:1051
ADDRESS_MODE Mode
Definition: compat.h:1176
DWORD64 Offset
Definition: compat.h:1174
uint64_t DWORD64
Definition: typedefs.h:67
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by PrintThread().

◆ PrintSystemInfo()

void PrintSystemInfo ( FILE output,
DumpData data 
)

Definition at line 56 of file sysinfo.cpp.

57{
58 SYSTEMTIME LocalTime;
59 GetLocalTime(&LocalTime);
60 xfprintf(output, NEWLINE "ReactOS " KERNEL_VERSION_STR " DrWtsn32" NEWLINE NEWLINE);
61 xfprintf(output, "Application exception occurred:" NEWLINE);
62 xfprintf(output, " App: %ls (pid=%d, tid=0x%x)" NEWLINE, data.ProcessName.c_str(), data.ProcessID, data.ThreadID);
63 xfprintf(output, " When: %d/%d/%d @ %02d:%02d:%02d.%d" NEWLINE,
64 LocalTime.wDay, LocalTime.wMonth, LocalTime.wYear,
65 LocalTime.wHour, LocalTime.wMinute, LocalTime.wSecond, LocalTime.wMilliseconds);
66
67 xfprintf(output, " First chance: %u" NEWLINE, data.ExceptionInfo.dwFirstChance);
68 EXCEPTION_RECORD& Record = data.ExceptionInfo.ExceptionRecord;
69 xfprintf(output, " Exception number: 0x%08x (%s)" NEWLINE, Record.ExceptionCode, Exception2Str(Record.ExceptionCode));
70 xfprintf(output, " Exception flags: 0x%08x" NEWLINE, Record.ExceptionFlags);
71 xfprintf(output, " Exception address: %p" NEWLINE, Record.ExceptionAddress);
72 if (Record.NumberParameters)
73 {
74 xfprintf(output, " Exception parameters: %u" NEWLINE, Record.NumberParameters);
75 for (DWORD n = 0; n < std::min<DWORD>(EXCEPTION_MAXIMUM_PARAMETERS, Record.NumberParameters); ++n)
76 {
77 xfprintf(output, " Parameter %u: 0x%p" NEWLINE, n, Record.ExceptionInformation[n]);
78 }
79 }
80
81 char Buffer[MAX_PATH];
82 DWORD count = sizeof(Buffer);
83 xfprintf(output, NEWLINE "*----> System Information <----*" NEWLINE NEWLINE);
85 xfprintf(output, " Computer Name: %s" NEWLINE, Buffer);
86 count = sizeof(Buffer);
88 xfprintf(output, " User Name: %s" NEWLINE, Buffer);
89
90
91 PVOID SMBiosBuf;
92 PCHAR DmiStrings[ID_STRINGS_MAX] = { 0 };
93 SMBiosBuf = LoadSMBiosData(DmiStrings);
94 if (SMBiosBuf)
95 {
96 if (DmiStrings[BIOS_VENDOR])
97 xfprintf(output, " BIOS Vendor: %s" NEWLINE, DmiStrings[BIOS_VENDOR]);
98 if (DmiStrings[BIOS_VERSION])
99 xfprintf(output, " BIOS Version: %s" NEWLINE, DmiStrings[BIOS_VERSION]);
100 if (DmiStrings[BIOS_DATE])
101 xfprintf(output, " BIOS Date: %s" NEWLINE, DmiStrings[BIOS_DATE]);
102 if (DmiStrings[SYS_VENDOR])
103 xfprintf(output, " System Manufacturer: %s" NEWLINE, DmiStrings[SYS_VENDOR]);
104 if (DmiStrings[SYS_FAMILY])
105 xfprintf(output, " System Family: %s" NEWLINE, DmiStrings[SYS_FAMILY]);
106 if (DmiStrings[SYS_PRODUCT])
107 xfprintf(output, " System Model: %s" NEWLINE, DmiStrings[SYS_PRODUCT]);
108 if (DmiStrings[SYS_VERSION])
109 xfprintf(output, " System Version: %s" NEWLINE, DmiStrings[SYS_VERSION]);
110 if (DmiStrings[SYS_SKU])
111 xfprintf(output, " System SKU: %s" NEWLINE, DmiStrings[SYS_SKU]);
112 if (DmiStrings[BOARD_VENDOR])
113 xfprintf(output, " Baseboard Manufacturer: %s" NEWLINE, DmiStrings[BOARD_VENDOR]);
114 if (DmiStrings[BOARD_NAME])
115 xfprintf(output, " Baseboard Model: %s" NEWLINE, DmiStrings[BOARD_NAME]);
116 if (DmiStrings[BOARD_VERSION])
117 xfprintf(output, " Baseboard Version: %s" NEWLINE, DmiStrings[BOARD_VERSION]);
118 FreeSMBiosData(SMBiosBuf);
119 }
120
123 xfprintf(output, " Number of Processors: %d" NEWLINE, info.dwNumberOfProcessors);
124
125 HKEY hKey;
126 LONG ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
127 0, KEY_READ, &hKey);
128 if (ret == ERROR_SUCCESS)
129 {
130 DWORD dwType;
131 count = sizeof(Buffer);
132 ret = RegQueryValueExA(hKey, "Identifier", NULL, &dwType, (LPBYTE)Buffer, &count);
133 if (ret == ERROR_SUCCESS && dwType == REG_SZ)
134 {
135 Buffer[count] = '\0';
136 xfprintf(output, " Processor Type: %s" NEWLINE, Buffer);
137 }
139 }
140
141 ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey);
142 if (ret == ERROR_SUCCESS)
143 {
144 char Version[50];
145 ReadKey(hKey, "ProductName", Buffer, sizeof(Buffer));
146 ReadKey(hKey, "CurrentVersion", Version, sizeof(Version));
147 xfprintf(output, " %s Version: %s" NEWLINE, Buffer, Version);
148 ReadKey(hKey, "BuildLab", Buffer, sizeof(Buffer));
149 xfprintf(output, " BuildLab: %s" NEWLINE, Buffer);
150 ReadKey(hKey, "CSDVersion", Buffer, sizeof(Buffer));
151 if (Buffer[0])
152 xfprintf(output, " Service Pack: %s" NEWLINE, Buffer);
153 ReadKey(hKey, "CurrentType", Buffer, sizeof(Buffer));
154 xfprintf(output, " Current Type: %s" NEWLINE, Buffer);
155 ReadKey(hKey, "RegisteredOrganization", Buffer, sizeof(Buffer));
156 xfprintf(output, " Registered Organization: %s" NEWLINE, Buffer);
157 ReadKey(hKey, "RegisteredOwner", Buffer, sizeof(Buffer));
158 xfprintf(output, " Registered Owner: %s" NEWLINE, Buffer);
159
161 }
162}
#define RegCloseKey(hKey)
Definition: registry.h:49
Definition: bufpool.h:45
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
BOOL WINAPI GetUserNameA(LPSTR lpszName, LPDWORD lpSize)
Definition: misc.c:246
#define EXCEPTION_MAXIMUM_PARAMETERS
Definition: compat.h:206
#define MAX_PATH
Definition: compat.h:34
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
@ BIOS_VERSION
Definition: dmilib.h:14
@ BOARD_VENDOR
Definition: dmilib.h:22
@ SYS_VERSION
Definition: dmilib.h:18
@ SYS_PRODUCT
Definition: dmilib.h:17
@ ID_STRINGS_MAX
Definition: dmilib.h:28
@ BIOS_DATE
Definition: dmilib.h:15
@ SYS_VENDOR
Definition: dmilib.h:16
@ BIOS_VENDOR
Definition: dmilib.h:13
@ BOARD_NAME
Definition: dmilib.h:23
@ BOARD_VERSION
Definition: dmilib.h:24
@ SYS_FAMILY
Definition: dmilib.h:21
@ SYS_SKU
Definition: dmilib.h:20
FxAutoRegKey hKey
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define REG_SZ
Definition: layer.c:22
#define KEY_READ
Definition: nt_native.h:1023
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
WORD wYear
Definition: winbase.h:905
WORD wMilliseconds
Definition: winbase.h:912
WORD wMonth
Definition: winbase.h:906
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910
WORD wDay
Definition: winbase.h:908
static const char * Exception2Str(DWORD code)
Definition: sysinfo.cpp:14
static void ReadKey(HKEY hKey, const char *ValueName, char *Buffer, DWORD size)
Definition: sysinfo.cpp:48
unsigned char * LPBYTE
Definition: typedefs.h:53
char * PCHAR
Definition: typedefs.h:51
PVOID LoadSMBiosData(_Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: udmihelp.c:30
VOID FreeSMBiosData(_In_ PVOID Buffer)
Definition: udmihelp.c:177
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:268

Referenced by PrintBugreport().

◆ UpdateFromEvent()

bool UpdateFromEvent ( DEBUG_EVENT evt,
DumpData data 
)

Definition at line 56 of file drwtsn32.cpp.

57{
58 switch(evt.dwDebugEventCode)
59 {
61 {
62 data.ProcessPath.resize(MAX_PATH*2);
63 DWORD len = GetModuleFileNameExW(evt.u.CreateProcessInfo.hProcess, NULL, &data.ProcessPath[0], data.ProcessPath.size());
64 if (len)
65 {
66 data.ProcessPath.resize(len);
67 std::string::size_type pos = data.ProcessPath.find_last_of(L"\\/");
68 if (pos != std::string::npos)
69 data.ProcessName = data.ProcessPath.substr(pos+1);
70 }
71 else
72 {
73 data.ProcessPath = L"??";
74 }
75 if (data.ProcessName.empty())
76 data.ProcessName = data.ProcessPath;
77
79 data.ProcessID = evt.dwProcessId;
80 data.ProcessHandle = evt.u.CreateProcessInfo.hProcess;
82 }
83 break;
85 data.Threads[evt.dwThreadId] = ThreadData(evt.u.CreateThread.hThread);
86 break;
88 {
89 ThreadMap::iterator it = data.Threads.find(evt.dwThreadId);
90 if (it != data.Threads.end())
91 {
92 data.Threads.erase(it);
93 }
94 }
95 break;
98 for (size_t n = 0; n < data.Modules.size(); ++n)
99 {
100 if (data.Modules[n].BaseAddress == evt.u.LoadDll.lpBaseOfDll)
101 {
102 data.Modules[n].Unloaded = false;
103 return true;
104 }
105 }
106 data.Modules.push_back(ModuleData(evt.u.LoadDll.lpBaseOfDll));
107 break;
109 for (size_t n = 0; n < data.Modules.size(); ++n)
110 {
111 if (data.Modules[n].BaseAddress == evt.u.UnloadDll.lpBaseOfDll)
112 data.Modules[n].Unloaded = true;
113 }
114 break;
115 case OUTPUT_DEBUG_STRING_EVENT: // ignore
116 break;
118 if (evt.u.Exception.dwFirstChance)
119 {
121 {
123 if (!data.FirstBPHit)
124 {
125 data.FirstBPHit = true;
126
127 if (data.Event)
128 {
129 SetEvent(data.Event);
130 CloseHandle(data.Event);
131 data.Event = NULL;
132 }
133 return true;
134 }
135 break;
137 /* Thread name */
138 return true;
139 case DBG_CONTROL_C:
141 return true;
142 }
143 }
144 data.ExceptionInfo = evt.u.Exception;
145 data.ThreadID = evt.dwThreadId;
146 return false;
148 //assert(FALSE);
149 return false;
150 case RIP_EVENT:
151 //assert(FALSE);
152 return false;
153 default:
154 assert(false);
155 }
156 return true;
157}
#define CloseHandle
Definition: compat.h:739
#define GetModuleFileNameExW(w, x, y, z)
Definition: compat.h:922
#define assert(x)
Definition: debug.h:53
#define MS_VC_EXCEPTION_THREAD_NAME
Definition: drwtsn32.cpp:11
GLenum GLsizei len
Definition: glext.h:6722
#define DBG_CONTROL_BREAK
Definition: ntstatus.h:55
#define DBG_CONTROL_C
Definition: ntstatus.h:52
#define L(x)
Definition: ntvdm.h:50
UNLOAD_DLL_DEBUG_INFO UnloadDll
Definition: winbase.h:798
DWORD dwDebugEventCode
Definition: winbase.h:788
DWORD dwThreadId
Definition: winbase.h:790
DWORD dwProcessId
Definition: winbase.h:789
LOAD_DLL_DEBUG_INFO LoadDll
Definition: winbase.h:797
EXCEPTION_DEBUG_INFO Exception
Definition: winbase.h:792
CREATE_PROCESS_DEBUG_INFO CreateProcessInfo
Definition: winbase.h:794
CREATE_THREAD_DEBUG_INFO CreateThread
Definition: winbase.h:793
union _DEBUG_EVENT::@3279 u
EXCEPTION_RECORD ExceptionRecord
Definition: winbase.h:751
DWORD ExceptionCode
Definition: compat.h:208
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define RIP_EVENT
Definition: winbase.h:110
#define CREATE_PROCESS_DEBUG_EVENT
Definition: winbase.h:104
#define LOAD_DLL_DEBUG_EVENT
Definition: winbase.h:107
#define EXIT_PROCESS_DEBUG_EVENT
Definition: winbase.h:106
#define OUTPUT_DEBUG_STRING_EVENT
Definition: winbase.h:109
#define EXCEPTION_DEBUG_EVENT
Definition: winbase.h:102
#define CREATE_THREAD_DEBUG_EVENT
Definition: winbase.h:103
#define UNLOAD_DLL_DEBUG_EVENT
Definition: winbase.h:108
#define EXCEPTION_BREAKPOINT
Definition: winbase.h:313
#define EXIT_THREAD_DEBUG_EVENT
Definition: winbase.h:105

Referenced by wWinMain().

◆ xfprintf()

void xfprintf ( FILE stream,
const char fmt,
  ... 
)

Definition at line 34 of file main.cpp.

35{
36 va_list ap;
37
38 va_start(ap, fmt);
41 va_end(ap);
42}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
#define DPFLTR_ERROR_LEVEL
Definition: main.cpp:32
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Definition: dsound.c:943
Definition: parse.h:23
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by PrintBugreport(), PrintStackBacktrace(), PrintSystemInfo(), PrintThread(), and wWinMain().