ReactOS 0.4.15-dev-7942-gd23573b
ws2help.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _WSH_HANDLE
 
struct  _WSH_HASH_TABLE
 
struct  _WSH_SEARCH_TABLE
 
struct  _WSH_HANDLE_TABLE
 

Typedefs

typedef struct _WSH_HANDLE WSH_HANDLE
 
typedef struct _WSH_HANDLEPWAH_HANDLE
 
typedef struct _WSH_HASH_TABLE WSH_HASH_TABLE
 
typedef struct _WSH_HASH_TABLEPWAH_HASH_TABLE
 
typedef struct _WSH_SEARCH_TABLE WSH_SEARCH_TABLE
 
typedef struct _WSH_SEARCH_TABLEPWAH_SEARCH_TABLE
 
typedef struct _WSH_HANDLE_TABLE WSH_HANDLE_TABLE
 
typedef struct _WSH_HANDLE_TABLEPWAH_HANDLE_TABLE
 
typedef BOOL(WINAPIPWAH_HANDLE_ENUMERATE_PROC) (IN PVOID Context, IN PWAH_HANDLE Handle)
 

Functions

PWAH_HANDLE WINAPI WahReferenceContextByHandle (IN PWAH_HANDLE_TABLE Table, IN HANDLE Handle)
 
DWORD WINAPI WahRemoveHandleContext (IN PWAH_HANDLE_TABLE Table, IN PWAH_HANDLE Handle)
 
DWORD WINAPI WahCloseSocketHandle (IN HANDLE HelperHandle, IN SOCKET Socket)
 
DWORD WINAPI WahOpenCurrentThread (IN HANDLE HelperHandle, OUT LPWSATHREADID ThreadId)
 
DWORD WINAPI WahCloseApcHelper (IN HANDLE HelperHandle)
 
DWORD WINAPI WahCloseThread (IN HANDLE HelperHandle, IN LPWSATHREADID ThreadId)
 
DWORD WINAPI WahCloseHandleHelper (IN HANDLE HelperHandle)
 
DWORD WINAPI WahCloseNotificationHandleHelper (IN HANDLE HelperHandle)
 
DWORD WINAPI WahOpenNotificationHandleHelper (OUT PHANDLE HelperHandle)
 
DWORD WINAPI WahCreateNotificationHandle (IN HANDLE HelperHandle, OUT PHANDLE NotificationHelperHandle)
 
