[FREELDR] Fix remaining hwdisk and FATX bugs (#1766)

- DiskGetFileInformation() should return relative addresses -- relative to the beginning of the "device" (partition, or disk) in question.
- FatXSearchDirectoryBufferForFile() should assign file attributes.
- Minor code style improvements in FatOpenVolume().

CORE-16216 CORE-16248

Co-authored-by: Victor Perevertkin <victor@perevertkin.ru>
This commit is contained in:
Stanislav Motylkov 2019-07-30 01:27:36 +03:00 committed by Hermès BÉLUSCA - MAÏTO
parent 48200015f7
commit ef76709b3d
2 changed files with 5 additions and 4 deletions

View file

@ -65,8 +65,8 @@ DiskGetFileInformation(ULONG FileId, FILEINFORMATION* Information)
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
RtlZeroMemory(Information, sizeof(FILEINFORMATION));
Information->EndingAddress.QuadPart = (Context->SectorOffset + Context->SectorCount) * Context->SectorSize;
Information->CurrentAddress.QuadPart = (Context->SectorOffset + Context->SectorNumber) * Context->SectorSize;
Information->EndingAddress.QuadPart = Context->SectorCount * Context->SectorSize;
Information->CurrentAddress.QuadPart = Context->SectorNumber * Context->SectorSize;
return ESUCCESS;
}

View file

@ -266,12 +266,12 @@ BOOLEAN FatOpenVolume(PFAT_VOLUME_INFO Volume, PFAT_BOOTSECTOR BootSector, ULONG
{
Volume->BytesPerSector = 512;
Volume->SectorsPerCluster = SWAPD(FatXVolumeBootSector->SectorsPerCluster);
Volume->FatSectorStart = (4096 / Volume->BytesPerSector);
Volume->FatSectorStart = (0x1000 / Volume->BytesPerSector);
Volume->ActiveFatSectorStart = Volume->FatSectorStart;
Volume->NumberOfFats = 1;
FatSize = (ULONG)(PartitionSectorCount / Volume->SectorsPerCluster *
(Volume->FatType == FATX16 ? 2 : 4));
Volume->SectorsPerFat = (((FatSize + 4095) / 4096) * 4096) / Volume->BytesPerSector;
Volume->SectorsPerFat = ROUND_UP(FatSize, 0x1000) / Volume->BytesPerSector;
Volume->RootDirSectorStart = Volume->FatSectorStart + Volume->NumberOfFats * Volume->SectorsPerFat;
Volume->RootDirSectors = FatXVolumeBootSector->SectorsPerCluster;
@ -720,6 +720,7 @@ static BOOLEAN FatXSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID D
/*
* We found the entry, now fill in the FAT_FILE_INFO struct
*/
FatFileInfoPointer->Attributes = DirEntry->Attr;
FatFileInfoPointer->FileSize = DirEntry->Size;
FatFileInfoPointer->FilePointer = 0;