Mercurial > hg > openttd
annotate src/os/windows/crashlog_win.cpp @ 13915:5a588b3068cf draft
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
author | glx <glx@openttd.org> |
---|---|
date | Wed, 09 Dec 2009 15:24:13 +0000 |
parents | b9302d9e1874 |
children | 3777c5a4b5eb |
rev | line source |
---|---|
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
3 /* |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
4 * This file is part of OpenTTD. |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
8 */ |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
9 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
10 /** @file crashlog_win.cpp Implementation of a crashlogger for Windows */ |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
11 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
12 #include "../../stdafx.h" |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
13 #include "../../crashlog.h" |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
14 #include "win32.h" |
12918
d595a7dce1de
(svn r17410) -Codechange: use the same define for determining whether windows does crash reports instead of using several that aren't necessarily equal
rubidium <rubidium@openttd.org>
parents:
12917
diff
changeset
|
15 #include "../../core/alloc_func.hpp" |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
16 #include "../../core/math_func.hpp" |
12918
d595a7dce1de
(svn r17410) -Codechange: use the same define for determining whether windows does crash reports instead of using several that aren't necessarily equal
rubidium <rubidium@openttd.org>
parents:
12917
diff
changeset
|
17 #include "../../string_func.h" |
d595a7dce1de
(svn r17410) -Codechange: use the same define for determining whether windows does crash reports instead of using several that aren't necessarily equal
rubidium <rubidium@openttd.org>
parents:
12917
diff
changeset
|
18 #include "../../fileio_func.h" |
d595a7dce1de
(svn r17410) -Codechange: use the same define for determining whether windows does crash reports instead of using several that aren't necessarily equal
rubidium <rubidium@openttd.org>
parents:
12917
diff
changeset
|
19 #include "../../strings_func.h" |
12959
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
20 #include "../../gamelog.h" |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
21 |
12918
d595a7dce1de
(svn r17410) -Codechange: use the same define for determining whether windows does crash reports instead of using several that aren't necessarily equal
rubidium <rubidium@openttd.org>
parents:
12917
diff
changeset
|
22 #include <windows.h> |
13915
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
23 #include <signal.h> |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
24 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
25 /** |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
26 * Windows implementation for the crash logger. |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
27 */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
28 class CrashLogWindows : public CrashLog { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
29 /** Information about the encountered exception */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
30 EXCEPTION_POINTERS *ep; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
31 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
32 /* virtual */ char *LogOSVersion(char *buffer, const char *last) const; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
33 /* virtual */ char *LogError(char *buffer, const char *last, const char *message) const; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
34 /* virtual */ char *LogStacktrace(char *buffer, const char *last) const; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
35 /* virtual */ char *LogRegisters(char *buffer, const char *last) const; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
36 /* virtual */ char *LogModules(char *buffer, const char *last) const; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
37 public: |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
38 #if defined(_MSC_VER) |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
39 /* virtual */ int WriteCrashDump(char *filename, const char *filename_last) const; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
40 #endif /* _MSC_VER */ |
12918
d595a7dce1de
(svn r17410) -Codechange: use the same define for determining whether windows does crash reports instead of using several that aren't necessarily equal
rubidium <rubidium@openttd.org>
parents:
12917
diff
changeset
|
41 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
42 /** Buffer for the generated crash log */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
43 char crashlog[65536]; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
44 /** Buffer for the filename of the crash log */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
45 char crashlog_filename[MAX_PATH]; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
46 /** Buffer for the filename of the crash dump */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
47 char crashdump_filename[MAX_PATH]; |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
48 /** Buffer for the filename of the crash screenshot */ |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
49 char screenshot_filename[MAX_PATH]; |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
50 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
51 /** |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
52 * A crash log is always generated when it's generated. |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
53 * @param ep the data related to the exception. |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
54 */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
55 CrashLogWindows(EXCEPTION_POINTERS *ep = NULL) : |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
56 ep(ep) |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
57 { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
58 this->crashlog[0] = '\0'; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
59 this->crashlog_filename[0] = '\0'; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
60 this->crashdump_filename[0] = '\0'; |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
61 this->screenshot_filename[0] = '\0'; |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
62 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
63 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
64 /** |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
65 * Points to the current crash log. |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
66 */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
67 static CrashLogWindows *current; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
68 }; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
69 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
70 /* static */ CrashLogWindows *CrashLogWindows::current = NULL; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
71 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
72 /* virtual */ char *CrashLogWindows::LogOSVersion(char *buffer, const char *last) const |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
73 { |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
74 _OSVERSIONINFOA os; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
75 os.dwOSVersionInfoSize = sizeof(os); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
76 GetVersionExA(&os); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
77 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
78 return buffer + seprintf(buffer, last, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
79 "Operating system:\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
80 " Name: Windows\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
81 " Release: %d.%d.%d (%s)\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
82 " MSVC: %s\n\n", |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
83 (int)os.dwMajorVersion, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
84 (int)os.dwMinorVersion, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
85 (int)os.dwBuildNumber, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
86 os.szCSDVersion, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
87 #if defined(_MSC_VER) |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
88 "Yes" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
89 #else |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
90 "No" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
91 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
92 ); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
93 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
94 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
95 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
96 /* virtual */ char *CrashLogWindows::LogError(char *buffer, const char *last, const char *message) const |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
97 { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
98 return buffer + seprintf(buffer, last, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
99 "Crash reason:\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
100 " Exception: %.8X\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
101 #ifdef _M_AMD64 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
102 " Location: %.16IX\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
103 #else |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
104 " Location: %.8X\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
105 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
106 " Message: %s\n\n", |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
107 (int)ep->ExceptionRecord->ExceptionCode, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
108 (size_t)ep->ExceptionRecord->ExceptionAddress, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
109 message == NULL ? "<none>" : message |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
110 ); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
111 } |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
112 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
113 struct DebugFileInfo { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
114 uint32 size; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
115 uint32 crc32; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
116 SYSTEMTIME file_time; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
117 }; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
118 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
119 static uint32 *_crc_table; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
120 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
121 static void MakeCRCTable(uint32 *table) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
122 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
123 uint32 crc, poly = 0xEDB88320L; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
124 int i; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
125 int j; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
126 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
127 _crc_table = table; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
128 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
129 for (i = 0; i != 256; i++) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
130 crc = i; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
131 for (j = 8; j != 0; j--) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 crc = (crc & 1 ? (crc >> 1) ^ poly : crc >> 1); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
133 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
134 table[i] = crc; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
136 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
137 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 static uint32 CalcCRC(byte *data, uint size, uint32 crc) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
140 for (; size > 0; size--) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
141 crc = ((crc >> 8) & 0x00FFFFFF) ^ _crc_table[(crc ^ *data++) & 0xFF]; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
142 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
143 return crc; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
144 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
145 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
146 static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
147 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
148 HANDLE file; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
149 memset(dfi, 0, sizeof(*dfi)); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
150 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
151 file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
152 if (file != INVALID_HANDLE_VALUE) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
153 byte buffer[1024]; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
154 DWORD numread; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
155 uint32 filesize = 0; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
156 FILETIME write_time; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
157 uint32 crc = (uint32)-1; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 for (;;) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
160 if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 || numread == 0) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
161 break; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
162 filesize += numread; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
163 crc = CalcCRC(buffer, numread, crc); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
165 dfi->size = filesize; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
166 dfi->crc32 = crc ^ (uint32)-1; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
167 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
168 if (GetFileTime(file, NULL, NULL, &write_time)) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
169 FileTimeToSystemTime(&write_time, &dfi->file_time); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
170 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
171 CloseHandle(file); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
172 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
173 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
174 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
175 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
176 static char *PrintModuleInfo(char *output, const char *last, HMODULE mod) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
177 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
178 TCHAR buffer[MAX_PATH]; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
179 DebugFileInfo dfi; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
180 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
181 GetModuleFileName(mod, buffer, MAX_PATH); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
182 GetFileInfo(&dfi, buffer); |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
183 output += seprintf(output, last, " %-20s handle: %p size: %d crc: %.8X date: %d-%.2d-%.2d %.2d:%.2d:%.2d\n", |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
184 WIDE_TO_MB(buffer), |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
185 mod, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
186 dfi.size, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
187 dfi.crc32, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
188 dfi.file_time.wYear, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
189 dfi.file_time.wMonth, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
190 dfi.file_time.wDay, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
191 dfi.file_time.wHour, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
192 dfi.file_time.wMinute, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
193 dfi.file_time.wSecond |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
194 ); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
195 return output; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
196 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
197 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
198 /* virtual */ char *CrashLogWindows::LogModules(char *output, const char *last) const |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
199 { |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
200 MakeCRCTable(AllocaM(uint32, 256)); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
201 BOOL (WINAPI *EnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
202 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
203 output += seprintf(output, last, "Module information:\n"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
204 |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
205 if (LoadLibraryList((Function*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0\0")) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
206 HMODULE modules[100]; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
207 DWORD needed; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
208 BOOL res; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
209 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
210 HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId()); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
211 if (proc != NULL) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
212 res = EnumProcessModules(proc, modules, sizeof(modules), &needed); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
213 CloseHandle(proc); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
214 if (res) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
215 size_t count = min(needed / sizeof(HMODULE), lengthof(modules)); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
216 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
217 for (size_t i = 0; i != count; i++) output = PrintModuleInfo(output, last, modules[i]); |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
218 return output + seprintf(output, last, "\n"); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
219 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
220 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
221 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
222 output = PrintModuleInfo(output, last, NULL); |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
223 return output + seprintf(output, last, "\n"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
224 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
225 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
226 /* virtual */ char *CrashLogWindows::LogRegisters(char *buffer, const char *last) const |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
227 { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
228 buffer += seprintf(buffer, last, "Registers:\n"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
229 #ifdef _M_AMD64 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
230 buffer += seprintf(buffer, last, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
231 "Registers:\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
232 " RAX: %.16llX RBX: %.16llX RCX: %.16llX RDX: %.16llX\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
233 " RSI: %.16llX RDI: %.16llX RBP: %.16llX RSP: %.16llX\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
234 " R8: %.16llX R9: %.16llX R10: %.16llX R11: %.16llX\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
235 " R12: %.16llX R13: %.16llX R14: %.16llX R15: %.16llX\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
236 " RIP: %.16llX EFLAGS: %.8X\n", |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
237 ep->ContextRecord->Rax, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
238 ep->ContextRecord->Rbx, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
239 ep->ContextRecord->Rcx, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
240 ep->ContextRecord->Rdx, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
241 ep->ContextRecord->Rsi, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
242 ep->ContextRecord->Rdi, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
243 ep->ContextRecord->Rbp, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
244 ep->ContextRecord->Rsp, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
245 ep->ContextRecord->R8, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
246 ep->ContextRecord->R9, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
247 ep->ContextRecord->R10, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
248 ep->ContextRecord->R11, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
249 ep->ContextRecord->R12, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
250 ep->ContextRecord->R13, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
251 ep->ContextRecord->R14, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
252 ep->ContextRecord->R15, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
253 ep->ContextRecord->Rip, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
254 ep->ContextRecord->EFlags |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
255 ); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
256 #else |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
257 buffer += seprintf(buffer, last, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
258 " EAX: %.8X EBX: %.8X ECX: %.8X EDX: %.8X\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
259 " ESI: %.8X EDI: %.8X EBP: %.8X ESP: %.8X\n" |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
260 " EIP: %.8X EFLAGS: %.8X\n", |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
261 (int)ep->ContextRecord->Eax, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
262 (int)ep->ContextRecord->Ebx, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
263 (int)ep->ContextRecord->Ecx, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
264 (int)ep->ContextRecord->Edx, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
265 (int)ep->ContextRecord->Esi, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
266 (int)ep->ContextRecord->Edi, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
267 (int)ep->ContextRecord->Ebp, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
268 (int)ep->ContextRecord->Esp, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
269 (int)ep->ContextRecord->Eip, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
270 (int)ep->ContextRecord->EFlags |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
271 ); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
272 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
273 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
274 buffer += seprintf(buffer, last, "\n Bytes at instruction pointer:\n"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
275 #ifdef _M_AMD64 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
276 byte *b = (byte*)ep->ContextRecord->Rip; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
277 #else |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
278 byte *b = (byte*)ep->ContextRecord->Eip; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
279 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
280 for (int i = 0; i != 24; i++) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
281 if (IsBadReadPtr(b, 1)) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
282 buffer += seprintf(buffer, last, " ??"); // OCR: WAS: , 0); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
283 } else { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
284 buffer += seprintf(buffer, last, " %.2X", *b); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
285 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
286 b++; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
287 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
288 return buffer + seprintf(buffer, last, "\n\n"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
289 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
290 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
291 /* virtual */ char *CrashLogWindows::LogStacktrace(char *buffer, const char *last) const |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
292 { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
293 buffer += seprintf(buffer, last, "Stack trace:\n"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
294 #ifdef _M_AMD64 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
295 uint32 *b = (uint32*)ep->ContextRecord->Rsp; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
296 #else |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
297 uint32 *b = (uint32*)ep->ContextRecord->Esp; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
298 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
299 for (int j = 0; j != 24; j++) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
300 for (int i = 0; i != 8; i++) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
301 if (IsBadReadPtr(b, sizeof(uint32))) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
302 buffer += seprintf(buffer, last, " ????????"); // OCR: WAS - , 0); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
303 } else { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
304 buffer += seprintf(buffer, last, " %.8X", *b); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
305 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
306 b++; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
307 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
308 buffer += seprintf(buffer, last, "\n"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
309 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
310 return buffer + seprintf(buffer, last, "\n"); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
311 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
312 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
313 #if defined(_MSC_VER) |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
314 #include <dbghelp.h> |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
315 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
316 /* virtual */ int CrashLogWindows::WriteCrashDump(char *filename, const char *filename_last) const |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
317 { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
318 int ret = 0; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
319 HMODULE dbghelp = LoadLibrary(_T("dbghelp.dll")); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
320 if (dbghelp != NULL) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
321 typedef BOOL (WINAPI *MiniDumpWriteDump_t)(HANDLE, DWORD, HANDLE, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
322 MINIDUMP_TYPE, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
323 CONST PMINIDUMP_EXCEPTION_INFORMATION, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
324 CONST PMINIDUMP_USER_STREAM_INFORMATION, |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
325 CONST PMINIDUMP_CALLBACK_INFORMATION); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
326 MiniDumpWriteDump_t funcMiniDumpWriteDump = (MiniDumpWriteDump_t)GetProcAddress(dbghelp, "MiniDumpWriteDump"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
327 if (funcMiniDumpWriteDump != NULL) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
328 seprintf(filename, filename_last, "%scrash.dmp", _personal_dir); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
329 HANDLE file = CreateFile(OTTD2FS(filename), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
330 HANDLE proc = GetCurrentProcess(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
331 DWORD procid = GetCurrentProcessId(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
332 MINIDUMP_EXCEPTION_INFORMATION mdei; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
333 MINIDUMP_USER_STREAM userstream; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
334 MINIDUMP_USER_STREAM_INFORMATION musi; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
335 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
336 userstream.Type = LastReservedStream + 1; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
337 userstream.Buffer = (void*)this->crashlog; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
338 userstream.BufferSize = (ULONG)strlen(this->crashlog) + 1; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
339 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
340 musi.UserStreamCount = 1; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
341 musi.UserStreamArray = &userstream; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
342 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
343 mdei.ThreadId = GetCurrentThreadId(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
344 mdei.ExceptionPointers = ep; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
345 mdei.ClientPointers = false; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
346 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
347 funcMiniDumpWriteDump(proc, procid, file, MiniDumpWithDataSegs, &mdei, &musi, NULL); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
348 ret = 1; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
349 } else { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
350 ret = -1; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
351 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
352 FreeLibrary(dbghelp); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
353 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
354 return ret; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
355 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
356 #endif /* _MSC_VER */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
357 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
358 extern bool CloseConsoleLogIfActive(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
359 static void ShowCrashlogWindow(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
360 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
361 /** |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
362 * Stack pointer for use when 'starting' the crash handler. |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
363 * Not static as gcc's inline assembly needs it that way. |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
364 */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
365 void *_safe_esp = NULL; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
366 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
367 static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep) |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
368 { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
369 if (CrashLogWindows::current != NULL) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
370 CrashLog::AfterCrashLogCleanup(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
371 ExitProcess(2); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
372 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
373 |
12959
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
374 if (GamelogTestEmergency()) { |
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
375 static const TCHAR _emergency_crash[] = |
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
376 _T("A serious fault condition occured in the game. The game will shut down.\n") |
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
377 _T("As you loaded an emergency savegame no crash information will be generated.\n"); |
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
378 MessageBox(NULL, _emergency_crash, _T("Fatal Application Failure"), MB_ICONERROR); |
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
379 ExitProcess(3); |
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
380 } |
3a7d79750a1f
(svn r17452) -Fix (r17450): emergency savegames weren't rejected by the crash logger anymore
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
381 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
382 CrashLogWindows *log = new CrashLogWindows(ep); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
383 CrashLogWindows::current = log; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
384 log->FillCrashLog(log->crashlog, lastof(log->crashlog)); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
385 log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename)); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
386 log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename)); |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
387 log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename)); |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
388 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
389 /* Close any possible log files */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
390 CloseConsoleLogIfActive(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
391 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
392 if (_safe_esp) { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
393 #ifdef _M_AMD64 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
394 ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
395 ep->ContextRecord->Rsp = (DWORD64)_safe_esp; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
396 #else |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
397 ep->ContextRecord->Eip = (DWORD)ShowCrashlogWindow; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
398 ep->ContextRecord->Esp = (DWORD)_safe_esp; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
399 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
400 return EXCEPTION_CONTINUE_EXECUTION; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
401 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
402 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
403 CrashLog::AfterCrashLogCleanup(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
404 return EXCEPTION_EXECUTE_HANDLER; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
405 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
406 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
407 #ifdef _M_AMD64 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
408 extern "C" void *_get_safe_esp(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
409 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
410 |
13915
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
411 static void CDECL CustomAbort(int signal) |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
412 { |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
413 RaiseException(0xE1212012, 0, 0, NULL); |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
414 } |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
415 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
416 /* static */ void CrashLog::InitialiseCrashLog() |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
417 { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
418 #if defined(_MSC_VER) |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
419 #ifdef _M_AMD64 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
420 _safe_esp = _get_safe_esp(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
421 #else |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
422 _asm { |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
423 mov _safe_esp, esp |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
424 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
425 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
426 #else |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
427 asm("movl %esp, __safe_esp"); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
428 #endif |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
429 |
13915
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
430 /* SIGABRT is not an unhandled exception, so we need to intercept it. */ |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
431 signal(SIGABRT, CustomAbort); |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
432 #if defined(_MSC_VER) |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
433 /* Don't show abort message as we will get the crashlog window anyway. */ |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
434 _set_abort_behavior(0, _WRITE_ABORT_MSG); |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
435 #endif |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
436 SetUnhandledExceptionFilter(ExceptionHandler); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
437 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
438 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
439 /* The crash log GUI */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
440 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
441 static bool _expanded; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
442 |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
443 static const TCHAR _crash_desc[] = |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
444 _T("A serious fault condition occured in the game. The game will shut down.\n") |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
445 _T("Please send the crash information and the crash.dmp file (if any) to the developers.\n") |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
446 _T("This will greatly help debugging. The correct place to do this is http://bugs.openttd.org. ") |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
447 _T("The information contained in the report is displayed below.\n") |
12981
bee7b7b5b53e
(svn r17475) -Codechange: show path to crash.log and crash.dmp in crash window. Also tells the user where crash.sav is when saving succeeded.
glx <glx@openttd.org>
parents:
12959
diff
changeset
|
448 _T("Press \"Emergency save\" to attempt saving the game. Generated file(s):\n") |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
449 _T("%s"); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
450 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
451 static const TCHAR _save_succeeded[] = |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
452 _T("Emergency save succeeded.\nIts location is '%s'.\n") |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
453 _T("Be aware that critical parts of the internal game state may have become ") |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
454 _T("corrupted. The saved game is not guaranteed to work."); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
455 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
456 static const TCHAR * const _expand_texts[] = {_T("S&how report >>"), _T("&Hide report <<") }; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
457 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
458 static void SetWndSize(HWND wnd, int mode) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
459 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
460 RECT r, r2; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
461 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
462 GetWindowRect(wnd, &r); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
463 SetDlgItemText(wnd, 15, _expand_texts[mode == 1]); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
464 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
465 if (mode >= 0) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
466 GetWindowRect(GetDlgItem(wnd, 11), &r2); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
467 int offs = r2.bottom - r2.top + 10; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
468 if (!mode) offs = -offs; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
469 SetWindowPos(wnd, HWND_TOPMOST, 0, 0, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
470 r.right - r.left, r.bottom - r.top + offs, SWP_NOMOVE | SWP_NOZORDER); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
471 } else { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
472 SetWindowPos(wnd, HWND_TOPMOST, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
473 (GetSystemMetrics(SM_CXSCREEN) - (r.right - r.left)) / 2, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
474 (GetSystemMetrics(SM_CYSCREEN) - (r.bottom - r.top)) / 2, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
475 0, 0, SWP_NOSIZE); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
476 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
477 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
478 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
479 static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
480 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
481 switch (msg) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
482 case WM_INITDIALOG: { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
483 #if defined(UNICODE) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
484 /* We need to put the crash-log in a seperate buffer because the default |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
485 * buffer in MB_TO_WIDE is not large enough (512 chars) */ |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
486 wchar_t crash_msgW[lengthof(CrashLogWindows::current->crashlog)]; |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
487 #endif |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
488 /* Convert unix -> dos newlines because the edit box only supports that properly :( */ |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
489 const char *unix_nl = CrashLogWindows::current->crashlog; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
490 char dos_nl[lengthof(CrashLogWindows::current->crashlog)]; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
491 char *p = dos_nl; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
492 WChar c; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
493 while ((c = Utf8Consume(&unix_nl)) && p < lastof(dos_nl) - 4) { // 4 is max number of bytes per character |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
494 if (c == '\n') p += Utf8Encode(p, '\r'); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
495 p += Utf8Encode(p, c); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
496 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
497 *p = '\0'; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
498 |
12981
bee7b7b5b53e
(svn r17475) -Codechange: show path to crash.log and crash.dmp in crash window. Also tells the user where crash.sav is when saving succeeded.
glx <glx@openttd.org>
parents:
12959
diff
changeset
|
499 /* Add path to crash.log and crash.dmp (if any) to the crash window text */ |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
500 size_t len = _tcslen(_crash_desc) + 2; |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
501 len += _tcslen(OTTD2FS(CrashLogWindows::current->crashlog_filename)) + 2; |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
502 len += _tcslen(OTTD2FS(CrashLogWindows::current->crashdump_filename)) + 2; |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
503 len += _tcslen(OTTD2FS(CrashLogWindows::current->screenshot_filename)) + 1; |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
504 |
12981
bee7b7b5b53e
(svn r17475) -Codechange: show path to crash.log and crash.dmp in crash window. Also tells the user where crash.sav is when saving succeeded.
glx <glx@openttd.org>
parents:
12959
diff
changeset
|
505 TCHAR *text = AllocaM(TCHAR, len); |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
506 _sntprintf(text, len, _crash_desc, OTTD2FS(CrashLogWindows::current->crashlog_filename)); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
507 if (OTTD2FS(CrashLogWindows::current->crashdump_filename)[0] != _T('\0')) { |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
508 _tcscat(text, _T("\n")); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
509 _tcscat(text, OTTD2FS(CrashLogWindows::current->crashdump_filename)); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
510 } |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
511 if (OTTD2FS(CrashLogWindows::current->screenshot_filename)[0] != _T('\0')) { |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
512 _tcscat(text, _T("\n")); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
513 _tcscat(text, OTTD2FS(CrashLogWindows::current->screenshot_filename)); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
514 } |
12981
bee7b7b5b53e
(svn r17475) -Codechange: show path to crash.log and crash.dmp in crash window. Also tells the user where crash.sav is when saving succeeded.
glx <glx@openttd.org>
parents:
12959
diff
changeset
|
515 |
bee7b7b5b53e
(svn r17475) -Codechange: show path to crash.log and crash.dmp in crash window. Also tells the user where crash.sav is when saving succeeded.
glx <glx@openttd.org>
parents:
12959
diff
changeset
|
516 SetDlgItemText(wnd, 10, text); |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
517 SetDlgItemText(wnd, 11, MB_TO_WIDE_BUFFER(dos_nl, crash_msgW, lengthof(crash_msgW))); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
518 SendDlgItemMessage(wnd, 11, WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), FALSE); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
519 SetWndSize(wnd, -1); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
520 } return TRUE; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
521 case WM_COMMAND: |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
522 switch (wParam) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
523 case 12: // Close |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
524 CrashLog::AfterCrashLogCleanup(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
525 ExitProcess(2); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
526 case 13: // Emergency save |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
527 char filename[MAX_PATH]; |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
528 if (CrashLogWindows::current->WriteSavegame(filename, lastof(filename))) { |
12993
90133be1c216
(svn r17487) -Fix: silence some MSVC warnings
rubidium <rubidium@openttd.org>
parents:
12981
diff
changeset
|
529 size_t len = _tcslen(_save_succeeded) + _tcslen(OTTD2FS(filename)) + 1; |
12981
bee7b7b5b53e
(svn r17475) -Codechange: show path to crash.log and crash.dmp in crash window. Also tells the user where crash.sav is when saving succeeded.
glx <glx@openttd.org>
parents:
12959
diff
changeset
|
530 TCHAR *text = AllocaM(TCHAR, len); |
bee7b7b5b53e
(svn r17475) -Codechange: show path to crash.log and crash.dmp in crash window. Also tells the user where crash.sav is when saving succeeded.
glx <glx@openttd.org>
parents:
12959
diff
changeset
|
531 _sntprintf(text, len, _save_succeeded, OTTD2FS(filename)); |
bee7b7b5b53e
(svn r17475) -Codechange: show path to crash.log and crash.dmp in crash window. Also tells the user where crash.sav is when saving succeeded.
glx <glx@openttd.org>
parents:
12959
diff
changeset
|
532 MessageBox(wnd, text, _T("Save successful"), MB_ICONINFORMATION); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
533 } else { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
534 MessageBox(wnd, _T("Save failed"), _T("Save failed"), MB_ICONINFORMATION); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
535 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
536 break; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
537 case 15: // Expand window to show crash-message |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
538 _expanded ^= 1; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
539 SetWndSize(wnd, _expanded); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
540 break; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
541 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
542 return TRUE; |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
543 case WM_CLOSE: |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
544 CrashLog::AfterCrashLogCleanup(); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
545 ExitProcess(2); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
546 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
547 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
548 return FALSE; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
549 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
550 |
12957
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
551 static void ShowCrashlogWindow() |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
552 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
553 ShowCursor(TRUE); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
554 ShowWindow(GetActiveWindow(), FALSE); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
555 DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(100), NULL, CrashDialogFunc); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
556 } |