Skip to content

Commit

Permalink
Add "D3DFMT_UNKNOWN" checks on object creation (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall authored Oct 17, 2024
1 parent f7012c9 commit 7a2f98e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions source/d3d8to9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateTexture(UINT Width, UINT Height
if (ppTexture == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppTexture = nullptr;

if (Pool == D3DPOOL_DEFAULT)
Expand Down Expand Up @@ -312,6 +315,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVolumeTexture(UINT Width, UINT
if (ppVolumeTexture == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppVolumeTexture = nullptr;

IDirect3DVolumeTexture9 *TextureInterface = nullptr;
Expand All @@ -329,6 +335,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateCubeTexture(UINT EdgeLength, UI
if (ppCubeTexture == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppCubeTexture = nullptr;

IDirect3DCubeTexture9 *TextureInterface = nullptr;
Expand Down Expand Up @@ -380,6 +389,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateRenderTarget(UINT Width, UINT H
if (ppSurface == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppSurface = nullptr;

DWORD QualityLevels = 0;
Expand Down Expand Up @@ -409,6 +421,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateDepthStencilSurface(UINT Width,
if (ppSurface == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppSurface = nullptr;

DWORD QualityLevels = 0;
Expand Down Expand Up @@ -442,8 +457,13 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateImageSurface(UINT Width, UINT H
if (ppSurface == nullptr)
return D3DERR_INVALIDCALL;

// Only CreateImageSurface clears the content of ppSurface
// before checking if Format is equal to D3DFMT_UNKNOWN.
*ppSurface = nullptr;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

IDirect3DSurface9 *SurfaceInterface = nullptr;

const HRESULT hr = ProxyInterface->CreateOffscreenPlainSurface(Width, Height, Format, D3DPOOL_SYSTEMMEM, &SurfaceInterface, nullptr);
Expand Down

0 comments on commit 7a2f98e

Please sign in to comment.