From 16c6a54da7af8ee3e318b9368ae26e50319ed234 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herv=C3=A9=20Poussineau?= Date: Tue, 22 Sep 2009 19:32:35 +0000 Subject: [PATCH 1/1] [freeldr] Accept to read blocks whose size is not a multiple of device sector size svn path=/trunk/; revision=43113 --- .../boot/freeldr/freeldr/arch/i386/hardware.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c index ec55e094ae3..864569e7da4 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c @@ -2,6 +2,7 @@ * FreeLoader * * Copyright (C) 2003, 2004 Eric Kohl + * Copyright (C) 2009 Hervé Poussineau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -466,15 +467,16 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count) { DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); UCHAR* Ptr = (UCHAR*)Buffer; - ULONG i; + ULONG i, Length; BOOLEAN ret; *Count = 0; - if (N & (Context->SectorSize - 1)) - return EINVAL; - - for (i = 0; i < N / Context->SectorSize; i++) + i = 0; + while (N > 0) { + Length = N; + if (Length > Context->SectorSize) + Length = Context->SectorSize; ret = MachDiskReadLogicalSectors( Context->DriveNumber, Context->SectorNumber + Context->SectorOffset + i, @@ -482,11 +484,13 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count) (PVOID)DISKREADBUFFER); if (!ret) return EIO; - RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Context->SectorSize); - Ptr += Context->SectorSize; + RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Length); + Ptr += Length; + *Count += Length; + N -= Length; + i++; } - *Count = N; return ESUCCESS; } -- 2.17.1