2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 DLL
4 * FILE: include/ws2_32.h
5 * PURPOSE: WinSock 2 DLL header
8 /* INCLUDES ******************************************************************/
12 /* DATA **********************************************************************/
14 #define APCH (HANDLE)'SOR '
16 /* FUNCTIONS *****************************************************************/
20 WahOpenApcHelper(OUT PHANDLE ApcHelperHandle
)
24 /* Enter the prolog, make sure we're initialized */
25 ErrorCode
= WS2HELP_PROLOG();
26 if (ErrorCode
!= ERROR_SUCCESS
) return ErrorCode
;
29 if (!ApcHelperHandle
) return ERROR_INVALID_PARAMETER
;
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.
36 *ApcHelperHandle
= APCH
;
42 WahCloseApcHelper(IN HANDLE ApcHelperHandle
)
46 /* Enter the prolog, make sure we're initialized */
47 ErrorCode
= WS2HELP_PROLOG();
48 if (ErrorCode
!= ERROR_SUCCESS
) return ErrorCode
;
51 if (ApcHelperHandle
!= APCH
) return ERROR_INVALID_PARAMETER
;
59 WahCloseThread(IN HANDLE ApcHelperHandle
,
60 IN LPWSATHREADID ThreadId
)
64 /* Enter the prolog, make sure we're initialized */
65 ErrorCode
= WS2HELP_PROLOG();
66 if (ErrorCode
!= ERROR_SUCCESS
) return ErrorCode
;
68 /* Validate handles */
69 if ((ApcHelperHandle
!= APCH
) || (!ThreadId
) || (!ThreadId
->ThreadHandle
))
71 /* Invalid helper/thread handles */
72 return ERROR_INVALID_PARAMETER
;
75 /* Close the thread handle */
76 if (CloseHandle(ThreadId
->ThreadHandle
))
78 /* Clear the sturcture */
79 ThreadId
->ThreadHandle
= NULL
;
80 ThreadId
->Reserved
= 0;
85 return GetLastError();
90 WahQueueUserApc(IN HANDLE ApcHelperHandle
,
91 IN LPWSATHREADID ThreadId
,
92 IN LPWSAUSERAPC ApcRoutine
,
93 IN PVOID ApcContext OPTIONAL
)
96 if ((ApcHelperHandle
!= APCH
) ||
98 (!ThreadId
->ThreadHandle
) ||
101 /* Invalid parameters */
102 return ERROR_INVALID_PARAMETER
;
106 if (QueueUserAPC(ApcRoutine
, ThreadId
->ThreadHandle
, (ULONG_PTR
)ApcContext
))
109 return ERROR_SUCCESS
;
113 return GetLastError();
118 WahOpenCurrentThread(IN HANDLE ApcHelperHandle
,
119 OUT LPWSATHREADID ThreadId
)
121 HANDLE ProcessHandle
, ThreadHandle
;
123 /* Validate params */
124 if ((ApcHelperHandle
!= APCH
) || (!ThreadId
))
126 /* Invalid parameters */
127 return ERROR_INVALID_PARAMETER
;
130 /* Get the process/thread handles */
131 ProcessHandle
= GetCurrentProcess();
132 ThreadHandle
= GetCurrentThread();
134 /* Duplicate the handle */
135 if (DuplicateHandle(ProcessHandle
,
138 &ThreadId
->ThreadHandle
,
141 DUPLICATE_SAME_ACCESS
))
143 /* Save the thread handle and return */
144 ThreadId
->Reserved
= (DWORD_PTR
)ThreadHandle
;
145 return ERROR_SUCCESS
;
149 return GetLastError();