From 98ae58da2b040ed7a89aaf02afcc6c5b4285875d Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Sun, 22 Oct 2006 10:43:36 +0000 Subject: [PATCH] should have read msdn one more time for D3DParseUnknownCommand vaild command return sizeof of the struct * number of struct + 4 bytes, so it point to the end of the buffer. svn path=/trunk/; revision=24601 --- reactos/dll/directx/ddraw/main.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/reactos/dll/directx/ddraw/main.c b/reactos/dll/directx/ddraw/main.c index 88051f8923c..5fb175e8e44 100644 --- a/reactos/dll/directx/ddraw/main.c +++ b/reactos/dll/directx/ddraw/main.c @@ -145,36 +145,34 @@ D3DParseUnknownCommand( LPVOID lpCmd, DWORD retCode = D3DERR_COMMAND_UNPARSED; /* prevent it crash if null pointer are being sent */ - if (lpCmd == NULL) || (lpRetCmd == NULL) ) + if ( (lpCmd == NULL) || (lpRetCmd == NULL) ) { return E_FAIL; } *lpRetCmd = lpCmd; + /* check for vaild command, only 3 command is vaild */ if (dp2command->bCommand == D3DDP2OP_VIEWPORTINFO) - { - *(PBYTE)lpRetCmd += ((dp2command->wStateCount * sizeof(D3DHAL_DP2VIEWPORTINFO)) + sizeof(D3DHAL_DP2POINTS)); + { + /* dp2command->wStateCount * sizeof D3DHAL_DP2VIEWPORTINFO + 4 bytes */ + *(PBYTE)lpRetCmd += ((dp2command->wStateCount * sizeof(D3DHAL_DP2VIEWPORTINFO)) + sizeof(ULONG_PTR)); retCode = 0; } else if (dp2command->bCommand == D3DDP2OP_WINFO) - { - *(PBYTE)lpRetCmd += (dp2command->wStateCount * sizeof(D3DHAL_DP2WINFO)) + sizeof(D3DHAL_DP2POINTS); + { + /* dp2command->wStateCount * sizeof D3DHAL_DP2WINFO + 4 bytes */ + *(PBYTE)lpRetCmd += (dp2command->wStateCount * sizeof(D3DHAL_DP2WINFO)) + sizeof(ULONG_PTR); retCode = 0; } else if (dp2command->bCommand == 0x0d) - { - /* math - *lpRetCmd = lpCmd + (wStateCount * sizeof( ? ) + sizeof(D3DHAL_DP2POINTS) - */ - - *(PBYTE)lpRetCmd += ((dp2command->wStateCount * dp2command->bReserved) + sizeof(D3DHAL_DP2POINTS)); + { + /* dp2command->wStateCount * how many wStateCount ? + 4 bytes */ + *(PBYTE)lpRetCmd += ((dp2command->wStateCount * dp2command->bReserved) + sizeof(ULONG_PTR)); retCode = 0; } - - /* error code */ - + /* set error code for command 0 to 3, 8 and 15 to 255 */ else if ( (dp2command->bCommand <= D3DDP2OP_INDEXEDTRIANGLELIST) || // dp2command->bCommand <= with 0 to 3 (dp2command->bCommand == D3DDP2OP_RENDERSTATE) || // dp2command->bCommand == with 8 (dp2command->bCommand >= D3DDP2OP_LINELIST) ) // dp2command->bCommand >= with 15 to 255