From 36fed67fe3683fd9cb0b23c8cdd080a8e06077d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sat, 27 Sep 2014 21:07:48 +0000 Subject: [PATCH] [NTOSKRNL] Partly implement FsRtlRegisterUncProvider/FsRtlDeregisterUncProvider 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 | 14 +++--- reactos/ntoskrnl/fsrtl/unc.c | 77 +++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 12 deletions(-) diff --git a/reactos/boot/bootdata/hivesys.inf b/reactos/boot/bootdata/hivesys.inf index 23c775acac7..be1ca6678a6 100644 --- a/reactos/boot/bootdata/hivesys.inf +++ b/reactos/boot/bootdata/hivesys.inf @@ -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 diff --git a/reactos/ntoskrnl/fsrtl/unc.c b/reactos/ntoskrnl/fsrtl/unc.c index 8f68e8fdb63..90ffbf1aa69 100644 --- a/reactos/ntoskrnl/fsrtl/unc.c +++ b/reactos/ntoskrnl/fsrtl/unc.c @@ -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; }