INT WINAPI WahWaitForNotification (IN HANDLE NotificationHelperHandle, IN HANDLE lpNotificationHandle, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 
INT WINAPI WahNotifyAllProcesses (IN HANDLE NotificationHelperHandle)
 
BOOL WINAPI WahEnumerateHandleContexts (IN PWAH_HANDLE_TABLE Table, IN PWAH_HANDLE_ENUMERATE_PROC Callback, IN PVOID Context)
 
DWORD WINAPI WahCreateHandleContextTable (OUT PWAH_HANDLE_TABLE *Table)
 
DWORD WINAPI WahDestroyHandleContextTable (IN PWAH_HANDLE_TABLE Table)
 
PWAH_HANDLE WINAPI WahInsertHandleContext (IN PWAH_HANDLE_TABLE Table, IN PWAH_HANDLE Handle)
 
DWORD WINAPI WahOpenApcHelper (OUT PHANDLE ApcHelperHandle)
 

Typedef Documentation

◆ PWAH_HANDLE

◆ PWAH_HANDLE_ENUMERATE_PROC

typedef BOOL(WINAPI * PWAH_HANDLE_ENUMERATE_PROC) (IN PVOID Context, IN PWAH_HANDLE Handle)

Definition at line 43 of file ws2help.h.

◆ PWAH_HANDLE_TABLE

◆ PWAH_HASH_TABLE

◆ PWAH_SEARCH_TABLE

◆ WSH_HANDLE

◆ WSH_HANDLE_TABLE

◆ WSH_HASH_TABLE

◆ WSH_SEARCH_TABLE

Function Documentation

◆ WahCloseApcHelper()

DWORD WINAPI WahCloseApcHelper ( IN HANDLE  HelperHandle)

Definition at line 42 of file apc.c.

43{
45
46 /* Enter the prolog, make sure we're initialized */
48 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
49
50 /* Validate handle */
51 if (ApcHelperHandle != APCH) return ERROR_INVALID_PARAMETER;
52
53 /* return */
54 return ERROR_SUCCESS;
55}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define APCH
Definition: apc.c:14
#define WS2HELP_PROLOG()
Definition: precomp.h:47
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436

Referenced by WsProcDelete().

◆ WahCloseHandleHelper()

DWORD WINAPI WahCloseHandleHelper ( IN HANDLE  HelperHandle)

Definition at line 86 of file handle.c.

87{
89 PWAH_HELPER_CONTEXT Context = HelperHandle;
90
91 /* Enter the prolog, make sure we're initialized */
93 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
94
95 /* Validate the handle */
97
98 /* Queue an APC to exit the thread */
100 {
101 /* Done */
102 return ERROR_SUCCESS;
103 }
104 else
105 {
106 /* We failed somewhere */
107 return ERROR_GEN_FAILURE;
108 }
109}
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:959
VOID CALLBACK ExitThreadApc(ULONG_PTR Context)
Definition: handle.c:69
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ERROR_GEN_FAILURE
Definition: winerror.h:134

Referenced by WsProcDelete().

◆ WahCloseNotificationHandleHelper()

DWORD WINAPI WahCloseNotificationHandleHelper ( IN HANDLE  HelperHandle)

Definition at line 22 of file notify.c.

23{
25
26 /* Enter the prolog, make sure we're initialized */
28 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
29
30 /* Validate handle */
31 if (HelperHandle != HANH) return ERROR_INVALID_PARAMETER;
32
33 /* return */
34 return ERROR_SUCCESS;
35}
#define HANH
Definition: notify.c:14

Referenced by WsProcDelete().

◆ WahCloseSocketHandle()

DWORD WINAPI WahCloseSocketHandle ( IN HANDLE  HelperHandle,
IN SOCKET  Socket 
)

Definition at line 113 of file handle.c.

115{
117 PWAH_HELPER_CONTEXT Context = HelperHandle;
118
119 /* Enter the prolog, make sure we're initialized */
121 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
122
123 /* Validate the handle */
124 if (!(Context) || (Socket == INVALID_SOCKET) || !(Socket))
125 {
126 /* Invalid handle and/or socket */
128 }
129
130 /* Just close the handle and return */
131 CloseHandle((HANDLE)Socket);
132 return ERROR_SUCCESS;
133}
#define CloseHandle
Definition: compat.h:739
#define INVALID_SOCKET
Definition: winsock.h:332

Referenced by WsProcDetachSocket().

◆ WahCloseThread()

DWORD WINAPI WahCloseThread ( IN HANDLE  HelperHandle,
IN LPWSATHREADID  ThreadId 
)

Definition at line 59 of file apc.c.

61{
63
64 /* Enter the prolog, make sure we're initialized */
66 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
67
68 /* Validate handles */
69 if ((ApcHelperHandle != APCH) || (!ThreadId) || (!ThreadId->ThreadHandle))
70 {
71 /* Invalid helper/thread handles */
73 }
74
75 /* Close the thread handle */
76 if (CloseHandle(ThreadId->ThreadHandle))
77 {
78 /* Clear the structure */
79 ThreadId->ThreadHandle = NULL;
80 ThreadId->Reserved = 0;
81 return NO_ERROR;
82 }
83
84 /* return */
85 return GetLastError();
86}
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by WsThreadDelete().

◆ WahCreateHandleContextTable()

DWORD WINAPI WahCreateHandleContextTable ( OUT PWAH_HANDLE_TABLE Table)

Definition at line 189 of file context.c.

190{
192 PWAH_HANDLE_TABLE LocalTable;
193 DWORD i;
194
195 /* Enter the prolog, make sure we're initialized */
197 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
198
199 /* Assume NULL */
200 *Table = NULL;
201
202 /* Allocate enough tables */
203 LocalTable = HeapAlloc(GlobalHeap,
204 0,
206 SearchTables[gHandleToIndexMask + 1]));
207
208 /* Make sure it was allocated */
209 if (!LocalTable) return WSA_NOT_ENOUGH_MEMORY;
210
211 /* Set the mask for the table */
212 LocalTable->Mask = gHandleToIndexMask;
213
214 /* Now initialize every table */
215 for (i = 0; i <= gHandleToIndexMask; i++)
216 {
217 /* No hash table yet */
218 LocalTable->SearchTables[i].HashTable = NULL;
219
220 /* Set the current count */
221 LocalTable->SearchTables[i].CurrentCount = &LocalTable->SearchTables[i].Count1;
222
223 /* Initialize the counts */
224 LocalTable->SearchTables[i].Count1 = 1;
225 LocalTable->SearchTables[i].Count2 = 0;
226
227 /* Set expanding state and spin count */
228 LocalTable->SearchTables[i].Expanding = FALSE;
229 LocalTable->SearchTables[i].SpinCount = gdwSpinCount;
230
231 /* Initialize the lock */
233 SearchTables[i].Lock,
235 }
236
237 /* Return pointer */
238 *Table = LocalTable;
239
240 /* Return success */
241 return ERROR_SUCCESS;
242}
#define VOID
Definition: acefi.h:82
#define FALSE
Definition: types.h:117
#define HeapAlloc
Definition: compat.h:733
HANDLE GlobalHeap
Definition: dllmain.c:19
DWORD gdwSpinCount
Definition: context.c:18
DWORD gHandleToIndexMask
Definition: context.c:19
ASMGENDATA Table[]
Definition: genincdata.c:61
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
WSH_SEARCH_TABLE SearchTables[1]
Definition: ws2help.h:38
volatile PWAH_HASH_TABLE HashTable
Definition: ws2help.h:26
volatile PLONG CurrentCount
Definition: ws2help.h:27
BOOL WINAPI InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount)
Definition: synch.c:765
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:620

