https://git.reactos.org/?p=reactos.git;a=commitdiff;h=563d9f26c4ab04145ae5c…
commit 563d9f26c4ab04145ae5cf9054e125d9c40b5c87
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed May 31 01:11:05 2017 +0000
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Jun 3 22:12:45 2018 +0200
[SETUPLIB] Adjustments in the code.
- Call OpenAndMapFile() with its new ReadWrite parameter;
- Add informative comments in osdetect.c;
- In partlist.c, check whether a disk has a valid MBR by also checking for its 0xAA55
signature.
svn path=/branches/setup_improvements/; revision=74712
---
base/setup/lib/bldrsup.c | 4 ++--
base/setup/lib/osdetect.c | 13 ++++++++++++-
base/setup/lib/partlist.c | 9 ++++++---
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/base/setup/lib/bldrsup.c b/base/setup/lib/bldrsup.c
index 493c52237e..13a1ed34e8 100644
--- a/base/setup/lib/bldrsup.c
+++ b/base/setup/lib/bldrsup.c
@@ -89,7 +89,7 @@ FindNTOSBootLoader( // By handle
#if 0
/* Check whether the loader configuration file exists */
Status = OpenAndMapFile(PartitionHandle,
NtosBootLoaders[Type].LoaderConfigurationFile,
- &FileHandle, &SectionHandle, &ViewBase,
&FileSize);
+ &FileHandle, &SectionHandle, &ViewBase,
&FileSize, FALSE);
if (!NT_SUCCESS(Status))
{
/* The loader does not exist, continue with another one */
@@ -314,7 +314,7 @@ EnumerateNTOSBootEntries(
/* Check whether the loader configuration file exists */
Status = OpenAndMapFile(PartitionHandle,
NtosBootLoaders[Type].LoaderConfigurationFile,
- &FileHandle, &SectionHandle, &ViewBase,
&FileSize);
+ &FileHandle, &SectionHandle, &ViewBase,
&FileSize, FALSE);
if (!NT_SUCCESS(Status))
{
/* The loader does not exist, continue with another one */
diff --git a/base/setup/lib/osdetect.c b/base/setup/lib/osdetect.c
index 20611bdc02..6b16e5624d 100644
--- a/base/setup/lib/osdetect.c
+++ b/base/setup/lib/osdetect.c
@@ -150,6 +150,8 @@ EnumerateInstallations(
{
/* This is not a ReactOS entry */
/* Certainly not a ReactOS installation */
+ DPRINT1(" A Win2k3 install '%wZ' without an ARC
path?!\n", &InstallName);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
}
@@ -171,6 +173,7 @@ EnumerateInstallations(
{
DPRINT1(" An NTOS installation with name \"%S\" already exists
in SystemRoot '%wZ'\n",
NtOsInstall->InstallationName, &NtOsInstall->SystemArcPath);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
@@ -183,6 +186,7 @@ EnumerateInstallations(
if (!ArcPathToNtPath(&SystemRootPath, BootEntry->OsLoadPath,
Data->PartList))
{
DPRINT1("ArcPathToNtPath(%S) failed, skip the installation.\n",
BootEntry->OsLoadPath);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
@@ -198,6 +202,7 @@ EnumerateInstallations(
{
DPRINT1(" An NTOS installation with name \"%S\" already exists
in SystemRoot '%wZ'\n",
NtOsInstall->InstallationName, &NtOsInstall->SystemNtPath);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
@@ -205,7 +210,10 @@ EnumerateInstallations(
/* Check if this is a valid NTOS installation; stop there if it isn't one */
if (!IsValidNTOSInstallation_UStr(&SystemRootPath))
+ {
+ /* Continue the enumeration */
return STATUS_SUCCESS;
+ }
DPRINT1("Found a valid NTOS installation in SystemRoot ARC path '%S', NT
path '%wZ'\n",
BootEntry->OsLoadPath, &SystemRootPath);
@@ -228,6 +236,7 @@ EnumerateInstallations(
DPRINT1("NtPathToDiskPartComponents(%wZ) failed\n",
&SystemRootPath);
}
+ /* Add the discovered NTOS installation into the list */
if (PartEntry && PartEntry->DriveLetter)
{
/* We have retrieved a partition that is mounted */
@@ -245,6 +254,7 @@ EnumerateInstallations(
DiskNumber, PartitionNumber, PartEntry,
InstallNameW);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
@@ -301,7 +311,8 @@ CheckForValidPEAndVendor(
VendorName->Length = 0;
Status = OpenAndMapFile(RootDirectory, PathNameToFile,
- &FileHandle, &SectionHandle, &ViewBase, NULL);
+ &FileHandle, &SectionHandle, &ViewBase,
+ NULL, FALSE);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to open and map file '%S', Status 0x%08lx\n",
PathNameToFile, Status);
diff --git a/base/setup/lib/partlist.c b/base/setup/lib/partlist.c
index 7b74cda8f0..f29b2859a6 100644
--- a/base/setup/lib/partlist.c
+++ b/base/setup/lib/partlist.c
@@ -989,9 +989,12 @@ AddDiskToList(
// DiskEntry->Signature = Signature;
DiskEntry->BiosFound = FALSE;
- /* Check if this disk has a valid MBR */
- // FIXME: Check for the MBR signature as well, etc...
- if (Mbr->BootCode[0] == 0 && Mbr->BootCode[1] == 0)
+ /*
+ * Check if this disk has a valid MBR: verify its signature,
+ * and whether its two first bytes are a valid instruction
+ * (related to this, see IsThereAValidBootSector() in partlist.c).
+ */
+ if (Mbr->Magic != 0xaa55 || (*(PUSHORT)Mbr->BootCode) == 0x0000)
DiskEntry->NoMbr = TRUE;
else
DiskEntry->NoMbr = FALSE;