Use LoadLibraryW
authorLuca Bacci <luca.bacci982@gmail.com>
Thu, 29 Dec 2022 17:32:57 +0000 (18:32 +0100)
committerØyvind "pippin" Kolås <pippin@gimp.org>
Tue, 3 Jan 2023 10:33:37 +0000 (10:33 +0000)
This makes it possible to load modules in path names having characters
outside of the ANSI codepage

babl/babl-extension.c

index d6d1a39ee3bf06d2290e905fefbc7b775b388f17..8f06fcdab247b4c18a2ecb75943576f62fb5c95b 100644 (file)
@@ -33,7 +33,6 @@
 #include "babl-base.h"
 
 #include <string.h>
-#include <stdarg.h>
 
 
 static Babl *babl_extension_current_extender = NULL;
@@ -176,7 +175,22 @@ dlsym (HLIB        handle,
 #include <windows.h>
 #define HLIB    HINSTANCE
 
-#define dlopen(a, b)    LoadLibrary (a)
+static HLIB
+LoadLibraryWrap (const char *filename)
+{
+  wchar_t *filename_utf16 = babl_convert_utf8_to_utf16 (filename);
+  HLIB module = NULL;
+
+  if (!filename_utf16)
+    return NULL;
+
+  module = LoadLibraryW (filename_utf16);
+
+  babl_free (filename_utf16);
+  return module;
+}
+
+#define dlopen(a, b)    LoadLibraryWrap (a)
 #define dlsym(l, s)     GetProcAddress (l, s)
 #define dlclose(l)      FreeLibrary (l)
 #define dlerror()       GetLastError ()