Referenced by WsSockStartup().

◆ WahCreateNotificationHandle()

DWORD WINAPI WahCreateNotificationHandle ( IN HANDLE  HelperHandle,
OUT PHANDLE  NotificationHelperHandle 
)

Definition at line 39 of file notify.c.

41{
42 UNREFERENCED_PARAMETER(HelperHandle);
43 UNREFERENCED_PARAMETER(NotificationHelperHandle);
44 return 0;
45}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

◆ WahDestroyHandleContextTable()

DWORD WINAPI WahDestroyHandleContextTable ( IN PWAH_HANDLE_TABLE  Table)

Definition at line 246 of file context.c.

247{
248 DWORD i;
249
250 /* Make sure the table is valid */
251 if (!Table)
252 {
253 /* No valid table */
255 }
256
257 /* Loop each search table */
258 for (i = 0; i <= Table->Mask; i++)
259 {
260 /* Check if there's a table here */
261 if (Table->SearchTables[i].HashTable)
262 {
263 /* Free it */
264 HeapFree(GlobalHeap, 0, Table->SearchTables[i].HashTable);
265 }
266
267 /* Delete the lock */
268 DeleteCriticalSection(&Table->SearchTables[i].Lock);
269 }
270
271 /* Delete the table */
273
274 /* Return success */
275 return ERROR_SUCCESS;
276}
#define HeapFree(x, y, z)
Definition: compat.h:735
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by WsSockCleanup().

◆ WahEnumerateHandleContexts()

BOOL WINAPI WahEnumerateHandleContexts ( IN PWAH_HANDLE_TABLE  Table,
IN PWAH_HANDLE_ENUMERATE_PROC  Callback,
IN PVOID  Context 
)

Definition at line 280 of file context.c.

283{
284 DWORD i, j;
285 PWAH_SEARCH_TABLE SearchTable;
288 BOOL GoOn = TRUE;
289
290 /* Loop the table */
291 for (i = 0; i <= Table->Mask; i++)
292 {
293 /* Get the Search table */
294 SearchTable = &Table->SearchTables[i];
295
296 /* Lock it */
297 AcquireWriteLock(SearchTable);
298
299 /* Mark us as expanding and wait for everyone */
300 SearchTable->Expanding = TRUE;
301 TryWaitForReaders(SearchTable);
302
303 /* Get the hash table */
304 HashTable = SearchTable->HashTable;
305
306 /* Make sure it exists */
307 if (HashTable)
308 {
309 /* Loop every handle in it */
310 for (j = 0; j < HashTable->Size; j++)
311 {
312 /* Get this handle */
313 Handle = HashTable->Handles[j];
314 if (!Handle) continue;
315
316 /* Call the callback proc */
317 GoOn = Callback(Context, Handle);
318 if (!GoOn) break;
319 }
320 }
321
322 /* Disable the expansion bit and release the lock */
323 SearchTable->Expanding = FALSE;
324 ReleaseWriteLock(SearchTable);
325
326 /* Check again if we should leave */
327 if (!GoOn) break;
328 }
329
330 /* return */
331 return GoOn;
332}
#define TRUE
Definition: types.h:120
static __inline VOID TryWaitForReaders(IN PWAH_SEARCH_TABLE Table)
Definition: context.c:144
#define ReleaseWriteLock(t)
Definition: context.c:43
#define AcquireWriteLock(t)
Definition: context.c:40
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG Handle
Definition: gdb_input.c:15
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 GLint GLint j
Definition: glfuncs.h:250
Definition: hash.c:67
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458

