mirror of
https://github.com/reactos/reactos.git
synced 2026-06-03 01:41:13 +08:00
[FREELDR] Use the new volume size mechanism when loading a storage volume as a RamDisk (#8423)
CORE-14603 The differentiation between a regular file loaded as a RamDisk and a storage device volume, is done by invoking `ArcGetFileInformation()` and looking at the `Information.Type` value.
This commit is contained in:
@@ -129,7 +129,7 @@ RamDiskLoadVirtualFile(
|
||||
if (Status != ESUCCESS)
|
||||
return Status;
|
||||
|
||||
/* Get the file size */
|
||||
/* Get the file or device size */
|
||||
Status = ArcGetFileInformation(RamFileId, &Information);
|
||||
if (Status != ESUCCESS)
|
||||
{
|
||||
@@ -141,6 +141,18 @@ RamDiskLoadVirtualFile(
|
||||
Information.EndingAddress.QuadPart -= Information.StartingAddress.QuadPart;
|
||||
Information.StartingAddress.QuadPart = 0ULL;
|
||||
|
||||
/* If we are actually opening a RAW device, retrieve instead its usable volume size */
|
||||
if (Information.FileNameLength == 0 && Information.FileName[0] == ANSI_NULL &&
|
||||
(Information.Type == DiskPeripheral || Information.Type == FloppyDiskPeripheral))
|
||||
{
|
||||
ULONGLONG VolumeSize;
|
||||
Status = FsGetVolumeSize(RamFileId, &VolumeSize);
|
||||
if (Status != ESUCCESS)
|
||||
ERR("Couldn't retrieve volume size on device '%s', falling back to RAW size\n", FileName);
|
||||
else
|
||||
Information.EndingAddress.QuadPart = VolumeSize;
|
||||
}
|
||||
|
||||
TRACE("RAMDISK size: %I64u (High: %lu ; Low: %lu)\n",
|
||||
Information.EndingAddress.QuadPart,
|
||||
Information.EndingAddress.HighPart,
|
||||
|
||||
Reference in New Issue
Block a user