2013-03-16 20:08:56 +00:00
|
|
|
/*
|
2002-10-29 18:40:02 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS text-mode setup
|
2015-09-13 16:40:36 +00:00
|
|
|
* FILE: base/setup/usetup/drivesup.c
|
2002-10-29 18:40:02 +00:00
|
|
|
* PURPOSE: Drive support functions
|
2018-05-27 19:33:07 +00:00
|
|
|
* PROGRAMMER:
|
2002-10-29 18:40:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2006-08-31 09:13:03 +00:00
|
|
|
#include "usetup.h"
|
2002-10-29 18:40:02 +00:00
|
|
|
|
2010-06-07 21:38:49 +00:00
|
|
|
#define NDEBUG
|
2005-06-20 22:49:45 +00:00
|
|
|
#include <debug.h>
|
2002-10-29 18:40:02 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
2014-05-12 14:17:37 +00:00
|
|
|
GetSourcePaths(
|
2017-05-30 00:15:54 +00:00
|
|
|
OUT PUNICODE_STRING SourcePath,
|
|
|
|
OUT PUNICODE_STRING SourceRootPath,
|
|
|
|
OUT PUNICODE_STRING SourceRootDir)
|
2002-10-29 18:40:02 +00:00
|
|
|
{
|
2017-05-30 00:15:54 +00:00
|
|
|
NTSTATUS Status;
|
2014-05-12 14:17:37 +00:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
2017-05-30 00:15:54 +00:00
|
|
|
UNICODE_STRING LinkName = RTL_CONSTANT_STRING(L"\\SystemRoot");
|
2014-05-12 14:17:37 +00:00
|
|
|
UNICODE_STRING SourceName;
|
2017-05-30 00:15:54 +00:00
|
|
|
WCHAR SourceBuffer[MAX_PATH] = L"";
|
2014-05-12 14:17:37 +00:00
|
|
|
HANDLE Handle;
|
|
|
|
ULONG Length;
|
|
|
|
PWCHAR Ptr;
|
|
|
|
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&LinkName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
Status = NtOpenSymbolicLinkObject(&Handle,
|
|
|
|
SYMBOLIC_LINK_ALL_ACCESS,
|
|
|
|
&ObjectAttributes);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return Status;
|
|
|
|
|
2017-05-30 00:15:54 +00:00
|
|
|
RtlInitEmptyUnicodeString(&SourceName, SourceBuffer, sizeof(SourceBuffer));
|
2014-05-12 14:17:37 +00:00
|
|
|
|
|
|
|
Status = NtQuerySymbolicLinkObject(Handle,
|
|
|
|
&SourceName,
|
|
|
|
&Length);
|
|
|
|
NtClose(Handle);
|
|
|
|
|
2017-05-30 00:15:54 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return Status;
|
2014-05-12 14:17:37 +00:00
|
|
|
|
2017-05-30 00:15:54 +00:00
|
|
|
RtlCreateUnicodeString(SourcePath,
|
|
|
|
SourceName.Buffer);
|
2014-05-12 14:17:37 +00:00
|
|
|
|
2017-05-30 00:15:54 +00:00
|
|
|
/* Strip trailing directory */
|
|
|
|
Ptr = wcsrchr(SourceName.Buffer, OBJ_NAME_PATH_SEPARATOR);
|
|
|
|
if (Ptr)
|
|
|
|
{
|
|
|
|
RtlCreateUnicodeString(SourceRootDir, Ptr);
|
|
|
|
*Ptr = UNICODE_NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RtlCreateUnicodeString(SourceRootDir, L"");
|
2002-10-29 18:40:02 +00:00
|
|
|
}
|
|
|
|
|
2017-05-30 00:15:54 +00:00
|
|
|
RtlCreateUnicodeString(SourceRootPath,
|
|
|
|
SourceName.Buffer);
|
2002-10-29 18:40:02 +00:00
|
|
|
|
2014-05-12 14:17:37 +00:00
|
|
|
return STATUS_SUCCESS;
|
2002-10-29 18:40:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|