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