dplayx_messages.h 7.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright 2000 Peter Hunnisett
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17
 */
18

19 20
#ifndef __WINE_DPLAYX_MESSAGES__
#define __WINE_DPLAYX_MESSAGES__
21

22 23
#include <stdarg.h>

24
#include "windef.h"
25
#include "winbase.h"
26 27
#include "dplay.h"
#include "rpc.h" /* For GUID */
28

Peter Hunnisett's avatar
Peter Hunnisett committed
29 30
#include "dplay_global.h"

31
DWORD CreateLobbyMessageReceptionThread( HANDLE hNotifyEvent, HANDLE hStart,
32
                                         HANDLE hDeath, HANDLE hConnRead ) DECLSPEC_HIDDEN;
33

34
HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags,
35 36
                                    LPDPID lpdipidAllocatedId ) DECLSPEC_HIDDEN;
HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ) DECLSPEC_HIDDEN;
37

38
void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId,
39
                           LPCVOID lpMsgBody, DWORD dwMsgBodySize ) DECLSPEC_HIDDEN;
40
void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId,
41 42
                           LPCVOID lpMsgBody, DWORD dwMsgBodySize ) DECLSPEC_HIDDEN;
void DP_MSG_ToSelf( IDirectPlay2AImpl* This, DPID dpidSelf ) DECLSPEC_HIDDEN;
43 44 45 46 47 48

/* Timings -> 1000 ticks/sec */
#define DPMSG_WAIT_5_SECS   5000
#define DPMSG_WAIT_30_SECS 30000
#define DPMSG_WAIT_60_SECS 60000
#define DPMSG_DEFAULT_WAIT_TIME DPMSG_WAIT_30_SECS
49

50 51 52 53 54 55
/* Message types etc. */
#include "pshpack1.h"

/* Non provided messages for DPLAY - guess work which may be wrong :( */
#define DPMSGCMD_ENUMSESSIONSREPLY    1
#define DPMSGCMD_ENUMSESSIONSREQUEST  2
56
#define DPMSGCMD_GETNAMETABLEREPLY    3  /* Contains all existing players in session */
57 58 59 60

#define DPMSGCMD_REQUESTNEWPLAYERID   5

#define DPMSGCMD_NEWPLAYERIDREPLY     7
61
#define DPMSGCMD_CREATESESSION        8 /* Might be a create nameserver or new player msg */
62
#define DPMSGCMD_CREATENEWPLAYER      9
63
#define DPMSGCMD_SYSTEMMESSAGE        10
Peter Hunnisett's avatar
Peter Hunnisett committed
64
#define DPMSGCMD_DELETEPLAYER         11
65 66 67 68
#define DPMSGCMD_DELETEGROUP          12

#define DPMSGCMD_ENUMGROUPS           17

69
#define DPMSGCMD_FORWARDADDPLAYER     19
70

71 72
#define DPMSGCMD_PLAYERCHAT           22

73
#define DPMSGCMD_FORWARDADDPLAYERNACK 36
Peter Hunnisett's avatar
Peter Hunnisett committed
74

75 76 77
#define DPMSGCMD_JUSTENVELOPE         1000
#define DPMSGCMD_JUSTENVELOPEREPLY    1001

78 79 80 81 82 83 84 85 86 87
/* This is what DP 6 defines it as. Don't know what it means. All messages
 * defined below are DPMSGVER_DP6.
 */
#define DPMSGVER_DP6 11

/* MAGIC number at the start of all dplay packets ("play" in ASCII) */
#define DPMSGMAGIC_DPLAYMSG  0x79616c70

/* All messages sent from the system are sent with this at the beginning of
 * the message.
88
 * Size is 8 bytes
89 90 91 92 93 94 95 96 97
 */
typedef struct tagDPMSG_SENDENVELOPE
{
  DWORD dwMagic;
  WORD  wCommandId;
  WORD  wVersion;
} DPMSG_SENDENVELOPE, *LPDPMSG_SENDENVELOPE;
typedef const DPMSG_SENDENVELOPE* LPCDPMSG_SENDENVELOPE;

98
/* System messages exchanged between players seems to have this
99
 * payload envelope on top of the basic envelope
100
 */
101 102 103 104 105 106 107
typedef struct tagDPMSG_SYSMSGENVELOPE
{
  DWORD dwPlayerFrom;
  DWORD dwPlayerTo;
} DPMSG_SYSMSGENVELOPE, *LPDPMSG_SYSMSGENVELOPE;
typedef const DPMSG_SYSMSGENVELOPE* LPCDPMSG_SYSMSGENVELOPE;

108
/* Reply sent in response to an enumsession request */
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
typedef struct tagDPMSG_ENUMSESSIONSREPLY
{
  DPMSG_SENDENVELOPE envelope;

#if 0
  DWORD dwSize;  /* Size of DPSESSIONDESC2 struct */
  DWORD dwFlags; /* Sessions flags */

  GUID guidInstance; /* Not 100% sure this is what it is... */

  GUID guidApplication;

  DWORD dwMaxPlayers;
  DWORD dwCurrentPlayers;

  BYTE unknown[36];
#else
  DPSESSIONDESC2 sd;
#endif

  DWORD dwUnknown;  /* Seems to be equal to 0x5c which is a "\\" */
                    /* Encryption package string? */

  /* At the end we have ... */
  /* WCHAR wszSessionName[1];  Var length with NULL terminal */

} DPMSG_ENUMSESSIONSREPLY, *LPDPMSG_ENUMSESSIONSREPLY;
typedef const DPMSG_ENUMSESSIONSREPLY* LPCDPMSG_ENUMSESSIONSREPLY;

