mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 21:30:53 +00:00
[Refs #87: Static Analysis] Handle paranoid case of dll not existing
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user