From 0f375710aa488428e1b5f43e6fcd29c6041222b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 23 Aug 2013 21:18:46 +0000 Subject: [PATCH] [NTOSKRNL] We aim at being compatible with Windows Server 2003... Do it better! Use the \GLOBAL?? dos-devices object directory instead of \??, as used in Windows NT and 2000 (which becomes per-session in Windows >= XP), but add a temporary hack (i.e. create a symbolic link \?? <---> \GLOBAL??) since we don't support yet Ob device mappings which are needed for this mapping, in particular. As a side-effect, fix starting of DeviceTree v2.30 on ReactOS. Now it works correctly, as on Win2k3 :) CORE-6572 #resolve #comment Finally fix loading of the objinfo driver, which failed at creating a symbolic link in \GLOBAL??\ for its device. svn path=/trunk/; revision=59803 --- reactos/ntoskrnl/ob/obname.c | 110 ++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 39 deletions(-) diff --git a/reactos/ntoskrnl/ob/obname.c b/reactos/ntoskrnl/ob/obname.c index 38e0574c50e..0744da0cb7f 100644 --- a/reactos/ntoskrnl/ob/obname.c +++ b/reactos/ntoskrnl/ob/obname.c @@ -37,56 +37,27 @@ INIT_FUNCTION ObpCreateDosDevicesDirectory(VOID) { OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING Name, LinkName; + UNICODE_STRING RootName, TargetName, LinkName; HANDLE Handle, SymHandle; NTSTATUS Status; - /* Create the '\??' directory */ - RtlInitUnicodeString(&Name, L"\\??"); + /* Create the global DosDevices directory \?? */ + RtlInitUnicodeString(&RootName, L"\\GLOBAL??"); InitializeObjectAttributes(&ObjectAttributes, - &Name, + &RootName, OBJ_PERMANENT, NULL, NULL); Status = NtCreateDirectoryObject(&Handle, DIRECTORY_ALL_ACCESS, &ObjectAttributes); - if (!NT_SUCCESS(Status)) return FALSE; - - /* Initialize the GLOBALROOT path */ - RtlInitUnicodeString(&LinkName, L"GLOBALROOT"); - RtlInitUnicodeString(&Name, L""); - InitializeObjectAttributes(&ObjectAttributes, - &LinkName, - OBJ_PERMANENT, - Handle, - NULL); - Status = NtCreateSymbolicLinkObject(&SymHandle, - SYMBOLIC_LINK_ALL_ACCESS, - &ObjectAttributes, - &Name); - if (NT_SUCCESS(Status)) NtClose(SymHandle); - - /* Link \??\Global to \?? */ - RtlInitUnicodeString(&LinkName, L"Global"); - RtlInitUnicodeString(&Name, L"\\??"); - InitializeObjectAttributes(&ObjectAttributes, - &LinkName, - OBJ_PERMANENT, - Handle, - NULL); - Status = NtCreateSymbolicLinkObject(&SymHandle, - SYMBOLIC_LINK_ALL_ACCESS, - &ObjectAttributes, - &Name); - if (NT_SUCCESS(Status)) NtClose(SymHandle); - - /* Close the directory handle */ - NtClose(Handle); if (!NT_SUCCESS(Status)) return Status; - /* Create link from '\DosDevices' to '\??' directory */ - RtlCreateUnicodeString(&LinkName, L"\\DosDevices"); + /*********************************************\ + |*** HACK until we support device mappings ***| + |*** Add a symlink \??\ <--> \GLOBAL??\ ***| + \*********************************************/ + RtlInitUnicodeString(&LinkName, L"\\??"); InitializeObjectAttributes(&ObjectAttributes, &LinkName, OBJ_PERMANENT, @@ -95,7 +66,68 @@ ObpCreateDosDevicesDirectory(VOID) Status = NtCreateSymbolicLinkObject(&SymHandle, SYMBOLIC_LINK_ALL_ACCESS, &ObjectAttributes, - &Name); + &RootName); + if (NT_SUCCESS(Status)) NtClose(SymHandle); + /*********************************************\ + \*********************************************/ + + // FIXME: Create a device mapping for the global \?? directory + + /* + * Initialize the \??\GLOBALROOT symbolic link + * pointing to the root directory \ . + */ + RtlInitUnicodeString(&LinkName, L"GLOBALROOT"); + RtlInitUnicodeString(&TargetName, L""); + InitializeObjectAttributes(&ObjectAttributes, + &LinkName, + OBJ_PERMANENT, + Handle, + NULL); + Status = NtCreateSymbolicLinkObject(&SymHandle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes, + &TargetName); + if (NT_SUCCESS(Status)) NtClose(SymHandle); + + /* + * Initialize the \??\Global symbolic link pointing to the global + * DosDevices directory \?? . It is used to access the global \?? + * by user-mode components which, by default, use a per-session + * DosDevices directory. + */ + RtlInitUnicodeString(&LinkName, L"Global"); + InitializeObjectAttributes(&ObjectAttributes, + &LinkName, + OBJ_PERMANENT, + Handle, + NULL); + Status = NtCreateSymbolicLinkObject(&SymHandle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes, + &RootName); + if (NT_SUCCESS(Status)) NtClose(SymHandle); + + /* Close the directory handle */ + NtClose(Handle); + if (!NT_SUCCESS(Status)) return Status; + + /* + * Initialize the \DosDevices symbolic link pointing to the global + * DosDevices directory \?? , for backward compatibility with + * Windows NT-2000 systems. + */ + RtlCreateUnicodeString(&LinkName, L"\\DosDevices"); + RtlInitUnicodeString(&RootName, (PCWSTR)&ObpDosDevicesShortNameRoot); + InitializeObjectAttributes(&ObjectAttributes, + &LinkName, + OBJ_PERMANENT, + NULL, + NULL); + Status = NtCreateSymbolicLinkObject(&SymHandle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes, + &RootName); if (NT_SUCCESS(Status)) NtClose(SymHandle); /* FIXME: Hack Hack! */