ReactOS  0.4.14-dev-1314-gacf135d
bhook.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for bhook.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

INT WSAAPI WSACancelBlockingCall (VOID)
 
BOOL WSAAPI WSAIsBlocking (VOID)
 
FARPROC WSAAPI WSASetBlockingHook (IN FARPROC lpBlockFunc)
 
INT WSAAPI WSAUnhookBlockingHook (VOID)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file bhook.c.

Function Documentation

◆ WSACancelBlockingCall()

INT WSAAPI WSACancelBlockingCall ( VOID  )

Definition at line 23 of file bhook.c.

24 {
27  INT ErrorCode;
28  DPRINT("WSACancelBlockingCall\n");
29 
30  /* Call the prolog */
32  if (ErrorCode != ERROR_SUCCESS)
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 */
49  if (ErrorCode != ERROR_SUCCESS)
50  {
51  /* Fail */
53  return SOCKET_ERROR;
54  }
55 
56  /* Return success */
57  return ERROR_SUCCESS;
58 }
#define SOCKET_ERROR
Definition: winsock.h:333
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LOBYTE(W)
Definition: jmemdos.c:487
int32_t INT
Definition: typedefs.h:57
#define WSAEOPNOTSUPP
Definition: winerror.h:1958
void DPRINT(...)
Definition: polytest.cpp:61
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:417
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
DWORD WSAAPI WsThreadCancelBlockingCall(IN PWSTHREAD Thread)
Definition: dthread.c:96

Referenced by AreLegacyFunctionsSupported(), and WsAsyncThreadBlockingHook().

◆ WSAIsBlocking()

BOOL WSAAPI WSAIsBlocking ( VOID  )

Definition at line 65 of file bhook.c.

66 {
69  INT ErrorCode;
70  DPRINT("WSAIsBlocking\n");
71 
72  /* Call the prolog */
74  if (ErrorCode != ERROR_SUCCESS)
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 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WSAEINPROGRESS
Definition: winerror.h:1949
int32_t INT
Definition: typedefs.h:57
void DPRINT(...)
Definition: polytest.cpp:61
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ WSASetBlockingHook()

FARPROC WSAAPI WSASetBlockingHook ( IN FARPROC  lpBlockFunc)

Definition at line 89 of file bhook.c.

90 {
93  INT ErrorCode;
94  DPRINT("WSASetBlockingHook: %p\n", lpBlockFunc);
95 
96  /* Call the prolog */
98  if (ErrorCode != ERROR_SUCCESS)
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 }
#define WSAEFAULT
Definition: winerror.h:1945
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LOBYTE(W)
Definition: jmemdos.c:487
int32_t INT
Definition: typedefs.h:57
#define WSAEOPNOTSUPP
Definition: winerror.h:1958
BOOL NTAPI IsBadCodePtr(FARPROC lpfn)
Definition: except.c:874
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:417
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
FARPROC WSAAPI WsThreadSetBlockingHook(IN PWSTHREAD Thread, IN FARPROC BlockingHook)
Definition: dthread.c:60

Referenced by WsAsyncThread().

◆ WSAUnhookBlockingHook()

INT WSAAPI WSAUnhookBlockingHook ( VOID  )

Definition at line 130 of file bhook.c.

131 {
134  INT ErrorCode;
135  DPRINT("WSAUnhookBlockingHook\n");
136 
137  /* Call the prolog */
139  if (ErrorCode != ERROR_SUCCESS)
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 }
#define SOCKET_ERROR
Definition: winsock.h:333
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LOBYTE(W)
Definition: jmemdos.c:487
int32_t INT
Definition: typedefs.h:57
#define WSAEOPNOTSUPP
Definition: winerror.h:1958
DWORD WSAAPI WsThreadUnhookBlockingHook(IN PWSTHREAD Thread)
Definition: dthread.c:84
void DPRINT(...)
Definition: polytest.cpp:61
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:417
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219