From bf3f878ee5b9cb35377ea566c2b16fc7e799684f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 5 Jan 2015 22:24:56 +0000 Subject: [PATCH] [FREELDR]: Make RamDiskLoadVirtualFile returning a BOOLEAN such that if we fail to load a Ram disk image, we can display an error message and abort boot. svn path=/trunk/; revision=65988 --- reactos/boot/freeldr/freeldr/disk/ramdisk.c | 16 +++++++++------- reactos/boot/freeldr/freeldr/include/ramdisk.h | 2 +- reactos/boot/freeldr/freeldr/windows/setupldr.c | 8 ++++++-- reactos/boot/freeldr/freeldr/windows/winldr.c | 6 +++++- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/disk/ramdisk.c b/reactos/boot/freeldr/freeldr/disk/ramdisk.c index 071f451658f..6998f2828a7 100644 --- a/reactos/boot/freeldr/freeldr/disk/ramdisk.c +++ b/reactos/boot/freeldr/freeldr/disk/ramdisk.c @@ -116,7 +116,7 @@ RamDiskInitialize(VOID) FsRegisterDevice("ramdisk(0)", &RamDiskVtbl); } -VOID +BOOLEAN NTAPI RamDiskLoadVirtualFile(IN PCHAR FileName) { @@ -138,7 +138,7 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) // RamFile = FsOpenFile(FileName); if (!RamFile) - return; + return FALSE; // // Get the file size @@ -147,7 +147,7 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) if (Status != ESUCCESS) { FsCloseFile(RamFile); - return; + return FALSE; } // @@ -157,7 +157,7 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) { UiMessageBox("RAM disk too big\n"); FsCloseFile(RamFile); - return; + return FALSE; } gRamDiskSize = Information.EndingAddress.LowPart; @@ -174,7 +174,7 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) { UiMessageBox("Failed to allocate memory for RAM disk\n"); FsCloseFile(RamFile); - return; + return FALSE; } // @@ -222,8 +222,8 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) gRamDiskBase = NULL; gRamDiskSize = 0; FsCloseFile(RamFile); - UiMessageBox("Failed to read RamDisk\n"); - return; + UiMessageBox("Failed to read RAM disk\n"); + return FALSE; } } @@ -231,4 +231,6 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) // Register a new device for the ramdisk FsRegisterDevice("ramdisk(0)", &RamDiskVtbl); + + return TRUE; } diff --git a/reactos/boot/freeldr/freeldr/include/ramdisk.h b/reactos/boot/freeldr/freeldr/include/ramdisk.h index 8979bcf98a8..ee3e5beb7ba 100644 --- a/reactos/boot/freeldr/freeldr/include/ramdisk.h +++ b/reactos/boot/freeldr/freeldr/include/ramdisk.h @@ -11,7 +11,7 @@ // // Ramdisk Routines // -VOID +BOOLEAN NTAPI RamDiskLoadVirtualFile( IN PCHAR FileName diff --git a/reactos/boot/freeldr/freeldr/windows/setupldr.c b/reactos/boot/freeldr/freeldr/windows/setupldr.c index 4b154b781d3..497819ced48 100644 --- a/reactos/boot/freeldr/freeldr/windows/setupldr.c +++ b/reactos/boot/freeldr/freeldr/windows/setupldr.c @@ -237,7 +237,11 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem, *strstr(FileName, " ") = ANSI_NULL; /* Load the ramdisk */ - RamDiskLoadVirtualFile(FileName); + if (!RamDiskLoadVirtualFile(FileName)) + { + UiMessageBox("Failed to load RAM disk file %s\n", FileName); + return; + } } TRACE("BootPath: '%s'\n", BootPath); @@ -252,7 +256,7 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem, SystemPath = SourcePaths[i]; if (!SystemPath) { - ERR("Failed to open txtsetup.sif\n"); + UiMessageBox("Failed to open txtsetup.sif\n"); return; } strcpy(File, SystemPath); diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/windows/winldr.c index c62e6dada1d..81c1cbb4f37 100644 --- a/reactos/boot/freeldr/freeldr/windows/winldr.c +++ b/reactos/boot/freeldr/freeldr/windows/winldr.c @@ -674,7 +674,11 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem, *strstr(FileName, " ") = ANSI_NULL; /* Load the ramdisk */ - RamDiskLoadVirtualFile(FileName); + if (!RamDiskLoadVirtualFile(FileName)) + { + UiMessageBox("Failed to load RAM disk file %s\n", FileName); + return; + } } /* Let user know we started loading */