X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=base%2Fsetup%2Fusetup%2Fdrivesup.c;h=b8561d77ed1ee9790b5a230261734ed81f11084b;hp=a910e9302efdce20ddec1a005e1e5b72400cea2b;hb=49d3daf1af625e360145f4f4ada24a48427524d4;hpb=e2dbefc3101158a091e54805cd7f3d02043c7d03 diff --git a/base/setup/usetup/drivesup.c b/base/setup/usetup/drivesup.c index a910e9302ef..b8561d77ed1 100644 --- a/base/setup/usetup/drivesup.c +++ b/base/setup/usetup/drivesup.c @@ -1,27 +1,9 @@ -/* - * 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 * PROJECT: ReactOS text-mode setup - * FILE: subsys/system/usetup/drivesup.c + * FILE: base/setup/usetup/drivesup.c * PURPOSE: Drive support functions - * PROGRAMMER: Eric Kohl + * PROGRAMMER: */ /* INCLUDES *****************************************************************/ @@ -34,66 +16,61 @@ /* FUNCTIONS ****************************************************************/ NTSTATUS -GetSourcePaths(PUNICODE_STRING SourcePath, - PUNICODE_STRING SourceRootPath, - PUNICODE_STRING SourceRootDir) +GetSourcePaths( + OUT PUNICODE_STRING SourcePath, + OUT PUNICODE_STRING SourceRootPath, + OUT PUNICODE_STRING SourceRootDir) { - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING LinkName; - UNICODE_STRING SourceName; - WCHAR SourceBuffer[MAX_PATH] = {L'\0'}; - HANDLE Handle; - NTSTATUS Status; - ULONG Length; - PWCHAR Ptr; - - RtlInitUnicodeString(&LinkName, - L"\\SystemRoot"); - - InitializeObjectAttributes(&ObjectAttributes, - &LinkName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - - Status = NtOpenSymbolicLinkObject(&Handle, - SYMBOLIC_LINK_ALL_ACCESS, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - return(Status); - - SourceName.Length = 0; - SourceName.MaximumLength = MAX_PATH * sizeof(WCHAR); - SourceName.Buffer = SourceBuffer; - - Status = NtQuerySymbolicLinkObject(Handle, - &SourceName, - &Length); - NtClose(Handle); - - if (NT_SUCCESS(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; + 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(SourcePath, - SourceName.Buffer); - - /* strip trailing directory */ - Ptr = wcsrchr(SourceName.Buffer, L'\\'); - if (Ptr) - { - RtlCreateUnicodeString(SourceRootDir, Ptr); - *Ptr = 0; - } - else - RtlCreateUnicodeString(SourceRootDir, L""); - - RtlCreateUnicodeString(SourceRootPath, - SourceName.Buffer); + RtlCreateUnicodeString(SourceRootDir, Ptr); + *Ptr = UNICODE_NULL; + } + else + { + RtlCreateUnicodeString(SourceRootDir, L""); } - NtClose(Handle); + RtlCreateUnicodeString(SourceRootPath, + SourceName.Buffer); - return(STATUS_SUCCESS); + return STATUS_SUCCESS; } - /* EOF */