[NTOSKRNL] Partly implement FsRtlRegisterUncProvider/FsRtlDeregisterUncProvider
authorHervé Poussineau <hpoussin@reactos.org>
Sat, 27 Sep 2014 21:07:48 +0000 (21:07 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Sat, 27 Sep 2014 21:07:48 +0000 (21:07 +0000)
Currently only support one UNC provider at the time. Also disable mup.sys, which is not used for now.

svn path=/trunk/; revision=64358

reactos/boot/bootdata/hivesys.inf
reactos/ntoskrnl/fsrtl/unc.c

index 23c775a..be1ca66 100644 (file)
@@ -1266,7 +1266,7 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices","MAILSLOT",0
 HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices","NUL",0x00000000,"\Device\Null"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices","PIPE",0x00000000,"\Device\NamedPipe"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices","PRN",0x00000000,"\DosDevices\LPT1"
-HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices","UNC",0x00000000,"\Device\Mup"
+;HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices","UNC",0x00000000,"\Device\Mup"
 
 ; System environment settings
 HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Environment","ComSpec",0x00020000,"%SystemRoot%\system32\cmd.exe"
@@ -1509,13 +1509,13 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Msfs","Start",0x00010001,0x00000001
 HKLM,"SYSTEM\CurrentControlSet\Services\Msfs","Type",0x00010001,0x00000002
 
 ; Multiple UNC provider driver
-HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Description",0x00000000,"Multiple UNC Provider (MUP)"
-HKLM,"SYSTEM\CurrentControlSet\Services\Mup","ErrorControl",0x00010001,0x00000001
+;HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Description",0x00000000,"Multiple UNC Provider (MUP)"
+;HKLM,"SYSTEM\CurrentControlSet\Services\Mup","ErrorControl",0x00010001,0x00000001
 ;HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Group",0x00000000,"Network"
-HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Group",0x00000000,"File System"
-HKLM,"SYSTEM\CurrentControlSet\Services\Mup","ImagePath",0x00020000,"system32\drivers\mup.sys"
-HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Start",0x00010001,0x00000000
-HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Type",0x00010001,0x00000002
+;HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Group",0x00000000,"File System"
+;HKLM,"SYSTEM\CurrentControlSet\Services\Mup","ImagePath",0x00020000,"system32\drivers\mup.sys"
+;HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Start",0x00010001,0x00000000
+;HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Type",0x00010001,0x00000002
 
 ; NDIS driver - the only boot-start network driver
 HKLM,"SYSTEM\CurrentControlSet\Services\Ndis","ErrorControl",0x00010001,0x00000001
index 8f68e8f..90ffbf1 100644 (file)
@@ -32,8 +32,18 @@ VOID
 NTAPI
 FsRtlDeregisterUncProvider(IN HANDLE Handle)
 {
-    /* Unimplemented */
-    KeBugCheck(FILE_SYSTEM);
+    UNICODE_STRING DosDevicesUNC = RTL_CONSTANT_STRING(L"\\DosDevices\\UNC");
+
+    DPRINT("FsRtlDeregisterUncProvider: Handle=%p\n", Handle);
+    //
+    // Normal implementation should look like:
+    // - notify mup.sys?
+    // - at last deregistration, destroy \DosDevices\UNC symbolic link
+    //
+
+    ZwClose(Handle);
+
+    IoDeleteSymbolicLink(&DosDevicesUNC);
 }
 
 /*++
@@ -61,7 +71,64 @@ FsRtlRegisterUncProvider(IN OUT PHANDLE Handle,
                          IN PUNICODE_STRING RedirectorDeviceName,
                          IN BOOLEAN MailslotsSupported)
 {
-    /* Unimplemented */
-    KeBugCheck(FILE_SYSTEM);
-    return STATUS_NOT_IMPLEMENTED;
+    UNICODE_STRING DevNull = RTL_CONSTANT_STRING(L"\\Device\\Null");
+    UNICODE_STRING DosDevicesUNC = RTL_CONSTANT_STRING(L"\\DosDevices\\UNC");
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    IO_STATUS_BLOCK Iosb;
+    HANDLE FileHandle;
+    NTSTATUS Status;
+
+    DPRINT("FsRtlRegisterUncProvider: Redirector=%wZ MailslotsSupported=%d\n",
+           RedirectorDeviceName, MailslotsSupported);
+
+    //
+    // Current implementation is a hack, as it only supports one UNC provider.
+    // However, it doesn't require to have a functional mup.sys driver.
+    //
+
+    //
+    // Normal implementation should look like:
+    // - at registration 1, creates symlink \DosDevices\UNC to new provider;
+    //   returns handle to \Device\Null
+    // - at registration 2, load mup.sys, register both providers to mup.sys
+    //   and change \DosDevices\UNC to DD_MUP_DEVICE_NAME;
+    //   returns handle to new provider
+    // - at next registrations, register provider to mup.sys;
+    //   returns handle to new provider
+    //
+
+    *Handle = (HANDLE)-1;
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &DevNull,
+                               OBJ_KERNEL_HANDLE,
+                               NULL,
+                               NULL);
+    Status = ZwCreateFile(&FileHandle,
+                          GENERIC_WRITE,
+                          &ObjectAttributes,
+                          &Iosb,
+                          NULL,
+                          FILE_ATTRIBUTE_NORMAL,
+                          FILE_SHARE_READ | FILE_SHARE_WRITE,
+                          FILE_OPEN,
+                          0,
+                          NULL,
+                          0);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT("Failed to open %wZ\n", &DevNull);
+        return Status;
+    }
+
+    Status = IoCreateSymbolicLink(&DosDevicesUNC, RedirectorDeviceName);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT("Failed to create symbolic link %wZ -> %wZ\n", &DosDevicesUNC, RedirectorDeviceName);
+        DPRINT1("FIXME: multiple unc provider registered?\n");
+        ZwClose(FileHandle);
+        return Status;
+    }
+
+    *Handle = FileHandle;
+    return STATUS_SUCCESS;
 }