Leaked source code of windows server 2003
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.

219 lines
7.4 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2000-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: addcore.h
  6. * Content: DIRECTPLAY8ADDRESS CORE HEADER FILE
  7. *@@BEGIN_MSINTERNAL
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 02/04/2000 rmt Created
  12. * 02/17/2000 rmt Added new defines for
  13. * 02/17/2000 rmt Parameter validation work
  14. * 02/21/2000 rmt Updated to make core Unicode and remove ANSI calls
  15. * 07/09/2000 rmt Added signature bytes to start of address objects
  16. * 07/13/2000 rmt Bug #39274 - INT 3 during voice run
  17. * 07/21/2000 rmt Bug #39940 - Addressing library doesn't properly parse stopbits in URLs
  18. * 7/31/2000 RichGr IA64: FPM_Release() overwrites first 8 bytes of chunk of memory on IA64.
  19. * Rearrange positions of members of affected structs so that's OK.
  20. *@@END_MSINTERNAL
  21. *
  22. ***************************************************************************/
  23. #ifndef __ADDCORE_H
  24. #define __ADDCORE_H
  25. class CStringCache;
  26. // Length of a single byte of userdata
  27. #define DNURL_LENGTH_USERDATA_BYTE 1
  28. // Header length (14 chars + null terminator)
  29. #define DNURL_LENGTH_HEADER 15
  30. // Includes escaped brackets
  31. #define DNURL_LENGTH_GUID 42
  32. // Just the number, in decimal
  33. #define DNURL_LENGTH_DWORD 10
  34. // The length of the seperator for user data
  35. #define DNURL_LENGTH_USERDATA_SEPERATOR 1
  36. // The right length for one byte of escaped data
  37. #define DNURL_LENGTH_BINARY_BYTE 3
  38. #ifdef DPNBUILD_ONLYONESP
  39. // DPNA_KEY_PROVIDER DPNA_SEPARATOR_KEYVALUE CLSID_DP8SP_TCPIP encoded
  40. #define DPNA_BUILTINPROVIDER DPNA_KEY_PROVIDER L"=%7BEBFE7BA0-628D-11D2-AE0F-006097B01411%7D"
  41. // Characters in the above string, not including NULL terminator
  42. #define DNURL_LENGTH_BUILTINPROVIDER (8 + 1 + DNURL_LENGTH_GUID)
  43. #endif // DPNBUILD_ONLYONESP
  44. #define DP8A_ENTERLEVEL 2
  45. #define DP8A_INFOLEVEL 7
  46. #define DP8A_ERRORLEVEL 0
  47. #define DP8A_WARNINGLEVEL 1
  48. #define DP8A_PARAMLEVEL 3
  49. extern const WCHAR *g_szBaseStrings[];
  50. extern const DWORD g_dwBaseRequiredTypes[];
  51. extern const DWORD c_dwNumBaseStrings;
  52. #ifndef DPNBUILD_NOPARAMVAL
  53. #ifdef DBG
  54. extern BOOL IsValidDP8AObject( LPVOID lpvObject );
  55. #define DP8A_VALID(a) IsValidDP8AObject( a )
  56. #else // !DBG
  57. #define DP8A_VALID(a) TRUE
  58. #endif // !DBG
  59. #endif // !DPNBUILD_NOPARAMVAL
  60. #define DP8A_RETURN( x ) DPFX(DPFPREP, DP8A_ENTERLEVEL, "Function returning hr=0x%x", x ); \
  61. return x;
  62. extern CFixedPool fpmAddressObjects;
  63. extern CFixedPool fpmAddressElements;
  64. extern CStringCache *g_pcstrKeyCache;
  65. #ifndef DPNBUILD_PREALLOCATEDMEMORYMODEL
  66. #define DP8ADDRESS_ELEMENT_HEAP 0x00000001
  67. #endif // ! DPNBUILD_PREALLOCATEDMEMORYMODEL
  68. #define DPASIGNATURE_ELEMENT 'LEAD'
  69. #define DPASIGNATURE_ELEMENT_FREE 'LEA_'
  70. #define DPASIGNATURE_ADDRESS 'BOAD'
  71. #define DPASIGNATURE_ADDRESS_FREE 'BOA_'
  72. // DP8ADDRESSELEMENT
  73. //
  74. // This structure contains all the information about a single element of the
  75. // address. These address elements are allocated from a central, fixed
  76. //
  77. // 7/31/2000(RichGr) - IA64: FPM_Release() overwrites first 8 bytes. Rearrange position of dwSignature so that's OK.
  78. #define MAX_EMBEDDED_STRING_LENGTH 64 // in wide characters (i.e. 128 bytes)
  79. typedef struct _DP8ADDRESSELEMENT
  80. {
  81. DWORD dwTagSize; // Size of the tag
  82. DWORD dwType; // Element type DNADDRESS8_DATATYPE_XXXXXX
  83. DWORD dwDataSize; // Size of the data
  84. DWORD dwStringSize;
  85. DWORD dwSignature; // Element debug signature
  86. WCHAR *pszTag; // Tag for the element.
  87. DWORD dwFlags; // Flags DNADDRESSELEMENT_XXXX
  88. union
  89. {
  90. GUID guidData;
  91. DWORD dwData;
  92. WCHAR szData[MAX_EMBEDDED_STRING_LENGTH];
  93. #ifndef DPNBUILD_PREALLOCATEDMEMORYMODEL
  94. PVOID pvData;
  95. #endif // ! DPNBUILD_PREALLOCATEDMEMORYMODEL
  96. } uData; // Union
  97. CBilink blAddressElements; // Bilink of address elements
  98. } DP8ADDRESSELEMENT, *PDP8ADDRESSELEMENT;
  99. // DP8ADDRESSELEMENT
  100. //
  101. // Data structure representing the address itself
  102. class DP8ADDRESSOBJECT
  103. {
  104. public:
  105. #ifdef DPNBUILD_LIBINTERFACE
  106. //
  107. // For lib interface builds, the interface Vtbl and refcount are embedded
  108. // in the object itself.
  109. //
  110. LPVOID lpVtbl; // must be first entry in structure
  111. LONG lRefCount;
  112. #endif // DPNBUILD_LIBINTERFACE
  113. HRESULT Cleanup();
  114. HRESULT Clear();
  115. HRESULT Copy( DP8ADDRESSOBJECT * const pAddressSource );
  116. HRESULT Init();
  117. HRESULT SetElement( const WCHAR * const pszTag, const void * const pvData, const DWORD dwDataSize, const DWORD dwDataType );
  118. HRESULT GetElement( DWORD dwIndex, WCHAR * pszTag, PDWORD pdwTagSize, void * pvDataBuffer, PDWORD pdwDataSize, PDWORD pdwDataType );
  119. HRESULT GetElement( const WCHAR * const pszTag, void * pvDataBuffer, PDWORD pdwDataSize, PDWORD pdwDataType );
  120. #ifndef DPNBUILD_ONLYONESP
  121. HRESULT GetSP( GUID * pGuid );
  122. HRESULT SetSP( const GUID* const pGuid );
  123. #endif // ! DPNBUILD_ONLYONESP
  124. #ifndef DPNBUILD_ONLYONEADAPTER
  125. HRESULT GetDevice( GUID * pGuid );
  126. HRESULT SetDevice( const GUID* const pGuid );
  127. #endif // ! DPNBUILD_ONLYONEADAPTER
  128. HRESULT SetUserData( const void * const pvData, const DWORD dwDataSize );
  129. HRESULT GetUserData( void * pvDataBuffer, PDWORD pdwDataSize );
  130. HRESULT BuildURLA( char * szURL, PDWORD pdwRequiredSize ) ;
  131. HRESULT BuildURLW( WCHAR * szURL, PDWORD pdwRequiredSize ) ;
  132. HRESULT SetURL( WCHAR * szURL );
  133. HRESULT GetElementType( const WCHAR * pszTag, PDWORD pdwType );
  134. HRESULT SetDirectPlay4Address( void * pvDataBuffer, const DWORD dwDataSize );
  135. inline GetNumComponents() const { return m_dwElements; };
  136. inline void ENTERLOCK() { DNEnterCriticalSection( &m_csAddressLock ); };
  137. inline void LEAVELOCK() { DNLeaveCriticalSection( &m_csAddressLock ); };
  138. static void FPM_Element_BlockInit( void *pvItem, PVOID pvContext );
  139. static void FPM_Element_BlockRelease( void *pvItem );
  140. static BOOL FPM_BlockCreate( void *pvItem, PVOID pvContext );
  141. static void FPM_BlockInit( void *pvItem, PVOID pvContext );
  142. static void FPM_BlockRelease( void *pvItem );
  143. static void FPM_BlockDestroy( void *pvItem );
  144. protected:
  145. HRESULT BuildURL_AddElements( WCHAR *szElements );
  146. static HRESULT BuildURL_AddHeader( WCHAR *szWorking );
  147. HRESULT BuildURL_AddUserData( WCHAR *szWorking );
  148. void BuildURL_AddString( WCHAR *szElements, WCHAR *szSource );
  149. HRESULT BuildURL_AddBinaryData( WCHAR *szSource, BYTE *bData, DWORD dwDataLen );
  150. HRESULT InternalGetElement( const WCHAR * const pszTag, PDP8ADDRESSELEMENT *ppaElement );
  151. HRESULT InternalGetElement( const DWORD dwIndex, PDP8ADDRESSELEMENT *ppaElement );
  152. HRESULT CalcComponentStringSize( PDP8ADDRESSELEMENT paddElement, PDWORD pdwSize );
  153. DWORD CalcExpandedStringSize( WCHAR *szString );
  154. DWORD CalcExpandedBinarySize( PBYTE pbData, DWORD dwDataSize );
  155. static BOOL IsEscapeChar( WCHAR ch );
  156. DWORD m_dwSignature;
  157. #ifndef DPNBUILD_ONLYONETHREAD
  158. DNCRITICAL_SECTION m_csAddressLock;
  159. #endif // !DPNBUILD_ONLYONETHREAD
  160. DWORD m_dwStringSize;
  161. DWORD m_dwElements;
  162. #ifndef DPNBUILD_ONLYONESP
  163. PDP8ADDRESSELEMENT m_pSP;
  164. #endif // ! DPNBUILD_ONLYONESP
  165. #ifndef DPNBUILD_ONLYONEADAPTER
  166. PDP8ADDRESSELEMENT m_pAdapter;
  167. #endif // ! DPNBUILD_ONLYONEADAPTER
  168. PVOID m_pvUserData;
  169. DWORD m_dwUserDataSize;
  170. DWORD m_dwUserDataStringSize;
  171. CBilink m_blAddressElements;
  172. };
  173. typedef DP8ADDRESSOBJECT *PDP8ADDRESSOBJECT;
  174. HRESULT DP8A_STRCACHE_Init();
  175. void DP8A_STRCACHE_Free();
  176. #endif // __ADDCORE_H