ReactOS  0.4.15-dev-1070-ge1a01de
nsprovid.c File Reference
#include <ws2_32.h>
Include dependency graph for nsprovid.c:

Go to the source code of this file.

Functions

PNSQUERY_PROVIDER WSAAPI WsNqProvAllocate (VOID)
 
DWORD WSAAPI WsNqProvInitialize (IN PNSQUERY_PROVIDER QueryProvider, IN PNS_PROVIDER Provider)
 
VOID WSAAPI WsNqProvDelete (IN PNSQUERY_PROVIDER QueryProvider)
 
PNS_PROVIDER WSAAPI WsNpAllocate (VOID)
 
DWORD WSAAPI WsNpInitialize (IN PNS_PROVIDER Provider, IN LPWSTR DllName, IN LPGUID ProviderId)
 
DWORD WSAAPI WsNpNSPCleanup (IN PNS_PROVIDER Provider)
 
VOID WSAAPI WsNpDelete (IN PNS_PROVIDER Provider)
 
VOID WSAAPI WsNpDereference (IN PNS_PROVIDER Provider)
 
DWORD WSAAPI WsNqProvLookupServiceEnd (IN PNSQUERY_PROVIDER QueryProvider)
 
DWORD WSAAPI WsNqProvLookupServiceNext (IN PNSQUERY_PROVIDER QueryProvider, IN DWORD ControlFlags, IN PDWORD BufferLength, LPWSAQUERYSETW Results)
 
DWORD WSAAPI WsNqProvLookupServiceBegin (IN PNSQUERY_PROVIDER QueryProvider, IN LPWSAQUERYSETW Restrictions, IN LPWSASERVICECLASSINFOW ServiceClassInfo, IN DWORD ControlFlags)
 
DWORD WSAAPI WsNpLookupServiceEnd (IN PNS_PROVIDER Provider, IN HANDLE LookupHandle)
 
DWORD WSAAPI WsNpLookupServiceNext (IN PNS_PROVIDER Provider, IN HANDLE LookupHandle, IN DWORD ControlFlags, OUT PDWORD BufferLength, OUT LPWSAQUERYSETW Results)
 
DWORD WSAAPI WsNpLookupServiceBegin (IN PNS_PROVIDER Provider, IN LPWSAQUERYSETW Restrictions, IN LPWSASERVICECLASSINFOW ServiceClassInfo, IN DWORD ControlFlags, OUT PHANDLE LookupHandle)
 

Function Documentation

◆ WsNpAllocate()

PNS_PROVIDER WSAAPI WsNpAllocate ( VOID  )

Definition at line 63 of file nsprovid.c.

64 {
66 
67  /* Allocate the object */
69  if (Provider)
70  {
71  /* Set non-null data */
72  Provider->RefCount = 1;
73  Provider->Service.cbSize = sizeof(NSP_ROUTINE);
74  }
75 
76  /* Return it */
77  return Provider;
78 }
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct _NSP_ROUTINE NSP_ROUTINE
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HANDLE WsSockHeap
Definition: dllmain.c:21

Referenced by WsNcLoadProvider().

◆ WsNpDelete()

VOID WSAAPI WsNpDelete ( IN PNS_PROVIDER  Provider)

Definition at line 161 of file nsprovid.c.

