ReactOS  0.4.14-dev-358-gbef841c
nscatalo.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for nscatalo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define WsNcLock()   EnterCriticalSection(&Catalog->Lock)
 
#define WsNcUnlock()   LeaveCriticalSection(&Catalog->Lock)
 

Functions

PNSCATALOG WSAAPI WsNcAllocate (VOID)
 
BOOLEAN WSAAPI WsNcOpen (IN PNSCATALOG Catalog, IN HKEY ParentKey)
 
INT WSAAPI WsNcInitializeFromRegistry (IN PNSCATALOG Catalog, IN HKEY ParentKey, IN HANDLE CatalogEvent)
 
INT WSAAPI WsNcRefreshFromRegistry (IN PNSCATALOG Catalog, IN HANDLE CatalogEvent)
 
VOID WSAAPI WsNcEnumerateCatalogItems (IN PNSCATALOG Catalog, IN PNSCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
 
INT WSAAPI WsNcLoadProvider (IN PNSCATALOG Catalog, IN PNSCATALOG_ENTRY CatalogEntry)
 
INT WSAAPI WsNcGetServiceClassInfo (IN PNSCATALOG Catalog, IN OUT LPDWORD BugSize, IN OUT LPWSASERVICECLASSINFOW lpServiceClassInfo)
 
VOID WSAAPI WsNcUpdateNamespaceList (IN PNSCATALOG Catalog, IN PLIST_ENTRY List)
 
INT WSAAPI WsNcGetCatalogFromProviderId (IN PNSCATALOG Catalog, IN LPGUID ProviderId, OUT PNSCATALOG_ENTRY *CatalogEntry)
 
BOOL WSAAPI WsNcMatchProtocols (IN DWORD NameSpace, IN LONG AddressFamily, IN LPWSAQUERYSETW QuerySet)
 
VOID WSAAPI WsNcRemoveCatalogItem (IN PNSCATALOG Catalog, IN PNSCATALOG_ENTRY Entry)
 
VOID WSAAPI WsNcDelete (IN PNSCATALOG Catalog)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file nscatalo.c.

◆ WsNcLock

#define WsNcLock ( )    EnterCriticalSection(&Catalog->Lock)

Definition at line 18 of file nscatalo.c.

◆ WsNcUnlock

#define WsNcUnlock ( )    LeaveCriticalSection(&Catalog->Lock)

Definition at line 19 of file nscatalo.c.

Function Documentation

◆ WsNcAllocate()

PNSCATALOG WSAAPI WsNcAllocate ( VOID  )

Definition at line 25 of file nscatalo.c.

26 {
27  PNSCATALOG Catalog;
28 
29  /* Allocate the catalog */
30  Catalog = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*Catalog));
31 
32  /* Return it */
33  return Catalog;
34 }
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HANDLE WsSockHeap
Definition: dllmain.c:21

Referenced by WsProcInitialize().

◆ WsNcDelete()

VOID WSAAPI WsNcDelete ( IN PNSCATALOG  Catalog)

Definition at line 603 of file nscatalo.c.

