Browse Source

Fixed uncaught error printing

pull/44/head
Anairkoen Schno 4 years ago
parent
commit
e538ecf3d7
2 changed files with 12 additions and 8 deletions
  1. +10
    -8
      Doorstop/Proxy/main.c
  2. +2
    -0
      Doorstop/Proxy/mono.h

+ 10
- 8
Doorstop/Proxy/main.c View File

@ -62,13 +62,14 @@ void unhandledException(void* exc, void* data)
DEBUG_BREAK; DEBUG_BREAK;
LOG("An error occurred stringifying uncaught error: %s\n", str); LOG("An error occurred stringifying uncaught error: %s\n", str);
size_t len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
/*size_t len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
wchar_t* wstr = memalloc(sizeof(wchar_t) * len); wchar_t* wstr = memalloc(sizeof(wchar_t) * len);
MultiByteToWideChar(CP_UTF8, 0, str, -1, wstr, len);
MultiByteToWideChar(CP_UTF8, 0, str, -1, wstr, len);*/
wchar_t* wstr = mono_string_to_utf16(monostr);
ASSERT_F(FALSE, L"Uncaught exception; stringify failed: %s", wstr);
ASSERT_F(FALSE, L"Uncaught exception; stringify failed: %wS", wstr);
memfree(wstr);
mono_free(wstr);
mono_free(str); mono_free(str);
} }
#else #else
@ -80,17 +81,18 @@ void unhandledException(void* exc, void* data)
DEBUG_BREAK; DEBUG_BREAK;
LOG("Uncaught exception: %s\n", str); LOG("Uncaught exception: %s\n", str);
size_t len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
/*size_t len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
wchar_t* wstr = memalloc(sizeof(wchar_t) * len); wchar_t* wstr = memalloc(sizeof(wchar_t) * len);
MultiByteToWideChar(CP_UTF8, 0, str, -1, wstr, len);
MultiByteToWideChar(CP_UTF8, 0, str, -1, wstr, len);*/
wchar_t* wstr = mono_string_to_utf16(mstr);
#ifdef _VERBOSE #ifdef _VERBOSE
ASSERT(FALSE, L"Uncaught exception; see doorstop.log for details"); ASSERT(FALSE, L"Uncaught exception; see doorstop.log for details");
#else #else
ASSERT_F(FALSE, L"Uncaught exception: %s", wstr);
ASSERT_F(FALSE, L"Uncaught exception: %wS", wstr);
#endif #endif
memfree(wstr);
mono_free(wstr);
mono_free(str); mono_free(str);
ReleaseMutex(unhandledMutex); ReleaseMutex(unhandledMutex);


+ 2
- 0
Doorstop/Proxy/mono.h View File

@ -64,6 +64,7 @@ void* (*mono_object_to_string)(void* obj, void** exc);
void (*mono_dllmap_insert)(void* assemblyImage, const char* dll, const char* func, const char* tdll, const char* tfunc); void (*mono_dllmap_insert)(void* assemblyImage, const char* dll, const char* func, const char* tdll, const char* tfunc);
char* (*mono_string_to_utf8)(void* str); char* (*mono_string_to_utf8)(void* str);
wchar_t* (*mono_string_to_utf16)(void* str);
void (*mono_free)(void*); void (*mono_free)(void*);
/* Installs a function which is called when the runtime encounters an unhandled exception. /* Installs a function which is called when the runtime encounters an unhandled exception.
@ -102,6 +103,7 @@ inline void loadMonoFunctions(HMODULE monoLib)
GET_MONO_PROC(mono_array_addr_with_size); GET_MONO_PROC(mono_array_addr_with_size);
GET_MONO_PROC(mono_object_to_string); GET_MONO_PROC(mono_object_to_string);
GET_MONO_PROC(mono_string_to_utf8); GET_MONO_PROC(mono_string_to_utf8);
GET_MONO_PROC(mono_string_to_utf16);
GET_MONO_PROC(mono_free); GET_MONO_PROC(mono_free);
GET_MONO_PROC(mono_dllmap_insert); GET_MONO_PROC(mono_dllmap_insert);
GET_MONO_PROC(mono_install_unhandled_exception_hook); GET_MONO_PROC(mono_install_unhandled_exception_hook);


Loading…
Cancel
Save