ReactOS 0.4.15-dev-8127-g6338913
enumprot.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for enumprot.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL WSAAPI CheckProtocolMatch (IN LPINT ProtocolSet, IN LPWSAPROTOCOL_INFOW ProtocolInfo)
 
VOID WSAAPI ProtocolInfoFromContext (IN LPWSAPROTOCOL_INFOW ProtocolInfo, IN PPROTOCOL_ENUM_CONTEXT Context)
 
BOOL WSAAPI ProtocolEnumerationProc (PVOID EnumContext, PTCATALOG_ENTRY Entry)
 
BOOL WSAAPI ProviderEnumerationProc (PVOID EnumContext, PNSCATALOG_ENTRY Entry)
 
PTCATALOG WSAAPI OpenInitializedCatalog (VOID)
 
INT WSPAPI WSCEnumProtocols (IN LPINT lpiProtocols, OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer, IN OUT LPDWORD lpdwBufferLength, OUT LPINT lpErrno)
 
INT WSAAPI WSAEnumProtocolsA (IN LPINT lpiProtocols, OUT LPWSAPROTOCOL_INFOA lpProtocolBuffer, IN OUT LPDWORD lpdwBufferLength)
 
INT WSAAPI WSAEnumProtocolsW (IN LPINT lpiProtocols, OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer, IN OUT LPDWORD lpdwBufferLength)
 
INT WSPAPI WPUGetProviderPath (IN LPGUID lpProviderId, OUT LPWSTR lpszProviderDllPath, IN OUT LPINT lpProviderDllPathLen, OUT LPINT lpErrno)
 
