mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
6b6163a5d9
- Remove a redundant NtClose() call; - Return failure if NtQuerySymbolicLinkObject() fails; - Use RTL_CONSTANT_STRING and RtlInitEmptyUnicodeString() where needed; - Reduce code indent level; - Add old-style function annotations; - Remove the deprecated code copyright notice, since the copyright in usage is already reported in the COPYING file in the top level ReactOS source code directory. svn path=/branches/setup_improvements/; revision=74698
76 lines
2 KiB
C
76 lines
2 KiB
C
/*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS text-mode setup
|
|
* FILE: base/setup/usetup/drivesup.c
|
|
* PURPOSE: Drive support functions
|
|
* PROGRAMMER:
|
|
*/
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
#include "usetup.h"
|
|
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
NTSTATUS
|
|
GetSourcePaths(
|
|
OUT PUNICODE_STRING SourcePath,
|
|
OUT PUNICODE_STRING SourceRootPath,
|
|
OUT PUNICODE_STRING SourceRootDir)
|
|
{
|
|
NTSTATUS Status;
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
UNICODE_STRING LinkName = RTL_CONSTANT_STRING(L"\\SystemRoot");
|
|
UNICODE_STRING SourceName;
|
|
WCHAR SourceBuffer[MAX_PATH] = L"";
|
|
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;
|
|
|
|
RtlInitEmptyUnicodeString(&SourceName, SourceBuffer, sizeof(SourceBuffer));
|
|
|
|
Status = NtQuerySymbolicLinkObject(Handle,
|
|
&SourceName,
|
|
&Length);
|
|
NtClose(Handle);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
return Status;
|
|
|
|
RtlCreateUnicodeString(SourcePath,
|
|
SourceName.Buffer);
|
|
|
|
/* Strip trailing directory */
|
|
Ptr = wcsrchr(SourceName.Buffer, OBJ_NAME_PATH_SEPARATOR);
|
|
if (Ptr)
|
|
{
|
|
RtlCreateUnicodeString(SourceRootDir, Ptr);
|
|
*Ptr = UNICODE_NULL;
|
|
}
|
|
else
|
|
{
|
|
RtlCreateUnicodeString(SourceRootDir, L"");
|
|
}
|
|
|
|
RtlCreateUnicodeString(SourceRootPath,
|
|
SourceName.Buffer);
|
|
|
|
return STATUS_SUCCESS;
|
|
}
|
|
|
|
/* EOF */
|