equal
deleted
inserted
replaced
3 /** @file win32.cpp Implementation of MS Windows system calls */ |
3 /** @file win32.cpp Implementation of MS Windows system calls */ |
4 |
4 |
5 #include "stdafx.h" |
5 #include "stdafx.h" |
6 #include "openttd.h" |
6 #include "openttd.h" |
7 #include "debug.h" |
7 #include "debug.h" |
8 #include "functions.h" |
|
9 #include "macros.h" |
|
10 #include "helpers.hpp" |
|
11 #include "saveload.h" |
8 #include "saveload.h" |
12 #include "string.h" |
9 #include "gfx_func.h" |
13 #include "gfx.h" |
10 #include "textbuf_gui.h" |
14 #include "window.h" |
|
15 #include "fileio.h" |
11 #include "fileio.h" |
16 #include <windows.h> |
12 #include <windows.h> |
17 #include <winnt.h> |
13 #include <winnt.h> |
18 #include <wininet.h> |
14 #include <wininet.h> |
19 #include <io.h> |
15 #include <io.h> |
21 #include <shlobj.h> // SHGetFolderPath |
17 #include <shlobj.h> // SHGetFolderPath |
22 #include "variables.h" |
18 #include "variables.h" |
23 #include "win32.h" |
19 #include "win32.h" |
24 #include "fios.h" // opendir/readdir/closedir |
20 #include "fios.h" // opendir/readdir/closedir |
25 #include "fileio.h" |
21 #include "fileio.h" |
|
22 #include "core/alloc_func.hpp" |
|
23 #include "functions.h" |
|
24 #include "core/random_func.hpp" |
|
25 #include "core/bitmath_func.hpp" |
|
26 #include "string_func.h" |
26 #include <ctype.h> |
27 #include <ctype.h> |
27 #include <tchar.h> |
28 #include <tchar.h> |
28 #include <errno.h> |
29 #include <errno.h> |
29 #include <sys/types.h> |
30 #include <sys/types.h> |
30 #include <sys/stat.h> |
31 #include <sys/stat.h> |
31 #include <shlobj.h> |
|
32 #if defined(_MSC_VER) && !defined(WINCE) |
32 #if defined(_MSC_VER) && !defined(WINCE) |
33 #include <dbghelp.h> |
33 #include <dbghelp.h> |
34 #endif |
34 #endif |
35 |
35 |
36 static bool _has_console; |
36 static bool _has_console; |
79 return true; |
79 return true; |
80 } |
80 } |
81 |
81 |
82 #ifdef _MSC_VER |
82 #ifdef _MSC_VER |
83 static const char *_exception_string = NULL; |
83 static const char *_exception_string = NULL; |
|
84 void SetExceptionString(const char *s, ...) |
|
85 { |
|
86 va_list va; |
|
87 char buf[512]; |
|
88 |
|
89 va_start(va, s); |
|
90 vsnprintf(buf, lengthof(buf), s, va); |
|
91 va_end(va); |
|
92 |
|
93 _exception_string = strdup(buf); |
|
94 } |
84 #endif |
95 #endif |
85 |
96 |
86 void ShowOSErrorBox(const char *buf) |
97 void ShowOSErrorBox(const char *buf) |
87 { |
98 { |
88 MyShowCursor(true); |
99 MyShowCursor(true); |
320 if (h == NULL) return; |
331 if (h == NULL) return; |
321 |
332 |
322 size = GetFileSize(h, NULL); |
333 size = GetFileSize(h, NULL); |
323 if (size > 500000) goto error1; |
334 if (size > 500000) goto error1; |
324 |
335 |
325 mem = malloc(size); |
336 mem = MallocT<byte>(size); |
326 if (mem == NULL) goto error1; |
337 if (mem == NULL) goto error1; |
327 |
338 |
328 if (!ReadFile(h, mem, size, &read, NULL) || read != size) goto error2; |
339 if (!ReadFile(h, mem, size, &read, NULL) || read != size) goto error2; |
329 |
340 |
330 SubmitCrashReport(wnd, mem, size, file); |
341 SubmitCrashReport(wnd, mem, size, file); |