ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

bhook.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS WinSock 2 API
00004  * FILE:        bhook.c
00005  * PURPOSE:     Blocking Hook support for 1.x clients
00006  * PROGRAMMER:  Alex Ionescu (alex@relsoft.net)
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 #include "ws2_32.h"
00011 
00012 //#define NDEBUG
00013 #include <debug.h>
00014 
00015 /* DATA **********************************************************************/
00016 
00017 /* FUNCTIONS *****************************************************************/
00018 
00019 /*
00020  * @implemented
00021  */
00022 INT
00023 WSAAPI
00024 WSACancelBlockingCall(VOID)
00025 {
00026     PWSPROCESS Process;
00027     PWSTHREAD Thread;
00028     INT ErrorCode;
00029     DPRINT("WSACancelBlockingCall\n");
00030 
00031     /* Call the prolog */
00032     ErrorCode = WsApiProlog(&Process, &Thread);
00033     if (ErrorCode != ERROR_SUCCESS)
00034     {
00035         /* Fail */
00036         SetLastError(ErrorCode);
00037         return SOCKET_ERROR;
00038     }
00039 
00040     /* Make sure this isn't a 2.2 client */
00041     if (LOBYTE(Process->Version) >= 2)
00042     {
00043         /* Only valid for 1.x */
00044         SetLastError(WSAEOPNOTSUPP);
00045         return SOCKET_ERROR;
00046     }
00047 
00048     /* Cancel the call */
00049     ErrorCode = WsThreadCancelBlockingCall(Thread);
00050     if (ErrorCode != ERROR_SUCCESS)
00051     {
00052         /* Fail */
00053         SetLastError(ErrorCode);
00054         return ErrorCode;
00055     }
00056 
00057     /* Return success */
00058     return ERROR_SUCCESS;
00059 }
00060 
00061 /*
00062  * @implemented
00063  */
00064 BOOL
00065 WSAAPI
00066 WSAIsBlocking(VOID)
00067 {
00068     PWSPROCESS Process;
00069     PWSTHREAD Thread;
00070     INT ErrorCode;
00071     DPRINT("WSAIsBlocking\n");
00072 
00073     /* Call the prolog */
00074     ErrorCode = WsApiProlog(&Process, &Thread);
00075     if (ErrorCode != ERROR_SUCCESS)
00076     {
00077         /* Fail unless its because we're busy */
00078         if (ErrorCode != WSAEINPROGRESS) return FALSE;
00079     }
00080 
00081     /* Return the value from the thread */
00082     return Thread->Blocking;
00083 }
00084 
00085 /*
00086  * @implemented
00087  */
00088 FARPROC
00089 WSAAPI
00090 WSASetBlockingHook(IN FARPROC lpBlockFunc)
00091 {
00092     PWSPROCESS Process;
00093     PWSTHREAD Thread;
00094     INT ErrorCode;
00095     DPRINT("WSASetBlockingHook: %p\n", lpBlockFunc);
00096 
00097     /* Call the prolog */
00098     ErrorCode = WsApiProlog(&Process, &Thread);
00099     if (ErrorCode != ERROR_SUCCESS)
00100     {
00101         /* Fail */
00102         SetLastError(ErrorCode);
00103         return NULL;
00104     }
00105 
00106     /* Make sure this isn't a 2.2 client */
00107     if (LOBYTE(Process->Version) >= 2)
00108     {
00109         /* Only valid for 1.x */
00110         SetLastError(WSAEOPNOTSUPP);
00111         return NULL;
00112     }
00113 
00114     /* Make sure the pointer is safe */
00115     if (IsBadCodePtr(lpBlockFunc))
00116     {
00117         /* Invalid pointer */
00118         SetLastError(WSAEFAULT);
00119         return NULL;
00120     }
00121 
00122     /* Set the blocking hook and return the previous one */
00123     return WsThreadSetBlockingHook(Thread, lpBlockFunc);
00124 }
00125 
00126 /*
00127  * @implemented
00128  */
00129 INT
00130 WSAAPI
00131 WSAUnhookBlockingHook(VOID)
00132 {
00133     PWSPROCESS Process;
00134     PWSTHREAD Thread;
00135     INT ErrorCode;
00136     DPRINT("WSAUnhookBlockingHook\n");
00137 
00138     /* Call the prolog */
00139     ErrorCode = WsApiProlog(&Process, &Thread);
00140     if (ErrorCode != ERROR_SUCCESS)
00141     {
00142         /* Fail */
00143         SetLastError(ErrorCode);
00144         return SOCKET_ERROR;
00145     }
00146 
00147     /* Make sure this isn't a 2.2 client */
00148     if (LOBYTE(Process->Version) >= 2)
00149     {
00150         /* Only valid for 1.x */
00151         SetLastError(WSAEOPNOTSUPP);
00152         return SOCKET_ERROR;
00153     }
00154 
00155     /* Set the blocking hook and return the previous one */
00156     return WsThreadUnhookBlockingHook(Thread);
00157 }

Generated on Sat May 26 2012 04:25:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.