Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

823 lines
22 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dplparam.cpp
  6. * Content: DirectPlayLobby8 Parameter Validation helper routines
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 04/18/00 rmt Created
  12. * 04/25/00 rmt Bug #s 33138, 33145, 33150
  13. * 04/26/00 mjn Removed dwTimeOut from Send() API call
  14. * 06/15/00 rmt Bug #33617 - Must provide method for providing automatic launch of DirectPlay instances
  15. * 07/08/2000 rmt Bug #38725 - Need to provide method to detect if app was lobby launched
  16. * rmt Bug #38757 - Callback messages for connections may return AFTER WaitForConnection returns
  17. * rmt Bug #38755 - No way to specify player name in Connection Settings
  18. * rmt Bug #38758 - DPLOBBY8.H has incorrect comments
  19. * rmt Bug #38783 - pvUserApplicationContext is only partially implemented
  20. * rmt Added DPLHANDLE_ALLCONNECTIONS and dwFlags (reserved field to couple of funcs).
  21. *
  22. ***************************************************************************/
  23. #include "dnlobbyi.h"
  24. extern IUnknownVtbl DN_UnknownVtbl;
  25. #undef DPF_MODNAME
  26. #define DPF_MODNAME "DPL_ValidateGetConnectionSettings"
  27. HRESULT DPL_ValidateGetConnectionSettings(LPVOID lpv,const DPNHANDLE hLobbyClient, DPL_CONNECTION_SETTINGS * const pdplSessionInfo, DWORD *pdwInfoSize, const DWORD dwFlags )
  28. {
  29. if( !IsValidDirectPlayLobby8Object( lpv ) )
  30. {
  31. DPFERR( "Invalid object" );
  32. return DPNERR_INVALIDOBJECT;
  33. }
  34. if( hLobbyClient == DPLHANDLE_ALLCONNECTIONS )
  35. {
  36. DPFERR( "Cannot specify ALLCONNECTIONS for GetConnectionSettings" );
  37. return DPNERR_INVALIDHANDLE;
  38. }
  39. if( hLobbyClient == 0 )
  40. {
  41. DPFERR( "Invalid connection ID" );
  42. return DPNERR_INVALIDHANDLE;
  43. }
  44. if( pdwInfoSize == NULL || !DNVALID_WRITEPTR( pdwInfoSize, sizeof( DWORD ) ) )
  45. {
  46. DPFERR( "Invalid pointer specified for infosize" );
  47. return DPNERR_INVALIDPOINTER;
  48. }
  49. if( *pdwInfoSize > 0 &&
  50. (pdplSessionInfo == NULL || !DNVALID_WRITEPTR( pdplSessionInfo, *pdwInfoSize ) ) )
  51. {
  52. DPFERR( "Invalid pointer specified for session info pointer" );
  53. return DPNERR_INVALIDPOINTER;
  54. }
  55. if( dwFlags != 0 )
  56. {
  57. DPFERR( "Invalid flags specified" );
  58. return DPNERR_INVALIDFLAGS;
  59. }
  60. return DPN_OK;
  61. }
  62. #undef DPF_MODNAME
  63. #define DPF_MODNAME "DPL_ValidateSetConnectionSettings"
  64. HRESULT DPL_ValidateSetConnectionSettings(LPVOID lpv,const DPNHANDLE hLobbyClient, const DPL_CONNECTION_SETTINGS * const pdplSessionInfo, const DWORD dwFlags )
  65. {
  66. HRESULT hr;
  67. if( !IsValidDirectPlayLobby8Object( lpv ) )
  68. {
  69. DPFERR( "Invalid object" );
  70. return DPNERR_INVALIDOBJECT;
  71. }
  72. if( hLobbyClient == 0 )
  73. {
  74. DPFERR( "Invalid handle" );
  75. return DPNERR_INVALIDHANDLE;
  76. }
  77. if( pdplSessionInfo != NULL )
  78. {
  79. hr = DPL_ValidConnectionSettings( pdplSessionInfo );
  80. if( FAILED( hr ) )
  81. {
  82. DPFERR( "Error validating connectsettings struct" );
  83. return hr;
  84. }
  85. }
  86. if( dwFlags != 0 )
  87. {
  88. DPFERR( "Invalid flags specified" );
  89. return DPNERR_INVALIDFLAGS;
  90. }
  91. return DPN_OK;
  92. }
  93. #undef DPF_MODNAME
  94. #define DPF_MODNAME "DPL_ValidateConnectionSettings"
  95. HRESULT DPL_ValidConnectionSettings( const DPL_CONNECTION_SETTINGS * const pdplConnectSettings )
  96. {
  97. if( pdplConnectSettings == NULL || !DNVALID_READPTR( pdplConnectSettings, sizeof( DPL_CONNECTION_SETTINGS ) ) )
  98. {
  99. DPFERR( "Invalid pointer specified for connection settings field" );
  100. return DPNERR_INVALIDPOINTER;
  101. }
  102. if( pdplConnectSettings->dwSize != sizeof( DPL_CONNECTION_SETTINGS ) )
  103. {
  104. DPFERR( "Invalid size specified for dplconnectsettings struct" );
  105. return DPNERR_INVALIDPARAM;
  106. }
  107. if( pdplConnectSettings->dwFlags & ~( DPLCONNECTSETTINGS_HOST ) )
  108. {
  109. DPFERR( "Invalid flags specified in connectsettings struct" );
  110. return DPNERR_INVALIDFLAGS;
  111. }
  112. if( pdplConnectSettings->dpnAppDesc.dwSize != sizeof( DPN_APPLICATION_DESC ) )
  113. {
  114. DPFERR( "Invalid size specified on app desc" );
  115. return DPNERR_INVALIDPOINTER;
  116. }
  117. if( pdplConnectSettings->dpnAppDesc.pwszSessionName != NULL &&
  118. !DNVALID_STRING_W( pdplConnectSettings->dpnAppDesc.pwszSessionName ) )
  119. {
  120. DPFERR( "Invalid session name specified on app desc" );
  121. return DPNERR_INVALIDSTRING;
  122. }
  123. if( pdplConnectSettings->dpnAppDesc.pwszPassword != NULL &&
  124. !DNVALID_STRING_W( pdplConnectSettings->dpnAppDesc.pwszPassword ) )
  125. {
  126. DPFERR( "Invalid password specified on app desc" );
  127. return DPNERR_INVALIDSTRING;
  128. }
  129. if( pdplConnectSettings->dpnAppDesc.dwReservedDataSize != 0 &&
  130. !DNVALID_READPTR( pdplConnectSettings->dpnAppDesc.pvReservedData, pdplConnectSettings->dpnAppDesc.dwReservedDataSize ) )
  131. {
  132. DPFERR( "Invalid reserved data specified on app desc" );
  133. return DPNERR_INVALIDPOINTER;
  134. }
  135. if( pdplConnectSettings->dpnAppDesc.dwApplicationReservedDataSize != 0 &&
  136. !DNVALID_READPTR( pdplConnectSettings->dpnAppDesc.pvApplicationReservedData,
  137. pdplConnectSettings->dpnAppDesc.dwApplicationReservedDataSize ) )
  138. {
  139. DPFERR( "Invalid application reserved data specified on app desc" );
  140. return DPNERR_INVALIDPOINTER;
  141. }
  142. if( pdplConnectSettings->dwFlags & DPLCONNECTSETTINGS_HOST )
  143. {
  144. if( pdplConnectSettings->pdp8HostAddress != NULL )
  145. {
  146. DPFERR( "Host address must be NULL if description is for host" );
  147. return DPNERR_INVALIDPARAM;
  148. }
  149. }
  150. else
  151. {
  152. if( pdplConnectSettings->pdp8HostAddress == NULL ||
  153. !DNVALID_READPTR( pdplConnectSettings->pdp8HostAddress, sizeof( IDirectPlay8Address * ) ) )
  154. {
  155. DPFERR( "Invalid host address specified" );
  156. return DPNERR_INVALIDHOSTADDRESS;
  157. }
  158. }
  159. if( pdplConnectSettings->ppdp8DeviceAddresses == NULL ||
  160. !DNVALID_READPTR( pdplConnectSettings->ppdp8DeviceAddresses, pdplConnectSettings->cNumDeviceAddresses * sizeof( IDirectPlay8Address * ) ) )
  161. {
  162. DPFERR( "Invalid device addresses specified" );
  163. return DPNERR_INVALIDDEVICEADDRESS;
  164. }
  165. if( pdplConnectSettings->cNumDeviceAddresses == 0 )
  166. {
  167. DPFERR( "You must specify at least one device address" );
  168. return DPNERR_INVALIDPARAM;
  169. }
  170. return DPN_OK;
  171. }
  172. #undef DPF_MODNAME
  173. #define DPF_MODNAME "DPL_ValidateQueryInterface"
  174. HRESULT DPL_ValidateQueryInterface( LPVOID lpv,REFIID riid,LPVOID *ppv )
  175. {
  176. if( !IsValidDirectPlayLobby8Object( lpv ) )
  177. {
  178. DPFERR( "Invalid object" );
  179. return DPNERR_INVALIDOBJECT;
  180. }
  181. if( ppv == NULL || !DNVALID_WRITEPTR( ppv, sizeof( void * ) ) )
  182. {
  183. DPFERR( "Invalid pointer specified for target of queryinterface" );
  184. return DPNERR_INVALIDPOINTER;
  185. }
  186. return DPN_OK;
  187. }
  188. #undef DPF_MODNAME
  189. #define DPF_MODNAME "DPL_ValidateRelease"
  190. HRESULT DPL_ValidateRelease( PVOID pv )
  191. {
  192. if( !IsValidDirectPlayLobby8Object( pv ) )
  193. {
  194. DPFERR( "Invalid object" );
  195. return DPNERR_INVALIDOBJECT;
  196. }
  197. return DPN_OK;
  198. }
  199. #undef DPF_MODNAME
  200. #define DPF_MODNAME "DPL_ValidateAddRef"
  201. HRESULT DPL_ValidateAddRef( PVOID pv )
  202. {
  203. if( !IsValidDirectPlayLobby8Object( pv ) )
  204. {
  205. DPFERR( "Invalid object" );
  206. return DPNERR_INVALIDOBJECT;
  207. }
  208. return DPN_OK;
  209. }
  210. #undef DPF_MODNAME
  211. #define DPF_MODNAME "DPL_ValidateRegisterMessageHandler"
  212. HRESULT DPL_ValidateRegisterMessageHandler(PVOID pv,
  213. const PVOID pvUserContext,
  214. const PFNDPNMESSAGEHANDLER pfn,
  215. DPNHANDLE * const pdpnhConnection,
  216. const DWORD dwFlags)
  217. {
  218. if( !IsValidDirectPlayLobby8Object( pv ) )
  219. {
  220. DPFERR( "Invalid object" );
  221. return DPNERR_INVALIDOBJECT;
  222. }
  223. if( pfn == NULL )
  224. {
  225. DPFERR( "Invalid pointer for message handler " );
  226. return DPNERR_INVALIDPOINTER;
  227. }
  228. if( pdpnhConnection )
  229. {
  230. if( !DNVALID_WRITEPTR( pdpnhConnection, sizeof( DPNHANDLE ) ) )
  231. {
  232. DPFERR( "Invalid pointer specified for connection handle" );
  233. return DPNERR_INVALIDPOINTER;
  234. }
  235. }
  236. if( dwFlags & ~(DPLINITIALIZE_DISABLEPARAMVAL) )
  237. {
  238. DPFERR( "Invalid flags specified" );
  239. return DPNERR_INVALIDFLAGS;
  240. }
  241. return DPN_OK;
  242. }
  243. #undef DPF_MODNAME
  244. #define DPF_MODNAME "DPL_ValidateClose"
  245. HRESULT DPL_ValidateClose(PVOID pv, const DWORD dwFlags )
  246. {
  247. if( !IsValidDirectPlayLobby8Object( pv ) )
  248. {
  249. DPFERR( "Invalid object" );
  250. return DPNERR_INVALIDOBJECT;
  251. }
  252. if( dwFlags != 0 )
  253. {
  254. DPFERR( "Invalid flags specified" );
  255. return DPNERR_INVALIDFLAGS;
  256. }
  257. return DPN_OK;
  258. }
  259. #undef DPF_MODNAME
  260. #define DPF_MODNAME "DPL_ValidateSend"
  261. HRESULT DPL_ValidateSend(PVOID pv,
  262. const DPNHANDLE hTarget,
  263. BYTE *const pBuffer,
  264. const DWORD dwBufferSize,
  265. const DWORD dwFlags)
  266. {
  267. if( !IsValidDirectPlayLobby8Object( pv ) )
  268. {
  269. DPFERR( "Invalid object" );
  270. return DPNERR_INVALIDOBJECT;
  271. }
  272. if( hTarget == 0 )
  273. {
  274. DPFERR( "Invalid handle" );
  275. return DPNERR_INVALIDHANDLE;
  276. }
  277. if( pBuffer == NULL ||
  278. !DNVALID_READPTR( pBuffer, dwBufferSize ) )
  279. {
  280. DPFERR( "Invalid pointer specified for buffer" );
  281. return DPNERR_INVALIDPOINTER;
  282. }
  283. if( dwBufferSize == 0 )
  284. {
  285. DPFERR( "Invalid buffer size specified" );
  286. return DPNERR_INVALIDPARAM;
  287. }
  288. if( dwBufferSize > 0x10000 )
  289. {
  290. DPFERR( "Queue does not support sends > 0x10000 in size" );
  291. return DPNERR_SENDTOOLARGE;
  292. }
  293. if( dwFlags != 0 )
  294. {
  295. DPFERR( "Invalid flags specified" );
  296. return DPNERR_INVALIDFLAGS;
  297. }
  298. return DPN_OK;
  299. }
  300. #undef DPF_MODNAME
  301. #define DPF_MODNAME "DPL_ValidateEnumLocalPrograms"
  302. HRESULT DPL_ValidateEnumLocalPrograms(IDirectPlay8LobbyClient *pInterface,
  303. GUID *const pGuidApplication,
  304. BYTE *const pEnumData,
  305. DWORD *const pdwEnumDataSize,
  306. DWORD *const pdwEnumDataItems,
  307. const DWORD dwFlags )
  308. {
  309. if( !IsValidDirectPlayLobby8Object( pInterface ) )
  310. {
  311. DPFERR( "Invalid object" );
  312. return DPNERR_INVALIDOBJECT;
  313. }
  314. if( pGuidApplication != NULL && !DNVALID_READPTR( pGuidApplication, sizeof( GUID ) ) )
  315. {
  316. DPFERR( "Invalid pointer specified for application guid" );
  317. return DPNERR_INVALIDPOINTER;
  318. }
  319. if( pdwEnumDataSize == NULL || !DNVALID_WRITEPTR( pdwEnumDataSize, sizeof( DWORD ) ) )
  320. {
  321. DPFERR( "Invalid pointer specified for enum data size" );
  322. return DPNERR_INVALIDPOINTER;
  323. }
  324. if( pdwEnumDataItems == NULL || !DNVALID_WRITEPTR( pdwEnumDataItems, sizeof( DWORD ) ) )
  325. {
  326. DPFERR( "Invalid pointer specified for enum data count" );
  327. return DPNERR_INVALIDPOINTER;
  328. }
  329. if( *pdwEnumDataSize > 0 &&
  330. (pEnumData == NULL || !DNVALID_WRITEPTR( pEnumData, *pdwEnumDataSize ) ) )
  331. {
  332. DPFERR( "Invalid enum data pointer specified" );
  333. return DPNERR_INVALIDPOINTER;
  334. }
  335. if( dwFlags != 0 )
  336. {
  337. DPFERR( "Invalid flags specified" );
  338. return DPNERR_INVALIDFLAGS;
  339. }
  340. return DPN_OK;
  341. }
  342. #undef DPF_MODNAME
  343. #define DPF_MODNAME "DPL_ValidateConnectApplication"
  344. HRESULT DPL_ValidateConnectApplication(IDirectPlay8LobbyClient *pInterface,
  345. DPL_CONNECT_INFO *const pdplConnectionInfo,
  346. const PVOID pvUserApplicationContext,
  347. DPNHANDLE *const hApplication,
  348. const DWORD dwTimeOut,
  349. const DWORD dwFlags)
  350. {
  351. HRESULT hResultCode;
  352. if( !IsValidDirectPlayLobby8Object( pInterface ) )
  353. {
  354. DPFERR( "Invalid object" );
  355. return DPNERR_INVALIDOBJECT;
  356. }
  357. if( FAILED( hResultCode = DPL_ValidConnectInfo( pdplConnectionInfo ) ) )
  358. {
  359. DPFX(DPFPREP, 0, "Error validating connect info hr=0x%x", hResultCode );
  360. return hResultCode;
  361. }
  362. if( hApplication == NULL ||
  363. !DNVALID_WRITEPTR( hApplication, sizeof( DPNHANDLE ) ) )
  364. {
  365. DPFERR( "Invalid pointer specified for application handle" );
  366. return DPNERR_INVALIDPOINTER;
  367. }
  368. if( dwFlags != 0 )
  369. {
  370. DPFERR( "Invalid flags" );
  371. return DPNERR_INVALIDFLAGS;
  372. }
  373. return DPN_OK;
  374. }
  375. #undef DPF_MODNAME
  376. #define DPF_MODNAME "DPL_ValidateReleaseApplication"
  377. HRESULT DPL_ValidateReleaseApplication(IDirectPlay8LobbyClient *pInterface,
  378. const DPNHANDLE hApplication, const DWORD dwFlags )
  379. {
  380. if( !IsValidDirectPlayLobby8Object( pInterface ) )
  381. {
  382. DPFERR( "Invalid object" );
  383. return DPNERR_INVALIDOBJECT;
  384. }
  385. if( hApplication == 0 )
  386. {
  387. DPFERR( "Invalid handle" );
  388. return DPNERR_INVALIDHANDLE;
  389. }
  390. if( dwFlags != 0 )
  391. {
  392. DPFERR( "Invalid flags" );
  393. return DPNERR_INVALIDFLAGS;
  394. }
  395. return DPN_OK;
  396. }
  397. #undef DPF_MODNAME
  398. #define DPF_MODNAME "DPL_ValidateUnRegisterProgram"
  399. HRESULT DPL_ValidateUnRegisterProgram(IDirectPlay8LobbiedApplication *pInterface,
  400. GUID *pguidApplication,
  401. const DWORD dwFlags)
  402. {
  403. if( !IsValidDirectPlayLobby8Object( pInterface ) )
  404. {
  405. DPFERR( "Invalid object" );
  406. return DPNERR_INVALIDOBJECT;
  407. }
  408. if( pguidApplication == NULL ||
  409. !DNVALID_READPTR( pguidApplication, sizeof( GUID ) ) )
  410. {
  411. DPFERR( "Invalid pointer to application GUID specified" );
  412. return DPNERR_INVALIDPOINTER;
  413. }
  414. if( dwFlags != 0 )
  415. {
  416. DPFERR( "Invalid flags specified" );
  417. return DPNERR_INVALIDFLAGS;
  418. }
  419. return DPN_OK;
  420. }
  421. #undef DPF_MODNAME
  422. #define DPF_MODNAME "DPL_ValidateSetAppAvailable"
  423. HRESULT DPL_ValidateSetAppAvailable(IDirectPlay8LobbiedApplication *pInterface, const BOOL fAvailable, const DWORD dwFlags )
  424. {
  425. if( !IsValidDirectPlayLobby8Object( pInterface ) )
  426. {
  427. DPFERR( "Invalid object" );
  428. return DPNERR_INVALIDOBJECT;
  429. }
  430. if( dwFlags & ~(DPLAVAILABLE_ALLOWMULTIPLECONNECT) )
  431. {
  432. DPFERR( "Invalid flags specified" );
  433. return DPNERR_INVALIDFLAGS;
  434. }
  435. return DPN_OK;
  436. }
  437. #undef DPF_MODNAME
  438. #define DPF_MODNAME "DPL_ValidateWaitForConnection"
  439. HRESULT DPL_ValidateWaitForConnection(IDirectPlay8LobbiedApplication *pInterface,
  440. const DWORD dwMilliseconds, const DWORD dwFlags )
  441. {
  442. if( !IsValidDirectPlayLobby8Object( pInterface ) )
  443. {
  444. DPFERR( "Invalid object" );
  445. return DPNERR_INVALIDOBJECT;
  446. }
  447. if( dwFlags != 0 )
  448. {
  449. DPFERR( "Invalid flags specified" );
  450. return DPNERR_INVALIDFLAGS;
  451. }
  452. return DPN_OK;
  453. }
  454. #undef DPF_MODNAME
  455. #define DPF_MODNAME "DPL_ValidateUpdateStatus"
  456. HRESULT DPL_ValidateUpdateStatus(IDirectPlay8LobbiedApplication *pInterface,
  457. const DPNHANDLE hLobby,
  458. const DWORD dwStatus,
  459. const DWORD dwFlags )
  460. {
  461. if( !IsValidDirectPlayLobby8Object( pInterface ) )
  462. {
  463. DPFERR( "Invalid object" );
  464. return DPNERR_INVALIDOBJECT;
  465. }
  466. if( hLobby == 0 )
  467. {
  468. DPFERR( "Invalid handle" );
  469. return DPNERR_INVALIDHANDLE;
  470. }
  471. if( dwStatus != DPLSESSION_CONNECTED &&
  472. dwStatus != DPLSESSION_COULDNOTCONNECT &&
  473. dwStatus != DPLSESSION_DISCONNECTED &&
  474. dwStatus != DPLSESSION_TERMINATED &&
  475. dwStatus != DPLSESSION_HOSTMIGRATED &&
  476. dwStatus != DPLSESSION_HOSTMIGRATEDHERE )
  477. {
  478. DPFERR( "Invalid status specified" );
  479. return DPNERR_INVALIDPARAM;
  480. }
  481. if( dwFlags != 0 )
  482. {
  483. DPFERR( "Invalid flags specified" );
  484. return DPNERR_INVALIDFLAGS;
  485. }
  486. return DPN_OK;
  487. }
  488. #undef DPF_MODNAME
  489. #define DPF_MODNAME "DPL_ValidateRegisterProgram"
  490. HRESULT DPL_ValidateRegisterProgram(IDirectPlay8LobbiedApplication *pInterface,
  491. DPL_PROGRAM_DESC *const pdplProgramDesc,
  492. const DWORD dwFlags)
  493. {
  494. HRESULT hResultCode;
  495. if( !IsValidDirectPlayLobby8Object( pInterface ) )
  496. {
  497. DPFERR( "Invalid object" );
  498. return DPNERR_INVALIDOBJECT;
  499. }
  500. if( FAILED( hResultCode = DPL_ValidProgramDesc(pdplProgramDesc) ) )
  501. {
  502. DPFX(DPFPREP, 0, "Error validating program desc structure hr=0x%x", hResultCode );
  503. return hResultCode;
  504. }
  505. if( dwFlags != 0 )
  506. {
  507. DPFERR( "Invalid flags specified" );
  508. return DPNERR_INVALIDFLAGS;
  509. }
  510. return DPN_OK;
  511. }
  512. #undef DPF_MODNAME
  513. #define DPF_MODNAME "DPL_ValidConnectInfo"
  514. HRESULT DPL_ValidConnectInfo( const DPL_CONNECT_INFO * const pdplConnectInfo )
  515. {
  516. if( pdplConnectInfo == NULL )
  517. {
  518. DPFERR( "Invalid pointer specified for connect info" );
  519. return DPNERR_INVALIDPOINTER;
  520. }
  521. if( pdplConnectInfo->dwSize != sizeof( DPL_CONNECT_INFO ) )
  522. {
  523. DPFERR( "Wrong size specified for connect info struct" );
  524. return DPNERR_INVALIDPARAM;
  525. }
  526. if( !DNVALID_READPTR( pdplConnectInfo, pdplConnectInfo->dwSize ) )
  527. {
  528. DPFERR( "Invalid pointer specified for connect info" );
  529. return DPNERR_INVALIDPOINTER;
  530. }
  531. if( pdplConnectInfo->dwFlags & ~(DPLCONNECT_LAUNCHNEW | DPLCONNECT_LAUNCHNOTFOUND) )
  532. {
  533. DPFERR("Invalid flags specified" );
  534. return DPNERR_INVALIDFLAGS;
  535. }
  536. if( pdplConnectInfo->dwFlags & DPLCONNECT_LAUNCHNEW &&
  537. pdplConnectInfo->dwFlags & DPLCONNECT_LAUNCHNOTFOUND )
  538. {
  539. DPFERR( "You cannot specify both launchnew and launchnotfound" );
  540. return DPNERR_INVALIDPARAM;
  541. }
  542. GUID guidTmp;
  543. memset( &guidTmp, 0x00, sizeof( GUID ) );
  544. if( pdplConnectInfo->guidApplication == guidTmp )
  545. {
  546. DPFERR( "Cannot specify GUID_NULL for the application GUID" );
  547. return DPNERR_INVALIDPARAM;
  548. }
  549. if( pdplConnectInfo->pdplConnectionSettings != NULL )
  550. {
  551. HRESULT hr = DPL_ValidConnectionSettings( pdplConnectInfo->pdplConnectionSettings );
  552. if( FAILED( hr ) )
  553. {
  554. DPFX(DPFPREP, 0, "Error validating connection settings field of connect info hr=0x%x", hr );
  555. return hr;
  556. }
  557. }
  558. if( pdplConnectInfo->dwLobbyConnectDataSize > 0 &&
  559. (pdplConnectInfo->pvLobbyConnectData == NULL || !DNVALID_READPTR( pdplConnectInfo->pvLobbyConnectData, pdplConnectInfo->dwLobbyConnectDataSize ) ) )
  560. {
  561. DPFERR( "Invalid pointer specified for lobby connect data" );
  562. return DPNERR_INVALIDPOINTER;
  563. }
  564. return DPN_OK;
  565. }
  566. #undef DPF_MODNAME
  567. #define DPF_MODNAME "DPL_ValidProgramDesc"
  568. HRESULT DPL_ValidProgramDesc( const DPL_PROGRAM_DESC * const pdplProgramInfo )
  569. {
  570. if( pdplProgramInfo == NULL )
  571. {
  572. DPFERR( "Invalid pointer specified for program info" );
  573. return DPNERR_INVALIDPOINTER;
  574. }
  575. if( pdplProgramInfo->dwSize != sizeof( DPL_PROGRAM_DESC ) )
  576. {
  577. DPFERR( "Wrong size specified for program info struct" );
  578. return DPNERR_INVALIDPARAM;
  579. }
  580. if( !DNVALID_READPTR( pdplProgramInfo, pdplProgramInfo->dwSize ) )
  581. {
  582. DPFERR( "Invalid pointer specified for app info" );
  583. return DPNERR_INVALIDPOINTER;
  584. }
  585. if( pdplProgramInfo->dwFlags != 0 )
  586. {
  587. DPFERR("Invalid flags specified" );
  588. return DPNERR_INVALIDFLAGS;
  589. }
  590. GUID guidTmp;
  591. memset( &guidTmp, 0x00, sizeof( GUID ) );
  592. if( pdplProgramInfo->guidApplication == guidTmp )
  593. {
  594. DPFERR( "Cannot specify GUID_NULL for the application GUID" );
  595. return DPNERR_INVALIDPARAM;
  596. }
  597. if( pdplProgramInfo->pwszApplicationName == NULL )
  598. {
  599. DPFERR( "You must specify an application name" );
  600. return DPNERR_INVALIDPARAM;
  601. }
  602. if( !DNVALID_STRING_W( pdplProgramInfo->pwszApplicationName ) )
  603. {
  604. DPFERR( "Invalid string specified for application name" );
  605. return DPNERR_INVALIDSTRING;
  606. }
  607. if( pdplProgramInfo->pwszCommandLine != NULL &&
  608. !DNVALID_STRING_W( pdplProgramInfo->pwszCommandLine ) )
  609. {
  610. DPFERR( "Invalid command-line string specified" );
  611. return DPNERR_INVALIDSTRING;
  612. }
  613. if( pdplProgramInfo->pwszCurrentDirectory != NULL &&
  614. !DNVALID_STRING_W( pdplProgramInfo->pwszCurrentDirectory ) )
  615. {
  616. DPFERR( "Invalid current directory string specified" );
  617. return DPNERR_INVALIDSTRING;
  618. }
  619. if( pdplProgramInfo->pwszDescription != NULL &&
  620. !DNVALID_STRING_W( pdplProgramInfo->pwszDescription ) )
  621. {
  622. DPFERR( "Invalid description string specified" );
  623. return DPNERR_INVALIDSTRING;
  624. }
  625. if( pdplProgramInfo->pwszExecutableFilename == NULL )
  626. {
  627. DPFERR( "You must specify an executable name" );
  628. return DPNERR_INVALIDPARAM;
  629. }
  630. if( !DNVALID_STRING_W( pdplProgramInfo->pwszExecutableFilename ) )
  631. {
  632. DPFERR( "Invalid string specified for executable name" );
  633. return DPNERR_INVALIDSTRING;
  634. }
  635. if( pdplProgramInfo->pwszExecutablePath != NULL &&
  636. !DNVALID_STRING_W( pdplProgramInfo->pwszExecutablePath ) )
  637. {
  638. DPFERR( "Invalid executable path string specified" );
  639. return DPNERR_INVALIDSTRING;
  640. }
  641. if( pdplProgramInfo->pwszLauncherFilename != NULL &&
  642. !DNVALID_STRING_W( pdplProgramInfo->pwszLauncherFilename ) )
  643. {
  644. DPFERR( "Invalid launcher filename string specified" );
  645. return DPNERR_INVALIDSTRING;
  646. }
  647. if( pdplProgramInfo->pwszLauncherPath != NULL &&
  648. !DNVALID_STRING_W( pdplProgramInfo->pwszLauncherPath ) )
  649. {
  650. DPFERR( "Invalid launcher path string specified" );
  651. return DPNERR_INVALIDSTRING;
  652. }
  653. return DPN_OK;
  654. }
  655. #undef DPF_MODNAME
  656. #define DPF_MODNAME "IsValidDirectPlayLobby8Object"
  657. BOOL IsValidDirectPlayLobby8Object( LPVOID lpvObject )
  658. {
  659. INTERFACE_LIST *pIntList = (INTERFACE_LIST *) lpvObject;
  660. if( !DNVALID_READPTR( lpvObject, sizeof( INTERFACE_LIST ) ) )
  661. {
  662. DPFX(DPFPREP, 0, "Invalid object pointer" );
  663. return FALSE;
  664. }
  665. if( pIntList->lpVtbl != &DPL_Lobby8ClientVtbl &&
  666. pIntList->lpVtbl != &DPL_8LobbiedApplicationVtbl &&
  667. pIntList->lpVtbl != &DN_UnknownVtbl
  668. )
  669. {
  670. DPFX(DPFPREP, 0, "Invalid object - bad vtable" );
  671. return FALSE;
  672. }
  673. if( pIntList->iid != IID_IDirectPlay8LobbyClient &&
  674. pIntList->iid != IID_IDirectPlay8LobbiedApplication &&
  675. pIntList->iid != IID_IUnknown )
  676. {
  677. DPFX(DPFPREP, 0, "Invalid object - bad iid" );
  678. return FALSE;
  679. }
  680. if( pIntList->lpObject == NULL ||
  681. !DNVALID_READPTR( pIntList->lpObject, sizeof( OBJECT_DATA ) ) )
  682. {
  683. DPFX(DPFPREP, 0, "Invalid object" );
  684. return FALSE;
  685. }
  686. DIRECTPLAYLOBBYOBJECT *pdpl = (DIRECTPLAYLOBBYOBJECT *) GET_OBJECT_FROM_INTERFACE( lpvObject );
  687. if( pdpl == NULL ||
  688. !DNVALID_READPTR( pdpl, sizeof( DIRECTPLAYLOBBYOBJECT ) ) )
  689. {
  690. DPFX(DPFPREP, 0, "Invalid object" );
  691. return FALSE;
  692. }
  693. return TRUE;
  694. }