Referenced by WsProcDelete().

◆ WahInsertHandleContext()

PWAH_HANDLE WINAPI WahInsertHandleContext ( IN PWAH_HANDLE_TABLE  Table,
IN PWAH_HANDLE  Handle 
)

Definition at line 336 of file context.c.

338{
339 PWAH_HANDLE *HashHandle, OldHandle;
342 DWORD HandleCount, i;
343 PWAH_SEARCH_TABLE SearchTable;
344
345 /* Get the current Search Table */
346 SearchTable = WSH_SEARCH_TABLE_FROM_HANDLE(Handle->Handle, Table);
347
348 /* Start loop */
349 do
350 {
351 /* Get reader lock */
352 AcquireReadLock(SearchTable, &Count);
353
354 /* Get the hash table */
355 HashTable = SearchTable->HashTable;
356
357 /* Make sure we are not expanding, and that the table is there */
358 if (!(SearchTable->Expanding) && (HashTable))
359 {
360 /* Get the hash handle */
361 HashHandle = &WSH_HASH_FROM_HANDLE(Handle->Handle, HashTable);
362
363 /* Do the insert */
365 Handle,
366 NULL) == NULL)
367 {
368 /* Success, release the reader lock */
369 ReleaseReadLock(SearchTable, Count);
370
371 /* Save old handle */
372 OldHandle = Handle;
373 break;
374 }
375 }
376
377 /* Release the read lock since we're done with it now */
378 ReleaseReadLock(SearchTable, Count);
379
380 /* We need the writer lock to expand/create the table */
381 AcquireWriteLock(SearchTable);
382
383 /* Mark the table in use */
384 SearchTable->Expanding = TRUE;
385
386 /* Wait for all the readers to finish */
387 TryWaitForReaders(SearchTable);
388
389 /* Start loop */
390 do
391 {
392 /* Get the hash table again */
393 HashTable = SearchTable->HashTable;
394
395 /* Check if exists now */
396 if (HashTable)
397 {
398 /* It does! Do what we wanted to do earlier. Get the hash... */
399 HashHandle = &WSH_HASH_FROM_HANDLE(Handle->Handle, HashTable);
400
401 /* Check if it doesn't exist */
402 if (!(*HashHandle))
403 {
404 /* Write it (no need for interlock, we have the RW lock) */
405 OldHandle = Handle;
406 *HashHandle = Handle;
407 break;
408 }
409 else if ((*HashHandle)->Handle == Handle->Handle)
410 {
411 /* Handle matches, write it (see comment above) */
412 OldHandle = *HashHandle;
413 *HashHandle = Handle;
414 break;
415 }
416
417 /* No go, we need to expand the table. Remember the size now */
418 HandleCount = HashTable->Size;
419 }
420 else
421 {
422 /* Table is empty, we have to create it */
423 HandleCount = 0;
424 }
425
426ExpandTable:
427 /* Find a free prime */
428 for (i = 0; HandleCount >= SockPrimes[i]; i++);
429
430 /* Check if we found one */
431 if (SockPrimes[i] != 0xFFFFFFFF)
432 {
433 /* Use the prime */
434 HandleCount = SockPrimes[i];
435 }
436 else
437 {
438 /* No primes left. Table is quite large, so simply double it */
439 HandleCount *= 2;
440 }
441
442 /* Allocate the table */
444 0,
446 Handles[HandleCount]));
447
448 /* Hopefully we have one now */
449 if (NewHashTable)
450 {
451 /* Set its size */
452 NewHashTable->Size = HandleCount;
453
454 /* Initialize it */
455 RtlZeroMemory(NewHashTable->Handles, HandleCount * sizeof(PVOID));
456
457 /* Insert us first */
459
460 /* Now check if our old table had entries in it */
461 if (HashTable)
462 {
463 /* We need to move them */
464 for (i = 0; i < HashTable->Size; i++)
465 {
466 /* Make sure the hash handle exists */
467 if (HashTable->Handles[i])
468 {
469 /* Get it */
470 HashHandle = &WSH_HASH_FROM_HANDLE(HashTable->
471 Handles[i]->Handle,
473
474 /* Check if it has a value */
475 if (!(*HashHandle))
476 {
477 /* It's empty, so just write the handle */
478 *HashHandle = HashTable->Handles[i];
479 }
480 else
481 {
482 /* Not empty :/... that implies a collision */
484 goto ExpandTable;
485 }
486 }
487 }
488
489 /* Write the new hash table */
490 SearchTable->HashTable = NewHashTable;
491
492 /* Wait for everyone to be done with it, then free it */
493 TryWaitForReaders(SearchTable);
495 }
496 else
497 {
498 /* It was empty, nothing to worry about */
499 SearchTable->HashTable = NewHashTable;
500 }
501
502 /* Save the old handle */
503 OldHandle = Handle;
504 }
505 else
506 {
507 /* There was no old handle */
508 OldHandle = Handle;
509 }
510 } while (0);
511
512 /* Mark us as free, and release the write lock */
513 SearchTable->Expanding = FALSE;
514 ReleaseWriteLock(SearchTable);
515 break;
516 } while (1);
517
518 /* Return the old handle */
519 return OldHandle;
520}
struct HashTable * NewHashTable(void)
Definition: hash.c:77
static __inline VOID ReleaseReadLock(IN PWAH_SEARCH_TABLE Table, IN PVLONG Count)
Definition: context.c:75
VLONG * PVLONG
Definition: context.c:29
#define WSH_HASH_FROM_HANDLE(h, hs)
Definition: context.c:37
static __inline VOID AcquireReadLock(IN PWAH_SEARCH_TABLE Table, IN PVLONG *Count)
Definition: context.c:50
CONST DWORD SockPrimes[]
Definition: context.c:21
#define WSH_SEARCH_TABLE_FROM_HANDLE(h, t)
Definition: context.c:34
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
int Count
Definition: noreturn.cpp:7
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by WsSockAssociateHandle().

