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;
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /*********************************************\
+ |*** HACK until we support device mappings ***|
+ |*** Add a symlink \??\ <--> \GLOBAL??\ ***|
+ \*********************************************/
+ RtlInitUnicodeString(&LinkName, L"\\??");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &LinkName,
+ OBJ_PERMANENT,
+ NULL,
+ NULL);
+ Status = NtCreateSymbolicLinkObject(&SymHandle,
+ SYMBOLIC_LINK_ALL_ACCESS,
+ &ObjectAttributes,
+ &RootName);
+ if (NT_SUCCESS(Status)) NtClose(SymHandle);
+ /*********************************************\
+ \*********************************************/
+
+ // FIXME: Create a device mapping for the global \?? directory
- /* Initialize the GLOBALROOT path */
+ /*
+ * Initialize the \??\GLOBALROOT symbolic link
+ * pointing to the root directory \ .
+ */
RtlInitUnicodeString(&LinkName, L"GLOBALROOT");
- RtlInitUnicodeString(&Name, L"");
+ RtlInitUnicodeString(&TargetName, L"");
InitializeObjectAttributes(&ObjectAttributes,
&LinkName,
OBJ_PERMANENT,
Status = NtCreateSymbolicLinkObject(&SymHandle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes,
- &Name);
+ &TargetName);
if (NT_SUCCESS(Status)) NtClose(SymHandle);
- /* Link \??\Global to \?? */
+ /*
+ * 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");
- RtlInitUnicodeString(&Name, L"\\??");
InitializeObjectAttributes(&ObjectAttributes,
&LinkName,
OBJ_PERMANENT,
Status = NtCreateSymbolicLinkObject(&SymHandle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes,
- &Name);
+ &RootName);
if (NT_SUCCESS(Status)) NtClose(SymHandle);
/* Close the directory handle */
NtClose(Handle);
if (!NT_SUCCESS(Status)) return Status;
- /* Create link from '\DosDevices' to '\??' directory */
+ /*
+ * 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,
Status = NtCreateSymbolicLinkObject(&SymHandle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes,
- &Name);
+ &RootName);
if (NT_SUCCESS(Status)) NtClose(SymHandle);
/* FIXME: Hack Hack! */
}
else if (!(ObjectName->Length) || !(ObjectName->Buffer))
{
- /* Just return the Root Directory if we didn't get a name*/
+ /* Just return the Root Directory if we didn't get a name */
Status = ObReferenceObjectByPointer(RootDirectory,
0,
ObjectType,
if (ObjectNameInfo->Name.Buffer)
{
/* Free it */
- ExFreePoolWithTag(ObjectNameInfo->Name.Buffer, OB_NAME_TAG );
+ ExFreePoolWithTag(ObjectNameInfo->Name.Buffer, OB_NAME_TAG);
}
/* Write new one */
/* Reparse again */
Reparse = TRUE;
--MaxReparse;
+ if (MaxReparse == 0)
+ {
+ Object = NULL;
+ break;
+ }
/* Start over from root if we got sent back there */
if ((Status == STATUS_REPARSE_OBJECT) ||
ObjectName = (PWCH)((ULONG_PTR)ObjectName -
sizeof(L"...") +
sizeof(UNICODE_NULL));
- RtlCopyMemory(ObjectName,
- L"...",
- sizeof(L"...") + sizeof(UNICODE_NULL));
+ RtlCopyMemory(ObjectName, L"...", sizeof(L"..."));
break;
}
}