mirror of
https://github.com/reactos/reactos
synced 2025-10-07 08:52:45 +02:00
Compare commits
2 Commits
Tree-restr
...
backups/ro
Author | SHA1 | Date | |
---|---|---|---|
|
37c3b778d5 | ||
|
706e703785 |
@@ -1665,6 +1665,7 @@ UpdateBootIni(PWSTR BootIniPath,
|
|||||||
PINICACHESECTION Section = NULL;
|
PINICACHESECTION Section = NULL;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG FileAttribute;
|
ULONG FileAttribute;
|
||||||
|
PWCHAR OldValue = NULL;
|
||||||
|
|
||||||
RtlInitUnicodeString(&Name,
|
RtlInitUnicodeString(&Name,
|
||||||
BootIniPath);
|
BootIniPath);
|
||||||
@@ -1685,11 +1686,20 @@ UpdateBootIni(PWSTR BootIniPath,
|
|||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
IniCacheInsertKey(Section,
|
/* Check - maybe record already exists */
|
||||||
|
Status = IniCacheGetKey(Section,
|
||||||
|
EntryName,
|
||||||
|
&OldValue);
|
||||||
|
|
||||||
|
/* If either key was not found, or contains something else - add new one */
|
||||||
|
if (!NT_SUCCESS(Status) || wcscmp(OldValue, EntryValue))
|
||||||
|
{
|
||||||
|
IniCacheInsertKey(Section,
|
||||||
NULL,
|
NULL,
|
||||||
INSERT_LAST,
|
INSERT_LAST,
|
||||||
EntryName,
|
EntryName,
|
||||||
EntryValue);
|
EntryValue);
|
||||||
|
}
|
||||||
|
|
||||||
Status = UnprotectBootIni(BootIniPath,
|
Status = UnprotectBootIni(BootIniPath,
|
||||||
&FileAttribute);
|
&FileAttribute);
|
||||||
@@ -1741,311 +1751,311 @@ InstallFatBootcodeToPartition(PUNICODE_STRING SystemRootPath,
|
|||||||
PUNICODE_STRING DestinationArcPath,
|
PUNICODE_STRING DestinationArcPath,
|
||||||
UCHAR PartitionType)
|
UCHAR PartitionType)
|
||||||
{
|
{
|
||||||
WCHAR SrcPath[MAX_PATH];
|
WCHAR SrcPath[MAX_PATH];
|
||||||
WCHAR DstPath[MAX_PATH];
|
WCHAR DstPath[MAX_PATH];
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* FAT or FAT32 partition */
|
/* FAT or FAT32 partition */
|
||||||
DPRINT1("System path: '%wZ'\n", SystemRootPath);
|
DPRINT1("System path: '%wZ'\n", SystemRootPath);
|
||||||
|
|
||||||
if (DoesFileExist(SystemRootPath->Buffer, L"ntldr") == TRUE ||
|
if (DoesFileExist(SystemRootPath->Buffer, L"ntldr") == TRUE ||
|
||||||
DoesFileExist(SystemRootPath->Buffer, L"boot.ini") == TRUE)
|
DoesFileExist(SystemRootPath->Buffer, L"boot.ini") == TRUE)
|
||||||
{
|
|
||||||
/* Search root directory for 'ntldr' and 'boot.ini'. */
|
|
||||||
DPRINT("Found Microsoft Windows NT/2000/XP boot loader\n");
|
|
||||||
|
|
||||||
/* Copy FreeLoader to the boot partition */
|
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
|
||||||
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.sys");
|
|
||||||
|
|
||||||
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
|
||||||
Status = SetupCopyFile(SrcPath, DstPath);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create or update freeldr.ini */
|
|
||||||
if (DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini") == FALSE)
|
|
||||||
{
|
|
||||||
/* Create new 'freeldr.ini' */
|
|
||||||
DPRINT1("Create new 'freeldr.ini'\n");
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.ini");
|
|
||||||
|
|
||||||
Status = CreateFreeLoaderIniForReactos(DstPath,
|
|
||||||
DestinationArcPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status);
|
/* Search root directory for 'ntldr' and 'boot.ini'. */
|
||||||
return Status;
|
DPRINT("Found Microsoft Windows NT/2000/XP boot loader\n");
|
||||||
|
|
||||||
|
/* Copy FreeLoader to the boot partition */
|
||||||
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
|
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\freeldr.sys");
|
||||||
|
|
||||||
|
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||||
|
Status = SetupCopyFile(SrcPath, DstPath);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create or update freeldr.ini */
|
||||||
|
if (DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini") == FALSE)
|
||||||
|
{
|
||||||
|
/* Create new 'freeldr.ini' */
|
||||||
|
DPRINT1("Create new 'freeldr.ini'\n");
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\freeldr.ini");
|
||||||
|
|
||||||
|
Status = CreateFreeLoaderIniForReactos(DstPath,
|
||||||
|
DestinationArcPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Install new bootcode */
|
||||||
|
if (PartitionType == PARTITION_FAT32 ||
|
||||||
|
PartitionType == PARTITION_FAT32_XINT13)
|
||||||
|
{
|
||||||
|
/* Install FAT32 bootcode */
|
||||||
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
|
wcscat(SrcPath, L"\\loader\\fat32.bin");
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\bootsect.ros");
|
||||||
|
|
||||||
|
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, DstPath);
|
||||||
|
Status = InstallFat32BootCodeToFile(SrcPath,
|
||||||
|
DstPath,
|
||||||
|
SystemRootPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("InstallFat32BootCodeToFile() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Install FAT16 bootcode */
|
||||||
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
|
wcscat(SrcPath, L"\\loader\\fat.bin");
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\bootsect.ros");
|
||||||
|
|
||||||
|
DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
|
||||||
|
Status = InstallFat16BootCodeToFile(SrcPath,
|
||||||
|
DstPath,
|
||||||
|
SystemRootPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("InstallFat16BootCodeToFile() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Update existing 'freeldr.ini' */
|
||||||
|
DPRINT1("Update existing 'freeldr.ini'\n");
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\freeldr.ini");
|
||||||
|
|
||||||
|
Status = UpdateFreeLoaderIni(DstPath,
|
||||||
|
DestinationArcPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update 'boot.ini' */
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\boot.ini");
|
||||||
|
|
||||||
|
DPRINT1("Update 'boot.ini': %S\n", DstPath);
|
||||||
|
Status = UpdateBootIni(DstPath,
|
||||||
|
L"C:\\bootsect.ros",
|
||||||
|
L"\"ReactOS\"");
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("UpdateBootIni() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (DoesFileExist(SystemRootPath->Buffer, L"io.sys") == TRUE ||
|
||||||
/* Install new bootcode */
|
DoesFileExist(SystemRootPath->Buffer, L"msdos.sys") == TRUE)
|
||||||
if (PartitionType == PARTITION_FAT32 ||
|
|
||||||
PartitionType == PARTITION_FAT32_XINT13)
|
|
||||||
{
|
{
|
||||||
/* Install FAT32 bootcode */
|
/* Search for root directory for 'io.sys' and 'msdos.sys'. */
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
|
||||||
wcscat(SrcPath, L"\\loader\\fat32.bin");
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\bootsect.ros");
|
|
||||||
|
|
||||||
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, DstPath);
|
/* Copy FreeLoader to the boot partition */
|
||||||
Status = InstallFat32BootCodeToFile(SrcPath,
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
DstPath,
|
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
||||||
SystemRootPath->Buffer);
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
if (!NT_SUCCESS(Status))
|
wcscat(DstPath, L"\\freeldr.sys");
|
||||||
{
|
|
||||||
DPRINT1("InstallFat32BootCodeToFile() failed (Status %lx)\n", Status);
|
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||||
return Status;
|
Status = SetupCopyFile(SrcPath, DstPath);
|
||||||
}
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create or update 'freeldr.ini' */
|
||||||
|
if (DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini") == FALSE)
|
||||||
|
{
|
||||||
|
/* Create new 'freeldr.ini' */
|
||||||
|
DPRINT1("Create new 'freeldr.ini'\n");
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\freeldr.ini");
|
||||||
|
|
||||||
|
Status = CreateFreeLoaderIniForDos(DstPath,
|
||||||
|
DestinationArcPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("CreateFreeLoaderIniForDos() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save current bootsector as 'BOOTSECT.DOS' */
|
||||||
|
wcscpy(SrcPath, SystemRootPath->Buffer);
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\bootsect.dos");
|
||||||
|
|
||||||
|
DPRINT1("Save bootsector: %S ==> %S\n", SrcPath, DstPath);
|
||||||
|
Status = SaveCurrentBootSector(SrcPath,
|
||||||
|
DstPath);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Install new bootsector */
|
||||||
|
if (PartitionType == PARTITION_FAT32 ||
|
||||||
|
PartitionType == PARTITION_FAT32_XINT13)
|
||||||
|
{
|
||||||
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
|
wcscat(SrcPath, L"\\loader\\fat32.bin");
|
||||||
|
|
||||||
|
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
||||||
|
Status = InstallFat32BootCodeToDisk(SrcPath,
|
||||||
|
SystemRootPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
|
wcscat(SrcPath, L"\\loader\\fat.bin");
|
||||||
|
|
||||||
|
DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
||||||
|
Status = InstallFat16BootCodeToDisk(SrcPath,
|
||||||
|
SystemRootPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Update existing 'freeldr.ini' */
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\freeldr.ini");
|
||||||
|
|
||||||
|
Status = UpdateFreeLoaderIni(DstPath,
|
||||||
|
DestinationArcPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Install FAT16 bootcode */
|
/* No or unknown boot loader */
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
DPRINT1("No or unknown boot loader found\n");
|
||||||
wcscat(SrcPath, L"\\loader\\fat.bin");
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\bootsect.ros");
|
|
||||||
|
|
||||||
DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
|
/* Copy FreeLoader to the boot partition */
|
||||||
Status = InstallFat16BootCodeToFile(SrcPath,
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
DstPath,
|
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
||||||
SystemRootPath->Buffer);
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
if (!NT_SUCCESS(Status))
|
wcscat(DstPath, L"\\freeldr.sys");
|
||||||
{
|
|
||||||
DPRINT1("InstallFat16BootCodeToFile() failed (Status %lx)\n", Status);
|
DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||||
return Status;
|
Status = SetupCopyFile(SrcPath, DstPath);
|
||||||
}
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create or update 'freeldr.ini' */
|
||||||
|
if (DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini") == FALSE)
|
||||||
|
{
|
||||||
|
/* Create new freeldr.ini */
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\freeldr.ini");
|
||||||
|
|
||||||
|
DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||||
|
Status = CreateFreeLoaderIniForReactos(DstPath,
|
||||||
|
DestinationArcPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save current bootsector as 'BOOTSECT.OLD' */
|
||||||
|
wcscpy(SrcPath, SystemRootPath->Buffer);
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\bootsect.old");
|
||||||
|
|
||||||
|
DPRINT1("Save bootsector: %S ==> %S\n", SrcPath, DstPath);
|
||||||
|
Status = SaveCurrentBootSector(SrcPath,
|
||||||
|
DstPath);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Install new bootsector */
|
||||||
|
if (PartitionType == PARTITION_FAT32 ||
|
||||||
|
PartitionType == PARTITION_FAT32_XINT13)
|
||||||
|
{
|
||||||
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
|
wcscat(SrcPath, L"\\loader\\fat32.bin");
|
||||||
|
|
||||||
|
DPRINT("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
||||||
|
Status = InstallFat32BootCodeToDisk(SrcPath,
|
||||||
|
SystemRootPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcscpy(SrcPath, SourceRootPath->Buffer);
|
||||||
|
wcscat(SrcPath, L"\\loader\\fat.bin");
|
||||||
|
|
||||||
|
DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
||||||
|
Status = InstallFat16BootCodeToDisk(SrcPath,
|
||||||
|
SystemRootPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Update existing 'freeldr.ini' */
|
||||||
|
wcscpy(DstPath, SystemRootPath->Buffer);
|
||||||
|
wcscat(DstPath, L"\\freeldr.ini");
|
||||||
|
|
||||||
|
Status = UpdateFreeLoaderIni(DstPath,
|
||||||
|
DestinationArcPath->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update 'boot.ini' */
|
return STATUS_SUCCESS;
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\boot.ini");
|
|
||||||
|
|
||||||
DPRINT1("Update 'boot.ini': %S\n", DstPath);
|
|
||||||
Status = UpdateBootIni(DstPath,
|
|
||||||
L"C:\\bootsect.ros",
|
|
||||||
L"\"ReactOS\"");
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("UpdateBootIni() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Update existing 'freeldr.ini' */
|
|
||||||
DPRINT1("Update existing 'freeldr.ini'\n");
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.ini");
|
|
||||||
|
|
||||||
Status = UpdateFreeLoaderIni(DstPath,
|
|
||||||
DestinationArcPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (DoesFileExist(SystemRootPath->Buffer, L"io.sys") == TRUE ||
|
|
||||||
DoesFileExist(SystemRootPath->Buffer, L"msdos.sys") == TRUE)
|
|
||||||
{
|
|
||||||
/* Search for root directory for 'io.sys' and 'msdos.sys'. */
|
|
||||||
DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
|
|
||||||
|
|
||||||
/* Copy FreeLoader to the boot partition */
|
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
|
||||||
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.sys");
|
|
||||||
|
|
||||||
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
|
||||||
Status = SetupCopyFile(SrcPath, DstPath);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create or update 'freeldr.ini' */
|
|
||||||
if (DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini") == FALSE)
|
|
||||||
{
|
|
||||||
/* Create new 'freeldr.ini' */
|
|
||||||
DPRINT1("Create new 'freeldr.ini'\n");
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.ini");
|
|
||||||
|
|
||||||
Status = CreateFreeLoaderIniForDos(DstPath,
|
|
||||||
DestinationArcPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("CreateFreeLoaderIniForDos() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Save current bootsector as 'BOOTSECT.DOS' */
|
|
||||||
wcscpy(SrcPath, SystemRootPath->Buffer);
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\bootsect.dos");
|
|
||||||
|
|
||||||
DPRINT1("Save bootsector: %S ==> %S\n", SrcPath, DstPath);
|
|
||||||
Status = SaveCurrentBootSector(SrcPath,
|
|
||||||
DstPath);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Install new bootsector */
|
|
||||||
if (PartitionType == PARTITION_FAT32 ||
|
|
||||||
PartitionType == PARTITION_FAT32_XINT13)
|
|
||||||
{
|
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
|
||||||
wcscat(SrcPath, L"\\loader\\fat32.bin");
|
|
||||||
|
|
||||||
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
|
||||||
Status = InstallFat32BootCodeToDisk(SrcPath,
|
|
||||||
SystemRootPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
|
||||||
wcscat(SrcPath, L"\\loader\\fat.bin");
|
|
||||||
|
|
||||||
DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
|
||||||
Status = InstallFat16BootCodeToDisk(SrcPath,
|
|
||||||
SystemRootPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Update existing 'freeldr.ini' */
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.ini");
|
|
||||||
|
|
||||||
Status = UpdateFreeLoaderIni(DstPath,
|
|
||||||
DestinationArcPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* No or unknown boot loader */
|
|
||||||
DPRINT1("No or unknown boot loader found\n");
|
|
||||||
|
|
||||||
/* Copy FreeLoader to the boot partition */
|
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
|
||||||
wcscat(SrcPath, L"\\loader\\freeldr.sys");
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.sys");
|
|
||||||
|
|
||||||
DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
|
|
||||||
Status = SetupCopyFile(SrcPath, DstPath);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create or update 'freeldr.ini' */
|
|
||||||
if (DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini") == FALSE)
|
|
||||||
{
|
|
||||||
/* Create new freeldr.ini */
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.ini");
|
|
||||||
|
|
||||||
DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
|
|
||||||
Status = CreateFreeLoaderIniForReactos(DstPath,
|
|
||||||
DestinationArcPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Save current bootsector as 'BOOTSECT.OLD' */
|
|
||||||
wcscpy(SrcPath, SystemRootPath->Buffer);
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\bootsect.old");
|
|
||||||
|
|
||||||
DPRINT1("Save bootsector: %S ==> %S\n", SrcPath, DstPath);
|
|
||||||
Status = SaveCurrentBootSector(SrcPath,
|
|
||||||
DstPath);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Install new bootsector */
|
|
||||||
if (PartitionType == PARTITION_FAT32 ||
|
|
||||||
PartitionType == PARTITION_FAT32_XINT13)
|
|
||||||
{
|
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
|
||||||
wcscat(SrcPath, L"\\loader\\fat32.bin");
|
|
||||||
|
|
||||||
DPRINT("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
|
||||||
Status = InstallFat32BootCodeToDisk(SrcPath,
|
|
||||||
SystemRootPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wcscpy(SrcPath, SourceRootPath->Buffer);
|
|
||||||
wcscat(SrcPath, L"\\loader\\fat.bin");
|
|
||||||
|
|
||||||
DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
|
|
||||||
Status = InstallFat16BootCodeToDisk(SrcPath,
|
|
||||||
SystemRootPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Update existing 'freeldr.ini' */
|
|
||||||
wcscpy(DstPath, SystemRootPath->Buffer);
|
|
||||||
wcscat(DstPath, L"\\freeldr.ini");
|
|
||||||
|
|
||||||
Status = UpdateFreeLoaderIni(DstPath,
|
|
||||||
DestinationArcPath->Buffer);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -599,6 +599,7 @@ static NTSTATUS STDCALL I8042BasicDetect(PDEVICE_EXTENSION DevExt)
|
|||||||
static NTSTATUS STDCALL I8042Initialize(PDEVICE_EXTENSION DevExt)
|
static NTSTATUS STDCALL I8042Initialize(PDEVICE_EXTENSION DevExt)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
UCHAR Value = 0;
|
||||||
|
|
||||||
Status = I8042BasicDetect(DevExt);
|
Status = I8042BasicDetect(DevExt);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
@@ -632,6 +633,32 @@ static NTSTATUS STDCALL I8042Initialize(PDEVICE_EXTENSION DevExt)
|
|||||||
I8042MouseEnable(DevExt);
|
I8042MouseEnable(DevExt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some machines do not reboot if SF is not set.
|
||||||
|
*/
|
||||||
|
if (!I8042Write(DevExt, I8042_CTRL_PORT, KBD_READ_MODE)) {
|
||||||
|
DPRINT1("Can't read i8042 mode\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = I8042ReadDataWait(DevExt, &Value);
|
||||||
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
DPRINT1("No response after read i8042 mode\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Value |= CCB_SYSTEM_FLAG;
|
||||||
|
|
||||||
|
if (!I8042Write(DevExt, I8042_CTRL_PORT, KBD_WRITE_MODE)) {
|
||||||
|
DPRINT1("Can't set i8042 mode\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!I8042Write(DevExt, I8042_DATA_PORT, Value)) {
|
||||||
|
DPRINT1("Can't send i8042 mode\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user