◆ WahNotifyAllProcesses()

INT WINAPI WahNotifyAllProcesses ( IN HANDLE  NotificationHelperHandle)

Definition at line 67 of file notify.c.

68{
69 UNREFERENCED_PARAMETER(NotificationHelperHandle);
70 return 0;
71}

◆ WahOpenApcHelper()

DWORD WINAPI WahOpenApcHelper ( OUT PHANDLE  ApcHelperHandle)

Definition at line 20 of file apc.c.

21{
23
24 /* Enter the prolog, make sure we're initialized */
26 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
27
28 /* Validate handle */
29 if (!ApcHelperHandle) return ERROR_INVALID_PARAMETER;
30
31 /*
32 * Return a bogus handle ("ROS")
33 * Historical note:(MS sends "CKM", which probably stands for "Keith Moore"
34 * (KM), one of the core architects of Winsock 2.2 from Microsoft.
35 */
36 *ApcHelperHandle = APCH;
37 return ERROR_SUCCESS;
38}

Referenced by WsProcOpenAsyncHelperDevice().

◆ WahOpenCurrentThread()

DWORD WINAPI WahOpenCurrentThread ( IN HANDLE  HelperHandle,
OUT LPWSATHREADID  ThreadId 
)

Definition at line 118 of file apc.c.

120{
121 HANDLE ProcessHandle, ThreadHandle;
122
123 /* Validate params */
124 if ((ApcHelperHandle != APCH) || (!ThreadId))
125 {
126 /* Invalid parameters */
128 }
129
130 /* Get the process/thread handles */
132 ThreadHandle = GetCurrentThread();
133
134 /* Duplicate the handle */
136 ThreadHandle,
138 &ThreadId->ThreadHandle,
139 0,
140 FALSE,
142 {
143 /* Save the thread handle and return */
144 ThreadId->Reserved = (DWORD_PTR)ThreadHandle;
145 return ERROR_SUCCESS;
146 }
147
148 /* Fail */
149 return GetLastError();
150}
#define GetCurrentProcess()
Definition: compat.h:759
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define DWORD_PTR
Definition: treelist.c:76
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define DUPLICATE_SAME_ACCESS

