mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Added (very) experimental DirectPlay support.
This commit is contained in:
parent
14e7e08dda
commit
e5271a3df6
12
Makefile
12
Makefile
@ -14,8 +14,8 @@
|
||||
# this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
CFLAGS := -Wall
|
||||
CXXFLAGS := -Wall
|
||||
CFLAGS := -Wall -I./include/
|
||||
CXXFLAGS := -Wall -I./include/
|
||||
|
||||
IPXWRAPPER_DEPS := src/ipxwrapper.o src/winsock.o src/ipxwrapper_stubs.o src/log.o src/ipxwrapper.def
|
||||
|
||||
@ -25,7 +25,7 @@ SRC_FILES := changes.txt license.txt Makefile mkstubs.pl readme.txt src/config.h
|
||||
src/mswsock.def src/mswsock_stubs.txt src/stubdll.c src/winsock.c src/winstuff.h src/wsock32.def \
|
||||
src/wsock32_stubs.txt
|
||||
|
||||
all: ipxwrapper.dll wsock32.dll mswsock.dll ipxconfig.exe
|
||||
all: ipxwrapper.dll wsock32.dll mswsock.dll ipxconfig.exe dpwsockx.dll
|
||||
|
||||
clean:
|
||||
rm -f ipxwrapper.dll wsock32.dll mswsock.dll ipxconfig.exe
|
||||
@ -51,6 +51,9 @@ ipxwrapper.dll: $(IPXWRAPPER_DEPS)
|
||||
ipxconfig.exe: src/ipxconfig.cpp
|
||||
$(CXX) $(CXXFLAGS) -static-libgcc -static-libstdc++ -Wl,-s -D_WIN32_IE=0x0400 -mwindows -o ipxconfig.exe src/ipxconfig.cpp -liphlpapi
|
||||
|
||||
dpwsockx.dll: src/directplay.o src/log.o src/dpwsockx_stubs.o ipxwrapper.dll
|
||||
$(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup,-s -shared -o dpwsockx.dll src/directplay.o src/log.o src/dpwsockx_stubs.o src/dpwsockx.def -L. -lipxwrapper -lwsock32
|
||||
|
||||
src/ipxwrapper_stubs.s: src/ipxwrapper_stubs.txt
|
||||
perl mkstubs.pl src/ipxwrapper_stubs.txt src/ipxwrapper_stubs.s
|
||||
|
||||
@ -60,6 +63,9 @@ src/wsock32_stubs.s: src/wsock32_stubs.txt
|
||||
src/mswsock_stubs.s: src/mswsock_stubs.txt
|
||||
perl mkstubs.pl src/mswsock_stubs.txt src/mswsock_stubs.s mswsock.dll
|
||||
|
||||
src/dpwsockx_stubs.s: src/dpwsockx_stubs.txt
|
||||
perl mkstubs.pl src/dpwsockx_stubs.txt src/dpwsockx_stubs.s dpwsockx.dll
|
||||
|
||||
%.dll: src/stubdll.o src/%_stubs.o src/log.o src/%.def
|
||||
$(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup,-s -shared -o $@ $^
|
||||
|
||||
|
1273
include/dplay.h
Normal file
1273
include/dplay.h
Normal file
File diff suppressed because it is too large
Load Diff
366
include/dplaysp.h
Normal file
366
include/dplaysp.h
Normal file
@ -0,0 +1,366 @@
|
||||
/*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __WINE_DIRECT_PLAY_SP_H
|
||||
#define __WINE_DIRECT_PLAY_SP_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "dplay.h"
|
||||
#include "dplobby.h"
|
||||
|
||||
/* GUID for IDirectPlaySP {0C9F6360-CC61-11cf-ACEC-00AA006886E3} */
|
||||
DEFINE_GUID(IID_IDirectPlaySP, 0xc9f6360, 0xcc61, 0x11cf, 0xac, 0xec, 0x0, 0xaa, 0x0, 0x68, 0x86, 0xe3);
|
||||
typedef struct IDirectPlaySP *LPDIRECTPLAYSP;
|
||||
|
||||
|
||||
typedef BOOL (CALLBACK *LPENUMMRUCALLBACK)( LPCVOID lpData,
|
||||
DWORD dwDataSize,
|
||||
LPVOID lpContext );
|
||||
|
||||
/* For SP. Top 16 bits is dplay, bottom 16 is SP */
|
||||
#define DPSP_MAJORVERSION 0x00060000
|
||||
#define DPSP_DX5VERSION 0x00050000
|
||||
#define DPSP_DX3VERSION 0x00040000
|
||||
|
||||
#define DPSP_MAJORVERSIONMASK 0xFFFF0000
|
||||
#define DPSP_MINORVERSIONMASK 0x0000FFFF
|
||||
|
||||
|
||||
/* Some flags */
|
||||
#define DPLAYI_PLAYER_SYSPLAYER 0x00000001
|
||||
#define DPLAYI_PLAYER_NAMESRVR 0x00000002
|
||||
#define DPLAYI_PLAYER_PLAYERINGROUP 0x00000004
|
||||
#define DPLAYI_PLAYER_PLAYERLOCAL 0x00000008
|
||||
#define DPLAYI_GROUP_SYSGROUP 0x00000020
|
||||
#define DPLAYI_GROUP_DPLAYOWNS 0x00000040
|
||||
#define DPLAYI_PLAYER_APPSERVER 0x00000080
|
||||
#define DPLAYI_GROUP_HIDDEN 0x00000400
|
||||
|
||||
/* Define the COM interface */
|
||||
#define INTERFACE IDirectPlaySP
|
||||
DECLARE_INTERFACE_(IDirectPlaySP,IUnknown)
|
||||
{
|
||||
/*** IUnknown methods ***/
|
||||
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
|
||||
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
|
||||
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
||||
/*** IDirectPlaySP methods ***/
|
||||
STDMETHOD(AddMRUEntry)(THIS_ LPCWSTR lpSection, LPCWSTR lpKey, LPCVOID lpData, DWORD dwDataSize, DWORD dwMaxEntries ) PURE;
|
||||
STDMETHOD(CreateAddress)(THIS_ REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, DWORD dwDataSize, LPVOID lpAddress,LPDWORD lpdwAddressSize) PURE;
|
||||
STDMETHOD(EnumAddress)(THIS_ LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress, DWORD dwAddressSize, LPVOID lpContext ) PURE;
|
||||
STDMETHOD(EnumMRUEntries)(THIS_ LPCWSTR lpSection, LPCWSTR lpKey, LPENUMMRUCALLBACK lpEnumMRUCallback, LPVOID lpContext ) PURE;
|
||||
STDMETHOD(GetPlayerFlags)(THIS_ DPID idPlayer, LPDWORD lpdwPlayerFlags ) PURE;
|
||||
STDMETHOD(GetSPPlayerData)(THIS_ DPID idPlayer, LPVOID *lplpData, LPDWORD lpdwDataSize, DWORD dwFlags ) PURE;
|
||||
STDMETHOD(HandleMessage)(THIS_ LPVOID lpMessageBody, DWORD dwMessageBodySize, LPVOID lpMessageHeader ) PURE;
|
||||
STDMETHOD(SetSPPlayerData)(THIS_ DPID idPlayer, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags ) PURE;
|
||||
STDMETHOD(CreateCompoundAddress)(THIS_ LPCDPCOMPOUNDADDRESSELEMENT lpElements, DWORD dwElementCount, LPVOID lpAddress, LPDWORD lpdwAddressSize ) PURE;
|
||||
STDMETHOD(GetSPData)(THIS_ LPVOID *lplpData, LPDWORD dwDataSize, DWORD dwFlags ) PURE;
|
||||
STDMETHOD(SetSPData)(THIS_ LPVOID lpData, DWORD dwDataSize, DWORD dwFlags ) PURE;
|
||||
STDMETHOD_(VOID,SendComplete)(THIS_ LPVOID , DWORD ) PURE;
|
||||
};
|
||||
#undef INTERFACE
|
||||
|
||||
|
||||
/* NOTE: The microsoft provided header file doesn't have these access
|
||||
* functions
|
||||
*/
|
||||
#if !defined (__cplusplus) || defined(CINTERFACE)
|
||||
/*** IUnknown methods ***/
|
||||
#define IDirectPlaySP_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
|
||||
#define IDirectPlaySP_AddRef(p) (p)->lpVtbl->AddRef(p)
|
||||
#define IDirectPlaySP_Release(p) (p)->lpVtbl->Release(p)
|
||||
/*** IDirectPlaySP methods ***/
|
||||
#define IDirectPlaySP_AddMRUEntry(p,a,b,c,d,e) (p)->lpVtbl->AddMRUEntry(p,a,b,c,d,e)
|
||||
#define IDirectPlaySP_CreateAddress(p,a,b,c,d,e,f) (p)->lpVtbl->CreateAddress(p,a,b,c,d,e,f)
|
||||
#define IDirectPlaySP_EnumAddress(p,a,b,c,d) (p)->lpVtbl->EnumAddress(p,a,b,c,d)
|
||||
#define IDirectPlaySP_EnumMRUEntries(p,a,b,c,d) (p)->lpVtbl->EnumMRUEntries(p,a,b,c,d)
|
||||
#define IDirectPlaySP_GetPlayerFlags(p,a,b) (p)->lpVtbl->GetPlayerFlags(p,a,b)
|
||||
#define IDirectPlaySP_GetSPPlayerData(p,a,b,c,d) (p)->lpVtbl->GetSPPlayerData(p,a,b,c,d)
|
||||
#define IDirectPlaySP_HandleMessage(p,a,b,c) (p)->lpVtbl->HandleMessage(p,a,b,c)
|
||||
#define IDirectPlaySP_SetSPPlayerData(p,a,b,c,d) (p)->lpVtbl->SetSPPlayerData(p,a,b,c,d)
|
||||
#define IDirectPlaySP_CreateCompoundAddress(p,a,b,c,d) (p)->lpVtbl->CreateCompoundAddress(p,a,b,c,d)
|
||||
#define IDirectPlaySP_GetSPData(p,a,b,c) (p)->lpVtbl->GetSPData(p,a,b,c)
|
||||
#define IDirectPlaySP_SetSPData(p,a,b,c) (p)->lpVtbl->SetSPData(p,a,b,c)
|
||||
#define IDirectPlaySP_SendComplete(p,a,b) (p)->lpVtbl->SendComplete(p,a,b)
|
||||
#endif
|
||||
|
||||
/* SP Callback stuff */
|
||||
|
||||
typedef struct tagDPSP_ADDPLAYERTOGROUPDATA
|
||||
{
|
||||
DPID idPlayer;
|
||||
DPID idGroup;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_ADDPLAYERTOGROUPDATA, *LPDPSP_ADDPLAYERTOGROUPDATA;
|
||||
|
||||
typedef struct tagDPSP_CLOSEDATA
|
||||
{
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_CLOSEDATA, *LPDPSP_CLOSEDATA;
|
||||
|
||||
typedef struct tagDPSP_CREATEGROUPDATA
|
||||
{
|
||||
DPID idGroup;
|
||||
DWORD dwFlags;
|
||||
LPVOID lpSPMessageHeader;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_CREATEGROUPDATA, *LPDPSP_CREATEGROUPDATA;
|
||||
|
||||
typedef struct tagDPSP_CREATEPLAYERDATA
|
||||
{
|
||||
DPID idPlayer;
|
||||
DWORD dwFlags;
|
||||
LPVOID lpSPMessageHeader;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_CREATEPLAYERDATA, *LPDPSP_CREATEPLAYERDATA;
|
||||
|
||||
typedef struct tagDPSP_DELETEGROUPDATA
|
||||
{
|
||||
DPID idGroup;
|
||||
DWORD dwFlags;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_DELETEGROUPDATA, *LPDPSP_DELETEGROUPDATA;
|
||||
|
||||
typedef struct tagDPSP_DELETEPLAYERDATA
|
||||
{
|
||||
DPID idPlayer;
|
||||
DWORD dwFlags;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_DELETEPLAYERDATA, *LPDPSP_DELETEPLAYERDATA;
|
||||
|
||||
typedef struct tagDPSP_ENUMSESSIONSDATA
|
||||
{
|
||||
LPVOID lpMessage;
|
||||
DWORD dwMessageSize;
|
||||
IDirectPlaySP* lpISP;
|
||||
BOOL bReturnStatus;
|
||||
} DPSP_ENUMSESSIONSDATA, *LPDPSP_ENUMSESSIONSDATA;
|
||||
|
||||
typedef struct _DPSP_GETADDRESSDATA
|
||||
{
|
||||
DPID idPlayer;
|
||||
DWORD dwFlags;
|
||||
LPDPADDRESS lpAddress;
|
||||
LPDWORD lpdwAddressSize;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_GETADDRESSDATA, *LPDPSP_GETADDRESSDATA;
|
||||
|
||||
typedef struct tagDPSP_GETADDRESSCHOICESDATA
|
||||
{
|
||||
LPDPADDRESS lpAddress;
|
||||
LPDWORD lpdwAddressSize;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_GETADDRESSCHOICESDATA, *LPDPSP_GETADDRESSCHOICESDATA;
|
||||
|
||||
typedef struct tagDPSP_GETCAPSDATA
|
||||
{
|
||||
DPID idPlayer;
|
||||
LPDPCAPS lpCaps;
|
||||
DWORD dwFlags;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_GETCAPSDATA, *LPDPSP_GETCAPSDATA;
|
||||
|
||||
typedef struct tagDPSP_OPENDATA
|
||||
{
|
||||
BOOL bCreate;
|
||||
LPVOID lpSPMessageHeader;
|
||||
IDirectPlaySP* lpISP;
|
||||
BOOL bReturnStatus;
|
||||
DWORD dwOpenFlags;
|
||||
DWORD dwSessionFlags;
|
||||
} DPSP_OPENDATA, *LPDPSP_OPENDATA;
|
||||
|
||||
typedef struct tagDPSP_REMOVEPLAYERFROMGROUPDATA
|
||||
{
|
||||
DPID idPlayer;
|
||||
DPID idGroup;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_REMOVEPLAYERFROMGROUPDATA, *LPDPSP_REMOVEPLAYERFROMGROUPDATA;
|
||||
|
||||
typedef struct tagDPSP_REPLYDATA
|
||||
{
|
||||
LPVOID lpSPMessageHeader;
|
||||
LPVOID lpMessage;
|
||||
DWORD dwMessageSize;
|
||||
DPID idNameServer;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_REPLYDATA, *LPDPSP_REPLYDATA;
|
||||
|
||||
typedef struct tagDPSP_SENDDATA
|
||||
{
|
||||
DWORD dwFlags;
|
||||
DPID idPlayerTo;
|
||||
DPID idPlayerFrom;
|
||||
LPVOID lpMessage;
|
||||
DWORD dwMessageSize;
|
||||
BOOL bSystemMessage;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_SENDDATA, *LPDPSP_SENDDATA;
|
||||
|
||||
typedef struct tagDPSP_SENDTOGROUPDATA
|
||||
{
|
||||
DWORD dwFlags;
|
||||
DPID idGroupTo;
|
||||
DPID idPlayerFrom;
|
||||
LPVOID lpMessage;
|
||||
DWORD dwMessageSize;
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_SENDTOGROUPDATA, *LPDPSP_SENDTOGROUPDATA;
|
||||
|
||||
typedef struct tagDPSP_SENDEXDATA
|
||||
{
|
||||
IDirectPlaySP* lpISP;
|
||||
DWORD dwFlags;
|
||||
DPID idPlayerTo;
|
||||
DPID idPlayerFrom;
|
||||
LPSGBUFFER lpSendBuffers;
|
||||
DWORD cBuffers;
|
||||
DWORD dwMessageSize;
|
||||
DWORD dwPriority;
|
||||
DWORD dwTimeout;
|
||||
LPVOID lpDPContext;
|
||||
LPDWORD lpdwSPMsgID;
|
||||
BOOL bSystemMessage;
|
||||
} DPSP_SENDEXDATA, *LPDPSP_SENDEXDATA;
|
||||
|
||||
typedef struct tagDPSP_SENDTOGROUPEXDATA
|
||||
{
|
||||
IDirectPlaySP* lpISP;
|
||||
DWORD dwFlags;
|
||||
DPID idGroupTo;
|
||||
DPID idPlayerFrom;
|
||||
LPSGBUFFER lpSendBuffers;
|
||||
DWORD cBuffers;
|
||||
DWORD dwMessageSize;
|
||||
DWORD dwPriority;
|
||||
DWORD dwTimeout;
|
||||
LPVOID lpDPContext;
|
||||
LPDWORD lpdwSPMsgID;
|
||||
} DPSP_SENDTOGROUPEXDATA, *LPDPSP_SENDTOGROUPEXDATA;
|
||||
|
||||
typedef struct tagDPSP_GETMESSAGEQUEUEDATA
|
||||
{
|
||||
IDirectPlaySP* lpISP;
|
||||
DWORD dwFlags;
|
||||
DPID idFrom;
|
||||
DPID idTo;
|
||||
LPDWORD lpdwNumMsgs;
|
||||
LPDWORD lpdwNumBytes;
|
||||
} DPSP_GETMESSAGEQUEUEDATA, *LPDPSP_GETMESSAGEQUEUEDATA;
|
||||
|
||||
#define DPCANCELSEND_PRIORITY 0x00000001
|
||||
#define DPCANCELSEND_ALL 0x00000002
|
||||
|
||||
typedef struct tagDPSP_CANCELDATA
|
||||
{
|
||||
IDirectPlaySP* lpISP;
|
||||
DWORD dwFlags;
|
||||
LPRGLPVOID lprglpvSPMsgID;
|
||||
DWORD cSPMsgID;
|
||||
DWORD dwMinPriority;
|
||||
DWORD dwMaxPriority;
|
||||
} DPSP_CANCELDATA, *LPDPSP_CANCELDATA;
|
||||
|
||||
typedef struct tagDPSP_SHUTDOWNDATA
|
||||
{
|
||||
IDirectPlaySP* lpISP;
|
||||
} DPSP_SHUTDOWNDATA, *LPDPSP_SHUTDOWNDATA;
|
||||
|
||||
|
||||
/* Prototypes returned by SPInit */
|
||||
typedef HRESULT (WINAPI *LPDPSP_CREATEPLAYER)(LPDPSP_CREATEPLAYERDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_DELETEPLAYER)(LPDPSP_DELETEPLAYERDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_SEND)(LPDPSP_SENDDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_ENUMSESSIONS)(LPDPSP_ENUMSESSIONSDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_REPLY)(LPDPSP_REPLYDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_SHUTDOWN)(void);
|
||||
typedef HRESULT (WINAPI *LPDPSP_CREATEGROUP)(LPDPSP_CREATEGROUPDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_DELETEGROUP)(LPDPSP_DELETEGROUPDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_ADDPLAYERTOGROUP)(LPDPSP_ADDPLAYERTOGROUPDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_REMOVEPLAYERFROMGROUP)(LPDPSP_REMOVEPLAYERFROMGROUPDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_GETCAPS)(LPDPSP_GETCAPSDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_GETADDRESS)(LPDPSP_GETADDRESSDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_GETADDRESSCHOICES)(LPDPSP_GETADDRESSCHOICESDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_OPEN)(LPDPSP_OPENDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_CLOSE)(void);
|
||||
typedef HRESULT (WINAPI *LPDPSP_SENDTOGROUP)(LPDPSP_SENDTOGROUPDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_SHUTDOWNEX)(LPDPSP_SHUTDOWNDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_CLOSEEX)(LPDPSP_CLOSEDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_SENDEX)(LPDPSP_SENDEXDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_SENDTOGROUPEX)(LPDPSP_SENDTOGROUPEXDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_CANCEL)(LPDPSP_CANCELDATA);
|
||||
typedef HRESULT (WINAPI *LPDPSP_GETMESSAGEQUEUE)(LPDPSP_GETMESSAGEQUEUEDATA);
|
||||
|
||||
|
||||
typedef struct tagDPSP_SPCALLBACKS
|
||||
{
|
||||
DWORD dwSize;
|
||||
DWORD dwVersion;
|
||||
|
||||
LPDPSP_ENUMSESSIONS EnumSessions; /* Must be provided */
|
||||
LPDPSP_REPLY Reply; /* Must be provided */
|
||||
LPDPSP_SEND Send; /* Must be provided */
|
||||
LPDPSP_ADDPLAYERTOGROUP AddPlayerToGroup; /* Optional */
|
||||
LPDPSP_CLOSE Close; /* Optional */
|
||||
LPDPSP_CREATEGROUP CreateGroup; /* Optional */
|
||||
LPDPSP_CREATEPLAYER CreatePlayer; /* Optional */
|
||||
LPDPSP_DELETEGROUP DeleteGroup; /* Optional */
|
||||
LPDPSP_DELETEPLAYER DeletePlayer; /* Optional */
|
||||
LPDPSP_GETADDRESS GetAddress; /* Optional */
|
||||
LPDPSP_GETCAPS GetCaps; /* Optional */
|
||||
LPDPSP_OPEN Open; /* Optional */
|
||||
LPDPSP_REMOVEPLAYERFROMGROUP RemovePlayerFromGroup; /* Optional */
|
||||
LPDPSP_SENDTOGROUP SendToGroup; /* Optional */
|
||||
LPDPSP_SHUTDOWN Shutdown; /* Optional */
|
||||
|
||||
LPDPSP_CLOSEEX CloseEx; /* Optional */
|
||||
LPDPSP_SHUTDOWNEX ShutdownEx; /* Optional */
|
||||
LPDPSP_GETADDRESSCHOICES GetAddressChoices; /* Optional */
|
||||
|
||||
LPDPSP_SENDEX SendEx; /* Optional */
|
||||
LPDPSP_SENDTOGROUPEX SendToGroupEx; /* Optional */
|
||||
LPDPSP_CANCEL Cancel; /* Optional */
|
||||
LPDPSP_GETMESSAGEQUEUE GetMessageQueue; /* Optional */
|
||||
} DPSP_SPCALLBACKS, *LPDPSP_SPCALLBACKS;
|
||||
|
||||
typedef struct tagSPINITDATA
|
||||
{
|
||||
LPDPSP_SPCALLBACKS lpCB;
|
||||
IDirectPlaySP* lpISP;
|
||||
LPWSTR lpszName;
|
||||
LPGUID lpGuid;
|
||||
DWORD dwReserved1;
|
||||
DWORD dwReserved2;
|
||||
DWORD dwSPHeaderSize;
|
||||
LPDPADDRESS lpAddress;
|
||||
DWORD dwAddressSize;
|
||||
DWORD dwSPVersion;
|
||||
} SPINITDATA, *LPSPINITDATA;
|
||||
|
||||
typedef HRESULT (WINAPI *LPDPSP_SPINIT)(LPSPINITDATA);
|
||||
|
||||
/* This variable is exported from the DLL at ordinal 6 to be accessed by the
|
||||
* SP directly
|
||||
*/
|
||||
extern DWORD gdwDPlaySPRefCount;
|
||||
|
||||
#endif
|
509
include/dplobby.h
Normal file
509
include/dplobby.h
Normal file
@ -0,0 +1,509 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Francois Gouget
|
||||
* Copyright (C) 1999 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
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __WINE_DPLOBBY_H
|
||||
#define __WINE_DPLOBBY_H
|
||||
|
||||
#include <dplay.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* defined(__cplusplus) */
|
||||
|
||||
/*****************************************************************************
|
||||
* Predeclare the interfaces
|
||||
*/
|
||||
DEFINE_GUID(CLSID_DirectPlayLobby, 0x2fe8f810, 0xb2a5, 0x11d0, 0xa7, 0x87, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc);
|
||||
|
||||
DEFINE_GUID(IID_IDirectPlayLobby, 0xaf465c71, 0x9588, 0x11cf, 0xa0, 0x20, 0x0, 0xaa, 0x0, 0x61, 0x57, 0xac);
|
||||
typedef struct IDirectPlayLobby *LPDIRECTPLAYLOBBY;
|
||||
|
||||
DEFINE_GUID(IID_IDirectPlayLobbyA, 0x26c66a70, 0xb367, 0x11cf, 0xa0, 0x24, 0x0, 0xaa, 0x0, 0x61, 0x57, 0xac);
|
||||
typedef struct IDirectPlayLobby IDirectPlayLobbyA,*LPDIRECTPLAYLOBBYA;
|
||||
|
||||
DEFINE_GUID(IID_IDirectPlayLobby2, 0x194c220, 0xa303, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
typedef struct IDirectPlayLobby2 *LPDIRECTPLAYLOBBY2;
|
||||
|
||||
DEFINE_GUID(IID_IDirectPlayLobby2A, 0x1bb4af80, 0xa303, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
typedef struct IDirectPlayLobby2 IDirectPlayLobby2A, *LPDIRECTPLAYLOBBY2A;
|
||||
|
||||
DEFINE_GUID(IID_IDirectPlayLobby3, 0x2db72490, 0x652c, 0x11d1, 0xa7, 0xa8, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc);
|
||||
typedef struct IDirectPlayLobby3 *LPDIRECTPLAYLOBBY3;
|
||||
|
||||
DEFINE_GUID(IID_IDirectPlayLobby3A, 0x2db72491, 0x652c, 0x11d1, 0xa7, 0xa8, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc);
|
||||
typedef struct IDirectPlayLobby3 IDirectPlayLobby3A, *LPDIRECTPLAYLOBBY3A;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* DirectPlayLobby Property GUIDs used in lobby messages
|
||||
*/
|
||||
|
||||
/* DPLPROPERTY_MessagesSupported {762CCDA1-D916-11d0-BA39-00C04FD7ED67}.
|
||||
* Purpose: Request if the lobby supports standard (?).
|
||||
* Response: Answer is a BOOL. TRUE if supports the standard (?) and FALSE otherwise. Of course, it might not respond at all.
|
||||
*/
|
||||
DEFINE_GUID(DPLPROPERTY_MessagesSupported, 0x762ccda1, 0xd916, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67);
|
||||
|
||||
/* DPLPROPERTY_LobbyGuid {F56920A0-D218-11d0-BA39-00C04FD7ED67}.
|
||||
* Purpose: Request the GUID that identifies the lobby version that the application is communicating with.
|
||||
* Response: The GUID which identifies the lobby version
|
||||
*/
|
||||
DEFINE_GUID(DPLPROPERTY_LobbyGuid, 0xf56920a0, 0xd218, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67);
|
||||
|
||||
/* DPLPROPERTY_PlayerGuid {B4319322-D20D-11d0-BA39-00C04FD7ED67}
|
||||
* Purpose: Request the GUID that identifies the player for this particular machine.
|
||||
* Response: DPLDATA_PLAYERDATA structure.
|
||||
*/
|
||||
DEFINE_GUID(DPLPROPERTY_PlayerGuid, 0xb4319322, 0xd20d, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67);
|
||||
|
||||
/* DPLPROPERTY_PlayerScore {48784000-D219-11d0-BA39-00C04FD7ED67}
|
||||
* Purpose: Used to send a score of a player to the lobby. The format is an array of long integers.
|
||||
* Response: I don't think there is one.
|
||||
*/
|
||||
DEFINE_GUID(DPLPROPERTY_PlayerScore, 0x48784000, 0xd219, 0x11d0, 0xba, 0x39, 0x0, 0xc0, 0x4f, 0xd7, 0xed, 0x67);
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* LOBBY structures associated with GUID messages
|
||||
*/
|
||||
|
||||
typedef struct tagDPLDATA_PLAYERGUID
|
||||
{
|
||||
GUID guidPlayer;
|
||||
DWORD dwPlayerFlags;
|
||||
} DPLDATA_PLAYERGUID, *LPDPLDATA_PLAYERGUID;
|
||||
|
||||
typedef struct tagDPLDATA_PLAYERSCORE
|
||||
{
|
||||
DWORD dwScoreCount;
|
||||
LONG Score[1];
|
||||
} DPLDATA_PLAYERSCORE, *LPDPLDATA_PLAYERSCORE;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* LOBBY messages and message data structures.
|
||||
*
|
||||
* System messages can be identified by dwMessageFlags having a value of DPLMSG_SYSTEM
|
||||
* after a call to ReceiveLobbyMessage.
|
||||
*
|
||||
* Standard messages can be indentified by dwMessageFlags having a value of DPLMSG_STANDARD
|
||||
* after a call to ReceiveLobbyMessage.
|
||||
*/
|
||||
|
||||
/* DPLobby1 definition required for backwards compatibility */
|
||||
#define DPLMSG_SYSTEM 0x00000001
|
||||
#define DPLMSG_STANDARD 0x00000002
|
||||
#define DPLAD_SYSTEM DPLMSG_SYSTEM
|
||||
|
||||
|
||||
/* System messages - dwType field for messages */
|
||||
#define DPLSYS_CONNECTIONSETTINGSREAD 0x00000001
|
||||
#define DPLSYS_DPLAYCONNECTFAILED 0x00000002
|
||||
#define DPLSYS_DPLAYCONNECTSUCCEEDED 0x00000003
|
||||
#define DPLSYS_APPTERMINATED 0x00000004
|
||||
#define DPLSYS_SETPROPERTY 0x00000005
|
||||
#define DPLSYS_SETPROPERTYRESPONSE 0x00000006
|
||||
#define DPLSYS_GETPROPERTY 0x00000007
|
||||
#define DPLSYS_GETPROPERTYRESPONSE 0x00000008
|
||||
#define DPLSYS_NEWSESSIONHOST 0x00000009
|
||||
#define DPLSYS_NEWCONNECTIONSETTINGS 0x0000000A
|
||||
|
||||
|
||||
|
||||
/* Used to indentify the message type */
|
||||
typedef struct tagDPLMSG_GENERIC
|
||||
{
|
||||
DWORD dwType; /* Message type */
|
||||
} DPLMSG_GENERIC, *LPDPLMSG_GENERIC;
|
||||
|
||||
/* Generic format for system messages - see above */
|
||||
typedef struct tagDPLMSG_SYSTEMMESSAGE
|
||||
{
|
||||
DWORD dwType; /* Message type */
|
||||
GUID guidInstance; /* Instance GUID of the dplay session the message corresponds to */
|
||||
} DPLMSG_SYSTEMMESSAGE, *LPDPLMSG_SYSTEMMESSAGE;
|
||||
|
||||
/* Generic message to set a property - see property GUIDs above */
|
||||
typedef struct tagDPLMSG_SETPROPERTY
|
||||
{
|
||||
DWORD dwType; /* Message type */
|
||||
DWORD dwRequestID; /* Request ID (DPL_NOCONFIRMATION if no confirmation desired) */
|
||||
GUID guidPlayer; /* Player GUID */
|
||||
GUID guidPropertyTag; /* Property GUID */
|
||||
DWORD dwDataSize; /* Size of data */
|
||||
DWORD dwPropertyData[1]; /* Buffer containing data */
|
||||
} DPLMSG_SETPROPERTY, *LPDPLMSG_SETPROPERTY;
|
||||
|
||||
#define DPL_NOCONFIRMATION 0L
|
||||
|
||||
/* Reply to DPLMSG_SETPROPERTY */
|
||||
typedef struct tagDPLMSG_SETPROPERTYRESPONSE
|
||||
{
|
||||
DWORD dwType; /* Message type */
|
||||
DWORD dwRequestID; /* Request ID */
|
||||
GUID guidPlayer; /* Player GUID */
|
||||
GUID guidPropertyTag; /* Property GUID */
|
||||
HRESULT hr; /* Return Code */
|
||||
} DPLMSG_SETPROPERTYRESPONSE, *LPDPLMSG_SETPROPERTYRESPONSE;
|
||||
|
||||
/* Request to get the present value of a property */
|
||||
typedef struct tagDPLMSG_GETPROPERTY
|
||||
{
|
||||
DWORD dwType; /* Message type */
|
||||
DWORD dwRequestID; /* Request ID */
|
||||
GUID guidPlayer; /* Player GUID */
|
||||
GUID guidPropertyTag; /* Property GUID */
|
||||
} DPLMSG_GETPROPERTY, *LPDPLMSG_GETPROPERTY;
|
||||
|
||||
/* Response to a request to get the present value of a property */
|
||||
typedef struct tagDPLMSG_GETPROPERTYRESPONSE
|
||||
{
|
||||
DWORD dwType; /* Message type */
|
||||
DWORD dwRequestID; /* Request ID */
|
||||
GUID guidPlayer; /* Player GUID */
|
||||
GUID guidPropertyTag; /* Property GUID */
|
||||
HRESULT hr; /* Return Code */
|
||||
DWORD dwDataSize; /* Size of data */
|
||||
DWORD dwPropertyData[1]; /* Buffer containing data */
|
||||
} DPLMSG_GETPROPERTYRESPONSE, *LPDPLMSG_GETPROPERTYRESPONSE;
|
||||
|
||||
/* Standard message in response to a session host migration to a new client */
|
||||
typedef struct tagDPLMSG_NEWSESSIONHOST
|
||||
{
|
||||
DWORD dwType; /* Message type */
|
||||
GUID guidInstance; /* GUID Instance of the session */
|
||||
} DPLMSG_NEWSESSIONHOST, *LPDPLMSG_NEWSESSIONHOST;
|
||||
|
||||
/*****************************************************************************
|
||||
* DirectPlay Address ID's
|
||||
* A DirectPlay address is composed of multiple data chunks, each associated with
|
||||
* a GUID to give significance to the type of data. All chunks have an associated
|
||||
* size so that unknown chunks can be ignored for backwards compatibility!
|
||||
* EnumAddresses function is used to parse the address data chunks.
|
||||
*/
|
||||
|
||||
/* DPAID_TotalSize {1318F560-912C-11d0-9DAA-00A0C90A43CB}
|
||||
* Chunk purpose: Chunk is a DWORD containing the size of the entire DPADDRESS struct
|
||||
*/
|
||||
DEFINE_GUID(DPAID_TotalSize, 0x1318f560, 0x912c, 0x11d0, 0x9d, 0xaa, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb);
|
||||
|
||||
/* DPAID_ServiceProvider {07D916C0-E0AF-11cf-9C4E-00A0C905425E}
|
||||
* Chunk purpose: Chunk is a GUID indicated what service provider created the chunk.
|
||||
*/
|
||||
DEFINE_GUID(DPAID_ServiceProvider, 0x7d916c0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
|
||||
/* DPAID_LobbyProvider {59B95640-9667-11d0-A77D-0000F803ABFC}
|
||||
* Chunk purpose: Chunk is a GUID indicating what lobby provider created the chunk.
|
||||
*/
|
||||
DEFINE_GUID(DPAID_LobbyProvider, 0x59b95640, 0x9667, 0x11d0, 0xa7, 0x7d, 0x0, 0x0, 0xf8, 0x3, 0xab, 0xfc);
|
||||
|
||||
/* DPAID_Phone {78EC89A0-E0AF-11cf-9C4E-00A0C905425E} -- ANSI
|
||||
* DPAID_PhoneW {BA5A7A70-9DBF-11d0-9CC1-00A0C905425E} -- UNICODE
|
||||
* Chunk purpose: Chunk is a phone number in ANSI or UNICODE format
|
||||
*/
|
||||
DEFINE_GUID(DPAID_Phone, 0x78ec89a0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
DEFINE_GUID(DPAID_PhoneW, 0xba5a7a70, 0x9dbf, 0x11d0, 0x9c, 0xc1, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
|
||||
/* DPAID_Modem {F6DCC200-A2FE-11d0-9C4F-00A0C905425E} -- ANSI
|
||||
* DPAID_ModemW {01FD92E0-A2FF-11d0-9C4F-00A0C905425E} -- UNICODE
|
||||
* Chunk purpose: Chunk is a modem name registered with TAPI
|
||||
*/
|
||||
DEFINE_GUID(DPAID_Modem, 0xf6dcc200, 0xa2fe, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
DEFINE_GUID(DPAID_ModemW, 0x1fd92e0, 0xa2ff, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
|
||||
/* DPAID_INet {C4A54DA0-E0AF-11cf-9C4E-00A0C905425E} -- ANSI
|
||||
* DPAID_INetW {E63232A0-9DBF-11d0-9CC1-00A0C905425E} -- UNICODE
|
||||
* Chunk purpose: Chunk is a string containing a TCP/IP host name or IP address
|
||||
*/
|
||||
DEFINE_GUID(DPAID_INet, 0xc4a54da0, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
DEFINE_GUID(DPAID_INetW, 0xe63232a0, 0x9dbf, 0x11d0, 0x9c, 0xc1, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
|
||||
/* DPAID_INetPort {E4524541-8EA5-11d1-8A96-006097B01411}
|
||||
* Chunk purpose: Chunk is a port number used for creating TCP and UDP sockets. (WORD)
|
||||
*/
|
||||
DEFINE_GUID(DPAID_INetPort, 0xe4524541, 0x8ea5, 0x11d1, 0x8a, 0x96, 0x0, 0x60, 0x97, 0xb0, 0x14, 0x11);
|
||||
|
||||
/* DPAID_ComPort {F2F0CE00-E0AF-11cf-9C4E-00A0C905425E}
|
||||
* Chunk purpose: Chunk contains the description of a serial port.
|
||||
*/
|
||||
DEFINE_GUID(DPAID_ComPort, 0xf2f0ce00, 0xe0af, 0x11cf, 0x9c, 0x4e, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
|
||||
|
||||
|
||||
/* Header block for address data elements */
|
||||
typedef struct tagDPADDRESS
|
||||
{
|
||||
GUID guidDataType;
|
||||
DWORD dwDataSize;
|
||||
} DPADDRESS, *LPDPADDRESS;
|
||||
|
||||
|
||||
/* Used for specification of a communication port. Baud rate, stop bits and
|
||||
* parity bits can be found in winbase.h. These are flow control constants only.
|
||||
*/
|
||||
#define DPCPA_NOFLOW 0 /* no flow control */
|
||||
#define DPCPA_XONXOFFFLOW 1 /* software flow control */
|
||||
#define DPCPA_RTSFLOW 2 /* hardware flow control with RTS */
|
||||
#define DPCPA_DTRFLOW 3 /* hardware flow control with DTR */
|
||||
#define DPCPA_RTSDTRFLOW 4 /* hardware flow control with RTS and DTR */
|
||||
|
||||
typedef struct tagDPCOMPORTADDRESS
|
||||
{
|
||||
DWORD dwComPort; /* COM port to use (1-4) */
|
||||
DWORD dwBaudRate; /* baud rate (100-256k) */
|
||||
DWORD dwStopBits; /* no. stop bits (1-2) */
|
||||
DWORD dwParity; /* parity (none, odd, even, mark) */
|
||||
DWORD dwFlowControl; /* flow control (none, xon/xoff, rts, dtr) */
|
||||
} DPCOMPORTADDRESS, *LPDPCOMPORTADDRESS;
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Miscellaneous
|
||||
*/
|
||||
|
||||
typedef struct tagDPLAPPINFO
|
||||
{
|
||||
DWORD dwSize;
|
||||
GUID guidApplication;
|
||||
|
||||
union
|
||||
{
|
||||
LPSTR lpszAppNameA;
|
||||
LPWSTR lpszAppName;
|
||||
} DUMMYUNIONNAME;
|
||||
|
||||
} DPLAPPINFO, *LPDPLAPPINFO;
|
||||
typedef const DPLAPPINFO *LPCDPLAPPINFO;
|
||||
|
||||
typedef struct DPCOMPOUNDADDRESSELEMENT
|
||||
{
|
||||
GUID guidDataType;
|
||||
DWORD dwDataSize;
|
||||
LPVOID lpData;
|
||||
} DPCOMPOUNDADDRESSELEMENT, *LPDPCOMPOUNDADDRESSELEMENT;
|
||||
typedef const DPCOMPOUNDADDRESSELEMENT *LPCDPCOMPOUNDADDRESSELEMENT;
|
||||
|
||||
typedef struct tagDPAPPLICATIONDESC
|
||||
{
|
||||
DWORD dwSize;
|
||||
DWORD dwFlags;
|
||||
|
||||
union
|
||||
{
|
||||
LPSTR lpszApplicationNameA;
|
||||
LPWSTR lpszApplicationName;
|
||||
} DUMMYUNIONNAME1;
|
||||
|
||||
GUID guidApplication;
|
||||
|
||||
union
|
||||
{
|
||||
LPSTR lpszFilenameA;
|
||||
LPWSTR lpszFilename;
|
||||
} DUMMYUNIONNAME2;
|
||||
|
||||
union
|
||||
{
|
||||
LPSTR lpszCommandLineA;
|
||||
LPWSTR lpszCommandLine;
|
||||
} DUMMYUNIONNAME3;
|
||||
|
||||
union
|
||||
{
|
||||
LPSTR lpszPathA;
|
||||
LPWSTR lpszPath;
|
||||
} DUMMYUNIONNAME4;
|
||||
|
||||
union
|
||||
{
|
||||
LPSTR lpszCurrentDirectoryA;
|
||||
LPWSTR lpszCurrentDirectory;
|
||||
} DUMMYUNIONNAME5;
|
||||
|
||||
LPSTR lpszDescriptionA;
|
||||
LPWSTR lpszDescriptionW;
|
||||
|
||||
} DPAPPLICATIONDESC, *LPDPAPPLICATIONDESC;
|
||||
|
||||
|
||||
|
||||
extern HRESULT WINAPI DirectPlayLobbyCreateW(LPGUID, LPDIRECTPLAYLOBBY*, IUnknown*, LPVOID, DWORD );
|
||||
extern HRESULT WINAPI DirectPlayLobbyCreateA(LPGUID, LPDIRECTPLAYLOBBYA*, IUnknown*, LPVOID, DWORD );
|
||||
#define DirectPlayLobbyCreate WINELIB_NAME_AW(DirectPlayLobbyCreate)
|
||||
|
||||
|
||||
typedef BOOL (CALLBACK *LPDPENUMADDRESSCALLBACK)(
|
||||
REFGUID guidDataType,
|
||||
DWORD dwDataSize,
|
||||
LPCVOID lpData,
|
||||
LPVOID lpContext );
|
||||
|
||||
typedef BOOL (CALLBACK *LPDPLENUMADDRESSTYPESCALLBACK)(
|
||||
REFGUID guidDataType,
|
||||
LPVOID lpContext,
|
||||
DWORD dwFlags );
|
||||
|
||||
typedef BOOL (CALLBACK *LPDPLENUMLOCALAPPLICATIONSCALLBACK)(
|
||||
LPCDPLAPPINFO lpAppInfo,
|
||||
LPVOID lpContext,
|
||||
DWORD dwFlags );
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirectPlayLobby and IDirectPlayLobbyA interface
|
||||
*/
|
||||
#define INTERFACE IDirectPlayLobby
|
||||
DECLARE_INTERFACE_(IDirectPlayLobby,IUnknown)
|
||||
{
|
||||
/*** IUnknown methods ***/
|
||||
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
|
||||
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
|
||||
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
||||
/*** IDirectPlayLobby methods ***/
|
||||
STDMETHOD(Connect)(THIS_ DWORD, LPDIRECTPLAY2*, IUnknown*) PURE;
|
||||
STDMETHOD(CreateAddress)(THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(EnumAddress)(THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE;
|
||||
STDMETHOD(EnumAddressTypes)(THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(ReceiveLobbyMessage)(THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(RunApplication)(THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE;
|
||||
STDMETHOD(SendLobbyMessage)(THIS_ DWORD, DWORD, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE;
|
||||
STDMETHOD(SetLobbyMessageEvent)(THIS_ DWORD, DWORD, HANDLE) PURE;
|
||||
};
|
||||
#undef INTERFACE
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirectPlayLobby2 and IDirectPlayLobby2A interface
|
||||
*/
|
||||
#define INTERFACE IDirectPlayLobby2
|
||||
DECLARE_INTERFACE_(IDirectPlayLobby2,IDirectPlayLobby)
|
||||
{
|
||||
/*** IUnknown methods ***/
|
||||
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
|
||||
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
|
||||
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
||||
/*** IDirectPlayLobby methods ***/
|
||||
STDMETHOD(Connect)(THIS_ DWORD, LPDIRECTPLAY2*, IUnknown*) PURE;
|
||||
STDMETHOD(CreateAddress)(THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(EnumAddress)(THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE;
|
||||
STDMETHOD(EnumAddressTypes)(THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(ReceiveLobbyMessage)(THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(RunApplication)(THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE;
|
||||
STDMETHOD(SendLobbyMessage)(THIS_ DWORD, DWORD, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE;
|
||||
STDMETHOD(SetLobbyMessageEvent)(THIS_ DWORD, DWORD, HANDLE) PURE;
|
||||
/*** IDirectPlayLobby2 methods ***/
|
||||
STDMETHOD(CreateCompoundAddress)(THIS_ LPCDPCOMPOUNDADDRESSELEMENT, DWORD, LPVOID, LPDWORD) PURE;
|
||||
};
|
||||
#undef INTERFACE
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirectPlayLobby3 and IDirectPlayLobby3A interface
|
||||
*/
|
||||
#define INTERFACE IDirectPlayLobby3
|
||||
DECLARE_INTERFACE_(IDirectPlayLobby3,IDirectPlayLobby2)
|
||||
{
|
||||
/*** IUnknown methods ***/
|
||||
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
|
||||
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
|
||||
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
||||
/*** IDirectPlayLobby methods ***/
|
||||
STDMETHOD(Connect)(THIS_ DWORD, LPDIRECTPLAY2*, IUnknown*) PURE;
|
||||
STDMETHOD(CreateAddress)(THIS_ REFGUID, REFGUID, LPCVOID, DWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(EnumAddress)(THIS_ LPDPENUMADDRESSCALLBACK, LPCVOID, DWORD, LPVOID) PURE;
|
||||
STDMETHOD(EnumAddressTypes)(THIS_ LPDPLENUMADDRESSTYPESCALLBACK, REFGUID, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(EnumLocalApplications)(THIS_ LPDPLENUMLOCALAPPLICATIONSCALLBACK, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(GetConnectionSettings)(THIS_ DWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(ReceiveLobbyMessage)(THIS_ DWORD, DWORD, LPDWORD, LPVOID, LPDWORD) PURE;
|
||||
STDMETHOD(RunApplication)(THIS_ DWORD, LPDWORD, LPDPLCONNECTION, HANDLE) PURE;
|
||||
STDMETHOD(SendLobbyMessage)(THIS_ DWORD, DWORD, LPVOID, DWORD) PURE;
|
||||
STDMETHOD(SetConnectionSettings)(THIS_ DWORD, DWORD, LPDPLCONNECTION) PURE;
|
||||
STDMETHOD(SetLobbyMessageEvent)(THIS_ DWORD, DWORD, HANDLE) PURE;
|
||||
/*** IDirectPlayLobby2 methods ***/
|
||||
STDMETHOD(CreateCompoundAddress)(THIS_ LPCDPCOMPOUNDADDRESSELEMENT, DWORD, LPVOID, LPDWORD) PURE;
|
||||
/*** IDirectPlayLobby3 methods ***/
|
||||
STDMETHOD(ConnectEx)(THIS_ DWORD, REFIID, LPVOID *, IUnknown *) PURE;
|
||||
STDMETHOD(RegisterApplication)(THIS_ DWORD, LPDPAPPLICATIONDESC) PURE;
|
||||
STDMETHOD(UnregisterApplication)(THIS_ DWORD, REFGUID) PURE;
|
||||
STDMETHOD(WaitForConnectionSettings)(THIS_ DWORD) PURE;
|
||||
};
|
||||
#undef INTERFACE
|
||||
|
||||
#if !defined(__cplusplus) || defined(CINTERFACE)
|
||||
/*** IUnknown methods ***/
|
||||
#define IDirectPlayLobby_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
|
||||
#define IDirectPlayLobby_AddRef(p) (p)->lpVtbl->AddRef(p)
|
||||
#define IDirectPlayLobby_Release(p) (p)->lpVtbl->Release(p)
|
||||
/*** IDirectPlayLobby methods ***/
|
||||
#define IDirectPlayLobby_Connect(p,a,b,c) (p)->lpVtbl->Connect(p,a,b,c)
|
||||
#define IDirectPlayLobby_CreateAddress(p,a,b,c,d,e,f) (p)->lpVtbl->CreateAddress(p,a,b,c,d,e,f)
|
||||
#define IDirectPlayLobby_EnumAddress(p,a,b,c,d) (p)->lpVtbl->EnumAddress(p,a,b,c,d)
|
||||
#define IDirectPlayLobby_EnumAddressTypes(p,a,b,c,d) (p)->lpVtbl->EnumAddressTypes(p,a,b,c,d)
|
||||
#define IDirectPlayLobby_EnumLocalApplications(p,a,b,c) (p)->lpVtbl->EnumLocalApplications(p,a,b,c)
|
||||
#define IDirectPlayLobby_GetConnectionSettings(p,a,b,c) (p)->lpVtbl->GetConnectionSettings(p,a,b,c)
|
||||
#define IDirectPlayLobby_ReceiveLobbyMessage(p,a,b,c,d,e) (p)->lpVtbl->ReceiveLobbyMessage(p,a,b,c,d,e)
|
||||
#define IDirectPlayLobby_RunApplication(p,a,b,c,d) (p)->lpVtbl->RunApplication(p,a,b,c,d)
|
||||
#define IDirectPlayLobby_SendLobbyMessage(p,a,b,c,d) (p)->lpVtbl->SendLobbyMessage(p,a,b,c,d)
|
||||
#define IDirectPlayLobby_SetConnectionSettings(p,a,b,c) (p)->lpVtbl->SetConnectionSettings(p,a,b,c)
|
||||
#define IDirectPlayLobby_SetLobbyMessageEvent(p,a,b,c) (p)->lpVtbl->SetLobbyMessageEvent(p,a,b,c)
|
||||
/*** IDirectPlayLobby2 methods ***/
|
||||
#define IDirectPlayLobby_CreateCompoundAddress(p,a,b,c,d) (p)->lpVtbl->CreateCompoundAddress(p,a,b,c,d)
|
||||
/*** IDirectPlayLobby3 methods ***/
|
||||
#define IDirectPlayLobby_ConnectEx(p,a,b,c,d) (p)->lpVtbl->ConnectEx(p,a,b,c,d)
|
||||
#define IDirectPlayLobby_RegisterApplication(p,a,b) (p)->lpVtbl->RegisterApplication(p,a,b)
|
||||
#define IDirectPlayLobby_UnregisterApplication(p,a,b) (p)->lpVtbl->UnregisterApplication(p,a,b)
|
||||
#define IDirectPlayLobby_WaitForConnectionSettings(p,a) (p)->lpVtbl->WaitForConnectionSettings(p,a)
|
||||
#else
|
||||
/*** IUnknown methods ***/
|
||||
#define IDirectPlayLobby_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
|
||||
#define IDirectPlayLobby_AddRef(p) (p)->AddRef()
|
||||
#define IDirectPlayLobby_Release(p) (p)->Release()
|
||||
/*** IDirectPlayLobby methods ***/
|
||||
#define IDirectPlayLobby_Connect(p,a,b,c) (p)->Connect(a,b,c)
|
||||
#define IDirectPlayLobby_CreateAddress(p,a,b,c,d,e,f) (p)->CreateAddress(a,b,c,d,e,f)
|
||||
#define IDirectPlayLobby_EnumAddress(p,a,b,c,d) (p)->EnumAddress(a,b,c,d)
|
||||
#define IDirectPlayLobby_EnumAddressTypes(p,a,b,c,d) (p)->EnumAddressTypes(a,b,c,d)
|
||||
#define IDirectPlayLobby_EnumLocalApplications(p,a,b,c) (p)->EnumLocalApplications(a,b,c)
|
||||
#define IDirectPlayLobby_GetConnectionSettings(p,a,b,c) (p)->GetConnectionSettings(a,b,c)
|
||||
#define IDirectPlayLobby_ReceiveLobbyMessage(p,a,b,c,d,e) (p)->ReceiveLobbyMessage(a,b,c,d,e)
|
||||
#define IDirectPlayLobby_RunApplication(p,a,b,c,d) (p)->RunApplication(a,b,c,d)
|
||||
#define IDirectPlayLobby_SendLobbyMessage(p,a,b,c,d) (p)->SendLobbyMessage(a,b,c,d)
|
||||
#define IDirectPlayLobby_SetConnectionSettings(p,a,b,c) (p)->SetConnectionSettings(a,b,c)
|
||||
#define IDirectPlayLobby_SetLobbyMessageEvent(p,a,b,c) (p)->SetLobbyMessageEvent(a,b,c)
|
||||
/*** IDirectPlayLobby2 methods ***/
|
||||
#define IDirectPlayLobby_CreateCompoundAddress(p,a,b,c,d) (p)->CreateCompoundAddress(a,b,c,d)
|
||||
/*** IDirectPlayLobby3 methods ***/
|
||||
#define IDirectPlayLobby_ConnectEx(p,a,b,c,d) (p)->ConnectEx(a,b,c,d)
|
||||
#define IDirectPlayLobby_RegisterApplication(p,a,b) (p)->RegisterApplication(a,b)
|
||||
#define IDirectPlayLobby_UnregisterApplication(p,a,b) (p)->UnregisterApplication(a,b)
|
||||
#define IDirectPlayLobby_WaitForConnectionSettings(p,a) (p)->WaitForConnectionSettings(a)
|
||||
#endif
|
||||
|
||||
/* Used for WaitForConnectionSettings */
|
||||
#define DPLWAIT_CANCEL 0x00000001
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* defined(__cplusplus) */
|
||||
|
||||
#endif /* __WINE_DPLOBBY_H */
|
501
src/directplay.c
Normal file
501
src/directplay.c
Normal file
@ -0,0 +1,501 @@
|
||||
/* ipxwrapper - DirectPlay service provider
|
||||
* Copyright (C) 2011 Daniel Collins <solemnwarning@solemnwarning.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program 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 General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/* TODO: ASYNC I/O!! */
|
||||
|
||||
#include <windows.h>
|
||||
#include <dplaysp.h>
|
||||
#include <winsock2.h>
|
||||
#include <wsipx.h>
|
||||
|
||||
#include "ipxwrapper.h"
|
||||
|
||||
struct sp_data {
|
||||
SOCKET sock;
|
||||
struct sockaddr_ipx addr;
|
||||
|
||||
struct sockaddr_ipx ns_addr; /* sa_family is 0 when undefined */
|
||||
|
||||
HANDLE worker_thread;
|
||||
DWORD worker_tid;
|
||||
};
|
||||
|
||||
struct sp_data_cont {
|
||||
struct sp_data *data;
|
||||
HANDLE mutex;
|
||||
};
|
||||
|
||||
const GUID IPX_GUID = {
|
||||
0x685BC400,
|
||||
0x9D2C,
|
||||
0x11CF,
|
||||
{0xA9, 0xCD, 0x00, 0xAA, 0x00, 0x68, 0x86, 0xE3}
|
||||
};
|
||||
|
||||
#define DIRECTPLAY_SOCKET 9001
|
||||
|
||||
#define API_HEADER_SIZE sizeof(struct sockaddr_ipx)
|
||||
|
||||
/* Lock the object mutex and return the data pointer */
|
||||
static struct sp_data *get_sp_data(IDirectPlaySP *sp) {
|
||||
struct sp_data_cont *cont;
|
||||
DWORD size;
|
||||
|
||||
HRESULT r = IDirectPlaySP_GetSPData(sp, (void**)&cont, &size, DPGET_LOCAL);
|
||||
//log_printf("GetSPData: %d", r);
|
||||
|
||||
WaitForSingleObject(cont->mutex, INFINITE);
|
||||
|
||||
return cont->data;
|
||||
}
|
||||
|
||||
/* Release the object mutex */
|
||||
static void release_sp_data(IDirectPlaySP *sp) {
|
||||
struct sp_data_cont *cont;
|
||||
DWORD size;
|
||||
|
||||
HRESULT r = IDirectPlaySP_GetSPData(sp, (void**)&cont, &size, DPGET_LOCAL);
|
||||
//log_printf("GetSPData: %d", r);
|
||||
|
||||
ReleaseMutex(cont->mutex);
|
||||
}
|
||||
|
||||
static DWORD WINAPI worker_main(LPVOID arg) {
|
||||
struct sp_data *sp_data = get_sp_data((IDirectPlaySP*)arg);
|
||||
|
||||
int sockfd = sp_data->sock;
|
||||
|
||||
release_sp_data((IDirectPlaySP*)arg);
|
||||
|
||||
char *buf = malloc(PACKET_BUF_SIZE);
|
||||
if(!buf) {
|
||||
abort();
|
||||
}
|
||||
|
||||
while(1) {
|
||||
struct sockaddr_ipx addr;
|
||||
int addrlen = sizeof(addr);
|
||||
|
||||
int r = recvfrom(sockfd, buf, PACKET_BUF_SIZE, 0, (struct sockaddr*)&addr, &addrlen);
|
||||
if(r == -1) {
|
||||
log_printf("recv failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT h = IDirectPlaySP_HandleMessage((IDirectPlaySP*)arg, buf, r, &addr);
|
||||
if(h != DP_OK) {
|
||||
log_printf("HandleMessage error: %d", (int)h);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL init_worker(IDirectPlaySP *sp) {
|
||||
struct sp_data *sp_data = get_sp_data(sp);
|
||||
|
||||
if(sp_data->worker_thread) {
|
||||
release_sp_data(sp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
sp_data->worker_thread = CreateThread(NULL, 0, &worker_main, sp, 0, &(sp_data->worker_tid));
|
||||
if(!sp_data->worker_thread) {
|
||||
log_printf("Failed to create worker thread");
|
||||
|
||||
release_sp_data(sp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
release_sp_data(sp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_EnumSessions(LPDPSP_ENUMSESSIONSDATA data) {
|
||||
//log_printf("IPX_EnumSessions called");
|
||||
|
||||
if(!init_worker(data->lpISP)) {
|
||||
return DPERR_GENERIC;
|
||||
}
|
||||
|
||||
struct sp_data *sp_data = get_sp_data(data->lpISP);
|
||||
|
||||
struct sockaddr_ipx addr;
|
||||
|
||||
memcpy(&addr, &(sp_data->addr), sizeof(addr));
|
||||
|
||||
memset(addr.sa_nodenum, 0xFF, 6);
|
||||
addr.sa_socket = htons(DIRECTPLAY_SOCKET);
|
||||
|
||||
if(sendto(sp_data->sock, data->lpMessage + API_HEADER_SIZE, data->dwMessageSize - API_HEADER_SIZE, 0, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||
log_printf("sendto failed: %s", w32_error(WSAGetLastError()));
|
||||
|
||||
release_sp_data(data->lpISP);
|
||||
return DPERR_GENERIC;
|
||||
}
|
||||
|
||||
release_sp_data(data->lpISP);
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_Send(LPDPSP_SENDDATA data) {
|
||||
//log_printf("IPX_Send called");
|
||||
|
||||
struct sockaddr_ipx addr_buf, *addr = NULL;
|
||||
|
||||
struct sp_data *sp_data = get_sp_data(data->lpISP);
|
||||
|
||||
if(data->idPlayerTo) {
|
||||
DWORD size;
|
||||
|
||||
HRESULT r = IDirectPlaySP_GetSPPlayerData(data->lpISP, data->idPlayerTo, (void**)&addr, &size, DPGET_LOCAL);
|
||||
if(r != DP_OK) {
|
||||
addr = NULL;
|
||||
//log_printf("GetSPPlayerData: %d", r);
|
||||
}
|
||||
}else if(sp_data->ns_addr.sa_family) {
|
||||
addr = &(sp_data->ns_addr);
|
||||
}
|
||||
|
||||
if(!addr) {
|
||||
log_printf("No known address for player ID %u, falling back to broadcast", data->idPlayerTo);
|
||||
|
||||
addr = &addr_buf;
|
||||
|
||||
memcpy(addr, &(sp_data->addr), sizeof(addr_buf));
|
||||
|
||||
memset(addr->sa_nodenum, 0xFF, 6);
|
||||
addr->sa_socket = htons(DIRECTPLAY_SOCKET);
|
||||
}
|
||||
|
||||
if(sendto(sp_data->sock, data->lpMessage + API_HEADER_SIZE, data->dwMessageSize - API_HEADER_SIZE, 0, (struct sockaddr*)addr, sizeof(*addr)) == -1) {
|
||||
log_printf("sendto failed: %s", w32_error(WSAGetLastError()));
|
||||
|
||||
release_sp_data(data->lpISP);
|
||||
return DPERR_GENERIC;
|
||||
}
|
||||
|
||||
release_sp_data(data->lpISP);
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_SendEx(LPDPSP_SENDEXDATA data) {
|
||||
//log_printf("IPX_SendEx called");
|
||||
|
||||
DPSP_SENDDATA s_data;
|
||||
|
||||
char *buf = malloc(data->dwMessageSize);
|
||||
size_t off = 0, i;
|
||||
|
||||
for(i = 0; i < data->cBuffers; i++) {
|
||||
if(off + data->lpSendBuffers[i].len > data->dwMessageSize) {
|
||||
log_printf("dwMessageSize too small, aborting");
|
||||
return DPERR_GENERIC;
|
||||
}
|
||||
|
||||
memcpy(buf + off, data->lpSendBuffers[i].pData, data->lpSendBuffers[i].len);
|
||||
off += data->lpSendBuffers[i].len;
|
||||
}
|
||||
|
||||
s_data.dwFlags = data->dwFlags;
|
||||
s_data.idPlayerTo = data->idPlayerTo;
|
||||
s_data.idPlayerFrom = data->idPlayerFrom;
|
||||
s_data.lpMessage = buf;
|
||||
s_data.dwMessageSize = data->dwMessageSize;
|
||||
s_data.bSystemMessage = data->bSystemMessage;
|
||||
s_data.lpISP = data->lpISP;
|
||||
|
||||
HRESULT ret = IPX_Send(&s_data);
|
||||
|
||||
free(buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_Reply(LPDPSP_REPLYDATA data) {
|
||||
//log_printf("IPX_Reply called (idNameServer = %u)", data->idNameServer);
|
||||
|
||||
/* TODO: Only update ns_addr if idNameServer has changed? */
|
||||
|
||||
struct sockaddr_ipx *addr_p;
|
||||
struct sp_data *sp_data = get_sp_data(data->lpISP);
|
||||
DWORD size;
|
||||
|
||||
HRESULT r = IDirectPlaySP_GetSPPlayerData(data->lpISP, data->idNameServer, (void**)&addr_p, &size, DPGET_LOCAL);
|
||||
//log_printf("GetSPPlayerData: %d", r);
|
||||
|
||||
if(r == DP_OK && addr_p) {
|
||||
memcpy(&(sp_data->ns_addr), addr_p, sizeof(struct sockaddr_ipx));
|
||||
}
|
||||
|
||||
/* Do the actual sending */
|
||||
|
||||
if(sendto(sp_data->sock, data->lpMessage + API_HEADER_SIZE, data->dwMessageSize - API_HEADER_SIZE, 0, (struct sockaddr*)data->lpSPMessageHeader, sizeof(struct sockaddr_ipx)) == -1) {
|
||||
log_printf("sendto failed: %s", w32_error(WSAGetLastError()));
|
||||
|
||||
release_sp_data(data->lpISP);
|
||||
return DPERR_GENERIC;
|
||||
}
|
||||
|
||||
release_sp_data(data->lpISP);
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_CreatePlayer(LPDPSP_CREATEPLAYERDATA data) {
|
||||
//log_printf("IPX_CreatePlayer called (player = %u, flags = %u, header = %p)", data->idPlayer, data->dwFlags, data->lpSPMessageHeader);
|
||||
|
||||
if(data->lpSPMessageHeader) {
|
||||
HRESULT r = IDirectPlaySP_SetSPPlayerData(data->lpISP, data->idPlayer, data->lpSPMessageHeader, sizeof(struct sockaddr_ipx), DPSET_LOCAL);
|
||||
//log_printf("SetSPPlayerData: %d", r);
|
||||
}
|
||||
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_DeletePlayer(LPDPSP_DELETEPLAYERDATA data) {
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_GetCaps(LPDPSP_GETCAPSDATA data) {
|
||||
//log_printf("IPX_GetCaps called");
|
||||
|
||||
if(data->lpCaps->dwSize < sizeof(DPCAPS)) {
|
||||
/* It's either this or DPERR_INVALIDOBJECT according to DirectX 7.0 */
|
||||
return DPERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
/* Most values are incorrect/inaccurate, copied from the MS implementation
|
||||
* for compatibility.
|
||||
*/
|
||||
|
||||
data->lpCaps->dwFlags = 0;
|
||||
data->lpCaps->dwMaxBufferSize = 1024;
|
||||
data->lpCaps->dwMaxQueueSize = 0;
|
||||
data->lpCaps->dwMaxPlayers = 65536;
|
||||
data->lpCaps->dwHundredBaud = 0;
|
||||
data->lpCaps->dwLatency = 50;
|
||||
data->lpCaps->dwMaxLocalPlayers = 65536;
|
||||
data->lpCaps->dwHeaderLength = API_HEADER_SIZE;
|
||||
data->lpCaps->dwTimeout = 500;
|
||||
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_Open(LPDPSP_OPENDATA data) {
|
||||
//log_printf("IPX_Open called");
|
||||
|
||||
if(!init_worker(data->lpISP)) {
|
||||
return DPERR_GENERIC;
|
||||
}
|
||||
|
||||
struct sp_data *sp_data = get_sp_data(data->lpISP);
|
||||
|
||||
if(data->bCreate) {
|
||||
struct sockaddr_ipx addr;
|
||||
|
||||
memcpy(&addr, &(sp_data->addr), sizeof(addr));
|
||||
addr.sa_socket = htons(DIRECTPLAY_SOCKET);
|
||||
|
||||
if(ipx_ex_bind(sp_data->sock, &addr) == -1) {
|
||||
release_sp_data(data->lpISP);
|
||||
return DPERR_CANNOTCREATESERVER;
|
||||
}
|
||||
}else if(data->lpSPMessageHeader) {
|
||||
memcpy(&(sp_data->ns_addr), data->lpSPMessageHeader, sizeof(struct sockaddr_ipx));
|
||||
}
|
||||
|
||||
release_sp_data(data->lpISP);
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_CloseEx(LPDPSP_CLOSEDATA data) {
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IPX_ShutdownEx(LPDPSP_SHUTDOWNDATA data) {
|
||||
struct sp_data *sp_data = get_sp_data(data->lpISP);
|
||||
|
||||
if(sp_data->worker_thread && GetCurrentThreadId() != sp_data->worker_tid) {
|
||||
TerminateThread(sp_data->worker_thread, 0);
|
||||
sp_data->worker_thread = NULL;
|
||||
}
|
||||
|
||||
closesocket(sp_data->sock);
|
||||
|
||||
release_sp_data(data->lpISP);
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI r_SPInit(LPSPINITDATA);
|
||||
|
||||
HRESULT WINAPI SPInit(LPSPINITDATA data) {
|
||||
if(!IsEqualGUID(data->lpGuid, &IPX_GUID)) {
|
||||
return r_SPInit(data);
|
||||
}
|
||||
|
||||
log_printf("SPInit: %p", data->lpISP);
|
||||
|
||||
{
|
||||
struct sp_data_cont *cont;
|
||||
DWORD size;
|
||||
|
||||
HRESULT r = IDirectPlaySP_GetSPData(data->lpISP, (void**)&cont, &size, DPGET_LOCAL);
|
||||
if(r != DP_OK) {
|
||||
log_printf("SPInit: GetSPData: %d", r);
|
||||
return DPERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
if(cont) {
|
||||
log_printf("SPInit: Already initialised, returning DP_OK");
|
||||
return DP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
struct sp_data *sp_data = malloc(sizeof(struct sp_data));
|
||||
if(!sp_data) {
|
||||
return DPERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
HANDLE mutex = CreateMutex(NULL, FALSE, NULL);
|
||||
if(!mutex) {
|
||||
free(sp_data);
|
||||
return DPERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
if((sp_data->sock = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == -1) {
|
||||
CloseHandle(mutex);
|
||||
free(sp_data);
|
||||
|
||||
return DPERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
struct sockaddr_ipx addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sa_family = AF_IPX;
|
||||
addr.sa_socket = 0;
|
||||
|
||||
if(bind(sp_data->sock, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||
closesocket(sp_data->sock);
|
||||
CloseHandle(mutex);
|
||||
free(sp_data);
|
||||
|
||||
return DPERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
int addrlen = sizeof(sp_data->addr);
|
||||
|
||||
if(getsockname(sp_data->sock, (struct sockaddr*)&(sp_data->addr), &addrlen) == -1) {
|
||||
log_printf("getsockname failed: %s", w32_error(WSAGetLastError()));
|
||||
|
||||
closesocket(sp_data->sock);
|
||||
CloseHandle(mutex);
|
||||
free(sp_data);
|
||||
|
||||
return DPERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
sp_data->ns_addr.sa_family = 0;
|
||||
sp_data->worker_thread = NULL;
|
||||
|
||||
BOOL bcast = TRUE;
|
||||
setsockopt(sp_data->sock, SOL_SOCKET, SO_BROADCAST, (char*)&bcast, sizeof(BOOL));
|
||||
|
||||
struct sp_data_cont cont;
|
||||
cont.data = sp_data;
|
||||
cont.mutex = mutex;
|
||||
|
||||
HRESULT r = IDirectPlaySP_SetSPData(data->lpISP, &cont, sizeof(cont), DPSET_LOCAL);
|
||||
//log_printf("SetSPData: %d", r);
|
||||
|
||||
data->lpCB->EnumSessions = &IPX_EnumSessions;
|
||||
data->lpCB->Send = &IPX_Send;
|
||||
data->lpCB->SendEx = &IPX_SendEx;
|
||||
data->lpCB->Reply = &IPX_Reply;
|
||||
data->lpCB->CreatePlayer = &IPX_CreatePlayer;
|
||||
data->lpCB->DeletePlayer = &IPX_DeletePlayer;
|
||||
data->lpCB->GetCaps = &IPX_GetCaps;
|
||||
data->lpCB->Open = &IPX_Open;
|
||||
data->lpCB->CloseEx = &IPX_CloseEx;
|
||||
data->lpCB->ShutdownEx = &IPX_ShutdownEx;
|
||||
|
||||
data->dwSPHeaderSize = API_HEADER_SIZE;
|
||||
data->dwSPVersion = DPSP_MAJORVERSIONMASK & DPSP_MAJORVERSION;
|
||||
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
/* Convert a windows error number to an error message */
|
||||
char const *w32_error(DWORD errnum) {
|
||||
static char buf[1024] = {'\0'};
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errnum, 0, buf, 1023, NULL);
|
||||
buf[strcspn(buf, "\r\n")] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
extern char const *dllname;
|
||||
unsigned char log_calls = 0;
|
||||
static HMODULE sysdll = NULL;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) {
|
||||
if(why == DLL_PROCESS_ATTACH) {
|
||||
log_open();
|
||||
|
||||
HKEY key;
|
||||
|
||||
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\IPXWrapper", 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) {
|
||||
DWORD size = 1;
|
||||
|
||||
if(RegQueryValueEx(key, "log_calls", NULL, NULL, (BYTE*)&log_calls, &size) != ERROR_SUCCESS || size != 1) {
|
||||
log_calls = 0;
|
||||
}
|
||||
|
||||
RegCloseKey(key);
|
||||
}
|
||||
}else if(why == DLL_PROCESS_DETACH) {
|
||||
if(sysdll) {
|
||||
FreeLibrary(sysdll);
|
||||
sysdll = NULL;
|
||||
}
|
||||
|
||||
log_close();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void __stdcall *find_sym(char const *symbol) {
|
||||
if(!sysdll) {
|
||||
char sysdir[1024], path[1024];
|
||||
|
||||
GetSystemDirectory(sysdir, 1024);
|
||||
snprintf(path, 1024, "%s\\%s", sysdir, dllname);
|
||||
|
||||
if(!(sysdll = LoadLibrary(path))) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void *ptr = GetProcAddress(sysdll, symbol);
|
||||
|
||||
if(!ptr) {
|
||||
log_printf("Missing symbol in %s: %s", dllname, symbol);
|
||||
abort();
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
5
src/dpwsockx.def
Normal file
5
src/dpwsockx.def
Normal file
@ -0,0 +1,5 @@
|
||||
LIBRARY DPWSOCKX.dll
|
||||
EXPORTS
|
||||
SPInit @1
|
||||
DPWS_GetEnumPort @3
|
||||
DPWS_BuildIPMessageHeader @4
|
3
src/dpwsockx_stubs.txt
Normal file
3
src/dpwsockx_stubs.txt
Normal file
@ -0,0 +1,3 @@
|
||||
r_SPInit
|
||||
DPWS_GetEnumPort
|
||||
DPWS_BuildIPMessageHeader
|
@ -332,25 +332,37 @@ static DWORD WINAPI router_main(LPVOID notused) {
|
||||
|
||||
for(sockptr = sockets; sockptr; sockptr = sockptr->next) {
|
||||
if(
|
||||
sockptr->flags & IPX_BOUND &&
|
||||
sockptr->flags & IPX_RECV &&
|
||||
packet->dest_socket == sockptr->socket &&
|
||||
(
|
||||
!(sockptr->flags & IPX_FILTER) ||
|
||||
packet->ptype == sockptr->f_ptype
|
||||
) && (
|
||||
memcmp(packet->dest_net, sockptr->nic->ipx_net, 4) == 0 ||
|
||||
) && ((
|
||||
sockptr->flags & IPX_BOUND &&
|
||||
packet->dest_socket == sockptr->socket &&
|
||||
(
|
||||
memcmp(packet->dest_net, f6, 4) == 0 &&
|
||||
(!global_conf.w95_bug || sockptr->flags & IPX_BROADCAST)
|
||||
memcmp(packet->dest_net, sockptr->nic->ipx_net, 4) == 0 ||
|
||||
(
|
||||
memcmp(packet->dest_net, f6, 4) == 0 &&
|
||||
(!global_conf.w95_bug || sockptr->flags & IPX_BROADCAST)
|
||||
)
|
||||
) && (
|
||||
memcmp(packet->dest_node, sockptr->nic->ipx_node, 6) == 0 ||
|
||||
(
|
||||
memcmp(packet->dest_node, f6, 6) == 0 &&
|
||||
(!global_conf.w95_bug || sockptr->flags & IPX_BROADCAST)
|
||||
)
|
||||
)
|
||||
) && (
|
||||
memcmp(packet->dest_node, sockptr->nic->ipx_node, 6) == 0 ||
|
||||
) || (
|
||||
sockptr->flags & IPX_EX_BOUND &&
|
||||
packet->dest_socket == sockptr->ex_socket &&
|
||||
(
|
||||
memcmp(packet->dest_node, f6, 6) == 0 &&
|
||||
(!global_conf.w95_bug || sockptr->flags & IPX_BROADCAST)
|
||||
memcmp(packet->dest_net, sockptr->ex_nic->ipx_net, 4) == 0 ||
|
||||
memcmp(packet->dest_net, f6, 4) == 0
|
||||
) && (
|
||||
memcmp(packet->dest_node, sockptr->ex_nic->ipx_node, 6) == 0 ||
|
||||
memcmp(packet->dest_node, f6, 6) == 0
|
||||
)
|
||||
)
|
||||
))
|
||||
) {
|
||||
addrlen = sizeof(addr);
|
||||
if(r_getsockname(sockptr->fd, (struct sockaddr*)&addr, &addrlen) == -1) {
|
||||
|
@ -14,3 +14,4 @@ EXPORTS
|
||||
EnumProtocolsW
|
||||
WSARecvEx
|
||||
ioctlsocket
|
||||
ipx_ex_bind
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <wsipx.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -36,6 +37,7 @@
|
||||
#define IPX_BROADCAST (int)(1<<2)
|
||||
#define IPX_SEND (int)(1<<3)
|
||||
#define IPX_RECV (int)(1<<4)
|
||||
#define IPX_EX_BOUND (int)(1<<5)
|
||||
|
||||
#define RETURN(...) \
|
||||
unlock_mutex();\
|
||||
@ -87,6 +89,12 @@ struct ipx_socket {
|
||||
ipx_nic *nic;
|
||||
uint16_t socket; /* Stored in NETWORK BYTE ORDER */
|
||||
|
||||
/* Extra bind address, only used for receiving packets.
|
||||
* Only defined when IPX_EX_BOUND is set.
|
||||
*/
|
||||
ipx_nic *ex_nic;
|
||||
uint16_t ex_socket;
|
||||
|
||||
ipx_socket *next;
|
||||
};
|
||||
|
||||
@ -150,6 +158,8 @@ void log_open();
|
||||
void log_close();
|
||||
void log_printf(const char *fmt, ...);
|
||||
|
||||
int ipx_ex_bind(SOCKET fd, const struct sockaddr_ipx *ipxaddr);
|
||||
|
||||
INT APIENTRY r_EnumProtocolsA(LPINT,LPVOID,LPDWORD);
|
||||
INT APIENTRY r_EnumProtocolsW(LPINT,LPVOID,LPDWORD);
|
||||
int PASCAL FAR r_WSARecvEx(SOCKET,char*,int,int*);
|
||||
|
@ -320,6 +320,63 @@ int WSAAPI bind(SOCKET fd, const struct sockaddr *addr, int addrlen) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Bind extra address of a socket, does not check if address is already in use
|
||||
* Attempts to bind socket 0 will really bind socket 0
|
||||
*/
|
||||
int ipx_ex_bind(SOCKET fd, const struct sockaddr_ipx *ipxaddr) {
|
||||
ipx_socket *ptr = get_socket(fd);
|
||||
|
||||
if(!ipxaddr) {
|
||||
/* Call with NULL address to remove extra bind */
|
||||
log_printf("ipx_ex_bind(%d, NULL)", fd);
|
||||
|
||||
ptr->flags &= ~IPX_EX_BOUND;
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
char net_s[12], node_s[18];
|
||||
|
||||
NET_TO_STRING(net_s, ipxaddr->sa_netnum);
|
||||
NODE_TO_STRING(node_s, ipxaddr->sa_nodenum);
|
||||
|
||||
log_printf("ipx_ex_bind(%d, net=%s node=%s socket=%hu)", fd, net_s, node_s, ntohs(ipxaddr->sa_socket));
|
||||
|
||||
if(!(ptr->flags & IPX_BOUND)) {
|
||||
log_printf("ipx_ex_bind: Socket is not bound");
|
||||
RETURN_WSA(WSAEINVAL, -1);
|
||||
}
|
||||
|
||||
unsigned char z6[] = {0,0,0,0,0,0};
|
||||
ipx_nic *nic = nics;
|
||||
|
||||
while(nic) {
|
||||
if(
|
||||
(memcmp(ipxaddr->sa_netnum, nic->ipx_net, 4) == 0 || memcmp(ipxaddr->sa_netnum, z6, 4) == 0) &&
|
||||
(memcmp(ipxaddr->sa_nodenum, nic->ipx_node, 6) == 0 || memcmp(ipxaddr->sa_nodenum, z6, 6) == 0)
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
nic = nic->next;
|
||||
}
|
||||
|
||||
if(!nic) {
|
||||
log_printf("ipx_ex_bind: no such address");
|
||||
RETURN_WSA(WSAEADDRNOTAVAIL, -1);
|
||||
}
|
||||
|
||||
NET_TO_STRING(net_s, nic->ipx_net);
|
||||
NODE_TO_STRING(node_s, nic->ipx_node);
|
||||
|
||||
log_printf("bind address: net=%s node=%s socket=%hu", net_s, node_s, ntohs(ipxaddr->sa_socket));
|
||||
|
||||
ptr->ex_nic = nic;
|
||||
ptr->ex_socket = ipxaddr->sa_socket;
|
||||
ptr->flags |= IPX_EX_BOUND;
|
||||
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
int WSAAPI getsockname(SOCKET fd, struct sockaddr *addr, int *addrlen) {
|
||||
struct sockaddr_ipx *ipxaddr = (struct sockaddr_ipx*)addr;
|
||||
ipx_socket *ptr = get_socket(fd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user