INT WSAAPI WSAProviderConfigChange (IN OUT LPHANDLE lpNotificationHandle, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 
INT WSPAPI WSCGetProviderPath (IN LPGUID lpProviderId, OUT LPWSTR lpszProviderDllPath, IN OUT LPINT lpProviderDllPathLen, OUT LPINT lpErrno)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file enumprot.c.

Function Documentation

◆ CheckProtocolMatch()

BOOL WSAAPI CheckProtocolMatch ( IN LPINT  ProtocolSet,
IN LPWSAPROTOCOL_INFOW  ProtocolInfo 
)

Definition at line 21 of file enumprot.c.

23{
24 BOOL Return = FALSE;
25 DWORD i = 0;
27
28 /* Make sure we have a set */
29 if (ProtocolSet)
30 {
31 /* Get the first ID */
32 ProtocolId = ProtocolSet[i];
33
34 /* Loop the list */
35 while (ProtocolId != 0 && ProtocolInfo->iProtocol != 0)
36 {
37 /* Check if it's within ranges */
38 if ((ProtocolId >= ProtocolInfo->iProtocol) &&
39 (ProtocolId <= (ProtocolInfo->iProtocol +
40 ProtocolInfo->iProtocolMaxOffset)))
41 {
42 /* Found it */
43 Return = TRUE;
44 break;
45 }
46
47 /* Move on */
48 i++;
49 ProtocolId = ProtocolSet[i];
50 }
51 }
52 else
53 {
54 /* Assume match */
55 Return = TRUE;
56 }
57
58 /* Return result */
59 return Return;
60}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ UINT ProtocolId
Definition: ndis.h:2924
int32_t INT
Definition: typedefs.h:58

Referenced by ProtocolEnumerationProc().

◆ OpenInitializedCatalog()

PTCATALOG WSAAPI OpenInitializedCatalog ( VOID  )

Definition at line 137 of file enumprot.c.

138{
139 PTCATALOG Catalog;
140 HKEY WsKey;
141
142 /* Allocate the catalog */
143 Catalog = WsTcAllocate();
144 if (Catalog)
145 {
146 /* Open the WS Key */
147 WsKey = WsOpenRegistryRoot();
148
149 /* Initialize the catalog */
150 WsTcInitializeFromRegistry(Catalog, WsKey, NULL);
151
152 /* Close the key */
153 RegCloseKey(WsKey);
154 }
155
156 /* Return it */
157 return Catalog;
158}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NULL
Definition: types.h:112
PTCATALOG WSAAPI WsTcAllocate(VOID)
Definition: dcatalog.c:25
HKEY WSAAPI WsOpenRegistryRoot(VOID)
Definition: wsautil.c:17
DWORD WSAAPI WsTcInitializeFromRegistry(IN PTCATALOG TCatalog, HKEY, PVOID)

Referenced by WSCEnumProtocols().

◆ ProtocolEnumerationProc()

BOOL WSAAPI ProtocolEnumerationProc ( PVOID  EnumContext,
PTCATALOG_ENTRY  Entry 
)

Definition at line 84 of file enumprot.c.

86{
88 LPWSAPROTOCOL_INFOW ProtocolInfo = &Entry->ProtocolInfo;
89
90 /* Check if this protocol matches */
91 if (CheckProtocolMatch(Context->Protocols, ProtocolInfo))
92 {
93 /* Copy the information */
94 ProtocolInfoFromContext(ProtocolInfo, Context);
95 Context->BufferUsed += sizeof(*ProtocolInfo);
96 }
97
98 /* Continue enumeration */
99 return TRUE;
100}
BOOL WSAAPI CheckProtocolMatch(IN LPINT ProtocolSet, IN LPWSAPROTOCOL_INFOW ProtocolInfo)
Definition: enumprot.c:21
VOID WSAAPI ProtocolInfoFromContext(IN LPWSAPROTOCOL_INFOW ProtocolInfo, IN PPROTOCOL_ENUM_CONTEXT Context)
Definition: enumprot.c:64
base of all file and directory entries
Definition: entries.h:83
struct _PROTOCOL_ENUM_CONTEXT * PPROTOCOL_ENUM_CONTEXT

Referenced by WSCEnumProtocols().

◆ ProtocolInfoFromContext()

VOID WSAAPI ProtocolInfoFromContext ( IN LPWSAPROTOCOL_INFOW  ProtocolInfo,
IN PPROTOCOL_ENUM_CONTEXT  Context 
)

Definition at line 64 of file enumprot.c.

66{
67 /* Check if we'll have space */
68 if ((Context->BufferUsed + sizeof(*ProtocolInfo)) <=
69 (Context->BufferLength))
70 {
71 /* Copy the data */
72 RtlMoveMemory((PVOID)((ULONG_PTR)Context->ProtocolBuffer +
73 Context->BufferUsed),
74 ProtocolInfo,
75 sizeof(*ProtocolInfo));
76
77 /* Increase the count */
78 Context->Count++;
79 }
80}
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by ProtocolEnumerationProc().

◆ ProviderEnumerationProc()

BOOL WSAAPI ProviderEnumerationProc ( PVOID  EnumContext,
PNSCATALOG_ENTRY  Entry 
)

Definition at line 104 of file enumprot.c.

106{
107 INT PathLen;
109
110 /* Check if this provider matches */
111 if (IsEqualGUID(&Entry->ProviderId, &Context->ProviderId))
112 {
113 /* Get the information about the provider */
114 PathLen = wcslen(Entry->DllPath) + 1;
115 Context->FoundPathLen = PathLen;
116 Context->Found = 1;
117
118 /* If we have enough room, copy path */
119 if (PathLen <= Context->ProviderDllPathLen)
120 {
121 wcscpy(Context->ProviderDllPath, Entry->DllPath);
122 }
123
124 /* Stop enumeration */
125 return FALSE;
126 }
127 else
128 {
129 /* Continue enumeration */
130 return TRUE;
131 }
132
133}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
struct _PROVIDER_ENUM_CONTEXT * PPROVIDER_ENUM_CONTEXT

Referenced by WSCGetProviderPath().

◆ WPUGetProviderPath()

INT WSPAPI WPUGetProviderPath ( IN LPGUID  lpProviderId,
OUT LPWSTR  lpszProviderDllPath,
IN OUT LPINT  lpProviderDllPathLen,
OUT LPINT  lpErrno 
)

Definition at line 297 of file enumprot.c.

301{
302 return WSCGetProviderPath(lpProviderId, lpszProviderDllPath, lpProviderDllPathLen, lpErrno);
303}
INT WSPAPI WSCGetProviderPath(IN LPGUID lpProviderId, OUT LPWSTR lpszProviderDllPath, IN OUT LPINT lpProviderDllPathLen, OUT LPINT lpErrno)
Definition: enumprot.c:325

Referenced by WsTpInitialize().

◆ WSAEnumProtocolsA()

INT WSAAPI WSAEnumProtocolsA ( IN LPINT  lpiProtocols,
OUT LPWSAPROTOCOL_INFOA  lpProtocolBuffer,
IN OUT LPDWORD  lpdwBufferLength 
)

Definition at line 229 of file enumprot.c.

232{
233 INT error, i, count;
234 LPWSAPROTOCOL_INFOW protocolInfoW;
235 DWORD size;
236 DPRINT("WSAEnumProtocolsA: %p %p %p\n", lpiProtocols, lpProtocolBuffer, lpdwBufferLength);
237 if (!lpdwBufferLength)
238 {
240 return SOCKET_ERROR;
241 }
242 count = WSCEnumProtocols(lpiProtocols, NULL, &size, &error);
243 if (!lpProtocolBuffer || *lpdwBufferLength < (size/sizeof(WSAPROTOCOL_INFOW))*sizeof(WSAPROTOCOL_INFOA))
244 {
247 return SOCKET_ERROR;
248 }
249 protocolInfoW = HeapAlloc(WsSockHeap, 0, size);
250 count = WSCEnumProtocols(lpiProtocols, protocolInfoW, &size, &error);
251 if (SOCKET_ERROR == count)
252 {
253 HeapFree(WsSockHeap, 0, protocolInfoW);
255 return SOCKET_ERROR;
256 }
257 *lpdwBufferLength = 0;
258 for (i = 0; i < count; i++)
259 {
260 /* Copy the data */
261 RtlMoveMemory(&lpProtocolBuffer[i],
262 &protocolInfoW[i],
263 sizeof(lpProtocolBuffer[0])-sizeof(lpProtocolBuffer[0].szProtocol));
264 wcstombs(lpProtocolBuffer[i].szProtocol, protocolInfoW[i].szProtocol, sizeof(lpProtocolBuffer[0].szProtocol));
266 }
267 HeapFree(WsSockHeap, 0, protocolInfoW);
268 return i;
269}
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
INT WSPAPI WSCEnumProtocols(IN LPINT lpiProtocols, OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer, IN OUT LPDWORD lpdwBufferLength, OUT LPINT lpErrno)
Definition: enumprot.c:165
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
size_t __cdecl wcstombs(_Out_writes_opt_z_(_MaxCount) char *_Dest, _In_z_ const wchar_t *_Source, _In_ size_t _MaxCount)
#define error(str)
Definition: mkdosfs.c:1605
#define DPRINT
Definition: sndvol32.h:73
#define WSAENOBUFS
Definition: winerror.h:1968
_In_ _In_opt_ _Out_writes_bytes_to_opt_ lpdwBufferLength _Inout_ LPDWORD lpdwBufferLength
Definition: winhttp.h:675
struct _WSAPROTOCOL_INFOW WSAPROTOCOL_INFOW
struct _WSAPROTOCOL_INFOA WSAPROTOCOL_INFOA
#define SOCKET_ERROR
Definition: winsock.h:333
HANDLE WsSockHeap
Definition: dllmain.c:21

Referenced by test_WSAEnumProtocolsA().

◆ WSAEnumProtocolsW()

INT WSAAPI WSAEnumProtocolsW ( IN LPINT  lpiProtocols,
OUT LPWSAPROTOCOL_INFOW  lpProtocolBuffer,
IN OUT LPDWORD  lpdwBufferLength 
)

Definition at line 276 of file enumprot.c.

279{
280 INT error, count;
281 DPRINT("WSAEnumProtocolsW: %p %p %p\n", lpiProtocols, lpProtocolBuffer, lpdwBufferLength);
282 count = WSCEnumProtocols(lpiProtocols, lpProtocolBuffer, lpdwBufferLength, &error);
283 if (SOCKET_ERROR == count)
284 {
286 return SOCKET_ERROR;
287 }
288 return count;
289}

Referenced by test_WSAEnumProtocolsW().

◆ WSAProviderConfigChange()

INT WSAAPI WSAProviderConfigChange ( IN OUT LPHANDLE  lpNotificationHandle,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Definition at line 310 of file enumprot.c.

313{
314 DPRINT("WSAProviderConfigChange: %p\n", lpNotificationHandle);
317 return SOCKET_ERROR;
318}
#define UNIMPLEMENTED
Definition: debug.h:118
#define WSAEINVAL
Definition: winerror.h:1946

◆ WSCEnumProtocols()

INT WSPAPI WSCEnumProtocols ( IN LPINT  lpiProtocols,
OUT LPWSAPROTOCOL_INFOW  lpProtocolBuffer,
IN OUT LPDWORD  lpdwBufferLength,
OUT LPINT  lpErrno 
)

Definition at line 165 of file enumprot.c.

169{
170 INT Status;
171 PTCATALOG Catalog;
173 DPRINT("WSCEnumProtocols: %p\n", lpiProtocols);
174
175 /* Create a catalog object from the current one */
176 Catalog = OpenInitializedCatalog();
177 if (!Catalog)
178 {
179 /* Fail if we couldn't */
180 *lpErrno = WSAENOBUFS;
181 return SOCKET_ERROR;
182 }
183
184 /* Setup the context */
185 Context.Protocols = lpiProtocols;
186 Context.ProtocolBuffer = lpProtocolBuffer;
187 Context.BufferLength = lpProtocolBuffer ? *lpdwBufferLength : 0;
188 Context.BufferUsed = 0;
189 Context.Count = 0;
190 Context.ErrorCode = ERROR_SUCCESS;
191
192 /* Enumerate the catalog */
194
195 /* Get status */
196 Status = Context.Count;
197
198 /* Check the error code */
199 if (Context.ErrorCode == ERROR_SUCCESS)
200 {
201 /* Check if enough space was available */
202 if (Context.BufferLength < Context.BufferUsed)
203 {
204 /* Fail and tell them how much we need */
205 *lpdwBufferLength = Context.BufferUsed;
206 *lpErrno = WSAENOBUFS;
208 }
209 }
210 else
211 {
212 /* Failure, normalize error */
214 *lpErrno = Context.ErrorCode;
215 }
216
217 /* Delete the catalog object */
218 WsTcDelete(Catalog);
219
220 /* Return */
221 return Status;
222}
#define ERROR_SUCCESS
Definition: deptool.c:10
PTCATALOG WSAAPI OpenInitializedCatalog(VOID)
Definition: enumprot.c:137
BOOL WSAAPI ProtocolEnumerationProc(PVOID EnumContext, PTCATALOG_ENTRY Entry)
Definition: enumprot.c:84
Status
Definition: gdiplustypes.h:25
VOID WSAAPI WsTcEnumerateCatalogItems(IN PTCATALOG Catalog, IN PTCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: dcatalog.c:750
VOID WSAAPI WsTcDelete(IN PTCATALOG Catalog)
Definition: dcatalog.c:883

Referenced by WSAEnumProtocolsA(), and WSAEnumProtocolsW().

◆ WSCGetProviderPath()

INT WSPAPI WSCGetProviderPath ( IN LPGUID  lpProviderId,
OUT LPWSTR  lpszProviderDllPath,
IN OUT LPINT  lpProviderDllPathLen,
OUT LPINT  lpErrno 
)

Definition at line 325 of file enumprot.c.

329{
332 PNSCATALOG Catalog;
333 INT ErrorCode, PathLen;
335
336 DPRINT("WSCGetProviderPath: %p %p %p %p\n", lpProviderId, lpszProviderDllPath, lpProviderDllPathLen, lpErrno);
337
338 /* Enter prolog */
340 {
341 /* FIXME: if WSANOTINITIALISED, we should init
342 * and perform the search!
343 */
344
345 /* Leave now */
346 *lpErrno = ErrorCode;
347 return SOCKET_ERROR;
348 }
349
350 /* Get the catalog */
351 Catalog = WsProcGetNsCatalog(Process);
352
354 {
355 /* Setup the context */
356 Context.ProviderId = *lpProviderId;
357 Context.ProviderDllPath = lpszProviderDllPath;
358 Context.ProviderDllPathLen = *lpProviderDllPathLen;
359 Context.FoundPathLen = 0;
360 Context.Found = 0;
361 Context.ErrorCode = ERROR_SUCCESS;
362
364
365 /* Enumerate the catalog */
367
368 /* Check the error code */
369 if (Context.ErrorCode == ERROR_SUCCESS)
370 {
371 /* Check if provider was found */
372 if (Context.Found)
373 {
374 PathLen = Context.FoundPathLen;
375
376 /* Check whether buffer is too small
377 * If it isn't, return length without null char
378 * (see ProviderEnumerationProc)
379 */
380 if (Context.FoundPathLen <= *lpProviderDllPathLen)
381 {
382 PathLen = Context.FoundPathLen - 1;
383 }
384 else
385 {
387 }
388
389 /* Set returned/required length */
390 *lpProviderDllPathLen = PathLen;
391 }
392 else
393 {
395 }
396 }
397 else
398 {
399 ErrorCode = Context.ErrorCode;
400 }
401 }
403 {
405 }
406 _SEH2_END;
407
408 /* Do we have to return failure? */
410 {
411 *lpErrno = ErrorCode;
412 return SOCKET_ERROR;
413 }
414
415 return 0;
416}
BOOL WSAAPI ProviderEnumerationProc(PVOID EnumContext, PNSCATALOG_ENTRY Entry)
Definition: enumprot.c:104
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define WSAEFAULT
Definition: winerror.h:1945
PNSCATALOG WSAAPI WsProcGetNsCatalog(IN PWSPROCESS Process)
Definition: dprocess.c:166
VOID WSAAPI WsNcEnumerateCatalogItems(IN PNSCATALOG Catalog, IN PNSCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: nscatalo.c:371
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91

Referenced by WPUGetProviderPath().