Skip to content

Commit

Permalink
Fixed compiling and tested on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed May 28, 2015
1 parent 6d1ad38 commit bccc2ad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/filesystem/windows/SDL_sysfilesystem.c
Expand Up @@ -36,34 +36,36 @@
char *
SDL_GetBasePath(void)
{
DWORD (WINAPI * pGetModuleFileNameExW)(HANDLE, HMODULE, LPWSTR, DWORD) = NULL;
typedef DWORD (WINAPI *GetModuleFileNameExW_t)(HANDLE, HMODULE, LPWSTR, DWORD);
GetModuleFileNameExW_t pGetModuleFileNameExW;
DWORD buflen = 128;
WCHAR *path = NULL;
HANDLE psapi = LoadLibrary(L"psapi.dll");
char *retval = NULL;
DWORD len = 0;
int i;

if (!psapi) {
WIN_SetError("Couldn't load psapi.dll");
return NULL;
}

pGetModuleFileNameExW = GetProcAddress(psapi, "GetModuleFileNameExW");
pGetModuleFileNameExW = (GetModuleFileNameExW_t)GetProcAddress(psapi, "GetModuleFileNameExW");
if (!pGetModuleFileNameExW) {
WIN_SetError("Couldn't find GetModuleFileNameExW");
FreeLibrary(psapi);
return NULL;
}

while (SDL_TRUE) {
path = (WCHAR *) SDL_malloc(path, buflen * sizeof (WCHAR));
path = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
if (!path) {
FreeLibrary(psapi);
SDL_OutOfMemory();
return NULL;
}

len = pGetModuleFileNameEx(GetCurrentProcess(), NULL, path, buflen);
len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
if (len != buflen) {
break;
}
Expand Down

0 comments on commit bccc2ad

Please sign in to comment.