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