138
/* Msg sent to find out what sessions are available */
139 140 141 142 143 144
typedef struct tagDPMSG_ENUMSESSIONSREQUEST
{
  DPMSG_SENDENVELOPE envelope;

  GUID  guidApplication;

145
  DWORD dwPasswordSize; /* A Guess. This is 0x00000000. */
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
                        /* This might be the name server DPID which
                           is needed for the reply */

  DWORD dwFlags; /* dwFlags from EnumSessions */

} DPMSG_ENUMSESSIONSREQUEST, *LPDPMSG_ENUMSESSIONSREQUEST;
typedef const DPMSG_ENUMSESSIONSREQUEST* LPCDPMSG_ENUMSESSIONSREQUEST;

/* Size is 146 received - with 18 or 20 bytes header = ~128 bytes */
typedef struct tagDPMSG_CREATESESSION
{
  DPMSG_SENDENVELOPE envelope;
} DPMSG_CREATESESSION, *LPDPMSG_CREATESESSION;
typedef const DPMSG_CREATESESSION* LPCDPMSG_CREATESESSION;

Peter Hunnisett's avatar
Peter Hunnisett committed
161
/* 12 bytes msg */
162 163 164 165
typedef struct tagDPMSG_REQUESTNEWPLAYERID
{
  DPMSG_SENDENVELOPE envelope;

Peter Hunnisett's avatar
Peter Hunnisett committed
166
  DWORD dwFlags;  /* dwFlags used for CreatePlayer */
167 168 169 170

} DPMSG_REQUESTNEWPLAYERID, *LPDPMSG_REQUESTNEWPLAYERID;
typedef const DPMSG_REQUESTNEWPLAYERID* LPCDPMSG_REQUESTNEWPLAYERID;

171
/* 48 bytes msg */
172 173 174 175
typedef struct tagDPMSG_NEWPLAYERIDREPLY
{
  DPMSG_SENDENVELOPE envelope;

Peter Hunnisett's avatar
Peter Hunnisett committed
176
  DPID dpidNewPlayerId;
177

178 179 180 181
  /* Assume that this is data that is tacked on to the end of the message
   * that comes from the SP remote data stored that needs to be propagated.
   */
  BYTE unknown[36];     /* This appears to always be 0 - not sure though */
182 183 184
} DPMSG_NEWPLAYERIDREPLY, *LPDPMSG_NEWPLAYERIDREPLY;
typedef const DPMSG_NEWPLAYERIDREPLY* LPCDPMSG_NEWPLAYERIDREPLY;

185 186 187
typedef struct tagDPMSG_FORWARDADDPLAYER
{
  DPMSG_SENDENVELOPE envelope;
188

189
  DWORD unknown; /* 0 */
Peter Hunnisett's avatar
Peter Hunnisett committed
190

191
  DPID  dpidAppServer; /* Remote application server id */
192
  DWORD unknown2[5]; /* 0x0, 0x1c, 0x6c, 0x50, 0x9 */
193 194

  DPID  dpidAppServer2; /* Remote application server id again !? */
195
  DWORD unknown3[5]; /* 0x0, 0x0, 0x20, 0x0, 0x0 */
196 197 198 199

  DPID  dpidAppServer3; /* Remote application server id again !? */

  DWORD unknown4[12]; /* ??? - Is this a clump of 5 and then 8? */
200
                      /* NOTE: 1 byte in front of the two 0x??090002 entries changes!
201 202 203
                      *       Is it a timestamp of some sort? 1st always smaller than
                      *       other...
                      */
204
#define FORWARDADDPLAYER_UNKNOWN4_INIT { 0x30, 0xb, 0x0, 0x1e090002, 0x0, 0x0, 0x0, 0x32090002, 0x0, 0x0, 0x0, 0x0 }
Peter Hunnisett's avatar
Peter Hunnisett committed
205

206
  BYTE unknown5[2]; /* 2 bytes at the end. This may be a part of something! ( 0x0, 0x0) */
Peter Hunnisett's avatar
Peter Hunnisett committed
207

208 209 210
} DPMSG_FORWARDADDPLAYER, *LPDPMSG_FORWARDADDPLAYER;
typedef const DPMSG_FORWARDADDPLAYER* LPCDPMSG_FORWARDADDPLAYER;

211
/* This is an error message that can be received. Not sure if this is
212 213 214 215 216 217 218 219 220 221
 * specifically for a forward add player or for all errors
 */
typedef struct tagDPMSG_FORWARDADDPLAYERNACK
{
  DPMSG_SENDENVELOPE envelope;
  HRESULT errorCode;
} DPMSG_FORWARDADDPLAYERNACK, *LPDPMSG_FORWARDADDPLAYERNACK;
typedef const DPMSG_FORWARDADDPLAYERNACK* LPCDPMSG_FORWARDADDPLAYERNACK;

#include "poppack.h"
Peter Hunnisett's avatar
Peter Hunnisett committed
222

223
#endif