ReactOS 0.4.15-dev-8116-gf69e256
bhook.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
4 * FILE: dll/win32/ws2_32/src/bhook.c
5 * PURPOSE: Blocking Hook support for 1.x clients
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include <ws2_32.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* FUNCTIONS *****************************************************************/
17
18/*
19 * @implemented
20 */
21INT
24{
28 DPRINT("WSACancelBlockingCall\n");
29
30 /* Call the prolog */
33 {
34 /* Fail */
36 return SOCKET_ERROR;
37 }
38
39 /* Make sure this isn't a 2.2 client */
40 if (LOBYTE(Process->Version) >= 2)
41 {
42 /* Only valid for 1.x */
44 return SOCKET_ERROR;
45 }
46
47 /* Cancel the call */
50 {
51 /* Fail */
53 return SOCKET_ERROR;
54 }
55
56 /* Return success */
57 return ERROR_SUCCESS;
58}
59
60/*
61 * @implemented
62 */
63BOOL
66{
70 DPRINT("WSAIsBlocking\n");
71
72 /* Call the prolog */
75 {
76 /* Fail unless its because we're busy */
77 if (ErrorCode != WSAEINPROGRESS) return FALSE;
78 }
79
80 /* Return the value from the thread */
81 return Thread->Blocking;
82}
83
84/*
85 * @implemented
86 */
90{
94 DPRINT("WSASetBlockingHook: %p\n", lpBlockFunc);
95
96 /* Call the prolog */
99 {
100 /* Fail */
102 return NULL;
103 }
104
105 /* Make sure this isn't a 2.2 client */
106 if (LOBYTE(Process->Version) >= 2)
107 {
108 /* Only valid for 1.x */
110 return NULL;
111 }
112
113 /* Make sure the pointer is safe */
114 if (IsBadCodePtr(lpBlockFunc))
115 {
116 /* Invalid pointer */
118 return NULL;
119 }
120
121 /* Set the blocking hook and return the previous one */
122 return WsThreadSetBlockingHook(Thread, lpBlockFunc);
123}
124
125/*
126 * @implemented
127 */
128INT
129WSAAPI
131{
135 DPRINT("WSAUnhookBlockingHook\n");
136
137 /* Call the prolog */
140 {
141 /* Fail */
143 return SOCKET_ERROR;
144 }
145
146 /* Make sure this isn't a 2.2 client */
147 if (LOBYTE(Process->Version) >= 2)
148 {
149 /* Only valid for 1.x */
151 return SOCKET_ERROR;
152 }
153
154 /* Set the blocking hook and return the previous one */
156}
FARPROC WSAAPI WSASetBlockingHook(IN FARPROC lpBlockFunc)
Definition: bhook.c:89
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
int(* FARPROC)()
Definition: compat.h:36
#define SetLastError(x)
Definition: compat.h:752
BOOL NTAPI IsBadCodePtr(FARPROC lpfn)
Definition: except.c:872
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define LOBYTE(W)
Definition: jmemdos.c:487
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define DPRINT
Definition: sndvol32.h:73
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
#define WSAEOPNOTSUPP
Definition: winerror.h:1958
#define WSAEINPROGRESS
Definition: winerror.h:1949
#define WSAEFAULT
Definition: winerror.h:1945
#define WSAAPI
Definition: winsock2.h:605
BOOL PASCAL FAR WSAIsBlocking(void)
Definition: bhook.c:65
int PASCAL FAR WSACancelBlockingCall(void)
Definition: bhook.c:23
#define SOCKET_ERROR
Definition: winsock.h:333
int PASCAL FAR WSAUnhookBlockingHook(void)
Definition: bhook.c:130
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
DWORD WSAAPI WsThreadCancelBlockingCall(IN PWSTHREAD Thread)
Definition: dthread.c:96
FARPROC WSAAPI WsThreadSetBlockingHook(IN PWSTHREAD Thread, IN FARPROC BlockingHook)
Definition: dthread.c:60
DWORD WSAAPI WsThreadUnhookBlockingHook(IN PWSTHREAD Thread)
Definition: dthread.c:84