[SETUPLIB][USETUP] Diverse additions.

- Use NT string safe functions.
- Add support for other bootloaders;
- Update a couple of comments;
- Remove deprecated __REACTOS__ #ifdefs.

svn path=/branches/setup_improvements/; revision=74713
This commit is contained in:
Hermès Bélusca-Maïto 2017-05-31 03:43:12 +02:00
parent 563d9f26c4
commit cacae6d9a0
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
5 changed files with 166 additions and 92 deletions

View file

@ -127,11 +127,11 @@ _MyGetFileSystem(
FileFsAttribute = (PFILE_FS_ATTRIBUTE_INFORMATION)Buffer; FileFsAttribute = (PFILE_FS_ATTRIBUTE_INFORMATION)Buffer;
/* Set PartitionRootPath */ /* Set PartitionRootPath */
swprintf(PathBuffer, RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
// L"\\Device\\Harddisk%lu\\Partition%lu", // Should work! But because ReactOS sucks atm. it actually doesn't work!! // L"\\Device\\Harddisk%lu\\Partition%lu", // Should work! But because ReactOS sucks atm. it actually doesn't work!!
L"\\Device\\Harddisk%lu\\Partition%lu\\", // HACK: Use this as a temporary hack! L"\\Device\\Harddisk%lu\\Partition%lu\\", // HACK: Use this as a temporary hack!
PartEntry->DiskEntry->DiskNumber, PartEntry->DiskEntry->DiskNumber,
PartEntry->PartitionNumber); PartEntry->PartitionNumber);
RtlInitUnicodeString(&PartitionRootPath, PathBuffer); RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath); DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);

View file

