[FREELDR]

Apply Carlos patch again, but use MaxSectors = 1 for now. That should result in the exact identical behaviour as before.

svn path=/trunk/; revision=57278
This commit is contained in:
Timo Kreuzer 2012-09-11 17:34:09 +00:00
parent c378d0a138
commit 858cfa0dbb

View file

@ -114,31 +114,45 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
{ {
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
UCHAR* Ptr = (UCHAR*)Buffer; UCHAR* Ptr = (UCHAR*)Buffer;
ULONG i, Length; ULONG Length, TotalSectors, MaxSectors, ReadSectors;
BOOLEAN ret; BOOLEAN ret;
ULONGLONG SectorOffset;
TotalSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
MaxSectors = 1;//DISKREADBUFFER_SIZE / Context->SectorSize;
SectorOffset = Context->SectorNumber + Context->SectorOffset;
ret = 0;
*Count = 0;
i = 0;
while (N > 0) while (N > 0)
{ {
Length = N; ReadSectors = TotalSectors;
if (Length > Context->SectorSize) if (ReadSectors > MaxSectors)
Length = Context->SectorSize; ReadSectors = MaxSectors;
ret = MachDiskReadLogicalSectors( ret = MachDiskReadLogicalSectors(
Context->DriveNumber, Context->DriveNumber,
Context->SectorNumber + Context->SectorOffset + i, SectorOffset,
1, ReadSectors,
(PVOID)DISKREADBUFFER); (PVOID)DISKREADBUFFER);
if (!ret) if (!ret)
return EIO; break;
Length = ReadSectors * Context->SectorSize;
if (Length > N)
Length = N;
RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Length); RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Length);
Ptr += Length; Ptr += Length;
*Count += Length;
N -= Length; N -= Length;
i++; SectorOffset += ReadSectors;
TotalSectors -= ReadSectors;
} }
return ESUCCESS; *Count = Ptr - (UCHAR *)Buffer;
return (!ret) ? EIO : ESUCCESS;
} }
static LONG DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode) static LONG DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode)