diff --git a/libmupen64plus/D3D8Interceptor/Direct3D8Functions.cpp b/libmupen64plus/D3D8Interceptor/Direct3D8Functions.cpp index ca5b69d040..9fc7339635 100644 --- a/libmupen64plus/D3D8Interceptor/Direct3D8Functions.cpp +++ b/libmupen64plus/D3D8Interceptor/Direct3D8Functions.cpp @@ -121,10 +121,21 @@ extern "C" STDMETHODIMP D3D8Wrapper::IDirect3D8::CreateDevice(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters,D3D8Wrapper::IDirect3DDevice8** ppReturnedDeviceInterface) { + //sometimes, Intel drivers will clear the dll path. So let's save and restore it (do their job for them) + //it doesn't seem like this happens any time besides creating the D3D8 object and a device. + //If it does, then this solution isn't scalable at all. + //This is a good place to note that it appears possible that on the affected drivers, the D3D9 interface will only SetDllDirectory the first time a D3D9 object is created + char oldDllDirectory[MAX_PATH]; + GetDllDirectory(MAX_PATH, oldDllDirectory); + LOG("IDirect3D8::CreateDevice( " << Adapter << " , " << DeviceType << " , " << hFocusWindow << " , " << BehaviorFlags << " , " << pPresentationParameters << " , " << ppReturnedDeviceInterface << " ) [ " << this << " ]\n"); D3D8Base::IDirect3DDevice8* realDevice = NULL; HRESULT hr = m_pD3D->CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,&realDevice); + + //restore old DLL directory + SetDllDirectory(oldDllDirectory); + if(FAILED(hr)) { return hr; diff --git a/libmupen64plus/D3D8Interceptor/d3d8Wrapper.cpp b/libmupen64plus/D3D8Interceptor/d3d8Wrapper.cpp index 03f850b19f..905fdaad0f 100644 --- a/libmupen64plus/D3D8Interceptor/d3d8Wrapper.cpp +++ b/libmupen64plus/D3D8Interceptor/d3d8Wrapper.cpp @@ -14,7 +14,11 @@ extern "C" D3D8Wrapper::IDirect3D8* WINAPI Direct3DCreate8(UINT Version) { - // Get the real DLL path from the system directory + //sometimes, Intel drivers will clear the dll path. So let's save and restore it (do their job for them) + char oldDllDirectory[MAX_PATH]; + GetDllDirectory(MAX_PATH, oldDllDirectory); + + // Get the real DLL path from the system directory, needs to be specific to avoid binding to the d3d8.dll we're in now! // Might be unsafe CHAR dll_path[1024]; GetSystemDirectory(dll_path,1024); @@ -30,6 +34,9 @@ extern "C" // Wrap the object D3D8Wrapper::IDirect3D8* wrappedD3D = D3D8Wrapper::IDirect3D8::GetDirect3D(realD3D); + //restore old DLL directory + SetDllDirectory(oldDllDirectory); + return wrappedD3D; } } diff --git a/output/dll/d3d8.dll b/output/dll/d3d8.dll index 980ce2d2a0..92edd74472 100644 Binary files a/output/dll/d3d8.dll and b/output/dll/d3d8.dll differ