ReactOS 0.4.16-dev-250-g3ecd236
apc.c File Reference
#include "precomp.h"
Include dependency graph for apc.c:

Go to the source code of this file.

Macros

#define APCH   (HANDLE)'SOR '
 

Functions

DWORD WINAPI WahOpenApcHelper (OUT PHANDLE ApcHelperHandle)
 
DWORD WINAPI WahCloseApcHelper (IN HANDLE ApcHelperHandle)
 
DWORD WINAPI WahCloseThread (IN HANDLE ApcHelperHandle, IN LPWSATHREADID ThreadId)
 
INT WINAPI WahQueueUserApc (IN HANDLE ApcHelperHandle, IN LPWSATHREADID ThreadId, IN LPWSAUSERAPC ApcRoutine, IN PVOID ApcContext OPTIONAL)
 
DWORD WINAPI WahOpenCurrentThread (IN HANDLE ApcHelperHandle, OUT LPWSATHREADID ThreadId)
 

Macro Definition Documentation

◆ APCH

#define APCH   (HANDLE)'SOR '

Definition at line 14 of file apc.c.

Function Documentation

◆ WahCloseApcHelper()

DWORD WINAPI WahCloseApcHelper ( IN HANDLE  ApcHelperHandle)

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().

◆ WahCloseThread()

DWORD WINAPI WahCloseThread ( IN HANDLE  ApcHelperHandle,
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
#define CloseHandle
Definition: compat.h:739
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by WsThreadDelete().

◆ 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  ApcHelperHandle,
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 FALSE
Definition: types.h:117
#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().

◆ WahQueueUserApc()

INT WINAPI WahQueueUserApc ( IN HANDLE  ApcHelperHandle,
IN LPWSATHREADID  ThreadId,
IN LPWSAUSERAPC  ApcRoutine,
IN PVOID ApcContext  OPTIONAL 
)

Definition at line 90 of file apc.c.

94{
95 /* Validate params */
96 if ((ApcHelperHandle != APCH) ||
97 (!ThreadId) ||
98 (!ThreadId->ThreadHandle) ||
99 (!ApcRoutine))
100 {
101 /* Invalid parameters */
103 }
104
105 /* Queue the APC */
106 if (QueueUserAPC(ApcRoutine, ThreadId->ThreadHandle, (ULONG_PTR)ApcContext))
107 {
108 /* Return success */
109 return ERROR_SUCCESS;
110 }
111
112 /* Fail */
113 return GetLastError();
114}
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:959
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID ApcContext
Definition: iofuncs.h:727
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE ApcRoutine
Definition: iofuncs.h:726
uint32_t ULONG_PTR
Definition: typedefs.h:65