ReactOS 0.4.16-dev-329-g9223134
dprocess.c File Reference
#include <ws2_32.h>
Include dependency graph for dprocess.c:

Go to the source code of this file.

Macros

#define WsProcLock()   EnterCriticalSection(&Process->ThreadLock)
 
#define WsProcUnlock()   LeaveCriticalSection(&Process->ThreadLock)
 

Functions

INT WSAAPI WsProcInitialize (IN PWSPROCESS Process)
 
PWSPROCESS WSAAPI WsProcAllocate (VOID)
 
INT WSAAPI WsProcOpenAsyncHelperDevice (IN PWSPROCESS Process, OUT PHANDLE Handle)
 
INT WSAAPI WsProcGetAsyncHelper (IN PWSPROCESS Process, OUT PHANDLE Handle)
 
INT WSAAPI WsProcStartup (VOID)
 
PTCATALOG WSAAPI WsProcGetTCatalog (IN PWSPROCESS Process)
 
PNSCATALOG WSAAPI WsProcGetNsCatalog (IN PWSPROCESS Process)
 
BOOL WSAAPI WsProcDetachSocket (IN PWSPROCESS Process, IN PWAH_HANDLE Handle)
 
BOOL WSAAPI CleanupNamespaceProviders (IN PVOID Callback, IN PNSCATALOG_ENTRY Entry)
 
BOOL WSAAPI CleanupProtocolProviders (IN PVOID Callback, IN PTCATALOG_ENTRY Entry)
 
VOID WSAAPI WsProcDelete (IN PWSPROCESS Process)
 
VOID WSAAPI WsProcSetVersion (IN PWSPROCESS Process, IN WORD VersionRequested)
 

Variables

PWSPROCESS CurrentWsProcess
 

Macro Definition Documentation

◆ WsProcLock

#define WsProcLock ( )    EnterCriticalSection(&Process->ThreadLock)

Definition at line 17 of file dprocess.c.

◆ WsProcUnlock

#define WsProcUnlock ( )    LeaveCriticalSection(&Process->ThreadLock)

Definition at line 18 of file dprocess.c.

Function Documentation

◆ CleanupNamespaceProviders()

BOOL WSAAPI CleanupNamespaceProviders ( IN PVOID  Callback,
IN PNSCATALOG_ENTRY  Entry 
)

Definition at line 208 of file dprocess.c.

