ReactOS 0.4.15-dev-5666-gc548b97
nscatent.c File Reference
#include <ws2_32.h>
Include dependency graph for nscatent.c:

Go to the source code of this file.

Functions

PNSCATALOG_ENTRY WSAAPI WsNcEntryAllocate (VOID)
 
VOID WSAAPI WsNcEntryDelete (IN PNSCATALOG_ENTRY CatalogEntry)
 
VOID WSAAPI WsNcEntryDereference (IN PNSCATALOG_ENTRY CatalogEntry)
 
INT WSAAPI WsNcEntryInitializeFromRegistry (IN PNSCATALOG_ENTRY CatalogEntry, IN HKEY ParentKey, IN ULONG UniqueId)
 
VOID WSAAPI WsNcEntrySetProvider (IN PNSCATALOG_ENTRY Entry, IN PNS_PROVIDER Provider)
 

Function Documentation

◆ WsNcEntryAllocate()

PNSCATALOG_ENTRY WSAAPI WsNcEntryAllocate ( VOID  )

Definition at line 17 of file nscatent.c.

18{
19 PNSCATALOG_ENTRY CatalogEntry;
20
21 /* Allocate the catalog */
22 CatalogEntry = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*CatalogEntry));
23 if (CatalogEntry)
24 {
25 /* Set the default non-null members */
26 CatalogEntry->RefCount = 1;
27 CatalogEntry->Enabled = TRUE;
28 CatalogEntry->AddressFamily = -1;
29 }
30
31 /* Return it */
32 return CatalogEntry;
33}
#define TRUE
Definition: types.h:120
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
Definition: ws2_32p.h:122
LONG RefCount
Definition: ws2_32p.h:124
LONG AddressFamily
Definition: ws2_32p.h:126
BOOLEAN Enabled
Definition: ws2_32p.h:130
HANDLE WsSockHeap
Definition: dllmain.c:21

Referenced by WsNcRefreshFromRegistry().

◆ WsNcEntryDelete()

VOID WSAAPI WsNcEntryDelete ( IN PNSCATALOG_ENTRY  CatalogEntry)

Definition at line 37 of file nscatent.c.

