windows: Workaround weird LoadLibraryEx failures

For some reason some Windows 7 systems (most are unaffected) cannot cope
with LoadLibraryEx and return error code 87 - "The parameter is
incorrect".

Switch to using LoadLibrary instead for any case where Windows 7 is
expected to successfully load the requested dll. Potentially Windows
Vista is also affected.
This commit is contained in:
Jonathan Li 2016-04-06 19:38:31 +01:00
parent da9577076c
commit e16b367e6e
3 changed files with 12 additions and 9 deletions

View File

@ -57,7 +57,9 @@ bool GSDeviceDX::LoadD3DCompiler()
else
{
if (!IsWindows8Point1OrGreater())
s_d3d_compiler_dll = LoadLibraryEx("D3DCompiler_43.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
// Use LoadLibrary instead of LoadLibraryEx, some Windows 7 systems
// have issues with it.
s_d3d_compiler_dll = LoadLibrary("D3DCompiler_43.dll");
if (s_d3d_compiler_dll == nullptr)
return false;

View File

@ -255,13 +255,13 @@ void EnumXInputDevices() {
// don't repeatedly try to load it.
if (pXInputEnable) return;
const DWORD flags = LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32;
// Prefer XInput 1.3 since SCP only has an XInput 1.3 wrapper right now.
// Also use LoadLibrary and not LoadLibraryEx for XInput 1.3, since some
// Windows 7 systems have issues with it.
// FIXME: Missing FreeLibrary call.
HMODULE hMod = LoadLibraryEx(L"xinput1_3.dll", nullptr, flags);
HMODULE hMod = LoadLibrary(L"xinput1_3.dll");
if (hMod == nullptr && IsWindows8OrGreater()) {
hMod = LoadLibraryEx(L"XInput1_4.dll", nullptr, flags);
hMod = LoadLibraryEx(L"XInput1_4.dll", nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
}
if (hMod) {

View File

@ -643,12 +643,13 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
EXPORT_C_(UINT32) PADinit(UINT32 flags)
{
DWORD loadFlags = LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32;
s_xInputDll = LoadLibraryEx(L"xinput1_3.dll", nullptr, loadFlags);
// Use LoadLibrary and not LoadLibraryEx for XInput 1.3, since some
// Windows 7 systems have issues with it.
// TODO: Only load XInput 1.4 for Windows 8+? Or implement the SCP extension?
s_xInputDll = LoadLibrary(L"xinput1_3.dll");
if (s_xInputDll == nullptr && IsWindows8OrGreater())
{
s_xInputDll = LoadLibraryEx(L"XInput1_4.dll", nullptr, loadFlags);
s_xInputDll = LoadLibraryEx(L"XInput1_4.dll", nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
}
if (s_xInputDll == nullptr)
{