[MSAFD]
authorCameron Gutman <aicommander@gmail.com>
Thu, 12 Aug 2010 13:13:19 +0000 (13:13 +0000)
committerCameron Gutman <aicommander@gmail.com>
Thu, 12 Aug 2010 13:13:19 +0000 (13:13 +0000)
- Update lpcbBytesReturned when FIONREAD is called
- Fix the value inside lpErrno when XxxSocketInformation() fails
- Pass the unrecognized IOCTLs to the winsock helper (no behavior change for this yet because wshtcpip's WSHIoctl is unimplemented)

svn path=/trunk/; revision=48522

reactos/dll/win32/msafd/misc/dllmain.c

index a5e33ae..66cf285 100644 (file)
@@ -1910,6 +1910,7 @@ WSPIoctl(IN  SOCKET Handle,
          OUT LPINT lpErrno)
 {
     PSOCKET_INFORMATION Socket = NULL;
          OUT LPINT lpErrno)
 {
     PSOCKET_INFORMATION Socket = NULL;
+       BOOLEAN NeedsCompletion;
 
     /* Get the Socket Structure associate to this Socket*/
     Socket = GetSocketStructure(Handle);
 
     /* Get the Socket Structure associate to this Socket*/
     Socket = GetSocketStructure(Handle);
@@ -1918,6 +1919,8 @@ WSPIoctl(IN  SOCKET Handle,
        *lpErrno = WSAENOTSOCK;
        return SOCKET_ERROR;
     }
        *lpErrno = WSAENOTSOCK;
        return SOCKET_ERROR;
     }
+       
+       *lpcbBytesReturned = 0;
 
     switch( dwIoControlCode )
     {
 
     switch( dwIoControlCode )
     {
@@ -1928,17 +1931,44 @@ WSPIoctl(IN  SOCKET Handle,
                 return SOCKET_ERROR;
             }
             Socket->SharedData.NonBlocking = *((PULONG)lpvInBuffer) ? 1 : 0;
                 return SOCKET_ERROR;
             }
             Socket->SharedData.NonBlocking = *((PULONG)lpvInBuffer) ? 1 : 0;
-            return SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, (PULONG)lpvInBuffer, NULL);
+            *lpErrno = SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, (PULONG)lpvInBuffer, NULL);
+                       if (*lpErrno != NO_ERROR)
+                               return SOCKET_ERROR;
+                       else
+                               return NO_ERROR;
         case FIONREAD:
             if( cbOutBuffer < sizeof(INT) || IS_INTRESOURCE(lpvOutBuffer) )
             {
                 *lpErrno = WSAEFAULT;
                 return SOCKET_ERROR;
             }
         case FIONREAD:
             if( cbOutBuffer < sizeof(INT) || IS_INTRESOURCE(lpvOutBuffer) )
             {
                 *lpErrno = WSAEFAULT;
                 return SOCKET_ERROR;
             }
-            return GetSocketInformation(Socket, AFD_INFO_RECEIVE_CONTENT_SIZE, (PULONG)lpvOutBuffer, NULL);
+            *lpErrno = GetSocketInformation(Socket, AFD_INFO_RECEIVE_CONTENT_SIZE, (PULONG)lpvOutBuffer, NULL);
+                       if (*lpErrno != NO_ERROR)
+                       {
+                               *lpcbBytesReturned = sizeof(ULONG);
+                               return SOCKET_ERROR;
+                       }
+                       else
+                               return NO_ERROR;
         default:
         default:
-            *lpErrno = WSAEINVAL;
-            return SOCKET_ERROR;
+                       *lpErrno = Socket->HelperData->WSHIoctl(Socket->HelperContext,
+                                                                                                       Handle,
+                                                                                                       Socket->TdiAddressHandle,
+                                                                                                       Socket->TdiConnectionHandle,
+                                                                                                       dwIoControlCode,
+                                                                                                       lpvInBuffer,
+                                                                                                       cbInBuffer,
+                                                                                                       lpvOutBuffer,
+                                                                                                       cbOutBuffer,
+                                                                                                       lpcbBytesReturned,
+                                                                                                       lpOverlapped,
+                                                                                                       lpCompletionRoutine,
+                                                                                                       (LPBOOL)&NeedsCompletion);
+                       
+                       if (*lpErrno != NO_ERROR)
+                               return SOCKET_ERROR;
+                       else
+                               return NO_ERROR;
     }
 }
 
     }
 }