From 0c470044fbfbf07c9d04bae706760672e8ea4f16 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Tue, 17 Sep 2019 09:57:57 +0200 Subject: [PATCH] Removed never-set union field : X_D3DVertexShader.CxbxVertexShaderHandle to avoid using garbage data. --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 4 +++- src/core/hle/D3D8/XbD3D8Types.h | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index db53fa79e..2c107f797 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -3151,7 +3151,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SelectVertexShader) if(pXboxVertexShader != nullptr) { - pCxbxVertexShader = (CxbxVertexShader *)(pXboxVertexShader->CxbxVertexShaderHandle); + LOG_TEST_CASE("Assigned g_VertexShaderSlots"); + // Was : pCxbxVertexShader = (CxbxVertexShader *)(pXboxVertexShader->CxbxVertexShaderHandle); + // However, the CxbxVertexShaderHandle union is never set, so could lead to using undefined data! } else { diff --git a/src/core/hle/D3D8/XbD3D8Types.h b/src/core/hle/D3D8/XbD3D8Types.h index 4f0dfe844..12d11f4b6 100644 --- a/src/core/hle/D3D8/XbD3D8Types.h +++ b/src/core/hle/D3D8/XbD3D8Types.h @@ -1060,10 +1060,7 @@ struct X_D3DVertexShader DWORD TotalSize; // seems to include both the function and ?constants? DWORD NumberOfDimensionsPerTexture; // Guesswork, since all 4 bytes (for all 4 textures) are most often set to 0 (or 2 when a texture isn't used) and 1, 3 and 4 also occur (and nothing else) X_VERTEXATTRIBUTEFORMAT VertexAttribute; - union { - DWORD CxbxVertexShaderHandle; // This is probably the least damaging part to overwrite : We put a pointer to our CbxVertexShader here - DWORD FunctionData[X_VSH_MAX_INSTRUCTION_COUNT]; // probably the binary function data and ?constants? (data continues futher outside this struct, up to TotalSize DWORD's) - }; + DWORD FunctionData[X_VSH_MAX_INSTRUCTION_COUNT]; // probably the binary function data and ?constants? (data continues futher outside this struct, up to TotalSize DWORD's) }; // vertex shader input registers for fixed function vertex shader