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;