210{
212
213 /* Get the provider */
214 Provider = Entry->Provider;
215 if (Provider)
216 {
217 /* Do cleanup */
219 }
220
221 /* Return success */
222 return TRUE;
223}
#define TRUE
Definition: types.h:120
base of all file and directory entries
Definition: entries.h:83
DWORD WSAAPI WsNpNSPCleanup(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:140

Referenced by WsProcDelete().

◆ CleanupProtocolProviders()

BOOL WSAAPI CleanupProtocolProviders ( IN PVOID  Callback,
IN PTCATALOG_ENTRY  Entry 
)

Definition at line 227 of file dprocess.c.

229{
232
233 /* Get the provider */
234 Provider = Entry->Provider;
235 if (Provider)
236 {
237 /* Do cleanup */
239 }
240
241 /* Return success */
242 return TRUE;
243}
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
int32_t INT
Definition: typedefs.h:58
DWORD WSAAPI WsTpWSPCleanup(IN PTPROVIDER Provider, int *)

Referenced by WsProcDelete().

◆ WsProcAllocate()

PWSPROCESS WSAAPI WsProcAllocate ( VOID  )

Definition at line 65 of file dprocess.c.

66{
68
69 /* Allocate the structure */
71 if (Process)
72 {
73 /* Set default non-zero values */
74 Process->Version = MAKEWORD(2,2);
75 }
76
77 /* Return it */
78 return Process;
79}
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define MAKEWORD(a, b)
Definition: typedefs.h:248
HANDLE WsSockHeap
Definition: dllmain.c:21

Referenced by WsProcStartup().

◆ WsProcDelete()

VOID WSAAPI WsProcDelete ( IN PWSPROCESS  Process)

Definition at line 247 of file dprocess.c.

248{
249 /* Check if we didn't even initialize yet */
250 if (!Process->LockReady) return;
251
252 /* No more current process */
254
255 /* If we have a socket table */
257 {
258 /* Enumerate the sockets with a delete callback */
261 Process);
262 }
263
264 /* Close APC Helper */
265 if (Process->ApcHelper) WahCloseApcHelper(Process->ApcHelper);
266
267 /* Close handle helper */
268 if (Process->HandleHelper) WahCloseHandleHelper(Process->HandleHelper);
269
270 /* Check for notification helper */
271 if (Process->NotificationHelper)
272 {
273 /* Close notification helper */
274 WahCloseNotificationHandleHelper(Process->NotificationHelper);
275 }
276
277 /* Check if we have a protocol catalog*/
278 if (Process->ProtocolCatalog)
279 {
280 /* Enumerate it to clean it up */
281 WsTcEnumerateCatalogItems(Process->ProtocolCatalog,
283 NULL);
284
285 /* Delete it */
286 WsTcDelete(Process->ProtocolCatalog);
287 Process->ProtocolCatalog = NULL;
288 }
289
290 /* Check if we have a namespace catalog*/
291 if (Process->NamespaceCatalog)
292 {
293 /* Enumerate it to clean it up */
294 WsNcEnumerateCatalogItems(Process->NamespaceCatalog,
296 NULL);
297
298 /* Delete it */
299 WsNcDelete(Process->NamespaceCatalog);
300 Process->NamespaceCatalog = NULL;
301 }
302
303 /* Delete the thread lock */
304 DeleteCriticalSection(&Process->ThreadLock);
305
306 /* Delete us */
308}
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:735
DWORD WINAPI WahCloseApcHelper(IN HANDLE ApcHelperHandle)
Definition: apc.c:42
BOOL WINAPI WahEnumerateHandleContexts(IN PWAH_HANDLE_TABLE Table, IN PWAH_HANDLE_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: context.c:280
DWORD WINAPI WahCloseHandleHelper(IN HANDLE HelperHandle)
Definition: handle.c:86
DWORD WINAPI WahCloseNotificationHandleHelper(IN HANDLE HelperHandle)
Definition: notify.c:22
BOOL WSAAPI CleanupNamespaceProviders(IN PVOID Callback, IN PNSCATALOG_ENTRY Entry)
Definition: dprocess.c:208
PWSPROCESS CurrentWsProcess
Definition: dprocess.c:15
BOOL WSAAPI CleanupProtocolProviders(IN PVOID Callback, IN PTCATALOG_ENTRY Entry)
Definition: dprocess.c:227
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
VOID WSAAPI WsNcDelete(IN PNSCATALOG Catalog)
Definition: nscatalo.c:624
VOID WSAAPI WsTcEnumerateCatalogItems(IN PTCATALOG Catalog, IN PTCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: dcatalog.c:750
PWAH_HANDLE_TABLE WsSockHandleTable
Definition: dsocket.c:15
VOID WSAAPI WsNcEnumerateCatalogItems(IN PNSCATALOG Catalog, IN PNSCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: nscatalo.c:371
BOOL WSAAPI WsSockDeleteSockets(IN LPVOID Context, IN PWAH_HANDLE Handle)
Definition: dsocket.c:180
VOID WSAAPI WsTcDelete(IN PTCATALOG Catalog)
Definition: dcatalog.c:883

Referenced by DllMain(), and WSACleanup().

◆ WsProcDetachSocket()

BOOL WSAAPI WsProcDetachSocket ( IN PWSPROCESS  Process,
IN PWAH_HANDLE  Handle 
)

Definition at line 182 of file dprocess.c.

184{
185 PWSSOCKET Socket = (PWSSOCKET)Handle;
186
187 /* Disassociate this socket from the table */
189
190 /* If this is isn't an IFS socket */
191 if (!Socket->Provider)
192 {
193 /* Check if we have an active handle helper */
194 if (Process->HandleHelper)
195 {
196 /* Close it */
197 WahCloseSocketHandle(Process->HandleHelper, (SOCKET)Socket->Handle);
198 }
199 }
200
201 /* Remove a reference and return */
202 WsSockDereference(Socket);
203 return TRUE;
204}
DWORD WINAPI WahRemoveHandleContext(IN PWAH_HANDLE_TABLE Table, IN PWAH_HANDLE Handle)
Definition: context.c:564
DWORD WINAPI WahCloseSocketHandle(IN HANDLE HelperHandle, IN SOCKET Socket)
Definition: handle.c:113
ULONG Handle
Definition: gdb_input.c:15
PTPROVIDER Provider
Definition: ws2_32p.h:199
HANDLE Handle
Definition: ws2_32p.h:197
UINT_PTR SOCKET
Definition: winsock.h:47
struct _WSSOCKET * PWSSOCKET
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205

Referenced by WsSockDeleteSockets().

◆ WsProcGetAsyncHelper()

INT WSAAPI WsProcGetAsyncHelper ( IN PWSPROCESS  Process,
OUT PHANDLE  Handle 
)

Definition at line 107 of file dprocess.c.

109{
110 /* Check if we have it already set up */
111 if (Process->ApcHelper)
112 {
113 /* Just return it */
114 *Handle = Process->ApcHelper;
115 return ERROR_SUCCESS;
116 }
117 else
118 {
119 /* Open it for the first time */
121 }
122}
#define ERROR_SUCCESS
Definition: deptool.c:10
INT WSAAPI WsProcOpenAsyncHelperDevice(IN PWSPROCESS Process, OUT PHANDLE Handle)
Definition: dprocess.c:83

Referenced by WsThreadInitialize().

◆ WsProcGetNsCatalog()

PNSCATALOG WSAAPI WsProcGetNsCatalog ( IN PWSPROCESS  Process)

Definition at line 166 of file dprocess.c.

167{
168 /* Check if the catalogs have been modified */
169 if (WsCheckCatalogState(Process->NamespaceCatalogEvent))
170 {
171 /* Modification happened, reload them */
172 WsNcRefreshFromRegistry(Process->NamespaceCatalog,
173 Process->NamespaceCatalogEvent);
174 }
175
176 /* Return it */
177 return Process->NamespaceCatalog;
178}
BOOL WSAAPI WsCheckCatalogState(IN HANDLE Event)
Definition: wsautil.c:75
INT WSAAPI WsNcRefreshFromRegistry(IN PNSCATALOG Catalog, IN HANDLE CatalogEvent)
Definition: nscatalo.c:230

Referenced by WSAEnumNameSpaceProvidersInternal(), WSALookupServiceBeginW(), and WSCGetProviderPath().

◆ WsProcGetTCatalog()

PTCATALOG WSAAPI WsProcGetTCatalog ( IN PWSPROCESS  Process)

Definition at line 150 of file dprocess.c.

151{
152 /* Check if the catalogs have been modified */
153 if (WsCheckCatalogState(Process->ProtocolCatalogEvent))
154 {
155 /* Modification happened, reload them */
156 WsTcRefreshFromRegistry(Process->ProtocolCatalog,
157 Process->ProtocolCatalogEvent);
158 }
159
160 /* Return it */
161 return Process->ProtocolCatalog;
162}
DWORD WSAAPI WsTcRefreshFromRegistry(IN PTCATALOG TCatalog, PVOID)

Referenced by WPUModifyIFSHandle(), WPUQueryBlockingCallback(), WSAAddressToStringA(), WSAAddressToStringW(), WSASocketW(), WSAStringToAddressA(), WSAStringToAddressW(), and WsSockFindIfsSocket().

◆ WsProcInitialize()

INT WSAAPI WsProcInitialize ( IN PWSPROCESS  Process)

Definition at line 24 of file dprocess.c.

25{
28
29 /* Initialize the thread list lock */
31 Process->LockReady = TRUE;
32
33 /* Open the Winsock Key */
35
36 /* Create the LP Catalog change event and catalog */
37 Process->ProtocolCatalogEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
38 Process->ProtocolCatalog = WsTcAllocate();
39
40 // FIXME: Check for Process->ProtocolCatalog == NULL
41
42 /* Initialize it */
43 WsTcInitializeFromRegistry(Process->ProtocolCatalog,
44 RootKey,
45 Process->ProtocolCatalogEvent);
46
47 /* Create the NS Catalog change event and catalog */
48 Process->NamespaceCatalogEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
49 Process->NamespaceCatalog = WsNcAllocate();
50
51 // FIXME: Check for Process->NamespaceCatalog == NULL
52
53 /* Initialize it */
55 RootKey,
56 Process->NamespaceCatalogEvent);
57
58 /* Close the root key */
60 return ErrorCode;
61}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define FALSE
Definition: types.h:117
static PMEMKEY RootKey
Definition: registry.c:55
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define CreateEvent
Definition: winbase.h:3773
#define WSAEFAULT
Definition: winerror.h:1945
PTCATALOG WSAAPI WsTcAllocate(VOID)
Definition: dcatalog.c:25
HKEY WSAAPI WsOpenRegistryRoot(VOID)
Definition: wsautil.c:17
INT WSAAPI WsNcInitializeFromRegistry(IN PNSCATALOG Catalog, IN HKEY ParentKey, IN HANDLE CatalogEvent)
Definition: nscatalo.c:211
DWORD WSAAPI WsTcInitializeFromRegistry(IN PTCATALOG TCatalog, HKEY, PVOID)
PNSCATALOG WSAAPI WsNcAllocate(VOID)
Definition: nscatalo.c:25

Referenced by WsProcStartup().

◆ WsProcOpenAsyncHelperDevice()

INT WSAAPI WsProcOpenAsyncHelperDevice ( IN PWSPROCESS  Process,
OUT PHANDLE  Handle 
)

Definition at line 83 of file dprocess.c.

85{
87
88 /* Lock the process */
89 WsProcLock();
90
91 /* Check if we have a handle, and if not, create one */
92 if ((Process->ApcHelper) ||
93 (WahOpenApcHelper(&Process->ApcHelper) == ERROR_SUCCESS))
94 {
95 /* Return the handle */
96 *Handle = Process->ApcHelper;
98 }
99
100 /* Unload the process and return */
101 WsProcUnlock();
102 return ErrorCode;
103}
DWORD WINAPI WahOpenApcHelper(OUT PHANDLE ApcHelperHandle)
Definition: apc.c:20
#define WsProcLock()
Definition: dprocess.c:17
#define WsProcUnlock()
Definition: dprocess.c:18
#define WSASYSCALLFAILURE
Definition: winerror.h:1994

Referenced by WsProcGetAsyncHelper().

◆ WsProcSetVersion()

VOID WSAAPI WsProcSetVersion ( IN PWSPROCESS  Process,
IN WORD  VersionRequested 
)

Definition at line 312 of file dprocess.c.

314{
315 WORD Major, Minor;
316 WORD OldMajor, OldMinor;
317
318 /* Get the version data */
319 Major = LOBYTE(VersionRequested);
320 Minor = HIBYTE(VersionRequested);
321 OldMajor = LOBYTE(Process->Version);
322 OldMinor = HIBYTE(Process->Version);
323
324 /* Check if we're going lower */
325 if ((Major < OldMajor) || ((Major == OldMajor) && (Minor < OldMinor)))
326 {
327 /* Set the new version */
328 Process->Version = VersionRequested;
329 }
330}
unsigned short WORD
Definition: ntddk_ex.h:93
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44

Referenced by WSAStartup().

◆ WsProcStartup()

INT WSAAPI WsProcStartup ( VOID  )

Definition at line 126 of file dprocess.c.

127{
129
130 /* Create a new process */
132
133 /* Initialize it */
135 {
136 /* Initialize the process */
138 }
139 else
140 {
141 /* No memory for the process object */
143 }
144
145 return ErrorCode;
146}
INT WSAAPI WsProcInitialize(IN PWSPROCESS Process)
Definition: dprocess.c:24
PWSPROCESS WSAAPI WsProcAllocate(VOID)
Definition: dprocess.c:65
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:620

Referenced by WSAStartup().

Variable Documentation

◆ CurrentWsProcess

PWSPROCESS CurrentWsProcess

Definition at line 15 of file dprocess.c.

Referenced by WsGetProcess(), WsProcDelete(), and WsProcStartup().