summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorMarcelo Fernandez <marcelofg55@gmail.com>2017-09-18 16:29:23 -0300
committerMarcelo Fernandez <marcelofg55@gmail.com>2017-09-18 16:29:23 -0300
commitff1e0a3e2cb6619644215432604293eb7ba53699 (patch)
tree19d15b364137f8bd31cd74bf02318916502d2a68 /platform/windows
parent3d06957f12ba5c04702f3db980af9c07142e7886 (diff)
Prevent running the crash_handler when a debugger is present on windows
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/crash_handler_win.cpp4
-rw-r--r--platform/windows/godot_win.cpp38
2 files changed, 23 insertions, 19 deletions
diff --git a/platform/windows/crash_handler_win.cpp b/platform/windows/crash_handler_win.cpp
index c9385f36d6..2f5ee7956e 100644
--- a/platform/windows/crash_handler_win.cpp
+++ b/platform/windows/crash_handler_win.cpp
@@ -116,7 +116,7 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
DWORD cbNeeded;
std::vector<HMODULE> module_handles(1);
- if (OS::get_singleton() == NULL || OS::get_singleton()->is_disable_crash_handler()) {
+ if (OS::get_singleton() == NULL || OS::get_singleton()->is_disable_crash_handler() || IsDebuggerPresent()) {
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -159,7 +159,7 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
IMAGE_NT_HEADERS *h = ImageNtHeader(base);
DWORD image_type = h->FileHeader.Machine;
int n = 0;
- String msg = GLOBAL_GET("debug/settings/backtrace/message");
+ String msg = GLOBAL_GET("debug/settings/crash_handler/message");
fprintf(stderr, "Dumping the backtrace. %ls\n", msg.c_str());
diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp
index 4450cb3670..cff2cbad42 100644
--- a/platform/windows/godot_win.cpp
+++ b/platform/windows/godot_win.cpp
@@ -156,32 +156,36 @@ int widechar_main(int argc, wchar_t **argv) {
return os.get_exit_code();
};
-int main(int _argc, char **_argv) {
-// _argc and _argv are ignored
-// we are going to use the WideChar version of them instead
+int _main() {
+ LPWSTR *wc_argv;
+ int argc;
+ int result;
-#ifdef CRASH_HANDLER_EXCEPTION
- __try {
-#endif
- LPWSTR *wc_argv;
- int argc;
- int result;
+ wc_argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+
+ if (NULL == wc_argv) {
+ wprintf(L"CommandLineToArgvW failed\n");
+ return 0;
+ }
- wc_argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+ result = widechar_main(argc, wc_argv);
- if (NULL == wc_argv) {
- wprintf(L"CommandLineToArgvW failed\n");
- return 0;
- }
+ LocalFree(wc_argv);
+ return result;
+}
- result = widechar_main(argc, wc_argv);
+int main(int _argc, char **_argv) {
+// _argc and _argv are ignored
+// we are going to use the WideChar version of them instead
- LocalFree(wc_argv);
- return result;
#ifdef CRASH_HANDLER_EXCEPTION
+ __try {
+ return _main();
} __except (CrashHandlerException(GetExceptionInformation())) {
return 1;
}
+#else
+ return _main();
#endif
}