Changeset 5311 for trunk/src


Ignore:
Timestamp:
Mar 14, 2001, 12:13:28 AM (24 years ago)
Author:
hugh
Message:

Synced with WINE

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:03 hugh Exp $
     1// $Id: dplay.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $
    22/* Direct Play 2,3,4 Implementation
    33 *
     
    1818#include "winnt.h"
    1919#include "winreg.h"
     20#include "winnls.h"
     21#include "wine/unicode.h"
    2022#include "dplay.h"
    2123#include "heap.h"
     
    173175            LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2,
    174176            LPVOID lpContext, DWORD dwFlags, BOOL bAnsi );
     177static HRESULT WINAPI DP_IF_InitializeConnection
     178          ( IDirectPlay3Impl* This, LPVOID lpConnection, DWORD dwFlags, BOOL bAnsi );
    175179static BOOL CALLBACK cbDPCreateEnumConnections( LPCGUID lpguidSP,
    176180    LPVOID lpConnection, DWORD dwConnectionSize, LPCDPNAME lpName,
     
    187191
    188192
    189 static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData );
     193static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData, LPBOOL lpbIsDpSp );
    190194
    191195
     
    254258  DPQ_INIT(This->dp2->receiveMsgs);
    255259  DPQ_INIT(This->dp2->sendMsgs);
     260  DPQ_INIT(This->dp2->replysExpected);
    256261
    257262  if( !NS_InitializeSessionCache( &This->dp2->lpNameServerData ) )
     
    518523
    519524  *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
    520                        sizeof( IDirectPlay2Impl ) );
     525                       sizeof( *This ) );
    521526
    522527  if( *ppvObj == NULL )
     
    525530  }
    526531
    527   CopyMemory( *ppvObj, iface, sizeof( IDirectPlay2Impl )  );
     532  //CopyMemory( *ppvObj, iface, sizeof( IDirectPlay2Impl )  );
     533  CopyMemory( *ppvObj, This, sizeof( *This )  );
    528534  (*(IDirectPlay2Impl**)ppvObj)->ulInterfaceRef = 0;
    529535
     
    627633
    628634/* *lplpReply will be non NULL iff there is something to reply */
    629 HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpMessageBody,
    630                           DWORD  dwMessageBodySize, LPCVOID lpMessageHeader,
     635HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpcMessageBody,
     636                          DWORD  dwMessageBodySize, LPCVOID lpcMessageHeader,
    631637                          WORD wCommandId, WORD wVersion,
    632638                          LPVOID* lplpReply, LPDWORD lpdwMsgSize )
    633639{
    634640  TRACE( "(%p)->(%p,0x%08lx,%p,%u,%u)\n",
    635          This, lpMessageBody, dwMessageBodySize, lpMessageHeader, wCommandId,
     641         This, lpcMessageBody, dwMessageBodySize, lpcMessageHeader, wCommandId,
    636642         wVersion );
    637643
    638   DebugBreak();
    639644
    640645  switch( wCommandId )
     
    642647    case DPMSGCMD_REQUESTNEWPLAYERID:
    643648    {
    644 #if 0
    645649      LPCDPMSG_REQUESTNEWPLAYERID lpcMsg =
    646         (LPCDPMSG_REQUESTNEWPLAYERID)lpMessageBody;
    647 #endif
     650        (LPCDPMSG_REQUESTNEWPLAYERID)lpcMessageBody;
    648651      LPDPMSG_NEWPLAYERIDREPLY lpReply;
    649652
     
    654657                                                        *lpdwMsgSize );
    655658
    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
    675662
    676663      /* Setup the reply */
     
    690677    }
    691678
     679    case DPMSGCMD_GETNAMETABLEREPLY:
    692680    case DPMSGCMD_NEWPLAYERIDREPLY:
    693681    {
    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 );
    708683
    709684      break;
    710685    }
    711686
     687    case DPMSGCMD_FORWARDADDPLAYERNACK:
     688    {
     689      DP_MSG_ErrorReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize );
     690      break;
     691    }
     692
    712693    default:
    713694    {
    714695      FIXME( "Unknown wCommandId %u. Ignoring message\n", wCommandId );
     696      DebugBreak();
    715697      break;
    716698    }
     
    887869  lpGData->dwFlags = dwFlags;
    888870
     871  TRACE( "Created group id 0x%08lx\n", *lpid );
     872
    889873  return lpGData;
    890874}
     
    982966  {
    983967    This->dp2->lpSysGroup = lpGData;
     968    TRACE( "Inserting system group\n" );
    984969  }
    985970  else
     
    11631148  }
    11641149
     1150  /* Initialize the SP data section */
     1151  lpPData->lpSPPlayerData = DPSP_CreateSPPlayerData();
     1152
     1153  TRACE( "Created player id 0x%08lx\n", *lpid );
     1154
    11651155  return lpPData;
    11661156}
     
    11701160DP_DeleteDPNameStruct( LPDPNAME lpDPName )
    11711161{
    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 );
    11741164}
    11751165
     
    12341224
    12351225  /* 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 );
    12441234  }
    12451235
     
    12491239  if( bAnsi )
    12501240  {
    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 );
    12621252    }
    12631253  }
    12641254  else
    12651255  {
    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 );
    12771267    }
    12781268  }
     
    13391329  lpPlayerData lpPData;
    13401330  lpPlayerList lpPList;
     1331  DWORD dwCreateFlags = 0;
    13411332
    13421333  TRACE( "(%p)->(%p,%p,%d,%p,0x%08lx,0x%08lx,%u)\n",
     
    13521343  {
    13531344    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;
    13541373  }
    13551374
     
    13741393    else
    13751394    {
    1376       hr = DP_MSG_SendRequestPlayerId( This, dwFlags, lpidPlayer );
     1395      hr = DP_MSG_SendRequestPlayerId( This, dwCreateFlags, lpidPlayer );
    13771396
    13781397      if( FAILED(hr) )
     
    13901409  }
    13911410
     1411  /* FIXME: Should we be storing these dwFlags or the creation ones? */
    13921412  lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwFlags,
    13931413                             hEvent, bAnsi );
     
    14201440  {
    14211441    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;
    14381442
    14391443    data.idPlayer          = *lpidPlayer;
     
    14421446    data.lpISP             = This->dp2->spData.lpISP;
    14431447
     1448    TRACE( "Calling SP CreatePlayer 0x%08lx: dwFlags: 0x%08lx lpMsgHdr: %p\n",
     1449           *lpidPlayer, data.dwFlags, data.lpSPMessageHeader );
     1450
    14441451    hr = (*This->dp2->spData.lpCB->CreatePlayer)( &data );
    14451452  }
     
    14671474  if( FAILED(hr) )
    14681475  {
    1469     ERR( "Failed to add player to sys groupwith sp: %s\n",
     1476    ERR( "Failed to add player to sys group with sp: %s\n",
    14701477         DPLAYX_HresultToString(hr) );
    14711478    return hr;
    14721479  }
    14731480
     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
    14741492  /* Inform all other peers of the creation of a new player. If there are
    14751493   * no peers keep this quiet.
     
    14981516                    sizeof( msg ), 0, 0, NULL, NULL, bAnsi );
    14991517  }
     1518#endif
    15001519
    15011520  return hr;
     
    20692088  if( This->dp2->hEnumSessionThread != INVALID_HANDLE_VALUE )
    20702089  {
    2071     TRACE( "Killing EnumSession thread\n" );
     2090    TRACE( "Killing EnumSession thread %u\n",
     2091           This->dp2->hEnumSessionThread );
    20722092
    20732093    /* Request that the thread kill itself nicely */
     
    21082128    dwTimeout = spCaps.dwTimeout;
    21092129
    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    }
    21112136  }
    21122137
     
    23352360  dwRequiredDataSize = lpGData->name.dwSize;
    23362361
    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;
    23452370  }
    23462371
     
    23562381  CopyMemory( lpName, &lpGData->name, lpGData->name.dwSize );
    23572382
    2358   if( lpGData->name.psn.lpszShortNameA )
     2383  if( lpGData->name.u1.lpszShortNameA )
    23592384  {
    23602385    strcpy( ((char*)lpName)+lpGData->name.dwSize,
    2361             lpGData->name.psn.lpszShortNameA );
     2386            lpGData->name.u1.lpszShortNameA );
    23622387  }
    23632388  else
    23642389  {
    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 )
    23692394  {
    23702395    strcpy( ((char*)lpName)+lpGData->name.dwSize,
    2371             lpGData->name.pln.lpszLongNameA );
     2396            lpGData->name.u2.lpszLongNameA );
    23722397  }
    23732398  else
    23742399  {
    2375     lpName->pln.lpszLongNameA = NULL;
     2400    lpName->u2.lpszLongNameA = NULL;
    23762401  }
    23772402
     
    25352560  dwRequiredDataSize = lpPList->lpPData->name.dwSize;
    25362561
    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;
    25452570  }
    25462571
     
    25562581  CopyMemory( lpName, &lpPList->lpPData->name, lpPList->lpPData->name.dwSize );
    25572582
    2558   if( lpPList->lpPData->name.psn.lpszShortNameA )
     2583  if( lpPList->lpPData->name.u1.lpszShortNameA )
    25592584  {
    25602585    strcpy( ((char*)lpName)+lpPList->lpPData->name.dwSize,
    2561             lpPList->lpPData->name.psn.lpszShortNameA );
     2586            lpPList->lpPData->name.u1.lpszShortNameA );
    25622587  }
    25632588  else
    25642589  {
    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 )
    25692594  {
    25702595    strcpy( ((char*)lpName)+lpPList->lpPData->name.dwSize,
    2571             lpPList->lpPData->name.pln.lpszLongNameA );
     2596            lpPList->lpPData->name.u2.lpszLongNameA );
    25722597  }
    25732598  else
    25742599  {
    2575     lpName->pln.lpszLongNameA = NULL;
     2600    lpName->u2.lpszLongNameA = NULL;
    25762601  }
    25772602
     
    31373162  if( bAnsi )
    31383163  {
    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;
    31473172    }
    31483173  }
    31493174  else /* UNICODE */
    31503175  {
    3151     if( lpSessDesc->sess.lpszSessionName )
     3176    if( lpSessDesc->u1.lpszSessionName )
    31523177    {
    31533178      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 )
    31583183    {
    31593184      dwSize += sizeof( WCHAR ) *
    3160         ( lstrlenW( lpSessDesc->pass.lpszPassword ) + 1 );
     3185        ( lstrlenW( lpSessDesc->u2.lpszPassword ) + 1 );
    31613186    }
    31623187  }
     
    31833208  if( bAnsi )
    31843209  {
    3185     if( lpSessionSrc->sess.lpszSessionNameA )
     3210    if( lpSessionSrc->u1.lpszSessionNameA )
    31863211    {
    31873212      lstrcpyA( (LPSTR)lpStartOfFreeSpace,
    3188                 lpSessionDest->sess.lpszSessionNameA );
    3189       lpSessionDest->sess.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;
     3213                lpSessionDest->u1.lpszSessionNameA );
     3214      lpSessionDest->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;
    31903215      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 )
    31953220    {
    31963221      lstrcpyA( (LPSTR)lpStartOfFreeSpace,
    3197                 lpSessionDest->pass.lpszPasswordA );
    3198       lpSessionDest->pass.lpszPasswordA = (LPSTR)lpStartOfFreeSpace;
     3222                lpSessionDest->u2.lpszPasswordA );
     3223      lpSessionDest->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace;
    31993224      lpStartOfFreeSpace +=
    3200         lstrlenA( (LPSTR)lpSessionDest->pass.lpszPasswordA ) + 1;
     3225        lstrlenA( (LPSTR)lpSessionDest->u2.lpszPasswordA ) + 1;
    32013226    }
    32023227  }
    32033228  else /* UNICODE */
    32043229  {
    3205     if( lpSessionSrc->sess.lpszSessionName )
     3230    if( lpSessionSrc->u1.lpszSessionName )
    32063231    {
    32073232      lstrcpyW( (LPWSTR)lpStartOfFreeSpace,
    3208                 lpSessionDest->sess.lpszSessionName );
    3209       lpSessionDest->sess.lpszSessionName = (LPWSTR)lpStartOfFreeSpace;
     3233                lpSessionDest->u1.lpszSessionName );
     3234      lpSessionDest->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace;
    32103235      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 )
    32153240    {
    32163241      lstrcpyW( (LPWSTR)lpStartOfFreeSpace,
    3217                 lpSessionDest->pass.lpszPassword );
    3218       lpSessionDest->pass.lpszPassword = (LPWSTR)lpStartOfFreeSpace;
     3242                lpSessionDest->u2.lpszPassword );
     3243      lpSessionDest->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace;
    32193244      lpStartOfFreeSpace += sizeof(WCHAR) *
    3220         ( lstrlenW( (LPWSTR)lpSessionDest->pass.lpszPassword ) + 1 );
     3245        ( lstrlenW( (LPWSTR)lpSessionDest->u2.lpszPassword ) + 1 );
    32213246    }
    32223247  }
     
    34993524      DWORD    returnTypeGUID, sizeOfReturnBuffer = 50;
    35003525      char     returnBuffer[51];
    3501       LPWSTR   lpWGUIDString;
     3526      WCHAR    buff[51];
    35023527      DPNAME   dpName;
    35033528      HRESULT  hr;
     
    35263551
    35273552      /* 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 );
    35313555      /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
    35323556
     
    35343558      dpName.dwSize             = sizeof( dpName );
    35353559      dpName.dwFlags            = 0;
    3536       dpName.psn.lpszShortNameA = subKeyName;
    3537       dpName.pln.lpszLongNameA  = NULL;
     3560      dpName.u1.lpszShortNameA = subKeyName;
     3561      dpName.u2.lpszLongNameA  = NULL;
    35383562
    35393563      /* 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 by
    3542                allocating an 80 byte buffer which isn't even a filled with a valid compound
    3543                address. Oh well. Creating a proper compound address is the way to go anyways
     3564         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 ...
    35443568               despite this method taking slightly more heap space and realtime :) */
    35453569      dpCompoundAddress.dwDataSize   = sizeof( GUID );
     
    36053629      DWORD    returnTypeGUID, sizeOfReturnBuffer = 50;
    36063630      char     returnBuffer[51];
    3607       LPWSTR   lpWGUIDString;
     3631      WCHAR    buff[51];
    36083632      DPNAME   dpName;
    36093633      HRESULT  hr;
     
    36323656
    36333657      /* 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 );
    36373660      /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
    36383661
     
    36403663      dpName.dwSize             = sizeof( dpName );
    36413664      dpName.dwFlags            = 0;
    3642       dpName.psn.lpszShortNameA = subKeyName;
    3643       dpName.pln.lpszLongNameA  = NULL;
     3665      dpName.u1.lpszShortNameA = subKeyName;
     3666      dpName.u2.lpszLongNameA  = NULL;
    36443667
    36453668      /* 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 by
    3648                allocating an 80 byte buffer which isn't even a filled with a valid compound
    3649                address. Oh well. Creating a proper compound address is the way to go anyways
     3669         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 ...
    36503673               despite this method taking slightly more heap space and realtime :) */
    36513674      dpCompoundAddress.guidDataType = DPAID_LobbyProvider;
     
    38063829
    38073830/* Find and perform a LoadLibrary on the requested SP or LP GUID */
    3808 static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData )
     3831static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData, LPBOOL lpbIsDpSp )
    38093832{
    38103833  UINT i;
     
    38283851
    38293852    (i == 0) ? (searchSubKey = spSubKey ) : (searchSubKey = lpSubKey );
     3853    *lpbIsDpSp = (i == 0) ? TRUE : FALSE;
    38303854
    38313855
     
    38503874      DWORD    returnType, sizeOfReturnBuffer = 255;
    38513875      char     returnBuffer[256];
    3852       LPWSTR   lpWGUIDString;
    3853       DWORD    dwTemp;
     3876      WCHAR    buff[51];
     3877      DWORD    dwTemp, len;
    38543878
    38553879      TRACE(" this time through: %s\n", subKeyName );
     
    38723896
    38733897      /* 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 );
    38773900      /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
    38783901
     
    38843907
    38853908      /* 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 );
    38873912
    38883913      sizeOfReturnBuffer = 255;
     
    39243949      }
    39253950
     3951      TRACE( "Loading %s\n", returnBuffer );
    39263952      return LoadLibraryA( returnBuffer );
    39273953    }
     
    39313957}
    39323958
    3933 static HRESULT WINAPI DirectPlay3AImpl_InitializeConnection
    3934           ( LPDIRECTPLAY3A iface, LPVOID lpConnection, DWORD dwFlags )
     3959static HRESULT WINAPI DP_IF_InitializeConnection
     3960          ( IDirectPlay3Impl* This, LPVOID lpConnection, DWORD dwFlags, BOOL bAnsi )
    39353961{
    39363962  HMODULE hServiceProvider;
     
    39383964  LPDPSP_SPINIT SPInit;
    39393965  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 );
    39453970
    39463971  if( dwFlags != 0 )
     
    39723997
    39733998  /* Load the service provider */
    3974   hServiceProvider = DP_LoadSP( &guidSP, &This->dp2->spData );
     3999  hServiceProvider = DP_LoadSP( &guidSP, &This->dp2->spData, &bIsDpSp );
    39754000
    39764001  if( hServiceProvider == 0 )
     
    39804005  }
    39814006
    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  }
    39844017
    39854018  if( SPInit == NULL )
    39864019  {
    3987     ERR( "Service provider doesn't provide SPInit interface?\n" );
     4020    ERR( "Service provider doesn't provide %s interface?\n",
     4021         bIsDpSp ? "SPInit" : "DPLSPInit" );
    39884022    FreeLibrary( hServiceProvider );
    39894023    return DPERR_UNAVAILABLE;
    39904024  }
    39914025
    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   */
    39934031  hr = (*SPInit)( &This->dp2->spData );
    39944032
    39954033  if( FAILED(hr) )
    39964034  {
    3997     ERR( "SP Initialization failed: %s\n", DPLAYX_HresultToString(hr) );
     4035    ERR( "DP/DPL SP Initialization failed: %s\n", DPLAYX_HresultToString(hr) );
    39984036    FreeLibrary( hServiceProvider );
    39994037    return hr;
     
    40094047}
    40104048
     4049static 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
    40114056static HRESULT WINAPI DirectPlay3WImpl_InitializeConnection
    40124057          ( LPDIRECTPLAY3 iface, LPVOID lpConnection, DWORD dwFlags )
    40134058{
    40144059  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 );
    40174061}
    40184062
     
    48164860};
    48174861
     4862extern
     4863HRESULT 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
     4879extern
     4880HRESULT 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}
    48184895
    48194896/***************************************************************************
    4820  *  DirectPlayEnumerateA (DPLAYX.2)
     4897 *  DirectPlayEnumerateA [DPLAYX.2][DPLAYX.9][DPLAY.2]
    48214898 *
    48224899 *  The pointer to the structure lpContext will be filled with the
     
    48824959    DWORD    returnTypeGUID, returnTypeReserved, sizeOfReturnBuffer = 50;
    48834960    char     returnBuffer[51];
     4961    WCHAR    buff[51];
    48844962    DWORD    majVersionNum , minVersionNum = 0;
    4885     LPWSTR   lpWGUIDString;
    48864963
    48874964    TRACE(" this time through: %s\n", subKeyName );
     
    49074984
    49084985    /* 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 );
    49124988
    49134989    /* FIXME: Need to know which of dwReserved1 and dwReserved2 are maj and min */
     
    49505026
    49515027/***************************************************************************
    4952  *  DirectPlayEnumerateW (DPLAYX.3)
     5028 *  DirectPlayEnumerateW ([DPLAYX.3]
    49535029 *
    49545030 */
     
    49975073
    49985074/***************************************************************************
    4999  *  DirectPlayCreate (DPLAYX.1) (DPLAY.1)
     5075 *  DirectPlayCreate [DPLAYX.1][DPLAY.1]
    50005076 *
    50015077 */
     
    50145090  }
    50155091
    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
    50185093     give them an IDirectPlay2A object and hope that doesn't cause problems */
    50195094  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:40 hugh Exp $
     1// $Id: dplay_global.h,v 1.3 2001-03-13 23:13:28 hugh Exp $
    22#ifndef __WINE_DPLAY_GLOBAL_INCLUDED
    33#define __WINE_DPLAY_GLOBAL_INCLUDED
     
    3737} EnumSessionAsyncCallbackData;
    3838
     39typedef 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
     48typedef 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
    3954struct PlayerData
    4055{
     
    5570  DWORD  dwRemoteDataSize;
    5671
     72  /* SP data on a per player basis */
     73  LPVOID lpSPPlayerData;
     74
    5775  DWORD  dwFlags; /* Special remarks about the type of player */
    5876};
     
    139157  BOOL bConnectionInitialized;
    140158
    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;
    145161} DirectPlay2Data;
    146162
     
    194210                          LPVOID* lplpReply, LPDWORD lpdwMsgSize );
    195211
     212/* DP SP external interfaces into DirectPlay */
     213extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData );
     214extern HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID lpData );
     215
     216/* DP external interfaces to call into DPSP interface */
     217extern LPVOID DPSP_CreateSPPlayerData(void);
    196218
    197219#endif /* __WINE_DPLAY_GLOBAL_INCLUDED */
  • trunk/src/DPlayX/dplaysp.cpp

    r4446 r5311  
    1 // $Id: dplaysp.cpp,v 1.3 2000-10-06 19:49:04 hugh Exp $
     1// $Id: dplaysp.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $
    22/* This contains the implementation of the interface Service
    33 * Providers require to communicate with Direct Play
     
    5858  IDirectPlay2Impl* dplay; /* FIXME: This should perhaps be iface not impl */
    5959
    60   LPVOID lpPlayerData; /* FIXME: Need to figure out how this actually behaves */
    61   DWORD dwPlayerDataSize;
    6260} DirectPlaySPData;
    6361
     
    7573/* Forward declaration of virtual tables */
    7674extern ICOM_VTABLE(IDirectPlaySP) directPlaySPVT;
     75
     76/* This structure is passed to the DP object for safe keeping */
     77typedef struct tagDP_SPPLAYERDATA
     78{
     79  LPVOID lpPlayerLocalData;
     80  DWORD  dwPlayerLocalDataSize;
     81
     82  LPVOID lpPlayerRemoteData;
     83  DWORD  dwPlayerRemoteDataSize;
     84} DP_SPPLAYERDATA, *LPDP_SPPLAYERDATA;
    7785
    7886
     
    177185  /* IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp ); */
    178186
     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
    179196  return TRUE;
    180197}
     
    375392)
    376393{
    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",
    381400         This, idPlayer, lplpData, lpdwDataSize, dwFlags );
    382401
     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
    383410  /* 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;
    389438}
    390439
     
    403452  ICOM_THIS(IDirectPlaySPImpl,iface);
    404453
    405   TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() );
     454/*  TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
    406455  FIXME( "(%p)->(%p,0x%08lx,%p): mostly stub\n",
    407456         This, lpMessageBody, dwMessageBodySize, lpMessageHeader );
     
    421470  {
    422471    /* Name server needs to handle this request */
     472    /* FIXME: This should be done in direct play handler */
    423473    case DPMSGCMD_ENUMSESSIONSREQUEST:
    424474    {
     
    442492
    443493    /* Name server needs to handle this request */
     494    /* FIXME: This should be done in direct play handler */
    444495    case DPMSGCMD_ENUMSESSIONSREPLY:
    445496    {
     
    450501
    451502      /* 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:
    460510    {
    461511      DPSP_REPLYDATA data;
     
    465515
    466516      /* 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,
    468518                        lpMessageHeader, wCommandId, wVersion,
    469519                        &data.lpMessage, &data.dwMessageSize );
     
    488538      break;
    489539    }
    490 
    491     default:
    492       FIXME( "Unknown Command of %u and size 0x%08lx\n",
    493              lpMsg->wCommandId, dwMessageBodySize );
    494540  }
    495541
     
    748794)
    749795{
    750   ICOM_THIS(IDirectPlaySPImpl,iface);
    751 
    752   /* FIXME: I'm not sure if this stuff should be associated with the DPlay
    753    *        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",
    758804         This, idPlayer, lpData, dwDataSize, dwFlags );
    759805
    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;
    766830}
    767831
     
    789853)
    790854{
    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() ); */
    794859  TRACE( "(%p)->(%p,%p,0x%08lx)\n",
    795860         This, lplpData, lpdwDataSize, dwFlags );
     
    797862#if 0
    798863  /* This is what the documentation says... */
    799   if( dwFlags != 0 )
     864  if( dwFlags != DPSET_REMOTE )
    800865  {
    801866    return DPERR_INVALIDPARAMS;
     
    806871   * thing?
    807872   */
    808   if( dwFlags != 0 )
     873  if( dwFlags != DPSET_REMOTE )
    809874  {
    810875    FIXME( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
    811876  }
    812877#endif
     878
     879  /* FIXME: What to do in the case where this isn't initialized yet? */
    813880
    814881  /* Yes, we're supposed to return a pointer to the memory we have stored! */
     
    817884    *lpdwDataSize = This->sp->dwSpRemoteDataSize;
    818885    *lplpData     = This->sp->lpSpRemoteData;
     886
     887    if( This->sp->lpSpRemoteData == NULL )
     888    {
     889      hr = DPERR_GENERIC;
     890    }
    819891  }
    820892  else if( dwFlags == DPSET_LOCAL )
     
    822894    *lpdwDataSize = This->sp->dwSpLocalDataSize;
    823895    *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;
    827904}
    828905
     
    838915  ICOM_THIS(IDirectPlaySPImpl,iface);
    839916
    840   TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() );
     917/*  TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
    841918  TRACE( "(%p)->(%p,0x%08lx,0x%08lx)\n",
    842919         This, lpData, dwDataSize, dwFlags );
     
    844921#if 0
    845922  /* This is what the documentation says... */
    846   if( dwFlags != 0 )
     923  if( dwFlags != DPSET_REMOTE )
    847924  {
    848925    return DPERR_INVALIDPARAMS;
     
    853930   * thing?
    854931   */
    855   if( dwFlags != 0 )
     932  if( dwFlags != DPSET_REMOTE )
    856933  {
    857934    FIXME( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
     
    859936#endif
    860937
    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 );
    870939  CopyMemory( lpSpData, lpData, dwDataSize );
    871940
     
    873942  if( dwFlags == DPSET_REMOTE )
    874943  {
    875     /* FIXME: This doesn't strictly make sense as there is no means to share
    876      *        this shared data. Must be misinterpreting something...
    877      */
    878944    if( This->sp->lpSpRemoteData )
    879945    {
    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
    884949    This->sp->dwSpRemoteDataSize = dwDataSize;
    885950    This->sp->lpSpRemoteData = lpSpData;
     
    933998  IDirectPlaySPImpl_SendComplete
    934999};
     1000
     1001
     1002/* DP external interfaces to call into DPSP interface */
     1003
     1004/* Allocate the structure */
     1005extern 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:39 hugh Exp $
     1// $Id: dplaysp.h,v 1.3 2001-03-13 23:13:28 hugh Exp $
    22#ifndef __WINE_DIRECT_PLAY_SP_H
    33#define __WINE_DIRECT_PLAY_SP_H
     
    5757#undef ICOM_INTERFACE
    5858
     59/* NOTE: The microsoft provided header file doesn't have these access
     60 * functions
     61 */
    5962/*** 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)
    6366/*** IDirectPlaySP methods ***/
    64 #define IDirectPlaySP_AddMRUEntry           ICOM_CALL5(AddMRUEntry,p,a,b,c,d,e)
    65 #define IDirectPlaySP_CreateAddress        ICOM_CALL6(CreateAddress,p,a,b,c,d,e,f)
    66 #define IDirectPlaySP_EnumAddress           ICOM_CALL4(EnumAddress,p,a,b,c,d)
    67 #define IDirectPlaySP_EnumMRUEntries        ICOM_CALL4(EnumMRUEntries,p,a,b,c,d)
    68 #define IDirectPlaySP_GetPlayerFlags        ICOM_CALL2(GetPlayerFlags,p,a,b)
    69 #define IDirectPlaySP_GetSPPlayerData       ICOM_CALL4(GetSPPlayerData,p,a,b,c,d)
    70 #define IDirectPlaySP_HandleMessage         ICOM_CALL3(HandleMessage,p,a,b,c)
    71 #define IDirectPlaySP_SetSPPlayerData       ICOM_CALL4(SetSPPlayerData,p,a,b,c,d)
    72 #define IDirectPlaySP_CreateCompoundAddress ICOM_CALL4(CreateCompoundAddress,p,a,b,c,d)
    73 #define IDirectPlaySP_GetSPData             ICOM_CALL3(GetSPData,p,a,b,c)
    74 #define IDirectPlaySP_SetSPData             ICOM_CALL3(SetSPData,p,a,b,c)
    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)
    7679
    7780/* SP Callback stuff */
     
    333336 * SP directly
    334337 */
    335 extern __declspec(dllimport) DWORD gdwDPlaySPRefCount;
     338//extern __declspec(dllimport) DWORD gdwDPlaySPRefCount;
     339extern DWORD gdwDPlaySPRefCount;
    336340
    337341#endif
  • trunk/src/DPlayX/dplayx_global.cpp

    r4446 r5311  
    1 // $Id: dplayx_global.cpp,v 1.3 2000-10-06 19:49:05 hugh Exp $
     1// $Id: dplayx_global.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $
    22/* dplayx.dll global data implementation.
    33 *
     
    659659
    660660    /* 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;
    665665      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;
    673673      lpStartOfFreeSpace +=
    674         strlen( (LPSTR)dest->lpSessionDesc->pass.lpszPasswordA ) + 1;
     674        strlen( (LPSTR)dest->lpSessionDesc->u2.lpszPasswordA ) + 1;
    675675    }
    676676  }
     
    683683    CopyMemory( dest->lpPlayerName, src->lpPlayerName, sizeof( DPNAME ) );
    684684
    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;
    689689      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;
    697697      lpStartOfFreeSpace +=
    698         strlen( (LPSTR)dest->lpPlayerName->pln.lpszLongName ) + 1 ;
     698        strlen( (LPSTR)dest->lpPlayerName->u2.lpszLongName ) + 1 ;
    699699    }
    700700
     
    781781
    782782    /* 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;
    787787      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;
    795795      lpStartOfFreeSpace +=  sizeof(WCHAR) *
    796         ( strlenW( (LPWSTR)dest->lpSessionDesc->pass.lpszPassword ) + 1 );
     796        ( strlenW( (LPWSTR)dest->lpSessionDesc->u2.lpszPassword ) + 1 );
    797797    }
    798798  }
     
    805805    CopyMemory( dest->lpPlayerName, src->lpPlayerName, sizeof( DPNAME ) );
    806806
    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;
    811811      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;
    819819      lpStartOfFreeSpace +=  sizeof(WCHAR) *
    820         ( strlenW( (LPWSTR)dest->lpPlayerName->pln.lpszLongName ) + 1 );
     820        ( strlenW( (LPWSTR)dest->lpPlayerName->u2.lpszLongName ) + 1 );
    821821    }
    822822
     
    964964    dwTotalSize += sizeof( DPSESSIONDESC2 );
    965965
    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;
    974974    }
    975975  }
     
    979979    dwTotalSize += sizeof( DPNAME );
    980980
    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;
    989989    }
    990990
     
    10111011    dwTotalSize += sizeof( DPSESSIONDESC2 );
    10121012
    1013     if( lpConn->lpSessionDesc->sess.lpszSessionName )
     1013    if( lpConn->lpSessionDesc->u1.lpszSessionName )
    10141014    {
    10151015      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 )
    10201020    {
    10211021      dwTotalSize += sizeof( WCHAR ) *
    1022         ( strlenW( lpConn->lpSessionDesc->pass.lpszPassword ) + 1 );
     1022        ( strlenW( lpConn->lpSessionDesc->u2.lpszPassword ) + 1 );
    10231023    }
    10241024  }
     
    10281028    dwTotalSize += sizeof( DPNAME );
    10291029
    1030     if( lpConn->lpPlayerName->psn.lpszShortName )
     1030    if( lpConn->lpPlayerName->u1.lpszShortName )
    10311031    {
    10321032      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 )
    10371037    {
    10381038      dwTotalSize += sizeof( WCHAR ) *
    1039         ( strlenW( lpConn->lpPlayerName->pln.lpszLongName ) + 1 );
     1039        ( strlenW( lpConn->lpPlayerName->u2.lpszLongName ) + 1 );
    10401040    }
    10411041
     
    10651065  CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) );
    10661066
    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 );
    10781078  }
    10791079
  • trunk/src/DPlayX/dplayx_main.cpp

    r5135 r5311  
    1 // $Id: dplayx_main.cpp,v 1.3 2001-02-14 15:14:41 sandervl Exp $
     1// $Id: dplayx_main.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $
    22/*
    33 * DPLAYX.DLL LibMain
     
    2323
    2424DEFAULT_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;
     25DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    2926
    3027/* This is a globally exported variable at ordinal 6 of DPLAYX.DLL */
     
    3431{
    3532
    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 );
    3734
    3835  switch ( fdwReason )
    3936  {
    4037    case DLL_PROCESS_ATTACH:
    41     {
    42 
    43       if ( DPLAYX_dwProcessesAttached++ == 0 )
    44       {
    4538        /* First instance perform construction of global processor data */
    4639        return DPLAYX_ConstructData();
    47       }
    48 
    49       break;
    50     }
    5140
    5241    case DLL_PROCESS_DETACH:
    5342    {
    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();
    6046#ifdef __WIN32OS2__
     47      if(gdwDPlaySPRefCount==0) // only do this the last time ?
    6148        ctordtorTerm();
    6249#endif
    6350        return rc;
    64       }
    6551
    6652      break;
  • trunk/src/DPlayX/dplayx_messages.cpp

    r4446 r5311  
    1 // $Id: dplayx_messages.cpp,v 1.3 2000-10-06 19:49:05 hugh Exp $
     1// $Id: dplayx_messages.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $
    22/* DirectPlay & DirectPlayLobby messaging implementation
    33 *
     
    2424#include "dplayx_global.h"
    2525
    26 DEFAULT_DEBUG_CHANNEL(dplay)
     26DEFAULT_DEBUG_CHANNEL(dplay);
    2727
    2828#undef  debugstr_guid
     
    3939
    4040static DWORD CALLBACK DPL_MSG_ThreadMain( LPVOID lpContext );
     41static LPVOID DP_MSG_ExpectReply( IDirectPlay2AImpl* This, LPDPSP_SENDDATA data,
     42                                  DWORD dwWaitTime, WORD wReplyCommandId,
     43                                  LPVOID* lplpReplyMsg, LPDWORD lpdwMsgBodySize );
    4144
    4245/* Create the message reception thread to allow the application to receive
     
    133136  {
    134137    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 );
    142139  }
    143140
     
    149146}
    150147
     148/* DP messageing stuff */
     149static HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This,
     150                                              LPDP_MSG_REPLY_STRUCT_LIST lpReplyStructList,
     151                                              WORD wReplyCommandId );
     152static LPVOID DP_MSG_CleanReplyStruct( LPDP_MSG_REPLY_STRUCT_LIST lpReplyStructList,
     153                                       LPVOID* lplpReplyMsg, LPDWORD lpdwMsgBodySize );
     154
     155
     156static
     157HANDLE 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
     173static
     174LPVOID 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}
    151184
    152185HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags,
     
    156189  LPDPMSG_REQUESTNEWPLAYERID lpMsgBody;
    157190  DWORD                      dwMsgSize;
    158   DWORD                      dwWaitReturn;
    159191  HRESULT                    hr = DP_OK;
    160192
     
    166198                                             This->dp2->spData.dwSPHeaderSize );
    167199
     200  /* Compose dplay message envelope */
    168201  lpMsgBody->envelope.dwMagic    = DPMSGMAGIC_DPLAYMSG;
    169202  lpMsgBody->envelope.wCommandId = DPMSGCMD_REQUESTNEWPLAYERID;
    170203  lpMsgBody->envelope.wVersion   = DPMSGVER_DP6;
    171204
     205  /* Compose the body of the message */
    172206  lpMsgBody->dwFlags = dwFlags;
    173207
    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 */
    180209  {
    181210    DPSP_SENDDATA data;
     
    189218    data.lpISP          = This->dp2->spData.lpISP;
    190219
    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
    215229
    216230  /* Need to examine the data and extract the new player id */
     
    219233    LPCDPMSG_NEWPLAYERIDREPLY lpcReply;
    220234
    221     lpcReply = (LPCDPMSG_NEWPLAYERIDREPLY)This->dp2->lpMsgReceived;
     235    lpcReply = (LPCDPMSG_NEWPLAYERIDREPLY)lpMsg;
    222236
    223237    *lpdpidAllocatedId = lpcReply->dpidNewPlayerId;
     
    227241    /* FIXME: I think that the rest of the message has something to do
    228242     *        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?
    229247     */
     248
     249    HeapFree( GetProcessHeap(), 0, lpMsg );
     250  }
     251
     252  return hr;
     253}
     254
     255HRESULT 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
    230274#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  }
    235297#endif
    236298
    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" );
    239354  }
    240355
     
    242357}
    243358
    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 */
     365static
     366LPVOID 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 );
    261382
    262383  if( FAILED(hr) )
    263384  {
    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 */
     405void 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
     445void 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:06 hugh Exp $
     1// $Id: dplayx_messages.h,v 1.4 2001-03-13 23:13:28 hugh Exp $
    22
    33#ifndef __WINE_DPLAYX_MESSAGES__
     
    1313                                         HANDLE hDeath, HANDLE hConnRead );
    1414
     15HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags,
     16                                    LPDPID lpdipidAllocatedId );
     17HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer );
     18
     19void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId,
     20                           LPCVOID lpMsgBody, DWORD dwMsgBodySize );
     21void 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
    1529
    1630/* Message types etc. */
     
    2034#define DPMSGCMD_ENUMSESSIONSREPLY    1
    2135#define DPMSGCMD_ENUMSESSIONSREQUEST  2
    22 
     36#define DPMSGCMD_GETNAMETABLEREPLY    3  /* Contains all existing players in session */
    2337
    2438#define DPMSGCMD_REQUESTNEWPLAYERID   5
    2539
    2640#define DPMSGCMD_NEWPLAYERIDREPLY     7
    27 #define DPMSGCMD_CREATESESSION        8
     41#define DPMSGCMD_CREATESESSION        8 /* Might be a create nameserver or new player msg */
    2842#define DPMSGCMD_CREATENEWPLAYER      9
    2943#define DPMSGCMD_SYSTEMMESSAGE        10
     
    3347#define DPMSGCMD_ENUMGROUPS           17
    3448
    35 #define DPMSGCMD_GETNAMETABLE         19
     49#define DPMSGCMD_FORWARDADDPLAYER     19
    3650
    37 #define DPMSGCMD_GETNAMETABLEREPLY    29
     51#define DPMSGCMD_FORWARDADDPLAYERNACK 36
    3852
    3953/* This is what DP 6 defines it as. Don't know what it means. All messages
     
    4761/* All messages sent from the system are sent with this at the beginning of
    4862 * the message.
     63 * Size is 8 bytes
    4964 */
    50 
    51 /* Size is 8 bytes */
    5265typedef struct tagDPMSG_SENDENVELOPE
    5366{
     
    5871typedef const DPMSG_SENDENVELOPE* LPCDPMSG_SENDENVELOPE;
    5972
     73/* System messages exchanged between players seems to have this
     74 * payload envelope on top of the basic envelope
     75 */
    6076typedef struct tagDPMSG_SYSMSGENVELOPE
    6177{
     
    6581typedef const DPMSG_SYSMSGENVELOPE* LPCDPMSG_SYSMSGENVELOPE;
    6682
    67 
     83/* Reply sent in response to an enumsession request */
    6884typedef struct tagDPMSG_ENUMSESSIONSREPLY
    6985{
     
    95111typedef const DPMSG_ENUMSESSIONSREPLY* LPCDPMSG_ENUMSESSIONSREPLY;
    96112
     113/* Msg sent to find out what sessions are available */
    97114typedef struct tagDPMSG_ENUMSESSIONSREQUEST
    98115{
     
    101118  GUID  guidApplication;
    102119
    103   DWORD dwPasswordSize; /* A Guess. This is normally 0x00000000. */
     120  DWORD dwPasswordSize; /* A Guess. This is 0x00000000. */
    104121                        /* This might be the name server DPID which
    105122                           is needed for the reply */
     
    133150
    134151  DPID dpidNewPlayerId;
    135 #if 1
     152
    136153  /* Assume that this is data that is tacked on to the end of the message
    137154   * that comes from the SP remote data stored that needs to be propagated.
    138155   */
    139156  BYTE unknown[36];     /* This appears to always be 0 - not sure though */
    140 #endif
    141 
    142157} DPMSG_NEWPLAYERIDREPLY, *LPDPMSG_NEWPLAYERIDREPLY;
    143158typedef const DPMSG_NEWPLAYERIDREPLY* LPCDPMSG_NEWPLAYERIDREPLY;
    144159
     160typedef 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;
     184typedef 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 */
     189typedef struct tagDPMSG_FORWARDADDPLAYERNACK
     190{
     191  DPMSG_SENDENVELOPE envelope;
     192  HRESULT errorCode;
     193} DPMSG_FORWARDADDPLAYERNACK, *LPDPMSG_FORWARDADDPLAYERNACK;
     194typedef const DPMSG_FORWARDADDPLAYERNACK* LPCDPMSG_FORWARDADDPLAYERNACK;
     195
    145196#include "poppack.h"
    146197
    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 
    155198#endif
  • trunk/src/DPlayX/dplobby.cpp

    r4446 r5311  
    1 // $Id: dplobby.cpp,v 1.3 2000-10-06 19:49:05 hugh Exp $
     1// $Id: dplobby.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $
    22/* Direct Play Lobby 2 & 3 Implementation
    33 *
     
    1616#include "winnt.h"
    1717#include "winreg.h"
     18#include "winnls.h"
    1819#include "heap.h"
    1920#include "heapstring.h"
     
    2627#include "dplayx_queue.h"
    2728
    28 DEFAULT_DEBUG_CHANNEL(dplay)
     29DEFAULT_DEBUG_CHANNEL(dplay);
    2930
    3031#undef  debugstr_guid
     
    363364
    364365  CopyMemory( *ppvObj, iface, sizeof( IDirectPlayLobbyWImpl )  );
    365   (*(IDirectPlayLobbyWImpl**)ppvObj)->ulInterfaceRef = 0;
     366  (*(IDirectPlayLobbyAImpl**)ppvObj)->ulInterfaceRef = 0;
    366367
    367368  if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
     
    767768      char     atSubKey[51];
    768769      char     returnBuffer[51];
    769       LPWSTR   lpWGUIDString;
     770      WCHAR    buff[51];
    770771      DWORD    dwAtIndex;
    771772      LPSTR    atKey = "Address Types";
     
    793794
    794795      /* 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 );
    798798      /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
    799799
     
    821821
    822822        /* 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 );
    826825        /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
    827826
     
    918917    DWORD      returnTypeGUID, sizeOfReturnBuffer = 50;
    919918    char       returnBuffer[51];
    920     LPWSTR     lpWGUIDString;
     919    WCHAR      buff[51];
    921920    DPLAPPINFO dplAppInfo;
    922921
     
    940939
    941940    /* 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 );
    945943    /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
    946944
    947945    dplAppInfo.dwSize               = sizeof( dplAppInfo );
    948946    dplAppInfo.guidApplication      = serviceProviderGUID;
    949     dplAppInfo.appName.lpszAppNameA = subKeyName;
     947    dplAppInfo.u.lpszAppNameA = subKeyName;
    950948
    951949    EnterCriticalSection( &This->unk->DPL_lock );
     
    10961094    else
    10971095    {
    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 );
    10991098    }
    11001099
     
    11091108    else
    11101109    {
    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 );
    11121112    }
    11131113
     
    11221122    else
    11231123    {
    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 );
    11251126    }
    11261127
     
    11351136    else
    11361137    {
    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 );
    11381140    }
    11391141
     
    11491151{
    11501152  /* These are the handles for the created process */
    1151   HANDLE hAppStart, hAppDeath, hAppRead, hTemp;;
     1153  HANDLE hAppStart, hAppDeath, hAppRead, hTemp;
    11521154  SECURITY_ATTRIBUTES s_attrib;
    11531155
     
    12451247  HeapFree( GetProcessHeap(), 0, enumData.lpszPath );
    12461248  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 );
    12481250
    12491251  /* Now the command line */
     
    12511253  strcat( temp, enumData.lpszCommandLine );
    12521254  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 );
    12541257
    12551258  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:06 hugh Exp $
     1// $Id: name_server.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $
    22/* DPLAYX.DLL name server implementation
    33 *
     
    1818#include "winbase.h"
    1919#include "winuser.h"
     20#include "winnls.h"
     21#include "wine/unicode.h"
    2022#include "debugtools.h"
    2123#include "heap.h"
     
    8284                                       LPVOID                    lpNSInfo )
    8385{
     86  DWORD len;
    8487  lpNSCache     lpCache = (lpNSCache)lpNSInfo;
    8588  lpNSCacheData lpCacheNode;
     
    128131
    129132  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();
    135139
    136140  DPQ_INSERT(lpCache->first, lpCacheNode, next );
     
    199203}
    200204
     205/* Delete a name server node which has been allocated on the heap */
    201206DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData )
    202207{
     
    209214}
    210215
    211 
    212 
    213216/* Render all data in a session cache invalid */
    214217void NS_InvalidateSessionCache( LPVOID lpNSInfo )
     
    257260void NS_ResetSessionEnumeration( LPVOID lpNSInfo )
    258261{
    259 
    260262  ((lpNSCache)lpNSInfo)->present = ((lpNSCache)lpNSInfo)->first.lpQHFirst;
    261263}
     
    285287 * older than the criteria. If so, just delete that information.
    286288 */
     289/* FIXME: This needs to be called by some periodic timer */
    287290void NS_PruneSessionCache( LPVOID lpNSInfo )
    288291{
     
    337340}
    338341
    339 
    340 
    341 /* Message stuff */
     342/* NAME SERVER Message stuff */
    342343void NS_ReplyToEnumSessionsRequest( LPVOID lpMsg,
    343344                                    LPDPSP_REPLYDATA lpReplyData,
     
    347348  DWORD dwVariableSize;
    348349  DWORD dwVariableLen;
    349   LPWSTR string;
    350350  /* LPDPMSG_ENUMSESSIONSREQUEST msg = (LPDPMSG_ENUMSESSIONSREQUEST)lpMsg; */
    351351  BOOL bAnsi = TRUE; /* FIXME: This needs to be in the DPLAY interface */
     
    353353  FIXME( ": few fixed + need to check request for response\n" );
    354354
    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;
    357361
    358362  dwVariableSize = dwVariableLen * sizeof( WCHAR );
     
    374378  rmsg->dwUnknown = 0x0000005c;
    375379  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 );
    381382  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.