Removed never-set union field : X_D3DVertexShader.CxbxVertexShaderHandle to avoid using garbage data.

This commit is contained in:
PatrickvL 2019-09-17 09:57:57 +02:00
parent 456906b6b4
commit 0c470044fb
2 changed files with 4 additions and 5 deletions

View File

@ -3151,7 +3151,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SelectVertexShader)
if(pXboxVertexShader != nullptr) 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 else
{ {

View File

@ -1060,10 +1060,7 @@ struct X_D3DVertexShader
DWORD TotalSize; // seems to include both the function and ?constants? 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) 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; X_VERTEXATTRIBUTEFORMAT VertexAttribute;
union { 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 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)
};
}; };
// vertex shader input registers for fixed function vertex shader // vertex shader input registers for fixed function vertex shader