162 {
163  /* Make sure we have a loaded handle */
164  if (Provider->DllHandle)
165  {
166  /* Clean us up */
168 
169  /* Unload the library */
170  FreeLibrary(Provider->DllHandle);
171  Provider->DllHandle = NULL;
172  }
173 
174  /* Delete us */
176 }
DWORD WSAAPI WsNpNSPCleanup(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:140
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:496
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by WsNpDereference().

◆ WsNpDereference()

VOID WSAAPI WsNpDereference ( IN PNS_PROVIDER  Provider)

Definition at line 180 of file nsprovid.c.

181 {
182  /* Decrease the reference count and check if it's zero */
183  if (!InterlockedDecrement(&Provider->RefCount))
184  {
185  /* Delete us*/
187  }
188 }
#define InterlockedDecrement
Definition: armddk.h:52
VOID WSAAPI WsNpDelete(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:161

Referenced by WsNcEntryDelete(), WsNcLoadProvider(), and WsNqProvDelete().

◆ WsNpInitialize()

DWORD WSAAPI WsNpInitialize ( IN PNS_PROVIDER  Provider,
IN LPWSTR  DllName,
IN LPGUID  ProviderId 
)

Definition at line 82 of file nsprovid.c.

85 {
87  LPNSPSTARTUP NSPStartupProc;
88  CHAR AnsiPath[MAX_PATH], ExpandedDllPath[MAX_PATH];
89 
90  /* Convert the path to ANSI */
92  0,
93  DllName,
94  -1,
95  AnsiPath,
96  MAX_PATH,
97  NULL,
98  NULL);
99 
100  /* Expand the DLL Path */
101  ExpandEnvironmentStringsA(AnsiPath,
102  ExpandedDllPath,
103  MAX_PATH);
104 
105  /* Load the DLL */
106  Provider->DllHandle = LoadLibraryA(ExpandedDllPath);
107  if (!Provider->DllHandle)
108  {
109  /* Fail */
111  goto Fail;
112  }
113 
114  /* Get the pointer to NSPStartup */
115  NSPStartupProc = (LPNSPSTARTUP)GetProcAddress(Provider->DllHandle,
116  "NSPStartup");
117  if (!NSPStartupProc)
118  {
119  /* Fail */
121  goto Fail;
122  }
123 
124  /* Call it */
125  (*NSPStartupProc)(ProviderId, &Provider->Service);
126 
127  /* Save the provider ID */
128  Provider->ProviderId = *ProviderId;
129  return ErrorCode;
130 
131 Fail:
132  /* Bail out */
133  if (Provider->DllHandle) FreeLibrary(Provider->DllHandle);
134  Provider->DllHandle = NULL;
135  return ErrorCode;
136 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
int32_t INT
Definition: typedefs.h:58
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
Definition: environ.c:399
#define FreeLibrary(x)
Definition: compat.h:496
#define MAX_PATH
Definition: compat.h:34
Definition: hiveinit.c:368
_Must_inspect_result_ INT(WSAAPI * LPNSPSTARTUP)(_In_ LPGUID lpProviderId, _Inout_ LPNSP_ROUTINE lpnspRoutines)
Definition: ws2spi.h:671
#define WSAEPROVIDERFAILEDINIT
Definition: winerror.h:1993
#define GetProcAddress(x, y)
Definition: compat.h:501

Referenced by WsNcLoadProvider().

◆ WsNpLookupServiceBegin()

DWORD WSAAPI WsNpLookupServiceBegin ( IN PNS_PROVIDER  Provider,
IN LPWSAQUERYSETW  Restrictions,
IN LPWSASERVICECLASSINFOW  ServiceClassInfo,
IN DWORD  ControlFlags,
OUT PHANDLE  LookupHandle 
)

Definition at line 255 of file nsprovid.c.

260 {
261  /* Call the NSP */
262  return Provider->Service.NSPLookupServiceBegin(&Provider->ProviderId,
263  Restrictions,
264  ServiceClassInfo,
265  ControlFlags,
266  LookupHandle);
267 }

Referenced by WsNqProvLookupServiceBegin().

◆ WsNpLookupServiceEnd()

DWORD WSAAPI WsNpLookupServiceEnd ( IN PNS_PROVIDER  Provider,
IN HANDLE  LookupHandle 
)

Definition at line 231 of file nsprovid.c.

233 {
234  /* Call the NSP */
235  return Provider->Service.NSPLookupServiceEnd(LookupHandle);
236 }

Referenced by WsNqProvLookupServiceEnd().

◆ WsNpLookupServiceNext()

DWORD WSAAPI WsNpLookupServiceNext ( IN PNS_PROVIDER  Provider,
IN HANDLE  LookupHandle,
IN DWORD  ControlFlags,
OUT PDWORD  BufferLength,
OUT LPWSAQUERYSETW  Results 
)

Definition at line 240 of file nsprovid.c.

245 {
246  /* Call the NSP */
247  return Provider->Service.NSPLookupServiceNext(LookupHandle,
248  ControlFlags,
249  BufferLength,
250  Results);
251 }
_In_ UCHAR BufferLength
Definition: scsi.h:4067

Referenced by WsNqProvLookupServiceNext().

◆ WsNpNSPCleanup()

DWORD WSAAPI WsNpNSPCleanup ( IN PNS_PROVIDER  Provider)

Definition at line 140 of file nsprovid.c.

141 {
143  LPNSPCLEANUP lpNSPCleanup = NULL;
144 
145  /* Make sure we have a loaded handle */
146  if (Provider->DllHandle)
147  {
148  /* Get the pointer and clear it */
149  lpNSPCleanup = InterlockedExchangePointer((PVOID*)&Provider->Service.NSPCleanup,
150  NULL);
151  /* If it's not NULL, call it */
152  if (lpNSPCleanup) ErrorCode = lpNSPCleanup(&Provider->ProviderId);
153  }
154 
155  /* Return */
156  return ErrorCode;
157 }
INT(WSAAPI * LPNSPCLEANUP)(_In_ LPGUID lpProviderId)
Definition: ws2spi.h:494
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
int32_t INT
Definition: typedefs.h:58
smooth NULL
Definition: ftsmooth.c:416
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45

Referenced by CleanupNamespaceProviders(), and WsNpDelete().

◆ WsNqProvAllocate()

PNSQUERY_PROVIDER WSAAPI WsNqProvAllocate ( VOID  )

Definition at line 17 of file nsprovid.c.

18 {
20 
21  /* Allocate the object */
23 
24  /* Return it */
25  return Provider;
26 }
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HANDLE WsSockHeap
Definition: dllmain.c:21

Referenced by WsNqAddProvider().

◆ WsNqProvDelete()

VOID WSAAPI WsNqProvDelete ( IN PNSQUERY_PROVIDER  QueryProvider)

Definition at line 45 of file nsprovid.c.

46 {
47  /* Check if we have a provider */
48  if (QueryProvider->Provider)
49  {
50  /* Dereference it */
51  WsNpDereference(QueryProvider->Provider);
52 
53  /* Clear it */
54  QueryProvider->Provider = NULL;
55  }
56 
57  /* Delete us */
58  HeapFree(WsSockHeap, 0, QueryProvider);
59 }
smooth NULL
Definition: ftsmooth.c:416
VOID WSAAPI WsNpDereference(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:180
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by WsNqDelete(), WsNqLookupServiceBegin(), and WsNqLookupServiceNext().

◆ WsNqProvInitialize()

DWORD WSAAPI WsNqProvInitialize ( IN PNSQUERY_PROVIDER  QueryProvider,
IN PNS_PROVIDER  Provider 
)

Definition at line 30 of file nsprovid.c.

32 {
33  /* Reference the provider */
34  InterlockedIncrement(&Provider->RefCount);
35 
36  /* Set it as our own */
37  QueryProvider->Provider = Provider;
38 
39  /* Return success */
40  return ERROR_SUCCESS;
41 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by WsNqAddProvider().

◆ WsNqProvLookupServiceBegin()

DWORD WSAAPI WsNqProvLookupServiceBegin ( IN PNSQUERY_PROVIDER  QueryProvider,
IN LPWSAQUERYSETW  Restrictions,
IN LPWSASERVICECLASSINFOW  ServiceClassInfo,
IN DWORD  ControlFlags 
)

Definition at line 216 of file nsprovid.c.

220 {
221  /* Simply call the provider */
222  return WsNpLookupServiceBegin(QueryProvider->Provider,
223  Restrictions,
224  ServiceClassInfo,
225  ControlFlags,
226  &QueryProvider->LookupHandle);
227 }
DWORD WSAAPI WsNpLookupServiceBegin(IN PNS_PROVIDER Provider, IN LPWSAQUERYSETW Restrictions, IN LPWSASERVICECLASSINFOW ServiceClassInfo, IN DWORD ControlFlags, OUT PHANDLE LookupHandle)
Definition: nsprovid.c:255

Referenced by WsNqLookupServiceBegin().

◆ WsNqProvLookupServiceEnd()

DWORD WSAAPI WsNqProvLookupServiceEnd ( IN PNSQUERY_PROVIDER  QueryProvider)

Definition at line 192 of file nsprovid.c.

193 {
194  /* Simply call the provider */
195  return WsNpLookupServiceEnd(QueryProvider->Provider,
196  QueryProvider->LookupHandle);
197 }
DWORD WSAAPI WsNpLookupServiceEnd(IN PNS_PROVIDER Provider, IN HANDLE LookupHandle)
Definition: nsprovid.c:231

Referenced by WsNqLookupServiceEnd(), and WsNqLookupServiceNext().

◆ WsNqProvLookupServiceNext()

DWORD WSAAPI WsNqProvLookupServiceNext ( IN PNSQUERY_PROVIDER  QueryProvider,
IN DWORD  ControlFlags,
IN PDWORD  BufferLength,
LPWSAQUERYSETW  Results 
)

Definition at line 201 of file nsprovid.c.

205 {
206  /* Simply call the provider */
207  return WsNpLookupServiceNext(QueryProvider->Provider,
208  QueryProvider->LookupHandle,
209  ControlFlags,
210  BufferLength,
211  Results);
212 }
_In_ UCHAR BufferLength
Definition: scsi.h:4067
DWORD WSAAPI WsNpLookupServiceNext(IN PNS_PROVIDER Provider, IN HANDLE LookupHandle, IN DWORD ControlFlags, OUT PDWORD BufferLength, OUT LPWSAQUERYSETW Results)
Definition: nsprovid.c:240