[Refs #87: Static Analysis] Handle paranoid case of dll not existing

This commit is contained in:
baldurk
2014-10-05 16:33:06 +01:00
parent 20e86183bf
commit 5954f1a406
2 changed files with 36 additions and 12 deletions
+15 -1
View File
@@ -120,9 +120,23 @@ private:
// shouldn't ever get in here if we're in the case without hooks but let's be safe.
if(m_HasHooks)
{
createFunc = CreateDeviceAndSwapChain();
}
else
createFunc = (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)GetProcAddress(GetModuleHandleA("d3d11.dll"), "D3D11CreateDeviceAndSwapChain");
{
HMODULE d3d11 = GetModuleHandleA("d3d11.dll");
if(d3d11)
{
createFunc = (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)GetProcAddress(d3d11, "D3D11CreateDeviceAndSwapChain");
}
else
{
RDCERR("Something went seriously wrong, d3d11.dll couldn't be loaded!");
return E_UNEXPECTED;
}
}
return createFunc(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels,
SDKVersion, pSwapChainDesc, ppSwapChain, ppDevice, pFeatureLevel, ppImmediateContext);
+21 -11
View File
@@ -66,20 +66,30 @@ public:
if(dxgihooks.m_HasHooks)
return dxgihooks.CreateDXGIFactory1_hook(riid, ppFactory);
PFN_CREATE_DXGI_FACTORY createFunc = (PFN_CREATE_DXGI_FACTORY)GetProcAddress(GetModuleHandleA("dxgi.dll"), "CreateDXGIFactory1");
HMODULE dxgi = GetModuleHandleA("dxgi.dll");
if(!createFunc)
if(dxgi)
{
RDCERR("Trying to create hooked dxgi factory without dxgi loaded");
return E_INVALIDARG;
}
HRESULT ret = createFunc(riid, ppFactory);
if(SUCCEEDED(ret))
RefCountDXGIObject::HandleWrap(riid, ppFactory);
PFN_CREATE_DXGI_FACTORY createFunc = (PFN_CREATE_DXGI_FACTORY)GetProcAddress(dxgi, "CreateDXGIFactory1");
return ret;
if(!createFunc)
{
RDCERR("Trying to create hooked dxgi factory without dxgi loaded");
return E_INVALIDARG;
}
HRESULT ret = createFunc(riid, ppFactory);
if(SUCCEEDED(ret))
RefCountDXGIObject::HandleWrap(riid, ppFactory);
return ret;
}
else
{
RDCERR("Something went seriously wrong, dxgi.dll couldn't be loaded!");
return E_UNEXPECTED;
}
}
private: