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.

306 lines
7.4 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: AppDesc.h
  6. * Content: Application Description Object Header File
  7. *@@BEGIN_MSINTERNAL
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 09/02/00 mjn Created
  12. * 09/05/00 mjn Added GetDPNIDMask()
  13. * 01/25/01 mjn Fixed 64-bit alignment problem when unpacking AppDesc
  14. * 07/22/01 mjn Added DPNBUILD_NOHOSTMIGRATE compile flag
  15. *@@END_MSINTERNAL
  16. *
  17. ***************************************************************************/
  18. #ifndef __APPDESC_H__
  19. #define __APPDESC_H__
  20. #undef DPF_SUBCOMP
  21. #define DPF_SUBCOMP DN_SUBCOMP_CORE
  22. //**********************************************************************
  23. // Constant definitions
  24. //**********************************************************************
  25. #define DN_APPDESCINFO_FLAG_SESSIONNAME 0x0001
  26. #define DN_APPDESCINFO_FLAG_PASSWORD 0x0002
  27. #define DN_APPDESCINFO_FLAG_RESERVEDDATA 0x0004
  28. #define DN_APPDESCINFO_FLAG_APPRESERVEDDATA 0x0008
  29. #define DN_APPDESCINFO_FLAG_CURRENTPLAYERS 0x0010
  30. #define DN_APPDESCINFO_FLAG_GUIDS 0x0020 // Only used in Update()
  31. //**********************************************************************
  32. // Macro definitions
  33. //**********************************************************************
  34. //**********************************************************************
  35. // Structure definitions
  36. //**********************************************************************
  37. class CPackedBuffer;
  38. typedef struct DPN_APPLICATION_DESC_INFO DPN_APPLICATION_DESC_INFO;
  39. typedef struct _DIRECTNETOBJECT DIRECTNETOBJECT;
  40. //**********************************************************************
  41. // Variable definitions
  42. //**********************************************************************
  43. //**********************************************************************
  44. // Function prototypes
  45. //**********************************************************************
  46. HRESULT DNProcessUpdateAppDesc(DIRECTNETOBJECT *const pdnObject,
  47. DPN_APPLICATION_DESC_INFO *const pv);
  48. //**********************************************************************
  49. // Class prototypes
  50. //**********************************************************************
  51. // class for Application Description
  52. class CApplicationDesc
  53. {
  54. public:
  55. HRESULT CApplicationDesc::Initialize( void );
  56. void CApplicationDesc::Deinitialize( void );
  57. void Lock( void )
  58. {
  59. DNEnterCriticalSection( &m_cs );
  60. };
  61. void Unlock( void )
  62. {
  63. DNLeaveCriticalSection( &m_cs );
  64. };
  65. HRESULT CApplicationDesc::Pack(CPackedBuffer *const pPackedBuffer,
  66. const DWORD dwFlags);
  67. HRESULT CApplicationDesc::PackInfo(CPackedBuffer *const pPackedBuffer,
  68. const DWORD dwFlags);
  69. HRESULT CApplicationDesc::UnpackInfo(UNALIGNED DPN_APPLICATION_DESC_INFO *const pdnAppDescInfo,
  70. void *const pBufferStart,
  71. const DWORD dwFlags);
  72. HRESULT CApplicationDesc::Update(const DPN_APPLICATION_DESC *const pdnAppDesc,
  73. const DWORD dwFlags);
  74. HRESULT CApplicationDesc::CreateNewInstanceGuid( void );
  75. HRESULT CApplicationDesc::IncPlayerCount(const BOOL fCheckLimit);
  76. void CApplicationDesc::DecPlayerCount( void );
  77. #ifndef DPNBUILD_SINGLEPROCESS
  78. HRESULT CApplicationDesc::RegisterWithDPNSVR( IDirectPlay8Address *const pListenAddr );
  79. HRESULT CApplicationDesc::UnregisterWithDPNSVR( void );
  80. #endif // ! DPNBUILD_SINGLEPROCESS
  81. DWORD GetMaxPlayers( void ) const
  82. {
  83. return( m_dwMaxPlayers );
  84. };
  85. DWORD GetCurrentPlayers( void ) const
  86. {
  87. return( m_dwCurrentPlayers );
  88. };
  89. const WCHAR *GetPassword( void ) const
  90. {
  91. return( m_pwszPassword );
  92. };
  93. const GUID *GetInstanceGuid( void ) const
  94. {
  95. return( &m_guidInstance );
  96. };
  97. const GUID *GetApplicationGuid( void ) const
  98. {
  99. return( &m_guidApplication );
  100. };
  101. PVOID GetReservedData( void ) const
  102. {
  103. return( m_pvReservedData);
  104. };
  105. DWORD GetReservedDataSize( void ) const
  106. {
  107. return( m_dwReservedDataSize);
  108. };
  109. BOOL IsClientServer( void ) const
  110. {
  111. if (m_dwFlags & DPNSESSION_CLIENT_SERVER)
  112. {
  113. return( TRUE );
  114. }
  115. return( FALSE );
  116. };
  117. #ifndef DPNBUILD_NOHOSTMIGRATE
  118. BOOL AllowHostMigrate( void ) const
  119. {
  120. if (m_dwFlags & DPNSESSION_MIGRATE_HOST)
  121. {
  122. return( TRUE );
  123. }
  124. return( FALSE );
  125. };
  126. #endif // DPNBUILD_NOHOSTMIGRATE
  127. BOOL UseDPNSVR( void ) const
  128. {
  129. if (m_dwFlags & DPNSESSION_NODPNSVR)
  130. {
  131. return( FALSE );
  132. }
  133. return( TRUE );
  134. };
  135. BOOL RequirePassword( void ) const
  136. {
  137. if (m_dwFlags & DPNSESSION_REQUIREPASSWORD)
  138. {
  139. return( TRUE );
  140. }
  141. return( FALSE );
  142. };
  143. BOOL DisallowEnums( void ) const
  144. {
  145. #ifdef DIRECTPLAYDIRECTX9
  146. if (m_dwFlags & DPNSESSION_NOENUMS)
  147. {
  148. return( TRUE );
  149. }
  150. #endif // DIRECTPLAYDIRECTX9
  151. return( FALSE );
  152. };
  153. //return TRUE if session is fast signed
  154. BOOL IsFastSigned() const
  155. { return (m_dwFlags & DPNSESSION_FAST_SIGNED); };
  156. //return TRUE if session is fully signed
  157. BOOL IsFullSigned() const
  158. { return (m_dwFlags & DPNSESSION_FULL_SIGNED); };
  159. //return TRUE is session is signed in any way (either fast or full)
  160. BOOL IsSigned() const
  161. { return (m_dwFlags & (DPNSESSION_FAST_SIGNED | DPNSESSION_FULL_SIGNED)); };
  162. #undef DPF_MODNAME
  163. #define DPF_MODNAME "CApplicationDesc::IsEqualInstanceGuid"
  164. BOOL IsEqualInstanceGuid( const GUID *const pguidInstance ) const
  165. {
  166. DNASSERT( pguidInstance != NULL );
  167. if (!memcmp(&m_guidInstance,(UNALIGNED GUID*)pguidInstance,sizeof(GUID)))
  168. {
  169. return( TRUE );
  170. }
  171. return( FALSE );
  172. };
  173. #undef DPF_MODNAME
  174. #define DPF_MODNAME "CApplicationDesc::IsEqualApplicationGuid"
  175. BOOL IsEqualApplicationGuid( const GUID *const pguidApplication ) const
  176. {
  177. DNASSERT( pguidApplication != NULL );
  178. if (!memcmp(&m_guidApplication,(UNALIGNED GUID*)pguidApplication,sizeof(GUID)))
  179. {
  180. return( TRUE );
  181. }
  182. return( FALSE );
  183. };
  184. #undef DPF_MODNAME
  185. #define DPF_MODNAME "CApplicationDesc::IsEqualPassword"
  186. BOOL IsEqualPassword( UNALIGNED const WCHAR *const pwszPassword ) const
  187. {
  188. UNALIGNED const WCHAR *p;
  189. WCHAR *q;
  190. if ((pwszPassword == NULL) && (m_pwszPassword == NULL))
  191. {
  192. return(TRUE);
  193. }
  194. if ((pwszPassword == NULL) || (m_pwszPassword == NULL))
  195. {
  196. return(FALSE);
  197. }
  198. DNASSERT( pwszPassword != NULL );
  199. DNASSERT( m_pwszPassword != NULL);
  200. p = pwszPassword;
  201. q = m_pwszPassword;
  202. while (*p != L'\0' && *q != L'\0')
  203. {
  204. if (*p != *q)
  205. {
  206. return(FALSE);
  207. }
  208. p++;
  209. q++;
  210. }
  211. if (*p != *q)
  212. {
  213. return(FALSE);
  214. }
  215. return(TRUE);
  216. };
  217. DPNID GetDPNIDMask( void )
  218. {
  219. DPNID *pdpnid;
  220. pdpnid = reinterpret_cast<DPNID*>(&m_guidInstance);
  221. return( *pdpnid );
  222. };
  223. private:
  224. BYTE m_Sig[4];
  225. DWORD m_dwFlags;
  226. DWORD m_dwMaxPlayers;
  227. DWORD m_dwCurrentPlayers;
  228. WCHAR *m_pwszSessionName;
  229. DWORD m_dwSessionNameSize; // in bytes
  230. WCHAR *m_pwszPassword;
  231. DWORD m_dwPasswordSize; // in bytes
  232. void *m_pvReservedData;
  233. DWORD m_dwReservedDataSize;
  234. void *m_pvApplicationReservedData;
  235. DWORD m_dwApplicationReservedDataSize;
  236. GUID m_guidInstance;
  237. GUID m_guidApplication;
  238. #ifndef DPNBUILD_ONLYONETHREAD
  239. DNCRITICAL_SECTION m_cs;
  240. #endif // !DPNBUILD_ONLYONETHREAD
  241. };
  242. #undef DPF_MODNAME
  243. #endif // __APPDESC_H__