@ -110,9 +110,9 @@ GetDriverName(
RtlInitUnicodeString(&DiskEntry->DriverName, RtlInitUnicodeString(&DiskEntry->DriverName,
NULL); NULL);
swprintf(KeyName, RtlStringCchPrintfW(KeyName, ARRAYSIZE(KeyName),
L"\\Scsi\\Scsi Port %hu", L"\\Scsi\\Scsi Port %hu",
DiskEntry->Port); DiskEntry->Port);
RtlZeroMemory(&QueryTable, RtlZeroMemory(&QueryTable,
sizeof(QueryTable)); sizeof(QueryTable));
@ -366,7 +366,9 @@ EnumerateBiosDiskEntries(
AdapterCount = 0; AdapterCount = 0;
while (1) while (1)
{ {
swprintf(Name, L"%s\\%lu", ROOT_NAME, AdapterCount); RtlStringCchPrintfW(Name, ARRAYSIZE(Name),
L"%s\\%lu",
ROOT_NAME, AdapterCount);
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
Name, Name,
&QueryTable[2], &QueryTable[2],
@ -377,7 +379,9 @@ EnumerateBiosDiskEntries(
break; break;
} }
swprintf(Name, L"%s\\%lu\\DiskController", ROOT_NAME, AdapterCount); RtlStringCchPrintfW(Name, ARRAYSIZE(Name),
L"%s\\%lu\\DiskController",
ROOT_NAME, AdapterCount);
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
Name, Name,
&QueryTable[2], &QueryTable[2],
@ -387,7 +391,9 @@ EnumerateBiosDiskEntries(
{ {
while (1) while (1)
{ {
swprintf(Name, L"%s\\%lu\\DiskController\\0", ROOT_NAME, AdapterCount); RtlStringCchPrintfW(Name, ARRAYSIZE(Name),
L"%s\\%lu\\DiskController\\0",
ROOT_NAME, AdapterCount);
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
Name, Name,
&QueryTable[2], &QueryTable[2],
@ -399,7 +405,9 @@ EnumerateBiosDiskEntries(
return; return;
} }
swprintf(Name, L"%s\\%lu\\DiskController\\0\\DiskPeripheral", ROOT_NAME, AdapterCount); RtlStringCchPrintfW(Name, ARRAYSIZE(Name),
L"%s\\%lu\\DiskController\\0\\DiskPeripheral",
ROOT_NAME, AdapterCount);
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
Name, Name,
&QueryTable[2], &QueryTable[2],
@ -421,7 +429,9 @@ EnumerateBiosDiskEntries(
break; break;
} }
swprintf(Name, L"%s\\%lu\\DiskController\\0\\DiskPeripheral\\%lu", ROOT_NAME, AdapterCount, DiskCount); RtlStringCchPrintfW(Name, ARRAYSIZE(Name),
L"%s\\%lu\\DiskController\\0\\DiskPeripheral\\%lu",
ROOT_NAME, AdapterCount, DiskCount);
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
Name, Name,
QueryTable, QueryTable,
@ -974,7 +984,8 @@ AddDiskToList(
} }
Checksum = ~Checksum + 1; Checksum = ~Checksum + 1;
swprintf(Identifier, L"%08x-%08x-A", Checksum, Signature); RtlStringCchPrintfW(Identifier, ARRAYSIZE(Identifier),
L"%08x-%08x-A", Checksum, Signature);
DPRINT("Identifier: %S\n", Identifier); DPRINT("Identifier: %S\n", Identifier);
DiskEntry = RtlAllocateHeap(ProcessHeap, DiskEntry = RtlAllocateHeap(ProcessHeap,
@ -1205,7 +1216,7 @@ CreatePartitionList(VOID)
List = (PPARTLIST)RtlAllocateHeap(ProcessHeap, List = (PPARTLIST)RtlAllocateHeap(ProcessHeap,
0, 0,
sizeof (PARTLIST)); sizeof(PARTLIST));
if (List == NULL) if (List == NULL)
return NULL; return NULL;
@ -1233,11 +1244,10 @@ CreatePartitionList(VOID)
for (DiskNumber = 0; DiskNumber < Sdi.NumberOfDisks; DiskNumber++) for (DiskNumber = 0; DiskNumber < Sdi.NumberOfDisks; DiskNumber++)
{ {
swprintf(Buffer, RtlStringCchPrintfW(Buffer, ARRAYSIZE(Buffer),
L"\\Device\\Harddisk%d\\Partition0", L"\\Device\\Harddisk%lu\\Partition0",
DiskNumber); DiskNumber);
RtlInitUnicodeString(&Name, RtlInitUnicodeString(&Name, Buffer);
Buffer);
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&Name, &Name,
@ -2460,7 +2470,7 @@ DeleteCurrentPartition(
RtlFreeHeap(ProcessHeap, 0, PartEntry); RtlFreeHeap(ProcessHeap, 0, PartEntry);
/* Remove the next entry */ /* Remove the next entry */
RemoveEntryList (&NextPartEntry->ListEntry); RemoveEntryList(&NextPartEntry->ListEntry);
RtlFreeHeap(ProcessHeap, 0, NextPartEntry); RtlFreeHeap(ProcessHeap, 0, NextPartEntry);
/* Update current partition */ /* Update current partition */
@ -2764,11 +2774,10 @@ WritePartitions(
DPRINT("WritePartitions() Disk: %lu\n", DiskEntry->DiskNumber); DPRINT("WritePartitions() Disk: %lu\n", DiskEntry->DiskNumber);
swprintf(DstPath, RtlStringCchPrintfW(DstPath, ARRAYSIZE(DstPath),
L"\\Device\\Harddisk%d\\Partition0", L"\\Device\\Harddisk%lu\\Partition0",
DiskEntry->DiskNumber); DiskEntry->DiskNumber);
RtlInitUnicodeString(&Name, RtlInitUnicodeString(&Name, DstPath);
DstPath);
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&Name, &Name,
0, 0,
@ -2865,7 +2874,8 @@ SetMountedDeviceValue(
NTSTATUS Status; NTSTATUS Status;
HANDLE KeyHandle; HANDLE KeyHandle;
swprintf(ValueNameBuffer, L"\\DosDevices\\%C:", Letter); RtlStringCchPrintfW(ValueNameBuffer, ARRAYSIZE(ValueNameBuffer),
L"\\DosDevices\\%C:", Letter);
RtlInitUnicodeString(&ValueName, ValueNameBuffer); RtlInitUnicodeString(&ValueName, ValueNameBuffer);
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,

View file

@ -14,10 +14,7 @@
#define _INC_WINDOWS #define _INC_WINDOWS
#define COM_NO_WINDOWS_H #define COM_NO_WINDOWS_H
#include <wingdi.h> // For LF_FACESIZE and TranslateCharsetInfo() #include <winxxx.h>
#include <wincon.h>
#include <winnls.h> // For code page support
#include <winreg.h>
#endif #endif
@ -29,6 +26,7 @@ extern HANDLE ProcessHeap;
#include "linklist.h" #include "linklist.h"
#include "ntverrsrc.h" #include "ntverrsrc.h"
// #include "arcname.h" // #include "arcname.h"
#include "bldrsup.h"
#include "filesup.h" #include "filesup.h"
#include "fsutil.h" #include "fsutil.h"
#include "genlist.h" #include "genlist.h"

View file

@ -435,13 +435,13 @@ CreateFreeLoaderIniForReactOS(
static static
NTSTATUS NTSTATUS
CreateFreeLoaderIniForReactOSAndBootSector( CreateFreeLoaderIniForReactOSAndBootSector(
PWCHAR IniPath, IN PCWSTR IniPath,
PWCHAR ArcPath, IN PCWSTR ArcPath,
PWCHAR Section, IN PCWSTR Section,
PWCHAR Description, IN PCWSTR Description,
PWCHAR BootDrive, IN PCWSTR BootDrive,
PWCHAR BootPartition, IN PCWSTR BootPartition,
PWCHAR BootSector) IN PCWSTR BootSector)
{ {
PINICACHE IniCache; PINICACHE IniCache;
PINICACHESECTION IniSection; PINICACHESECTION IniSection;
@ -453,7 +453,7 @@ CreateFreeLoaderIniForReactOSAndBootSector(
CreateCommonFreeLoaderSections(IniCache); CreateCommonFreeLoaderSections(IniCache);
/* Add the ReactOS entries */ /* Add the ReactOS entries */
CreateFreeLoaderReactOSEntries(IniCache, ArcPath); CreateFreeLoaderReactOSEntries(IniCache, (PWCHAR)ArcPath);
/* Get "Operating Systems" section */ /* Get "Operating Systems" section */
IniSection = IniCacheGetSection(IniCache, L"Operating Systems"); IniSection = IniCacheGetSection(IniCache, L"Operating Systems");
@ -462,11 +462,11 @@ CreateFreeLoaderIniForReactOSAndBootSector(
IniCacheInsertKey(IniSection, IniCacheInsertKey(IniSection,
NULL, NULL,
INSERT_LAST, INSERT_LAST,
Section, (PWCHAR)Section,
Description); (PWCHAR)Description);
/* Create new section */ /* Create new section */
IniSection = IniCacheAppendSection(IniCache, Section); IniSection = IniCacheAppendSection(IniCache, (PWCHAR)Section);
/* BootType=BootSector */ /* BootType=BootSector */
IniCacheInsertKey(IniSection, IniCacheInsertKey(IniSection,
@ -480,24 +480,24 @@ CreateFreeLoaderIniForReactOSAndBootSector(
NULL, NULL,
INSERT_LAST, INSERT_LAST,
L"BootDrive", L"BootDrive",
BootDrive); (PWCHAR)BootDrive);
/* BootPartition= */ /* BootPartition= */
IniCacheInsertKey(IniSection, IniCacheInsertKey(IniSection,
NULL, NULL,
INSERT_LAST, INSERT_LAST,
L"BootPartition", L"BootPartition",
BootPartition); (PWCHAR)BootPartition);
/* BootSector= */ /* BootSector= */
IniCacheInsertKey(IniSection, IniCacheInsertKey(IniSection,
NULL, NULL,
INSERT_LAST, INSERT_LAST,
L"BootSectorFile", L"BootSectorFile",
BootSector); (PWCHAR)BootSector);
/* Save the INI file */ /* Save the INI file */
IniCacheSave(IniCache, IniPath); IniCacheSave(IniCache, (PWCHAR)IniPath);
IniCacheDestroy(IniCache); IniCacheDestroy(IniCache);
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -2260,9 +2260,9 @@ InstallFatBootcodeToPartition(
/* FAT or FAT32 partition */ /* FAT or FAT32 partition */
DPRINT("System path: '%wZ'\n", SystemRootPath); DPRINT("System path: '%wZ'\n", SystemRootPath);
/* Copy FreeLoader to the system partition */ /* Copy FreeLoader to the system partition, always overwriting the older version */
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys"); CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.sys"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath); DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
Status = SetupCopyFile(SrcPath, DstPath); Status = SetupCopyFile(SrcPath, DstPath);
@ -2272,8 +2272,8 @@ InstallFatBootcodeToPartition(
return Status; return Status;
} }
/* Prepare for possibly copying 'freeldr.ini' */ /* Prepare for possibly updating 'freeldr.ini' */
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
DoesFreeLdrExist = DoesFileExist(NULL, DstPath); DoesFreeLdrExist = DoesFileExist(NULL, DstPath);
if (DoesFreeLdrExist) if (DoesFreeLdrExist)
@ -2292,10 +2292,12 @@ InstallFatBootcodeToPartition(
/* Check for NT and other bootloaders */ /* Check for NT and other bootloaders */
// FIXME: Check for Vista+ bootloader! // FIXME: Check for Vista+ bootloader!
if (DoesFileExist_2(SystemRootPath->Buffer, L"ntldr") == TRUE || /*** Status = FindNTOSBootLoader(PartitionHandle, NtLdr, &Version); ***/
DoesFileExist_2(SystemRootPath->Buffer, L"boot.ini") == TRUE) /*** Status = FindNTOSBootLoader(PartitionHandle, BootMgr, &Version); ***/
if (DoesFileExist_2(SystemRootPath->Buffer, L"NTLDR") == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"BOOT.INI") == TRUE)
{ {
/* Search root directory for 'ntldr' and 'boot.ini' */ /* Search root directory for 'NTLDR' and 'BOOT.INI' */
DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n"); DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
/* Create or update 'freeldr.ini' */ /* Create or update 'freeldr.ini' */
@ -2303,7 +2305,7 @@ InstallFatBootcodeToPartition(
{ {
/* Create new 'freeldr.ini' */ /* Create new 'freeldr.ini' */
DPRINT1("Create new 'freeldr.ini'\n"); DPRINT1("Create new 'freeldr.ini'\n");
// CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini"); // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -2313,7 +2315,7 @@ InstallFatBootcodeToPartition(
} }
/* Install new bootcode into a file */ /* Install new bootcode into a file */
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\bootsect.ros"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"bootsect.ros");
if (PartitionType == PARTITION_FAT32 || if (PartitionType == PARTITION_FAT32 ||
PartitionType == PARTITION_FAT32_XINT13) PartitionType == PARTITION_FAT32_XINT13)
@ -2347,7 +2349,7 @@ InstallFatBootcodeToPartition(
} }
/* Update 'boot.ini' */ /* Update 'boot.ini' */
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\boot.ini"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"boot.ini");
DPRINT1("Update 'boot.ini': %S\n", DstPath); DPRINT1("Update 'boot.ini': %S\n", DstPath);
Status = UpdateBootIni(DstPath, Status = UpdateBootIni(DstPath,
@ -2363,31 +2365,97 @@ InstallFatBootcodeToPartition(
{ {
/* Non-NT bootloaders: install our own bootloader */ /* Non-NT bootloaders: install our own bootloader */
PWCHAR Section; PCWSTR Section;
PWCHAR Description; PCWSTR Description;
PWCHAR BootDrive; PCWSTR BootDrive;
PWCHAR BootPartition; PCWSTR BootPartition;
PWCHAR BootSector; PCWSTR BootSector;
PWCHAR BootSectorFileName;
if (DoesFileExist_2(SystemRootPath->Buffer, L"io.sys") == TRUE || /* Search for COMPAQ MS-DOS 1.x (1.11, 1.12, based on MS-DOS 1.25) boot loader */
DoesFileExist_2(SystemRootPath->Buffer, L"msdos.sys") == TRUE) if (DoesFileExist_2(SystemRootPath->Buffer, L"IOSYS.COM") == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"MSDOS.COM") == TRUE)
{ {
/* Search for root directory for 'io.sys' and 'msdos.sys' */ DPRINT1("Found COMPAQ MS-DOS 1.x (1.11, 1.12) / MS-DOS 1.25 boot loader\n");
DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
Section = L"DOS"; Section = L"DOS";
Description = L"\"DOS/Windows\""; Description = L"\"COMPAQ MS-DOS 1.x / MS-DOS 1.25\"";
BootDrive = L"hd0"; BootDrive = L"hd0";
BootPartition = L"1"; BootPartition = L"1";
BootSector = L"BOOTSECT.DOS"; BootSector = L"BOOTSECT.DOS";
BootSectorFileName = L"\\bootsect.dos";
} }
else else
/* Search for Microsoft DOS or Windows 9x boot loader */
if (DoesFileExist_2(SystemRootPath->Buffer, L"IO.SYS") == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"MSDOS.SYS") == TRUE)
// WINBOOT.SYS
{
DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
Section = L"DOS";
Description = L"\"MS-DOS/Windows\"";
BootDrive = L"hd0";
BootPartition = L"1";
BootSector = L"BOOTSECT.DOS";
}
else
/* Search for IBM PC-DOS or DR-DOS 5.x boot loader */
if (DoesFileExist_2(SystemRootPath->Buffer, L"IBMIO.COM" ) == TRUE || // Some people refer to this file instead of IBMBIO.COM...
DoesFileExist_2(SystemRootPath->Buffer, L"IBMBIO.COM") == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"IBMDOS.COM") == TRUE)
{
DPRINT1("Found IBM PC-DOS or DR-DOS 5.x or IBM OS/2 1.0\n");
Section = L"DOS";
Description = L"\"IBM PC-DOS or DR-DOS 5.x or IBM OS/2 1.0\"";
BootDrive = L"hd0";
BootPartition = L"1";
BootSector = L"BOOTSECT.DOS";
}
else
/* Search for DR-DOS 3.x boot loader */
if (DoesFileExist_2(SystemRootPath->Buffer, L"DRBIOS.SYS") == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"DRBDOS.SYS") == TRUE)
{
DPRINT1("Found DR-DOS 3.x\n");
Section = L"DOS";
Description = L"\"DR-DOS 3.x\"";
BootDrive = L"hd0";
BootPartition = L"1";
BootSector = L"BOOTSECT.DOS";
}
else
/* Search for MS OS/2 1.x */
if (DoesFileExist_2(SystemRootPath->Buffer, L"OS2BOOT.COM") == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"OS2BIO.COM" ) == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"OS2DOS.COM" ) == TRUE)
{
DPRINT1("Found MS OS/2 1.x\n");
Section = L"DOS";
Description = L"\"MS OS/2 1.x\"";
BootDrive = L"hd0";
BootPartition = L"1";
BootSector = L"BOOTSECT.OS2";
}
else
/* Search for MS or IBM OS/2 */
if (DoesFileExist_2(SystemRootPath->Buffer, L"OS2BOOT") == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"OS2LDR" ) == TRUE ||
DoesFileExist_2(SystemRootPath->Buffer, L"OS2KRNL") == TRUE)
{
DPRINT1("Found MS/IBM OS/2\n");
Section = L"DOS";
Description = L"\"MS/IBM OS/2\"";
BootDrive = L"hd0";
BootPartition = L"1";
BootSector = L"BOOTSECT.OS2";
}
else
/* Search for FreeDOS boot loader */
if (DoesFileExist_2(SystemRootPath->Buffer, L"kernel.sys") == TRUE) if (DoesFileExist_2(SystemRootPath->Buffer, L"kernel.sys") == TRUE)
{ {
/* Search for root directory for 'kernel.sys' */
DPRINT1("Found FreeDOS boot loader\n"); DPRINT1("Found FreeDOS boot loader\n");
Section = L"DOS"; Section = L"DOS";
@ -2395,8 +2463,6 @@ InstallFatBootcodeToPartition(
BootDrive = L"hd0"; BootDrive = L"hd0";
BootPartition = L"1"; BootPartition = L"1";
BootSector = L"BOOTSECT.DOS"; BootSector = L"BOOTSECT.DOS";
BootSectorFileName = L"\\bootsect.dos";
} }
else else
{ {
@ -2408,8 +2474,6 @@ InstallFatBootcodeToPartition(
BootDrive = L"hd0"; BootDrive = L"hd0";
BootPartition = L"1"; BootPartition = L"1";
BootSector = L"BOOTSECT.OLD"; BootSector = L"BOOTSECT.OLD";
BootSectorFileName = L"\\bootsect.old";
} }
/* Create or update 'freeldr.ini' */ /* Create or update 'freeldr.ini' */
@ -2417,7 +2481,7 @@ InstallFatBootcodeToPartition(
{ {
/* Create new 'freeldr.ini' */ /* Create new 'freeldr.ini' */
DPRINT1("Create new 'freeldr.ini'\n"); DPRINT1("Create new 'freeldr.ini'\n");
// CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini"); // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
if (IsThereAValidBootSector(SystemRootPath->Buffer)) if (IsThereAValidBootSector(SystemRootPath->Buffer))
{ {
@ -2432,7 +2496,7 @@ InstallFatBootcodeToPartition(
} }
/* Save current bootsector */ /* Save current bootsector */
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSectorFileName); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSector);
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath); DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
Status = SaveBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE); Status = SaveBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE);
@ -2502,9 +2566,9 @@ InstallExt2BootcodeToPartition(
/* EXT2 partition */ /* EXT2 partition */
DPRINT("System path: '%wZ'\n", SystemRootPath); DPRINT("System path: '%wZ'\n", SystemRootPath);
/* Copy FreeLoader to the system partition */ /* Copy FreeLoader to the system partition, always overwriting the older version */
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys"); CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.sys"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath); DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
Status = SetupCopyFile(SrcPath, DstPath); Status = SetupCopyFile(SrcPath, DstPath);
@ -2515,7 +2579,7 @@ InstallExt2BootcodeToPartition(
} }
/* Prepare for possibly copying 'freeldr.ini' */ /* Prepare for possibly copying 'freeldr.ini' */
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
DoesFreeLdrExist = DoesFileExist(NULL, DstPath); DoesFreeLdrExist = DoesFileExist(NULL, DstPath);
if (DoesFreeLdrExist) if (DoesFreeLdrExist)
@ -2545,10 +2609,12 @@ InstallExt2BootcodeToPartition(
if (IsThereAValidBootSector(SystemRootPath->Buffer)) if (IsThereAValidBootSector(SystemRootPath->Buffer))
{ {
PCWSTR BootSector = L"BOOTSECT.OLD";
Status = CreateFreeLoaderIniForReactOSAndBootSector( Status = CreateFreeLoaderIniForReactOSAndBootSector(
DstPath, DestinationArcPath->Buffer, DstPath, DestinationArcPath->Buffer,
L"Linux", L"\"Linux\"", L"Linux", L"\"Linux\"",
L"hd0", L"1", L"BOOTSECT.OLD"); L"hd0", L"1", BootSector);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("CreateFreeLoaderIniForReactOSAndBootSector() failed (Status %lx)\n", Status); DPRINT1("CreateFreeLoaderIniForReactOSAndBootSector() failed (Status %lx)\n", Status);
@ -2556,7 +2622,7 @@ InstallExt2BootcodeToPartition(
} }
/* Save current bootsector */ /* Save current bootsector */
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\bootsect.old"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSector);
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath); DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR)); Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR));
@ -2627,6 +2693,7 @@ InstallVBRToPartition(
} }
case PARTITION_IFS: case PARTITION_IFS:
DPRINT1("Partitions of type NTFS or HPFS are not supported yet!\n");
break; break;
default: default:
@ -2645,7 +2712,7 @@ InstallFatBootcodeToFloppy(
{ {
NTSTATUS Status; NTSTATUS Status;
PFILE_SYSTEM FatFS; PFILE_SYSTEM FatFS;
UNICODE_STRING FloppyDevice = RTL_CONSTANT_STRING(L"\\Device\\Floppy0"); UNICODE_STRING FloppyDevice = RTL_CONSTANT_STRING(L"\\Device\\Floppy0\\");
WCHAR SrcPath[MAX_PATH]; WCHAR SrcPath[MAX_PATH];
WCHAR DstPath[MAX_PATH]; WCHAR DstPath[MAX_PATH];
@ -2670,8 +2737,7 @@ InstallFatBootcodeToFloppy(
/* Copy FreeLoader to the boot partition */ /* Copy FreeLoader to the boot partition */
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys"); CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice.Buffer, L"freeldr.sys");
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0\\freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath); DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
Status = SetupCopyFile(SrcPath, DstPath); Status = SetupCopyFile(SrcPath, DstPath);
@ -2682,7 +2748,7 @@ InstallFatBootcodeToFloppy(
} }
/* Create new 'freeldr.ini' */ /* Create new 'freeldr.ini' */
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0\\freeldr.ini"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice.Buffer, L"freeldr.ini");
DPRINT("Create new 'freeldr.ini'\n"); DPRINT("Create new 'freeldr.ini'\n");
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer);
@ -2692,16 +2758,15 @@ InstallFatBootcodeToFloppy(
return Status; return Status;
} }
/* Install FAT12/16 boosector */ /* Install FAT12 boosector */
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin"); CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), FloppyDevice.Buffer);
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0");
DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath); DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath); Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status); DPRINT1("InstallFat12BootCodeToFloppy() failed (Status %lx)\n", Status);
return Status; return Status;
} }

View file

@ -1,4 +1,5 @@
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Setup"
#define REACTOS_STR_INTERNAL_NAME "usetup" #define REACTOS_STR_FILE_DESCRIPTION "ReactOS Text-Mode Setup"
#define REACTOS_STR_ORIGINAL_FILENAME "usetup.exe" #define REACTOS_STR_INTERNAL_NAME "usetup"
#define REACTOS_STR_ORIGINAL_FILENAME "usetup.exe"
#include <reactos/version.rc> #include <reactos/version.rc>