ReactOS 0.4.16-dev-297-gc569aee
browser.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: NetAPI DLL
4 * FILE: dll/win32/netapi32/browser.c
5 * PURPOSE: Computer Browser service interface code
6 * PROGRAMMERS: Eric Kohl (eric.kohl@reactos.org)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include "netapi32.h"
12
13#include <rpc.h>
14#include <lmbrowsr.h>
15#include <lmserver.h>
16#include "browser_c.h"
17
18
20
21/* FUNCTIONS *****************************************************************/
22
25{
27 LPWSTR pszStringBinding;
29
30 TRACE("BROWSER_IDENTIFY_HANDLE_bind() called\n");
31
33 L"ncacn_np",
34 pszSystemName,
35 L"\\pipe\\browser",
36 NULL,
37 &pszStringBinding);
38 if (status)
39 {
40 TRACE("RpcStringBindingCompose returned 0x%x\n", status);
41 return NULL;
42 }
43
44 /* Set the binding handle that will be used to bind to the server. */
45 status = RpcBindingFromStringBindingW(pszStringBinding,
46 &hBinding);
47 if (status)
48 {
49 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
50 }
51
52 status = RpcStringFreeW(&pszStringBinding);
53 if (status)
54 {
55// TRACE("RpcStringFree returned 0x%x\n", status);
56 }
57
58 return hBinding;
59}
60
61
62void __RPC_USER
65{
67
68 TRACE("BROWSER_IDENTIFY_HANDLE_unbind() called\n");
69
71 if (status)
72 {
73 TRACE("RpcBindingFree returned 0x%x\n", status);
74 }
75}
76
77
81 _In_opt_ LPWSTR ServerName,
83{
85
86 TRACE("I_BrowserDebugTrace(%s %s)\n",
87 debugstr_w(ServerName), Buffer);
88
90 {
91 status = I_BrowserrDebugTrace(ServerName,
92 Buffer);
93 }
95 {
97 }
99
100 return status;
101}
102
103
105WINAPI
107 _In_opt_ LPWSTR ServerName,
108 _Out_ PBROWSER_EMULATED_DOMAIN *EmulatedDomains,
109 _Out_ LPDWORD EntriesRead)
110{
113
114 TRACE("I_BrowserQueryEmulatedDomains(%s %p %p)\n",
115 debugstr_w(ServerName), EmulatedDomains, EntriesRead);
116
117 *EmulatedDomains = NULL;
118 *EntriesRead = 0;
119
121 {
123 &Container);
124
125 if (status == NERR_Success)
126 {
127 *EmulatedDomains = (PBROWSER_EMULATED_DOMAIN)Container.Buffer;
128 *EntriesRead = Container.EntriesRead;
129 }
130 }
132 {
134 }
136
137 return status;
138}
139
140
142WINAPI
144 _In_opt_ LPCWSTR ServerName,
145 _Out_ LPBYTE *BufPtr,
146 _Out_ LPDWORD EntriesRead,
147 _Out_ LPDWORD TotalEntries)
148{
149 SERVER_INFO_100_CONTAINER Level100Container = {0, NULL};
150 SERVER_ENUM_STRUCT EnumStruct;
152
153 TRACE("I_BrowserQueryOtherDomains(%s %p %p %p)\n",
154 debugstr_w(ServerName), BufPtr, EntriesRead, TotalEntries);
155
156 EnumStruct.Level = 100;
157 EnumStruct.ServerInfo.Level100 = &Level100Container;
158
160 {
162 &EnumStruct,
163 TotalEntries);
164
166 {
167 *BufPtr = (LPBYTE)EnumStruct.ServerInfo.Level100->Buffer;
168 *EntriesRead = EnumStruct.ServerInfo.Level100->EntriesRead;
169 }
170 }
172 {
174 }
176
177 return status;
178}
179
180
182WINAPI
184 _In_opt_ LPCWSTR ServerName,
185 _In_opt_ LPCWSTR Transport,
186 _In_opt_ LPCWSTR ClientName,
188 _Out_ LPBYTE *BufPtr,
189 _In_ DWORD PrefMaxLen,
190 _Out_ LPDWORD EntriesRead,
191 _Out_ LPDWORD TotalEntries,
192 _In_ DWORD ServerType,
193 _In_opt_ LPCWSTR Domain,
194 _Inout_opt_ LPDWORD ResumeHandle)
195{
196 SERVER_INFO_100_CONTAINER Level100Container = {0, NULL};
197 SERVER_ENUM_STRUCT EnumStruct;
199
200 TRACE("I_BrowserServerEnum(%s %s %s %lu %p %lu %p %p %lu %s %p)\n",
201 debugstr_w(ServerName), debugstr_w(Transport), debugstr_w(ClientName),
202 Level, BufPtr, PrefMaxLen, EntriesRead, TotalEntries, ServerType,
203 debugstr_w(Domain), ResumeHandle);
204
205 EnumStruct.Level = 100;
206 EnumStruct.ServerInfo.Level100 = &Level100Container;
207
209 {
210 status = I_BrowserrServerEnum((PWSTR)ServerName,
211 (PWSTR)Transport,
212 (PWSTR)ClientName,
213 &EnumStruct,
214 PrefMaxLen,
215 TotalEntries,
216 ServerType,
217 (PWSTR)Domain,
218 ResumeHandle);
219
221 {
222 *BufPtr = (LPBYTE)EnumStruct.ServerInfo.Level100->Buffer;
223 *EntriesRead = EnumStruct.ServerInfo.Level100->EntriesRead;
224 }
225 }
227 {
229 }
231
232 return status;
233}
234
235
237WINAPI
239 _In_opt_ LPCWSTR ServerName,
240 _Inout_ LPBROWSER_STATISTICS *Statistics)
241{
243
244 TRACE("I_BrowserQueryStatistics(%s %p)\n",
245 debugstr_w(ServerName), Statistics);
246
248 {
250 Statistics);
251 }
253 {
255 }
257
258 return status;
259}
260
261
263WINAPI
265 _In_opt_ LPCWSTR ServerName)
266{
268
269 TRACE("I_BrowserResetStatistics(%s)\n",
270 debugstr_w(ServerName));
271
273 {
275 }
277 {
279 }
281
282 return status;
283}
284
285
287WINAPI
289 _In_ LPCWSTR ServerName)
290{
292
293 TRACE("I_BrowserResetNetlogonState(%s)\n",
294 debugstr_w(ServerName));
295
297 {
299 }
301 {
303 }
305
306 return status;
307}
308
309
311WINAPI
313 _In_ LPWSTR ServerName,
314 _In_ LPWSTR DomainName,
315 _In_ LPWSTR EmulatedServerName,
316 _In_ DWORD Role)
317{
319
320 TRACE("I_BrowserSetNetlogonState(%s %s %s %lu)\n",
321 debugstr_w(ServerName), debugstr_w(ServerName),
322 debugstr_w(EmulatedServerName), Role);
323
325 {
327 DomainName,
328 EmulatedServerName,
329 Role);
330 }
332 {
334 }
336
337 return status;
338}
339
340
342WINAPI
344 _In_ LPWSTR ServerName,
347{
348 BROWSER_STATISTICS_STRUCT StatisticsStruct;
349 BROWSER_STATISTICS_100_CONTAINER Level100Container = {0, NULL};
350 BROWSER_STATISTICS_101_CONTAINER Level101Container = {0, NULL};
352
353 TRACE("NetBrowserStatisticsGet(%s %lu %p)\n",
354 debugstr_w(ServerName), Level, Buffer);
355
356 if (Level != 100 && Level != 101)
357 return ERROR_INVALID_LEVEL;
358
359 StatisticsStruct.Level = Level;
360 switch (Level)
361 {
362 case 100:
363 StatisticsStruct.Statistics.Level100 = &Level100Container;
364 break;
365
366 case 101:
367 StatisticsStruct.Statistics.Level101 = &Level101Container;
368 break;
369 }
370
372 {
373 status = NetrBrowserStatisticsGet(ServerName,
374 Level,
375 &StatisticsStruct);
376
377 switch (Level)
378 {
379 case 100:
380 if (StatisticsStruct.Statistics.Level100->Buffer != NULL)
381 {
382 *Buffer = (LPBYTE)StatisticsStruct.Statistics.Level100->Buffer;
383 }
384 break;
385
386 case 101:
387 if (StatisticsStruct.Statistics.Level101->Buffer != NULL)
388 {
389 *Buffer = (LPBYTE)StatisticsStruct.Statistics.Level101->Buffer;
390 }
391 break;
392 }
393 }
395 {
397 }
399
400 return status;
401}
402
403
405WINAPI
407 _In_opt_ LMCSTR servername,
410 _In_ DWORD prefmaxlen,
411 _Out_ LPDWORD entriesread,
412 _Out_ LPDWORD totalentries,
413 _In_ DWORD servertype,
415 _Inout_opt_ LPDWORD resume_handle)
416{
417 TRACE("NetServerEnum(%s %lu %p %lu %p %p %lu %s %p)\n",
418 debugstr_w(servername), level, bufptr, prefmaxlen, entriesread,
419 totalentries, servertype, debugstr_w(domain), resume_handle);
420
421 if (resume_handle != NULL)
422 *resume_handle = 0;
423
424 return NetServerEnumEx(servername,
425 level,
426 bufptr,
427 prefmaxlen,
428 entriesread,
429 totalentries,
430 servertype,
431 domain,
432 NULL);
433}
434
435
437WINAPI
439 _In_opt_ LMCSTR ServerName,
441 _Out_ LPBYTE *Bufptr,
442 _In_ DWORD PrefMaxlen,
443 _Out_ LPDWORD EntriesRead,
444 _Out_ LPDWORD totalentries,
445 _In_ DWORD servertype,
447 _In_opt_ LMCSTR FirstNameToReturn)
448{
449 FIXME("NetServerEnumEx(%s %lu %p %lu %p %p %lu %s %s)\n",
450 debugstr_w(ServerName), Level, Bufptr, PrefMaxlen, EntriesRead, totalentries,
451 servertype, debugstr_w(domain), debugstr_w(FirstNameToReturn));
452
454}
455
456/* EOF */
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
NET_API_STATUS __stdcall I_BrowserrQueryOtherDomains(BROWSER_IDENTIFY_HANDLE ServerName, LPSERVER_ENUM_STRUCT EnumStruct, LPDWORD TotalEntries)
Definition: rpcserver.c:93
NET_API_STATUS __stdcall I_BrowserrQueryEmulatedDomains(BROWSER_IDENTIFY_HANDLE ServerName, PBROWSER_EMULATED_DOMAIN_CONTAINER EmulatedDomains)
Definition: rpcserver.c:190
NET_API_STATUS __stdcall NetrBrowserStatisticsGet(BROWSER_IDENTIFY_HANDLE ServerName, DWORD Level, LPBROWSER_STATISTICS_STRUCT StatisticsStruct)
Definition: rpcserver.c:163
NET_API_STATUS __stdcall I_BrowserrServerEnum(BROWSER_IDENTIFY_HANDLE ServerName, LPWSTR Transport, LPWSTR ClientName, LPSERVER_ENUM_STRUCT EnumStruct, DWORD PreferedMaximumLength, LPDWORD TotalEntries, DWORD ServerType, LPWSTR Domain, LPDWORD ResumeHandle)
Definition: rpcserver.c:64
NET_API_STATUS __stdcall I_BrowserrQueryStatistics(BROWSER_IDENTIFY_HANDLE ServerName, LPBROWSER_STATISTICS *Statistics)
Definition: rpcserver.c:129
NET_API_STATUS __stdcall I_BrowserrSetNetlogonState(BROWSER_IDENTIFY_HANDLE ServerName, LPWSTR DomainName, LPWSTR EmulatedComputerName, DWORD Role)
Definition: rpcserver.c:176
NET_API_STATUS __stdcall I_BrowserrDebugTrace(BROWSER_IDENTIFY_HANDLE ServerName, LPSTR String)
Definition: rpcserver.c:117
NET_API_STATUS __stdcall I_BrowserrResetNetlogonState(BROWSER_IDENTIFY_HANDLE ServerName)
Definition: rpcserver.c:106
NET_API_STATUS __stdcall I_BrowserrResetStatistics(BROWSER_IDENTIFY_HANDLE ServerName)
Definition: rpcserver.c:141
#define FIXME(fmt,...)
Definition: precomp.h:53
wchar_t * BROWSER_IDENTIFY_HANDLE
Definition: browser.idl:7
Definition: bufpool.h:45
handle_t hBinding
Definition: ctx_c.c:54
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define NULL
Definition: types.h:112
NET_API_STATUS WINAPI NetBrowserStatisticsGet(_In_ LPWSTR ServerName, _In_ DWORD Level, _Out_ LPBYTE *Buffer)
Definition: browser.c:343
NET_API_STATUS WINAPI I_BrowserDebugTrace(_In_opt_ LPWSTR ServerName, _In_ PCHAR Buffer)
Definition: browser.c:80
NET_API_STATUS WINAPI I_BrowserQueryStatistics(_In_opt_ LPCWSTR ServerName, _Inout_ LPBROWSER_STATISTICS *Statistics)
Definition: browser.c:238
NET_API_STATUS WINAPI I_BrowserQueryEmulatedDomains(_In_opt_ LPWSTR ServerName, _Out_ PBROWSER_EMULATED_DOMAIN *EmulatedDomains, _Out_ LPDWORD EntriesRead)
Definition: browser.c:106
NET_API_STATUS WINAPI I_BrowserResetStatistics(_In_opt_ LPCWSTR ServerName)
Definition: browser.c:264
NET_API_STATUS WINAPI NetServerEnumEx(_In_opt_ LMCSTR ServerName, _In_ DWORD Level, _Out_ LPBYTE *Bufptr, _In_ DWORD PrefMaxlen, _Out_ LPDWORD EntriesRead, _Out_ LPDWORD totalentries, _In_ DWORD servertype, _In_opt_ LMCSTR domain, _In_opt_ LMCSTR FirstNameToReturn)
Definition: browser.c:438
NET_API_STATUS WINAPI I_BrowserSetNetlogonState(_In_ LPWSTR ServerName, _In_ LPWSTR DomainName, _In_ LPWSTR EmulatedServerName, _In_ DWORD Role)
Definition: browser.c:312
NET_API_STATUS WINAPI NetServerEnum(_In_opt_ LMCSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _In_ DWORD servertype, _In_opt_ LMCSTR domain, _Inout_opt_ LPDWORD resume_handle)
Definition: browser.c:406
handle_t __RPC_USER BROWSER_IDENTIFY_HANDLE_bind(BROWSER_IDENTIFY_HANDLE pszSystemName)
Definition: browser.c:24
NET_API_STATUS WINAPI I_BrowserServerEnum(_In_opt_ LPCWSTR ServerName, _In_opt_ LPCWSTR Transport, _In_opt_ LPCWSTR ClientName, _In_ DWORD Level, _Out_ LPBYTE *BufPtr, _In_ DWORD PrefMaxLen, _Out_ LPDWORD EntriesRead, _Out_ LPDWORD TotalEntries, _In_ DWORD ServerType, _In_opt_ LPCWSTR Domain, _Inout_opt_ LPDWORD ResumeHandle)
Definition: browser.c:183
void __RPC_USER BROWSER_IDENTIFY_HANDLE_unbind(BROWSER_IDENTIFY_HANDLE pszSystemName, handle_t hBinding)
Definition: browser.c:63
NET_API_STATUS WINAPI I_BrowserResetNetlogonState(_In_ LPCWSTR ServerName)
Definition: browser.c:288
NET_API_STATUS WINAPI I_BrowserQueryOtherDomains(_In_opt_ LPCWSTR ServerName, _Out_ LPBYTE *BufPtr, _Out_ LPDWORD EntriesRead, _Out_ LPDWORD TotalEntries)
Definition: browser.c:143
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint level
Definition: gl.h:1546
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define debugstr_w
Definition: kernel32.h:32
struct _BROWSER_EMULATED_DOMAIN * PBROWSER_EMULATED_DOMAIN
#define NERR_Success
Definition: lmerr.h:5
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
const wchar_t * LMCSTR
Definition: ms-dtyp.idl:118
#define _Inout_
Definition: no_sal2.h:162
#define _Inout_opt_
Definition: no_sal2.h:216
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define L(x)
Definition: ntvdm.h:50
RPC_STATUS WINAPI RpcBindingFromStringBindingW(RPC_WSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:880
RPC_STATUS WINAPI RpcStringBindingComposeW(RPC_WSTR ObjUuid, RPC_WSTR Protseq, RPC_WSTR NetworkAddr, RPC_WSTR Endpoint, RPC_WSTR Options, RPC_WSTR *StringBinding)
Definition: rpc_binding.c:510
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:787
LONG WINAPI I_RpcMapWin32Status(RPC_STATUS status)
Definition: rpcrt4_main.c:740
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:175
#define RpcEndExcept
Definition: rpc.h:128
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExcept(expr)
Definition: rpc.h:127
long RPC_STATUS
Definition: rpc.h:52
#define __RPC_USER
Definition: rpc.h:65
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
PBROWSER_EMULATED_DOMAIN Buffer
Definition: browser.idl:21
PBROWSER_STATISTICS_100 Buffer
Definition: browser.idl:107
PBROWSER_STATISTICS_101 Buffer
Definition: browser.idl:113
union _BROWSER_STATISTICS_STRUCT::_BROWSER_STATISTICS_UNION Statistics
union _SERVER_ENUM_STRUCT::_SERVER_ENUM_UNION ServerInfo
LPSERVER_INFO_100 Buffer
Definition: browser.idl:35
Definition: cookie.c:42
Definition: ps.c:97
static unsigned int bufptr
Definition: tncon.cpp:77
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t * LPDWORD
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
PBROWSER_STATISTICS_100_CONTAINER Level100
Definition: browser.idl:121
PBROWSER_STATISTICS_101_CONTAINER Level101
Definition: browser.idl:122
LPSERVER_INFO_100_CONTAINER Level100
Definition: browser.idl:43
#define WINAPI
Definition: msvc.h:6
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define ERROR_NO_BROWSER_SERVERS_FOUND
Definition: winerror.h:1415
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185