Commit 01a2f276791b65005b732fd0ae64cf7a34a1cecb

Ozkan Sezer 2021-01-04T01:23:50

consistently use TEXT() macro with LoadLibrary() and GetModuleHandle() cf. bug #5435.

diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c
index 2fe6da5..eb31989 100644
--- a/src/audio/wasapi/SDL_wasapi_win32.c
+++ b/src/audio/wasapi/SDL_wasapi_win32.c
@@ -251,7 +251,7 @@ WASAPI_PlatformInit(void)
         return WIN_SetErrorFromHRESULT("WASAPI CoCreateInstance(MMDeviceEnumerator)", ret);
     }
 
-    libavrt = LoadLibraryW(L"avrt.dll");  /* this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! */
+    libavrt = LoadLibrary(TEXT("avrt.dll"));  /* this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! */
     if (libavrt) {
         pAvSetMmThreadCharacteristicsW = (pfnAvSetMmThreadCharacteristicsW) GetProcAddress(libavrt, "AvSetMmThreadCharacteristicsW");
         pAvRevertMmThreadCharacteristics = (pfnAvRevertMmThreadCharacteristics) GetProcAddress(libavrt, "AvRevertMmThreadCharacteristics");
diff --git a/src/core/windows/SDL_hid.c b/src/core/windows/SDL_hid.c
index 43cb8e7..07eddd1 100644
--- a/src/core/windows/SDL_hid.c
+++ b/src/core/windows/SDL_hid.c
@@ -48,7 +48,7 @@ WIN_LoadHIDDLL(void)
         return 0;  /* already loaded */
     }
 
-    s_pHIDDLL = LoadLibrary(L"hid.dll");
+    s_pHIDDLL = LoadLibrary(TEXT("hid.dll"));
     if (!s_pHIDDLL) {
         return -1;
     }
diff --git a/src/core/windows/SDL_xinput.c b/src/core/windows/SDL_xinput.c
index 6a70822..edc8738 100644
--- a/src/core/windows/SDL_xinput.c
+++ b/src/core/windows/SDL_xinput.c
@@ -86,17 +86,17 @@ WIN_LoadXInputDLL(void)
      * limitations of that API (no devices at startup, no background input, etc.)
      */
     version = (1 << 16) | 4;
