From 34165f3814a0cdc80760c5133785f07d70619294 Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Tue, 19 Nov 2024 17:57:56 +0200 Subject: [PATCH] [d3d8] Validate PS/VS version on creation --- src/d3d8/d3d8_device.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/d3d8/d3d8_device.cpp b/src/d3d8/d3d8_device.cpp index a1925cb7..ec6a557b 100644 --- a/src/d3d8/d3d8_device.cpp +++ b/src/d3d8/d3d8_device.cpp @@ -1696,6 +1696,17 @@ namespace dxvk { if (unlikely(pDeclaration == nullptr || pHandle == nullptr)) return D3DERR_INVALIDCALL; + // Validate VS version for non-FF shaders + if (pFunction != nullptr) { + uint32_t majorVersion = (pFunction[0] >> 8) & 0xff; + uint32_t minorVersion = pFunction[0] & 0xff; + + if (unlikely(majorVersion != 1 || minorVersion > 1)) { + Logger::err(str::format("D3D8Device::CreateVertexShader: Unsupported VS version ", majorVersion, ".", minorVersion)); + return D3DERR_INVALIDCALL; + } + } + D3D8VertexShaderInfo& info = m_vertexShaders.emplace_back(); // Store D3D8 bytecodes in the shader info @@ -1926,6 +1937,14 @@ namespace dxvk { if (unlikely(pFunction == nullptr || pHandle == nullptr)) return D3DERR_INVALIDCALL; + uint32_t majorVersion = (pFunction[0] >> 8) & 0xff; + uint32_t minorVersion = pFunction[0] & 0xff; + + if (unlikely(majorVersion != 1 || minorVersion > 4)) { + Logger::err(str::format("D3D8Device::CreatePixelShader: Unsupported PS version ", majorVersion, ".", minorVersion)); + return D3DERR_INVALIDCALL; + } + d3d9::IDirect3DPixelShader9* pPixelShader; HRESULT res = GetD3D9()->CreatePixelShader(pFunction, &pPixelShader);