Mercurial > hg > openttd
annotate src/os/windows/crashlog_win.cpp @ 14279:22e76a982410 draft
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 16 Jan 2010 19:08:33 +0000 |
parents | 3777c5a4b5eb |
children | 979a0a9ae875 |
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" |
14279
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
21 #include "../../saveload/saveload.h" |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
22 |
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
|
23 #include <windows.h> |
13915
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
24 #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
|
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 /** |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 * 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
|
28 */ |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 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
|
30 /** 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
|
31 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
|
32 |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 *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
|
34 /* 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
|
35 /* 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
|
36 /* 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
|
37 /* 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
|
38 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
|
39 #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
|
40 /* 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
|
41 #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
|
42 |
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
|
43 /** 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
|
44 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
|
45 /** 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
|
46 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
|
47 /** 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
|
48 char crashdump_filename[MAX_PATH]; |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
49 /** 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
|
50 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
|
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 /** |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 * 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
|
54 * @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
|
55 */ |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 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
|
57 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
|
58 { |
ae69ac470a83
(svn r17450) -Codechange: refactor 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[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->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
|
61 this->crashdump_filename[0] = '\0'; |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
62 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
|
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 /** |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 * 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
|
67 */ |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 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
|
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 |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 /* 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
|
72 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
73 /* 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
|
74 { |
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
|
75 _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
|
76 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
|
77 GetVersionExA(&os); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
78 |
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
|
79 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
|
80 "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
|
81 " 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
|
82 " 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
|
83 " 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
|
84 (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
|
85 (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
|
86 (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
|
87 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
|
88 #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
|
89 "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
|
90 #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
|
91 "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
|
92 #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
|
93 ); |
12917
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 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
96 |
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
|
97 /* 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
|
98 { |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 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
|
100 "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
|
101 " 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
|
102 #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
|
103 " 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
|
104 #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
|
105 " 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
|
106 #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
|
107 " 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
|
108 (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
|
109 (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
|
110 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
|
111 ); |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
112 } |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
113 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
114 struct DebugFileInfo { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
115 uint32 size; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
116 uint32 crc32; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
117 SYSTEMTIME file_time; |
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 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
120 static uint32 *_crc_table; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
121 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
122 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
|
123 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
124 uint32 crc, poly = 0xEDB88320L; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
125 int i; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
126 int j; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
127 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
128 _crc_table = table; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
129 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
130 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
|
131 crc = i; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 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
|
133 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
|
134 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 table[i] = crc; |
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 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 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
|
140 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
141 for (; size > 0; size--) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
142 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
|
143 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
144 return crc; |
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 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
147 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
|
148 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
149 HANDLE file; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
150 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
|
151 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
152 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
|
153 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
|
154 byte buffer[1024]; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
155 DWORD numread; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
156 uint32 filesize = 0; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
157 FILETIME write_time; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 uint32 crc = (uint32)-1; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
160 for (;;) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
161 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
|
162 break; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
163 filesize += numread; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 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
|
165 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
166 dfi->size = filesize; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
167 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
|
168 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
169 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
|
170 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
|
171 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
172 CloseHandle(file); |
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 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
177 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
|
178 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
179 TCHAR buffer[MAX_PATH]; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
180 DebugFileInfo dfi; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
181 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
182 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
|
183 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
|
184 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
|
185 WIDE_TO_MB(buffer), |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
186 mod, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
187 dfi.size, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
188 dfi.crc32, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
189 dfi.file_time.wYear, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
190 dfi.file_time.wMonth, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
191 dfi.file_time.wDay, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
192 dfi.file_time.wHour, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
193 dfi.file_time.wMinute, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
194 dfi.file_time.wSecond |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
195 ); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
196 return output; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
197 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
198 |
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
|
199 /* 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
|
200 { |
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
|
201 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
|
202 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
|
203 |
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
|
204 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
|
205 |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
206 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
|
207 HMODULE modules[100]; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
208 DWORD needed; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
209 BOOL res; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
210 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
211 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
|
212 if (proc != NULL) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
213 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
|
214 CloseHandle(proc); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
215 if (res) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
216 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
|
217 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
218 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
|
219 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
|
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 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
223 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
|
224 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
|
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 |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 /* 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
|
228 { |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 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
|
230 #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
|
231 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
|
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 |
14279
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
382 if (SaveloadCrashWithMissingNewGRFs()) { |
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
383 static const TCHAR _saveload_crash[] = |
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
384 _T("A serious fault condition occured in the game. The game will shut down.\n") |
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
385 _T("As you loaded an savegame for which you do not have the required NewGRFs\n") |
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
386 _T("no crash information will be generated.\n"); |
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
387 MessageBox(NULL, _saveload_crash, _T("Fatal Application Failure"), MB_ICONERROR); |
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
388 ExitProcess(3); |
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
389 } |
22e76a982410
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents:
14080
diff
changeset
|
390 |
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
|
391 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
|
392 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 /* 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
|
399 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
|
400 |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 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
|
402 #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
|
403 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
|
404 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
|
405 #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
|
406 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
|
407 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
|
408 #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
|
409 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
|
410 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
411 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
412 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
|
413 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
|
414 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
415 |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 #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
|
417 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
|
418 #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
|
419 |
13915
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
420 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
|
421 { |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
422 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
|
423 } |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
424 |
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
|
425 /* 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
|
426 { |
ae69ac470a83
(svn r17450) -Codechange: refactor 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 #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
|
428 #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
|
429 _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
|
430 #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
|
431 _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
|
432 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
|
433 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
434 #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
|
435 #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
|
436 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
|
437 #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
|
438 |
13915
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
439 /* 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
|
440 signal(SIGABRT, CustomAbort); |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
441 #if defined(_MSC_VER) |
5a588b3068cf
(svn r18446) -Fix (r17450): abort() doesn't trigger crashlog on windows
glx <glx@openttd.org>
parents:
13660
diff
changeset
|
442 /* 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
|
443 _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
|
444 #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
|
445 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
|
446 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
447 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
448 /* 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
|
449 |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
450 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
|
451 |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
452 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
|
453 _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
|
454 _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
|
455 _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
|
456 _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
|
457 _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
|
458 _T("%s"); |
12917
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 static const TCHAR _save_succeeded[] = |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
461 _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
|
462 _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
|
463 _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
|
464 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
465 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
|
466 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
467 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
|
468 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
469 RECT r, r2; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
470 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
471 GetWindowRect(wnd, &r); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
472 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
|
473 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
474 if (mode >= 0) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
475 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
|
476 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
|
477 if (!mode) offs = -offs; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
478 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
|
479 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
|
480 } else { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
481 SetWindowPos(wnd, HWND_TOPMOST, |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
482 (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
|
483 (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
|
484 0, 0, SWP_NOSIZE); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
485 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
486 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
487 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
488 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
|
489 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
490 switch (msg) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
491 case WM_INITDIALOG: { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
492 #if defined(UNICODE) |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
493 /* 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
|
494 * 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
|
495 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
|
496 #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
|
497 /* 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 } |
ae69ac470a83
(svn r17450) -Codechange: refactor the windows crash logger so parts of it can be reused by other crash logger implementations
rubidium <rubidium@openttd.org>
parents:
12924
diff
changeset
|
506 *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
|
507 |
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
|
508 /* 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
|
509 size_t len = _tcslen(_crash_desc) + 2; |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
510 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
|
511 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
|
512 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
|
513 |
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
|
514 TCHAR *text = AllocaM(TCHAR, len); |
13660
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
515 _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
|
516 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
|
517 _tcscat(text, _T("\n")); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
518 _tcscat(text, OTTD2FS(CrashLogWindows::current->crashdump_filename)); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
519 } |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
520 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
|
521 _tcscat(text, _T("\n")); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
522 _tcscat(text, OTTD2FS(CrashLogWindows::current->screenshot_filename)); |
b9302d9e1874
(svn r18184) -Codechange: add crash screenshot for win32
glx <glx@openttd.org>
parents:
12993
diff
changeset
|
523 } |
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
|
524 |
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
|
525 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
|
526 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
|
527 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
|
528 SetWndSize(wnd, -1); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
529 } return TRUE; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
530 case WM_COMMAND: |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
531 switch (wParam) { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
532 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
|
533 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
|
534 ExitProcess(2); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
535 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
|
536 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
|
537 if (CrashLogWindows::current->WriteSavegame(filename, lastof(filename))) { |
12993
90133be1c216
(svn r17487) -Fix: silence some MSVC warnings
rubidium <rubidium@openttd.org>
parents:
12981
diff
changeset
|
538 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
|
539 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
|
540 _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
|
541 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
|
542 } else { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
543 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
|
544 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
545 break; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
546 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
|
547 _expanded ^= 1; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
548 SetWndSize(wnd, _expanded); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
549 break; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
550 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
551 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
|
552 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
|
553 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
|
554 ExitProcess(2); |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
555 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
556 |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
557 return FALSE; |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
558 } |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
559 |
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
|
560 static void ShowCrashlogWindow() |
12917
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
561 { |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
562 ShowCursor(TRUE); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
563 ShowWindow(GetActiveWindow(), FALSE); |
d223546bf49d
(svn r17409) -Codechange: split the crash log and other windows 'glue' code
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
564 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
|
565 } |