-    s_pXInputDLL = LoadLibrary(L"XInput1_4.dll");  /* 1.4 Ships with Windows 8. */
+    s_pXInputDLL = LoadLibrary(TEXT("XInput1_4.dll"));  /* 1.4 Ships with Windows 8. */
     if (!s_pXInputDLL) {
         version = (1 << 16) | 3;
-        s_pXInputDLL = LoadLibrary(L"XInput1_3.dll");  /* 1.3 can be installed as a redistributable component. */
+        s_pXInputDLL = LoadLibrary(TEXT("XInput1_3.dll"));  /* 1.3 can be installed as a redistributable component. */
     }
     if (!s_pXInputDLL) {
-        s_pXInputDLL = LoadLibrary(L"bin\\XInput1_3.dll");
+        s_pXInputDLL = LoadLibrary(TEXT("bin\\XInput1_3.dll"));
     }
     if (!s_pXInputDLL) {
         /* "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.)  */
-        s_pXInputDLL = LoadLibrary(L"XInput9_1_0.dll");
+        s_pXInputDLL = LoadLibrary(TEXT("XInput9_1_0.dll"));
     }
     if (!s_pXInputDLL) {
         return -1;
diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c
index af315d4..d57a6df 100644
--- a/src/filesystem/windows/SDL_sysfilesystem.c
+++ b/src/filesystem/windows/SDL_sysfilesystem.c
@@ -39,7 +39,7 @@ SDL_GetBasePath(void)
     GetModuleFileNameExW_t pGetModuleFileNameExW;
     DWORD buflen = 128;
     WCHAR *path = NULL;
-    HANDLE psapi = LoadLibrary(L"psapi.dll");
+    HANDLE psapi = LoadLibrary(TEXT("psapi.dll"));
     char *retval = NULL;
     DWORD len = 0;
     int i;
diff --git a/src/hidapi/windows/hid.c b/src/hidapi/windows/hid.c
index 4b0f7cb..3f39133 100644
--- a/src/hidapi/windows/hid.c
+++ b/src/hidapi/windows/hid.c
@@ -242,7 +242,7 @@ static void register_error(hid_device *device, const char *op)
 #ifndef HIDAPI_USE_DDK
 static int lookup_functions()
 {
-	lib_handle = LoadLibraryA("hid.dll");
+	lib_handle = LoadLibrary(TEXT("hid.dll"));
 	if (lib_handle) {
 #define RESOLVE(x) x = (x##_)GetProcAddress(lib_handle, #x); if (!x) return -1;
 		RESOLVE(HidD_GetAttributes);
diff --git a/src/locale/windows/SDL_syslocale.c b/src/locale/windows/SDL_syslocale.c
index 5bb1039..736adbb 100644
--- a/src/locale/windows/SDL_syslocale.c
+++ b/src/locale/windows/SDL_syslocale.c
@@ -100,7 +100,7 @@ void
 SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
 {
     if (!kernel32) {
-        kernel32 = GetModuleHandleW(L"kernel32.dll");
+        kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
         if (kernel32) {
             pGetUserPreferredUILanguages = (pfnGetUserPreferredUILanguages) GetProcAddress(kernel32, "GetUserPreferredUILanguages");
         }
diff --git a/src/thread/windows/SDL_syscond_srw.c b/src/thread/windows/SDL_syscond_srw.c
index 4ea0dfc..139bacc 100644
--- a/src/thread/windows/SDL_syscond_srw.c
+++ b/src/thread/windows/SDL_syscond_srw.c
@@ -215,7 +215,7 @@ SDL_CreateCond(void)
             /* Link statically on this platform */
             impl = &SDL_cond_impl_srw;
 #else
-            HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
+            HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
             if (kernel32) {
                 pWakeConditionVariable = (pfnWakeConditionVariable) GetProcAddress(kernel32, "WakeConditionVariable");
                 pWakeAllConditionVariable = (pfnWakeAllConditionVariable) GetProcAddress(kernel32, "WakeAllConditionVariable");
diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c
index 04d2749..bac5ea5 100644
--- a/src/thread/windows/SDL_sysmutex.c
+++ b/src/thread/windows/SDL_sysmutex.c
@@ -275,7 +275,7 @@ SDL_CreateMutex(void)
             impl = &SDL_mutex_impl_srw;
 #else
             /* Try faster implementation for Windows 7 and newer */
-            HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
+            HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
             if (kernel32) {
                 /* Requires Vista: */
                 pReleaseSRWLockExclusive = (pfnReleaseSRWLockExclusive) GetProcAddress(kernel32, "ReleaseSRWLockExclusive");
diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c
index b17dfe6..3306783 100644
--- a/src/thread/windows/SDL_syssem.c
+++ b/src/thread/windows/SDL_syssem.c
@@ -415,7 +415,7 @@ SDL_CreateSemaphore(Uint32 initial_value)
              * Microsoft our specific use case is legal and correct:
              * https://github.com/microsoft/STL/pull/593#issuecomment-655799859
              */
-            HMODULE synch120 = GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll");
+            HMODULE synch120 = GetModuleHandle(TEXT("api-ms-win-core-synch-l1-2-0.dll"));
             if (synch120) {
                 /* Try to load required functions provided by Win 8 or newer */
                 pWaitOnAddress = (pfnWaitOnAddress) GetProcAddress(synch120, "WaitOnAddress");
diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c
index 53eff89..ea6b489 100644
--- a/src/thread/windows/SDL_systhread.c
+++ b/src/thread/windows/SDL_systhread.c
@@ -163,7 +163,7 @@ SDL_SYS_SetupThread(const char *name)
         static HMODULE kernel32 = 0;
 
         if (!kernel32) {
-            kernel32 = GetModuleHandleW(L"kernel32.dll");
+            kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
             if (kernel32) {
                 pSetThreadDescription = (pfnSetThreadDescription) GetProcAddress(kernel32, "SetThreadDescription");
             }
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index a71c89b..2557d86 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1250,7 +1250,7 @@ struct SDL_WIN_OSVERSIONINFOW {
 static SDL_bool
 IsWin10FCUorNewer(void)
 {
-    HMODULE handle = GetModuleHandleW(L"ntdll.dll");
+    HMODULE handle = GetModuleHandle(TEXT("ntdll.dll"));
     if (handle) {
         typedef LONG(WINAPI* RtlGetVersionPtr)(struct SDL_WIN_OSVERSIONINFOW*);
         RtlGetVersionPtr getVersionPtr = (RtlGetVersionPtr)GetProcAddress(handle, "RtlGetVersion");
diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c
index 3618a6c..78b81fd 100644
--- a/src/video/windows/SDL_windowsmessagebox.c
+++ b/src/video/windows/SDL_windowsmessagebox.c
@@ -798,7 +798,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
     }
 
     /* If we cannot load comctl32.dll use the old messagebox! */
-    hComctl32 = LoadLibrary(TEXT("Comctl32.dll"));
+    hComctl32 = LoadLibrary(TEXT("comctl32.dll"));
     if (hComctl32 == NULL) {
         return WIN_ShowOldMessageBox(messageboxdata, buttonid);
     }