mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-31 23:08:26 -04:00
[core] drive handling improvements
* Use IOCTL_DISK_UPDATE_PROPERTIES after partitioning * Use IOCTL_DISK_DELETE_DRIVE_LAYOUT to invalidate partitions before formatting * Fix handling of unpartitioned drives * Increase delay after partitioning * All of the above should help with the infamous #122 * Also fix display of error messages in ms-sys' file.c as well as stdio.c * Also add commandline option -f to list fixed drives
This commit is contained in:
parent
fe3b1eb6f6
commit
cd5665881c
7 changed files with 163 additions and 72 deletions
|
@ -41,15 +41,15 @@ int64_t write_sectors(HANDLE hDrive, uint64_t SectorSize,
|
|||
ptr.QuadPart = StartSector*SectorSize;
|
||||
if(!SetFilePointerEx(hDrive, ptr, NULL, FILE_BEGIN))
|
||||
{
|
||||
uprintf("write_sectors: Could not access sector %d - %s\n", StartSector, WindowsErrorString());
|
||||
uprintf("write_sectors: Could not access sector 0x%08llx - %s\n", StartSector, WindowsErrorString());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((!WriteFile(hDrive, pBuf, Size, &Size, NULL)) || (Size != nSectors*SectorSize))
|
||||
{
|
||||
uprintf("write_sectors: Write error - %s\n", WindowsErrorString());
|
||||
uprintf(" Wrote: %d, Expected: %d\n", Size, nSectors*SectorSize);
|
||||
uprintf(" StartSector:%0X, nSectors:%0X, SectorSize:%0X\n", StartSector, nSectors, SectorSize);
|
||||
uprintf("write_sectors: Write error %s\n", (GetLastError()!=ERROR_SUCCESS)?WindowsErrorString():"");
|
||||
uprintf(" Wrote: %d, Expected: %lld\n", Size, nSectors*SectorSize);
|
||||
uprintf(" StartSector: 0x%08llx, nSectors: 0x%llx, SectorSize: 0x%llx\n", StartSector, nSectors, SectorSize);
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
@ -74,15 +74,15 @@ int64_t read_sectors(HANDLE hDrive, uint64_t SectorSize,
|
|||
ptr.QuadPart = StartSector*SectorSize;
|
||||
if(!SetFilePointerEx(hDrive, ptr, NULL, FILE_BEGIN))
|
||||
{
|
||||
uprintf("read_sectors: Could not access sector %d - %s\n", StartSector, WindowsErrorString());
|
||||
uprintf("read_sectors: Could not access sector 0x%08llx - %s\n", StartSector, WindowsErrorString());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((!ReadFile(hDrive, pBuf, Size, &Size, NULL)) || (Size != nSectors*SectorSize))
|
||||
{
|
||||
uprintf("read_sectors: Read error - %s\n", WindowsErrorString());
|
||||
uprintf(" Read: %d, Expected: %d\n", Size, nSectors*SectorSize);
|
||||
uprintf(" StartSector:%0X, nSectors:%0X, SectorSize:%0X\n", StartSector, nSectors, SectorSize);
|
||||
uprintf("read_sectors: Read error %s\n", (GetLastError()!=ERROR_SUCCESS)?WindowsErrorString():"");
|
||||
uprintf(" Read: %d, Expected: %lld\n", Size, nSectors*SectorSize);
|
||||
uprintf(" StartSector: 0x%08llx, nSectors: 0x%llx, SectorSize: 0x%llx\n", StartSector, nSectors, SectorSize);
|
||||
}
|
||||
|
||||
return (int64_t)Size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue