mirror of https://github.com/encounter/SDL.git
Merge commit '3f1b5efccaa727745b335b546a42bd650694ca08' into main
This commit is contained in:
commit
da4c97250a
|
@ -47,11 +47,20 @@ SDL_LoadObject(const char *sofile)
|
|||
|
||||
pszModName = OS2_UTF8ToSys(sofile);
|
||||
ulRC = DosLoadModule(acError, sizeof(acError), pszModName, &hModule);
|
||||
SDL_free(pszModName);
|
||||
|
||||
if (ulRC != NO_ERROR && !SDL_strrchr(pszModName, '\\') && !SDL_strrchr(pszModName, '/')) {
|
||||
/* strip .dll extension and retry only if name has no path. */
|
||||
size_t len = SDL_strlen(pszModName);
|
||||
if (len > 4 && SDL_strcasecmp(&pszModName[len - 4], ".dll") == 0) {
|
||||
pszModName[len - 4] = '\0';
|
||||
ulRC = DosLoadModule(acError, sizeof(acError), pszModName, &hModule);
|
||||
}
|
||||
}
|
||||
if (ulRC != NO_ERROR) {
|
||||
SDL_SetError("Failed loading %s: %s (E%u)", sofile, acError, ulRC);
|
||||
return NULL;
|
||||
hModule = NULLHANDLE;
|
||||
}
|
||||
SDL_free(pszModName);
|
||||
|
||||
return (void *)hModule;
|
||||
}
|
||||
|
@ -63,6 +72,16 @@ SDL_LoadFunction(void *handle, const char *name)
|
|||
PFN pFN;
|
||||
|
||||
ulRC = DosQueryProcAddr((HMODULE)handle, 0, name, &pFN);
|
||||
if (ulRC != NO_ERROR) {
|
||||
/* retry with an underscore prepended, e.g. for gcc-built dlls. */
|
||||
SDL_bool isstack;
|
||||
size_t len = SDL_strlen(name) + 1;
|
||||
char *_name = SDL_small_alloc(char, len + 1, &isstack);
|
||||
_name[0] = '_';
|
||||
SDL_memcpy(&_name[1], name, len);
|
||||
ulRC = DosQueryProcAddr((HMODULE)handle, 0, _name, &pFN);
|
||||
SDL_small_free(_name, isstack);
|
||||
}
|
||||
if (ulRC != NO_ERROR) {
|
||||
SDL_SetError("Failed loading procedure %s (E%u)", name, ulRC);
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue