https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a5318432454fdd8c75f48…
commit a5318432454fdd8c75f48eb1065a51c54ddd9aa9
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jan 28 23:05:43 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue Nov 6 00:09:15 2018 +0100
[REACTOS] Add two icons (drive and partition) for the drive list.
---
base/setup/reactos/reactos.rc | 12 +++++++-----
base/setup/reactos/res/README.txt | 24 ++++++++++++++++++++++++
base/setup/reactos/res/drive_disk.ico | Bin 0 -> 15086 bytes
base/setup/reactos/res/partition.ico | Bin 0 -> 5430 bytes
base/setup/reactos/resource.h | 2 ++
5 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/base/setup/reactos/reactos.rc b/base/setup/reactos/reactos.rc
index 2b794d83a6..b1fdf6f33d 100644
--- a/base/setup/reactos/reactos.rc
+++ b/base/setup/reactos/reactos.rc
@@ -12,13 +12,15 @@
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
/* Icons */
-IDI_MAIN ICON "res/setup.ico"
-IDI_ROSICON ICON "res/roslogo.ico"
-IDI_WINICON ICON "res/winlogo.ico"
+IDI_MAIN ICON "res/setup.ico"
+IDI_ROSICON ICON "res/roslogo.ico"
+IDI_WINICON ICON "res/winlogo.ico"
+IDI_DISKDRIVE ICON "res/drive_disk.ico"
+IDI_PARTITION ICON "res/partition.ico"
/* Bitmaps */
-IDB_WATERMARK BITMAP "res/watermark.bmp"
-IDB_HEADER BITMAP "res/header.bmp"
+IDB_WATERMARK BITMAP "res/watermark.bmp"
+IDB_HEADER BITMAP "res/header.bmp"
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "reactos.exe.manifest"
diff --git a/base/setup/reactos/res/README.txt b/base/setup/reactos/res/README.txt
index 54c0b111c4..163a4ca97f 100644
--- a/base/setup/reactos/res/README.txt
+++ b/base/setup/reactos/res/README.txt
@@ -1,9 +1,33 @@
+drive_disk.ico
+--------------
+From the GNOME-Colors project,
+by Victor Castillejo (perfectska04).
+Distributed under the terms of GNU GPL v2.
+
+
+partition.ico
+-------------
+Farm-Fresh Icon Set
+FatCow Web Hosting - http://www.fatcow.com/
+
+Terms of Use
+============
+These icon sets are licensed under a Creative Commons Attribution 3.0 License.
+This means you can freely use these icons for any purpose, private and commercial,
+including online services, templates, themes and software. However, you should
+include a link to this page (http://www.fatcow.com/free-icons) in your credits
+(software or website). The icons may not be resold, sub-licensed, rented, transferred
+or otherwise made available for use. Please link to this page on fatcow.com if you
+would like to spread the word.
+
+
roslogo.ico
-----------
(C) 2018 ReactOS Team & Contributors
Distributed under CC-BY-SA 4.0 International License Terms.
+
winlogo.ico
-----------
Adapted from the WinTango IconPack, by 'heebijeebi'
diff --git a/base/setup/reactos/res/drive_disk.ico b/base/setup/reactos/res/drive_disk.ico
new file mode 100644
index 0000000000..b9ddff5d52
Binary files /dev/null and b/base/setup/reactos/res/drive_disk.ico differ
diff --git a/base/setup/reactos/res/partition.ico b/base/setup/reactos/res/partition.ico
new file mode 100644
index 0000000000..181a6b5528
Binary files /dev/null and b/base/setup/reactos/res/partition.ico differ
diff --git a/base/setup/reactos/resource.h b/base/setup/reactos/resource.h
index 5d2037ea7c..11d855ce49 100644
--- a/base/setup/reactos/resource.h
+++ b/base/setup/reactos/resource.h
@@ -8,6 +8,8 @@
#define IDI_MAIN 3000
#define IDI_ROSICON 3001
#define IDI_WINICON 3002
+#define IDI_DISKDRIVE 3003
+#define IDI_PARTITION 3004
#define IDC_STATIC -1
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e282ec39a25061675e927…
commit e282ec39a25061675e9279fcfd71983bd6dbbf6d
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jan 28 23:32:52 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue Nov 6 00:09:13 2018 +0100
[SETUPLIB] Retrieve and store the machine (architecture) ID of the discovered NTOS installations. Will be used later.
---
base/setup/lib/utils/osdetect.c | 87 +++++++++++++++++++++++++++++------------
base/setup/lib/utils/osdetect.h | 5 ++-
2 files changed, 66 insertions(+), 26 deletions(-)
diff --git a/base/setup/lib/utils/osdetect.c b/base/setup/lib/utils/osdetect.c
index ed5e1f5805..8dd35cd55b 100644
--- a/base/setup/lib/utils/osdetect.c
+++ b/base/setup/lib/utils/osdetect.c
@@ -34,6 +34,7 @@ static const PCWSTR KnownVendors[] = { VENDOR_REACTOS, VENDOR_MICROSOFT };
static BOOLEAN
IsValidNTOSInstallation(
IN PUNICODE_STRING SystemRootPath,
+ OUT PUSHORT Machine OPTIONAL,
OUT PUNICODE_STRING VendorName OPTIONAL);
static PNTOS_INSTALLATION
@@ -47,6 +48,7 @@ static PNTOS_INSTALLATION
AddNTOSInstallation(
IN PGENERIC_LIST List,
IN PCWSTR InstallationName,
+ IN USHORT Machine,
IN PCWSTR VendorName,
IN PCWSTR SystemRootArcPath,
IN PUNICODE_STRING SystemRootNtPath, // or PCWSTR ?
@@ -82,6 +84,7 @@ EnumerateInstallations(
UNICODE_STRING SystemRootPath;
WCHAR SystemRoot[MAX_PATH];
+ USHORT Machine;
UNICODE_STRING VendorName;
WCHAR VendorNameBuffer[MAX_PATH];
@@ -166,7 +169,7 @@ EnumerateInstallations(
/* Check if this is a valid NTOS installation; stop there if it isn't one */
RtlInitEmptyUnicodeString(&VendorName, VendorNameBuffer, sizeof(VendorNameBuffer));
- if (!IsValidNTOSInstallation(&SystemRootPath, &VendorName))
+ if (!IsValidNTOSInstallation(&SystemRootPath, &Machine, &VendorName))
{
/* Continue the enumeration */
return STATUS_SUCCESS;
@@ -196,6 +199,7 @@ EnumerateInstallations(
/* Add the discovered NTOS installation into the list */
AddNTOSInstallation(Data->List,
BootEntry->FriendlyName,
+ Machine,
VendorName.Buffer, // FIXME: What if it's not NULL-terminated?
Options->OsLoadPath,
&SystemRootPath, PathComponent,
@@ -239,14 +243,15 @@ static BOOLEAN
CheckForValidPEAndVendor(
IN HANDLE RootDirectory OPTIONAL,
IN PCWSTR PathNameToFile,
- OUT PUNICODE_STRING VendorName
- )
+ OUT PUSHORT Machine,
+ OUT PUNICODE_STRING VendorName)
{
BOOLEAN Success = FALSE;
NTSTATUS Status;
HANDLE FileHandle, SectionHandle;
// SIZE_T ViewSize;
PVOID ViewBase;
+ PIMAGE_NT_HEADERS NtHeader;
PVOID VersionBuffer = NULL; // Read-only
PVOID pvData = NULL;
UINT BufLen = 0;
@@ -266,14 +271,18 @@ CheckForValidPEAndVendor(
return FALSE; // Status;
}
- /* Make sure it's a valid PE file */
- if (!RtlImageNtHeader(ViewBase))
+ /* Make sure it's a valid NT PE file */
+ NtHeader = RtlImageNtHeader(ViewBase);
+ if (!NtHeader)
{
- DPRINT1("File '%S' does not seem to be a valid PE, bail out\n", PathNameToFile);
+ DPRINT1("File '%S' does not seem to be a valid NT PE file, bail out\n", PathNameToFile);
Status = STATUS_INVALID_IMAGE_FORMAT;
goto UnmapCloseFile;
}
+ /* Retrieve the target architecture of this PE module */
+ *Machine = NtHeader->FileHeader.Machine;
+
/*
* Search for a valid executable version and vendor.
* NOTE: The module is loaded as a data file, it should be marked as such.
@@ -336,11 +345,13 @@ UnmapCloseFile:
static BOOLEAN
IsValidNTOSInstallationByHandle(
IN HANDLE SystemRootDirectory,
+ OUT PUSHORT Machine OPTIONAL,
OUT PUNICODE_STRING VendorName OPTIONAL)
{
BOOLEAN Success = FALSE;
PCWSTR PathName;
USHORT i;
+ USHORT LocalMachine;
UNICODE_STRING LocalVendorName;
WCHAR VendorNameBuffer[MAX_PATH];
@@ -404,11 +415,17 @@ IsValidNTOSInstallationByHandle(
/* Check for the existence of \SystemRoot\System32\ntoskrnl.exe and retrieves its vendor name */
PathName = L"System32\\ntoskrnl.exe";
- Success = CheckForValidPEAndVendor(SystemRootDirectory, PathName, &LocalVendorName);
+ Success = CheckForValidPEAndVendor(SystemRootDirectory, PathName, &LocalMachine, &LocalVendorName);
if (!Success)
DPRINT1("Kernel executable '%S' is either not a PE file, or does not have any vendor?\n", PathName);
- /* The kernel gives the OS its flavour */
+ /*
+ * The kernel gives the OS its flavour. If we failed due to the absence of
+ * ntoskrnl.exe this might be due to the fact this particular installation
+ * uses a custom kernel that has a different name, overridden in the boot
+ * parameters. We then rely on the existence of ntdll.dll, which cannot be
+ * renamed on a valid NT system.
+ */
if (Success)
{
for (i = 0; i < ARRAYSIZE(KnownVendors); ++i)
@@ -421,23 +438,32 @@ IsValidNTOSInstallationByHandle(
break;
}
}
- }
- /* Return the vendor name */
- if (VendorName)
- {
- /* Copy the string and invalidate the pointer */
- RtlCopyUnicodeString(VendorName, &LocalVendorName);
- VendorName = NULL;
+ /* Return the target architecture */
+ if (Machine)
+ {
+ /* Copy the value and invalidate the pointer */
+ *Machine = LocalMachine;
+ Machine = NULL;
+ }
+
+ /* Return the vendor name */
+ if (VendorName)
+ {
+ /* Copy the string and invalidate the pointer */
+ RtlCopyUnicodeString(VendorName, &LocalVendorName);
+ VendorName = NULL;
+ }
}
/* OPTIONAL: Check for the existence of \SystemRoot\System32\ntkrnlpa.exe */
/* Check for the existence of \SystemRoot\System32\ntdll.dll and retrieves its vendor name */
PathName = L"System32\\ntdll.dll";
- Success = CheckForValidPEAndVendor(SystemRootDirectory, PathName, &LocalVendorName);
+ Success = CheckForValidPEAndVendor(SystemRootDirectory, PathName, &LocalMachine, &LocalVendorName);
if (!Success)
DPRINT1("User-mode DLL '%S' is either not a PE file, or does not have any vendor?\n", PathName);
+
if (Success)
{
for (i = 0; i < ARRAYSIZE(KnownVendors); ++i)
@@ -449,14 +475,22 @@ IsValidNTOSInstallationByHandle(
break;
}
}
- }
- /* Return the vendor name if not already obtained */
- if (VendorName)
- {
- /* Copy the string and invalidate the pointer */
- RtlCopyUnicodeString(VendorName, &LocalVendorName);
- VendorName = NULL;
+ /* Return the target architecture if not already obtained */
+ if (Machine)
+ {
+ /* Copy the value and invalidate the pointer */
+ *Machine = LocalMachine;
+ Machine = NULL;
+ }
+
+ /* Return the vendor name if not already obtained */
+ if (VendorName)
+ {
+ /* Copy the string and invalidate the pointer */
+ RtlCopyUnicodeString(VendorName, &LocalVendorName);
+ VendorName = NULL;
+ }
}
return Success;
@@ -465,6 +499,7 @@ IsValidNTOSInstallationByHandle(
static BOOLEAN
IsValidNTOSInstallation(
IN PUNICODE_STRING SystemRootPath,
+ OUT PUSHORT Machine,
OUT PUNICODE_STRING VendorName OPTIONAL)
{
NTSTATUS Status;
@@ -491,7 +526,8 @@ IsValidNTOSInstallation(
return FALSE;
}
- Success = IsValidNTOSInstallationByHandle(SystemRootDirectory, VendorName);
+ Success = IsValidNTOSInstallationByHandle(SystemRootDirectory,
+ Machine, VendorName);
/* Done! */
NtClose(SystemRootDirectory);
@@ -573,6 +609,7 @@ static PNTOS_INSTALLATION
AddNTOSInstallation(
IN PGENERIC_LIST List,
IN PCWSTR InstallationName,
+ IN USHORT Machine,
IN PCWSTR VendorName,
IN PCWSTR SystemRootArcPath,
IN PUNICODE_STRING SystemRootNtPath, // or PCWSTR ?
@@ -613,6 +650,8 @@ AddNTOSInstallation(
NtOsInstall->PartitionNumber = PartitionNumber;
NtOsInstall->PartEntry = PartEntry;
+ NtOsInstall->Machine = Machine;
+
RtlInitEmptyUnicodeString(&NtOsInstall->SystemArcPath,
(PWCHAR)(NtOsInstall + 1),
ArcPathLength);
diff --git a/base/setup/lib/utils/osdetect.h b/base/setup/lib/utils/osdetect.h
index 7151d6feb8..e8b5449601 100644
--- a/base/setup/lib/utils/osdetect.h
+++ b/base/setup/lib/utils/osdetect.h
@@ -16,8 +16,9 @@ typedef struct _NTOS_INSTALLATION
{
LIST_ENTRY ListEntry;
// BOOLEAN IsDefault; // TRUE / FALSE whether this installation is marked as "default" in its corresponding loader configuration file.
- UNICODE_STRING SystemArcPath; // Normalized ARC path
- UNICODE_STRING SystemNtPath; // Corresponding NT path
+ USHORT Machine; // Target architecture of the NTOS installation
+ UNICODE_STRING SystemArcPath; // Normalized ARC path ("ArcSystemRoot")
+ UNICODE_STRING SystemNtPath; // Corresponding NT path ("NtSystemRoot")
PCWSTR PathComponent; // Pointer inside SystemNtPath.Buffer
ULONG DiskNumber;
ULONG PartitionNumber;
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7c3570f9f5362309a6681…
commit 7c3570f9f5362309a668172c913f2ff339e4467e
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Tue Jan 9 03:21:38 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue Nov 6 00:04:30 2018 +0100
[REACTOS] Add helpers and modify ConvertNtPathToWin32Path() to make it use a cache of NT/Win32 path mappings.
This increases performance for each time the SETUPLIB calls (using NT paths)
Win32 SetupAPI functions which of course only accept Win32 paths.
- Handle also the fact that a NT path to convert may start with
\Device\HarddiskX\PartitionY\..., which can be a symlink to
\Device\HarddiskVolumeN\... on some systems. In that case, the
Win32 path mapping should be done slightly differently.
- Add support for network mapped drives.
---
base/setup/reactos/reactos.c | 198 ++++++++++++++++++++++++++++-----
base/setup/reactos/reactos.h | 34 ++++++
base/setup/reactos/spapisup/fileqsup.c | 17 ++-
base/setup/reactos/spapisup/infsupp.c | 3 +-
4 files changed, 220 insertions(+), 32 deletions(-)
diff --git a/base/setup/reactos/reactos.c b/base/setup/reactos/reactos.c
index 626b0ad9f8..230eafa38c 100644
--- a/base/setup/reactos/reactos.c
+++ b/base/setup/reactos/reactos.c
@@ -1192,37 +1192,99 @@ BOOL LoadSetupData(
return ret;
}
+VOID
+InitNtToWin32PathMappingList(
+ IN OUT PNT_WIN32_PATH_MAPPING_LIST MappingList)
+{
+ InitializeListHead(&MappingList->List);
+ MappingList->MappingsCount = 0;
+}
+
+VOID
+FreeNtToWin32PathMappingList(
+ IN OUT PNT_WIN32_PATH_MAPPING_LIST MappingList)
+{
+ PLIST_ENTRY ListEntry;
+ PVOID Entry;
+
+ while (!IsListEmpty(&MappingList->List))
+ {
+ ListEntry = RemoveHeadList(&MappingList->List);
+ Entry = (PVOID)CONTAINING_RECORD(ListEntry, NT_WIN32_PATH_MAPPING, ListEntry);
+ HeapFree(ProcessHeap, 0, Entry);
+ }
+
+ MappingList->MappingsCount = 0;
+}
+
/*
* Attempts to convert a pure NT file path into a corresponding Win32 path.
* Adapted from GetInstallSourceWin32() in dll/win32/syssetup/wizard.c
*/
BOOL
ConvertNtPathToWin32Path(
+ IN OUT PNT_WIN32_PATH_MAPPING_LIST MappingList,
OUT PWSTR pwszPath,
IN DWORD cchPathMax,
IN PCWSTR pwszNTPath)
{
BOOL FoundDrive = FALSE, RetryOnce = FALSE;
+ PLIST_ENTRY ListEntry;
+ PNT_WIN32_PATH_MAPPING Entry;
+ PCWSTR pwszNtPathToMap = pwszNTPath;
+ PCWSTR pwszRemaining = NULL;
DWORD cchDrives;
PWCHAR pwszDrive;
- PCWSTR pwszRemaining = NULL;
WCHAR wszDrives[512];
WCHAR wszNTPath[MAX_PATH];
- WCHAR TargetPath[MAX_PATH] = L"";
+ WCHAR TargetPath[MAX_PATH];
*pwszPath = UNICODE_NULL;
+ /*
+ * We find first a mapping inside the MappingList. If one is found, use it
+ * to build the Win32 path. If there is none, we need to create one by
+ * checking the Win32 drives (and possibly NT symlinks too).
+ * In case of success, add the newly found mapping to the list and use it
+ * to build the Win32 path.
+ */
+
+ for (ListEntry = MappingList->List.Flink;
+ ListEntry != &MappingList->List;
+ ListEntry = ListEntry->Flink)
+ {
+ Entry = CONTAINING_RECORD(ListEntry, NT_WIN32_PATH_MAPPING, ListEntry);
+
+ DPRINT("Testing '%S' --> '%S'\n", Entry->Win32Path, Entry->NtPath);
+
+ /* Check whether the queried NT path prefixes the user-provided NT path */
+ FoundDrive = !_wcsnicmp(pwszNtPathToMap, Entry->NtPath, wcslen(Entry->NtPath));
+ if (FoundDrive)
+ {
+ /* Found it! */
+
+ /* Set the pointers and go build the Win32 path */
+ pwszDrive = Entry->Win32Path;
+ pwszRemaining = pwszNTPath + wcslen(Entry->NtPath);
+ goto Quit;
+ }
+ }
+
+ /*
+ * No mapping exists for this path yet: try to find one now.
+ */
+
/* Retrieve the mounted drives (available drive letters) */
cchDrives = GetLogicalDriveStringsW(_countof(wszDrives) - 1, wszDrives);
if (cchDrives == 0 || cchDrives >= _countof(wszDrives))
{
/* Buffer too small or failure */
- DPRINT1("GetLogicalDriveStringsW failed\n");
+ DPRINT1("ConvertNtPathToWin32Path: GetLogicalDriveStringsW failed\n");
return FALSE;
}
-
-Retry: // We go back there once if RetryOnce == TRUE
+/* We go back there once if RetryOnce == TRUE */
+Retry:
/* Enumerate the mounted drives */
for (pwszDrive = wszDrives; *pwszDrive; pwszDrive += wcslen(pwszDrive) + 1)
@@ -1235,25 +1297,87 @@ Retry: // We go back there once if RetryOnce == TRUE
DPRINT("Testing '%S' --> '%S'\n", pwszDrive, wszNTPath);
/* Check whether the queried NT path prefixes the user-provided NT path */
- if (!_wcsnicmp(wszNTPath, pwszNTPath, wcslen(wszNTPath)))
+ FoundDrive = !_wcsnicmp(pwszNtPathToMap, wszNTPath, wcslen(wszNTPath));
+ if (!FoundDrive)
+ {
+ PWCHAR ptr, ptr2;
+
+ /*
+ * Check whether this was a network share that has a drive letter,
+ * but the user-provided NT path points to this share without
+ * mentioning the drive letter.
+ *
+ * The format is: \Device\<network_redirector>\;X:<data>\share\path
+ * The corresponding drive letter is 'X'.
+ * A system-provided network redirector (LanManRedirector or Mup)
+ * or a 3rd-party one may be used.
+ *
+ * We check whether the user-provided NT path has the form:
+ * \Device\<network_redirector>\<data>\share\path
+ * as it obviously did not have the full form (the previous check
+ * would have been OK otherwise).
+ */
+ if (!_wcsnicmp(wszNTPath, L"\\Device\\", _countof(L"\\Device\\")-1) &&
+ (ptr = wcschr(wszNTPath + _countof(L"\\Device\\")-1, L'\\')) &&
+ wcslen(++ptr) >= 3 && ptr[0] == L';' && ptr[2] == L':')
+ {
+ /*
+ * Normally the specified drive letter should correspond
+ * to the one used for the mapping. But we will ignore
+ * if it happens not to be the case.
+ */
+ if (pwszDrive[0] != ptr[1])
+ {
+ DPRINT1("Peculiar: expected network share drive letter %C different from actual one %C\n",
+ pwszDrive[0], ptr[1]);
+ }
+
+ /* Remove the drive letter from the NT network share path */
+ ptr2 = ptr + 3;
+ /* Swallow as many possible consecutive backslashes as there could be */
+ while (*ptr2 == L'\\') ++ptr2;
+
+ memmove(ptr, ptr2, (wcslen(ptr2) + 1) * sizeof(WCHAR));
+
+ /* Now do the check again */
+ FoundDrive = !_wcsnicmp(pwszNtPathToMap, wszNTPath, wcslen(wszNTPath));
+ }
+ }
+ if (FoundDrive)
{
/* Found it! */
- FoundDrive = TRUE;
- if (!RetryOnce && pwszNTPath != TargetPath)
+
+ pwszDrive[2] = UNICODE_NULL; // Remove the backslash
+
+ if (pwszNtPathToMap == pwszNTPath)
+ {
+ ASSERT(!RetryOnce && pwszNTPath != TargetPath);
pwszRemaining = pwszNTPath + wcslen(wszNTPath);
+ }
break;
}
}
if (FoundDrive)
{
- pwszDrive[2] = UNICODE_NULL; // Remove the backslash
- StringCchPrintfW(pwszPath, cchPathMax,
- L"%s%s",
- pwszDrive,
- pwszRemaining);
- DPRINT1("ConvertNtPathToWin32Path: %S\n", pwszPath);
- return TRUE;
+ /* A mapping was found, add it to the cache */
+ Entry = HeapAlloc(ProcessHeap, HEAP_ZERO_MEMORY, sizeof(*Entry));
+ if (!Entry)
+ {
+ DPRINT1("ConvertNtPathToWin32Path: Cannot allocate memory\n");
+ return FALSE;
+ }
+ StringCchCopyNW(Entry->NtPath, _countof(Entry->NtPath),
+ pwszNTPath, pwszRemaining - pwszNTPath);
+ StringCchCopyW(Entry->Win32Path, _countof(Entry->Win32Path), pwszDrive);
+
+ /* Insert it as the most recent entry */
+ InsertHeadList(&MappingList->List, &Entry->ListEntry);
+ MappingList->MappingsCount++;
+
+ /* Set the pointers and go build the Win32 path */
+ pwszDrive = Entry->Win32Path;
+ goto Quit;
}
/*
@@ -1309,10 +1433,12 @@ Retry: // We go back there once if RetryOnce == TRUE
if (!NT_SUCCESS(Status))
{
/* Not a symlink, or something else happened: bail out */
- DPRINT1("NtOpenSymbolicLinkObject(%wZ) failed, Status 0x%08lx\n", &SymLink, Status);
+ DPRINT1("ConvertNtPathToWin32Path: NtOpenSymbolicLinkObject(%wZ) failed, Status 0x%08lx\n",
+ &SymLink, Status);
return FALSE;
}
+ *TargetPath = UNICODE_NULL;
RtlInitEmptyUnicodeString(&Target, TargetPath, sizeof(TargetPath));
/* Resolve the link and close its handle */
@@ -1323,25 +1449,41 @@ Retry: // We go back there once if RetryOnce == TRUE
if (!NT_SUCCESS(Status))
{
/* Not a symlink, or something else happened: bail out */
- DPRINT1("NtQuerySymbolicLinkObject(%wZ) failed, Status 0x%08lx\n", &SymLink, Status);
+ DPRINT1("ConvertNtPathToWin32Path: NtQuerySymbolicLinkObject(%wZ) failed, Status 0x%08lx\n",
+ &SymLink, Status);
return FALSE;
}
- /* Set pointers */
+ /* Set the pointers */
pwszRemaining = pwszNTPath + Length;
- pwszNTPath = TargetPath;
+ pwszNtPathToMap = TargetPath; // Point to our local buffer
/* Retry once */
RetryOnce = TRUE;
goto Retry;
}
+ ASSERT(!FoundDrive);
+
+Quit:
+ if (FoundDrive)
+ {
+ StringCchPrintfW(pwszPath, cchPathMax,
+ L"%s%s",
+ pwszDrive,
+ pwszRemaining);
+ DPRINT("ConvertNtPathToWin32Path: %S\n", pwszPath);
+ return TRUE;
+ }
+
return FALSE;
}
/* Used to enable and disable the shutdown privilege */
/* static */ BOOL
-EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
+EnablePrivilege(
+ IN LPCWSTR lpszPrivilegeName,
+ IN BOOL bEnablePrivilege)
{
BOOL Success;
HANDLE hToken;
@@ -1382,6 +1524,14 @@ _tWinMain(HINSTANCE hInst,
ProcessHeap = GetProcessHeap();
+ SetupData.hInstance = hInst;
+ SetupData.hInstallThread = NULL;
+ SetupData.hHaltInstallEvent = NULL;
+ SetupData.bStopInstall = FALSE;
+
+ /* Initialize the NT to Win32 path prefix mapping list */
+ InitNtToWin32PathMappingList(&SetupData.MappingList);
+
/* Initialize Setup, phase 0 */
InitializeSetup(&SetupData.USetupData, 0);
@@ -1406,11 +1556,6 @@ _tWinMain(HINSTANCE hInst,
if (!LoadSetupData(&SetupData))
goto Quit;
- SetupData.hInstance = hInst;
- SetupData.hInstallThread = NULL;
- SetupData.hHaltInstallEvent = NULL;
- SetupData.bStopInstall = FALSE;
-
CheckUnattendedSetup(&SetupData.USetupData);
SetupData.bUnattend = IsUnattendedSetup; // FIXME :-)
@@ -1544,6 +1689,9 @@ Quit:
/* Setup has finished */
FinishSetup(&SetupData.USetupData);
+ /* Free the NT to Win32 path prefix mapping list */
+ FreeNtToWin32PathMappingList(&SetupData.MappingList);
+
#if 0 // NOTE: Disabled for testing purposes only!
EnablePrivilege(SE_SHUTDOWN_NAME, TRUE);
ExitWindowsEx(EWX_REBOOT, 0);
diff --git a/base/setup/reactos/reactos.h b/base/setup/reactos/reactos.h
index 0c4a76eb40..ded1d85f74 100644
--- a/base/setup/reactos/reactos.h
+++ b/base/setup/reactos/reactos.h
@@ -66,6 +66,35 @@ typedef struct _KBLAYOUT
#endif
+/*
+ * A mapping entry that maps an NT path to a corresponding Win32 path.
+ *
+ * Example is:
+ * NT path: "\Device\Harddisk0\Partition1\some\path1"
+ * Win32 path: "C:\some\path1"
+ *
+ * Here, the NT path prefix to be cached is only
+ * "\Device\Harddisk0\Partition1\", to be mapped with "C:\".
+ *
+ * Then the same entry would be reused if one wants to convert
+ * the NT path "\Device\Harddisk0\Partition1\another\path2",
+ * which converts to the Win32 path "C:\another\path2" .
+ */
+typedef struct _NT_WIN32_PATH_MAPPING
+{
+ LIST_ENTRY ListEntry;
+ WCHAR NtPath[MAX_PATH]; // MAX_PATH for both entries should be more than enough.
+ WCHAR Win32Path[MAX_PATH];
+} NT_WIN32_PATH_MAPPING, *PNT_WIN32_PATH_MAPPING;
+
+/* The list of NT to Win32 path prefix mappings */
+typedef struct _NT_WIN32_PATH_MAPPING_LIST
+{
+ LIST_ENTRY List;
+ ULONG MappingsCount;
+} NT_WIN32_PATH_MAPPING_LIST, *PNT_WIN32_PATH_MAPPING_LIST;
+
+
typedef struct _SETUPDATA
{
/* General */
@@ -81,6 +110,8 @@ typedef struct _SETUPDATA
TCHAR szAbortMessage[512];
TCHAR szAbortTitle[64];
+ NT_WIN32_PATH_MAPPING_LIST MappingList;
+
USETUP_DATA USetupData;
BOOLEAN RepairUpdateFlag; // flag for update/repair an installed reactos
@@ -113,6 +144,8 @@ typedef struct _SETUPDATA
extern HANDLE ProcessHeap;
extern BOOLEAN IsUnattendedSetup;
+extern SETUPDATA SetupData;
+
typedef struct _IMGINFO
{
@@ -128,6 +161,7 @@ typedef struct _IMGINFO
*/
BOOL
ConvertNtPathToWin32Path(
+ IN OUT PNT_WIN32_PATH_MAPPING_LIST MappingList,
OUT PWSTR pwszPath,
IN DWORD cchPathMax,
IN PCWSTR pwszNTPath);
diff --git a/base/setup/reactos/spapisup/fileqsup.c b/base/setup/reactos/spapisup/fileqsup.c
index 9c15f8cdac..ea46c03f75 100644
--- a/base/setup/reactos/spapisup/fileqsup.c
+++ b/base/setup/reactos/spapisup/fileqsup.c
@@ -38,7 +38,8 @@ SpFileQueueCopy_NtToWin32(
* the Win32 SetupQueueCopyW API only takes Win32 paths. We therefore
* map the NT path to Win32 path and then call the Win32 API.
*/
- if (!ConvertNtPathToWin32Path(Win32SourceRootPath,
+ if (!ConvertNtPathToWin32Path(&SetupData.MappingList,
+ Win32SourceRootPath,
_countof(Win32SourceRootPath),
SourceRootPath))
{
@@ -46,7 +47,8 @@ SpFileQueueCopy_NtToWin32(
}
/* SourcePath, SourceFileName and SourceCabinet are appended to SourceRootPath by the SetupApi function */
- if (!ConvertNtPathToWin32Path(Win32TargetDirectory,
+ if (!ConvertNtPathToWin32Path(&SetupData.MappingList,
+ Win32TargetDirectory,
_countof(Win32TargetDirectory),
TargetDirectory))
{
@@ -64,7 +66,7 @@ SpFileQueueCopy_NtToWin32(
SourcePath,
SourceFileName,
// Undocumented on MSDN is the fact that this parameter is mandatory *IF* one wants to take the TagFile into account!
- L"foobar",
+ L"ReactOS",
// SourceTagFile -- Special behaviour: use cabinet file present in ArchiveDir path! The API does not check for a ".cab" extension.
SourceCabinet,
Win32TargetDirectory,
@@ -88,7 +90,8 @@ SpFileQueueDelete_NtToWin32(
* the Win32 SetupQueueDeleteW API only takes Win32 paths. We therefore
* map the NT path to Win32 path and then call the Win32 API.
*/
- if (!ConvertNtPathToWin32Path(Win32PathPart1,
+ if (!ConvertNtPathToWin32Path(&SetupData.MappingList,
+ Win32PathPart1,
_countof(Win32PathPart1),
PathPart1))
{
@@ -116,7 +119,8 @@ SpFileQueueRename_NtToWin32(
* the Win32 SetupQueueRenameW API only takes Win32 paths. We therefore
* map the NT path to Win32 path and then call the Win32 API.
*/
- if (!ConvertNtPathToWin32Path(Win32SourcePath,
+ if (!ConvertNtPathToWin32Path(&SetupData.MappingList,
+ Win32SourcePath,
_countof(Win32SourcePath),
SourcePath))
{
@@ -126,7 +130,8 @@ SpFileQueueRename_NtToWin32(
if (TargetPath)
{
- if (!ConvertNtPathToWin32Path(Win32TargetPath,
+ if (!ConvertNtPathToWin32Path(&SetupData.MappingList,
+ Win32TargetPath,
_countof(Win32TargetPath),
TargetPath))
{
diff --git a/base/setup/reactos/spapisup/infsupp.c b/base/setup/reactos/spapisup/infsupp.c
index 7c40e8421e..98e48b07bb 100644
--- a/base/setup/reactos/spapisup/infsupp.c
+++ b/base/setup/reactos/spapisup/infsupp.c
@@ -48,7 +48,8 @@ SetupOpenInfFileExW(
* 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,
+ if (!ConvertNtPathToWin32Path(&SetupData.MappingList,
+ Win32FileName,
_countof(Win32FileName),
FileName))
{