+ /* 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.
+ */
+