From 881740112d49c4216e79f763ee972fdb51a07635 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 29 Dec 2022 18:32:57 +0100 Subject: [PATCH] Use LoadLibraryW This makes it possible to load modules in path names having characters outside of the ANSI codepage --- babl/babl-extension.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/babl/babl-extension.c b/babl/babl-extension.c index d6d1a39..8f06fcd 100644 --- a/babl/babl-extension.c +++ b/babl/babl-extension.c @@ -33,7 +33,6 @@ #include "babl-base.h" #include -#include static Babl *babl_extension_current_extender = NULL; @@ -176,7 +175,22 @@ dlsym (HLIB handle, #include #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 () -- 2.30.2