From f7be0cf68eaebb3ef18c690fd6f3f961aa91855b Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Fri, 30 Dec 2022 13:32:10 +0100 Subject: [PATCH] Use LoadLibraryW () --- app/core/gimpbacktrace-windows.c | 2 +- modules/gimpinputdevicestore-dx.c | 2 +- plug-ins/screenshot/screenshot-win32-dwm-api.h | 2 +- .../screenshot-win32-magnification-api.h | 2 +- plug-ins/screenshot/screenshot-win32.c | 2 +- .../script-fu/libscriptfu/tinyscheme/dynload.c | 15 +++++++++++++-- plug-ins/twain/tw_platform.h | 1 + plug-ins/twain/tw_win.c | 2 +- 8 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/core/gimpbacktrace-windows.c b/app/core/gimpbacktrace-windows.c index da1fb734e9..239a6758a2 100644 --- a/app/core/gimpbacktrace-windows.c +++ b/app/core/gimpbacktrace-windows.c @@ -285,7 +285,7 @@ gimp_backtrace_start (void) HMODULE hModule; DWORD options; - hModule = LoadLibraryA ("mgwhelp.dll"); + hModule = LoadLibraryW (L"mgwhelp.dll"); #define INIT_PROC(name) \ G_STMT_START \ diff --git a/modules/gimpinputdevicestore-dx.c b/modules/gimpinputdevicestore-dx.c index 75b438f80b..6e389e44b4 100644 --- a/modules/gimpinputdevicestore-dx.c +++ b/modules/gimpinputdevicestore-dx.c @@ -216,7 +216,7 @@ gimp_input_device_store_init (GimpInputDeviceStore *store) return; } - if ((dinput8 = LoadLibrary ("dinput8.dll")) == NULL) + if ((dinput8 = LoadLibraryW (L"dinput8.dll")) == NULL) { g_set_error_literal (&store->error, GIMP_MODULE_ERROR, GIMP_MODULE_FAILED, "Could not load dinput8.dll"); diff --git a/plug-ins/screenshot/screenshot-win32-dwm-api.h b/plug-ins/screenshot/screenshot-win32-dwm-api.h index 5f5c0f91c0..542fc77f11 100644 --- a/plug-ins/screenshot/screenshot-win32-dwm-api.h +++ b/plug-ins/screenshot/screenshot-win32-dwm-api.h @@ -61,7 +61,7 @@ LoadRequiredDwmFunctions (void) { if (dwmApi) return TRUE; - dwmApi = LoadLibrary ("dwmapi"); + dwmApi = LoadLibraryW (L"dwmapi"); if (! dwmApi) return FALSE; DwmGetWindowAttribute = (DWMGETWINDOWATTRIBUTE) GetProcAddress (dwmApi, "DwmGetWindowAttribute"); diff --git a/plug-ins/screenshot/screenshot-win32-magnification-api.h b/plug-ins/screenshot/screenshot-win32-magnification-api.h index a204c80b21..f81967fbbd 100644 --- a/plug-ins/screenshot/screenshot-win32-magnification-api.h +++ b/plug-ins/screenshot/screenshot-win32-magnification-api.h @@ -112,7 +112,7 @@ BOOL LoadMagnificationLibrary(void) { if (magnificationLibrary) return TRUE; - magnificationLibrary = LoadLibrary("Magnification"); + magnificationLibrary = LoadLibraryW(L"Magnification"); if (!magnificationLibrary) return FALSE; MagInitialize = (MAGINITIALIZE)GetProcAddress(magnificationLibrary,"MagInitialize"); diff --git a/plug-ins/screenshot/screenshot-win32.c b/plug-ins/screenshot/screenshot-win32.c index a88394afef..2c531ec099 100644 --- a/plug-ins/screenshot/screenshot-win32.c +++ b/plug-ins/screenshot/screenshot-win32.c @@ -1207,7 +1207,7 @@ BOOL InitInstance (HINSTANCE hInstance, int nCmdShow) { - HINSTANCE User32Library = LoadLibrary ("user32.dll"); + HINSTANCE User32Library = LoadLibraryW (L"user32.dll"); if (User32Library) { diff --git a/plug-ins/script-fu/libscriptfu/tinyscheme/dynload.c b/plug-ins/script-fu/libscriptfu/tinyscheme/dynload.c index 6084a40547..2e056f2efc 100644 --- a/plug-ins/script-fu/libscriptfu/tinyscheme/dynload.c +++ b/plug-ins/script-fu/libscriptfu/tinyscheme/dynload.c @@ -9,6 +9,8 @@ #include #include +#include + #ifndef MAXPATHLEN # define MAXPATHLEN 1024 #endif @@ -44,8 +46,17 @@ typedef void (*FARPROC)(); } static HMODULE dl_attach(const char *module) { - HMODULE dll = LoadLibrary(module); - if (!dll) display_w32_error_msg(module); + wchar_t *module_utf16 = g_utf8_to_utf16 (module, -1, NULL, NULL, NULL); + HMODULE dll = NULL; + + if (!module_utf16) + return NULL; + + dll = LoadLibraryW (module_utf16); + if (!dll) + display_w32_error_msg (module); + + free (module_utf16); return dll; } diff --git a/plug-ins/twain/tw_platform.h b/plug-ins/twain/tw_platform.h index 4f8609a3d1..0e8839addb 100644 --- a/plug-ins/twain/tw_platform.h +++ b/plug-ins/twain/tw_platform.h @@ -25,6 +25,7 @@ #include "twain.h" /* The DLL to be loaded for TWAIN support */ +#define TWAIN_DLL_NAME_W L"TWAIN_32.DLL" #define TWAIN_DLL_NAME "TWAIN_32.DLL" #define DEBUG_LOGFILE "c:\\twain.log" #define DUMP_FILE "C:\\TWAINCAP.BIN" diff --git a/plug-ins/twain/tw_win.c b/plug-ins/twain/tw_win.c index 3c97af9583..84cc8437fa 100644 --- a/plug-ins/twain/tw_win.c +++ b/plug-ins/twain/tw_win.c @@ -92,7 +92,7 @@ twainIsAvailable(void) } /* Attempt to load the library */ - hDLL = LoadLibrary(TWAIN_DLL_NAME); + hDLL = LoadLibraryW (TWAIN_DLL_NAME_W); if (hDLL == NULL) return FALSE;