- Timestamp:
- Mar 14, 2001, 12:13:28 AM (24 years ago)
- Location:
- trunk/src/DPlayX
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/DPlayX/dplay.cpp
r4446 r5311 1 // $Id: dplay.cpp,v 1. 3 2000-10-06 19:49:03hugh Exp $1 // $Id: dplay.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ 2 2 /* Direct Play 2,3,4 Implementation 3 3 * … … 18 18 #include "winnt.h" 19 19 #include "winreg.h" 20 #include "winnls.h" 21 #include "wine/unicode.h" 20 22 #include "dplay.h" 21 23 #include "heap.h" … … 173 175 LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2, 174 176 LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ); 177 static HRESULT WINAPI DP_IF_InitializeConnection 178 ( IDirectPlay3Impl* This, LPVOID lpConnection, DWORD dwFlags, BOOL bAnsi ); 175 179 static BOOL CALLBACK cbDPCreateEnumConnections( LPCGUID lpguidSP, 176 180 LPVOID lpConnection, DWORD dwConnectionSize, LPCDPNAME lpName, … … 187 191 188 192 189 static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData );193 static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData, LPBOOL lpbIsDpSp ); 190 194 191 195 … … 254 258 DPQ_INIT(This->dp2->receiveMsgs); 255 259 DPQ_INIT(This->dp2->sendMsgs); 260 DPQ_INIT(This->dp2->replysExpected); 256 261 257 262 if( !NS_InitializeSessionCache( &This->dp2->lpNameServerData ) ) … … 518 523 519 524 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 520 sizeof( IDirectPlay2Impl) );525 sizeof( *This ) ); 521 526 522 527 if( *ppvObj == NULL ) … … 525 530 } 526 531 527 CopyMemory( *ppvObj, iface, sizeof( IDirectPlay2Impl ) ); 532 //CopyMemory( *ppvObj, iface, sizeof( IDirectPlay2Impl ) ); 533 CopyMemory( *ppvObj, This, sizeof( *This ) ); 528 534 (*(IDirectPlay2Impl**)ppvObj)->ulInterfaceRef = 0; 529 535 … … 627 633 628 634 /* *lplpReply will be non NULL iff there is something to reply */ 629 HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lp MessageBody,630 DWORD dwMessageBodySize, LPCVOID lp MessageHeader,635 HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpcMessageBody, 636 DWORD dwMessageBodySize, LPCVOID lpcMessageHeader, 631 637 WORD wCommandId, WORD wVersion, 632 638 LPVOID* lplpReply, LPDWORD lpdwMsgSize ) 633 639 { 634 640 TRACE( "(%p)->(%p,0x%08lx,%p,%u,%u)\n", 635 This, lp MessageBody, dwMessageBodySize, lpMessageHeader, wCommandId,641 This, lpcMessageBody, dwMessageBodySize, lpcMessageHeader, wCommandId, 636 642 wVersion ); 637 643 638 DebugBreak();639 644 640 645 switch( wCommandId ) … … 642 647 case DPMSGCMD_REQUESTNEWPLAYERID: 643 648 { 644 #if 0645 649 LPCDPMSG_REQUESTNEWPLAYERID lpcMsg = 646 (LPCDPMSG_REQUESTNEWPLAYERID)lpMessageBody; 647 #endif 650 (LPCDPMSG_REQUESTNEWPLAYERID)lpcMessageBody; 648 651 LPDPMSG_NEWPLAYERIDREPLY lpReply; 649 652 … … 654 657 *lpdwMsgSize ); 655 658 656 FIXME( "Ignoring dwFlags in request msg\n" ); 657 658 #if 0 659 /* This is just a test. See how large the SPData is and send it */ 660 { 661 LPVOID lpData; 662 DWORD dwDataSize; 663 HRESULT hr; 664 665 hr = IDirectPlaySP_GetSPData( This->dp2->spData.lpISP, &lpData, 666 &dwDataSize, DPSET_REMOTE ); 667 668 if( FAILED(hr) ) 669 { 670 ERR( "Unable to get remote SPData %s\n", DPLAYX_HresultToString(hr) ); 671 } 672 673 } 674 #endif 659 FIXME( "Ignoring dwFlags 0x%08lx in request msg\n", 660 lpcMsg->dwFlags ); 661 675 662 676 663 /* Setup the reply */ … … 690 677 } 691 678 679 case DPMSGCMD_GETNAMETABLEREPLY: 692 680 case DPMSGCMD_NEWPLAYERIDREPLY: 693 681 { 694 695 if( This->dp2->hMsgReceipt ) 696 { 697 /* This is a hack only */ 698 This->dp2->lpMsgReceived = HeapAlloc( GetProcessHeap(), 699 HEAP_ZERO_MEMORY, 700 dwMessageBodySize ); 701 CopyMemory( This->dp2->lpMsgReceived, lpMessageBody, dwMessageBodySize ); 702 SetEvent( This->dp2->hMsgReceipt ); 703 } 704 else 705 { 706 ERR( "No receipt event set - only expecting in reply mode\n" ); 707 } 682 DP_MSG_ReplyReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize ); 708 683 709 684 break; 710 685 } 711 686 687 case DPMSGCMD_FORWARDADDPLAYERNACK: 688 { 689 DP_MSG_ErrorReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize ); 690 break; 691 } 692 712 693 default: 713 694 { 714 695 FIXME( "Unknown wCommandId %u. Ignoring message\n", wCommandId ); 696 DebugBreak(); 715 697 break; 716 698 } … … 887 869 lpGData->dwFlags = dwFlags; 888 870 871 TRACE( "Created group id 0x%08lx\n", *lpid ); 872 889 873 return lpGData; 890 874 } … … 982 966 { 983 967 This->dp2->lpSysGroup = lpGData; 968 TRACE( "Inserting system group\n" ); 984 969 } 985 970 else … … 1163 1148 } 1164 1149 1150 /* Initialize the SP data section */ 1151 lpPData->lpSPPlayerData = DPSP_CreateSPPlayerData(); 1152 1153 TRACE( "Created player id 0x%08lx\n", *lpid ); 1154 1165 1155 return lpPData; 1166 1156 } … … 1170 1160 DP_DeleteDPNameStruct( LPDPNAME lpDPName ) 1171 1161 { 1172 HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName-> psn.lpszShortNameA );1173 HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName-> pln.lpszLongNameA );1162 HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->u1.lpszShortNameA ); 1163 HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->u2.lpszLongNameA ); 1174 1164 } 1175 1165 … … 1234 1224 1235 1225 /* Delete any existing pointers */ 1236 if( lpDst-> psn.lpszShortNameA )1237 { 1238 HeapFree( GetProcessHeap(), 0, lpDst-> psn.lpszShortNameA );1239 } 1240 1241 if( lpDst-> pln.lpszLongNameA )1242 { 1243 HeapFree( GetProcessHeap(), 0, lpDst-> psn.lpszShortNameA );1226 if( lpDst->u1.lpszShortNameA ) 1227 { 1228 HeapFree( GetProcessHeap(), 0, lpDst->u1.lpszShortNameA ); 1229 } 1230 1231 if( lpDst->u2.lpszLongNameA ) 1232 { 1233 HeapFree( GetProcessHeap(), 0, lpDst->u2.lpszLongNameA ); 1244 1234 } 1245 1235 … … 1249 1239 if( bAnsi ) 1250 1240 { 1251 if( lpSrc-> psn.lpszShortNameA )1252 { 1253 lpDst->psn.lpszShortNameA =1254 HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY,1255 lpSrc->psn.lpszShortNameA );1256 } 1257 if( lpSrc-> pln.lpszLongNameA )1258 { 1259 lpDst->pln.lpszLongNameA =1260 HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY,1261 lpSrc->pln.lpszLongNameA );1241 if( lpSrc->u1.lpszShortNameA ) 1242 { 1243 lpDst->u1.lpszShortNameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, 1244 strlen(lpSrc->u1.lpszShortNameA)+1 ); 1245 strcpy( lpDst->u1.lpszShortNameA, lpSrc->u1.lpszShortNameA ); 1246 } 1247 if( lpSrc->u2.lpszLongNameA ) 1248 { 1249 lpDst->u2.lpszLongNameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, 1250 strlen(lpSrc->u2.lpszLongNameA)+1 ); 1251 strcpy( lpDst->u2.lpszLongNameA, lpSrc->u2.lpszLongNameA ); 1262 1252 } 1263 1253 } 1264 1254 else 1265 1255 { 1266 if( lpSrc-> psn.lpszShortNameA )1267 { 1268 lpDst->psn.lpszShortName =1269 HEAP_strdupW( GetProcessHeap(), HEAP_ZERO_MEMORY,1270 lpSrc->psn.lpszShortName );1271 } 1272 if( lpSrc-> pln.lpszLongNameA )1273 { 1274 lpDst->pln.lpszLongName =1275 HEAP_strdupW( GetProcessHeap(), HEAP_ZERO_MEMORY,1276 lpSrc->pln.lpszLongName );1256 if( lpSrc->u1.lpszShortNameA ) 1257 { 1258 lpDst->u1.lpszShortName = (LPWSTR) HeapAlloc( GetProcessHeap(), 0, 1259 (strlenW(lpSrc->u1.lpszShortName)+1)*sizeof(WCHAR) ); 1260 strcpyW( lpDst->u1.lpszShortName, lpSrc->u1.lpszShortName ); 1261 } 1262 if( lpSrc->u2.lpszLongNameA ) 1263 { 1264 lpDst->u2.lpszLongName = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, 1265 (strlenW(lpSrc->u2.lpszLongName)+1)*sizeof(WCHAR) ); 1266 strcpyW( lpDst->u2.lpszLongName, lpSrc->u2.lpszLongName ); 1277 1267 } 1278 1268 } … … 1339 1329 lpPlayerData lpPData; 1340 1330 lpPlayerList lpPList; 1331 DWORD dwCreateFlags = 0; 1341 1332 1342 1333 TRACE( "(%p)->(%p,%p,%d,%p,0x%08lx,0x%08lx,%u)\n", … … 1352 1343 { 1353 1344 return DPERR_INVALIDPARAMS; 1345 } 1346 1347 /* Determine the creation flags for the player. These will be passed 1348 * to the name server if requesting a player id and to the SP when 1349 * informing it of the player creation 1350 */ 1351 { 1352 if( dwFlags & DPPLAYER_SERVERPLAYER ) 1353 { 1354 if( *lpidPlayer == DPID_SERVERPLAYER ) 1355 { 1356 /* Server player for the host interface */ 1357 dwCreateFlags |= DPLAYI_PLAYER_APPSERVER; 1358 } 1359 else if( *lpidPlayer == DPID_NAME_SERVER ) 1360 { 1361 /* Name server - master of everything */ 1362 dwCreateFlags |= (DPLAYI_PLAYER_NAMESRVR|DPLAYI_PLAYER_SYSPLAYER); 1363 } 1364 else 1365 { 1366 /* Server player for a non host interface */ 1367 dwCreateFlags |= DPLAYI_PLAYER_SYSPLAYER; 1368 } 1369 } 1370 1371 if( lpMsgHdr == NULL ) 1372 dwCreateFlags |= DPLAYI_PLAYER_PLAYERLOCAL; 1354 1373 } 1355 1374 … … 1374 1393 else 1375 1394 { 1376 hr = DP_MSG_SendRequestPlayerId( This, dw Flags, lpidPlayer );1395 hr = DP_MSG_SendRequestPlayerId( This, dwCreateFlags, lpidPlayer ); 1377 1396 1378 1397 if( FAILED(hr) ) … … 1390 1409 } 1391 1410 1411 /* FIXME: Should we be storing these dwFlags or the creation ones? */ 1392 1412 lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwFlags, 1393 1413 hEvent, bAnsi ); … … 1420 1440 { 1421 1441 DPSP_CREATEPLAYERDATA data; 1422 DWORD dwCreateFlags = 0;1423 1424 TRACE( "Calling SP CreatePlayer\n" );1425 1426 if( ( dwFlags & DPPLAYER_SERVERPLAYER ) &&1427 ( *lpidPlayer == DPID_SERVERPLAYER )1428 )1429 dwCreateFlags |= DPLAYI_PLAYER_APPSERVER;1430 1431 if( ( dwFlags & DPPLAYER_SERVERPLAYER ) &&1432 ( *lpidPlayer == DPID_NAME_SERVER )1433 )1434 dwCreateFlags |= (DPLAYI_PLAYER_NAMESRVR|DPLAYI_PLAYER_SYSPLAYER);1435 1436 if( lpMsgHdr == NULL )1437 dwCreateFlags |= DPLAYI_PLAYER_PLAYERLOCAL;1438 1442 1439 1443 data.idPlayer = *lpidPlayer; … … 1442 1446 data.lpISP = This->dp2->spData.lpISP; 1443 1447 1448 TRACE( "Calling SP CreatePlayer 0x%08lx: dwFlags: 0x%08lx lpMsgHdr: %p\n", 1449 *lpidPlayer, data.dwFlags, data.lpSPMessageHeader ); 1450 1444 1451 hr = (*This->dp2->spData.lpCB->CreatePlayer)( &data ); 1445 1452 } … … 1467 1474 if( FAILED(hr) ) 1468 1475 { 1469 ERR( "Failed to add player to sys group with sp: %s\n",1476 ERR( "Failed to add player to sys group with sp: %s\n", 1470 1477 DPLAYX_HresultToString(hr) ); 1471 1478 return hr; 1472 1479 } 1473 1480 1481 #if 1 1482 if( This->dp2->bHostInterface == FALSE ) 1483 { 1484 /* Let the name server know about the creation of this player */ 1485 /* FIXME: Is this only to be done for the creation of a server player or 1486 * is this used for regular players? If only for server players, move 1487 * this call to DP_SecureOpen(...); 1488 */ 1489 hr = DP_MSG_ForwardPlayerCreation( This, *lpidPlayer); 1490 } 1491 #else 1474 1492 /* Inform all other peers of the creation of a new player. If there are 1475 1493 * no peers keep this quiet. … … 1498 1516 sizeof( msg ), 0, 0, NULL, NULL, bAnsi ); 1499 1517 } 1518 #endif 1500 1519 1501 1520 return hr; … … 2069 2088 if( This->dp2->hEnumSessionThread != INVALID_HANDLE_VALUE ) 2070 2089 { 2071 TRACE( "Killing EnumSession thread\n" ); 2090 TRACE( "Killing EnumSession thread %u\n", 2091 This->dp2->hEnumSessionThread ); 2072 2092 2073 2093 /* Request that the thread kill itself nicely */ … … 2108 2128 dwTimeout = spCaps.dwTimeout; 2109 2129 2110 /* FIXME: If it's still 0, we need to provide the IP default */ 2130 /* The service provider doesn't provide one either! */ 2131 if( dwTimeout == 0 ) 2132 { 2133 /* Provide the TCP/IP default */ 2134 dwTimeout = DPMSG_WAIT_5_SECS; 2135 } 2111 2136 } 2112 2137 … … 2335 2360 dwRequiredDataSize = lpGData->name.dwSize; 2336 2361 2337 if( lpGData->name. psn.lpszShortNameA )2338 { 2339 dwRequiredDataSize += strlen( lpGData->name. psn.lpszShortNameA ) + 1;2340 } 2341 2342 if( lpGData->name. pln.lpszLongNameA )2343 { 2344 dwRequiredDataSize += strlen( lpGData->name. pln.lpszLongNameA ) + 1;2362 if( lpGData->name.u1.lpszShortNameA ) 2363 { 2364 dwRequiredDataSize += strlen( lpGData->name.u1.lpszShortNameA ) + 1; 2365 } 2366 2367 if( lpGData->name.u2.lpszLongNameA ) 2368 { 2369 dwRequiredDataSize += strlen( lpGData->name.u2.lpszLongNameA ) + 1; 2345 2370 } 2346 2371 … … 2356 2381 CopyMemory( lpName, &lpGData->name, lpGData->name.dwSize ); 2357 2382 2358 if( lpGData->name. psn.lpszShortNameA )2383 if( lpGData->name.u1.lpszShortNameA ) 2359 2384 { 2360 2385 strcpy( ((char*)lpName)+lpGData->name.dwSize, 2361 lpGData->name. psn.lpszShortNameA );2386 lpGData->name.u1.lpszShortNameA ); 2362 2387 } 2363 2388 else 2364 2389 { 2365 lpName-> psn.lpszShortNameA = NULL;2366 } 2367 2368 if( lpGData->name. psn.lpszShortNameA )2390 lpName->u1.lpszShortNameA = NULL; 2391 } 2392 2393 if( lpGData->name.u2.lpszLongNameA ) 2369 2394 { 2370 2395 strcpy( ((char*)lpName)+lpGData->name.dwSize, 2371 lpGData->name. pln.lpszLongNameA );2396 lpGData->name.u2.lpszLongNameA ); 2372 2397 } 2373 2398 else 2374 2399 { 2375 lpName-> pln.lpszLongNameA = NULL;2400 lpName->u2.lpszLongNameA = NULL; 2376 2401 } 2377 2402 … … 2535 2560 dwRequiredDataSize = lpPList->lpPData->name.dwSize; 2536 2561 2537 if( lpPList->lpPData->name. psn.lpszShortNameA )2538 { 2539 dwRequiredDataSize += strlen( lpPList->lpPData->name. psn.lpszShortNameA ) + 1;2540 } 2541 2542 if( lpPList->lpPData->name. pln.lpszLongNameA )2543 { 2544 dwRequiredDataSize += strlen( lpPList->lpPData->name. pln.lpszLongNameA ) + 1;2562 if( lpPList->lpPData->name.u1.lpszShortNameA ) 2563 { 2564 dwRequiredDataSize += strlen( lpPList->lpPData->name.u1.lpszShortNameA ) + 1; 2565 } 2566 2567 if( lpPList->lpPData->name.u2.lpszLongNameA ) 2568 { 2569 dwRequiredDataSize += strlen( lpPList->lpPData->name.u2.lpszLongNameA ) + 1; 2545 2570 } 2546 2571 … … 2556 2581 CopyMemory( lpName, &lpPList->lpPData->name, lpPList->lpPData->name.dwSize ); 2557 2582 2558 if( lpPList->lpPData->name. psn.lpszShortNameA )2583 if( lpPList->lpPData->name.u1.lpszShortNameA ) 2559 2584 { 2560 2585 strcpy( ((char*)lpName)+lpPList->lpPData->name.dwSize, 2561 lpPList->lpPData->name. psn.lpszShortNameA );2586 lpPList->lpPData->name.u1.lpszShortNameA ); 2562 2587 } 2563 2588 else 2564 2589 { 2565 lpName-> psn.lpszShortNameA = NULL;2566 } 2567 2568 if( lpPList->lpPData->name. psn.lpszShortNameA )2590 lpName->u1.lpszShortNameA = NULL; 2591 } 2592 2593 if( lpPList->lpPData->name.u2.lpszLongNameA ) 2569 2594 { 2570 2595 strcpy( ((char*)lpName)+lpPList->lpPData->name.dwSize, 2571 lpPList->lpPData->name. pln.lpszLongNameA );2596 lpPList->lpPData->name.u2.lpszLongNameA ); 2572 2597 } 2573 2598 else 2574 2599 { 2575 lpName-> pln.lpszLongNameA = NULL;2600 lpName->u2.lpszLongNameA = NULL; 2576 2601 } 2577 2602 … … 3137 3162 if( bAnsi ) 3138 3163 { 3139 if( lpSessDesc-> sess.lpszSessionNameA )3140 { 3141 dwSize += lstrlenA( lpSessDesc-> sess.lpszSessionNameA ) + 1;3142 } 3143 3144 if( lpSessDesc-> pass.lpszPasswordA )3145 { 3146 dwSize += lstrlenA( lpSessDesc-> pass.lpszPasswordA ) + 1;3164 if( lpSessDesc->u1.lpszSessionNameA ) 3165 { 3166 dwSize += lstrlenA( lpSessDesc->u1.lpszSessionNameA ) + 1; 3167 } 3168 3169 if( lpSessDesc->u2.lpszPasswordA ) 3170 { 3171 dwSize += lstrlenA( lpSessDesc->u2.lpszPasswordA ) + 1; 3147 3172 } 3148 3173 } 3149 3174 else /* UNICODE */ 3150 3175 { 3151 if( lpSessDesc-> sess.lpszSessionName )3176 if( lpSessDesc->u1.lpszSessionName ) 3152 3177 { 3153 3178 dwSize += sizeof( WCHAR ) * 3154 ( lstrlenW( lpSessDesc-> sess.lpszSessionName ) + 1 );3155 } 3156 3157 if( lpSessDesc-> pass.lpszPassword )3179 ( lstrlenW( lpSessDesc->u1.lpszSessionName ) + 1 ); 3180 } 3181 3182 if( lpSessDesc->u2.lpszPassword ) 3158 3183 { 3159 3184 dwSize += sizeof( WCHAR ) * 3160 ( lstrlenW( lpSessDesc-> pass.lpszPassword ) + 1 );3185 ( lstrlenW( lpSessDesc->u2.lpszPassword ) + 1 ); 3161 3186 } 3162 3187 } … … 3183 3208 if( bAnsi ) 3184 3209 { 3185 if( lpSessionSrc-> sess.lpszSessionNameA )3210 if( lpSessionSrc->u1.lpszSessionNameA ) 3186 3211 { 3187 3212 lstrcpyA( (LPSTR)lpStartOfFreeSpace, 3188 lpSessionDest-> sess.lpszSessionNameA );3189 lpSessionDest-> sess.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;3213 lpSessionDest->u1.lpszSessionNameA ); 3214 lpSessionDest->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace; 3190 3215 lpStartOfFreeSpace += 3191 lstrlenA( (LPSTR)lpSessionDest-> sess.lpszSessionNameA ) + 1;3192 } 3193 3194 if( lpSessionSrc-> pass.lpszPasswordA )3216 lstrlenA( (LPSTR)lpSessionDest->u1.lpszSessionNameA ) + 1; 3217 } 3218 3219 if( lpSessionSrc->u2.lpszPasswordA ) 3195 3220 { 3196 3221 lstrcpyA( (LPSTR)lpStartOfFreeSpace, 3197 lpSessionDest-> pass.lpszPasswordA );3198 lpSessionDest-> pass.lpszPasswordA = (LPSTR)lpStartOfFreeSpace;3222 lpSessionDest->u2.lpszPasswordA ); 3223 lpSessionDest->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace; 3199 3224 lpStartOfFreeSpace += 3200 lstrlenA( (LPSTR)lpSessionDest-> pass.lpszPasswordA ) + 1;3225 lstrlenA( (LPSTR)lpSessionDest->u2.lpszPasswordA ) + 1; 3201 3226 } 3202 3227 } 3203 3228 else /* UNICODE */ 3204 3229 { 3205 if( lpSessionSrc-> sess.lpszSessionName )3230 if( lpSessionSrc->u1.lpszSessionName ) 3206 3231 { 3207 3232 lstrcpyW( (LPWSTR)lpStartOfFreeSpace, 3208 lpSessionDest-> sess.lpszSessionName );3209 lpSessionDest-> sess.lpszSessionName = (LPWSTR)lpStartOfFreeSpace;3233 lpSessionDest->u1.lpszSessionName ); 3234 lpSessionDest->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace; 3210 3235 lpStartOfFreeSpace += sizeof(WCHAR) * 3211 ( lstrlenW( (LPWSTR)lpSessionDest-> sess.lpszSessionName ) + 1 );3212 } 3213 3214 if( lpSessionSrc-> pass.lpszPassword )3236 ( lstrlenW( (LPWSTR)lpSessionDest->u1.lpszSessionName ) + 1 ); 3237 } 3238 3239 if( lpSessionSrc->u2.lpszPassword ) 3215 3240 { 3216 3241 lstrcpyW( (LPWSTR)lpStartOfFreeSpace, 3217 lpSessionDest-> pass.lpszPassword );3218 lpSessionDest-> pass.lpszPassword = (LPWSTR)lpStartOfFreeSpace;3242 lpSessionDest->u2.lpszPassword ); 3243 lpSessionDest->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace; 3219 3244 lpStartOfFreeSpace += sizeof(WCHAR) * 3220 ( lstrlenW( (LPWSTR)lpSessionDest-> pass.lpszPassword ) + 1 );3245 ( lstrlenW( (LPWSTR)lpSessionDest->u2.lpszPassword ) + 1 ); 3221 3246 } 3222 3247 } … … 3499 3524 DWORD returnTypeGUID, sizeOfReturnBuffer = 50; 3500 3525 char returnBuffer[51]; 3501 LPWSTR lpWGUIDString;3526 WCHAR buff[51]; 3502 3527 DPNAME dpName; 3503 3528 HRESULT hr; … … 3526 3551 3527 3552 /* FIXME: Check return types to ensure we're interpreting data right */ 3528 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer ); 3529 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID ); 3530 HeapFree( GetProcessHeap(), 0, lpWGUIDString ); 3553 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) ); 3554 CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID ); 3531 3555 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */ 3532 3556 … … 3534 3558 dpName.dwSize = sizeof( dpName ); 3535 3559 dpName.dwFlags = 0; 3536 dpName. psn.lpszShortNameA = subKeyName;3537 dpName. pln.lpszLongNameA = NULL;3560 dpName.u1.lpszShortNameA = subKeyName; 3561 dpName.u2.lpszLongNameA = NULL; 3538 3562 3539 3563 /* Create the compound address for the service provider. 3540 NOTE: This is a gruesome architectural scar right now. DP uses DPL and DPL uses DP 3541 nast stuff. This may be why the native dll just gets around this little bit by3542 allocating an 80 byte buffer which isn't even afilled with a valid compound3543 address. Oh well. Creating a proper compound address is the way to go anyway s3564 NOTE: This is a gruesome architectural scar right now. DP uses DPL and DPL uses DP, 3565 nasty stuff. This may be why the native dll just gets around this little bit by 3566 allocating an 80 byte buffer which isn't even filled with a valid compound 3567 address. Oh well. Creating a proper compound address is the way to go anyway ... 3544 3568 despite this method taking slightly more heap space and realtime :) */ 3545 3569 dpCompoundAddress.dwDataSize = sizeof( GUID ); … … 3605 3629 DWORD returnTypeGUID, sizeOfReturnBuffer = 50; 3606 3630 char returnBuffer[51]; 3607 LPWSTR lpWGUIDString;3631 WCHAR buff[51]; 3608 3632 DPNAME dpName; 3609 3633 HRESULT hr; … … 3632 3656 3633 3657 /* FIXME: Check return types to ensure we're interpreting data right */ 3634 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer ); 3635 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID ); 3636 HeapFree( GetProcessHeap(), 0, lpWGUIDString ); 3658 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) ); 3659 CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID ); 3637 3660 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */ 3638 3661 … … 3640 3663 dpName.dwSize = sizeof( dpName ); 3641 3664 dpName.dwFlags = 0; 3642 dpName. psn.lpszShortNameA = subKeyName;3643 dpName. pln.lpszLongNameA = NULL;3665 dpName.u1.lpszShortNameA = subKeyName; 3666 dpName.u2.lpszLongNameA = NULL; 3644 3667 3645 3668 /* Create the compound address for the service provider. 3646 NOTE: This is a gruesome architectural scar right now. DP uses DPL and DPL uses DP 3647 nast stuff. This may be why the native dll just gets around this little bit by3648 allocating an 80 byte buffer which isn't even afilled with a valid compound3649 address. Oh well. Creating a proper compound address is the way to go anyway s3669 NOTE: This is a gruesome architectural scar right now. DP uses DPL and DPL uses DP, 3670 nasty stuff. This may be why the native dll just gets around this little bit by 3671 allocating an 80 byte buffer which isn't even filled with a valid compound 3672 address. Oh well. Creating a proper compound address is the way to go anyway ... 3650 3673 despite this method taking slightly more heap space and realtime :) */ 3651 3674 dpCompoundAddress.guidDataType = DPAID_LobbyProvider; … … 3806 3829 3807 3830 /* Find and perform a LoadLibrary on the requested SP or LP GUID */ 3808 static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData )3831 static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData, LPBOOL lpbIsDpSp ) 3809 3832 { 3810 3833 UINT i; … … 3828 3851 3829 3852 (i == 0) ? (searchSubKey = spSubKey ) : (searchSubKey = lpSubKey ); 3853 *lpbIsDpSp = (i == 0) ? TRUE : FALSE; 3830 3854 3831 3855 … … 3850 3874 DWORD returnType, sizeOfReturnBuffer = 255; 3851 3875 char returnBuffer[256]; 3852 LPWSTR lpWGUIDString;3853 DWORD dwTemp ;3876 WCHAR buff[51]; 3877 DWORD dwTemp, len; 3854 3878 3855 3879 TRACE(" this time through: %s\n", subKeyName ); … … 3872 3896 3873 3897 /* FIXME: Check return types to ensure we're interpreting data right */ 3874 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer ); 3875 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID ); 3876 HeapFree( GetProcessHeap(), 0, lpWGUIDString ); 3898 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) ); 3899 CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID ); 3877 3900 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */ 3878 3901 … … 3884 3907 3885 3908 /* Save the name of the SP or LP */ 3886 lpSpData->lpszName = HEAP_strdupAtoW( GetProcessHeap(), 0, subKeyName ); 3909 len = MultiByteToWideChar( CP_ACP, 0, subKeyName, -1, NULL, 0 ); 3910 lpSpData->lpszName = (WCHAR*)HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); 3911 MultiByteToWideChar( CP_ACP, 0, subKeyName, -1, lpSpData->lpszName, len ); 3887 3912 3888 3913 sizeOfReturnBuffer = 255; … … 3924 3949 } 3925 3950 3951 TRACE( "Loading %s\n", returnBuffer ); 3926 3952 return LoadLibraryA( returnBuffer ); 3927 3953 } … … 3931 3957 } 3932 3958 3933 static HRESULT WINAPI D irectPlay3AImpl_InitializeConnection3934 ( LPDIRECTPLAY3A iface, LPVOID lpConnection, DWORD dwFlags)3959 static HRESULT WINAPI DP_IF_InitializeConnection 3960 ( IDirectPlay3Impl* This, LPVOID lpConnection, DWORD dwFlags, BOOL bAnsi ) 3935 3961 { 3936 3962 HMODULE hServiceProvider; … … 3938 3964 LPDPSP_SPINIT SPInit; 3939 3965 GUID guidSP; 3940 DWORD dwAddrSize = 80; /* FIXME: Need to calculate it correctly */ 3941 3942 ICOM_THIS(IDirectPlay3Impl,iface); 3943 3944 TRACE("(%p)->(%p,0x%08lx)\n", This, lpConnection, dwFlags ); 3966 const DWORD dwAddrSize = 80; /* FIXME: Need to calculate it correctly */ 3967 BOOL bIsDpSp; /* TRUE if Direct Play SP, FALSE if Direct Play Lobby SP */ 3968 3969 TRACE("(%p)->(%p,0x%08lx,%u)\n", This, lpConnection, dwFlags, bAnsi ); 3945 3970 3946 3971 if( dwFlags != 0 ) … … 3972 3997 3973 3998 /* Load the service provider */ 3974 hServiceProvider = DP_LoadSP( &guidSP, &This->dp2->spData );3999 hServiceProvider = DP_LoadSP( &guidSP, &This->dp2->spData, &bIsDpSp ); 3975 4000 3976 4001 if( hServiceProvider == 0 ) … … 3980 4005 } 3981 4006 3982 /* Initialize the service provider by calling SPInit */ 3983 SPInit = (LPDPSP_SPINIT)GetProcAddress( hServiceProvider, "SPInit" ); 4007 if( bIsDpSp ) 4008 { 4009 /* Initialize the service provider by calling SPInit */ 4010 SPInit = (LPDPSP_SPINIT)GetProcAddress( hServiceProvider, "SPInit" ); 4011 } 4012 else 4013 { 4014 /* Initialize the service provider by calling SPInit */ 4015 SPInit = (LPDPSP_SPINIT)GetProcAddress( hServiceProvider, "DPLSPInit" ); 4016 } 3984 4017 3985 4018 if( SPInit == NULL ) 3986 4019 { 3987 ERR( "Service provider doesn't provide SPInit interface?\n" ); 4020 ERR( "Service provider doesn't provide %s interface?\n", 4021 bIsDpSp ? "SPInit" : "DPLSPInit" ); 3988 4022 FreeLibrary( hServiceProvider ); 3989 4023 return DPERR_UNAVAILABLE; 3990 4024 } 3991 4025 3992 TRACE( "Calling SPInit\n" ); 4026 TRACE( "Calling %s (SP entry point)\n", bIsDpSp ? "SPInit" : "DPLSPInit" ); 4027 4028 /* FIXME: Need to break this out into a separate routine for DP SP and 4029 * DPL SP as they actually use different stuff... 4030 */ 3993 4031 hr = (*SPInit)( &This->dp2->spData ); 3994 4032 3995 4033 if( FAILED(hr) ) 3996 4034 { 3997 ERR( " SP Initialization failed: %s\n", DPLAYX_HresultToString(hr) );4035 ERR( "DP/DPL SP Initialization failed: %s\n", DPLAYX_HresultToString(hr) ); 3998 4036 FreeLibrary( hServiceProvider ); 3999 4037 return hr; … … 4009 4047 } 4010 4048 4049 static HRESULT WINAPI DirectPlay3AImpl_InitializeConnection 4050 ( LPDIRECTPLAY3A iface, LPVOID lpConnection, DWORD dwFlags ) 4051 { 4052 ICOM_THIS(IDirectPlay3Impl,iface); 4053 return DP_IF_InitializeConnection( This, lpConnection, dwFlags, TRUE ); 4054 } 4055 4011 4056 static HRESULT WINAPI DirectPlay3WImpl_InitializeConnection 4012 4057 ( LPDIRECTPLAY3 iface, LPVOID lpConnection, DWORD dwFlags ) 4013 4058 { 4014 4059 ICOM_THIS(IDirectPlay3Impl,iface); 4015 FIXME("(%p)->(%p,0x%08lx): stub\n", This, lpConnection, dwFlags ); 4016 return DP_OK; 4060 return DP_IF_InitializeConnection( This, lpConnection, dwFlags, FALSE ); 4017 4061 } 4018 4062 … … 4816 4860 }; 4817 4861 4862 extern 4863 HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, 4864 DPID idPlayer, 4865 LPVOID* lplpData ) 4866 { 4867 lpPlayerList lpPlayer = DP_FindPlayer( lpDP, idPlayer ); 4868 4869 if( lpPlayer == NULL ) 4870 { 4871 return DPERR_INVALIDPLAYER; 4872 } 4873 4874 *lplpData = lpPlayer->lpPData->lpSPPlayerData; 4875 4876 return DP_OK; 4877 } 4878 4879 extern 4880 HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, 4881 DPID idPlayer, 4882 LPVOID lpData ) 4883 { 4884 lpPlayerList lpPlayer = DP_FindPlayer( lpDP, idPlayer ); 4885 4886 if( lpPlayer == NULL ) 4887 { 4888 return DPERR_INVALIDPLAYER; 4889 } 4890 4891 lpPlayer->lpPData->lpSPPlayerData = lpData; 4892 4893 return DP_OK; 4894 } 4818 4895 4819 4896 /*************************************************************************** 4820 * DirectPlayEnumerateA (DPLAYX.2)4897 * DirectPlayEnumerateA [DPLAYX.2][DPLAYX.9][DPLAY.2] 4821 4898 * 4822 4899 * The pointer to the structure lpContext will be filled with the … … 4882 4959 DWORD returnTypeGUID, returnTypeReserved, sizeOfReturnBuffer = 50; 4883 4960 char returnBuffer[51]; 4961 WCHAR buff[51]; 4884 4962 DWORD majVersionNum , minVersionNum = 0; 4885 LPWSTR lpWGUIDString;4886 4963 4887 4964 TRACE(" this time through: %s\n", subKeyName ); … … 4907 4984 4908 4985 /* FIXME: Check return types to ensure we're interpreting data right */ 4909 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer ); 4910 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID ); 4911 HeapFree( GetProcessHeap(), 0, lpWGUIDString ); 4986 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) ); 4987 CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID ); 4912 4988 4913 4989 /* FIXME: Need to know which of dwReserved1 and dwReserved2 are maj and min */ … … 4950 5026 4951 5027 /*************************************************************************** 4952 * DirectPlayEnumerateW ( DPLAYX.3)5028 * DirectPlayEnumerateW ([DPLAYX.3] 4953 5029 * 4954 5030 */ … … 4997 5073 4998 5074 /*************************************************************************** 4999 * DirectPlayCreate (DPLAYX.1) (DPLAY.1)5075 * DirectPlayCreate [DPLAYX.1][DPLAY.1] 5000 5076 * 5001 5077 */ … … 5014 5090 } 5015 5091 5016 5017 /* Create an IDirectPlay object. We don't support that so we'll cheat and 5092 /* Create an IDirectPlay object. We don't support that so we'll cheat and 5018 5093 give them an IDirectPlay2A object and hope that doesn't cause problems */ 5019 5094 if( DP_CreateInterface( &IID_IDirectPlay2A, (LPVOID*)lplpDP ) != DP_OK ) -
trunk/src/DPlayX/dplay_global.h
r4317 r5311 1 // $Id: dplay_global.h,v 1. 2 2000-09-24 22:47:40hugh Exp $1 // $Id: dplay_global.h,v 1.3 2001-03-13 23:13:28 hugh Exp $ 2 2 #ifndef __WINE_DPLAY_GLOBAL_INCLUDED 3 3 #define __WINE_DPLAY_GLOBAL_INCLUDED … … 37 37 } EnumSessionAsyncCallbackData; 38 38 39 typedef struct tagDP_MSG_REPLY_STRUCT 40 { 41 HANDLE hReceipt; 42 WORD wExpectedReply; 43 LPVOID lpReplyMsg; 44 DWORD dwMsgBodySize; 45 /* FIXME: Is the message header required as well? */ 46 } DP_MSG_REPLY_STRUCT, *LPDP_MSG_REPLY_STRUCT; 47 48 typedef struct tagDP_MSG_REPLY_STRUCT_LIST 49 { 50 DPQ_ENTRY(tagDP_MSG_REPLY_STRUCT_LIST) replysExpected; 51 DP_MSG_REPLY_STRUCT replyExpected; 52 } DP_MSG_REPLY_STRUCT_LIST, *LPDP_MSG_REPLY_STRUCT_LIST; 53 39 54 struct PlayerData 40 55 { … … 55 70 DWORD dwRemoteDataSize; 56 71 72 /* SP data on a per player basis */ 73 LPVOID lpSPPlayerData; 74 57 75 DWORD dwFlags; /* Special remarks about the type of player */ 58 76 }; … … 139 157 BOOL bConnectionInitialized; 140 158 141 142 /* proof of concept for message reception */ 143 HANDLE hMsgReceipt; 144 LPVOID lpMsgReceived; 159 /* Expected messages queue */ 160 DPQ_HEAD( tagDP_MSG_REPLY_STRUCT_LIST ) replysExpected; 145 161 } DirectPlay2Data; 146 162 … … 194 210 LPVOID* lplpReply, LPDWORD lpdwMsgSize ); 195 211 212 /* DP SP external interfaces into DirectPlay */ 213 extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData ); 214 extern HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID lpData ); 215 216 /* DP external interfaces to call into DPSP interface */ 217 extern LPVOID DPSP_CreateSPPlayerData(void); 196 218 197 219 #endif /* __WINE_DPLAY_GLOBAL_INCLUDED */ -
trunk/src/DPlayX/dplaysp.cpp
r4446 r5311 1 // $Id: dplaysp.cpp,v 1. 3 2000-10-06 19:49:04hugh Exp $1 // $Id: dplaysp.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ 2 2 /* This contains the implementation of the interface Service 3 3 * Providers require to communicate with Direct Play … … 58 58 IDirectPlay2Impl* dplay; /* FIXME: This should perhaps be iface not impl */ 59 59 60 LPVOID lpPlayerData; /* FIXME: Need to figure out how this actually behaves */61 DWORD dwPlayerDataSize;62 60 } DirectPlaySPData; 63 61 … … 75 73 /* Forward declaration of virtual tables */ 76 74 extern ICOM_VTABLE(IDirectPlaySP) directPlaySPVT; 75 76 /* This structure is passed to the DP object for safe keeping */ 77 typedef struct tagDP_SPPLAYERDATA 78 { 79 LPVOID lpPlayerLocalData; 80 DWORD dwPlayerLocalDataSize; 81 82 LPVOID lpPlayerRemoteData; 83 DWORD dwPlayerRemoteDataSize; 84 } DP_SPPLAYERDATA, *LPDP_SPPLAYERDATA; 77 85 78 86 … … 177 185 /* IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp ); */ 178 186 187 /* FIXME: This is a kludge to get around a problem where a queryinterface 188 * is used to get a new interface and then is closed. We will then 189 * reference garbage. However, with this we will never deallocate 190 * the interface we store. The correct fix is to require all 191 * DP internal interfaces to use the This->dp2 interface which 192 * should be changed to This->dp 193 */ 194 IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp ); 195 179 196 return TRUE; 180 197 } … … 375 392 ) 376 393 { 377 ICOM_THIS(IDirectPlaySPImpl,iface); 378 379 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 380 FIXME( "(%p)->(0x%08lx,%p,%p,0x%08lx): stub\n", 394 HRESULT hr; 395 LPDP_SPPLAYERDATA lpPlayerData; 396 ICOM_THIS(IDirectPlaySPImpl,iface); 397 398 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 399 TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx)\n", 381 400 This, idPlayer, lplpData, lpdwDataSize, dwFlags ); 382 401 402 hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerData ); 403 404 if( FAILED(hr) ) 405 { 406 TRACE( "Couldn't get player data: %s\n", DPLAYX_HresultToString(hr) ); 407 return DPERR_INVALIDPLAYER; 408 } 409 383 410 /* What to do in the case where there is nothing set yet? */ 384 385 *lplpData = This->sp->lpPlayerData; 386 *lpdwDataSize = This->sp->dwPlayerDataSize; 387 388 return DP_OK; 411 if( dwFlags == DPSET_LOCAL ) 412 { 413 if( lpPlayerData->lpPlayerLocalData ) 414 { 415 HeapFree( GetProcessHeap(), 0, lpPlayerData->lpPlayerLocalData ); 416 } 417 418 *lplpData = lpPlayerData->lpPlayerLocalData; 419 *lpdwDataSize = lpPlayerData->dwPlayerLocalDataSize; 420 } 421 else if( dwFlags == DPSET_REMOTE ) 422 { 423 if( lpPlayerData->lpPlayerRemoteData ) 424 { 425 HeapFree( GetProcessHeap(), 0, lpPlayerData->lpPlayerRemoteData ); 426 } 427 428 *lplpData = lpPlayerData->lpPlayerRemoteData; 429 *lpdwDataSize = lpPlayerData->dwPlayerRemoteDataSize; 430 } 431 432 if( *lplpData == NULL ) 433 { 434 hr = DPERR_GENERIC; 435 } 436 437 return hr; 389 438 } 390 439 … … 403 452 ICOM_THIS(IDirectPlaySPImpl,iface); 404 453 405 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 454 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 406 455 FIXME( "(%p)->(%p,0x%08lx,%p): mostly stub\n", 407 456 This, lpMessageBody, dwMessageBodySize, lpMessageHeader ); … … 421 470 { 422 471 /* Name server needs to handle this request */ 472 /* FIXME: This should be done in direct play handler */ 423 473 case DPMSGCMD_ENUMSESSIONSREQUEST: 424 474 { … … 442 492 443 493 /* Name server needs to handle this request */ 494 /* FIXME: This should be done in direct play handler */ 444 495 case DPMSGCMD_ENUMSESSIONSREPLY: 445 496 { … … 450 501 451 502 /* No reply expected */ 452 453 break; 454 } 455 456 case DPMSGCMD_GETNAMETABLE: 457 case DPMSGCMD_GETNAMETABLEREPLY: 458 case DPMSGCMD_NEWPLAYERIDREPLY: 459 case DPMSGCMD_REQUESTNEWPLAYERID: 503 hr = DP_OK; 504 505 break; 506 } 507 508 /* Pass everything else to Direct Play */ 509 default: 460 510 { 461 511 DPSP_REPLYDATA data; … … 465 515 466 516 /* Pass this message to the dplay interface to handle */ 467 DP_HandleMessage( This->sp->dplay, lpMessageBody, dwMessageBodySize,517 hr = DP_HandleMessage( This->sp->dplay, lpMessageBody, dwMessageBodySize, 468 518 lpMessageHeader, wCommandId, wVersion, 469 519 &data.lpMessage, &data.dwMessageSize ); … … 488 538 break; 489 539 } 490 491 default:492 FIXME( "Unknown Command of %u and size 0x%08lx\n",493 lpMsg->wCommandId, dwMessageBodySize );494 540 } 495 541 … … 748 794 ) 749 795 { 750 ICOM_THIS(IDirectPlaySPImpl,iface);751 752 /* FIXME: I'm not sure if this stuff should be associated with the DPlay753 * player lists. How else would this stuff get deleted? 754 */755 756 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 757 FIXME( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx): stub\n",796 HRESULT hr; 797 LPDP_SPPLAYERDATA lpPlayerEntry; 798 LPVOID lpPlayerData; 799 800 ICOM_THIS(IDirectPlaySPImpl,iface); 801 802 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 803 TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx)\n", 758 804 This, idPlayer, lpData, dwDataSize, dwFlags ); 759 805 760 This->sp->lpPlayerData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize ); 761 762 This->sp->dwPlayerDataSize = dwDataSize; 763 CopyMemory( This->sp->lpPlayerData, lpData, dwDataSize ); 764 765 return DP_OK; 806 hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerEntry ); 807 if( FAILED(hr) ) 808 { 809 /* Player must not exist */ 810 return DPERR_INVALIDPLAYER; 811 } 812 813 lpPlayerData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize ); 814 CopyMemory( lpPlayerData, lpData, dwDataSize ); 815 816 if( dwFlags == DPSET_LOCAL ) 817 { 818 lpPlayerEntry->lpPlayerLocalData = lpPlayerData; 819 lpPlayerEntry->dwPlayerLocalDataSize = dwDataSize; 820 } 821 else if( dwFlags == DPSET_REMOTE ) 822 { 823 lpPlayerEntry->lpPlayerRemoteData = lpPlayerData; 824 lpPlayerEntry->dwPlayerRemoteDataSize = dwDataSize; 825 } 826 827 hr = DP_SetSPPlayerData( This->sp->dplay, idPlayer, lpPlayerEntry ); 828 829 return hr; 766 830 } 767 831 … … 789 853 ) 790 854 { 791 ICOM_THIS(IDirectPlaySPImpl,iface); 792 793 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 855 HRESULT hr = DP_OK; 856 ICOM_THIS(IDirectPlaySPImpl,iface); 857 858 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 794 859 TRACE( "(%p)->(%p,%p,0x%08lx)\n", 795 860 This, lplpData, lpdwDataSize, dwFlags ); … … 797 862 #if 0 798 863 /* This is what the documentation says... */ 799 if( dwFlags != 0)864 if( dwFlags != DPSET_REMOTE ) 800 865 { 801 866 return DPERR_INVALIDPARAMS; … … 806 871 * thing? 807 872 */ 808 if( dwFlags != 0)873 if( dwFlags != DPSET_REMOTE ) 809 874 { 810 875 FIXME( "Undocumented dwFlags 0x%08lx used\n", dwFlags ); 811 876 } 812 877 #endif 878 879 /* FIXME: What to do in the case where this isn't initialized yet? */ 813 880 814 881 /* Yes, we're supposed to return a pointer to the memory we have stored! */ … … 817 884 *lpdwDataSize = This->sp->dwSpRemoteDataSize; 818 885 *lplpData = This->sp->lpSpRemoteData; 886 887 if( This->sp->lpSpRemoteData == NULL ) 888 { 889 hr = DPERR_GENERIC; 890 } 819 891 } 820 892 else if( dwFlags == DPSET_LOCAL ) … … 822 894 *lpdwDataSize = This->sp->dwSpLocalDataSize; 823 895 *lplpData = This->sp->lpSpLocalData; 824 } 825 826 return DP_OK; 896 897 if( This->sp->lpSpLocalData == NULL ) 898 { 899 hr = DPERR_GENERIC; 900 } 901 } 902 903 return hr; 827 904 } 828 905 … … 838 915 ICOM_THIS(IDirectPlaySPImpl,iface); 839 916 840 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 917 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 841 918 TRACE( "(%p)->(%p,0x%08lx,0x%08lx)\n", 842 919 This, lpData, dwDataSize, dwFlags ); … … 844 921 #if 0 845 922 /* This is what the documentation says... */ 846 if( dwFlags != 0)923 if( dwFlags != DPSET_REMOTE ) 847 924 { 848 925 return DPERR_INVALIDPARAMS; … … 853 930 * thing? 854 931 */ 855 if( dwFlags != 0)932 if( dwFlags != DPSET_REMOTE ) 856 933 { 857 934 FIXME( "Undocumented dwFlags 0x%08lx used\n", dwFlags ); … … 859 936 #endif 860 937 861 if( dwFlags == DPSET_REMOTE ) 862 { 863 lpSpData = DPLAYX_PrivHeapAlloc( HEAP_ZERO_MEMORY, dwDataSize ); 864 } 865 else 866 { 867 lpSpData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize ); 868 } 869 938 lpSpData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize ); 870 939 CopyMemory( lpSpData, lpData, dwDataSize ); 871 940 … … 873 942 if( dwFlags == DPSET_REMOTE ) 874 943 { 875 /* FIXME: This doesn't strictly make sense as there is no means to share876 * this shared data. Must be misinterpreting something...877 */878 944 if( This->sp->lpSpRemoteData ) 879 945 { 880 DPLAYX_PrivHeapFree( This->sp->lpSpRemoteData ); 881 } 882 883 /* NOTE: dwDataSize is also stored in the heap structure */ 946 HeapFree( GetProcessHeap(), 0, This->sp->lpSpRemoteData ); 947 } 948 884 949 This->sp->dwSpRemoteDataSize = dwDataSize; 885 950 This->sp->lpSpRemoteData = lpSpData; … … 933 998 IDirectPlaySPImpl_SendComplete 934 999 }; 1000 1001 1002 /* DP external interfaces to call into DPSP interface */ 1003 1004 /* Allocate the structure */ 1005 extern LPVOID DPSP_CreateSPPlayerData(void) 1006 { 1007 TRACE( "Creating SPPlayer data struct\n" ); 1008 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 1009 sizeof( DP_SPPLAYERDATA ) ); 1010 } 1011 -
trunk/src/DPlayX/dplaysp.h
r4317 r5311 1 // $Id: dplaysp.h,v 1. 2 2000-09-24 22:47:39hugh Exp $1 // $Id: dplaysp.h,v 1.3 2001-03-13 23:13:28 hugh Exp $ 2 2 #ifndef __WINE_DIRECT_PLAY_SP_H 3 3 #define __WINE_DIRECT_PLAY_SP_H … … 57 57 #undef ICOM_INTERFACE 58 58 59 /* NOTE: The microsoft provided header file doesn't have these access 60 * functions 61 */ 59 62 /*** IUnknown methods ***/ 60 #define IDirectPlaySP_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)61 #define IDirectPlaySP_AddRef(p) ICOM_CALL (AddRef,p)62 #define IDirectPlaySP_Release(p) ICOM_CALL (Release,p)63 #define IDirectPlaySP_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) 64 #define IDirectPlaySP_AddRef(p) ICOM_CALL (AddRef,p) 65 #define IDirectPlaySP_Release(p) ICOM_CALL (Release,p) 63 66 /*** IDirectPlaySP methods ***/ 64 #define IDirectPlaySP_AddMRUEntry 65 #define IDirectPlaySP_CreateAddress 66 #define IDirectPlaySP_EnumAddress 67 #define IDirectPlaySP_EnumMRUEntries 68 #define IDirectPlaySP_GetPlayerFlags ICOM_CALL2(GetPlayerFlags,p,a,b)69 #define IDirectPlaySP_GetSPPlayerData 70 #define IDirectPlaySP_HandleMessage 71 #define IDirectPlaySP_SetSPPlayerData 72 #define IDirectPlaySP_CreateCompoundAddress ICOM_CALL4(CreateCompoundAddress,p,a,b,c,d)73 #define IDirectPlaySP_GetSPData 74 #define IDirectPlaySP_SetSPData 75 #define IDirectPlaySP_SendComplete ICOM_CALL2(SendComplete,p,a,b)67 #define IDirectPlaySP_AddMRUEntry(p,a,b,c,d,e) ICOM_CALL5(AddMRUEntry,p,a,b,c,d,e) 68 #define IDirectPlaySP_CreateAddress(p,a,b,c,d,e,f) ICOM_CALL6(CreateAddress,p,a,b,c,d,e,f) 69 #define IDirectPlaySP_EnumAddress(p,a,b,c,d) ICOM_CALL4(EnumAddress,p,a,b,c,d) 70 #define IDirectPlaySP_EnumMRUEntries(p,a,b,c,d) ICOM_CALL4(EnumMRUEntries,p,a,b,c,d) 71 #define IDirectPlaySP_GetPlayerFlags(p,a,b) ICOM_CALL2(GetPlayerFlags,p,a,b) 72 #define IDirectPlaySP_GetSPPlayerData(p,a,b,c,d) ICOM_CALL4(GetSPPlayerData,p,a,b,c,d) 73 #define IDirectPlaySP_HandleMessage(p,a,b,c) ICOM_CALL3(HandleMessage,p,a,b,c) 74 #define IDirectPlaySP_SetSPPlayerData(p,a,b,c,d) ICOM_CALL4(SetSPPlayerData,p,a,b,c,d) 75 #define IDirectPlaySP_CreateCompoundAddress(p,a,b,c,d) ICOM_CALL4(CreateCompoundAddress,p,a,b,c,d) 76 #define IDirectPlaySP_GetSPData(p,a,b,c) ICOM_CALL3(GetSPData,p,a,b,c) 77 #define IDirectPlaySP_SetSPData(p,a,b,c) ICOM_CALL3(SetSPData,p,a,b,c) 78 #define IDirectPlaySP_SendComplete(p,a,b) ICOM_CALL2(SendComplete,p,a,b) 76 79 77 80 /* SP Callback stuff */ … … 333 336 * SP directly 334 337 */ 335 extern __declspec(dllimport) DWORD gdwDPlaySPRefCount; 338 //extern __declspec(dllimport) DWORD gdwDPlaySPRefCount; 339 extern DWORD gdwDPlaySPRefCount; 336 340 337 341 #endif -
trunk/src/DPlayX/dplayx_global.cpp
r4446 r5311 1 // $Id: dplayx_global.cpp,v 1. 3 2000-10-06 19:49:05hugh Exp $1 // $Id: dplayx_global.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ 2 2 /* dplayx.dll global data implementation. 3 3 * … … 659 659 660 660 /* Session names may or may not exist */ 661 if( src->lpSessionDesc-> sess.lpszSessionNameA )662 { 663 strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc-> sess.lpszSessionNameA );664 dest->lpSessionDesc-> sess.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;661 if( src->lpSessionDesc->u1.lpszSessionNameA ) 662 { 663 strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionNameA ); 664 dest->lpSessionDesc->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace; 665 665 lpStartOfFreeSpace += 666 strlen( (LPSTR)dest->lpSessionDesc-> sess.lpszSessionNameA ) + 1;667 } 668 669 if( src->lpSessionDesc-> pass.lpszPasswordA )670 { 671 strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc-> pass.lpszPasswordA );672 dest->lpSessionDesc-> pass.lpszPasswordA = (LPSTR)lpStartOfFreeSpace;666 strlen( (LPSTR)dest->lpSessionDesc->u1.lpszSessionNameA ) + 1; 667 } 668 669 if( src->lpSessionDesc->u2.lpszPasswordA ) 670 { 671 strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPasswordA ); 672 dest->lpSessionDesc->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace; 673 673 lpStartOfFreeSpace += 674 strlen( (LPSTR)dest->lpSessionDesc-> pass.lpszPasswordA ) + 1;674 strlen( (LPSTR)dest->lpSessionDesc->u2.lpszPasswordA ) + 1; 675 675 } 676 676 } … … 683 683 CopyMemory( dest->lpPlayerName, src->lpPlayerName, sizeof( DPNAME ) ); 684 684 685 if( src->lpPlayerName-> psn.lpszShortNameA )686 { 687 strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName-> psn.lpszShortNameA );688 dest->lpPlayerName-> psn.lpszShortNameA = (LPSTR)lpStartOfFreeSpace;685 if( src->lpPlayerName->u1.lpszShortNameA ) 686 { 687 strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortNameA ); 688 dest->lpPlayerName->u1.lpszShortNameA = (LPSTR)lpStartOfFreeSpace; 689 689 lpStartOfFreeSpace += 690 strlen( (LPSTR)dest->lpPlayerName-> psn.lpszShortNameA ) + 1;691 } 692 693 if( src->lpPlayerName-> pln.lpszLongNameA )694 { 695 strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName-> pln.lpszLongNameA );696 dest->lpPlayerName-> pln.lpszLongNameA = (LPSTR)lpStartOfFreeSpace;690 strlen( (LPSTR)dest->lpPlayerName->u1.lpszShortNameA ) + 1; 691 } 692 693 if( src->lpPlayerName->u2.lpszLongNameA ) 694 { 695 strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongNameA ); 696 dest->lpPlayerName->u2.lpszLongNameA = (LPSTR)lpStartOfFreeSpace; 697 697 lpStartOfFreeSpace += 698 strlen( (LPSTR)dest->lpPlayerName-> pln.lpszLongName ) + 1 ;698 strlen( (LPSTR)dest->lpPlayerName->u2.lpszLongName ) + 1 ; 699 699 } 700 700 … … 781 781 782 782 /* Session names may or may not exist */ 783 if( src->lpSessionDesc-> sess.lpszSessionName )784 { 785 strcpyW( (LPWSTR)lpStartOfFreeSpace, dest->lpSessionDesc-> sess.lpszSessionName );786 src->lpSessionDesc-> sess.lpszSessionName = (LPWSTR)lpStartOfFreeSpace;783 if( src->lpSessionDesc->u1.lpszSessionName ) 784 { 785 strcpyW( (LPWSTR)lpStartOfFreeSpace, dest->lpSessionDesc->u1.lpszSessionName ); 786 src->lpSessionDesc->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace; 787 787 lpStartOfFreeSpace += sizeof(WCHAR) * 788 ( strlenW( (LPWSTR)dest->lpSessionDesc-> sess.lpszSessionName ) + 1 );789 } 790 791 if( src->lpSessionDesc-> pass.lpszPassword )792 { 793 strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc-> pass.lpszPassword );794 dest->lpSessionDesc-> pass.lpszPassword = (LPWSTR)lpStartOfFreeSpace;788 ( strlenW( (LPWSTR)dest->lpSessionDesc->u1.lpszSessionName ) + 1 ); 789 } 790 791 if( src->lpSessionDesc->u2.lpszPassword ) 792 { 793 strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPassword ); 794 dest->lpSessionDesc->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace; 795 795 lpStartOfFreeSpace += sizeof(WCHAR) * 796 ( strlenW( (LPWSTR)dest->lpSessionDesc-> pass.lpszPassword ) + 1 );796 ( strlenW( (LPWSTR)dest->lpSessionDesc->u2.lpszPassword ) + 1 ); 797 797 } 798 798 } … … 805 805 CopyMemory( dest->lpPlayerName, src->lpPlayerName, sizeof( DPNAME ) ); 806 806 807 if( src->lpPlayerName-> psn.lpszShortName )808 { 809 strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName-> psn.lpszShortName );810 dest->lpPlayerName-> psn.lpszShortName = (LPWSTR)lpStartOfFreeSpace;807 if( src->lpPlayerName->u1.lpszShortName ) 808 { 809 strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortName ); 810 dest->lpPlayerName->u1.lpszShortName = (LPWSTR)lpStartOfFreeSpace; 811 811 lpStartOfFreeSpace += sizeof(WCHAR) * 812 ( strlenW( (LPWSTR)dest->lpPlayerName-> psn.lpszShortName ) + 1 );813 } 814 815 if( src->lpPlayerName-> pln.lpszLongName )816 { 817 strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName-> pln.lpszLongName );818 dest->lpPlayerName-> pln.lpszLongName = (LPWSTR)lpStartOfFreeSpace;812 ( strlenW( (LPWSTR)dest->lpPlayerName->u1.lpszShortName ) + 1 ); 813 } 814 815 if( src->lpPlayerName->u2.lpszLongName ) 816 { 817 strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongName ); 818 dest->lpPlayerName->u2.lpszLongName = (LPWSTR)lpStartOfFreeSpace; 819 819 lpStartOfFreeSpace += sizeof(WCHAR) * 820 ( strlenW( (LPWSTR)dest->lpPlayerName-> pln.lpszLongName ) + 1 );820 ( strlenW( (LPWSTR)dest->lpPlayerName->u2.lpszLongName ) + 1 ); 821 821 } 822 822 … … 964 964 dwTotalSize += sizeof( DPSESSIONDESC2 ); 965 965 966 if( lpConn->lpSessionDesc-> sess.lpszSessionNameA )967 { 968 dwTotalSize += strlen( lpConn->lpSessionDesc-> sess.lpszSessionNameA ) + 1;969 } 970 971 if( lpConn->lpSessionDesc-> pass.lpszPasswordA )972 { 973 dwTotalSize += strlen( lpConn->lpSessionDesc-> pass.lpszPasswordA ) + 1;966 if( lpConn->lpSessionDesc->u1.lpszSessionNameA ) 967 { 968 dwTotalSize += strlen( lpConn->lpSessionDesc->u1.lpszSessionNameA ) + 1; 969 } 970 971 if( lpConn->lpSessionDesc->u2.lpszPasswordA ) 972 { 973 dwTotalSize += strlen( lpConn->lpSessionDesc->u2.lpszPasswordA ) + 1; 974 974 } 975 975 } … … 979 979 dwTotalSize += sizeof( DPNAME ); 980 980 981 if( lpConn->lpPlayerName-> psn.lpszShortNameA )982 { 983 dwTotalSize += strlen( lpConn->lpPlayerName-> psn.lpszShortNameA ) + 1;984 } 985 986 if( lpConn->lpPlayerName-> pln.lpszLongNameA )987 { 988 dwTotalSize += strlen( lpConn->lpPlayerName-> pln.lpszLongNameA ) + 1;981 if( lpConn->lpPlayerName->u1.lpszShortNameA ) 982 { 983 dwTotalSize += strlen( lpConn->lpPlayerName->u1.lpszShortNameA ) + 1; 984 } 985 986 if( lpConn->lpPlayerName->u2.lpszLongNameA ) 987 { 988 dwTotalSize += strlen( lpConn->lpPlayerName->u2.lpszLongNameA ) + 1; 989 989 } 990 990 … … 1011 1011 dwTotalSize += sizeof( DPSESSIONDESC2 ); 1012 1012 1013 if( lpConn->lpSessionDesc-> sess.lpszSessionName )1013 if( lpConn->lpSessionDesc->u1.lpszSessionName ) 1014 1014 { 1015 1015 dwTotalSize += sizeof( WCHAR ) * 1016 ( strlenW( lpConn->lpSessionDesc-> sess.lpszSessionName ) + 1 );1017 } 1018 1019 if( lpConn->lpSessionDesc-> pass.lpszPassword )1016 ( strlenW( lpConn->lpSessionDesc->u1.lpszSessionName ) + 1 ); 1017 } 1018 1019 if( lpConn->lpSessionDesc->u2.lpszPassword ) 1020 1020 { 1021 1021 dwTotalSize += sizeof( WCHAR ) * 1022 ( strlenW( lpConn->lpSessionDesc-> pass.lpszPassword ) + 1 );1022 ( strlenW( lpConn->lpSessionDesc->u2.lpszPassword ) + 1 ); 1023 1023 } 1024 1024 } … … 1028 1028 dwTotalSize += sizeof( DPNAME ); 1029 1029 1030 if( lpConn->lpPlayerName-> psn.lpszShortName )1030 if( lpConn->lpPlayerName->u1.lpszShortName ) 1031 1031 { 1032 1032 dwTotalSize += sizeof( WCHAR ) * 1033 ( strlenW( lpConn->lpPlayerName-> psn.lpszShortName ) + 1 );1034 } 1035 1036 if( lpConn->lpPlayerName-> pln.lpszLongName )1033 ( strlenW( lpConn->lpPlayerName->u1.lpszShortName ) + 1 ); 1034 } 1035 1036 if( lpConn->lpPlayerName->u2.lpszLongName ) 1037 1037 { 1038 1038 dwTotalSize += sizeof( WCHAR ) * 1039 ( strlenW( lpConn->lpPlayerName-> pln.lpszLongName ) + 1 );1039 ( strlenW( lpConn->lpPlayerName->u2.lpszLongName ) + 1 ); 1040 1040 } 1041 1041 … … 1065 1065 CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) ); 1066 1066 1067 if( lpSessionSrc-> sess.lpszSessionNameA )1068 { 1069 lpSessionDest->sess.lpszSessionNameA =1070 HEAP_strdupA( GetProcessHeap(),1071 HEAP_ZERO_MEMORY, lpSessionSrc->sess.lpszSessionNameA );1072 } 1073 if( lpSessionSrc-> pass.lpszPasswordA )1074 { 1075 lpSessionDest->pass.lpszPasswordA =1076 HEAP_strdupA( GetProcessHeap(),1077 HEAP_ZERO_MEMORY, lpSessionSrc->pass.lpszPasswordA );1067 if( lpSessionSrc->u1.lpszSessionNameA ) 1068 { 1069 if ((lpSessionDest->u1.lpszSessionNameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, 1070 strlen(lpSessionSrc->u1.lpszSessionNameA)+1 ))) 1071 strcpy( lpSessionDest->u1.lpszSessionNameA, lpSessionSrc->u1.lpszSessionNameA ); 1072 } 1073 if( lpSessionSrc->u2.lpszPasswordA ) 1074 { 1075 if ((lpSessionDest->u2.lpszPasswordA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, 1076 strlen(lpSessionSrc->u2.lpszPasswordA)+1 ))) 1077 strcpy( lpSessionDest->u2.lpszPasswordA, lpSessionSrc->u2.lpszPasswordA ); 1078 1078 } 1079 1079 -
trunk/src/DPlayX/dplayx_main.cpp
r5135 r5311 1 // $Id: dplayx_main.cpp,v 1. 3 2001-02-14 15:14:41 sandervlExp $1 // $Id: dplayx_main.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ 2 2 /* 3 3 * DPLAYX.DLL LibMain … … 23 23 24 24 DEFAULT_DEBUG_CHANNEL(dplay); 25 26 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); 27 28 static DWORD DPLAYX_dwProcessesAttached = 0; 25 DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 29 26 30 27 /* This is a globally exported variable at ordinal 6 of DPLAYX.DLL */ … … 34 31 { 35 32 36 TRACE( "(%u,0x%08lx,%p) & 0x%08lx\n", hinstDLL, fdwReason, lpvReserved, DPLAYX_dwProcessesAttached);33 TRACE( "(%u,0x%08lx,%p) & 0x%08lx\n", hinstDLL, fdwReason, lpvReserved, gdwDPlaySPRefCount ); 37 34 38 35 switch ( fdwReason ) 39 36 { 40 37 case DLL_PROCESS_ATTACH: 41 {42 43 if ( DPLAYX_dwProcessesAttached++ == 0 )44 {45 38 /* First instance perform construction of global processor data */ 46 39 return DPLAYX_ConstructData(); 47 }48 49 break;50 }51 40 52 41 case DLL_PROCESS_DETACH: 53 42 { 54 55 if ( --DPLAYX_dwProcessesAttached == 0 ) 56 { 57 BOOL rc; 58 /* Last instance performs destruction of global processor data */ 59 rc = DPLAYX_DestructData(); 43 BOOL rc; 44 /* Last instance performs destruction of global processor data */ 45 rc = DPLAYX_DestructData(); 60 46 #ifdef __WIN32OS2__ 47 if(gdwDPlaySPRefCount==0) // only do this the last time ? 61 48 ctordtorTerm(); 62 49 #endif 63 50 return rc; 64 }65 51 66 52 break; -
trunk/src/DPlayX/dplayx_messages.cpp
r4446 r5311 1 // $Id: dplayx_messages.cpp,v 1. 3 2000-10-06 19:49:05hugh Exp $1 // $Id: dplayx_messages.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ 2 2 /* DirectPlay & DirectPlayLobby messaging implementation 3 3 * … … 24 24 #include "dplayx_global.h" 25 25 26 DEFAULT_DEBUG_CHANNEL(dplay) 26 DEFAULT_DEBUG_CHANNEL(dplay); 27 27 28 28 #undef debugstr_guid … … 39 39 40 40 static DWORD CALLBACK DPL_MSG_ThreadMain( LPVOID lpContext ); 41 static LPVOID DP_MSG_ExpectReply( IDirectPlay2AImpl* This, LPDPSP_SENDDATA data, 42 DWORD dwWaitTime, WORD wReplyCommandId, 43 LPVOID* lplpReplyMsg, LPDWORD lpdwMsgBodySize ); 41 44 42 45 /* Create the message reception thread to allow the application to receive … … 133 136 { 134 137 MSG lobbyMsg; 135 #ifdef STRICT 136 HANDLE hNullHandle = NULL; 137 #else 138 HANDLE hNullHandle = 0; 139 #endif 140 141 GetMessageW( &lobbyMsg, hNullHandle, 0, 0 ); 138 GetMessageW( &lobbyMsg, 0, 0, 0 ); 142 139 } 143 140 … … 149 146 } 150 147 148 /* DP messageing stuff */ 149 static HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This, 150 LPDP_MSG_REPLY_STRUCT_LIST lpReplyStructList, 151 WORD wReplyCommandId ); 152 static LPVOID DP_MSG_CleanReplyStruct( LPDP_MSG_REPLY_STRUCT_LIST lpReplyStructList, 153 LPVOID* lplpReplyMsg, LPDWORD lpdwMsgBodySize ); 154 155 156 static 157 HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This, 158 LPDP_MSG_REPLY_STRUCT_LIST lpReplyStructList, WORD wReplyCommandId ) 159 { 160 lpReplyStructList->replyExpected.hReceipt = CreateEventA( NULL, FALSE, FALSE, NULL ); 161 lpReplyStructList->replyExpected.wExpectedReply = wReplyCommandId; 162 lpReplyStructList->replyExpected.lpReplyMsg = NULL; 163 lpReplyStructList->replyExpected.dwMsgBodySize = 0; 164 165 /* Insert into the message queue while locked */ 166 EnterCriticalSection( &This->unk->DP_lock ); 167 DPQ_INSERT( This->dp2->replysExpected, lpReplyStructList, replysExpected ); 168 LeaveCriticalSection( &This->unk->DP_lock ); 169 170 return lpReplyStructList->replyExpected.hReceipt; 171 } 172 173 static 174 LPVOID DP_MSG_CleanReplyStruct( LPDP_MSG_REPLY_STRUCT_LIST lpReplyStructList, 175 LPVOID* lplpReplyMsg, LPDWORD lpdwMsgBodySize ) 176 { 177 CloseHandle( lpReplyStructList->replyExpected.hReceipt ); 178 179 *lplpReplyMsg = lpReplyStructList->replyExpected.lpReplyMsg; 180 *lpdwMsgBodySize = lpReplyStructList->replyExpected.dwMsgBodySize; 181 182 return lpReplyStructList->replyExpected.lpReplyMsg; 183 } 151 184 152 185 HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags, … … 156 189 LPDPMSG_REQUESTNEWPLAYERID lpMsgBody; 157 190 DWORD dwMsgSize; 158 DWORD dwWaitReturn;159 191 HRESULT hr = DP_OK; 160 192 … … 166 198 This->dp2->spData.dwSPHeaderSize ); 167 199 200 /* Compose dplay message envelope */ 168 201 lpMsgBody->envelope.dwMagic = DPMSGMAGIC_DPLAYMSG; 169 202 lpMsgBody->envelope.wCommandId = DPMSGCMD_REQUESTNEWPLAYERID; 170 203 lpMsgBody->envelope.wVersion = DPMSGVER_DP6; 171 204 205 /* Compose the body of the message */ 172 206 lpMsgBody->dwFlags = dwFlags; 173 207 174 /* FIXME: Need to have a more advanced queuing system as this needs to 175 * block on send until we get response. Otherwise we need to be 176 * able to ensure we can pick out the exact response. Of course, 177 * with something as non critical as this, would it matter? The 178 * id has been effectively reserved for this session... 179 */ 208 /* Send the message */ 180 209 { 181 210 DPSP_SENDDATA data; … … 189 218 data.lpISP = This->dp2->spData.lpISP; 190 219 191 /* Setup for receipt */ 192 This->dp2->hMsgReceipt = CreateEventA( NULL, FALSE, FALSE, NULL ); 193 194 TRACE( "Sending request for player id\n" ); 195 196 hr = (*This->dp2->spData.lpCB->Send)( &data ); 197 198 if( FAILED(hr) ) 199 { 200 ERR( "Request for new playerID send failed: %s\n", 201 DPLAYX_HresultToString( hr ) ); 202 return DPERR_NOCONNECTION; 203 } 204 } 205 206 dwWaitReturn = WaitForSingleObject( This->dp2->hMsgReceipt, 30000 ); 207 if( dwWaitReturn != WAIT_OBJECT_0 ) 208 { 209 ERR( "Wait failed 0x%08lx\n", dwWaitReturn ); 210 hr = DPERR_TIMEOUT; 211 } 212 213 CloseHandle( This->dp2->hMsgReceipt ); 214 This->dp2->hMsgReceipt = 0; 220 TRACE( "Asking for player id w/ dwFlags 0x%08lx\n", 221 lpMsgBody->dwFlags ); 222 223 224 DP_MSG_ExpectReply( This, &data, DPMSG_DEFAULT_WAIT_TIME, DPMSGCMD_NEWPLAYERIDREPLY, 225 &lpMsg, &dwMsgSize ); 226 227 } 228 215 229 216 230 /* Need to examine the data and extract the new player id */ … … 219 233 LPCDPMSG_NEWPLAYERIDREPLY lpcReply; 220 234 221 lpcReply = (LPCDPMSG_NEWPLAYERIDREPLY) This->dp2->lpMsgReceived;235 lpcReply = (LPCDPMSG_NEWPLAYERIDREPLY)lpMsg; 222 236 223 237 *lpdpidAllocatedId = lpcReply->dpidNewPlayerId; … … 227 241 /* FIXME: I think that the rest of the message has something to do 228 242 * with remote data for the player that perhaps I need to setup. 243 * However, with the information that is passed, all that it could 244 * be used for is a standardized intialization value, which I'm 245 * guessing we can do without. Unless the message content is the same 246 * for several different messages? 229 247 */ 248 249 HeapFree( GetProcessHeap(), 0, lpMsg ); 250 } 251 252 return hr; 253 } 254 255 HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ) 256 { 257 LPVOID lpMsg; 258 LPDPMSG_FORWARDADDPLAYER lpMsgBody; 259 DWORD dwMsgSize; 260 HRESULT hr = DP_OK; 261 262 dwMsgSize = This->dp2->spData.dwSPHeaderSize + sizeof( *lpMsgBody ); 263 264 lpMsg = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwMsgSize ); 265 266 lpMsgBody = (LPDPMSG_FORWARDADDPLAYER)( (BYTE*)lpMsg + 267 This->dp2->spData.dwSPHeaderSize ); 268 269 /* Compose dplay message envelope */ 270 lpMsgBody->envelope.dwMagic = DPMSGMAGIC_DPLAYMSG; 271 lpMsgBody->envelope.wCommandId = DPMSGCMD_FORWARDADDPLAYER; 272 lpMsgBody->envelope.wVersion = DPMSGVER_DP6; 273 230 274 #if 0 231 /* Set the passed service provider data */ 232 IDirectPlaySP_SetSPData( This->dp2->spData.lpISP, data, 233 msgsize, DPSET_REMOTE ); 234 275 { 276 LPBYTE lpPData; 277 DWORD dwDataSize; 278 279 /* SP Player remote data needs to be propagated at some point - is this the point? */ 280 IDirectPlaySP_GetSPPlayerData( This->dp2->spData.lpISP, dpidServer, (LPVOID*)&lpPData, &dwDataSize, DPSET_REMOTE ); 281 282 ERR( "Player Data size is 0x%08lx\n" 283 "[%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x]\n" 284 "[%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x]\n", 285 286 dwDataSize, 287 lpPData[0], lpPData[1], lpPData[2], lpPData[3], lpPData[4], 288 lpPData[5], lpPData[6], lpPData[7], lpPData[8], lpPData[9], 289 lpPData[10], lpPData[11], lpPData[12], lpPData[13], lpPData[14], 290 lpPData[15], lpPData[16], lpPData[17], lpPData[18], lpPData[19], 291 lpPData[20], lpPData[21], lpPData[22], lpPData[23], lpPData[24], 292 lpPData[25], lpPData[26], lpPData[27], lpPData[28], lpPData[29], 293 lpPData[30], lpPData[31] 294 ); 295 DebugBreak(); 296 } 235 297 #endif 236 298 237 HeapFree( GetProcessHeap(), 0, This->dp2->lpMsgReceived ); 238 This->dp2->lpMsgReceived = NULL; 299 /* Compose body of message */ 300 lpMsgBody->dpidAppServer = dpidServer; 301 lpMsgBody->unknown2[0] = 0x0; 302 lpMsgBody->unknown2[1] = 0x1c; 303 lpMsgBody->unknown2[2] = 0x6c; 304 lpMsgBody->unknown2[3] = 0x50; 305 lpMsgBody->unknown2[4] = 0x9; 306 307 lpMsgBody->dpidAppServer2 = dpidServer; 308 lpMsgBody->unknown3[0] = 0x0; 309 lpMsgBody->unknown3[0] = 0x0; 310 lpMsgBody->unknown3[0] = 0x20; 311 lpMsgBody->unknown3[0] = 0x0; 312 lpMsgBody->unknown3[0] = 0x0; 313 314 lpMsgBody->dpidAppServer3 = dpidServer; 315 lpMsgBody->unknown4[0] = 0x30; 316 lpMsgBody->unknown4[1] = 0xb; 317 lpMsgBody->unknown4[2] = 0x0; 318 lpMsgBody->unknown4[3] = 0x1e090002; 319 lpMsgBody->unknown4[4] = 0x0; 320 lpMsgBody->unknown4[5] = 0x0; 321 lpMsgBody->unknown4[6] = 0x0; 322 lpMsgBody->unknown4[7] = 0x32090002; 323 lpMsgBody->unknown4[8] = 0x0; 324 lpMsgBody->unknown4[9] = 0x0; 325 lpMsgBody->unknown4[10] = 0x0; 326 lpMsgBody->unknown4[11] = 0x0; 327 lpMsgBody->unknown4[12] = 0x0; 328 329 lpMsgBody->unknown5[0] = 0x0; 330 lpMsgBody->unknown5[1] = 0x0; 331 332 /* Send the message */ 333 { 334 DPSP_SENDDATA data; 335 336 data.dwFlags = DPSEND_GUARANTEED; 337 data.idPlayerTo = 0; /* Name server */ 338 data.idPlayerFrom = dpidServer; /* Sending from session server */ 339 data.lpMessage = lpMsg; 340 data.dwMessageSize = dwMsgSize; 341 data.bSystemMessage = TRUE; /* Allow reply to be sent */ 342 data.lpISP = This->dp2->spData.lpISP; 343 344 lpMsg = DP_MSG_ExpectReply( This, &data, 345 DPMSG_WAIT_60_SECS, 346 DPMSGCMD_GETNAMETABLEREPLY, 347 &lpMsg, &dwMsgSize ); 348 } 349 350 /* Need to examine the data and extract the new player id */ 351 if( lpMsg != NULL ) 352 { 353 FIXME( "Name Table reply received: stub\n" ); 239 354 } 240 355 … … 242 357 } 243 358 244 245 /* This function seems to cause a trap in the SP. It would seem unnecessary */ 246 /* FIXME: Remove this method if not required */ 247 HRESULT DP_MSG_OpenStream( IDirectPlay2AImpl* This ) 248 { 249 HRESULT hr; 250 DPSP_SENDDATA data; 251 252 data.dwFlags = DPSEND_OPENSTREAM; 253 data.idPlayerTo = 0; /* Name server */ 254 data.idPlayerFrom = 0; /* From DP itself */ 255 data.lpMessage = NULL; 256 data.dwMessageSize = This->dp2->spData.dwSPHeaderSize; 257 data.bSystemMessage = FALSE; /* FIXME? */ 258 data.lpISP = This->dp2->spData.lpISP; 259 260 hr = (*This->dp2->spData.lpCB->Send)( &data ); 359 /* Queue up a structure indicating that we want a reply of type wReplyCommandId. DPlay does 360 * not seem to offer any way of uniquely differentiating between replies of the same type 361 * relative to the request sent. There is an implicit assumption that there will be no 362 * ordering issues on sends and receives from the opposite machine. No wonder MS is not 363 * a networking company. 364 */ 365 static 366 LPVOID DP_MSG_ExpectReply( IDirectPlay2AImpl* This, LPDPSP_SENDDATA lpData, 367 DWORD dwWaitTime, WORD wReplyCommandId, 368 LPVOID* lplpReplyMsg, LPDWORD lpdwMsgBodySize ) 369 { 370 HRESULT hr; 371 HANDLE hMsgReceipt; 372 DP_MSG_REPLY_STRUCT_LIST replyStructList; 373 DWORD dwWaitReturn; 374 375 /* Setup for receipt */ 376 hMsgReceipt = DP_MSG_BuildAndLinkReplyStruct( This, &replyStructList, 377 wReplyCommandId ); 378 379 TRACE( "Sending msg and expecting cmd %u in reply within %lu ticks\n", 380 wReplyCommandId, dwWaitTime ); 381 hr = (*This->dp2->spData.lpCB->Send)( lpData ); 261 382 262 383 if( FAILED(hr) ) 263 384 { 264 ERR( "Request for open stream send failed: %s\n", 265 DPLAYX_HresultToString( hr ) ); 266 } 267 268 /* FIXME: hack to give some time for channel to open */ 269 SleepEx( 1000 /* 1 sec */, FALSE ); 270 271 return hr; 272 } 385 ERR( "Request for new playerID send failed: %s\n", 386 DPLAYX_HresultToString( hr ) ); 387 return NULL; 388 } 389 390 dwWaitReturn = WaitForSingleObject( hMsgReceipt, dwWaitTime ); 391 if( dwWaitReturn != WAIT_OBJECT_0 ) 392 { 393 ERR( "Wait failed 0x%08lx\n", dwWaitReturn ); 394 return NULL; 395 } 396 397 /* Clean Up */ 398 return DP_MSG_CleanReplyStruct( &replyStructList, lplpReplyMsg, lpdwMsgBodySize ); 399 } 400 401 /* Determine if there is a matching request for this incomming message and then copy 402 * all important data. It is quite silly to have to copy the message, but the documents 403 * indicate that a copy is taken. Silly really. 404 */ 405 void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId, 406 LPCVOID lpcMsgBody, DWORD dwMsgBodySize ) 407 { 408 LPDP_MSG_REPLY_STRUCT_LIST lpReplyList; 409 410 #if 0 411 if( wCommandId == DPMSGCMD_FORWARDADDPLAYER ) 412 { 413 DebugBreak(); 414 } 415 #endif 416 417 /* Find, and immediately remove (to avoid double triggering), the appropriate entry. Call locked to 418 * avoid problems. 419 */ 420 EnterCriticalSection( &This->unk->DP_lock ); 421 DPQ_REMOVE_ENTRY( This->dp2->replysExpected, replysExpected, replyExpected.wExpectedReply,\ 422 ==, wCommandId, lpReplyList ); 423 LeaveCriticalSection( &This->unk->DP_lock ); 424 425 if( lpReplyList != NULL ) 426 { 427 lpReplyList->replyExpected.dwMsgBodySize = dwMsgBodySize; 428 lpReplyList->replyExpected.lpReplyMsg = HeapAlloc( GetProcessHeap(), 429 HEAP_ZERO_MEMORY, 430 dwMsgBodySize ); 431 CopyMemory( lpReplyList->replyExpected.lpReplyMsg, 432 lpcMsgBody, dwMsgBodySize ); 433 434 /* Signal the thread which sent the message that it has a reply */ 435 SetEvent( lpReplyList->replyExpected.hReceipt ); 436 } 437 else 438 { 439 ERR( "No receipt event set - only expecting in reply mode\n" ); 440 DebugBreak(); 441 } 442 443 } 444 445 void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId, 446 LPCVOID lpMsgBody, DWORD dwMsgBodySize ) 447 { 448 LPCDPMSG_FORWARDADDPLAYERNACK lpcErrorMsg; 449 450 lpcErrorMsg = (LPCDPMSG_FORWARDADDPLAYERNACK)lpMsgBody; 451 452 ERR( "Received error message %u. Error is %s\n", 453 wCommandId, DPLAYX_HresultToString( lpcErrorMsg->errorCode) ); 454 DebugBreak(); 455 } 456 -
trunk/src/DPlayX/dplayx_messages.h
r4446 r5311 1 // $Id: dplayx_messages.h,v 1. 3 2000-10-06 19:49:06hugh Exp $1 // $Id: dplayx_messages.h,v 1.4 2001-03-13 23:13:28 hugh Exp $ 2 2 3 3 #ifndef __WINE_DPLAYX_MESSAGES__ … … 13 13 HANDLE hDeath, HANDLE hConnRead ); 14 14 15 HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags, 16 LPDPID lpdipidAllocatedId ); 17 HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ); 18 19 void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId, 20 LPCVOID lpMsgBody, DWORD dwMsgBodySize ); 21 void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId, 22 LPCVOID lpMsgBody, DWORD dwMsgBodySize ); 23 24 /* Timings -> 1000 ticks/sec */ 25 #define DPMSG_WAIT_5_SECS 5000 26 #define DPMSG_WAIT_30_SECS 30000 27 #define DPMSG_WAIT_60_SECS 60000 28 #define DPMSG_DEFAULT_WAIT_TIME DPMSG_WAIT_30_SECS 15 29 16 30 /* Message types etc. */ … … 20 34 #define DPMSGCMD_ENUMSESSIONSREPLY 1 21 35 #define DPMSGCMD_ENUMSESSIONSREQUEST 2 22 36 #define DPMSGCMD_GETNAMETABLEREPLY 3 /* Contains all existing players in session */ 23 37 24 38 #define DPMSGCMD_REQUESTNEWPLAYERID 5 25 39 26 40 #define DPMSGCMD_NEWPLAYERIDREPLY 7 27 #define DPMSGCMD_CREATESESSION 8 41 #define DPMSGCMD_CREATESESSION 8 /* Might be a create nameserver or new player msg */ 28 42 #define DPMSGCMD_CREATENEWPLAYER 9 29 43 #define DPMSGCMD_SYSTEMMESSAGE 10 … … 33 47 #define DPMSGCMD_ENUMGROUPS 17 34 48 35 #define DPMSGCMD_ GETNAMETABLE1949 #define DPMSGCMD_FORWARDADDPLAYER 19 36 50 37 #define DPMSGCMD_ GETNAMETABLEREPLY 2951 #define DPMSGCMD_FORWARDADDPLAYERNACK 36 38 52 39 53 /* This is what DP 6 defines it as. Don't know what it means. All messages … … 47 61 /* All messages sent from the system are sent with this at the beginning of 48 62 * the message. 63 * Size is 8 bytes 49 64 */ 50 51 /* Size is 8 bytes */52 65 typedef struct tagDPMSG_SENDENVELOPE 53 66 { … … 58 71 typedef const DPMSG_SENDENVELOPE* LPCDPMSG_SENDENVELOPE; 59 72 73 /* System messages exchanged between players seems to have this 74 * payload envelope on top of the basic envelope 75 */ 60 76 typedef struct tagDPMSG_SYSMSGENVELOPE 61 77 { … … 65 81 typedef const DPMSG_SYSMSGENVELOPE* LPCDPMSG_SYSMSGENVELOPE; 66 82 67 83 /* Reply sent in response to an enumsession request */ 68 84 typedef struct tagDPMSG_ENUMSESSIONSREPLY 69 85 { … … 95 111 typedef const DPMSG_ENUMSESSIONSREPLY* LPCDPMSG_ENUMSESSIONSREPLY; 96 112 113 /* Msg sent to find out what sessions are available */ 97 114 typedef struct tagDPMSG_ENUMSESSIONSREQUEST 98 115 { … … 101 118 GUID guidApplication; 102 119 103 DWORD dwPasswordSize; /* A Guess. This is normally0x00000000. */120 DWORD dwPasswordSize; /* A Guess. This is 0x00000000. */ 104 121 /* This might be the name server DPID which 105 122 is needed for the reply */ … … 133 150 134 151 DPID dpidNewPlayerId; 135 #if 1 152 136 153 /* Assume that this is data that is tacked on to the end of the message 137 154 * that comes from the SP remote data stored that needs to be propagated. 138 155 */ 139 156 BYTE unknown[36]; /* This appears to always be 0 - not sure though */ 140 #endif141 142 157 } DPMSG_NEWPLAYERIDREPLY, *LPDPMSG_NEWPLAYERIDREPLY; 143 158 typedef const DPMSG_NEWPLAYERIDREPLY* LPCDPMSG_NEWPLAYERIDREPLY; 144 159 160 typedef struct tagDPMSG_FORWARDADDPLAYER 161 { 162 DPMSG_SENDENVELOPE envelope; 163 164 DWORD unknown; /* 0 */ 165 166 DPID dpidAppServer; /* Remote application server id */ 167 DWORD unknown2[5]; /* ??? */ 168 #define FORWARDADDPLAYER_UNKNOWN2_INIT { 0x0, 0x1c, 0x6c, 0x50, 0x9 } 169 170 DPID dpidAppServer2; /* Remote application server id again !? */ 171 DWORD unknown3[5]; /* ??? */ 172 #define FORWARDADDPLAYER_UNKNOWN3_INIT { 0x0, 0x0, 0x20, 0x0, 0x0 } 173 174 DPID dpidAppServer3; /* Remote application server id again !? */ 175 176 DWORD unknown4[12]; /* ??? - Is this a clump of 5 and then 8? */ 177 /* NOTE: 1 byte infront of the two 0x??090002 entries changes! */ 178 #define FORWARDADDPLAYER_UNKNOWN4_INIT { 0x30, 0xb, 0x0, 0x1e090002, 0x0, 0x0, 0x0, 0x32090002, 0x0, 0x0, 0x0, 0x0 } 179 180 BYTE unknown5[2]; /* 2 bytes at the end. This may be a part of something! */ 181 #define FORWARDADDPLAYER_UNKNOWN5_INIT { 0x0 } 182 183 } DPMSG_FORWARDADDPLAYER, *LPDPMSG_FORWARDADDPLAYER; 184 typedef const DPMSG_FORWARDADDPLAYER* LPCDPMSG_FORWARDADDPLAYER; 185 186 /* This is an error message that can be received. Not sure if this is 187 * specifically for a forward add player or for all errors 188 */ 189 typedef struct tagDPMSG_FORWARDADDPLAYERNACK 190 { 191 DPMSG_SENDENVELOPE envelope; 192 HRESULT errorCode; 193 } DPMSG_FORWARDADDPLAYERNACK, *LPDPMSG_FORWARDADDPLAYERNACK; 194 typedef const DPMSG_FORWARDADDPLAYERNACK* LPCDPMSG_FORWARDADDPLAYERNACK; 195 145 196 #include "poppack.h" 146 197 147 148 HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags,149 LPDPID lpdipidAllocatedId );150 151 /* FIXME: I don't think that this is a needed method */152 HRESULT DP_MSG_OpenStream( IDirectPlay2AImpl* This );153 154 155 198 #endif -
trunk/src/DPlayX/dplobby.cpp
r4446 r5311 1 // $Id: dplobby.cpp,v 1. 3 2000-10-06 19:49:05hugh Exp $1 // $Id: dplobby.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ 2 2 /* Direct Play Lobby 2 & 3 Implementation 3 3 * … … 16 16 #include "winnt.h" 17 17 #include "winreg.h" 18 #include "winnls.h" 18 19 #include "heap.h" 19 20 #include "heapstring.h" … … 26 27 #include "dplayx_queue.h" 27 28 28 DEFAULT_DEBUG_CHANNEL(dplay) 29 DEFAULT_DEBUG_CHANNEL(dplay); 29 30 30 31 #undef debugstr_guid … … 363 364 364 365 CopyMemory( *ppvObj, iface, sizeof( IDirectPlayLobbyWImpl ) ); 365 (*(IDirectPlayLobby WImpl**)ppvObj)->ulInterfaceRef = 0;366 (*(IDirectPlayLobbyAImpl**)ppvObj)->ulInterfaceRef = 0; 366 367 367 368 if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) ) … … 767 768 char atSubKey[51]; 768 769 char returnBuffer[51]; 769 LPWSTR lpWGUIDString;770 WCHAR buff[51]; 770 771 DWORD dwAtIndex; 771 772 LPSTR atKey = "Address Types"; … … 793 794 794 795 /* FIXME: Check return types to ensure we're interpreting data right */ 795 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer ); 796 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID ); 797 HeapFree( GetProcessHeap(), 0, lpWGUIDString ); 796 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) ); 797 CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID ); 798 798 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */ 799 799 … … 821 821 822 822 /* FIXME: Check return types to ensure we're interpreting data right */ 823 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, atSubKey ); 824 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID ); 825 HeapFree( GetProcessHeap(), 0, lpWGUIDString ); 823 MultiByteToWideChar( CP_ACP, 0, atSubKey, -1, buff, sizeof(buff)/sizeof(WCHAR) ); 824 CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID ); 826 825 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */ 827 826 … … 918 917 DWORD returnTypeGUID, sizeOfReturnBuffer = 50; 919 918 char returnBuffer[51]; 920 LPWSTR lpWGUIDString;919 WCHAR buff[51]; 921 920 DPLAPPINFO dplAppInfo; 922 921 … … 940 939 941 940 /* FIXME: Check return types to ensure we're interpreting data right */ 942 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer ); 943 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID ); 944 HeapFree( GetProcessHeap(), 0, lpWGUIDString ); 941 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) ); 942 CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID ); 945 943 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */ 946 944 947 945 dplAppInfo.dwSize = sizeof( dplAppInfo ); 948 946 dplAppInfo.guidApplication = serviceProviderGUID; 949 dplAppInfo. appName.lpszAppNameA = subKeyName;947 dplAppInfo.u.lpszAppNameA = subKeyName; 950 948 951 949 EnterCriticalSection( &This->unk->DPL_lock ); … … 1096 1094 else 1097 1095 { 1098 lpData->lpszCommandLine = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, returnBuffer ); 1096 if ((lpData->lpszCommandLine = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 ))) 1097 strcpy( lpData->lpszCommandLine, returnBuffer ); 1099 1098 } 1100 1099 … … 1109 1108 else 1110 1109 { 1111 lpData->lpszCurrentDirectory = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, returnBuffer ); 1110 if ((lpData->lpszCurrentDirectory = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 ))) 1111 strcpy( lpData->lpszCurrentDirectory, returnBuffer ); 1112 1112 } 1113 1113 … … 1122 1122 else 1123 1123 { 1124 lpData->lpszFileName = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, returnBuffer ); 1124 if ((lpData->lpszFileName = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 ))) 1125 strcpy( lpData->lpszFileName, returnBuffer ); 1125 1126 } 1126 1127 … … 1135 1136 else 1136 1137 { 1137 lpData->lpszPath = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, returnBuffer ); 1138 if ((lpData->lpszPath = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 ))) 1139 strcpy( lpData->lpszPath, returnBuffer ); 1138 1140 } 1139 1141 … … 1149 1151 { 1150 1152 /* These are the handles for the created process */ 1151 HANDLE hAppStart, hAppDeath, hAppRead, hTemp; ;1153 HANDLE hAppStart, hAppDeath, hAppRead, hTemp; 1152 1154 SECURITY_ATTRIBUTES s_attrib; 1153 1155 … … 1245 1247 HeapFree( GetProcessHeap(), 0, enumData.lpszPath ); 1246 1248 HeapFree( GetProcessHeap(), 0, enumData.lpszFileName ); 1247 appName = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, temp );1249 if ((appName = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 ))) strcpy( appName, temp ); 1248 1250 1249 1251 /* Now the command line */ … … 1251 1253 strcat( temp, enumData.lpszCommandLine ); 1252 1254 HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine ); 1253 enumData.lpszCommandLine = HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, temp ); 1255 if ((enumData.lpszCommandLine = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 ))) 1256 strcpy( enumData.lpszCommandLine, temp ); 1254 1257 1255 1258 ZeroMemory( &startupInfo, sizeof( startupInfo ) ); -
trunk/src/DPlayX/name_server.cpp
r4446 r5311 1 // $Id: name_server.cpp,v 1. 3 2000-10-06 19:49:06hugh Exp $1 // $Id: name_server.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ 2 2 /* DPLAYX.DLL name server implementation 3 3 * … … 18 18 #include "winbase.h" 19 19 #include "winuser.h" 20 #include "winnls.h" 21 #include "wine/unicode.h" 20 22 #include "debugtools.h" 21 23 #include "heap.h" … … 82 84 LPVOID lpNSInfo ) 83 85 { 86 DWORD len; 84 87 lpNSCache lpCache = (lpNSCache)lpNSInfo; 85 88 lpNSCacheData lpCacheNode; … … 128 131 129 132 CopyMemory( lpCacheNode->data, &lpMsg->sd, sizeof( *lpCacheNode->data ) ); 130 lpCacheNode->data->sess.lpszSessionNameA = HEAP_strdupWtoA( GetProcessHeap(), 131 HEAP_ZERO_MEMORY, 132 (LPWSTR)(lpMsg+1) ); 133 134 lpCacheNode->dwTime = GetTickCount(); 133 len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1, NULL, 0, NULL, NULL ); 134 if ((lpCacheNode->data->u1.lpszSessionNameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, len ))) 135 WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1, 136 lpCacheNode->data->u1.lpszSessionNameA, len, NULL, NULL ); 137 138 lpCacheNode->dwTime = timeGetTime(); 135 139 136 140 DPQ_INSERT(lpCache->first, lpCacheNode, next ); … … 199 203 } 200 204 205 /* Delete a name server node which has been allocated on the heap */ 201 206 DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData ) 202 207 { … … 209 214 } 210 215 211 212 213 216 /* Render all data in a session cache invalid */ 214 217 void NS_InvalidateSessionCache( LPVOID lpNSInfo ) … … 257 260 void NS_ResetSessionEnumeration( LPVOID lpNSInfo ) 258 261 { 259 260 262 ((lpNSCache)lpNSInfo)->present = ((lpNSCache)lpNSInfo)->first.lpQHFirst; 261 263 } … … 285 287 * older than the criteria. If so, just delete that information. 286 288 */ 289 /* FIXME: This needs to be called by some periodic timer */ 287 290 void NS_PruneSessionCache( LPVOID lpNSInfo ) 288 291 { … … 337 340 } 338 341 339 340 341 /* Message stuff */ 342 /* NAME SERVER Message stuff */ 342 343 void NS_ReplyToEnumSessionsRequest( LPVOID lpMsg, 343 344 LPDPSP_REPLYDATA lpReplyData, … … 347 348 DWORD dwVariableSize; 348 349 DWORD dwVariableLen; 349 LPWSTR string;350 350 /* LPDPMSG_ENUMSESSIONSREQUEST msg = (LPDPMSG_ENUMSESSIONSREQUEST)lpMsg; */ 351 351 BOOL bAnsi = TRUE; /* FIXME: This needs to be in the DPLAY interface */ … … 353 353 FIXME( ": few fixed + need to check request for response\n" ); 354 354 355 dwVariableLen = bAnsi ? lstrlenA( lpDP->dp2->lpSessionDesc->sess.lpszSessionNameA ) + 1 356 : lstrlenW( lpDP->dp2->lpSessionDesc->sess.lpszSessionName ) + 1; 355 if (bAnsi) 356 dwVariableLen = MultiByteToWideChar( CP_ACP, 0, 357 lpDP->dp2->lpSessionDesc->u1.lpszSessionNameA, 358 -1, NULL, 0 ); 359 else 360 dwVariableLen = strlenW( lpDP->dp2->lpSessionDesc->u1.lpszSessionName ) + 1; 357 361 358 362 dwVariableSize = dwVariableLen * sizeof( WCHAR ); … … 374 378 rmsg->dwUnknown = 0x0000005c; 375 379 if( bAnsi ) 376 { 377 string = HEAP_strdupAtoW( GetProcessHeap(), 0, 378 lpDP->dp2->lpSessionDesc->sess.lpszSessionNameA ); 379 /* FIXME: Memory leak */ 380 } 380 MultiByteToWideChar( CP_ACP, 0, lpDP->dp2->lpSessionDesc->u1.lpszSessionNameA, -1, 381 (LPWSTR)(rmsg+1), dwVariableLen ); 381 382 else 382 { 383 string = lpDP->dp2->lpSessionDesc->sess.lpszSessionName; 384 } 385 386 lstrcpyW( (LPWSTR)(rmsg+1), string ); 387 388 } 389 383 strcpyW( (LPWSTR)(rmsg+1), lpDP->dp2->lpSessionDesc->u1.lpszSessionName ); 384 }
Note:
See TracChangeset
for help on using the changeset viewer.