38{
39 /* Check if a provider is loaded */
40 if (CatalogEntry->Provider)
41 {
42 /* Dereference it too */
43 WsNpDereference(CatalogEntry->Provider);
44 CatalogEntry->Provider = NULL;
45 }
46
47 /* Delete us */
48 HeapFree(WsSockHeap, 0, CatalogEntry);
49}
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:735
VOID WSAAPI WsNpDereference(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:180

Referenced by WsNcEntryDereference().

◆ WsNcEntryDereference()

VOID WSAAPI WsNcEntryDereference ( IN PNSCATALOG_ENTRY  CatalogEntry)

Definition at line 53 of file nscatent.c.

54{
55 /* Dereference and check if it's now 0 */
56 if (!(InterlockedDecrement(&CatalogEntry->RefCount)))
57 {
58 /* We can delete the Provider now */
59 WsNcEntryDelete(CatalogEntry);
60 }
61}
#define InterlockedDecrement
Definition: armddk.h:52
VOID WSAAPI WsNcEntryDelete(IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatent.c:37

Referenced by WsNcDelete(), WsNcRefreshFromRegistry(), and WsNcUpdateNamespaceList().

◆ WsNcEntryInitializeFromRegistry()

INT WSAAPI WsNcEntryInitializeFromRegistry ( IN PNSCATALOG_ENTRY  CatalogEntry,
IN HKEY  ParentKey,
IN ULONG  UniqueId 
)

Definition at line 65 of file nscatent.c.

68{
70 CHAR CatalogEntryName[13];
71 HKEY EntryKey;
72 ULONG RegType = REG_SZ;
73 ULONG RegSize = MAX_PATH;
74 ULONG RegValue;
75
76 /* Convert to a 00000xxx string */
77 sprintf(CatalogEntryName, "%0""12""i", (int)UniqueId);
78
79 /* Open the Entry */
81 CatalogEntryName,
82 0,
84 &EntryKey);
85 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
86 /* Read the Library Path */
87 ErrorCode = RegQueryValueExW(EntryKey,
88 L"LibraryPath",
89 0,
90 &RegType,
91 (LPBYTE)&CatalogEntry->DllPath,
92 &RegSize);
93 if (ErrorCode != ERROR_SUCCESS) goto out;
94 /* Query Display String Size*/
95 ErrorCode = RegQueryValueExW(EntryKey,
96 L"DisplayString",
97 0,
98 NULL,
99 NULL,
100 &RegSize);
101 if (ErrorCode != ERROR_SUCCESS) goto out;
102 /* Allocate it */
103 CatalogEntry->ProviderName = (LPWSTR)HeapAlloc(WsSockHeap, 0, RegSize);
104
105 /* Read it */
106 ErrorCode = RegQueryValueExW(EntryKey,
107 L"DisplayString",
108 0,
109 &RegType,
110 (LPBYTE)CatalogEntry->ProviderName,
111 &RegSize);
112 if (ErrorCode != ERROR_SUCCESS) goto out;
113 /* Read the Provider Id */
114 RegType = REG_BINARY;
115 RegSize = sizeof(GUID);
116 ErrorCode = RegQueryValueEx(EntryKey,
117 "ProviderId",
118 0,
119 &RegType,
120 (LPBYTE)&CatalogEntry->ProviderId,
121 &RegSize);
122 if (ErrorCode != ERROR_SUCCESS) goto out;
123 /* Read the Address Family */
124 RegType = REG_DWORD;
125 RegSize = sizeof(DWORD);
126 ErrorCode = RegQueryValueEx(EntryKey,
127 "AddressFamily",
128 0,
129 &RegType,
130 (LPBYTE)&CatalogEntry->AddressFamily,
131 &RegSize);
132 if (ErrorCode != ERROR_SUCCESS) goto out;
133 /* Read the Namespace Id */
134 ErrorCode = RegQueryValueEx(EntryKey,
135 "SupportedNamespace",
136 0,
137 &RegType,
138 (LPBYTE)&CatalogEntry->NamespaceId,
139 &RegSize);
140 if (ErrorCode != ERROR_SUCCESS) goto out;
141 /* Read the Enabled Flag */
142 ErrorCode = RegQueryValueEx(EntryKey,
143 "Enabled",
144 0,
145 &RegType,
146 (LPBYTE)&RegValue,
147 &RegSize);
148 if (ErrorCode != ERROR_SUCCESS) goto out;
149 CatalogEntry->Enabled = RegValue != 0;
150
151 /* Read the Version */
152 ErrorCode = RegQueryValueEx(EntryKey,
153 "Version",
154 0,
155 &RegType,
156 (LPBYTE)&CatalogEntry->Version,
157 &RegSize);
158 if (ErrorCode != ERROR_SUCCESS) goto out;
159 /* Read the Support Service Class Info Flag */
160 ErrorCode = RegQueryValueEx(EntryKey,
161 "StoresServiceClassInfo",
162 0,
163 &RegType,
164 (LPBYTE)&RegValue,
165 &RegSize);
166 CatalogEntry->StoresServiceClassInfo = RegValue != 0;
167out:
168 /* Done */
169 RegCloseKey(EntryKey);
170 return ErrorCode;
171}
#define RegCloseKey(hKey)
Definition: registry.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
#define MAX_PATH
Definition: compat.h:34
#define REG_SZ
Definition: layer.c:22
unsigned int ULONG
Definition: retypes.h:1
#define sprintf(buf, format,...)
Definition: sprintf.c:55
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
static FILE * out
Definition: regtests2xml.c:44
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegQueryValueEx
Definition: winreg.h:524
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175

Referenced by WsNcRefreshFromRegistry().

◆ WsNcEntrySetProvider()

VOID WSAAPI WsNcEntrySetProvider ( IN PNSCATALOG_ENTRY  Entry,
IN PNS_PROVIDER  Provider 
)

Definition at line 175 of file nscatent.c.

177{
178 /* Reference the provider */
179 InterlockedIncrement(&Provider->RefCount);
180
181 /* Set it */
182 Entry->Provider = Provider;
183}
#define InterlockedIncrement
Definition: armddk.h:53
base of all file and directory entries
Definition: entries.h:83

Referenced by WsNcLoadProvider().