SDL: simplify SDL_GetBasePath on windows

From de711e1685277f71ae81cfc1f835b2c7b8ac3056 Mon Sep 17 00:00:00 2001
From: pionere <[EMAIL REDACTED]>
Date: Tue, 12 Apr 2022 10:32:43 +0200
Subject: [PATCH] simplify SDL_GetBasePath on windows - use GetModuleFileName
 directly (as recommended)

---
 src/filesystem/windows/SDL_sysfilesystem.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c
index d50fb511bc0..d2f618509eb 100644
--- a/src/filesystem/windows/SDL_sysfilesystem.c
+++ b/src/filesystem/windows/SDL_sysfilesystem.c
@@ -35,39 +35,23 @@
 char *
 SDL_GetBasePath(void)
 {
-    typedef DWORD (WINAPI *GetModuleFileNameExW_t)(HANDLE, HMODULE, LPWSTR, DWORD);
-    GetModuleFileNameExW_t pGetModuleFileNameExW;
     DWORD buflen = 128;
     WCHAR *path = NULL;
-    HANDLE psapi = LoadLibrary(TEXT("psapi.dll"));
     char *retval = NULL;
     DWORD len = 0;
     int i;
 
-    if (!psapi) {
-        WIN_SetError("Couldn't load psapi.dll");
-        return NULL;
-    }
-
-    pGetModuleFileNameExW = (GetModuleFileNameExW_t)GetProcAddress(psapi, "GetModuleFileNameExW");
-    if (!pGetModuleFileNameExW) {
-        WIN_SetError("Couldn't find GetModuleFileNameExW");
-        FreeLibrary(psapi);
-        return NULL;
-    }
-
     while (SDL_TRUE) {
         void *ptr = SDL_realloc(path, buflen * sizeof (WCHAR));
         if (!ptr) {
             SDL_free(path);
-            FreeLibrary(psapi);
             SDL_OutOfMemory();
             return NULL;
         }
 
         path = (WCHAR *) ptr;
 
-        len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
+        len = GetModuleFileName(NULL, path, buflen);
         /* if it truncated, then len >= buflen - 1 */
         /* if there was enough room (or failure), len < buflen - 1 */
         if (len < buflen - 1) {
@@ -78,8 +62,6 @@ SDL_GetBasePath(void)
         buflen *= 2;
     }
 
-    FreeLibrary(psapi);
-
     if (len == 0) {
         SDL_free(path);
         WIN_SetError("Couldn't locate our .exe");