Referenced by WsThreadInitialize().

◆ WahOpenNotificationHandleHelper()

DWORD WINAPI WahOpenNotificationHandleHelper ( OUT PHANDLE  HelperHandle)

Definition at line 49 of file notify.c.

50{
52
53 /* Enter the prolog, make sure we're initialized */
55 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
56
57 /* Validate handle */
58 if (!HelperHandle) return ERROR_INVALID_PARAMETER;
59
60 /* Return a bogus handle ("ROS2") */
61 *HelperHandle = HANH;
62 return ERROR_SUCCESS;
63}

◆ WahReferenceContextByHandle()

PWAH_HANDLE WINAPI WahReferenceContextByHandle ( IN PWAH_HANDLE_TABLE  Table,
IN HANDLE  Handle 
)

Definition at line 524 of file context.c.

526{
527 PWAH_HANDLE HashHandle;
528 PWAH_SEARCH_TABLE SearchTable;
531
532 /* Get the current Search Table */
534
535 /* Lock it */
536 AcquireReadLock(SearchTable, &Count);
537
538 /* Get the hash table and handle */
539 HashTable = SearchTable->HashTable;
540
541 /* Check if it's valid, and if it's the one we want */
542 if ((HashTable) &&
543 (HashHandle = WSH_HASH_FROM_HANDLE(Handle, HashTable)) &&
544 (HashHandle->Handle == Handle))
545 {
546 /* Reference the handle */
547 InterlockedIncrement(&HashHandle->RefCount);
548 }
549 else
550 {
551 /* Invalid handle */
552 HashHandle = NULL;
553 }
554
555 /* Release the lock */
556 ReleaseReadLock(SearchTable, Count);
557
558 /* Return */
559 return HashHandle;
560}
#define InterlockedIncrement
Definition: armddk.h:53
LONG RefCount
Definition: ws2help.h:14
HANDLE Handle
Definition: ws2help.h:15

Referenced by WsSockGetSocket(), and WsSockGetSocketNoExport().

◆ WahRemoveHandleContext()

DWORD WINAPI WahRemoveHandleContext ( IN PWAH_HANDLE_TABLE  Table,
IN PWAH_HANDLE  Handle 
)

Definition at line 564 of file context.c.

566{
567 PWAH_HANDLE *HashHandle;
568 PWAH_SEARCH_TABLE SearchTable;
571
572 /* Get the current Search Table */
573 SearchTable = WSH_SEARCH_TABLE_FROM_HANDLE(Handle->Handle, Table);
574
575 /* Lock it */
576 AcquireWriteLock(SearchTable);
577
578 /* Get the hash table and handle */
579 HashTable = SearchTable->HashTable;
580 HashHandle = &WSH_HASH_FROM_HANDLE(Handle->Handle, HashTable);
581
582 /* Make sure we have a handle, and write the new pointer */
583 if (HashHandle && (InterlockedCompareExchangePointer((PVOID*)HashHandle,
584 NULL,
585 Handle) == Handle))
586 {
587 /* Wait for everyone to be done with it */
588 TryWaitForReaders(SearchTable);
589 }
590 else
591 {
592 /* Invalid handle */
594 }
595
596 /* Release the lock */
597 ReleaseWriteLock(SearchTable);
598
599 /* Return */
600 return ErrorCode;
601}

Referenced by WsProcDetachSocket(), and WsSockDisassociateHandle().

◆ WahWaitForNotification()

INT WINAPI WahWaitForNotification ( IN HANDLE  NotificationHelperHandle,
IN HANDLE  lpNotificationHandle,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Definition at line 75 of file notify.c.

79{
80 UNREFERENCED_PARAMETER(NotificationHelperHandle);
81 UNREFERENCED_PARAMETER(lpNotificationHandle);
83 UNREFERENCED_PARAMETER(lpCompletionRoutine);
84 return 0;
85}
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93