2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
5 * PURPOSE: Blocking Hook support for 1.x clients
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
9 /* INCLUDES ******************************************************************/
15 /* DATA **********************************************************************/
17 /* FUNCTIONS *****************************************************************/
24 WSACancelBlockingCall(VOID
)
29 DPRINT("WSACancelBlockingCall\n");
32 ErrorCode
= WsApiProlog(&Process
, &Thread
);
33 if (ErrorCode
!= ERROR_SUCCESS
)
36 SetLastError(ErrorCode
);
40 /* Make sure this isn't a 2.2 client */
41 if (LOBYTE(Process
->Version
) >= 2)
43 /* Only valid for 1.x */
44 SetLastError(WSAEOPNOTSUPP
);
49 ErrorCode
= WsThreadCancelBlockingCall(Thread
);
50 if (ErrorCode
!= ERROR_SUCCESS
)
53 SetLastError(ErrorCode
);
71 DPRINT("WSAIsBlocking\n");
74 ErrorCode
= WsApiProlog(&Process
, &Thread
);
75 if (ErrorCode
!= ERROR_SUCCESS
)
77 /* Fail unless its because we're busy */
78 if (ErrorCode
!= WSAEINPROGRESS
) return FALSE
;
81 /* Return the value from the thread */
82 return Thread
->Blocking
;
90 WSASetBlockingHook(IN FARPROC lpBlockFunc
)
95 DPRINT("WSASetBlockingHook: %p\n", lpBlockFunc
);
98 ErrorCode
= WsApiProlog(&Process
, &Thread
);
99 if (ErrorCode
!= ERROR_SUCCESS
)
102 SetLastError(ErrorCode
);
106 /* Make sure this isn't a 2.2 client */
107 if (LOBYTE(Process
->Version
) >= 2)
109 /* Only valid for 1.x */
110 SetLastError(WSAEOPNOTSUPP
);
114 /* Make sure the pointer is safe */
115 if (IsBadCodePtr(lpBlockFunc
))
117 /* Invalid pointer */
118 SetLastError(WSAEFAULT
);
122 /* Set the blocking hook and return the previous one */
123 return WsThreadSetBlockingHook(Thread
, lpBlockFunc
);
131 WSAUnhookBlockingHook(VOID
)
136 DPRINT("WSAUnhookBlockingHook\n");
138 /* Call the prolog */
139 ErrorCode
= WsApiProlog(&Process
, &Thread
);
140 if (ErrorCode
!= ERROR_SUCCESS
)
143 SetLastError(ErrorCode
);
147 /* Make sure this isn't a 2.2 client */
148 if (LOBYTE(Process
->Version
) >= 2)
150 /* Only valid for 1.x */
151 SetLastError(WSAEOPNOTSUPP
);
155 /* Set the blocking hook and return the previous one */
156 return WsThreadUnhookBlockingHook(Thread
);