Author: hbelusca
Date: Fri Aug 25 09:29:20 2017
New Revision: 75668
URL:
http://svn.reactos.org/svn/reactos?rev=75668&view=rev
Log:
[REACTOS]: More interfacing of the 1st-stage GUI installer with the setuplib:
- Add a ConvertNtPathToWin32Path() helper function that allows me to convert NT paths
like: \Device\CdRom0\i386\txtsetup.sif file into a Win32 path that the Win32 versions of
the SetupApi functions (e.g. SetupOpenInfFileW) can accept.
Note that RtlNtPathNameToDosPathName() cannot be used here because this function only
works for NT paths within the \DosDevices\ (or \??\) NTObj directory, and not in other
directories.
- Use this helper function in the implementation of SetupOpenInfFileExW. Now the
txtsetup.sif function can be loaded by setuplib *when being used* by the 1st-stage GUI
installer!
- Remove deprecated code.
Modified:
branches/setup_improvements/base/setup/reactos/inffile.c
branches/setup_improvements/base/setup/reactos/reactos.c
branches/setup_improvements/base/setup/reactos/reactos.h
Modified: branches/setup_improvements/base/setup/reactos/inffile.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/r…
==============================================================================
--- branches/setup_improvements/base/setup/reactos/inffile.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/reactos/inffile.c [iso-8859-1] Fri Aug 25
09:29:20 2017
@@ -28,8 +28,26 @@
IN LCID LocaleId,
OUT PUINT ErrorLine)
{
+ WCHAR Win32FileName[MAX_PATH];
+
UNREFERENCED_PARAMETER(LocaleId);
- return SetupOpenInfFileW(FileName, InfClass, InfStyle, ErrorLine);
+
+ /*
+ * SetupOpenInfFileExW is called within setuplib with NT paths, however
+ * the Win32 SetupOpenInfFileW API only takes Win32 paths. We therefore
+ * map the NT path to Win32 path and then call the Win32 API.
+ */
+ if (!ConvertNtPathToWin32Path(Win32FileName,
+ _countof(Win32FileName),
+ FileName))
+ {
+ return INVALID_HANDLE_VALUE;
+ }
+
+ return SetupOpenInfFileW(Win32FileName,
+ InfClass,
+ InfStyle,
+ ErrorLine);
}
Modified: branches/setup_improvements/base/setup/reactos/reactos.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/r…
==============================================================================
--- branches/setup_improvements/base/setup/reactos/reactos.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/reactos/reactos.c [iso-8859-1] Fri Aug 25
09:29:20 2017
@@ -701,45 +701,55 @@
return TotalCount;
}
-BOOL IsUnattendSetup(VOID)
-{
- WCHAR szPath[MAX_PATH];
- WCHAR *ch;
- HINF hUnattendedInf;
- INFCONTEXT InfContext;
- TCHAR szValue[MAX_PATH];
- DWORD LineLength;
- //HKEY hKey;
- BOOL result = 0;
-
- GetModuleFileNameW(NULL, szPath, MAX_PATH);
- ch = wcsrchr(szPath, L'\\');
- if (ch != NULL)
- *ch = L'\0';
-
- wcscat(szPath, L"\\unattend.inf");
- hUnattendedInf = SetupOpenInfFileW(szPath, NULL, INF_STYLE_OLDNT, NULL);
-
- if (hUnattendedInf != INVALID_HANDLE_VALUE)
- {
- if (SetupFindFirstLine(hUnattendedInf, _T("Unattend"),
_T("UnattendSetupEnabled"),&InfContext))
- {
- if (SetupGetStringField(&InfContext,
- 1,
- szValue,
- sizeof(szValue) / sizeof(TCHAR),
- &LineLength) && (_tcsicmp(szValue,
_T("yes")) == 0))
- {
- result = 1; // unattendSetup enabled
- // read values and store in SetupData
- }
- }
- SetupCloseInfFile(hUnattendedInf);
- }
-
- return result;
-}
-
+/*
+ * Attempts to convert a pure NT file path into a corresponding Win32 path.
+ * Adapted from GetInstallSourceWin32() in dll/win32/syssetup/wizard.c
+ */
+BOOL
+ConvertNtPathToWin32Path(
+ OUT PWSTR pwszPath,
+ IN DWORD cchPathMax,
+ IN PCWSTR pwszNTPath)
+{
+ WCHAR wszDrives[512];
+ WCHAR wszNTPath[512]; // MAX_PATH ?
+ DWORD cchDrives;
+ PWCHAR pwszDrive;
+
+ *pwszPath = UNICODE_NULL;
+
+ cchDrives = GetLogicalDriveStringsW(_countof(wszDrives) - 1, wszDrives);
+ if (cchDrives == 0 || cchDrives >= _countof(wszDrives))
+ {
+ /* Buffer too small or failure */
+ DPRINT1("GetLogicalDriveStringsW failed\n");
+ return FALSE;
+ }
+
+ for (pwszDrive = wszDrives; *pwszDrive; pwszDrive += wcslen(pwszDrive) + 1)
+ {
+ /* Retrieve the NT path corresponding to the current Win32 DOS path */
+ pwszDrive[2] = UNICODE_NULL; // Temporarily remove the backslash
+ QueryDosDeviceW(pwszDrive, wszNTPath, _countof(wszNTPath));
+ pwszDrive[2] = L'\\'; // Restore the backslash
+
+ wcscat(wszNTPath, L"\\"); // Concat a backslash
+
+ DPRINT1("Testing '%S' --> '%S'\n", pwszDrive,
wszNTPath);
+
+ /* Check whether the NT path corresponds to the NT installation source path */
+ if (!_wcsnicmp(wszNTPath, pwszNTPath, wcslen(wszNTPath)))
+ {
+ /* Found it! */
+ wsprintf(pwszPath, L"%s%s", // cchPathMax
+ pwszDrive, pwszNTPath + wcslen(wszNTPath));
+ DPRINT1("ConvertNtPathToWin32Path: %S\n", pwszPath);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
/* Used to enable and disable the shutdown privilege */
/* static */ BOOL
@@ -768,7 +778,6 @@
CloseHandle(hToken);
return Success;
}
-
int WINAPI
_tWinMain(HINSTANCE hInst,
@@ -778,17 +787,12 @@
{
NTSTATUS Status;
ULONG Error;
- // PSETUPDATA pSetupData = NULL;
PROPSHEETHEADER psh;
HPROPSHEETPAGE ahpsp[8];
PROPSHEETPAGE psp = {0};
UINT nPages = 0;
ProcessHeap = GetProcessHeap();
-
- // pSetupData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SETUPDATA));
- // if (pSetupData == NULL)
- // return 1;
/* Initialize global unicode strings */
RtlInitUnicodeString(&SetupData.USetupData.SourcePath, NULL);
@@ -833,7 +837,6 @@
SetupData.hInstance = hInst;
- // SetupData.bUnattend = IsUnattendSetup();
CheckUnattendedSetup(&SetupData.USetupData);
SetupData.bUnattend = IsUnattendedSetup;
@@ -940,7 +943,6 @@
SetupCloseInfFile(SetupData.SetupInf);
Quit:
- // HeapFree(GetProcessHeap(), 0, pSetupData);
#if 0 // NOTE: Disabled for testing purposes only!
EnablePrivilege(SE_SHUTDOWN_NAME, TRUE);
Modified: branches/setup_improvements/base/setup/reactos/reactos.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/r…
==============================================================================
--- branches/setup_improvements/base/setup/reactos/reactos.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/reactos/reactos.h [iso-8859-1] Fri Aug 25
09:29:20 2017
@@ -29,6 +29,7 @@
#define _REACTOS_PCH_
/* C Headers */
+#include <stdlib.h>
#include <stdarg.h>
#include <tchar.h>
@@ -133,6 +134,17 @@
+/*
+ * Attempts to convert a pure NT file path into a corresponding Win32 path.
+ * Adapted from GetInstallSourceWin32() in dll/win32/syssetup/wizard.c
+ */
+BOOL
+ConvertNtPathToWin32Path(
+ OUT PWSTR pwszPath,
+ IN DWORD cchPathMax,
+ IN PCWSTR pwszNTPath);
+
+
/* drivepage.c */
INT_PTR
CALLBACK