[AfD]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 20 Feb 2014 21:41:33 +0000 (21:41 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 20 Feb 2014 21:41:33 +0000 (21:41 +0000)
In AfdBindSocket, open a usermode handle and return that to the caller, instead of returning the kernel mode handle.

svn path=/trunk/; revision=62272

reactos/drivers/network/afd/afd/bind.c

index e16ab26..a66e967 100644 (file)
@@ -77,6 +77,7 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
     PFILE_OBJECT FileObject = IrpSp->FileObject;
     PAFD_FCB FCB = FileObject->FsContext;
     PAFD_BIND_DATA BindReq;
     PFILE_OBJECT FileObject = IrpSp->FileObject;
     PAFD_FCB FCB = FileObject->FsContext;
     PAFD_BIND_DATA BindReq;
+    HANDLE UserHandle;
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
 
     UNREFERENCED_PARAMETER(DeviceObject);
 
@@ -99,9 +100,20 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
     AFD_DbgPrint(MID_TRACE,("FCB->Flags %x\n", FCB->Flags));
 
     if (NT_SUCCESS(Status))
     AFD_DbgPrint(MID_TRACE,("FCB->Flags %x\n", FCB->Flags));
 
     if (NT_SUCCESS(Status))
-        FCB->State = SOCKET_STATE_BOUND;
+    {
+        UserHandle = NULL;
+        Status = ObOpenObjectByPointer(FCB->AddressFile.Object,
+                                       0,
+                                       NULL,
+                                       MAXIMUM_ALLOWED,
+                                       IoFileObjectType,
+                                       Irp->RequestorMode,
+                                       &UserHandle);
+        if (NT_SUCCESS(Status))
+            FCB->State = SOCKET_STATE_BOUND;
+    }
 
     /* MSAFD relies on us returning the address file handle in the IOSB */
     return UnlockAndMaybeComplete( FCB, Status, Irp,
 
     /* MSAFD relies on us returning the address file handle in the IOSB */
     return UnlockAndMaybeComplete( FCB, Status, Irp,
-                                   (ULONG_PTR)FCB->AddressFile.Handle );
+                                   (ULONG_PTR)UserHandle);
 }
 }