mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 14:37:45 +00:00
[USETUP] Minor fixes & simplifications.
- 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
This commit is contained in:
parent
6681fb8af5
commit
6b6163a5d9
|
@ -1,21 +1,3 @@
|
||||||
/*
|
|
||||||
* ReactOS kernel
|
|
||||||
* Copyright (C) 2002 ReactOS Team
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS text-mode setup
|
* PROJECT: ReactOS text-mode setup
|
||||||
|
@ -35,22 +17,19 @@
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
GetSourcePaths(
|
GetSourcePaths(
|
||||||
PUNICODE_STRING SourcePath,
|
OUT PUNICODE_STRING SourcePath,
|
||||||
PUNICODE_STRING SourceRootPath,
|
OUT PUNICODE_STRING SourceRootPath,
|
||||||
PUNICODE_STRING SourceRootDir)
|
OUT PUNICODE_STRING SourceRootDir)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
UNICODE_STRING LinkName;
|
|
||||||
UNICODE_STRING SourceName;
|
|
||||||
WCHAR SourceBuffer[MAX_PATH] = {L'\0'};
|
|
||||||
HANDLE Handle;
|
|
||||||
NTSTATUS Status;
|
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;
|
ULONG Length;
|
||||||
PWCHAR Ptr;
|
PWCHAR Ptr;
|
||||||
|
|
||||||
RtlInitUnicodeString(&LinkName,
|
|
||||||
L"\\SystemRoot");
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&LinkName,
|
&LinkName,
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
@ -63,35 +42,33 @@ GetSourcePaths(
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
SourceName.Length = 0;
|
RtlInitEmptyUnicodeString(&SourceName, SourceBuffer, sizeof(SourceBuffer));
|
||||||
SourceName.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
|
||||||
SourceName.Buffer = SourceBuffer;
|
|
||||||
|
|
||||||
Status = NtQuerySymbolicLinkObject(Handle,
|
Status = NtQuerySymbolicLinkObject(Handle,
|
||||||
&SourceName,
|
&SourceName,
|
||||||
&Length);
|
&Length);
|
||||||
NtClose(Handle);
|
NtClose(Handle);
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
RtlCreateUnicodeString(SourcePath,
|
||||||
|
SourceName.Buffer);
|
||||||
|
|
||||||
|
/* Strip trailing directory */
|
||||||
|
Ptr = wcsrchr(SourceName.Buffer, OBJ_NAME_PATH_SEPARATOR);
|
||||||
|
if (Ptr)
|
||||||
{
|
{
|
||||||
RtlCreateUnicodeString(SourcePath,
|
RtlCreateUnicodeString(SourceRootDir, Ptr);
|
||||||
SourceName.Buffer);
|
*Ptr = UNICODE_NULL;
|
||||||
|
}
|
||||||
/* strip trailing directory */
|
else
|
||||||
Ptr = wcsrchr(SourceName.Buffer, L'\\');
|
{
|
||||||
if (Ptr)
|
RtlCreateUnicodeString(SourceRootDir, L"");
|
||||||
{
|
|
||||||
RtlCreateUnicodeString(SourceRootDir, Ptr);
|
|
||||||
*Ptr = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
RtlCreateUnicodeString(SourceRootDir, L"");
|
|
||||||
|
|
||||||
RtlCreateUnicodeString(SourceRootPath,
|
|
||||||
SourceName.Buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NtClose(Handle);
|
RtlCreateUnicodeString(SourceRootPath,
|
||||||
|
SourceName.Buffer);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,3 @@
|
||||||
/*
|
|
||||||
* ReactOS kernel
|
|
||||||
* Copyright (C) 2002 ReactOS Team
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS text-mode setup
|
* PROJECT: ReactOS text-mode setup
|
||||||
|
@ -28,8 +10,8 @@
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
GetSourcePaths(
|
GetSourcePaths(
|
||||||
PUNICODE_STRING SourcePath,
|
OUT PUNICODE_STRING SourcePath,
|
||||||
PUNICODE_STRING SourceRootPath,
|
OUT PUNICODE_STRING SourceRootPath,
|
||||||
PUNICODE_STRING SourceRootDir);
|
OUT PUNICODE_STRING SourceRootDir);
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue