Author: greatlrd Date: Sun Oct 22 14:43:36 2006 New Revision: 24601
URL: http://svn.reactos.org/svn/reactos?rev=24601&view=rev Log: 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.
Modified: trunk/reactos/dll/directx/ddraw/main.c
Modified: trunk/reactos/dll/directx/ddraw/main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main.c?re... ============================================================================== --- trunk/reactos/dll/directx/ddraw/main.c (original) +++ trunk/reactos/dll/directx/ddraw/main.c Sun Oct 22 14:43:36 2006 @@ -145,36 +145,34 @@ 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