Skip to content

Commit

Permalink
Additional error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 22, 2024
1 parent b89c6b7 commit 6ef8c94
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7205
#define BUILD_NUMBER 7206
1 change: 1 addition & 0 deletions IClassFactory/IClassFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ HRESULT m_IClassFactory::QueryInterface(REFIID riid, LPVOID FAR * ppvObj)
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_IClassFactory || riid == IID_IUnknown)
{
Expand Down
6 changes: 2 additions & 4 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ HRESULT m_IDirect3DDeviceX::QueryInterface(REFIID riid, LPVOID FAR * ppvObj, DWO
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down Expand Up @@ -754,7 +755,6 @@ HRESULT m_IDirect3DDeviceX::GetTexture(DWORD dwStage, LPDIRECT3DTEXTURE2* lplpTe
{
return DDERR_INVALIDPARAMS;
}

*lplpTexture = nullptr;

// Get surface stage
Expand Down Expand Up @@ -814,11 +814,10 @@ HRESULT m_IDirect3DDeviceX::GetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7* lplp
{
return DDERR_INVALIDPARAMS;
}
*lplpTexture = nullptr;

HRESULT hr = DDERR_GENERIC;

*lplpTexture = nullptr;

if (AttachedTexture[dwStage])
{
AttachedTexture[dwStage]->AddRef();
Expand Down Expand Up @@ -1968,7 +1967,6 @@ HRESULT m_IDirect3DDeviceX::GetDirect3D(LPDIRECT3D7* lplpD3D, DWORD DirectXVersi
{
return DDERR_INVALIDPARAMS;
}

*lplpD3D = nullptr;

// Check for device interface
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DExecuteBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HRESULT m_IDirect3DExecuteBuffer::QueryInterface(REFIID riid, LPVOID FAR * ppvOb
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HRESULT m_IDirect3DLight::QueryInterface(REFIID riid, LPVOID FAR * ppvObj)
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DMaterialX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HRESULT m_IDirect3DMaterialX::QueryInterface(REFIID riid, LPVOID FAR * ppvObj, D
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DTextureX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HRESULT m_IDirect3DTextureX::QueryInterface(REFIID riid, LPVOID FAR * ppvObj, DW
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DVertexBufferX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HRESULT m_IDirect3DVertexBufferX::QueryInterface(REFIID riid, LPVOID FAR * ppvOb
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DViewportX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HRESULT m_IDirect3DViewportX::QueryInterface(REFIID riid, LPVOID FAR * ppvObj, D
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
6 changes: 6 additions & 0 deletions ddraw/IDirect3DX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ HRESULT m_IDirect3DX::QueryInterface(REFIID riid, LPVOID FAR * ppvObj, DWORD Dir
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down Expand Up @@ -411,6 +412,7 @@ HRESULT m_IDirect3DX::CreateLight(LPDIRECT3DLIGHT * lplpDirect3DLight, LPUNKNOWN
{
return DDERR_INVALIDPARAMS;
}
*lplpDirect3DLight = nullptr;

// Check for device
if (!ddrawParent)
Expand Down Expand Up @@ -461,6 +463,7 @@ HRESULT m_IDirect3DX::CreateMaterial(LPDIRECT3DMATERIAL3 * lplpDirect3DMaterial,
{
return DDERR_INVALIDPARAMS;
}
*lplpDirect3DMaterial = nullptr;

// Check for device
if (!ddrawParent)
Expand Down Expand Up @@ -515,6 +518,7 @@ HRESULT m_IDirect3DX::CreateViewport(LPDIRECT3DVIEWPORT3 * lplpD3DViewport, LPUN
{
return DDERR_INVALIDPARAMS;
}
*lplpD3DViewport = nullptr;

// Check for device
if (!ddrawParent)
Expand Down Expand Up @@ -617,6 +621,7 @@ HRESULT m_IDirect3DX::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE7 lpDDS,
{
return DDERR_INVALIDPARAMS;
}
*lplpD3DDevice = nullptr;

// Check for device
if (!ddrawParent)
Expand Down Expand Up @@ -707,6 +712,7 @@ HRESULT m_IDirect3DX::CreateVertexBuffer(LPD3DVERTEXBUFFERDESC lpVBDesc, LPDIREC
{
return DDERR_INVALIDPARAMS;
}
*lplpD3DVertexBuffer = nullptr;

if (!lpVBDesc->dwNumVertices)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirectDrawClipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ HRESULT m_IDirectDrawClipper::QueryInterface(REFIID riid, LPVOID FAR * ppvObj)
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirectDrawColorControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HRESULT m_IDirectDrawColorControl::QueryInterface(REFIID riid, LPVOID FAR * ppvO
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirectDrawGammaControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HRESULT m_IDirectDrawGammaControl::QueryInterface(REFIID riid, LPVOID FAR * ppvO
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirectDrawPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ HRESULT m_IDirectDrawPalette::QueryInterface(REFIID riid, LPVOID FAR * ppvObj)
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down
2 changes: 1 addition & 1 deletion ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2309,11 +2309,11 @@ HRESULT m_IDirectDrawSurfaceX::GetPalette(LPDIRECTDRAWPALETTE FAR * lplpDDPalett
{
return DDERR_INVALIDPARAMS;
}
*lplpDDPalette = nullptr;

// No palette attached
if (!attachedPalette)
{
*lplpDDPalette = nullptr;
return DDERR_NOPALETTEATTACHED;
}

Expand Down
2 changes: 2 additions & 0 deletions ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ HRESULT m_IDirectDrawX::QueryInterface(REFIID riid, LPVOID FAR * ppvObj, DWORD D
{
return E_POINTER;
}
*ppvObj = nullptr;

if (riid == IID_GetRealInterface)
{
Expand Down Expand Up @@ -540,6 +541,7 @@ HRESULT m_IDirectDrawX::CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRE
{
return DDERR_INVALIDPARAMS;
}
*lplpDDSurface = nullptr;

if (Config.Dd7to9)
{
Expand Down
5 changes: 1 addition & 4 deletions ddraw/InterfaceQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ HRESULT DdrawWrapper::ProxyQueryInterface(LPVOID ProxyInterface, REFIID riid, LP
{
return E_POINTER;
}
*ppvObj = nullptr;

if (Config.Dd7to9 || !ProxyInterface)
{
*ppvObj = nullptr;

genericQueryInterface(riid, ppvObj);

if (*ppvObj)
Expand All @@ -125,8 +124,6 @@ HRESULT DdrawWrapper::ProxyQueryInterface(LPVOID ProxyInterface, REFIID riid, LP
}
else
{
*ppvObj = nullptr;

genericQueryInterface(riid, ppvObj);

if (*ppvObj)
Expand Down

0 comments on commit 6ef8c94

Please sign in to comment.