Author: hbelusca
Date: Fri Aug 25 09:19:44 2017
New Revision: 75667
URL:
http://svn.reactos.org/svn/reactos?rev=75667&view=rev
Log:
[SETUPLIB]: - Compute the installation source paths based on the full path of the
installer program that uses the setup library. - Add INF_STYLE_OLDNT define in infsupp.h.
- Add some (silenced) diagnostic DPRINTs.
Modified:
branches/setup_improvements/base/setup/lib/infsupp.h
branches/setup_improvements/base/setup/lib/setuplib.c
Modified: branches/setup_improvements/base/setup/lib/infsupp.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/infsupp.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/infsupp.h [iso-8859-1] Fri Aug 25 09:19:44
2017
@@ -95,6 +95,10 @@
#undef MAX_INF_STRING_LENGTH
#define MAX_INF_STRING_LENGTH 1024 // Still larger than in infcommon.h
+#ifndef INF_STYLE_OLDNT
+#define INF_STYLE_OLDNT 0x00000001
+#endif
+
#ifndef INF_STYLE_WIN4
#define INF_STYLE_WIN4 0x00000002
#endif
Modified: branches/setup_improvements/base/setup/lib/setuplib.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/setuplib.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/setuplib.c [iso-8859-1] Fri Aug 25 09:19:44
2017
@@ -37,6 +37,8 @@
CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2,
pSetupData->SourcePath.Buffer, L"unattend.inf");
+
+ DPRINT("UnattendInf path: '%S'\n", UnattendInfPath);
if (DoesFileExist(NULL, UnattendInfPath) == FALSE)
{
@@ -376,8 +378,6 @@
#endif
}
-
-
NTSTATUS
GetSourcePaths(
OUT PUNICODE_STRING SourcePath,
@@ -385,41 +385,87 @@
OUT PUNICODE_STRING SourceRootDir)
{
NTSTATUS Status;
+ HANDLE Handle;
OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING LinkName = RTL_CONSTANT_STRING(L"\\SystemRoot");
- UNICODE_STRING SourceName;
- WCHAR SourceBuffer[MAX_PATH] = L"";
- HANDLE Handle;
- ULONG Length;
+ UCHAR ImageFileBuffer[sizeof(UNICODE_STRING) + MAX_PATH * sizeof(WCHAR)];
+ PUNICODE_STRING InstallSourcePath = (PUNICODE_STRING)&ImageFileBuffer;
+ WCHAR SystemRootBuffer[MAX_PATH] = L"";
+ UNICODE_STRING SystemRootPath = RTL_CONSTANT_STRING(L"\\SystemRoot");
+ ULONG BufferSize;
PWCHAR Ptr;
+ /* Determine the installation source path via the full path of the installer */
+ RtlInitEmptyUnicodeString(InstallSourcePath,
+ (PWSTR)((ULONG_PTR)ImageFileBuffer +
sizeof(UNICODE_STRING)),
+ sizeof(ImageFileBuffer) - sizeof(UNICODE_STRING)
+ /* Reserve space for a NULL terminator */ - sizeof(UNICODE_NULL));
+ BufferSize = sizeof(ImageFileBuffer);
+ Status = NtQueryInformationProcess(NtCurrentProcess(),
+ ProcessImageFileName,
+ InstallSourcePath,
+ BufferSize,
+ NULL);
+ // STATUS_INFO_LENGTH_MISMATCH or STATUS_BUFFER_TOO_SMALL ?
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Manually NULL-terminate */
+ InstallSourcePath->Buffer[InstallSourcePath->Length / sizeof(WCHAR)] =
UNICODE_NULL;
+
+ /* Strip the trailing file name */
+ Ptr = wcsrchr(InstallSourcePath->Buffer, OBJ_NAME_PATH_SEPARATOR);
+ if (Ptr)
+ *Ptr = UNICODE_NULL;
+ InstallSourcePath->Length = wcslen(InstallSourcePath->Buffer) * sizeof(WCHAR);
+
+
+ /*
+ * Now resolve the full path to \SystemRoot. In case it prefixes
+ * the installation source path determined from the full path of
+ * the installer, we use instead the resolved \SystemRoot as the
+ * installation source path.
+ * Otherwise, we use instead the path from the full installer path.
+ */
+
InitializeObjectAttributes(&ObjectAttributes,
- &LinkName,
+ &SystemRootPath,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenSymbolicLinkObject(&Handle,
- SYMBOLIC_LINK_ALL_ACCESS,
+ SYMBOLIC_LINK_QUERY,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
return Status;
- RtlInitEmptyUnicodeString(&SourceName, SourceBuffer, sizeof(SourceBuffer));
+ RtlInitEmptyUnicodeString(&SystemRootPath,
+ SystemRootBuffer,
+ sizeof(SystemRootBuffer));
Status = NtQuerySymbolicLinkObject(Handle,
- &SourceName,
- &Length);
+ &SystemRootPath,
+ &BufferSize);
NtClose(Handle);
if (!NT_SUCCESS(Status))
return Status;
- RtlCreateUnicodeString(SourcePath,
- SourceName.Buffer);
+ /* Check whether the resolved \SystemRoot is a prefix of the image file path */
+ if (RtlPrefixUnicodeString(&SystemRootPath, InstallSourcePath, TRUE))
+ {
+ /* Yes it is, so we use instead SystemRoot as the installation source path */
+ InstallSourcePath = &SystemRootPath;
+ }
+
+
+ /*
+ * Retrieve the different source path components
+ */
+ RtlCreateUnicodeString(SourcePath, InstallSourcePath->Buffer);
/* Strip trailing directory */
- Ptr = wcsrchr(SourceName.Buffer, OBJ_NAME_PATH_SEPARATOR);
+ Ptr = wcsrchr(InstallSourcePath->Buffer, OBJ_NAME_PATH_SEPARATOR);
if (Ptr)
{
RtlCreateUnicodeString(SourceRootDir, Ptr);
@@ -430,12 +476,10 @@
RtlCreateUnicodeString(SourceRootDir, L"");
}
- RtlCreateUnicodeString(SourceRootPath,
- SourceName.Buffer);
+ RtlCreateUnicodeString(SourceRootPath, InstallSourcePath->Buffer);
return STATUS_SUCCESS;
}
-
ERROR_NUMBER
LoadSetupInf(
@@ -451,6 +495,8 @@
CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2,
pSetupData->SourcePath.Buffer, L"txtsetup.sif");
+ DPRINT("SetupInf path: '%S'\n", FileNameBuffer);
+
*SetupInf = SetupOpenInfFileExW(FileNameBuffer,
NULL,
INF_STYLE_WIN4,