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.

1123 lines
31 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: addtcp.cpp
  6. * Content: DirectPlay8Address TCP interace file
  7. *@@BEGIN_MSINTERNAL
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 02/04/2000 rmt Created
  12. * 02/12/2000 rmt Split Get into GetByName and GetByIndex
  13. * 02/17/2000 rmt Parameter validation work
  14. * 02/21/2000 rmt Updated to make core Unicode and remove ANSI calls
  15. * 03/21/2000 rmt Renamed all DirectPlayAddress8's to DirectPlay8Addresses
  16. * Added support for the new ANSI type
  17. * Added SetEqual function
  18. * 03/24/2000 rmt Added IsEqual function
  19. * 04/21/2000 rmt Bug #32952 - Does not run on Win95 GOLD pre-IE4
  20. * 05/01/2000 rmt Bug #33074 - Debug accessing invalid memory
  21. * 05/17/2000 rmt Bug #35051 - Incorrect function names in debug spew
  22. * 06/09/2000 rmt Updates to split CLSID and allow whistler compat
  23. * 07/21/2000 rmt Fixed bug w/directplay 4 address parsing
  24. * 02/07/2001 rmt WINBUG #290631 - IA64: DirectPlay: Addressing BuildFromDPADDRESS should always return UNSUPPORTED
  25. *
  26. *@@END_MSINTERNAL
  27. *
  28. ***************************************************************************/
  29. #include "dnaddri.h"
  30. typedef STDMETHODIMP BaseQueryInterface( IDirectPlay8Address *pInterface, REFIID riid, LPVOID *ppvObj );
  31. typedef STDMETHODIMP_(ULONG) BaseAddRef( IDirectPlay8Address *pInterface );
  32. typedef STDMETHODIMP_(ULONG) BaseRelease( IDirectPlay8Address *pInterface );
  33. //
  34. // VTable for client interface
  35. //
  36. IDirectPlay8AddressVtbl DP8A_BaseVtbl =
  37. {
  38. (BaseQueryInterface*) DP8A_QueryInterface,
  39. (BaseAddRef*) DP8A_AddRef,
  40. (BaseRelease*) DP8A_Release,
  41. DP8A_BuildFromURLW,
  42. DP8A_BuildFromURLA,
  43. DP8A_Duplicate,
  44. DP8A_SetEqual,
  45. DP8A_IsEqual,
  46. DP8A_Clear,
  47. DP8A_GetURLW,
  48. DP8A_GetURLA,
  49. DP8A_GetSP,
  50. DP8A_GetUserData,
  51. DP8A_SetSP,
  52. DP8A_SetUserData,
  53. DP8A_GetNumComponents,
  54. DP8A_GetComponentByNameW,
  55. DP8A_GetComponentByIndexW,
  56. DP8A_AddComponentW,
  57. DP8A_GetDevice,
  58. DP8A_SetDevice,
  59. DP8A_BuildFromDirectPlay4Address
  60. };
  61. //**********************************************************************
  62. // Function prototypes
  63. //**********************************************************************
  64. #undef DPF_MODNAME
  65. #define DPF_MODNAME "DP8A_IsEqual"
  66. STDMETHODIMP DP8A_IsEqual( IDirectPlay8Address *pInterface, PDIRECTPLAY8ADDRESS pdp8ExternalAddress )
  67. {
  68. if( pInterface == NULL ||
  69. !DP8A_VALID( pInterface ) )
  70. {
  71. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  72. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  73. }
  74. HRESULT hr;
  75. WCHAR *wszFirstURL = NULL,
  76. *wszSecondURL = NULL;
  77. DWORD dwFirstBufferSize = 0,
  78. dwSecondBuffersize = 0;
  79. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  80. if( pdp8ExternalAddress == NULL )
  81. {
  82. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified" );
  83. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  84. }
  85. if( !DP8A_VALID( pdp8ExternalAddress ) )
  86. {
  87. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid object" );
  88. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  89. }
  90. hr = pInterface->lpVtbl->GetURLW( pInterface, wszFirstURL, &dwFirstBufferSize );
  91. if( hr != DPNERR_BUFFERTOOSMALL )
  92. {
  93. DPFX(DPFPREP, 0, "Could not get URL size for current object hr=[0x%lx]", hr );
  94. goto ISEQUAL_ERROR;
  95. }
  96. wszFirstURL = new WCHAR[dwFirstBufferSize];
  97. if( wszFirstURL == NULL )
  98. {
  99. DPFX(DPFPREP, 0, "Error allocating memory hr=[0x%lx]", hr );
  100. goto ISEQUAL_ERROR;
  101. }
  102. hr = pInterface->lpVtbl->GetURLW( pInterface, wszFirstURL, &dwFirstBufferSize );
  103. if( FAILED( hr ) )
  104. {
  105. DPFX(DPFPREP, 0, "Could not get URL for current object hr=[0x%lx]", hr );
  106. goto ISEQUAL_ERROR;
  107. }
  108. hr = pdp8ExternalAddress->lpVtbl->GetURLW( pdp8ExternalAddress, wszSecondURL, &dwSecondBuffersize );
  109. if( hr != DPNERR_BUFFERTOOSMALL )
  110. {
  111. DPFX(DPFPREP, 0, "Could not get URL size for exterior object hr=[0x%lx]", hr );
  112. goto ISEQUAL_ERROR;
  113. }
  114. wszSecondURL = new WCHAR[dwSecondBuffersize];
  115. if( wszSecondURL == NULL )
  116. {
  117. DPFX(DPFPREP, 0, "Error allocating memory hr=[0x%lx]", hr );
  118. goto ISEQUAL_ERROR;
  119. }
  120. hr = pdp8ExternalAddress->lpVtbl->GetURLW( pdp8ExternalAddress, wszSecondURL, &dwSecondBuffersize );
  121. if( FAILED( hr ) )
  122. {
  123. DPFX(DPFPREP, 0, "Could not get URL for exterior object hr=[0x%lx]", hr );
  124. goto ISEQUAL_ERROR;
  125. }
  126. if( _wcsicmp( wszFirstURL, wszSecondURL ) == 0 )
  127. {
  128. hr = DPNSUCCESS_EQUAL;
  129. }
  130. else
  131. {
  132. hr = DPNSUCCESS_NOTEQUAL;
  133. }
  134. ISEQUAL_ERROR:
  135. if( wszFirstURL != NULL )
  136. delete [] wszFirstURL;
  137. if( wszSecondURL != NULL )
  138. delete [] wszSecondURL;
  139. DP8A_RETURN( hr );
  140. }
  141. #undef DPF_MODNAME
  142. #define DPF_MODNAME "DP8A_SetEqual"
  143. STDMETHODIMP DP8A_SetEqual( IDirectPlay8Address *pInterface, PDIRECTPLAY8ADDRESS pdp8ExternalAddress )
  144. {
  145. if( pInterface == NULL ||
  146. !DP8A_VALID( pInterface ) )
  147. {
  148. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  149. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  150. }
  151. DP8ADDRESSOBJECT *pdp8Address = (DP8ADDRESSOBJECT *) GET_OBJECT_FROM_INTERFACE( pInterface );
  152. HRESULT hr;
  153. WCHAR *wszURLBuffer = NULL;
  154. DWORD dwBufferSize = 0;
  155. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  156. if( pdp8ExternalAddress == NULL )
  157. {
  158. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified" );
  159. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  160. }
  161. if( !DP8A_VALID( pdp8ExternalAddress ) )
  162. {
  163. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid object" );
  164. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  165. }
  166. // Get ourselves a reference for duration of the call
  167. pdp8ExternalAddress->lpVtbl->AddRef(pdp8ExternalAddress);
  168. hr = pdp8ExternalAddress->lpVtbl->GetURLW( pdp8ExternalAddress, wszURLBuffer, &dwBufferSize );
  169. if( hr != DPNERR_BUFFERTOOSMALL )
  170. {
  171. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Error getting contents of passed address hr=0x%x", hr );
  172. goto SETEQUAL_CLEANUP;
  173. }
  174. wszURLBuffer = new WCHAR[dwBufferSize];
  175. if( wszURLBuffer == NULL )
  176. {
  177. hr = DPNERR_OUTOFMEMORY;
  178. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Error allocating memory" );
  179. goto SETEQUAL_CLEANUP;
  180. }
  181. hr = pdp8ExternalAddress->lpVtbl->GetURLW( pdp8ExternalAddress, wszURLBuffer, &dwBufferSize );
  182. if( FAILED( hr ) )
  183. {
  184. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Error getting contents of passed address w/buffer hr=0x%x", hr );
  185. goto SETEQUAL_CLEANUP;
  186. }
  187. hr = pdp8Address->SetURL( wszURLBuffer );
  188. if( FAILED( hr ) )
  189. {
  190. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Error setting address to match passed address hr=0x%x", hr );
  191. goto SETEQUAL_CLEANUP;
  192. }
  193. SETEQUAL_CLEANUP:
  194. pdp8ExternalAddress->lpVtbl->Release(pdp8ExternalAddress);
  195. if( wszURLBuffer != NULL )
  196. delete [] wszURLBuffer;
  197. DP8A_RETURN( hr );
  198. }
  199. #undef DPF_MODNAME
  200. #define DPF_MODNAME "DP8A_BuildFromDirectPlay4Address"
  201. STDMETHODIMP DP8A_BuildFromDirectPlay4Address( IDirectPlay8Address *pInterface, void * pvDataBuffer, DWORD dwDataSize )
  202. {
  203. // XBOX! This function will not be required on XBOX. Have it return DPNERR_NOTSUPPORTED
  204. if( pInterface == NULL ||
  205. !DP8A_VALID( pInterface ) )
  206. {
  207. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  208. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  209. }
  210. #ifdef _WIN64
  211. DPFX(DPFPREP, DP8A_ERRORLEVEL, "BuildFromDirectPlay4Address() is not supported on Win64" );
  212. DP8A_RETURN( E_NOTIMPL );
  213. #else
  214. DP8ADDRESSOBJECT *pdp8Address = (DP8ADDRESSOBJECT *) GET_OBJECT_FROM_INTERFACE( pInterface );
  215. HRESULT hr;
  216. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  217. if( dwDataSize == 0 )
  218. {
  219. DPFX(DPFPREP, DP8A_ERRORLEVEL, "0 length addresses are not allowed" );
  220. return DPNERR_INVALIDPARAM;
  221. }
  222. if( pvDataBuffer == NULL ||
  223. !DNVALID_READPTR( pvDataBuffer, dwDataSize ) )
  224. {
  225. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Specified buffer is invalid" );
  226. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  227. }
  228. hr = pdp8Address->SetDirectPlay4Address( pvDataBuffer, dwDataSize );
  229. DP8A_RETURN( hr );
  230. #endif
  231. }
  232. // DP8A_BuildFromURLA
  233. //
  234. // Initializes this object with URL specified in ANSI
  235. //
  236. #undef DPF_MODNAME
  237. #define DPF_MODNAME "DP8A_BuildFromURLA"
  238. STDMETHODIMP DP8A_BuildFromURLA( IDirectPlay8Address *pInterface, CHAR * pszAddress )
  239. {
  240. if( pInterface == NULL ||
  241. !DP8A_VALID( pInterface ) )
  242. {
  243. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  244. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  245. }
  246. DP8ADDRESSOBJECT *pdp8Address = (DP8ADDRESSOBJECT *) GET_OBJECT_FROM_INTERFACE( pInterface );
  247. HRESULT hr;
  248. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  249. if( pszAddress == NULL )
  250. {
  251. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer to address. An address must be specified" );
  252. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  253. }
  254. if( !DNVALID_STRING_A( pszAddress ) )
  255. {
  256. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid string specified for address" );
  257. DP8A_RETURN( DPNERR_INVALIDSTRING );
  258. }
  259. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pszAddress = %s", pszAddress );
  260. WCHAR *szShadowBuffer = NULL;
  261. DWORD dwStrSize = 0;
  262. if( pszAddress != NULL )
  263. {
  264. dwStrSize = strlen(pszAddress)+1;
  265. szShadowBuffer = new WCHAR[dwStrSize];
  266. if( szShadowBuffer == NULL )
  267. {
  268. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Error allocating memory" );
  269. hr = DPNERR_OUTOFMEMORY;
  270. goto BUILDFROMURLW_RETURN;
  271. }
  272. if( FAILED( hr = STR_jkAnsiToWide( szShadowBuffer, pszAddress, dwStrSize ) ) )
  273. {
  274. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Error converting URL to ANSI hr=0x%x", hr );
  275. hr = DPNERR_CONVERSION;
  276. goto BUILDFROMURLW_RETURN;
  277. }
  278. }
  279. hr = pdp8Address->SetURL( szShadowBuffer );
  280. BUILDFROMURLW_RETURN:
  281. if( szShadowBuffer )
  282. delete [] szShadowBuffer;
  283. DP8A_RETURN( hr );
  284. }
  285. // DP8A_BuildFromURLW
  286. //
  287. // Initializes this object with URL specified in Unicode
  288. //
  289. #undef DPF_MODNAME
  290. #define DPF_MODNAME "DP8A_BuildFromURLW"
  291. STDMETHODIMP DP8A_BuildFromURLW( IDirectPlay8Address *pInterface, WCHAR * pwszAddress )
  292. {
  293. if( pInterface == NULL ||
  294. !DP8A_VALID( pInterface ) )
  295. {
  296. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  297. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  298. }
  299. DP8ADDRESSOBJECT *pdp8Address = (DP8ADDRESSOBJECT *) GET_OBJECT_FROM_INTERFACE( pInterface );
  300. HRESULT hr;
  301. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  302. if( pwszAddress == NULL )
  303. {
  304. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer to address. An address must be specified" );
  305. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  306. }
  307. if( !DNVALID_STRING_W( pwszAddress ) )
  308. {
  309. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid string specified for address" );
  310. DP8A_RETURN( DPNERR_INVALIDSTRING );
  311. }
  312. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  313. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pwszAddress = 0x%p", pwszAddress );
  314. hr = pdp8Address->SetURL( pwszAddress );
  315. DP8A_RETURN( hr );
  316. }
  317. // DP8A_Duplicate
  318. //
  319. // Creates and initializes another address object as a duplicate to this one.
  320. //
  321. #undef DPF_MODNAME
  322. #define DPF_MODNAME "DP8A_Duplicate"
  323. STDMETHODIMP DP8A_Duplicate( IDirectPlay8Address *pInterface, PDIRECTPLAY8ADDRESS *ppInterface )
  324. {
  325. if( pInterface == NULL ||
  326. !DP8A_VALID( pInterface ) )
  327. {
  328. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  329. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  330. }
  331. DP8ADDRESSOBJECT *pdp8Address = (DP8ADDRESSOBJECT *) GET_OBJECT_FROM_INTERFACE( pInterface );
  332. HRESULT hr;
  333. WCHAR *szTmpURL = NULL;
  334. DWORD dwURLSize = 0;
  335. LPDIRECTPLAY8ADDRESS lpdp8Address = NULL;
  336. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  337. if( ppInterface == NULL ||
  338. !DNVALID_WRITEPTR( ppInterface, sizeof(LPVOID) ) )
  339. {
  340. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer to pointer specified in ppInterface" );
  341. hr = DPNERR_INVALIDPOINTER;
  342. goto DUPLICATE_FAIL;
  343. }
  344. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  345. DPFX(DPFPREP, DP8A_PARAMLEVEL, "ppInterface = 0x%p", ppInterface );
  346. hr = pdp8Address->BuildURL( szTmpURL, &dwURLSize );
  347. if( hr != DPNERR_BUFFERTOOSMALL )
  348. {
  349. DPFX(DPFPREP, DP8A_ERRORLEVEL, "BuildURL from object failed hr=0x%x", hr );
  350. goto DUPLICATE_FAIL;
  351. }
  352. szTmpURL = new WCHAR[dwURLSize];
  353. if( szTmpURL == NULL )
  354. {
  355. hr = DPNERR_OUTOFMEMORY;
  356. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Memory alloc failure" );
  357. goto DUPLICATE_FAIL;
  358. }
  359. hr = pdp8Address->BuildURL( szTmpURL, &dwURLSize );
  360. if( FAILED( hr ) )
  361. {
  362. DPFX(DPFPREP, DP8A_ERRORLEVEL, "BuildURL from object failed hr=0x%x", hr );
  363. goto DUPLICATE_FAIL;
  364. }
  365. hr = COM_CoCreateInstance( CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER , IID_IDirectPlay8Address, (void **) &lpdp8Address );
  366. if( FAILED( hr ) )
  367. {
  368. DPFX(DPFPREP, DP8A_ERRORLEVEL, "CoCreate failed hr=0x%x", hr );
  369. goto DUPLICATE_FAIL;
  370. }
  371. hr = lpdp8Address->lpVtbl->BuildFromURLW( lpdp8Address, szTmpURL );
  372. if( FAILED( hr ) )
  373. {
  374. DPFX(DPFPREP, DP8A_ERRORLEVEL, "BuildFailed hr=0x%x", hr );
  375. goto DUPLICATE_FAIL;
  376. }
  377. *ppInterface = lpdp8Address;
  378. if( szTmpURL != NULL )
  379. delete [] szTmpURL;
  380. return DPN_OK;
  381. DUPLICATE_FAIL:
  382. if( lpdp8Address != NULL )
  383. lpdp8Address->lpVtbl->Release(lpdp8Address);
  384. if( szTmpURL != NULL )
  385. delete [] szTmpURL;
  386. return hr;
  387. }
  388. #undef DPF_MODNAME
  389. #define DPF_MODNAME "DP8A_GetURLA"
  390. STDMETHODIMP DP8A_GetURLA( IDirectPlay8Address *pInterface, CHAR * pszAddress, PDWORD pdwAddressSize )
  391. {
  392. if( pInterface == NULL ||
  393. !DP8A_VALID( pInterface ) )
  394. {
  395. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  396. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  397. }
  398. DP8ADDRESSOBJECT *pdp8Address = (DP8ADDRESSOBJECT *) GET_OBJECT_FROM_INTERFACE( pInterface );
  399. HRESULT hr;
  400. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  401. if( pdwAddressSize == NULL ||
  402. !DNVALID_WRITEPTR( pdwAddressSize, sizeof(DWORD) ) )
  403. {
  404. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for address size" );
  405. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  406. }
  407. if( *pdwAddressSize > 0 &&
  408. (pszAddress == NULL ||
  409. !DNVALID_WRITEPTR( pszAddress, (*pdwAddressSize) ) ) )
  410. {
  411. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for address" );
  412. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  413. }
  414. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  415. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pwszAddress = 0x%p pdwAddressSize = 0x%p (%u)",
  416. pszAddress , pdwAddressSize, *pdwAddressSize );
  417. WCHAR *szShadowBuffer = NULL;
  418. if( *pdwAddressSize != 0 )
  419. {
  420. szShadowBuffer = new WCHAR[*pdwAddressSize];
  421. if( szShadowBuffer == NULL )
  422. {
  423. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Error allocating memory" );
  424. hr = DPNERR_OUTOFMEMORY;
  425. goto GETURLW_RETURN;
  426. }
  427. }
  428. else
  429. {
  430. szShadowBuffer= NULL;
  431. }
  432. hr = pdp8Address->BuildURL( szShadowBuffer, pdwAddressSize );
  433. if( hr == DPN_OK )
  434. {
  435. if( FAILED( hr = STR_jkWideToAnsi( pszAddress, szShadowBuffer, *pdwAddressSize ) ) )
  436. {
  437. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Error converting ANSI->WIDE hr=0x%x", hr );
  438. hr = DPNERR_CONVERSION;
  439. goto GETURLW_RETURN;
  440. }
  441. }
  442. GETURLW_RETURN:
  443. if( szShadowBuffer != NULL )
  444. delete [] szShadowBuffer;
  445. DP8A_RETURN( hr );
  446. }
  447. // DP8A_GetURLW
  448. //
  449. // Retrieves the URL represented by this object in Unicode format
  450. //
  451. #undef DPF_MODNAME
  452. #define DPF_MODNAME "DP8A_GetURLW"
  453. STDMETHODIMP DP8A_GetURLW( IDirectPlay8Address *pInterface, WCHAR * pwszAddress, PDWORD pdwAddressSize )
  454. {
  455. if( pInterface == NULL ||
  456. !DP8A_VALID( pInterface ) )
  457. {
  458. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  459. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  460. }
  461. DP8ADDRESSOBJECT *pdp8Address = (DP8ADDRESSOBJECT *) GET_OBJECT_FROM_INTERFACE( pInterface );
  462. HRESULT hr;
  463. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  464. if( pdwAddressSize == NULL ||
  465. !DNVALID_WRITEPTR( pdwAddressSize, sizeof(DWORD) ) )
  466. {
  467. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for address size" );
  468. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  469. }
  470. if( *pdwAddressSize > 0 &&
  471. (pwszAddress == NULL ||
  472. !DNVALID_WRITEPTR( pwszAddress, (*pdwAddressSize)*sizeof(WCHAR) ) ) )
  473. {
  474. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for address" );
  475. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  476. }
  477. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  478. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pwszAddress = 0x%p pdwAddressSize = 0x%p (%u)",
  479. pwszAddress, pdwAddressSize, *pdwAddressSize );
  480. hr = pdp8Address->BuildURL( pwszAddress, pdwAddressSize );
  481. DP8A_RETURN( hr );
  482. }
  483. #undef DPF_MODNAME
  484. #define DPF_MODNAME "DP8A_GetSP"
  485. STDMETHODIMP DP8A_GetSP( IDirectPlay8Address *pInterface, GUID * pguidSP )
  486. {
  487. if( pInterface == NULL ||
  488. !DP8A_VALID( pInterface ) )
  489. {
  490. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  491. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  492. }
  493. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  494. HRESULT hr;
  495. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  496. if( pguidSP == NULL ||
  497. !DNVALID_WRITEPTR( pguidSP, sizeof( GUID ) ) )
  498. {
  499. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pguidSP" );
  500. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  501. }
  502. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  503. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pguidSP = 0x%p ", pguidSP );
  504. hr = pdp8Address->GetSP( pguidSP );
  505. DP8A_RETURN( hr );
  506. }
  507. #undef DPF_MODNAME
  508. #define DPF_MODNAME "DP8A_GetUserData"
  509. STDMETHODIMP DP8A_GetUserData( IDirectPlay8Address *pInterface, void * pBuffer, PDWORD pdwBufferSize )
  510. {
  511. if( pInterface == NULL ||
  512. !DP8A_VALID( pInterface ) )
  513. {
  514. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  515. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  516. }
  517. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  518. HRESULT hr;
  519. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  520. if( pdwBufferSize == NULL ||
  521. !DNVALID_WRITEPTR( pdwBufferSize, sizeof( DWORD ) ) )
  522. {
  523. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pdwBufferSize" );
  524. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  525. }
  526. if( *pdwBufferSize > 0 &&
  527. (pBuffer == NULL || !DNVALID_WRITEPTR( pBuffer, *pdwBufferSize ) ) )
  528. {
  529. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pBuffer" );
  530. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  531. }
  532. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  533. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pBuffer = 0x%p pdwBufferSize = 0x%p(%u) ", pBuffer, pdwBufferSize, *pdwBufferSize );
  534. hr = pdp8Address->GetUserData( pBuffer, pdwBufferSize );
  535. DP8A_RETURN( hr );
  536. }
  537. #undef DPF_MODNAME
  538. #define DPF_MODNAME "DP8A_SetSP"
  539. STDMETHODIMP DP8A_SetSP( IDirectPlay8Address *pInterface, const GUID * const pguidSP )
  540. {
  541. if( pInterface == NULL ||
  542. !DP8A_VALID( pInterface ) )
  543. {
  544. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  545. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  546. }
  547. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  548. HRESULT hr;
  549. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  550. if( pguidSP == NULL ||
  551. !DNVALID_READPTR( pguidSP, sizeof( GUID ) ) )
  552. {
  553. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pguidSP" );
  554. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  555. }
  556. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  557. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pguidSP = 0x%p", pguidSP );
  558. hr = pdp8Address->SetSP( pguidSP );
  559. DP8A_RETURN( hr );
  560. }
  561. #undef DPF_MODNAME
  562. #define DPF_MODNAME "DP8A_GetDevice"
  563. STDMETHODIMP DP8A_GetDevice( IDirectPlay8Address *pInterface, GUID * pguidSP )
  564. {
  565. if( pInterface == NULL ||
  566. !DP8A_VALID( pInterface ) )
  567. {
  568. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  569. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  570. }
  571. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  572. HRESULT hr;
  573. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  574. if( pguidSP == NULL ||
  575. !DNVALID_WRITEPTR( pguidSP, sizeof( GUID ) ) )
  576. {
  577. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pguidDevice" );
  578. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  579. }
  580. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  581. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pguidDevice = 0x%p", pguidSP );
  582. hr = pdp8Address->GetDevice( pguidSP );
  583. DP8A_RETURN( hr );
  584. }
  585. #undef DPF_MODNAME
  586. #define DPF_MODNAME "DP8A_SetDevice"
  587. STDMETHODIMP DP8A_SetDevice( IDirectPlay8Address *pInterface, const GUID * const pguidSP )
  588. {
  589. if( pInterface == NULL ||
  590. !DP8A_VALID( pInterface ) )
  591. {
  592. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  593. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  594. }
  595. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  596. HRESULT hr;
  597. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  598. if( pguidSP == NULL ||
  599. !DNVALID_READPTR( pguidSP, sizeof( GUID ) ) )
  600. {
  601. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pguidDevice" );
  602. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  603. }
  604. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  605. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pguidDevice = 0x%p", pguidSP );
  606. hr = pdp8Address->SetDevice( pguidSP );
  607. DP8A_RETURN( hr );
  608. }
  609. #undef DPF_MODNAME
  610. #define DPF_MODNAME "DP8A_SetUserData"
  611. STDMETHODIMP DP8A_SetUserData( IDirectPlay8Address *pInterface, const void * const pBuffer, const DWORD dwBufferSize )
  612. {
  613. if( pInterface == NULL ||
  614. !DP8A_VALID( pInterface ) )
  615. {
  616. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  617. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  618. }
  619. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  620. HRESULT hr;
  621. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  622. if( dwBufferSize > 0 &&
  623. (pBuffer == NULL || !DNVALID_READPTR( pBuffer, dwBufferSize ) ) )
  624. {
  625. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pBuffer" );
  626. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  627. }
  628. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  629. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pBuffer = 0x%p dwBufferSize = %u", pBuffer, dwBufferSize );
  630. hr = pdp8Address->SetUserData( pBuffer, dwBufferSize );
  631. DP8A_RETURN( hr );
  632. }
  633. #undef DPF_MODNAME
  634. #define DPF_MODNAME "DP8A_GetNumComponents"
  635. STDMETHODIMP DP8A_GetNumComponents( IDirectPlay8Address *pInterface, PDWORD pdwNumComponents )
  636. {
  637. if( pInterface == NULL ||
  638. !DP8A_VALID( pInterface ) )
  639. {
  640. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  641. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  642. }
  643. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  644. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  645. if( pdwNumComponents == NULL ||
  646. !DNVALID_WRITEPTR( pdwNumComponents, sizeof(DWORD) ) )
  647. {
  648. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid ptr for num of components" );
  649. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  650. }
  651. *pdwNumComponents = pdp8Address->GetNumComponents();
  652. DP8A_RETURN( DPN_OK );
  653. }
  654. #undef DPF_MODNAME
  655. #define DPF_MODNAME "DP8A_GetComponentByNameW"
  656. STDMETHODIMP DP8A_GetComponentByNameW( IDirectPlay8Address *pInterface, const WCHAR * const pwszTag, void * pComponentBuffer, PDWORD pdwComponentSize, PDWORD pdwDataType )
  657. {
  658. if( pInterface == NULL ||
  659. !DP8A_VALID( pInterface ) )
  660. {
  661. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  662. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  663. }
  664. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  665. HRESULT hr;
  666. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  667. if( pwszTag == NULL )
  668. {
  669. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer to tag. A name must be specified" );
  670. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  671. }
  672. if( pdwComponentSize == NULL ||
  673. !DNVALID_WRITEPTR( pdwComponentSize, sizeof(DWORD)) )
  674. {
  675. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid Pointer to data size" );
  676. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  677. }
  678. if( pdwDataType == NULL ||
  679. !DNVALID_READPTR( pdwDataType, sizeof(DWORD)) )
  680. {
  681. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer to data type" );
  682. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  683. }
  684. if( *pdwComponentSize > 0 &&
  685. (pComponentBuffer == NULL || !DNVALID_WRITEPTR( pComponentBuffer, *pdwComponentSize ) ) )
  686. {
  687. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer to component data" );
  688. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  689. }
  690. if( !DNVALID_STRING_W( pwszTag ) )
  691. {
  692. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid string specified for tag" );
  693. DP8A_RETURN( DPNERR_INVALIDSTRING );
  694. }
  695. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  696. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pwszTag = 0x%p pComponentBuffer = 0x%p, pdwComponentSize = 0x%p, pdwDataType = 0x%p",
  697. (pwszTag==NULL) ? NULL : pwszTag, pComponentBuffer, pdwComponentSize, pdwDataType );
  698. hr = pdp8Address->GetElement( pwszTag, pComponentBuffer, pdwComponentSize, pdwDataType );
  699. DP8A_RETURN( hr );
  700. }
  701. #undef DPF_MODNAME
  702. #define DPF_MODNAME "DP8A_GetComponentByIndexW"
  703. STDMETHODIMP DP8A_GetComponentByIndexW( IDirectPlay8Address *pInterface,
  704. const DWORD dwComponentID, WCHAR * pwszTag, PDWORD pdwNameLen,
  705. void * pComponentBuffer, PDWORD pdwComponentSize, PDWORD pdwDataType )
  706. {
  707. if( pInterface == NULL ||
  708. !DP8A_VALID( pInterface ) )
  709. {
  710. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  711. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  712. }
  713. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  714. HRESULT hr;
  715. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  716. if( pdwNameLen == NULL || !DNVALID_WRITEPTR( pdwNameLen, sizeof(DWORD) ) )
  717. {
  718. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pdwNameLen" );
  719. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  720. }
  721. if( *pdwNameLen != 0 &&
  722. (pwszTag == NULL || !DNVALID_WRITEPTR( pwszTag, *pdwNameLen*sizeof(WCHAR) ) ) )
  723. {
  724. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pwszTag" );
  725. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  726. }
  727. if( pdwComponentSize == NULL || !DNVALID_WRITEPTR( pdwComponentSize, sizeof(DWORD) ) )
  728. {
  729. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pdwComponentSize" );
  730. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  731. }
  732. if( *pdwComponentSize != 0 &&
  733. (pComponentBuffer == NULL || !DNVALID_WRITEPTR( pComponentBuffer, *pdwComponentSize ) ) )
  734. {
  735. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pwszTag" );
  736. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  737. }
  738. if( pdwDataType == NULL || !DNVALID_WRITEPTR( pdwDataType, sizeof(DWORD) ) )
  739. {
  740. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for pdwDataType" );
  741. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  742. }
  743. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  744. DPFX(DPFPREP, DP8A_PARAMLEVEL, "dwComponentID = %u pwszTag = 0x%p pdwNameLen = 0x%p (%u) pComponentBuffer = 0x%p, pdwComponentSize = 0x%p (%u), pdwDataType = 0x%p",
  745. dwComponentID, pwszTag, pdwNameLen, *pdwNameLen, pComponentBuffer, pdwComponentSize, *pdwComponentSize, pdwDataType );
  746. hr = pdp8Address->GetElement( dwComponentID, pwszTag, pdwNameLen, pComponentBuffer, pdwComponentSize, pdwDataType );
  747. DP8A_RETURN( hr );
  748. }
  749. #undef DPF_MODNAME
  750. #define DPF_MODNAME "DP8A_AddComponentW"
  751. STDMETHODIMP DP8A_AddComponentW( IDirectPlay8Address *pInterface, const WCHAR * const pwszTag, const void * const pComponentData, const DWORD dwComponentSize, const DWORD dwDataType )
  752. {
  753. if( pInterface == NULL ||
  754. !DP8A_VALID( pInterface ) )
  755. {
  756. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  757. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  758. }
  759. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  760. HRESULT hr;
  761. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  762. if( pwszTag == NULL )
  763. {
  764. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer for tag string" );
  765. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  766. }
  767. if( pComponentData == NULL ||
  768. !DNVALID_READPTR( pComponentData, dwComponentSize ) )
  769. {
  770. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid pointer specified for component" );
  771. DP8A_RETURN( DPNERR_INVALIDPOINTER );
  772. }
  773. if( !DNVALID_STRING_W( pwszTag ) )
  774. {
  775. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid string specified for tag" );
  776. DP8A_RETURN( DPNERR_INVALIDSTRING );
  777. }
  778. if( dwDataType != DPNA_DATATYPE_STRING &&
  779. dwDataType != DPNA_DATATYPE_DWORD &&
  780. dwDataType != DPNA_DATATYPE_GUID &&
  781. dwDataType != DPNA_DATATYPE_BINARY &&
  782. dwDataType != DPNA_DATATYPE_STRING_ANSI )
  783. {
  784. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid datatype specified" );
  785. DP8A_RETURN( DPNERR_INVALIDPARAM );
  786. }
  787. if( dwDataType == DPNA_DATATYPE_STRING )
  788. {
  789. if( !DNVALID_STRING_W( (const WCHAR * const) pComponentData ) )
  790. {
  791. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid string component specified" );
  792. DP8A_RETURN( DPNERR_INVALIDSTRING );
  793. }
  794. if( ((wcslen( (const WCHAR * const) pComponentData)+1)*sizeof(WCHAR)) != dwComponentSize )
  795. {
  796. DPFX(DPFPREP, DP8A_ERRORLEVEL, "String size and component size don't match" );
  797. DP8A_RETURN( DPNERR_INVALIDPARAM );
  798. }
  799. }
  800. else if( dwDataType == DPNA_DATATYPE_STRING_ANSI )
  801. {
  802. if( !DNVALID_STRING_A( (const CHAR * const) pComponentData ) )
  803. {
  804. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid string component specified" );
  805. DP8A_RETURN( DPNERR_INVALIDSTRING );
  806. }
  807. if( ((strlen( (const CHAR * const) pComponentData)+1)*sizeof(char)) != dwComponentSize )
  808. {
  809. DPFX(DPFPREP, DP8A_ERRORLEVEL, "String size and component size don't match" );
  810. DP8A_RETURN( DPNERR_INVALIDPARAM );
  811. }
  812. }
  813. else if( dwDataType == DPNA_DATATYPE_DWORD )
  814. {
  815. if( dwComponentSize != sizeof( DWORD ) )
  816. {
  817. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid size for DWORD component" );
  818. DP8A_RETURN( DPNERR_INVALIDPARAM );
  819. }
  820. }
  821. else if( dwDataType == DPNA_DATATYPE_GUID )
  822. {
  823. if( dwComponentSize != sizeof( GUID ) )
  824. {
  825. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid size for GUID component" );
  826. DP8A_RETURN( DPNERR_INVALIDPARAM );
  827. }
  828. }
  829. // 7/28/2000(a-JiTay): IA64: Use %p format specifier for 32/64-bit pointers, addresses, and handles.
  830. DPFX(DPFPREP, DP8A_PARAMLEVEL, "pwszTag = 0x%p pComponentData = 0x%p dwComponentSize = %d dwDataType = %d",
  831. pwszTag, pComponentData, dwComponentSize, dwDataType );
  832. hr = pdp8Address->SetElement( pwszTag, pComponentData, dwComponentSize, dwDataType );
  833. DP8A_RETURN( hr );
  834. }
  835. #undef DPF_MODNAME
  836. #define DPF_MODNAME "DP8A_Clear"
  837. STDMETHODIMP DP8A_Clear( IDirectPlay8Address *pInterface )
  838. {
  839. if( pInterface == NULL ||
  840. !DP8A_VALID( pInterface ) )
  841. {
  842. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Invalid object" );
  843. DP8A_RETURN( DPNERR_INVALIDOBJECT );
  844. }
  845. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( pInterface );
  846. HRESULT hr;
  847. DPFX(DPFPREP, DP8A_ENTERLEVEL, "Enter" );
  848. hr = pdp8Address->Clear( );
  849. DP8A_RETURN( hr );
  850. }
  851. BOOL IsValidDP8AObject( LPVOID lpvObject )
  852. {
  853. INTERFACE_LIST *pIntList = (INTERFACE_LIST *) lpvObject;
  854. if( !DNVALID_READPTR( lpvObject, sizeof( INTERFACE_LIST ) ) )
  855. {
  856. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid object pointer" );
  857. return FALSE;
  858. }
  859. if( pIntList->lpVtbl != &DP8A_BaseVtbl &&
  860. pIntList->lpVtbl != &DP8A_IPVtbl &&
  861. pIntList->lpVtbl != &DP8A_InternalVtbl &&
  862. pIntList->lpVtbl != &DP8A_UnknownVtbl )
  863. {
  864. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid object" );
  865. return FALSE;
  866. }
  867. if( pIntList->iid != IID_IDirectPlay8Address &&
  868. pIntList->iid != IID_IDirectPlay8AddressIP &&
  869. pIntList->iid != IID_IDirectPlay8AddressInternal &&
  870. pIntList->iid != IID_IUnknown )
  871. {
  872. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Unknown object" );
  873. return FALSE;
  874. }
  875. if( pIntList->lpObject == NULL ||
  876. !DNVALID_READPTR( pIntList->lpObject, sizeof( OBJECT_DATA ) ) )
  877. {
  878. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid object" );
  879. return FALSE;
  880. }
  881. DP8ADDRESSOBJECT *pdp8Address = (PDP8ADDRESSOBJECT) GET_OBJECT_FROM_INTERFACE( lpvObject );
  882. if( pdp8Address == NULL ||
  883. !DNVALID_READPTR( pdp8Address, sizeof( DP8ADDRESSOBJECT ) ) )
  884. {
  885. DPFX(DPFPREP, DP8A_ERRORLEVEL, "Invalid object" );
  886. return FALSE;
  887. }
  888. return TRUE;
  889. }