23static const char szUsage[] =
"Usage: DrWtsn32 [-i] [-g] [-p dddd] [-e dddd] [-?]\n"
24 " -i: Install DrWtsn32 as the postmortem debugger\n"
25 " -g: Ignored, Provided for compatibility with WinDbg and CDB.\n"
26 " -p dddd: Attach to process dddd.\n"
27 " -e dddd: Signal the event dddd.\n"
32#define DPFLTR_ERROR_LEVEL 0
48 return left.BaseAddress <
right.BaseAddress;
56 (
tid ==
data.ThreadID) ?
" (CRASH)" :
"");
64#elif defined(_M_AMD64)
65 xfprintf(output,
"rax:%p rbx:%p rcx:%p rdx:%p rsi:%p rdi:%p rbp:%p rsp:%p" NEWLINE,
67 xfprintf(output,
"r8:%p r9:%p r10:%p r11:%p r12:%p r13:%p r14:%p r15:%p" NEWLINE,
75#error Unknown architecture
84#elif defined(_M_AMD64)
91#error Unknown architecture
97#if defined(_M_IX86) || defined(_M_AMD64)
111#error Unknown architecture
145 data.ProcessPath.c_str());
147 for (
size_t n = 0;
n <
data.Modules.size(); ++
n)
152 mod.Update(
data.ProcessHandle);
156 mod.ModuleName.c_str());
163 ThreadMap::iterator crash =
data.Threads.find(
data.ThreadID);
164 if (crash !=
data.Threads.end())
168 for (ThreadMap::iterator it =
data.Threads.begin(); it !=
data.Threads.end(); ++it)
170 if (it->first !=
data.ThreadID)
197 UseDefaultPath =
FALSE;
204 return std::wstring();
208 return std::wstring(
Buffer);
309 return abort(output, 0);
327 BOOL HasPath = (OutputPath.size() != 0);
334 xfprintf(
stdout,
"Could not create output directory, not writing dump\n");
346 output =
_wfopen(OutputPath.c_str(),
L"wb");
353 return abort(output, -2);
360 return abort(output, -3);
369 return abort(output, -4);
387 return abort(output, 0);
std::map< E_MODULE, HMODULE > mod
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 ComponentId
static const char szUsage[]
static void PrintThread(FILE *output, DumpData &data, DWORD tid, ThreadData &thread)
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR cmdLine, INT)
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
void xfprintf(FILE *stream, const char *fmt,...)
std::wstring Settings_GetOutputPath(void)
BOOL Settings_GetShouldWriteDump(void)
#define DPFLTR_ERROR_LEVEL
HRESULT WriteMinidump(LPCWSTR LogFilePath, DumpData &data)
void PrintBugreport(FILE *output, DumpData &data)
static bool SortModules(const ModuleData &left, const ModuleData &right)
#define IDS_USER_ALERT_MESSAGE
PXSTR GetString() noexcept
BOOL LoadString(_In_ UINT nID)
void __cdecl Format(UINT nFormatID,...)
#define INVALID_HANDLE_VALUE
#define FILE_ATTRIBUTE_NORMAL
BOOL WINAPI DebugSetProcessKillOnExit(IN BOOL KillOnExit)
BOOL WINAPI ContinueDebugEvent(IN DWORD dwProcessId, IN DWORD dwThreadId, IN DWORD dwContinueStatus)
BOOL WINAPI DebugActiveProcess(IN DWORD dwProcessId)
BOOL WINAPI WaitForDebugEvent(IN LPDEBUG_EVENT lpDebugEvent, IN DWORD dwMilliseconds)
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
void WINAPI PathRemoveExtensionW(WCHAR *path)
LPWSTR WINAPI GetCommandLineW(void)
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
bool UpdateFromEvent(DEBUG_EVENT &evt, DumpData &data)
void PrintStackBacktrace(FILE *output, DumpData &data, ThreadData &thread)
void BeginStackBacktrace(DumpData &data)
void PrintSystemInfo(FILE *output, DumpData &data)
void EndStackBacktrace(DumpData &data)
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
__in PVOID ContextPointer
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
BOOL WINAPI MiniDumpWriteDump(HANDLE hProcess, DWORD pid, HANDLE hFile, MINIDUMP_TYPE DumpType, PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, PMINIDUMP_CALLBACK_INFORMATION CallbackParam)
#define ERROR_ALREADY_EXISTS
#define CONTEXT_DEBUG_REGISTERS
#define PathAddExtensionW
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ARM_MAX_WATCHPOINTS
#define ARM_MAX_BREAKPOINTS
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
void Update(HANDLE hProcess)
PEXCEPTION_RECORD ExceptionRecord
struct _EXCEPTION_RECORD * ExceptionRecord
#define TH32CS_SNAPPROCESS
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
DWORD WINAPI GetLastError(void)
#define CREATE_PROCESS_DEBUG_EVENT
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
#define HRESULT_FROM_WIN32(x)
void int int ULONGLONG int va_list * ap
#define HKEY_CURRENT_USER
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
unsigned __int64 CDECL _wcstoui64(const wchar_t *nptr, wchar_t **endptr, int base)