Author: hbelusca
Date: Fri Jun 30 19:02:35 2017
New Revision: 75246
URL:
http://svn.reactos.org/svn/reactos?rev=75246&view=rev
Log:
[USETUP]: Moving around some code:
- As GetSourcePaths() is used once in usetup to initialize global UNICODE_STRING path
strings once, move it out of drivesup.c and put it in usetup.c. Then remove drivesup.c : 1
file less!
- Move some INF file prototype declarations out of usetup.h and inside inffile.h where
they should better be, as inffile.h and .c is the glue code for the INF library, defining
similar functions as the ones in setupapi.dll.
- I rename our local SetupOpenInfFileW into SetupOpenInfFileExW because the latter one
takes an extra user-provided LCID parameter, and this is this one that we use in usetup.
- Make UNICODE_STRING SourcePath; visible only inside usetup.c (not used elsewhere).
- Implement installation path validity check in case we are either in repair/update, or
unattended setup mode. If the path is detected as invalid, then we fall back into manual
path specification (for now...; note that we could instead fail the installation too).
Removed:
branches/setup_improvements/base/setup/usetup/drivesup.c
branches/setup_improvements/base/setup/usetup/drivesup.h
Modified:
branches/setup_improvements/base/setup/usetup/CMakeLists.txt
branches/setup_improvements/base/setup/usetup/inffile.c
branches/setup_improvements/base/setup/usetup/inffile.h
branches/setup_improvements/base/setup/usetup/interface/usetup.c
branches/setup_improvements/base/setup/usetup/usetup.h
Modified: branches/setup_improvements/base/setup/usetup/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/CMakeLists.txt [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/CMakeLists.txt [iso-8859-1] Fri Jun 30
19:02:35 2017
@@ -20,7 +20,6 @@
cabinet.c
chkdsk.c
cmdcons.c
- drivesup.c
filesup.c
filequeue.c
format.c
Removed: branches/setup_improvements/base/setup/usetup/drivesup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/drivesup.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/drivesup.c (removed)
@@ -1,76 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS text-mode setup
- * FILE: base/setup/usetup/drivesup.c
- * PURPOSE: Drive support functions
- * PROGRAMMER: Eric Kohl
- */
-
-/* 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 */
Removed: branches/setup_improvements/base/setup/usetup/drivesup.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/drivesup.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/drivesup.h (removed)
@@ -1,17 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS text-mode setup
- * FILE: base/setup/usetup/drivesup.h
- * PURPOSE: Drive support functions
- * PROGRAMMER: Eric Kohl
- */
-
-#pragma once
-
-NTSTATUS
-GetSourcePaths(
- OUT PUNICODE_STRING SourcePath,
- OUT PUNICODE_STRING SourceRootPath,
- OUT PUNICODE_STRING SourceRootDir);
-
-/* EOF */
Modified: branches/setup_improvements/base/setup/usetup/inffile.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/inffile.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/inffile.c [iso-8859-1] Fri Jun 30
19:02:35 2017
@@ -81,6 +81,7 @@
return hInf;
}
+
#endif /* __REACTOS__ */
Modified: branches/setup_improvements/base/setup/usetup/inffile.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/inffile.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/inffile.h [iso-8859-1] Fri Jun 30
19:02:35 2017
@@ -34,10 +34,39 @@
#include <infcommon.h>
+extern VOID InfSetHeap(PVOID Heap);
+extern VOID InfCloseFile(HINF InfHandle);
+extern BOOLEAN InfFindNextLine(PINFCONTEXT ContextIn,
+ PINFCONTEXT ContextOut);
+extern BOOLEAN InfGetBinaryField(PINFCONTEXT Context,
+ ULONG FieldIndex,
+ PUCHAR ReturnBuffer,
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize);
+extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context,
+ ULONG FieldIndex,
+ PWSTR ReturnBuffer,
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize);
+extern BOOLEAN InfGetStringField(PINFCONTEXT Context,
+ ULONG FieldIndex,
+ PWSTR ReturnBuffer,
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize);
+
+#define SetupCloseInfFile InfCloseFile
+#define SetupFindNextLine InfFindNextLine
+#define SetupGetBinaryField InfGetBinaryField
+#define SetupGetMultiSzFieldW InfGetMultiSzField
+#define SetupGetStringFieldW InfGetStringField
+
+
#define SetupFindFirstLineW InfpFindFirstLineW
#define SetupGetFieldCount InfGetFieldCount
#define SetupGetIntField InfGetIntField
-#define SetupOpenInfFileW InfpOpenInfFileW
+
+// SetupOpenInfFileW with support for a user-provided LCID
+#define SetupOpenInfFileExW InfpOpenInfFileW
#define INF_STYLE_WIN4 0x00000002
Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1]
(original)
+++ branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] Fri Jun
30 19:02:35 2017
@@ -32,7 +32,6 @@
#include "chkdsk.h"
#include "cmdcons.h"
#include "format.h"
-#include "drivesup.h"
#include "settings.h"
#define NDEBUG
@@ -45,7 +44,7 @@
static UNICODE_STRING SourceRootPath;
static UNICODE_STRING SourceRootDir;
-/* static */ UNICODE_STRING SourcePath;
+static UNICODE_STRING SourcePath;
BOOLEAN IsUnattendedSetup = FALSE;
LONG UnattendDestinationDiskNumber;
@@ -70,6 +69,10 @@
static PFILE_SYSTEM_LIST FileSystemList = NULL;
+/*
+ * NOTE: Technically only used for the COPYCONTEXT InstallPath member
+ * for the filequeue functionality.
+ */
static UNICODE_STRING InstallPath;
/*
@@ -87,7 +90,7 @@
*/
static UNICODE_STRING SystemRootPath;
-/* Path to the install directory inside the ReactOS boot partition */
+/* Path to the installation directory inside the ReactOS boot partition */
static UNICODE_STRING DestinationPath;
static UNICODE_STRING DestinationArcPath;
static UNICODE_STRING DestinationRootPath;
@@ -442,15 +445,15 @@
}
/* Load 'unattend.inf' from install media. */
- UnattendInf = SetupOpenInfFileW(UnattendInfPath,
- NULL,
- INF_STYLE_WIN4,
- LanguageId,
- &ErrorLine);
+ UnattendInf = SetupOpenInfFileExW(UnattendInfPath,
+ NULL,
+ INF_STYLE_WIN4,
+ LanguageId,
+ &ErrorLine);
if (UnattendInf == INVALID_HANDLE_VALUE)
{
- DPRINT("SetupOpenInfFileW() failed\n");
+ DPRINT("SetupOpenInfFileExW() failed\n");
return;
}
@@ -768,6 +771,65 @@
}
return WELCOME_PAGE;
+}
+
+
+static 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;
}
@@ -823,11 +885,11 @@
/* Load txtsetup.sif from install media. */
CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2, SourcePath.Buffer,
L"txtsetup.sif");
- SetupInf = SetupOpenInfFileW(FileNameBuffer,
- NULL,
- INF_STYLE_WIN4,
- LanguageId,
- &ErrorLine);
+ SetupInf = SetupOpenInfFileExW(FileNameBuffer,
+ NULL,
+ INF_STYLE_WIN4,
+ LanguageId,
+ &ErrorLine);
if (SetupInf == INVALID_HANDLE_VALUE)
{
@@ -3272,6 +3334,7 @@
{
WCHAR PathBuffer[MAX_PATH];
+/** Equivalent of 'NTOS_INSTALLATION::PathComponent' **/
/* Create 'InstallPath' string */
RtlFreeUnicodeString(&InstallPath);
RtlCreateUnicodeString(&InstallPath, InstallDir);
@@ -3285,12 +3348,14 @@
RtlCreateUnicodeString(&DestinationRootPath, PathBuffer);
DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath);
+/** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
/* Create 'DestinationPath' string */
RtlFreeUnicodeString(&DestinationPath);
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
DestinationRootPath.Buffer, InstallDir);
RtlCreateUnicodeString(&DestinationPath, PathBuffer);
+/** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
/* Create 'DestinationArcPath' */
RtlFreeUnicodeString(&DestinationArcPath);
StringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
@@ -3326,7 +3391,7 @@
WCHAR c;
ULONG Length;
- /* We do not need the filesystem list any more */
+ /* We do not need the filesystem list anymore */
if (FileSystemList != NULL)
{
DestroyFileSystemList(FileSystemList);
@@ -3352,26 +3417,24 @@
wcscpy(InstallDir, L"\\ReactOS");
Length = wcslen(InstallDir);
- CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
- MUIDisplayPage(INSTALL_DIRECTORY_PAGE);
-
- // FIXME: Check the validity of the InstallDir; however what to do
- // if it is invalid but we are in unattended setup? (case of somebody
- // specified an invalid installation directory in the unattended file).
-
- if (RepairUpdateFlag)
+
+ /*
+ * Check the validity of the predefined 'InstallDir'. If we are either
+ * in unattended setup or in update/repair mode, and the installation path
+ * is valid, just perform the installation. Otherwise (either in the case
+ * of an invalid path, or we are in regular setup), display the UI and allow
+ * the user to specify a new installation path.
+ */
+ if ((RepairUpdateFlag || IsUnattendedSetup) &&
+ IsValidPath(InstallDir, Length))
{
return InstallDirectoryPage1(InstallDir,
DiskEntry,
PartEntry);
}
- if (IsUnattendedSetup)
- {
- return InstallDirectoryPage1(InstallDir,
- DiskEntry,
- PartEntry);
- }
+ MUIDisplayPage(INSTALL_DIRECTORY_PAGE);
+ CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
while (TRUE)
{
@@ -4160,7 +4223,7 @@
CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE), File);
- if (!ImportRegistryFile(File, Section, LanguageId, Delete))
+ if (!ImportRegistryFile(SourcePath.Buffer, File, Section, LanguageId, Delete))
{
DPRINT1("Importing %S failed\n", File);
MUIDisplayError(ERROR_IMPORT_HIVE, Ir, POPUP_WAIT_ENTER);
Modified: branches/setup_improvements/base/setup/usetup/usetup.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/usetup.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/usetup.h [iso-8859-1] Fri Jun 30
19:02:35 2017
@@ -75,39 +75,8 @@
#include "mui.h"
extern HANDLE ProcessHeap;
-extern UNICODE_STRING SourcePath;
extern BOOLEAN IsUnattendedSetup;
extern PWCHAR SelectedLanguageId;
-
-#ifdef __REACTOS__
-
-extern VOID InfSetHeap(PVOID Heap);
-extern VOID InfCloseFile(HINF InfHandle);
-extern BOOLEAN InfFindNextLine(PINFCONTEXT ContextIn,
- PINFCONTEXT ContextOut);
-extern BOOLEAN InfGetBinaryField(PINFCONTEXT Context,
- ULONG FieldIndex,
- PUCHAR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize);
-extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context,
- ULONG FieldIndex,
- PWSTR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize);
-extern BOOLEAN InfGetStringField(PINFCONTEXT Context,
- ULONG FieldIndex,
- PWSTR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize);
-
-#define SetupCloseInfFile InfCloseFile
-#define SetupFindNextLine InfFindNextLine
-#define SetupGetBinaryField InfGetBinaryField
-#define SetupGetMultiSzFieldW InfGetMultiSzField
-#define SetupGetStringFieldW InfGetStringField
-
-#endif /* __REACTOS__ */
typedef enum _PAGE_NUMBER
{