-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] fix "drive cannot find the sector requested" when writing VHDs
* As opposed to the ERROR_HANDLE_EOF we get when reading sectors from the VHD file directly, now that we mount VHD/VHDX for reading, and access them as regular disks, we also need to process ERROR_SECTOR_NOT_FOUND as an indicator for the end of the drive. * Also switch to using GetOverlappedResultEx() with a timeout since we no longer have to cater for Windows 7. * Closes #2468.
- Loading branch information
Showing
2 changed files
with
10 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Rufus: The Reliable USB Formatting Utility | ||
* Windows I/O redefinitions, that would be totally unnecessary had | ||
* Microsoft done a proper job with their asynchronous APIs. | ||
* Copyright © 2021 Pete Batard <[email protected]> | ||
* Copyright © 2021-2024 Pete Batard <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -165,10 +165,10 @@ static __inline BOOL GetSizeAsync(HANDLE h, LPDWORD lpNumberOfBytes) | |
SetLastError(ERROR_NO_MORE_ITEMS); | ||
return FALSE; | ||
} | ||
// TODO: Use a timeout and call GetOverlappedResultEx() on Windows 8 and later | ||
if (!GetOverlappedResult(fd->hFile, (OVERLAPPED*)&fd->Overlapped, | ||
lpNumberOfBytes, (fd->iStatus < 0))) | ||
return (GetLastError() == ERROR_HANDLE_EOF); | ||
if (!GetOverlappedResultEx(fd->hFile, (OVERLAPPED*)&fd->Overlapped, | ||
lpNumberOfBytes, WRITE_TIMEOUT, (fd->iStatus < 0))) | ||
// When reading from VHD/VHDX we get SECTOR_NOT_FOUND rather than EOF for the end of the drive | ||
return (GetLastError() == ERROR_HANDLE_EOF || GetLastError() == ERROR_SECTOR_NOT_FOUND); | ||
fd->Overlapped.Offset += *lpNumberOfBytes; | ||
fd->Overlapped.bOffsetUpdated = TRUE; | ||
return TRUE; | ||
|