From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/tests/dplayx.c | 243 ++++++++++++++++++++++++++++++++++++- 1 file changed, 242 insertions(+), 1 deletion(-)
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index e396966cb3b..6b9aaf6c5b6 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -1868,6 +1868,41 @@ static unsigned short receiveGuaranteedGameMessage_( int line, SOCKET sock, DPID return port; }
+#define sendGuaranteedGameMessage( sock, port, fromId, toId, data, dataSize ) \ + sendGuaranteedGameMessage_( __LINE__, sock, port, fromId, toId, data, dataSize ) +static void sendGuaranteedGameMessage_( int line, SOCKET sock, unsigned short port, DPID fromId, DPID toId, void *data, + DWORD dataSize ) +{ + struct + { + SpHeader spHeader; + GameMessage request; + } request = + { + .spHeader = + { + .mixed = 0xfab00000 + sizeof( request ) + dataSize, + .addr = + { + .sin_family = AF_INET, + .sin_port = htons( port ), + }, + }, + .request = + { + .fromId = fromId, + .toId = toId, + } + }; + int wsResult; + + wsResult = send( sock, (char *) &request, sizeof( request ), 0 ); + ok_( __FILE__, line )( wsResult == sizeof( request ), "send() returned %d.\n", wsResult ); + + wsResult = send( sock, data, dataSize, 0 ); + ok_( __FILE__, line )( wsResult == dataSize, "send() returned %d.\n", wsResult ); +} + static void init_TCPIP_provider( IDirectPlay4 *pDP, LPCSTR strIPAddressString, WORD port ) {
@@ -8051,6 +8086,211 @@ static void test_interactive_Send(void) /* Receive */
static void test_Receive(void) +{ + DPSESSIONDESC2 appGuidDpsd = + { + .dwSize = sizeof( DPSESSIONDESC2 ), + .guidApplication = appGuid, + .guidInstance = appGuid, + }; + DPSESSIONDESC2 serverDpsd = + { + .dwSize = sizeof( DPSESSIONDESC2 ), + .guidApplication = appGuid, + .guidInstance = appGuid, + .lpszSessionName = (WCHAR *) L"normal", + .dwReserved1 = 0xaabbccdd, + }; + BYTE data0[] = { 1, 2, 3, 4, 5, 6, 7, 8, }; + BYTE data1[] = { 4, 3, 2, 1, }; + BYTE msgData[ 256 ]; + DWORD msgDataSize; + DPID fromId, toId; + DWORD waitResult; + IDirectPlay4 *dp; + SOCKET sendSock; + SOCKET recvSock; + HANDLE event0; + HANDLE event1; + HRESULT hr; + + event0 = CreateEventA( NULL, FALSE, FALSE, NULL ); + event1 = CreateEventA( NULL, FALSE, FALSE, NULL ); + + hr = CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectPlay4A, (void **) &dp ); + ok( hr == DP_OK, "got hr %#lx.\n", hr ); + + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); + ok( hr == DPERR_UNINITIALIZED, "got hr %#lx.\n", hr ); + + init_TCPIP_provider( dp, "127.0.0.1", 0 ); + + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); + ok( hr == DPERR_NOMESSAGES, "got hr %#lx.\n", hr ); + + joinSession( dp, &appGuidDpsd, &serverDpsd, &sendSock, &recvSock ); + + createPlayer( dp, 0x07734, event0, NULL, 0, 0, sendSock, recvSock ); + createPlayer( dp, 0x14, event1, NULL, 0, 0, sendSock, recvSock ); + + waitResult = WaitForSingleObject( event0, 2000 ); + ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + + checkCreatePlayerOrGroupMessage( dp, DPPLAYERTYPE_PLAYER, 0x14, 2, NULL, 0, NULL, NULL, 0, DPPLAYER_LOCAL ); + + sendGuaranteedGameMessage( sendSock, 2349, 0x1337, 0x07734, data0, sizeof( data0 ) ); + sendGuaranteedGameMessage( sendSock, 2349, 0x1337, 0x14, data1, sizeof( data1 ) ); + + waitResult = WaitForSingleObject( event0, 2000 ); + todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + waitResult = WaitForSingleObject( event1, 2000 ); + todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + + fromId = 0xdeadbeef; + toId = 0xdeadbeef; + msgDataSize = sizeof( data0 ) - 1; + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_ALL | DPRECEIVE_PEEK, msgData, &msgDataSize ); + todo_wine ok( hr == DPERR_BUFFERTOOSMALL, "got hr %#lx.\n", hr ); + ok( fromId == 0xdeadbeef, "got source id %#lx.\n", fromId ); + ok( toId == 0xdeadbeef, "got destination id %#lx.\n", toId ); + todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + + fromId = 0xdeadbeef; + toId = 0xdeadbeef; + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, NULL, &msgDataSize ); + todo_wine ok( hr == DPERR_BUFFERTOOSMALL, "got hr %#lx.\n", hr ); + ok( fromId == 0xdeadbeef, "got source id %#lx.\n", fromId ); + ok( toId == 0xdeadbeef, "got destination id %#lx.\n", toId ); + todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + + fromId = 0xdeadbeef; + toId = 0xdeadbeef; + memset( msgData, 0xcc, sizeof( msgData ) ); + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_ALL | DPRECEIVE_PEEK, msgData, &msgDataSize ); + todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); + todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + todo_wine ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + + fromId = 0xdeadbeef; + toId = 0xdeadbeef; + memset( msgData, 0xcc, sizeof( msgData ) ); + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_PEEK, msgData, &msgDataSize ); + todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); + todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + todo_wine ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + + fromId = 0xdeadbeef; + toId = 0xdeadbeef; + memset( msgData, 0xcc, sizeof( msgData ) ); + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); + todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); + todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + todo_wine ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + + fromId = 0xdeadbeef; + toId = 0xdeadbeef; + memset( msgData, 0xcc, sizeof( msgData ) ); + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); + todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); + todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + todo_wine ok( toId == 0x14, "got destination id %#lx.\n", toId ); + todo_wine ok( !memcmp( msgData, data1, sizeof( data1 ) ), "message data didn't match.\n" ); + todo_wine ok( msgDataSize == sizeof( data1 ), "got message size %lu.\n", msgDataSize ); + + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); + ok( hr == DPERR_NOMESSAGES, "got hr %#lx.\n", hr ); + + sendGuaranteedGameMessage( sendSock, 2349, 0x1337, 0x07734, data0, sizeof( data0 ) ); + + waitResult = WaitForSingleObject( event0, 2000 ); + todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + + fromId = 0x14; + toId = 0xdeadbeef; + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_FROMPLAYER, msgData, &msgDataSize ); + ok( hr == DPERR_NOMESSAGES, "got hr %#lx.\n", hr ); + + fromId = 0x1337; + toId = 0xdeadbeef; + memset( msgData, 0xcc, sizeof( msgData ) ); + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_FROMPLAYER, msgData, &msgDataSize ); + todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); + ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + todo_wine ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + + fromId = 0x1337; + toId = 0xdeadbeef; + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_FROMPLAYER, msgData, &msgDataSize ); + ok( hr == DPERR_NOMESSAGES, "got hr %#lx.\n", hr ); + + sendGuaranteedGameMessage( sendSock, 2349, 0x1337, DPID_ALLPLAYERS, data0, sizeof( data0 ) ); + + waitResult = WaitForSingleObject( event0, 2000 ); + todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + waitResult = WaitForSingleObject( event1, 2000 ); + todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + + fromId = 0xdeadbeef; + toId = 0x07734; + memset( msgData, 0xcc, sizeof( msgData ) ); + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_TOPLAYER, msgData, &msgDataSize ); + todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); + todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + + toId = 0x07734; + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_TOPLAYER, msgData, &msgDataSize ); + ok( hr == DPERR_NOMESSAGES, "got hr %#lx.\n", hr ); + + fromId = 0xdeadbeef; + toId = 0x14; + memset( msgData, 0xcc, sizeof( msgData ) ); + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_TOPLAYER, msgData, &msgDataSize ); + todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); + todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + ok( toId == 0x14, "got destination id %#lx.\n", toId ); + todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + + toId = 0x14; + msgDataSize = sizeof( msgData ); + hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_TOPLAYER, msgData, &msgDataSize ); + ok( hr == DPERR_NOMESSAGES, "got hr %#lx.\n", hr ); + + closesocket( recvSock ); + closesocket( sendSock ); + + IDirectPlayX_Release( dp ); + + CloseHandle( event1 ); + CloseHandle( event0 ); +} + +static void test_interactive_Receive(void) {
IDirectPlay4 *pDP; @@ -9587,6 +9827,7 @@ START_TEST(dplayx) test_CreatePlayer(); test_CREATEPLAYER(); test_Send(); + test_Receive();
if (!winetest_interactive) { @@ -9624,7 +9865,7 @@ START_TEST(dplayx) test_groups_cs();
test_interactive_Send(); - test_Receive(); + test_interactive_Receive(); test_GetMessageCount(); test_GetMessageQueue();
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 20 +++++++++++++++++ dlls/dplayx/dplay_global.h | 2 ++ dlls/dplayx/dplaysp.c | 9 +++++++- dlls/dplayx/tests/dplayx.c | 46 +++++++++++++++++++------------------- 4 files changed, 53 insertions(+), 24 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 3fd813f311b..1a4edb61ebf 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -595,6 +595,26 @@ HRESULT DP_HandleMessage( IDirectPlayImpl *This, void *messageBody, return DP_OK; }
+HRESULT DP_HandleGameMessage( IDirectPlayImpl *This, void *messageBody, DWORD messageBodySize, + DPID fromId, DPID toId ) +{ + DPMSG_GENERIC *msg; + DWORD msgSize; + HRESULT hr; + + TRACE( "(%p)->(%p,0x%08lx,0x%08lx,0x%08lx)\n", This, messageBody, messageBodySize, fromId, toId ); + + msg = (DPMSG_GENERIC *) ((char *) messageBody + sizeof( DPMSG_SYSMSGENVELOPE )); + msgSize = messageBodySize - sizeof( DPMSG_SYSMSGENVELOPE ); + + EnterCriticalSection( &This->lock ); + + hr = DP_QueueMessage( This, fromId, toId, 0, msg, DP_CopyGeneric, msgSize ); + + LeaveCriticalSection( &This->lock ); + + return hr; +}
static HRESULT WINAPI IDirectPlayImpl_QueryInterface( IDirectPlay *iface, REFIID riid, void **ppv ) { diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h index b371eda9df6..902396f52c4 100644 --- a/dlls/dplayx/dplay_global.h +++ b/dlls/dplayx/dplay_global.h @@ -213,6 +213,8 @@ HRESULT DP_HandleMessage( IDirectPlayImpl *This, void *messageBody, DWORD dwMessageBodySize, void *messageHeader, WORD wCommandId, WORD wVersion, void **lplpReply, DWORD *lpdwMsgSize ); DPSESSIONDESC2 *DP_DuplicateSessionDesc( const DPSESSIONDESC2 *src, BOOL dstAnsi, BOOL srcAnsi ); +HRESULT DP_HandleGameMessage( IDirectPlayImpl *This, void *messageBody, DWORD messageBodySize, + DPID fromId, DPID toId ); HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPNAME *lpName, void *data, DWORD dataSize, void *spData, DWORD spDataSize, DWORD dwFlags, HANDLE hEvent, struct PlayerData **playerData, BOOL bAnsi ); diff --git a/dlls/dplayx/dplaysp.c b/dlls/dplayx/dplaysp.c index 535e7fa85c2..5ebd42c1b15 100644 --- a/dlls/dplayx/dplaysp.c +++ b/dlls/dplayx/dplaysp.c @@ -216,12 +216,19 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage( IDirectPlaySP *iface, voi WORD wVersion; DPSP_REPLYDATA data;
- FIXME( "(%p)->(%p,0x%08lx,%p): mostly stub\n", + TRACE( "(%p)->(%p,0x%08lx,%p)\n", This, lpMessageBody, dwMessageBodySize, lpMessageHeader );
if ( dwMessageBodySize < sizeof( DPMSG_SENDENVELOPE ) ) return DPERR_GENERIC;
+ if ( lpMsg->dwMagic != DPMSGMAGIC_DPLAYMSG ) + { + LPDPMSG_SYSMSGENVELOPE gameMsg = lpMessageBody; + return DP_HandleGameMessage( This->dplay, lpMessageBody, dwMessageBodySize, + gameMsg->dwPlayerFrom, gameMsg->dwPlayerTo ); + } + wCommandId = lpMsg->wCommandId; wVersion = lpMsg->wVersion;
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 6b9aaf6c5b6..73278501884 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -8144,18 +8144,18 @@ static void test_Receive(void) sendGuaranteedGameMessage( sendSock, 2349, 0x1337, 0x14, data1, sizeof( data1 ) );
waitResult = WaitForSingleObject( event0, 2000 ); - todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); waitResult = WaitForSingleObject( event1, 2000 ); - todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult );
fromId = 0xdeadbeef; toId = 0xdeadbeef; msgDataSize = sizeof( data0 ) - 1; hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_ALL | DPRECEIVE_PEEK, msgData, &msgDataSize ); todo_wine ok( hr == DPERR_BUFFERTOOSMALL, "got hr %#lx.\n", hr ); - ok( fromId == 0xdeadbeef, "got source id %#lx.\n", fromId ); - ok( toId == 0xdeadbeef, "got destination id %#lx.\n", toId ); - todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + todo_wine ok( fromId == 0xdeadbeef, "got source id %#lx.\n", fromId ); + todo_wine ok( toId == 0xdeadbeef, "got destination id %#lx.\n", toId ); + ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
fromId = 0xdeadbeef; toId = 0xdeadbeef; @@ -8171,11 +8171,11 @@ static void test_Receive(void) memset( msgData, 0xcc, sizeof( msgData ) ); msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_ALL | DPRECEIVE_PEEK, msgData, &msgDataSize ); - todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); - todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); - todo_wine ok( toId == 0x07734, "got destination id %#lx.\n", toId ); - todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); - todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + ok( hr == DP_OK, "got hr %#lx.\n", hr ); + ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
fromId = 0xdeadbeef; toId = 0xdeadbeef; @@ -8193,22 +8193,22 @@ static void test_Receive(void) memset( msgData, 0xcc, sizeof( msgData ) ); msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); - todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); - todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); - todo_wine ok( toId == 0x07734, "got destination id %#lx.\n", toId ); - todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); - todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + ok( hr == DP_OK, "got hr %#lx.\n", hr ); + ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
fromId = 0xdeadbeef; toId = 0xdeadbeef; memset( msgData, 0xcc, sizeof( msgData ) ); msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); - todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); - todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); - todo_wine ok( toId == 0x14, "got destination id %#lx.\n", toId ); - todo_wine ok( !memcmp( msgData, data1, sizeof( data1 ) ), "message data didn't match.\n" ); - todo_wine ok( msgDataSize == sizeof( data1 ), "got message size %lu.\n", msgDataSize ); + ok( hr == DP_OK, "got hr %#lx.\n", hr ); + ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + ok( toId == 0x14, "got destination id %#lx.\n", toId ); + ok( !memcmp( msgData, data1, sizeof( data1 ) ), "message data didn't match.\n" ); + ok( msgDataSize == sizeof( data1 ), "got message size %lu.\n", msgDataSize );
msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); @@ -8217,7 +8217,7 @@ static void test_Receive(void) sendGuaranteedGameMessage( sendSock, 2349, 0x1337, 0x07734, data0, sizeof( data0 ) );
waitResult = WaitForSingleObject( event0, 2000 ); - todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult );
fromId = 0x14; toId = 0xdeadbeef; @@ -8245,9 +8245,9 @@ static void test_Receive(void) sendGuaranteedGameMessage( sendSock, 2349, 0x1337, DPID_ALLPLAYERS, data0, sizeof( data0 ) );
waitResult = WaitForSingleObject( event0, 2000 ); - todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); waitResult = WaitForSingleObject( event1, 2000 ); - todo_wine ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult ); + ok( waitResult == WAIT_OBJECT_0, "message wait returned %lu\n", waitResult );
fromId = 0xdeadbeef; toId = 0x07734;
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 6 ++++++ dlls/dplayx/tests/dplayx.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 1a4edb61ebf..e6dccc2097c 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3841,6 +3841,12 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT
msgSize = lpMsg->copyMessage( NULL, lpMsg->msg, lpMsg->genericSize, bAnsi );
+ if( *lpdwDataSize < msgSize ) + { + *lpdwDataSize = msgSize; + return DPERR_BUFFERTOOSMALL; + } + *lpidFrom = lpMsg->fromId; *lpidTo = lpMsg->toId; *lpdwDataSize = msgSize; diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 73278501884..0ae709a89a1 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -8152,9 +8152,9 @@ static void test_Receive(void) toId = 0xdeadbeef; msgDataSize = sizeof( data0 ) - 1; hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_ALL | DPRECEIVE_PEEK, msgData, &msgDataSize ); - todo_wine ok( hr == DPERR_BUFFERTOOSMALL, "got hr %#lx.\n", hr ); - todo_wine ok( fromId == 0xdeadbeef, "got source id %#lx.\n", fromId ); - todo_wine ok( toId == 0xdeadbeef, "got destination id %#lx.\n", toId ); + ok( hr == DPERR_BUFFERTOOSMALL, "got hr %#lx.\n", hr ); + ok( fromId == 0xdeadbeef, "got source id %#lx.\n", fromId ); + ok( toId == 0xdeadbeef, "got destination id %#lx.\n", toId ); ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
fromId = 0xdeadbeef;
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 12 ++---------- dlls/dplayx/tests/dplayx.c | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index e6dccc2097c..cc7972a7516 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3811,14 +3811,6 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT dwFlags = DPRECEIVE_ALL; }
- /* If the lpData is NULL, we must be peeking the message */ - if( ( lpData == NULL ) && - !( dwFlags & DPRECEIVE_PEEK ) - ) - { - return DPERR_INVALIDPARAMS; - } - if( dwFlags & DPRECEIVE_ALL ) { lpMsg = This->dp2->receiveMsgs.lpQHFirst; @@ -3841,7 +3833,7 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT
msgSize = lpMsg->copyMessage( NULL, lpMsg->msg, lpMsg->genericSize, bAnsi );
- if( *lpdwDataSize < msgSize ) + if( *lpdwDataSize < msgSize || !lpData ) { *lpdwDataSize = msgSize; return DPERR_BUFFERTOOSMALL; @@ -3852,7 +3844,7 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT *lpdwDataSize = msgSize;
/* Copy into the provided buffer */ - if (lpData) lpMsg->copyMessage( lpData, lpMsg->msg, lpMsg->genericSize, bAnsi ); + lpMsg->copyMessage( lpData, lpMsg->msg, lpMsg->genericSize, bAnsi );
if( !( dwFlags & DPRECEIVE_PEEK ) ) { diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 0ae709a89a1..d921966abe6 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -8161,10 +8161,10 @@ static void test_Receive(void) toId = 0xdeadbeef; msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, NULL, &msgDataSize ); - todo_wine ok( hr == DPERR_BUFFERTOOSMALL, "got hr %#lx.\n", hr ); + ok( hr == DPERR_BUFFERTOOSMALL, "got hr %#lx.\n", hr ); ok( fromId == 0xdeadbeef, "got source id %#lx.\n", fromId ); ok( toId == 0xdeadbeef, "got destination id %#lx.\n", toId ); - todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
fromId = 0xdeadbeef; toId = 0xdeadbeef;
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 25 +++++++------------------ dlls/dplayx/tests/dplayx.c | 34 +++++++++++++++++----------------- 2 files changed, 24 insertions(+), 35 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index cc7972a7516..f0b6fd2c866 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3798,7 +3798,7 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT LPDPMSG lpMsg = NULL; DWORD msgSize;
- FIXME( "(%p)->(%p,%p,0x%08lx,%p,%p,%u): stub\n", + TRACE( "(%p)->(%p,%p,0x%08lx,%p,%p,%u)\n", This, lpidFrom, lpidTo, dwFlags, lpData, lpdwDataSize, bAnsi );
if( This->dp2->connectionInitialized == NO_PROVIDER ) @@ -3806,24 +3806,13 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT return DPERR_UNINITIALIZED; }
- if( dwFlags == 0 ) - { - dwFlags = DPRECEIVE_ALL; - } - - if( dwFlags & DPRECEIVE_ALL ) - { - lpMsg = This->dp2->receiveMsgs.lpQHFirst; - } - else if( ( dwFlags & DPRECEIVE_TOPLAYER ) || - ( dwFlags & DPRECEIVE_FROMPLAYER ) - ) - { - FIXME( "Find matching message 0x%08lx\n", dwFlags ); - } - else + for( lpMsg = DPQ_FIRST( This->dp2->receiveMsgs ); lpMsg; lpMsg = DPQ_NEXT( lpMsg->msgs ) ) { - ERR( "Hmmm..dwFlags 0x%08lx\n", dwFlags ); + if( ( dwFlags & DPRECEIVE_TOPLAYER ) && ( lpMsg->toId != *lpidTo ) ) + continue; + if( ( dwFlags & DPRECEIVE_FROMPLAYER ) && ( lpMsg->fromId != *lpidFrom ) ) + continue; + break; }
if( lpMsg == NULL ) diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index d921966abe6..c9428aafead 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -8182,11 +8182,11 @@ static void test_Receive(void) memset( msgData, 0xcc, sizeof( msgData ) ); msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_PEEK, msgData, &msgDataSize ); - todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); - todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); - todo_wine ok( toId == 0x07734, "got destination id %#lx.\n", toId ); - todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); - todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + ok( hr == DP_OK, "got hr %#lx.\n", hr ); + ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
fromId = 0xdeadbeef; toId = 0xdeadbeef; @@ -8230,11 +8230,11 @@ static void test_Receive(void) memset( msgData, 0xcc, sizeof( msgData ) ); msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_FROMPLAYER, msgData, &msgDataSize ); - todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); + ok( hr == DP_OK, "got hr %#lx.\n", hr ); ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); - todo_wine ok( toId == 0x07734, "got destination id %#lx.\n", toId ); - todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); - todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + ok( toId == 0x07734, "got destination id %#lx.\n", toId ); + ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
fromId = 0x1337; toId = 0xdeadbeef; @@ -8254,11 +8254,11 @@ static void test_Receive(void) memset( msgData, 0xcc, sizeof( msgData ) ); msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_TOPLAYER, msgData, &msgDataSize ); - todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); - todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + ok( hr == DP_OK, "got hr %#lx.\n", hr ); + ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); ok( toId == 0x07734, "got destination id %#lx.\n", toId ); - todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); - todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
toId = 0x07734; msgDataSize = sizeof( msgData ); @@ -8270,11 +8270,11 @@ static void test_Receive(void) memset( msgData, 0xcc, sizeof( msgData ) ); msgDataSize = sizeof( msgData ); hr = IDirectPlayX_Receive( dp, &fromId, &toId, DPRECEIVE_TOPLAYER, msgData, &msgDataSize ); - todo_wine ok( hr == DP_OK, "got hr %#lx.\n", hr ); - todo_wine ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); + ok( hr == DP_OK, "got hr %#lx.\n", hr ); + ok( fromId == 0x1337, "got source id %#lx.\n", fromId ); ok( toId == 0x14, "got destination id %#lx.\n", toId ); - todo_wine ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); - todo_wine ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize ); + ok( !memcmp( msgData, data0, sizeof( data0 ) ), "message data didn't match.\n" ); + ok( msgDataSize == sizeof( data0 ), "got message size %lu.\n", msgDataSize );
toId = 0x14; msgDataSize = sizeof( msgData );
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index f0b6fd2c866..4dbbd722730 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3806,6 +3806,8 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT return DPERR_UNINITIALIZED; }
+ EnterCriticalSection( &This->lock ); + for( lpMsg = DPQ_FIRST( This->dp2->receiveMsgs ); lpMsg; lpMsg = DPQ_NEXT( lpMsg->msgs ) ) { if( ( dwFlags & DPRECEIVE_TOPLAYER ) && ( lpMsg->toId != *lpidTo ) ) @@ -3817,6 +3819,7 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT
if( lpMsg == NULL ) { + LeaveCriticalSection( &This->lock ); return DPERR_NOMESSAGES; }
@@ -3825,6 +3828,7 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT if( *lpdwDataSize < msgSize || !lpData ) { *lpdwDataSize = msgSize; + LeaveCriticalSection( &This->lock ); return DPERR_BUFFERTOOSMALL; }
@@ -3842,6 +3846,8 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT free( lpMsg ); }
+ LeaveCriticalSection( &This->lock ); + return DP_OK; }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=149501
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
dplayx: dplayx.c:2947: Test failed: got flags 0.
=== w10pro64_en_AE_u8 (32 bit report) ===
dplayx: dplayx.c:2931: Test failed: Open() returned 0x8007000e.
=== debian11 (32 bit de report) ===
dplayx: dplayx.c:3648: Test failed: recv() returned 52. dplayx.c:3662: Test failed: recv() returned 52.
This merge request was approved by Alistair Leslie-Hughes.