mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-26 20:45:39 +00:00
Fixed compiling and tested on Windows
This commit is contained in:
parent
6d1ad3847a
commit
bccc2ad09e
|
@ -36,19 +36,21 @@
|
||||||
char *
|
char *
|
||||||
SDL_GetBasePath(void)
|
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;
|
DWORD buflen = 128;
|
||||||
WCHAR *path = NULL;
|
WCHAR *path = NULL;
|
||||||
HANDLE psapi = LoadLibrary(L"psapi.dll");
|
HANDLE psapi = LoadLibrary(L"psapi.dll");
|
||||||
char *retval = NULL;
|
char *retval = NULL;
|
||||||
DWORD len = 0;
|
DWORD len = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!psapi) {
|
if (!psapi) {
|
||||||
WIN_SetError("Couldn't load psapi.dll");
|
WIN_SetError("Couldn't load psapi.dll");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pGetModuleFileNameExW = GetProcAddress(psapi, "GetModuleFileNameExW");
|
pGetModuleFileNameExW = (GetModuleFileNameExW_t)GetProcAddress(psapi, "GetModuleFileNameExW");
|
||||||
if (!pGetModuleFileNameExW) {
|
if (!pGetModuleFileNameExW) {
|
||||||
WIN_SetError("Couldn't find GetModuleFileNameExW");
|
WIN_SetError("Couldn't find GetModuleFileNameExW");
|
||||||
FreeLibrary(psapi);
|
FreeLibrary(psapi);
|
||||||
|
@ -56,14 +58,14 @@ SDL_GetBasePath(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (SDL_TRUE) {
|
while (SDL_TRUE) {
|
||||||
path = (WCHAR *) SDL_malloc(path, buflen * sizeof (WCHAR));
|
path = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
|
||||||
if (!path) {
|
if (!path) {
|
||||||
FreeLibrary(psapi);
|
FreeLibrary(psapi);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = pGetModuleFileNameEx(GetCurrentProcess(), NULL, path, buflen);
|
len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
|
||||||
if (len != buflen) {
|
if (len != buflen) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue