Author: hbelusca
Date: Wed May 31 01:11:05 2017
New Revision: 74712
URL: http://svn.reactos.org/svn/reactos?rev=74712&view=rev
Log:
[SETUPLIB]: Adjustments:
- 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.
Modified:
branches/setup_improvements/base/setup/lib/bldrsup.c
branches/setup_improvements/base/setup/lib/osdetect.c
branches/setup_improvements/base/setup/lib/partlist.c
Modified: branches/setup_improvements/base/setup/lib/bldrsup.c
URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/bldrsup.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/bldrsup.c [iso-8859-1] Wed May 31 01:11:05 2017
@@ -90,7 +90,7 @@
#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 */
@@ -315,7 +315,7 @@
/* 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 */
Modified: branches/setup_improvements/base/setup/lib/osdetect.c
URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/osdetect.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/osdetect.c [iso-8859-1] Wed May 31 01:11:05 2017
@@ -148,6 +148,8 @@
{
/* 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;
}
}
@@ -169,6 +171,7 @@
{
DPRINT1(" An NTOS installation with name \"%S\" already exists in SystemRoot '%wZ'\n",
NtOsInstall->InstallationName, &NtOsInstall->SystemArcPath);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
@@ -181,6 +184,7 @@
if (!ArcPathToNtPath(&SystemRootPath, BootEntry->OsLoadPath, Data->PartList))
{
DPRINT1("ArcPathToNtPath(%S) failed, skip the installation.\n", BootEntry->OsLoadPath);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
@@ -196,6 +200,7 @@
{
DPRINT1(" An NTOS installation with name \"%S\" already exists in SystemRoot '%wZ'\n",
NtOsInstall->InstallationName, &NtOsInstall->SystemNtPath);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
@@ -203,7 +208,10 @@
/* 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);
@@ -226,6 +234,7 @@
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 */
@@ -243,6 +252,7 @@
DiskNumber, PartitionNumber, PartEntry,
InstallNameW);
+ /* Continue the enumeration */
return STATUS_SUCCESS;
}
@@ -299,7 +309,8 @@
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);
Modified: branches/setup_improvements/base/setup/lib/partlist.c
URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/partlist.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/partlist.c [iso-8859-1] Wed May 31 01:11:05 2017
@@ -995,9 +995,12 @@
// 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;
Author: hbelusca
Date: Wed May 31 00:03:33 2017
New Revision: 74709
URL: http://svn.reactos.org/svn/reactos?rev=74709&view=rev
Log:
[NTOS]: Underline the fact that CmpGetRegistryPath (especially when being run in 1st-stage text mode) is just a big hack (introduced in r3794 and r3795). I however need to monitor its output for the moment...
Modified:
trunk/reactos/ntoskrnl/config/cmsysini.c
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] Wed May 31 00:03:33 2017
@@ -1192,6 +1192,8 @@
/* Check if we are booted in setup */
if (ExpInTextModeSetup)
{
+ DPRINT1("CmpGetRegistryPath TextMode setup HACK!!\n");
+
/* Setup the object attributes */
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
@@ -1244,6 +1246,8 @@
/* Add registry path */
wcscat(ConfigPath, L"\\System32\\Config\\");
+
+ DPRINT1("CmpGetRegistryPath: ConfigPath = '%S'\n", ConfigPath);
/* Done */
return STATUS_SUCCESS;
Author: hbelusca
Date: Wed May 31 00:01:31 2017
New Revision: 74708
URL: http://svn.reactos.org/svn/reactos?rev=74708&view=rev
Log:
[NTOS]: Minor fixes:
- Correctly specify the buffer size for RtlInitEmptyUnicodeString calls;
- Prefer using RtlAppendUnicodeStringToString instead of RtlAppendStringToString: both actually do the very same job on counted strings, but the former doesn't need the explicit PSTRING casts, and NULL-terminate the string buffer if possible (aka. if the available remaining length permits it, otherwise it doesn't add any NULL terminator, falling back to the default behaviour of RtlAppendStringToString).
- Remove a deprecated commented-out variable.
Modified:
trunk/reactos/ntoskrnl/config/cmsysini.c
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] Wed May 31 00:01:31 2017
@@ -1179,7 +1179,7 @@
NTSTATUS
NTAPI
-CmpGetRegistryPath(IN PWCHAR ConfigPath)
+CmpGetRegistryPath(OUT PWCHAR ConfigPath)
{
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
@@ -1257,7 +1257,6 @@
UNICODE_STRING TempName, FileName, RegName;
ULONG i, ErrorResponse, WorkerCount, Length;
USHORT FileStart;
- //ULONG RegStart;
ULONG PrimaryDisposition, SecondaryDisposition, ClusterSize;
PCMHIVE CmHive;
HANDLE PrimaryHandle = NULL, LogHandle = NULL;
@@ -1273,36 +1272,35 @@
CmpMachineHiveList[i].ThreadStarted = TRUE;
/* Build the file name and registry name strings */
- RtlInitEmptyUnicodeString(&FileName, FileBuffer, MAX_PATH);
- RtlInitEmptyUnicodeString(&RegName, RegBuffer, MAX_PATH);
+ RtlInitEmptyUnicodeString(&FileName, FileBuffer, sizeof(FileBuffer));
+ RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
/* Now build the system root path */
CmpGetRegistryPath(ConfigPath);
RtlInitUnicodeString(&TempName, ConfigPath);
- RtlAppendStringToString((PSTRING)&FileName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&FileName, &TempName);
FileStart = FileName.Length;
/* And build the registry root path */
RtlInitUnicodeString(&TempName, L"\\REGISTRY\\");
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
- //RegStart = RegName.Length;
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
/* Build the base name */
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].BaseName);
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
/* Check if this is a child of the root */
- if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == '\\')
+ if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == OBJ_NAME_PATH_SEPARATOR)
{
/* Then setup the whole name */
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].Name);
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
}
/* Now add the rest of the file name */
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].Name);
FileName.Length = FileStart;
- RtlAppendStringToString((PSTRING)&FileName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&FileName, &TempName);
if (!CmpMachineHiveList[i].CmHive)
{
/* We need to allocate a new hive structure */
@@ -1426,17 +1424,17 @@
CmpNoWrite = FALSE;
/* Build the file name and registry name strings */
- RtlInitEmptyUnicodeString(&FileName, FileBuffer, MAX_PATH);
- RtlInitEmptyUnicodeString(&RegName, RegBuffer, MAX_PATH);
+ RtlInitEmptyUnicodeString(&FileName, FileBuffer, sizeof(FileBuffer));
+ RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
/* Now build the system root path */
CmpGetRegistryPath(ConfigPath);
RtlInitUnicodeString(&TempName, ConfigPath);
- RtlAppendStringToString((PSTRING)&FileName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&FileName, &TempName);
/* And build the registry root path */
RtlInitUnicodeString(&TempName, L"\\REGISTRY\\");
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
RegStart = RegName.Length;
/* Setup the event to synchronize workers */
@@ -1504,14 +1502,14 @@
/* Build the base name */
RegName.Length = RegStart;
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].BaseName);
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
/* Check if this is a child of the root */
- if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == '\\')
+ if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == OBJ_NAME_PATH_SEPARATOR)
{
/* Then setup the whole name */
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].Name);
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
}
/* Now link the hive to its master */