source: trunk/src/dplay/dplay.cpp@ 1036

Last change on this file since 1036 was 939, checked in by phaller, 26 years ago

Add: ported DPLAY from WINE

File size: 5.3 KB
Line 
1/* $Id: dplay.cpp,v 1.1 1999-09-15 15:38:47 phaller Exp $ */
2
3/* Direct Play 3 and Direct Play Lobby 2 Implementation
4 *
5 * Copyright (C) 1999 Patrick Haller <phaller@gmx.net>
6 *
7 */
8
9#include <odin.h>
10
11#define ICOM_CINTERFACE 1
12#define CINTERFACE
13
14
15#include "winerror.h"
16#include "winnt.h"
17#include "winreg.h"
18#include "dplay.h"
19#include "dplobby.h"
20#include "heap.h"
21#include "debugtools.h"
22
23#include <odinwrap.h>
24#include <heapstring.h>
25#include <misc.h>
26
27ODINDEBUGCHANNEL(DPLAY)
28
29
30/***************************************************************************
31 * DirectPlayEnumerateA (DPLAYX.2)
32 *
33 * The pointer to the structure lpContext will be filled with the
34 * appropriate data for each service offered by the OS. These services are
35 * not necessarily available on this particular machine but are defined
36 * as simple service providers under the "Service Providers" registry key.
37 * This structure is then passed to lpEnumCallback for each of the different
38 * services.
39 *
40 * This API is useful only for applications written using DirectX3 or
41 * worse. It is superceeded by IDirectPlay3::EnumConnections which also
42 * gives information on the actual connections.
43 *
44 * defn of a service provider:
45 * A dynamic-link library used by DirectPlay to communicate over a network.
46 * The service provider contains all the network-specific code required
47 * to send and receive messages. Online services and network operators can
48 * supply service providers to use specialized hardware, protocols, communications
49 * media, and network resources.
50 *
51 * TODO: Allocate string buffer space from the heap (length from reg)
52 * Pass real device driver numbers...
53 * Get the GUID properly...
54 */
55HRESULT WINAPI DirectPlayEnumerateA( LPDPENUMDPCALLBACKA lpEnumCallback,
56 LPVOID lpContext )
57{
58
59 HKEY hkResult;
60 LPCSTR searchSubKey = "SOFTWARE\\Microsoft\\DirectPlay\\Service Providers";
61 LPSTR guidDataSubKey = "Guid";
62 LPSTR majVerDataSubKey = "dwReserved1";
63 DWORD dwIndex, sizeOfSubKeyName=50;
64 char subKeyName[51];
65
66 TRACE(": lpEnumCallback=%p lpContext=%p\n", lpEnumCallback, lpContext );
67
68 if( !lpEnumCallback )
69 {
70 return DPERR_INVALIDPARAMS;
71 }
72
73 /* Need to loop over the service providers in the registry */
74 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
75 0, KEY_ENUMERATE_SUB_KEYS, &hkResult ) != ERROR_SUCCESS )
76 {
77 /* Hmmm. Does this mean that there are no service providers? */
78 ERR(": no service providers?\n");
79 return DP_OK;
80 }
81
82 /* Traverse all the service providers we have available */
83 for( dwIndex=0;
84 RegEnumKeyA( hkResult, dwIndex, subKeyName, sizeOfSubKeyName ) !=
85 ERROR_NO_MORE_ITEMS;
86 ++dwIndex )
87 {
88 HKEY hkServiceProvider;
89 GUID serviceProviderGUID;
90 DWORD returnTypeGUID, returnTypeReserved1, sizeOfReturnBuffer=50;
91 char returnBuffer[51];
92 DWORD majVersionNum /*, minVersionNum */;
93 LPWSTR lpWGUIDString;
94
95 TRACE(" this time through: %s\n", subKeyName );
96
97 /* Get a handle for this particular service provider */
98 if( RegOpenKeyExA( hkResult, subKeyName, 0, KEY_QUERY_VALUE,
99 &hkServiceProvider ) != ERROR_SUCCESS )
100 {
101 ERR(": what the heck is going on?\n" );
102 continue;
103 }
104
105 /* Get the GUID, Device major number and device minor number
106 * from the registry.
107 */
108 if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
109 NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
110 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
111 {
112 ERR(": missing GUID registry data members\n" );
113 continue;
114 }
115
116 /* FIXME: Check return types to ensure we're interpreting data right */
117 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
118 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
119 HeapFree( GetProcessHeap(), 0, lpWGUIDString );
120
121 sizeOfReturnBuffer = 50;
122
123 if( RegQueryValueExA( hkServiceProvider, majVerDataSubKey,
124 NULL, &returnTypeReserved1, (LPBYTE)returnBuffer,
125 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
126 {
127 ERR(": missing dwReserved1 registry data members\n") ;
128 continue;
129 }
130 /* FIXME: This couldn't possibly be right...*/
131 majVersionNum = GET_DWORD( returnBuffer );
132
133 /* The enumeration will return FALSE if we are not to continue */
134 if( !lpEnumCallback( &serviceProviderGUID , subKeyName,
135 majVersionNum, (DWORD)0, lpContext ) )
136 {
137 WARN("lpEnumCallback returning FALSE\n" );
138 break;
139 }
140 }
141
142 return DP_OK;
143
144}
145
146/***************************************************************************
147 * DirectPlayEnumerateW (DPLAYX.3)
148 *
149 */
150HRESULT WINAPI DirectPlayEnumerateW( LPDPENUMDPCALLBACKW lpEnumCallback, LPVOID lpContext )
151{
152
153 FIXME(":stub\n");
154
155 return DPERR_OUTOFMEMORY;
156
157}
158
159/***************************************************************************
160 * DirectPlayCreate (DPLAYX.1) (DPLAY.1)
161 *
162 */
163HRESULT WINAPI DirectPlayCreate
164( LPGUID lpGUID, LPDIRECTPLAY2 *lplpDP, IUnknown *pUnk)
165{
166 //@@@PH stub
167 FIXME("lpGUID=%p lplpDP=%p pUnk=%p\n", lpGUID,lplpDP,pUnk);
168
169 if( pUnk != NULL )
170 {
171 /* Hmmm...wonder what this means! */
172 ERR("What does a NULL here mean?\n" );
173 return DPERR_OUTOFMEMORY;
174 }
175
176
177 /* Unknown interface type */
178 return DPERR_NOINTERFACE;
179
180}
181
Note: See TracBrowser for help on using the repository browser.