X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=base%2Fsetup%2Flib%2Fbootsup.c;h=5f0f694779e03e7e0fb2b305fba0927f6d3396c9;hp=7ea6240b9af5a46a17ae8d63f0c2acbfde6a39b5;hb=a7a11dd60db9f244e1a10bd0d5aecc041f36161f;hpb=95a34ef6fc5d916ebb751230c5b18cb1d80ab641 diff --git a/base/setup/lib/bootsup.c b/base/setup/lib/bootsup.c index 7ea6240b9af..5f0f694779e 100644 --- a/base/setup/lib/bootsup.c +++ b/base/setup/lib/bootsup.c @@ -551,7 +551,6 @@ IsThereAValidBootSector( HANDLE FileHandle; LARGE_INTEGER FileOffset; PUCHAR BootSector; - ULONG Instruction; /* Allocate buffer for bootsector */ BootSector = RtlAllocateHeap(ProcessHeap, 0, SECTORSIZE); @@ -593,17 +592,18 @@ IsThereAValidBootSector( if (!NT_SUCCESS(Status)) goto Quit; - /* Check the instruction; we use a ULONG to read three bytes */ - Instruction = (*(PULONG)BootSector) & 0x00FFFFFF; - IsValid = (Instruction != 0x00000000); - - /* Check the bootsector signature */ - IsValid &= (*(PUSHORT)(BootSector + 0x1fe) == 0xaa55); + /* Check for the existence of the bootsector signature */ + IsValid = (*(PUSHORT)(BootSector + 0x1FE) == 0xAA55); + if (IsValid) + { + /* Check for the first instruction encoded on three bytes */ + IsValid = (((*(PULONG)BootSector) & 0x00FFFFFF) != 0x00000000); + } Quit: /* Free the boot sector */ RtlFreeHeap(ProcessHeap, 0, BootSector); - return IsValid; // Status; + return IsValid; } static @@ -883,9 +883,9 @@ InstallMbrBootCodeToDisk( #if 0 WCHAR DestinationDevicePathBuffer[MAX_PATH]; - StringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer), - L"\\Device\\Harddisk%d\\Partition0", - DiskNumber); + RtlStringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer), + L"\\Device\\Harddisk%d\\Partition0", + DiskNumber); #endif CombinePaths(SourceMbrPathBuffer, ARRAYSIZE(SourceMbrPathBuffer), 2, @@ -2303,7 +2303,11 @@ InstallFatBootcodeToFloppy( WCHAR SrcPath[MAX_PATH]; WCHAR DstPath[MAX_PATH]; - /* Format the floppy first */ + /* Verify that the floppy disk is accessible */ + if (DoesDirExist(NULL, FloppyDevice.Buffer) == FALSE) + return STATUS_DEVICE_NOT_READY; + + /* Format the floppy disk */ FatFS = GetFileSystemByName(L"FAT"); if (!FatFS) {