From 58b408724d7df0e23386780482b350c1b01d6d50 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Fri, 14 Mar 2008 10:25:10 +0000 Subject: [PATCH] 2008-03-14 Robert Jordan * mono-dl.c (w32_load_module): prevent error dialog by resetting the Win32 error mode during LoadLibrary (). Fixes #360363. * mono-dl.c (w32_dlerror): kill a warning. svn path=/trunk/mono/; revision=98258 --- mono/utils/ChangeLog | 8 ++++++++ mono/utils/mono-dl.c | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/mono/utils/ChangeLog b/mono/utils/ChangeLog index 5c39e02fcbf..95fc24d3862 100644 --- a/mono/utils/ChangeLog +++ b/mono/utils/ChangeLog @@ -1,3 +1,11 @@ + +2008-03-14 Robert Jordan + + * mono-dl.c (w32_load_module): prevent error dialog by resetting + the Win32 error mode during LoadLibrary (). Fixes #360363. + + * mono-dl.c (w32_dlerror): kill a warning. + 2007-MM-DD Yoichi NAKAYAMA * mono-membar.h: Memory barrier for mips. diff --git a/mono/utils/mono-dl.c b/mono/utils/mono-dl.c index 1986112a5d0..4aaf65d4787 100644 --- a/mono/utils/mono-dl.c +++ b/mono/utils/mono-dl.c @@ -91,7 +91,7 @@ w32_dlerror (void) DWORD code = GetLastError (); if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, - code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &buf, 0, NULL)) + code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, 0, NULL)) { ret = g_utf16_to_utf8 (buf, wcslen(buf), NULL, NULL, NULL); LocalFree (buf); @@ -163,14 +163,21 @@ static gpointer w32_load_module (const char* file, int flags) { gpointer hModule = NULL; - if (file) - { + if (file) { gunichar2* file_utf16 = g_utf8_to_utf16 (file, strlen (file), NULL, NULL, NULL); + guint last_sem = SetErrorMode (SEM_FAILCRITICALERRORS); + guint32 last_error = 0; + hModule = LoadLibrary (file_utf16); + if (!hModule) + last_error = GetLastError (); + + SetErrorMode (last_sem); g_free (file_utf16); - } - else - { + + if (!hModule) + SetLastError (last_error); + } else { hModule = GetModuleHandle (NULL); } return hModule; -- 2.25.1