2008-03-14 Robert Jordan <robertj@gmx.net>
authorRobert Jordan <robertj@gmx.net>
Fri, 14 Mar 2008 10:25:10 +0000 (10:25 -0000)
committerRobert Jordan <robertj@gmx.net>
Fri, 14 Mar 2008 10:25:10 +0000 (10:25 -0000)
* 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
mono/utils/mono-dl.c

index 5c39e02fcbfb8b96b4b530299e8047fb69ed4d11..95fc24d3862279a2b1cd426260f73e5e120e0245 100644 (file)
@@ -1,3 +1,11 @@
+
+2008-03-14  Robert Jordan  <robertj@gmx.net>
+
+       * 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  <nakayama@pixela.co.jp>
  
        * mono-membar.h: Memory barrier for mips.
index 1986112a5d02dd4198b6673384d0d9de4f1a3032..4aaf65d47873e3e7470a96bad35624a8b7965e92 100644 (file)
@@ -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;