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.

757 lines
31 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1996-1997 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dplobpr.h
  6. * Content: DirectPlayLobby private header file
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 4/13/96 myronth created it
  11. * 6/24/96 kipo changed guidGame to guidApplication.
  12. * 7/16/96 kipo changed address types to be GUIDs instead of 4CC
  13. * 10/23/96 myronth added client/server methods
  14. * 11/20/96 myronth Added Implemented Logon/LogoffServer
  15. * 12/12/96 myronth Added validation macros for DPSESSIONDESC2 and DPNAME
  16. * 1/2/97 myronth Added wrappers for CreateAddress and EnumAddress
  17. * 2/12/97 myronth Mass DX5 changes
  18. * 2/18/97 myronth Implemented GetObjectCaps
  19. * 2/20/97 myronth Changed buffer R/W to be circular
  20. * 2/26/97 myronth #ifdef'd out DPASYNCDATA stuff (removed dependency)
  21. * 3/12/97 myronth Added LP node stuff, initial async enumsessions
  22. * 3/13/97 myronth Changed reg key, other bug fixes
  23. * 3/17/97 myronth Added ID map table to lobby object
  24. * 3/21/97 myronth Removed unnecessary response function prototypes
  25. * 3/24/97 kipo Added support for IDirectPlayLobby2 interface
  26. * 3/31/97 myronth Removed dead code, Added IDPLobbySP methods
  27. * 4/3/97 myronth Added dplaypr.h dependency, removed dplayi.h dep,
  28. * Removed all duplicated code with dplaypr.h, cleaned
  29. * up a bunch of dead code
  30. * 4/4/97 myronth Changed IDPLobbySP methods' structure names
  31. * 5/8/97 myronth Added packed connection header, subgroup function
  32. * prototypes
  33. * 5/12/97 myronth Added lobby system player
  34. * 5/17/97 myronth SendChatMessage function prototype for IDPLobbySP
  35. * 5/17/97 myronth Added parent ID to CreateAndMapNewGroup
  36. * 5/20/97 myronth Added PRV_DeleteRemotePlayerFromGroup prototype
  37. * 5/22/97 myronth Added DPLP_DestroyGroup prototype
  38. * 6/3/97 myronth Added PRV_DestroySubgroups and PRV_RemoveSubgroups-
  39. * AndPlayersFromGroup function prototypes
  40. * 6/6/97 myronth Added prototypes for PRV_DestroyGroupAndParents and
  41. * PRV_DeleteRemoteGroupFromGroup
  42. * 6/16/97 myronth Added prototype for PRV_SendDeleteShortcutMessage-
  43. * ForExitingGroup
  44. * 7/30/97 myronth Added support for standard lobby messaging
  45. * 8/11/97 myronth Added guidInstance to GameNode struct, added internal
  46. * flad indicating we slammed this guid in a request
  47. * 8/22/97 myronth Added Desciptions & flags to LSPNODE structure
  48. * 9/29/97 myronth Added prototypes for PRV_SendName/DataChangedMessageLocally
  49. * 10/7/97 myronth Added LP version to lobby struct
  50. * 10/23/97 myronth Added lpStopParent group parameter to DeleteGroupAndParents
  51. * and DeleteRemoteGroupFromGroup (#12885)
  52. * 10/29/97 myronth Changed and added internal prototypes for group owners
  53. * 11/5/97 myronth Expose lobby ID's as DPID's in lobby sessions
  54. * 11/13/97 myronth Added stuff for asynchronous Connect (#12541)
  55. * 12/2/97 myronth Added IDPLobby3 interface, Register/UnregisterApp
  56. * 12/4/97 myronth Added ConnectEx
  57. * 1/20/98 myronth Added WaitForConnectionSettings
  58. * 1/25/98 sohailm Added #define for CSTR_EQUAL (we define it if it's not already defined)
  59. * 6/25/98 a-peterz Added DPL_A_ConnectEx
  60. * 10/22/99 aarono added support for application flags
  61. * 02/08/00 aarono added pid to ipc struct to allow monitoring by app.
  62. ***************************************************************************/
  63. #ifndef __DPLOBPR_INCLUDED__
  64. #define __DPLOBPR_INCLUDED__
  65. #include <windows.h>
  66. #include "dpmem.h"
  67. #include "dpf.h"
  68. #include "dplobby.h"
  69. #include "dpneed.h"
  70. #include "dpos.h"
  71. #include "lobbysp.h"
  72. #include "dplaypr.h"
  73. #include "dpmess.h"
  74. //--------------------------------------------------------------------------
  75. //
  76. // Prototypes
  77. //
  78. //--------------------------------------------------------------------------
  79. typedef struct IDirectPlayLobbyVtbl DIRECTPLAYLOBBYCALLBACKS;
  80. typedef DIRECTPLAYLOBBYCALLBACKS * LPDIRECTPLAYLOBBYCALLBACKS;
  81. // Right now the ASCII Vtbl is the same (by definition), but we may need
  82. // to change it in the future, so let's use this structure
  83. typedef struct IDirectPlayLobbyVtbl DIRECTPLAYLOBBYCALLBACKSA;
  84. typedef DIRECTPLAYLOBBYCALLBACKSA * LPDIRECTPLAYLOBBYCALLBACKSA;
  85. typedef struct IDirectPlayLobby2Vtbl DIRECTPLAYLOBBYCALLBACKS2;
  86. typedef DIRECTPLAYLOBBYCALLBACKS2 * LPDIRECTPLAYLOBBYCALLBACKS2;
  87. // Right now the ASCII Vtbl is the same (by definition), but we may need
  88. // to change it in the future, so let's use this structure
  89. typedef struct IDirectPlayLobby2Vtbl DIRECTPLAYLOBBYCALLBACKS2A;
  90. typedef DIRECTPLAYLOBBYCALLBACKS2A * LPDIRECTPLAYLOBBYCALLBACKS2A;
  91. typedef struct IDirectPlayLobby3Vtbl DIRECTPLAYLOBBYCALLBACKS3;
  92. typedef DIRECTPLAYLOBBYCALLBACKS3 * LPDIRECTPLAYLOBBYCALLBACKS3;
  93. // Right now the ASCII Vtbl is the same (by definition), but we may need
  94. // to change it in the future, so let's use this structure
  95. typedef struct IDirectPlayLobby3Vtbl DIRECTPLAYLOBBYCALLBACKS3A;
  96. typedef DIRECTPLAYLOBBYCALLBACKS3A * LPDIRECTPLAYLOBBYCALLBACKS3A;
  97. typedef struct IDPLobbySPVtbl DIRECTPLAYLOBBYSPCALLBACKS;
  98. typedef DIRECTPLAYLOBBYSPCALLBACKS * LPDIRECTPLAYLOBBYSPCALLBACKS;
  99. //--------------------------------------------------------------------------
  100. //
  101. // DPLobby SP Node stuff
  102. //
  103. //--------------------------------------------------------------------------
  104. // DirectPlay Service Provider for DPLobby
  105. // {4AF206E0-9712-11cf-A021-00AA006157AC}
  106. DEFINE_GUID(GUID_DirectPlaySP, 0x4af206e0, 0x9712, 0x11cf, 0xa0, 0x21, 0x0, 0xaa, 0x0, 0x61, 0x57, 0xac);
  107. // This is where the service provider info read from
  108. // the registry is kept
  109. typedef struct LSPNODE
  110. {
  111. LPWSTR lpwszName;
  112. LPWSTR lpwszPath;
  113. GUID guid;
  114. DWORD dwReserved1;
  115. DWORD dwReserved2;
  116. DWORD dwNodeFlags;
  117. LPSTR lpszDescA;
  118. LPWSTR lpwszDesc;
  119. struct LSPNODE * lpNext;
  120. } LSPNODE, * LPLSPNODE;
  121. #define LSPNODE_DESCRIPTION (0x00000001)
  122. #define LSPNODE_PRIVATE (0x00000002)
  123. //--------------------------------------------------------------------------
  124. //
  125. // DirectPlayLobby Stuff
  126. //
  127. //--------------------------------------------------------------------------
  128. // Forward declarations for pointers to these two structs
  129. typedef struct DPLOBBYI_INTERFACE * LPDPLOBBYI_INTERFACE;
  130. typedef struct DPLOBBYI_DPLOBJECT * LPDPLOBBYI_DPLOBJECT;
  131. // This is a structure represent each interface on our DPLobby object
  132. typedef struct DPLOBBYI_INTERFACE
  133. {
  134. // REVIEW!!!! -- Why isn't this strongly typed????
  135. // LPDIRECTPLAYLOBBYCALLBACKS lpVtbl;
  136. LPVOID lpVtbl;
  137. LPDPLOBBYI_DPLOBJECT lpDPLobby;
  138. LPDPLOBBYI_INTERFACE lpNextInterface; // Next interface on DPLobby object
  139. DWORD dwIntRefCnt; // Ref count for this interface
  140. } DPLOBBYI_INTERFACE;
  141. // This structure represents a message node for messages sent between the
  142. // lobby client & the game using Send/ReceiveLobbyMessage
  143. typedef struct DPLOBBYI_MESSAGE
  144. {
  145. DWORD dwFlags; // Flags pertinent to the data in the message
  146. DWORD dwSize; // Size of the data
  147. LPVOID lpData; // Pointer to the data
  148. struct DPLOBBYI_MESSAGE * lpPrev; // Pointer to the previous message
  149. struct DPLOBBYI_MESSAGE * lpNext; // Pointer to the next message
  150. } DPLOBBYI_MESSAGE, * LPDPLOBBYI_MESSAGE;
  151. // This represents an entry in our ID map table
  152. typedef struct DPLOBBYI_MAPIDNODE
  153. {
  154. DWORD dwLobbyID;
  155. DPID dpid;
  156. } DPLOBBYI_MAPIDNODE, * LPDPLOBBYI_MAPIDNODE;
  157. // This structure represents each game launched by the lobby client
  158. typedef struct DPLOBBYI_GAMENODE
  159. {
  160. DWORD dwSize; // Size of this structure
  161. DWORD dwFlags; // Flags relevant to the GameNode
  162. DWORD dwGameProcessID; // Process ID of Game spun off (in lobbyclient)
  163. HANDLE hGameProcess; // Process Hande for the Game spun off (in lobbyclient)
  164. DWORD dwLobbyClientProcessID; // Process ID of lobby client (in a game)
  165. HANDLE hLobbyClientProcess; // Process Handle for the client (in a game)
  166. GUID guidIPC; // IPC guid for handling ripple launch case
  167. HANDLE hTerminateThread; // Handle to the Terminate monitor thread
  168. HANDLE hKillTermThreadEvent; // Handle of an event used to kill the monitor thread
  169. DPLOBBYI_MESSAGE MessageHead; // Message queue head
  170. DWORD dwMessageCount; // Count of messages in the queue
  171. // Connection settings shared memory buffer related stuff
  172. HANDLE hConnectDataMutex; // Mutex for write access to connect data buffer
  173. HANDLE hConnectDataFile; // File handle for game data buffer
  174. LPVOID lpConnectDataBuffer; // Pointer to game data buffer
  175. // Game settings shared memory buffer related stuff
  176. HANDLE hGameWriteFile; // File handle for game write buffer
  177. LPVOID lpGameWriteBuffer; // Pointer to game write buffer
  178. HANDLE hGameWriteEvent; // Handle to GameWriteEvent
  179. HANDLE hGameWriteMutex; // Handle to GameWrite Mutex
  180. HANDLE hLobbyWriteFile; // File handle for lobby write buffer
  181. LPVOID lpLobbyWriteBuffer; // Pointer to lobby write buffer
  182. HANDLE hLobbyWriteEvent; // Handle to LobbyWrite Event
  183. HANDLE hLobbyWriteMutex; // Handle to LobbyWrite Mutex
  184. HANDLE hReceiveThread; // Handle to the Receive thread
  185. HANDLE hDupReceiveEvent; // Duplicate Handle of Caller's Event
  186. HANDLE hKillReceiveThreadEvent;// Handle of an event used to kill receive thread
  187. LPDPLOBBYI_DPLOBJECT this; // Back pointer to the DPLobby object
  188. struct DPLOBBYI_GAMENODE * lpgnNext;// Pointer to the next GameNode in the list
  189. // Pointer to the dplay object which has a connection to the lobby server
  190. // and the ID of the player that received the start session message
  191. LPDPLAYI_DPLAY lpDPlayObject;
  192. DPID dpidPlayer;
  193. GUID guidInstance; // Instance guid for the game
  194. } DPLOBBYI_GAMENODE, *LPDPLOBBYI_GAMENODE;
  195. // This is used to keep track of Property requests made via SendLobbyMessage
  196. typedef struct DPLOBBYI_REQUESTNODE
  197. {
  198. DWORD dwFlags; // GN_* flags
  199. DWORD dwRequestID; // Internal Request ID
  200. DWORD dwAppRequestID; // Request ID passed in by the app
  201. LPDPLOBBYI_GAMENODE lpgn; // Pointer to a Game Node
  202. struct DPLOBBYI_REQUESTNODE * lpPrev; // Pointer to the previous request node
  203. struct DPLOBBYI_REQUESTNODE * lpNext; // Pointer to the next request node
  204. } DPLOBBYI_REQUESTNODE, * LPDPLOBBYI_REQUESTNODE;
  205. // This is the DirectPlayLobby object
  206. typedef struct DPLOBBYI_DPLOBJECT
  207. {
  208. DWORD dwSize; // Size of this structure
  209. LPDPLOBBYI_INTERFACE lpInterfaces; // List of interface on this object
  210. DWORD dwRefCnt; // Reference Count for the object
  211. DWORD dwFlags; // DPLOBBYPR_xxx
  212. HINSTANCE hInstanceLP; // Lobby Provider DLL's hInstance
  213. LPSP_CALLBACKS pcbSPCallbacks; // SP entry points
  214. LPVOID lpSPData; // SP-specific blob storage
  215. LPDPLOBBYI_GAMENODE lpgnHead; // Head node for all launched games
  216. LPDPLAYI_DPLAY lpDPlayObject; // Back pointer to aggregate DPlay object
  217. LPDPLOBBYI_MAPIDNODE lpMap; // Pointer to the ID map table
  218. DWORD dwTotalMapEntries; // Number of total entries in the map table
  219. DWORD dwMapEntries; // Number of used entries in the map table
  220. DPID dpidSysPlayer; // ID of the lobby's system player
  221. LPDPLOBBYI_REQUESTNODE lprnHead; // Head node for all property requests
  222. DWORD dwCurrentRequest; // ID of the next request
  223. DWORD dwLPVersion; // Version of the lobby provider
  224. LPDIRECTPLAY2 lpDP2; // DPlay2 interface pointer used by async DP_Connect
  225. LPDPLCONNECTION lpConn; // DPLCONNECTION pointer used by async DP_Connect
  226. } DPLOBBYI_DPLOBJECT;
  227. typedef struct DPLOBBYI_BUFFERCONTROL
  228. {
  229. DWORD dwToken; // Set by the lobby client
  230. DWORD dwReadOffset; // Offset of the read cursor (relative to this structure)
  231. DWORD dwWriteOffset; // Offset of the write cursor (relative to this structure)
  232. DWORD dwFlags; // Flags for this buffer
  233. DWORD dwMessages; // Number of messages in the buffer
  234. DWORD dwBufferSize; // Size of the entire buffer
  235. DWORD dwBufferLeft; // Number of free bytes left in the buffer
  236. } DPLOBBYI_BUFFERCONTROL, * LPDPLOBBYI_BUFFERCONTROL;
  237. typedef struct DPLOBBYI_CONNCONTROL
  238. {
  239. DWORD dwToken; // Set by the lobby client
  240. DWORD dwFlags; // Flags for this buffer
  241. DWORD CliProcId; // Lobby client's process Id so we can see if it crashes.
  242. } DPLOBBYI_CONNCONTROL, * LPDPLOBBYI_CONNCONTROL;
  243. typedef struct DPLOBBYI_MESSAGEHEADER
  244. {
  245. DWORD dwSize;
  246. DWORD dwFlags;
  247. } DPLOBBYI_MESSAGEHEADER, * LPDPLOBBYI_MESSAGEHEADER;
  248. typedef struct DPLOBBYI_PACKEDCONNHEADER
  249. {
  250. DWORD dwUnicodeSize;
  251. DWORD dwAnsiSize;
  252. } DPLOBBYI_PACKEDCONNHEADER, * LPDPLOBBYI_PACKEDCONNHEADER;
  253. typedef struct CONNECTINFO
  254. {
  255. GUID guidApplication;
  256. GUID guidIPC;
  257. LPWSTR lpszName;
  258. LPWSTR lpszFile;
  259. LPWSTR lpszPath;
  260. LPWSTR lpszCommandLine;
  261. LPWSTR lpszCurrentDir;
  262. LPWSTR lpszAppLauncherName;
  263. } CONNECTINFO, * LPCONNECTINFO;
  264. // This is used for messaging during the StartGame method
  265. typedef struct DPLOBBYI_STARTGAME
  266. {
  267. DWORD dwFlags;
  268. HRESULT hr;
  269. } DPLOBBYI_STARTGAME, * LPDPLOBBYI_STARTGAME;
  270. //--------------------------------------------------------------------------
  271. //
  272. // Definitions
  273. //
  274. //--------------------------------------------------------------------------
  275. // These two entries are only used by dplos.c. They can be removed if we
  276. // generalize these functions between DPlay & DPLobby
  277. #define DPLAY_MAX_FILENAMELEN 512
  278. #define DPLOBBY_DEFAULT_CHAR "-"
  279. #define DPLOBBYPR_DEFAULTMAPENTRIES 100
  280. #define DPLOBBYPR_SIZE_HANDLEMESSAGE_DX50 20
  281. // Note, the 'L' Macro makes these strings Unicode (the TEXT macro uses L also)
  282. #define SZ_DPLAY_APPS_KEY L"Software\\Microsoft\\DirectPlay\\Applications"
  283. #define SZ_DPLAY_SP_KEY L"Software\\Microsoft\\DirectPlay\\Service Providers"
  284. #define SZ_DPLOBBY_SP_KEY L"Software\\Microsoft\\DirectPlay\\Lobby Providers"
  285. #define SZ_ADDRESS_TYPES L"Address Types"
  286. #define SZ_GUID L"Guid"
  287. #define SZ_PATH L"Path"
  288. #define SZ_DESCRIPTIONA L"DescriptionA"
  289. #define SZ_DESCRIPTIONW L"DescriptionW"
  290. #define SZ_PRIVATE L"Private"
  291. #define SZ_FILE L"File"
  292. #define SZ_LAUNCHER L"Launcher"
  293. #define SZ_MAJORVERSION L"Major Version"
  294. #define SZ_MINORVERSION L"Minor Version"
  295. #define SZ_DWRESERVED1 L"dwReserved1"
  296. #define SZ_DWRESERVED2 L"dwReserved2"
  297. #define SZ_COMMANDLINE L"CommandLine"
  298. #define SZ_CURRENTDIR L"CurrentDirectory"
  299. #define SZ_BACKSLASH L"\\"
  300. #define SZ_SPACE L" "
  301. #define SZ_SP_FOR_DPLAY L"dpldplay.dll"
  302. #define SZ_DP_IPC_GUID L"/dplay_ipc_guid:"
  303. #define SZ_GUID_PROTOTYPE L"{01020304-0506-0708-090A-0B0C0D0E0F10}"
  304. #define SZ_DWFLAGS L"dwFlags"
  305. // The following #defines are all for the shared buffers and control
  306. // elements used by the lobby methods for communication between
  307. // a lobby client and a game
  308. #define MAX_PID_LENGTH (10)
  309. #define MAX_MMFILENAME_LENGTH (_MAX_FNAME + MAX_PID_LENGTH)
  310. #define SZ_FILENAME_BASE L"DPLobby"
  311. #define SZ_CONNECT_DATA_FILE L"ConnectDataSharedMemory"
  312. #define SZ_CONNECT_DATA_MUTEX L"ConnectDataMutex"
  313. #define SZ_GAME_WRITE_FILE L"GameWriteSharedMemory"
  314. #define SZ_GAME_WRITE_EVENT L"GameWriteEvent"
  315. #define SZ_GAME_WRITE_MUTEX L"GameWriteMutex"
  316. #define SZ_LOBBY_WRITE_FILE L"LobbyWriteSharedMemory"
  317. #define SZ_LOBBY_WRITE_EVENT L"LobbyWriteEvent"
  318. #define SZ_LOBBY_WRITE_MUTEX L"LobbyWriteMutex"
  319. #define SZ_NAME_TEMPLATE L"%s-%s-%u"
  320. #define SZ_GUID_NAME_TEMPLATE L"%s-%s-"
  321. #define TYPE_CONNECT_DATA_FILE 1
  322. #define TYPE_CONNECT_DATA_MUTEX 2
  323. #define TYPE_GAME_WRITE_FILE 3
  324. #define TYPE_LOBBY_WRITE_FILE 4
  325. #define TYPE_LOBBY_WRITE_EVENT 5
  326. #define TYPE_GAME_WRITE_EVENT 7
  327. #define TYPE_LOBBY_WRITE_MUTEX 9
  328. #define TYPE_GAME_WRITE_MUTEX 10
  329. // If this flag is set, the Lobby object has been registered with a lobby
  330. // server. Some methods require the client to be registered.
  331. #define DPLOBBYPR_REGISTERED 0x00000010
  332. // If this flag is set, we have allocated an IDPLobbySP interface
  333. #define DPLOBBYPR_SPINTERFACE 0x00000020
  334. // If this flag is set, the app has called Connect with the async flag
  335. #define DPLOBBYPR_ASYNCCONNECT 0x00000040
  336. // Message flags
  337. #define DPLOBBYPR_MESSAGE_SYSTEM 0x00000001
  338. #define DPLOBBYPR_INTERNALMESSAGEFLAGS (0x00000000) // This will change
  339. // HRESULT used by EnumLocalApplication to denote a callback return of
  340. // FALSE (internally, of course)
  341. #define DPLOBBYPR_CALLBACKSTOP (HRESULT) (0xFFFFFFFF)
  342. // Transport Flags
  343. #define DPLOBBYPR_DPLAYSP (0x00000001)
  344. // Default Timeout value (15 seconds)
  345. #define DPLOBBYPR_DEFAULTTIMEOUT (15000)
  346. //
  347. // GameNode Flags
  348. //
  349. // If this flag is set, the calling application is a lobby client and not
  350. // a game. The user shouldn't even set this, but we should be able to
  351. // figure it out from the connection method. Use this flag to distinguish
  352. // when to "Create" the memory-mapped files, or when to "Open" them.
  353. #define GN_LOBBY_CLIENT (0x00000001)
  354. // The memory mapped files are available and ready for use
  355. #define GN_SHARED_MEMORY_AVAILABLE (0x00000002)
  356. // Used to denote when an application's process has gone away.
  357. #define GN_DEAD_GAME_NODE (0x00000004)
  358. // These two flags determine whether the game was lobby client launched or
  359. // self-lobbied. If neither of these are set, the game was lobby client
  360. // launched, and the flag is set on the lobby client side (not on the game side)
  361. #define GN_CLIENT_LAUNCHED (0x00000008)
  362. #define GN_SELF_LOBBIED (0x00000010)
  363. // This flag is used to identify whether the guidInstance for the game
  364. // was exchanged for GUID_NULL in the guidPlayer field of a Get/SetProperty
  365. // lobby system message.
  366. #define GN_SLAMMED_GUID (0x00000020)
  367. // This flag is set when the guidIPC field of the game node has been set
  368. // either because we are a lobby client that ripple launched or it was
  369. // on the application's command line.
  370. #define GN_IPCGUID_SET (0x00000040)
  371. //
  372. // BufferControl Flags
  373. //
  374. // Flags used by the dwFlags member of the BUFFERCONTROL struct
  375. #define BC_LOBBY_ACTIVE (0x00000001)
  376. #define BC_GAME_ACTIVE (0x00000002)
  377. #define BC_WAIT_MODE (0x00000004)
  378. #define BC_PENDING_CONNECT (0x00000008)
  379. #define BC_TOKEN (0xFEEDFACE)
  380. #ifndef CSTR_EQUAL
  381. #define CSTR_EQUAL 2
  382. #endif
  383. //--------------------------------------------------------------------------
  384. //
  385. // Globals
  386. //
  387. //--------------------------------------------------------------------------
  388. // The vtable!
  389. extern DIRECTPLAYLOBBYCALLBACKS dplCallbacks;
  390. extern DIRECTPLAYLOBBYCALLBACKSA dplCallbacksA;
  391. extern DIRECTPLAYLOBBYCALLBACKS2 dplCallbacks2;
  392. extern DIRECTPLAYLOBBYCALLBACKS2A dplCallbacks2A;
  393. extern DIRECTPLAYLOBBYCALLBACKS3 dplCallbacks3;
  394. extern DIRECTPLAYLOBBYCALLBACKS3A dplCallbacks3A;
  395. extern DIRECTPLAYLOBBYSPCALLBACKS dplCallbacksSP;
  396. //--------------------------------------------------------------------------
  397. //
  398. // Macros, etc.
  399. //
  400. //--------------------------------------------------------------------------
  401. // Our own hard-coded break
  402. #define DEBUGBREAK() _asm { int 3 }
  403. #define DPLOBJECT_FROM_INTERFACE(ptr) (((LPDPLOBBYI_INTERFACE)ptr)->lpDPLobby)
  404. #define DPLOBBY_REGISTRY_NAMELEN 512
  405. // Crit section
  406. extern LPCRITICAL_SECTION gpcsDPLCritSection; // defined in dllmain.c
  407. extern LPCRITICAL_SECTION gpcsDPLQueueCritSection; // also in dllmain.c
  408. extern LPCRITICAL_SECTION gpcsDPLGameNodeCritSection; // also in dllmain.c
  409. // Validation macros
  410. #define VALID_DPLOBBY_INTERFACE( ptr ) \
  411. (!IsBadWritePtr(ptr, sizeof(DPLOBBYI_INTERFACE)) && \
  412. ((((LPDPLOBBYI_INTERFACE)ptr)->lpVtbl == &dplCallbacks) || \
  413. (((LPDPLOBBYI_INTERFACE)ptr)->lpVtbl == &dplCallbacksA) || \
  414. (((LPDPLOBBYI_INTERFACE)ptr)->lpVtbl == &dplCallbacks2) || \
  415. (((LPDPLOBBYI_INTERFACE)ptr)->lpVtbl == &dplCallbacks2A) || \
  416. (((LPDPLOBBYI_INTERFACE)ptr)->lpVtbl == &dplCallbacks3) || \
  417. (((LPDPLOBBYI_INTERFACE)ptr)->lpVtbl == &dplCallbacks3A) || \
  418. (((LPDPLOBBYI_INTERFACE)ptr)->lpVtbl == &dplCallbacksSP)))
  419. #define VALID_DPLOBBY_PTR(ptr) \
  420. (!IsBadWritePtr(ptr, sizeof(DPLOBBYI_DPLOBJECT)) && \
  421. (ptr->dwSize == sizeof(DPLOBBYI_DPLOBJECT)))
  422. #define VALID_UUID_PTR(ptr) \
  423. (ptr && !IsBadWritePtr( ptr, sizeof(UUID)))
  424. #define VALID_READ_UUID_PTR(ptr) \
  425. (ptr && !IsBadReadPtr( ptr, sizeof(UUID)))
  426. #define VALID_DPLOBBY_CONNECTION( ptr ) \
  427. (!IsBadWritePtr(ptr, sizeof(DPLCONNECTION)) && \
  428. (ptr->dwSize == sizeof(DPLCONNECTION)))
  429. #define VALID_DPLOBBY_APPLICATIONDESC( ptr ) \
  430. (!IsBadWritePtr(ptr, sizeof(DPAPPLICATIONDESC)) && \
  431. (ptr->dwSize == sizeof(DPAPPLICATIONDESC)))
  432. #define VALID_DPLOBBY_APPLICATIONDESC2( ptr ) \
  433. (!IsBadWritePtr(ptr, sizeof(DPAPPLICATIONDESC2)) && \
  434. (ptr->dwSize == sizeof(DPAPPLICATIONDESC2)))
  435. #define IS_DPLOBBY_APPLICATIONDESC2(ptr) \
  436. (ptr->dwSize == sizeof(DPAPPLICATIONDESC2))
  437. #define VALID_DPLOGONINFO( ptr ) \
  438. (!IsBadWritePtr(ptr, sizeof(DPLOGONINFO)) && \
  439. (ptr->dwSize == sizeof(DPLOGONINFO)))
  440. #define VALID_DPLOBBY_SP_LOADED( ptr ) \
  441. (ptr->pcbSPCallbacks)
  442. #define VALID_SENDLOBBYMESSAGE_FLAGS(dwFlags) \
  443. (!((dwFlags) & \
  444. ~(DPLMSG_STANDARD) \
  445. ) )
  446. #define VALID_WAIT_FLAGS(dwFlags) \
  447. (!((dwFlags) & \
  448. ~(DPLWAIT_CANCEL) \
  449. ) )
  450. #define VALID_REGISTERAPP_FLAGS(dwFlags) \
  451. (!((dwFlags) & \
  452. ~(DPLAPP_NOENUM | \
  453. DPLAPP_AUTOVOICE | \
  454. DPLAPP_SELFVOICE ) \
  455. ) )
  456. #define IS_GAME_DEAD(lpgn) \
  457. (lpgn->dwFlags & GN_DEAD_GAME_NODE)
  458. #define CALLBACK_EXISTS(fn) (((LPSP_CALLBACKS)this->pcbSPCallbacks)->fn)
  459. #define CALL_LP(ptr,fn,pdata) (((LPSP_CALLBACKS)ptr->pcbSPCallbacks)->fn(pdata))
  460. #define DPLAPI WINAPI
  461. //--------------------------------------------------------------------------
  462. //
  463. // Prototypes
  464. //
  465. //--------------------------------------------------------------------------
  466. // convert.c
  467. HRESULT PRV_ConvertDPLCONNECTIONToUnicode(LPDPLCONNECTION, LPDPLCONNECTION *);
  468. // dplunk.c
  469. extern HRESULT DPLAPI DPL_QueryInterface(LPDIRECTPLAYLOBBY,
  470. REFIID riid, LPVOID * ppvObj);
  471. extern ULONG DPLAPI DPL_AddRef(LPDIRECTPLAYLOBBY);
  472. extern ULONG DPLAPI DPL_Release(LPDIRECTPLAYLOBBY);
  473. LPDPLOBBYSP PRV_GetDPLobbySPInterface(LPDPLOBBYI_DPLOBJECT);
  474. HRESULT PRV_GetInterface(LPDPLOBBYI_DPLOBJECT, LPDPLOBBYI_INTERFACE *, LPVOID);
  475. // dplgame.c
  476. extern HRESULT DPLAPI DPL_RunApplication(LPDIRECTPLAYLOBBY, DWORD,
  477. LPDWORD, LPDPLCONNECTION, HANDLE);
  478. BOOL PRV_FindGameInRegistry(LPGUID, LPWSTR, DWORD, HKEY *);
  479. // dplenum.c
  480. extern HRESULT DPLAPI DPL_EnumLocalApplications(LPDIRECTPLAYLOBBY,
  481. LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD);
  482. extern HRESULT DPLAPI DPL_EnumAddressTypes(LPDIRECTPLAYLOBBY,
  483. LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD);
  484. HRESULT PRV_EnumLocalApplications(LPDIRECTPLAYLOBBY,
  485. LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD, BOOL);
  486. // dplobby.c
  487. extern HRESULT DPLAPI DPL_Connect(LPDIRECTPLAYLOBBY, DWORD, LPDIRECTPLAY2 *,
  488. IUnknown FAR *);
  489. extern HRESULT DPLAPI DPL_ConnectEx(LPDIRECTPLAYLOBBY, DWORD, REFIID,
  490. LPVOID *, IUnknown FAR *);
  491. extern HRESULT DPLAPI DPL_CreateAddress(LPDIRECTPLAYLOBBY pISP,
  492. REFGUID lpguidSP, REFGUID lpguidDataType, LPCVOID lpData, DWORD dwDataSize,
  493. LPDPADDRESS lpAddress, LPDWORD lpdwAddressSize);
  494. extern HRESULT DPLAPI DPL_CreateCompoundAddress(LPDIRECTPLAYLOBBY pISP,
  495. LPDPCOMPOUNDADDRESSELEMENT lpAddressElements, DWORD dwAddressElementCount,
  496. LPDPADDRESS lpAddress, LPDWORD lpdwAddressSize);
  497. extern HRESULT DPLAPI DPL_EnumAddress(LPDIRECTPLAYLOBBY pISP,
  498. LPDPENUMADDRESSCALLBACK lpEnumCallback, LPCVOID lpAddress, DWORD dwAddressSize,
  499. LPVOID lpContext);
  500. extern HRESULT DPLAPI DPL_RegisterApplication(LPDIRECTPLAYLOBBY lpDPL,
  501. DWORD dwFlags, LPVOID lpvDesc);
  502. extern HRESULT DPLAPI DPL_UnregisterApplication(LPDIRECTPLAYLOBBY lpDPL,
  503. DWORD dwFlags, REFGUID lpguid);
  504. HRESULT PRV_WriteAppDescInRegistryAnsi(LPDPAPPLICATIONDESC);
  505. HRESULT PRV_WriteAppDescInRegistryUnicode(LPDPAPPLICATIONDESC);
  506. // dplobbya.c (Ansi entry points)
  507. extern HRESULT DPLAPI DPL_A_Connect(LPDIRECTPLAYLOBBY, DWORD,
  508. LPDIRECTPLAY2 *, IUnknown FAR *);
  509. extern HRESULT DPLAPI DPL_A_ConnectEx(LPDIRECTPLAYLOBBY, DWORD, REFIID,
  510. LPVOID *, IUnknown FAR *);
  511. extern HRESULT DPLAPI DPL_A_EnumLocalApplications(LPDIRECTPLAYLOBBY,
  512. LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD);
  513. extern HRESULT DPLAPI DPL_A_GetConnectionSettings(LPDIRECTPLAYLOBBY, DWORD,
  514. LPVOID, LPDWORD);
  515. extern HRESULT DPLAPI DPL_A_RegisterApplication(LPDIRECTPLAYLOBBY,
  516. DWORD, LPVOID);
  517. extern HRESULT DPLAPI DPL_A_RunApplication(LPDIRECTPLAYLOBBY, DWORD, LPDWORD,
  518. LPDPLCONNECTION, HANDLE);
  519. extern HRESULT DPLAPI DPL_A_SetConnectionSettings(LPDIRECTPLAYLOBBY,
  520. DWORD, DWORD, LPDPLCONNECTION);
  521. // dplpack.c
  522. void PRV_GetDPLCONNECTIONPackageSize(LPDPLCONNECTION, LPDWORD, LPDWORD);
  523. HRESULT PRV_PackageDPLCONNECTION(LPDPLCONNECTION, LPVOID, BOOL);
  524. HRESULT PRV_UnpackageDPLCONNECTIONAnsi(LPVOID, LPVOID);
  525. HRESULT PRV_UnpackageDPLCONNECTIONUnicode(LPVOID, LPVOID);
  526. HRESULT PRV_ValidateDPLCONNECTION(LPDPLCONNECTION, BOOL);
  527. HRESULT PRV_ValidateDPAPPLICATIONDESC(LPDPAPPLICATIONDESC, BOOL);
  528. HRESULT PRV_ConvertDPAPPLICATIONDESCToAnsi(LPDPAPPLICATIONDESC,
  529. LPDPAPPLICATIONDESC *);
  530. HRESULT PRV_ConvertDPAPPLICATIONDESCToUnicode(LPDPAPPLICATIONDESC,
  531. LPDPAPPLICATIONDESC *);
  532. void PRV_FreeLocalDPAPPLICATIONDESC(LPDPAPPLICATIONDESC);
  533. // dplshare.c
  534. extern HRESULT DPLAPI DPL_GetConnectionSettings(LPDIRECTPLAYLOBBY, DWORD,
  535. LPVOID, LPDWORD);
  536. extern HRESULT DPLAPI DPL_ReceiveLobbyMessage(LPDIRECTPLAYLOBBY, DWORD,
  537. DWORD, LPDWORD, LPVOID, LPDWORD);
  538. extern HRESULT DPLAPI DPL_SendLobbyMessage(LPDIRECTPLAYLOBBY, DWORD,
  539. DWORD, LPVOID, DWORD);
  540. extern HRESULT DPLAPI DPL_SetConnectionSettings(LPDIRECTPLAYLOBBY, DWORD,
  541. DWORD, LPDPLCONNECTION);
  542. extern HRESULT DPLAPI DPL_SetLobbyMessageEvent(LPDIRECTPLAYLOBBY, DWORD,
  543. DWORD, HANDLE);
  544. extern HRESULT DPLAPI DPL_WaitForConnectionSettings(LPDIRECTPLAYLOBBY, DWORD);
  545. HRESULT PRV_GetInternalName(LPDPLOBBYI_GAMENODE, DWORD, LPWSTR);
  546. HRESULT PRV_AddNewGameNode(LPDPLOBBYI_DPLOBJECT, LPDPLOBBYI_GAMENODE *,
  547. DWORD, HANDLE, BOOL, LPGUID);
  548. HRESULT PRV_WriteConnectionSettings(LPDPLOBBYI_GAMENODE, LPDPLCONNECTION, BOOL);
  549. HRESULT PRV_FreeGameNode(LPDPLOBBYI_GAMENODE);
  550. void PRV_RemoveGameNodeFromList(LPDPLOBBYI_GAMENODE);
  551. HANDLE PRV_DuplicateHandle(HANDLE);
  552. DWORD WINAPI PRV_ReceiveClientNotification(LPVOID);
  553. DWORD WINAPI PRV_ClientTerminateNotification(LPVOID);
  554. HRESULT PRV_GetConnectionSettings(LPDIRECTPLAYLOBBY, DWORD, LPVOID,
  555. LPDWORD, BOOL);
  556. HRESULT PRV_SetConnectionSettings(LPDIRECTPLAYLOBBY, DWORD, DWORD,
  557. LPDPLCONNECTION);
  558. void PRV_KillThread(HANDLE, HANDLE);
  559. HRESULT PRV_InjectMessageInQueue(LPDPLOBBYI_GAMENODE, DWORD, LPVOID, DWORD, BOOL);
  560. HRESULT PRV_WriteClientData(LPDPLOBBYI_GAMENODE, DWORD, LPVOID, DWORD);
  561. void PRV_RemoveRequestNode(LPDPLOBBYI_DPLOBJECT, LPDPLOBBYI_REQUESTNODE);
  562. // dplsp.c
  563. extern HRESULT DPLAPI DPLP_AddGroupToGroup(LPDPLOBBYSP, LPSPDATA_ADDREMOTEGROUPTOGROUP);
  564. extern HRESULT DPLAPI DPLP_AddPlayerToGroup(LPDPLOBBYSP, LPSPDATA_ADDREMOTEPLAYERTOGROUP);
  565. extern HRESULT DPLAPI DPLP_CreateGroup(LPDPLOBBYSP, LPSPDATA_CREATEREMOTEGROUP);
  566. extern HRESULT DPLAPI DPLP_CreateGroupInGroup(LPDPLOBBYSP, LPSPDATA_CREATEREMOTEGROUPINGROUP);
  567. extern HRESULT DPLAPI DPLP_DeleteGroupFromGroup(LPDPLOBBYSP, LPSPDATA_DELETEREMOTEGROUPFROMGROUP);
  568. extern HRESULT DPLAPI DPLP_DeletePlayerFromGroup(LPDPLOBBYSP, LPSPDATA_DELETEREMOTEPLAYERFROMGROUP);
  569. extern HRESULT DPLAPI DPLP_DestroyGroup(LPDPLOBBYSP, LPSPDATA_DESTROYREMOTEGROUP);
  570. extern HRESULT DPLAPI DPLP_GetSPDataPointer(LPDPLOBBYSP, LPVOID *);
  571. extern HRESULT DPLAPI DPLP_HandleMessage(LPDPLOBBYSP, LPSPDATA_HANDLEMESSAGE);
  572. extern HRESULT DPLAPI DPLP_SendChatMessage(LPDPLOBBYSP, LPSPDATA_CHATMESSAGE);
  573. extern HRESULT DPLAPI DPLP_SetGroupName(LPDPLOBBYSP, LPSPDATA_SETREMOTEGROUPNAME);
  574. extern HRESULT DPLAPI DPLP_SetGroupOwner(LPDPLOBBYSP, LPSPDATA_SETREMOTEGROUPOWNER);
  575. extern HRESULT DPLAPI DPLP_SetPlayerName(LPDPLOBBYSP, LPSPDATA_SETREMOTEPLAYERNAME);
  576. extern HRESULT DPLAPI DPLP_SetSessionDesc(LPDPLOBBYSP, LPSPDATA_SETSESSIONDESC);
  577. extern HRESULT DPLAPI DPLP_SetSPDataPointer(LPDPLOBBYSP, LPVOID);
  578. extern HRESULT DPLAPI DPLP_StartSession(LPDPLOBBYSP, LPSPDATA_STARTSESSIONCOMMAND);
  579. HRESULT DPLAPI PRV_BroadcastDestroyGroupMessage(LPDPLOBBYI_DPLOBJECT, DPID);
  580. HRESULT PRV_DeleteRemotePlayerFromGroup(LPDPLOBBYI_DPLOBJECT,
  581. LPSPDATA_DELETEREMOTEPLAYERFROMGROUP, BOOL);
  582. HRESULT DPLAPI DPLP_DestroyGroup(LPDPLOBBYSP, LPSPDATA_DESTROYREMOTEGROUP);
  583. void PRV_RemoveSubgroupsAndPlayersFromGroup(LPDPLOBBYI_DPLOBJECT,
  584. LPDPLAYI_GROUP, DWORD, BOOL);
  585. HRESULT PRV_DeleteRemoteGroupFromGroup(LPDPLOBBYI_DPLOBJECT,
  586. LPSPDATA_DELETEREMOTEGROUPFROMGROUP, BOOL, LPDPLAYI_GROUP);
  587. void PRV_SendDeleteShortcutMessageForExitingGroup(LPDPLOBBYI_DPLOBJECT, LPDPLAYI_GROUP);
  588. HRESULT PRV_SendDataChangedMessageLocally(LPDPLOBBYI_DPLOBJECT, DPID, LPVOID, DWORD);
  589. HRESULT PRV_SendNameChangedMessageLocally(LPDPLOBBYI_DPLOBJECT, DPID, LPDPNAME, BOOL);
  590. HRESULT PRV_SendGroupOwnerMessageLocally(LPDPLOBBYI_DPLOBJECT, DPID, DPID, DPID);
  591. // group.c
  592. extern HRESULT PRV_GetGroupConnectionSettings(LPDIRECTPLAY, DWORD, DPID,
  593. LPVOID, LPDWORD);
  594. extern HRESULT PRV_SetGroupConnectionSettings(LPDIRECTPLAY, DWORD, DPID,
  595. LPDPLCONNECTION, BOOL);
  596. extern HRESULT PRV_CreateAndMapNewGroup(LPDPLOBBYI_DPLOBJECT,
  597. DPID *, LPDPNAME, LPVOID, DWORD, DWORD, DWORD, DPID, DWORD);
  598. void PRV_DestroySubgroups(LPDPLOBBYI_DPLOBJECT, LPDPLAYI_GROUP, BOOL);
  599. void PRV_DestroyGroupAndParents(LPDPLOBBYI_DPLOBJECT, LPDPLAYI_GROUP, LPDPLAYI_GROUP);
  600. // player.c
  601. extern HRESULT PRV_GrowMapTable(LPDPLOBBYI_DPLOBJECT);
  602. extern HRESULT PRV_CreateAndMapNewPlayer(LPDPLOBBYI_DPLOBJECT,
  603. DPID *, LPDPNAME, HANDLE, LPVOID, DWORD, DWORD, DWORD, BOOL);
  604. extern BOOL IsValidLobbyID(DWORD);
  605. extern BOOL IsLobbyIDInMapTable(LPDPLOBBYI_DPLOBJECT, DWORD);
  606. // session.c
  607. extern HRESULT DPLAPI DPLP_EnumSessionsResponse(LPDPLOBBYSP, LPSPDATA_ENUMSESSIONSRESPONSE);
  608. // api.c (in the dplay project)
  609. HRESULT TimeBomb();
  610. HRESULT ConnectMe(LPDIRECTPLAYLOBBY, LPDIRECTPLAY2 FAR *, IUnknown FAR *, DWORD);
  611. // SECURITY, memcpy that verifies dest bounds before executing,
  612. // on fail dispatches to label, logs specified string.
  613. #define memcpySecureD(dest,src,len,pBuf,cbBuf,error,action,exit) \
  614. if(((LPBYTE)(dest)) > (((LPBYTE)pBuf) + cbBuf) || \
  615. ((LPBYTE)(dest)) < ((LPBYTE)(pBuf)) || \
  616. (((LPBYTE)(dest)+len) > (((LPBYTE)pBuf) + cbBuf)) ) \
  617. { \
  618. DPF(4,error); \
  619. action; \
  620. goto exit; \
  621. } else { \
  622. memcpy(dest,src,len); \
  623. }
  624. // SECURITY, memcpy that verifies src bounds before executing,
  625. // on fail dispatches to label, logs specified string.
  626. #define memcpySecureS(dest,src,len,pBuf,cbBuf,error,action,exit) \
  627. if(((LPBYTE)(src)) > (((LPBYTE)pBuf) + cbBuf) || \
  628. ((LPBYTE)(src)) < ((LPBYTE)(pBuf)) || \
  629. (((LPBYTE)(src)+len) > (((LPBYTE)pBuf) + cbBuf)) ) \
  630. { \
  631. DPF(4,error); \
  632. action; \
  633. goto exit; \
  634. } else { \
  635. memcpy(dest,src,len); \
  636. }
  637. //--------------------------------------------------------------------------
  638. //
  639. // Definitions
  640. //
  641. //--------------------------------------------------------------------------
  642. #define MAX_APPDATABUFFERSIZE (65535)
  643. #define APPDATA_RESERVEDSIZE (2 * sizeof(DWORD))
  644. #endif // __DPLOBPR_INCLUDED__