604 {
606  PNSCATALOG_ENTRY CatalogEntry;
607 
608  /* Check if we're initialized */
609  if (!Catalog->CatalogList.Flink) return;
610 
611  /* Acquire lock */
612  WsNcLock();
613 
614  /* Loop every entry */
615  Entry = Catalog->CatalogList.Flink;
616  while (Entry != &Catalog->CatalogList)
617  {
618  /* Get this entry */
619  CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
620 
621  /* Remove it and dereference it */
622  WsNcRemoveCatalogItem(Catalog, CatalogEntry);
623  WsNcEntryDereference(CatalogEntry);
624 
625  /* Move to the next entry */
626  Entry = Catalog->CatalogList.Flink;
627  }
628 
629  /* Check if the catalog key is opened */
630  if (Catalog->CatalogKey)
631  {
632  /* Close it */
633  RegCloseKey(Catalog->CatalogKey);
634  Catalog->CatalogKey = NULL;
635  }
636 
637  /* Release and delete the lock */
638  WsNcUnlock();
639  DeleteCriticalSection(&Catalog->Lock);
640 
641  /* Delete the object */
642  HeapFree(WsSockHeap, 0, Catalog);
643 }
struct _Entry Entry
Definition: kefuncs.h:640
VOID WSAAPI WsNcEntryDereference(IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatent.c:53
Definition: ws2_32p.h:121
#define WsNcUnlock()
Definition: nscatalo.c:19
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define WsNcLock()
Definition: nscatalo.c:18
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
Definition: typedefs.h:117
VOID WSAAPI WsNcRemoveCatalogItem(IN PNSCATALOG Catalog, IN PNSCATALOG_ENTRY Entry)
Definition: nscatalo.c:591
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:402
base of all file and directory entries
Definition: entries.h:82

Referenced by WsProcDelete().

◆ WsNcEnumerateCatalogItems()

VOID WSAAPI WsNcEnumerateCatalogItems ( IN PNSCATALOG  Catalog,
IN PNSCATALOG_ENUMERATE_PROC  Callback,
IN PVOID  Context 
)

Definition at line 350 of file nscatalo.c.

353 {
355  PNSCATALOG_ENTRY CatalogEntry;
356  BOOL GoOn = TRUE;
357 
358  /* Lock the catalog */
359  WsNcLock();
360 
361  /* Loop the entries */
362  Entry = Catalog->CatalogList.Flink;
363  while (GoOn && (Entry != &Catalog->CatalogList))
364  {
365  /* Get the entry */
366  CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
367 
368  /* Move to the next one and call the callback */
369  Entry = Entry->Flink;
370  GoOn = Callback(Context, CatalogEntry);
371  }
372 
373  /* Release the lock */
374  WsNcUnlock();
375 }
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
Definition: ws2_32p.h:121
#define WsNcUnlock()
Definition: nscatalo.c:19
#define WsNcLock()
Definition: nscatalo.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Definition: typedefs.h:117
LPFNPSPCALLBACK Callback
Definition: desk.c:111
base of all file and directory entries
Definition: entries.h:82

Referenced by WSAEnumNameSpaceProvidersInternal(), WSCGetProviderPath(), WsNqLookupServiceBegin(), and WsProcDelete().

◆ WsNcGetCatalogFromProviderId()

INT WSAAPI WsNcGetCatalogFromProviderId ( IN PNSCATALOG  Catalog,
IN LPGUID  ProviderId,
OUT PNSCATALOG_ENTRY CatalogEntry 
)

Definition at line 496 of file nscatalo.c.

499 {
501  PLIST_ENTRY NextEntry;
503 
504  /* Lock the catalog */
505  WsNcLock();
506 
507  /* Match the Id with all the entries in the List */
508  NextEntry = Catalog->CatalogList.Flink;
509  while (NextEntry != &Catalog->CatalogList)
510  {
511  /* Get the Current Entry */
512  Entry = CONTAINING_RECORD(NextEntry, NSCATALOG_ENTRY, CatalogLink);
513  NextEntry = NextEntry->Flink;
514 
515  /* Check if this is the Catalog Entry ID we want */
516  if (IsEqualGUID(&Entry->ProviderId, ProviderId))
517  {
518  /* If it doesn't already have a provider, load the provider */
519  if (!Entry->Provider)
520  ErrorCode = WsNcLoadProvider(Catalog, Entry);
521 
522  /* If we succeeded, reference the entry and return it */
523  if (Entry->Provider /* || ErrorCode == ERROR_SUCCESS */)
524  {
525  InterlockedIncrement(&Entry->RefCount);
526  *CatalogEntry = Entry;
528  break;
529  }
530  }
531  }
532 
533  /* Release the lock and return */
534  WsNcUnlock();
535  return ErrorCode;
536 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
struct _Entry Entry
Definition: kefuncs.h:640
#define WSAEINVAL
Definition: winerror.h:1946
Definition: ws2_32p.h:121
int32_t INT
Definition: typedefs.h:56
#define WsNcUnlock()
Definition: nscatalo.c:19
#define WsNcLock()
Definition: nscatalo.c:18
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
#define InterlockedIncrement
Definition: armddk.h:53
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
INT WSAAPI WsNcLoadProvider(IN PNSCATALOG Catalog, IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatalo.c:379
base of all file and directory entries
Definition: entries.h:82

Referenced by WsNqLookupServiceBegin().

◆ WsNcGetServiceClassInfo()

INT WSAAPI WsNcGetServiceClassInfo ( IN PNSCATALOG  Catalog,
IN OUT LPDWORD  BugSize,
IN OUT LPWSASERVICECLASSINFOW  lpServiceClassInfo 
)

Definition at line 423 of file nscatalo.c.

426 {
427  /* Not yet implemented in the spec? */
429  return SOCKET_ERROR;
430 }
#define SOCKET_ERROR
Definition: winsock.h:333
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SetLastError(x)
Definition: compat.h:417

Referenced by WsNqLookupServiceBegin().

◆ WsNcInitializeFromRegistry()

INT WSAAPI WsNcInitializeFromRegistry ( IN PNSCATALOG  Catalog,
IN HKEY  ParentKey,
IN HANDLE  CatalogEvent 
)

Definition at line 190 of file nscatalo.c.

193 {
195 
196  /* Open the catalog */
197  if (WsNcOpen(Catalog, ParentKey))
198  {
199  /* Refresh it */
200  ErrorCode = WsNcRefreshFromRegistry(Catalog, CatalogEvent);
201  }
202 
203  /* Return the status */
204  return ErrorCode;
205 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
int32_t INT
Definition: typedefs.h:56
BOOLEAN WSAAPI WsNcOpen(IN PNSCATALOG Catalog, IN HKEY ParentKey)
Definition: nscatalo.c:38
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
INT WSAAPI WsNcRefreshFromRegistry(IN PNSCATALOG Catalog, IN HANDLE CatalogEvent)
Definition: nscatalo.c:209

Referenced by WsProcInitialize().

◆ WsNcLoadProvider()

INT WSAAPI WsNcLoadProvider ( IN PNSCATALOG  Catalog,
IN PNSCATALOG_ENTRY  CatalogEntry 
)

Definition at line 379 of file nscatalo.c.

381 {
384 
385  /* Lock the catalog */
386  WsNcLock();
387 
388  /* Check if we have a provider already */
389  if (!CatalogEntry->Provider)
390  {
391  /* Allocate a provider */
392  if ((Provider = WsNpAllocate()))
393  {
394  /* Initialize it */
396  CatalogEntry->DllPath,
397  &CatalogEntry->ProviderId);
398 
399  /* Ensure success */
400  if (ErrorCode == ERROR_SUCCESS)
401  {
402  /* Set the provider */
403  WsNcEntrySetProvider(CatalogEntry, Provider);
404  }
405 
406  /* Dereference it */
408  }
409  else
410  {
411  /* No memory */
413  }
414  }
415 
416  /* Release the lock and return */
417  WsNcUnlock();
418  return ErrorCode;
419 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WSAAPI WsNpInitialize(IN PNS_PROVIDER Provider, IN LPWSTR DllPath, IN LPGUID ProviderGuid)
Definition: nsprovid.c:82
int32_t INT
Definition: typedefs.h:56
#define WsNcUnlock()
Definition: nscatalo.c:19
#define WsNcLock()
Definition: nscatalo.c:18
VOID WSAAPI WsNpDereference(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:180
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:593
VOID WSAAPI WsNcEntrySetProvider(IN PNSCATALOG_ENTRY Entry, IN PNS_PROVIDER Provider)
Definition: nscatent.c:175
PNS_PROVIDER WSAAPI WsNpAllocate(VOID)
Definition: nsprovid.c:63

Referenced by WsNcGetCatalogFromProviderId(), and WsNqBeginEnumerationProc().

◆ WsNcMatchProtocols()

BOOL WSAAPI WsNcMatchProtocols ( IN DWORD  NameSpace,
IN LONG  AddressFamily,
IN LPWSAQUERYSETW  QuerySet 
)

Definition at line 540 of file nscatalo.c.

543 {
544  DWORD ProtocolCount = QuerySet->dwNumberOfProtocols;
545  LPAFPROTOCOLS AfpProtocols = QuerySet->lpafpProtocols;
546  LONG Family;
547 
548  /* Check for valid family */
549  if (AddressFamily != -1)
550  {
551  /* Check if it's the magic */
552  if (AddressFamily == AF_UNSPEC) return TRUE;
554  }
555  else
556  {
557  /* No family given, check for namespace */
558  if (NameSpace == NS_SAP)
559  {
560  /* Use IPX family */
561  Family = AF_IPX;
562  }
563  else
564  {
565  /* Other namespace, it's valid */
566  return TRUE;
567  }
568  }
569 
570  /* Now try to get a match */
571  while (ProtocolCount--)
572  {
573  /* Check this protocol entry */
574  if ((AfpProtocols->iAddressFamily == AF_UNSPEC) ||
575  (AfpProtocols->iAddressFamily == Family))
576  {
577  /* Match found */
578  return TRUE;
579  }
580 
581  /* Move to the next one */
582  AfpProtocols++;
583  }
584 
585  /* No match */
586  return FALSE;
587 }
IN PCO_ADDRESS_FAMILY AddressFamily
Definition: ndis.h:1906
#define TRUE
Definition: types.h:120
static int Family
Definition: ping.c:62
long LONG
Definition: pedump.c:60
#define AF_UNSPEC
Definition: winsock.h:344
unsigned long DWORD
Definition: ntddk_ex.h:95
#define AF_IPX
Definition: winsock.h:350
INT iAddressFamily
Definition: winsock2.h:787
#define NS_SAP
Definition: nspapi.h:10

Referenced by WsNqBeginEnumerationProc().

◆ WsNcOpen()

BOOLEAN WSAAPI WsNcOpen ( IN PNSCATALOG  Catalog,
IN HKEY  ParentKey 
)

Definition at line 38 of file nscatalo.c.

40 {
43  HKEY CatalogKey, NewKey;
44  DWORD RegType = REG_DWORD;
45  DWORD RegSize = sizeof(DWORD);
46  DWORD UniqueId = 0;
47  DWORD NewData = 0;
48  CHAR* CatalogKeyName;
49 
50  /* Initialize the catalog lock and namespace list */
51  InitializeCriticalSection(&Catalog->Lock);
52  InitializeListHead(&Catalog->CatalogList);
53 
54  /* Read the catalog name */
55  ErrorCode = RegQueryValueEx(ParentKey,
56  "Current_NameSpace_Catalog",
57  0,
58  &RegType,
59  NULL,
60  &RegSize);
61 
62  CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize);
63 
64  /* Read the catalog name */
65  ErrorCode = RegQueryValueEx(ParentKey,
66  "Current_NameSpace_Catalog",
67  0,
68  &RegType,
69  (LPBYTE)CatalogKeyName,
70  &RegSize);
71 
72  /* Open the Catalog Key */
73  ErrorCode = RegOpenKeyEx(ParentKey,
74  CatalogKeyName,
75  0,
77  &CatalogKey);
78 
79  /* If we didn't find the key, create it */
80  if (ErrorCode == ERROR_SUCCESS)
81  {
82  /* Fake that we opened an existing key */
84  }
85  else if (ErrorCode == ERROR_FILE_NOT_FOUND)
86  {
87  /* Create the Catalog Name */
88  ErrorCode = RegCreateKeyEx(ParentKey,
89  CatalogKeyName,
90  0,
91  NULL,
94  NULL,
95  &CatalogKey,
97  }
98 
99  HeapFree(WsSockHeap, 0, CatalogKeyName);
100  RegType = REG_DWORD;
101  RegSize = sizeof(DWORD);
102 
103  /* Fail if that didn't work */
104  if (ErrorCode != ERROR_SUCCESS) return FALSE;
105 
106  /* Check if we had to create the key */
108  {
109  /* Write the count of entries (0 now) */
110  ErrorCode = RegSetValueEx(CatalogKey,
111  "Num_Catalog_Entries",
112  0,
113  REG_DWORD,
114  (LPBYTE)&NewData,
115  sizeof(NewData));
116  if (ErrorCode != ERROR_SUCCESS)
117  {
118  /* Close the key and fail */
119  RegCloseKey(CatalogKey);
120  return FALSE;
121  }
122 
123  /* Write the first catalog entry Uniqe ID */
124  NewData = 1;
125  ErrorCode = RegSetValueEx(CatalogKey,
126  "Serial_Access_Num",
127  0,
128  REG_DWORD,
129  (LPBYTE)&NewData,
130  sizeof(NewData));
131  if (ErrorCode != ERROR_SUCCESS)
132  {
133  /* Close the key and fail */
134  RegCloseKey(CatalogKey);
135  return FALSE;
136  }
137 
138  /* Create a key for this entry */
139  ErrorCode = RegCreateKeyEx(CatalogKey,
140  "Catalog_Entries",
141  0,
142  NULL,
145  NULL,
146  &NewKey,
148  if (ErrorCode != ERROR_SUCCESS)
149  {
150  /* Close the key and fail */
151  RegCloseKey(CatalogKey);
152  return FALSE;
153  }
154 
155  /* Close the key since we don't need it */
156  RegCloseKey(NewKey);
157  }
158  else
159  {
160  RegSize = sizeof(UniqueId);
161  /* Read the serial number */
162  ErrorCode = RegQueryValueEx(CatalogKey,
163  "Serial_Access_Num",
164  0,
165  &RegType,
166  (LPBYTE)&UniqueId,
167  &RegSize);
168 
169  /* Check if it's missing for some reason */
170  if (ErrorCode != ERROR_SUCCESS)
171  {
172  /* Write the first catalog entry Unique ID */
173  NewData = 1;
174  ErrorCode = RegSetValueEx(CatalogKey,
175  "Serial_Access_Num",
176  0,
177  REG_DWORD,
178  (LPBYTE)&NewData,
179  sizeof(NewData));
180  }
181  }
182 
183  /* Set the Catalog Key */
184  Catalog->CatalogKey = CatalogKey;
185  return TRUE;
186 }
#define RegQueryValueEx
Definition: winreg.h:524
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define TRUE
Definition: types.h:120
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKeyEx
Definition: winreg.h:520
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define REG_DWORD
Definition: sdbapi.c:596
HANDLE WsSockHeap
Definition: dllmain.c:21
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT _In_ ULONG CreateDisposition
Definition: create.c:4157
#define HeapFree(x, y, z)
Definition: compat.h:402
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by WsNcInitializeFromRegistry().

◆ WsNcRefreshFromRegistry()

INT WSAAPI WsNcRefreshFromRegistry ( IN PNSCATALOG  Catalog,
IN HANDLE  CatalogEvent 
)

Definition at line 209 of file nscatalo.c.

211 {
212  INT ErrorCode;
213  BOOLEAN LocalEvent = FALSE;
214  LIST_ENTRY LocalList;
215  DWORD UniqueId;
216  HKEY EntriesKey;
217  DWORD CatalogEntries;
218  PNSCATALOG_ENTRY CatalogEntry;
219  BOOL NewChangesMade;
221  DWORD RegType = REG_DWORD;
222  DWORD RegSize = sizeof(DWORD);
223  DWORD i;
224 
225  /* Check if we got an event */
226  if (!CatalogEvent)
227  {
228  /* Create an event ourselves */
229  CatalogEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
230  if (!CatalogEvent) return WSASYSCALLFAILURE;
231  LocalEvent = TRUE;
232  }
233 
234  /* Lock the catalog */
235  WsNcLock();
236 
237  /* Initialize our local list for the loop */
238  InitializeListHead(&LocalList);
239 
240  /* Start looping */
241  do
242  {
243  /* Setup notifications for the catalog entry */
244  ErrorCode = WsSetupCatalogProtection(Catalog->CatalogKey,
245  CatalogEvent,
246  &UniqueId);
247  if (ErrorCode != ERROR_SUCCESS) break;
248 
249  /* Check if we've changed till now */
250  if (UniqueId == Catalog->UniqueId)
251  {
252  /* We haven't, so return */
254  break;
255  }
256 
257  /* Now Open the Entries */
258  ErrorCode = RegOpenKeyEx(Catalog->CatalogKey,
259  "Catalog_Entries",
260  0,
262  &EntriesKey);
263  if (ErrorCode != ERROR_SUCCESS)
264  {
265  /* Critical failure */
267  break;
268  }
269 
270  /* Find out how many there are */
271  ErrorCode = RegQueryValueEx(Catalog->CatalogKey,
272  "Num_Catalog_Entries",
273  0,
274  &RegType,
275  (LPBYTE)&CatalogEntries,
276  &RegSize);
277  if (ErrorCode != ERROR_SUCCESS)
278  {
279  /* Critical failure */
281  break;
282  }
283 
284  /* Initialize them all */
285  for (i = 1; i <= CatalogEntries; i++)
286  {
287  /* Allocate a Catalog Entry Structure */
288  CatalogEntry = WsNcEntryAllocate();
289  if (!CatalogEntry)
290  {
291  /* Not enough memory, fail */
293  break;
294  }
295 
296  /* Initialize it from the Registry Key */
298  EntriesKey,
299  i);
300  if (ErrorCode != ERROR_SUCCESS)
301  {
302  /* We failed to get it, dereference the entry and leave */
303  WsNcEntryDereference(CatalogEntry);
304  break;
305  }
306 
307  /* Insert it to our List */
308  InsertTailList(&LocalList, &CatalogEntry->CatalogLink);
309  }
310 
311  /* Close the catalog key */
312  RegCloseKey(EntriesKey);
313 
314  /* Check if we changed during our read and if we have success */
315  NewChangesMade = WsCheckCatalogState(CatalogEvent);
316  if (!NewChangesMade && ErrorCode == ERROR_SUCCESS)
317  {
318  /* All is good, update the protocol list */
319  WsNcUpdateNamespaceList(Catalog, &LocalList);
320 
321  /* Update and return */
322  Catalog->UniqueId = UniqueId;
323  break;
324  }
325 
326  /* We failed and/or catalog data changed, free what we did till now */
327  while (!IsListEmpty(&LocalList))
328  {
329  /* Get the LP Catalog Item */
330  Entry = RemoveHeadList(&LocalList);
331  CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
332 
333  /* Dereference it */
334  WsNcEntryDereference(CatalogEntry);
335  }
336  } while (NewChangesMade);
337 
338  /* Release the lock */
339  WsNcUnlock();
340 
341  /* Close the event, if any was created by us */
342  if (LocalEvent) CloseHandle(CatalogEvent);
343 
344  /* All Done */
345  return ErrorCode;
346 }
#define CreateEvent
Definition: winbase.h:3572
#define RegQueryValueEx
Definition: winreg.h:524
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
struct _Entry Entry
Definition: kefuncs.h:640
VOID WSAAPI WsNcEntryDereference(IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatent.c:53
INT WSAAPI WsNcEntryInitializeFromRegistry(IN PNSCATALOG_ENTRY CatalogEntry, IN HKEY ParentKey, IN ULONG UniqueId)
Definition: nscatent.c:65
#define InsertTailList(ListHead, Entry)
LIST_ENTRY CatalogLink
Definition: ws2_32p.h:123
Definition: ws2_32p.h:121
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define WsNcUnlock()
Definition: nscatalo.c:19
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define WsNcLock()
Definition: nscatalo.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
INT WSAAPI WsSetupCatalogProtection(IN HKEY CatalogKey, IN HANDLE CatalogEvent, OUT LPDWORD UniqueId)
Definition: wsautil.c:142
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
VOID WSAAPI WsNcUpdateNamespaceList(IN PNSCATALOG Catalog, IN PLIST_ENTRY List)
Definition: nscatalo.c:434
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:593
BOOL WSAAPI WsCheckCatalogState(IN HANDLE Event)
Definition: wsautil.c:75
Definition: typedefs.h:117
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
#define RegOpenKeyEx
Definition: winreg.h:520
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PNSCATALOG_ENTRY WSAAPI WsNcEntryAllocate(VOID)
Definition: nscatent.c:17
#define REG_DWORD
Definition: sdbapi.c:596
base of all file and directory entries
Definition: entries.h:82

Referenced by WsNcInitializeFromRegistry(), and WsProcGetNsCatalog().

◆ WsNcRemoveCatalogItem()

VOID WSAAPI WsNcRemoveCatalogItem ( IN PNSCATALOG  Catalog,
IN PNSCATALOG_ENTRY  Entry 
)

Definition at line 591 of file nscatalo.c.

593 {
594  /* Remove the entry from the list */
595  RemoveEntryList(&Entry->CatalogLink);
596 
597  /* Decrease our count */
598  Catalog->ItemCount--;
599 }
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
base of all file and directory entries
Definition: entries.h:82

Referenced by WsNcDelete().

◆ WsNcUpdateNamespaceList()

VOID WSAAPI WsNcUpdateNamespaceList ( IN PNSCATALOG  Catalog,
IN PLIST_ENTRY  List 
)

Definition at line 434 of file nscatalo.c.

436 {
437  LIST_ENTRY TempList;
438  PNSCATALOG_ENTRY CatalogEntry, OldCatalogEntry;
440 
441  /* First move from our list to the old one */
442  InsertHeadList(&Catalog->CatalogList, &TempList);
443  RemoveEntryList(&Catalog->CatalogList);
444  InitializeListHead(&Catalog->CatalogList);
445 
446  /* Loop every item on the list */
447  while (!IsListEmpty(List))
448  {
449  /* Get the catalog entry */
451  CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
452 
453  /* Check if this item is already on our list */
454  Entry = TempList.Flink;
455  while (Entry != &TempList)
456  {
457  /* Get the catalog entry */
458  OldCatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
459  Entry = Entry->Flink;
460 
461  /* Check if they match */
462  if (IsEqualGUID(&CatalogEntry->ProviderId,
463  &OldCatalogEntry->ProviderId))
464  {
465  /* We have a match, use the old item instead */
466  WsNcEntryDereference(CatalogEntry);
467  CatalogEntry = OldCatalogEntry;
468  RemoveEntryList(&CatalogEntry->CatalogLink);
469 
470  /* Decrease the number of protocols we have */
471  Catalog->ItemCount--;
472  break;
473  }
474  }
475 
476  /* Add this item */
477  InsertTailList(&Catalog->CatalogList, &CatalogEntry->CatalogLink);
478  Catalog->ItemCount++;
479  }
480 
481  /* If there's anything left on the temporary list */
482  while (!IsListEmpty(&TempList))
483  {
484  /* Get the entry */
485  Entry = RemoveHeadList(&TempList);
486  CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
487 
488  /* Remove it */
489  Catalog->ItemCount--;
490  WsNcEntryDereference(CatalogEntry);
491  }
492 }
struct _Entry Entry
Definition: kefuncs.h:640
VOID WSAAPI WsNcEntryDereference(IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatent.c:53
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define InsertTailList(ListHead, Entry)
LIST_ENTRY CatalogLink
Definition: ws2_32p.h:123
Definition: ws2_32p.h:121
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY List
Definition: psmgr.c:57
Definition: typedefs.h:117
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
GUID ProviderId
Definition: ws2_32p.h:132
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
base of all file and directory entries
Definition: entries.h:82

Referenced by WsNcRefreshFromRegistry().