mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[iso] improve handling of image size
* Don't use the projected size where the actual image size should be used * Also fix an issue with the projected size computation
This commit is contained in:
parent
0c76dbf075
commit
30137de7cb
7 changed files with 20 additions and 18 deletions
|
@ -931,10 +931,10 @@ DWORD WINAPI SumThread(void* param)
|
|||
// Update the progress and check for cancel
|
||||
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
|
||||
LastRefresh = _GetTickCount64();
|
||||
format_percent = (100.0f*rb) / (1.0f*img_report.projected_size);
|
||||
format_percent = (100.0f*rb) / (1.0f*img_report.image_size);
|
||||
PrintInfo(0, MSG_271, format_percent);
|
||||
SendMessage(hProgress, PBM_SETPOS, (WPARAM)((format_percent / 100.0f)*MAX_PROGRESS), 0);
|
||||
SetTaskbarProgressValue(rb, img_report.projected_size);
|
||||
SetTaskbarProgressValue(rb, img_report.image_size);
|
||||
}
|
||||
CHECK_FOR_USER_CANCEL;
|
||||
|
||||
|
|
|
@ -1505,7 +1505,7 @@ static void update_progress(const uint64_t processed_bytes)
|
|||
{
|
||||
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
|
||||
LastRefresh = _GetTickCount64();
|
||||
format_percent = (100.0f*processed_bytes)/(1.0f*img_report.projected_size);
|
||||
format_percent = (100.0f*processed_bytes)/(1.0f*img_report.image_size);
|
||||
PrintInfo(0, MSG_261, format_percent);
|
||||
UpdateProgress(OP_FORMAT, format_percent);
|
||||
}
|
||||
|
@ -1517,7 +1517,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage)
|
|||
BOOL s, ret = FALSE;
|
||||
LARGE_INTEGER li;
|
||||
DWORD rSize, wSize, BufSize;
|
||||
uint64_t wb, target_size = hSourceImage?img_report.projected_size:SelectedDrive.DiskSize;
|
||||
uint64_t wb, target_size = hSourceImage?img_report.image_size:SelectedDrive.DiskSize;
|
||||
uint8_t *buffer = NULL;
|
||||
int i;
|
||||
|
||||
|
|
|
@ -242,9 +242,9 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t i_file_length, cons
|
|||
if (i_file_length >= FOUR_GIGABYTES)
|
||||
img_report.has_4GB_file = TRUE;
|
||||
// Compute projected size needed
|
||||
total_blocks += i_file_length/UDF_BLOCKSIZE;
|
||||
total_blocks += i_file_length / ISO_BLOCKSIZE;
|
||||
// NB: ISO_BLOCKSIZE = UDF_BLOCKSIZE
|
||||
if ((i_file_length != 0) && (i_file_length%ISO_BLOCKSIZE == 0))
|
||||
if ((i_file_length != 0) && (i_file_length % ISO_BLOCKSIZE != 0))
|
||||
total_blocks++;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -673,7 +673,6 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
|
|||
uprintf("ISO analysis:");
|
||||
SendMessage(hMainDialog, UM_PROGRESS_INIT, PBS_MARQUEE, 0);
|
||||
total_blocks = 0;
|
||||
memset(&img_report, 0, sizeof(img_report));
|
||||
has_ldlinux_c32 = FALSE;
|
||||
// String array of all isolinux/syslinux locations
|
||||
StrArrayCreate(&config_path, 8);
|
||||
|
|
|
@ -972,7 +972,7 @@ static void DisplayISOProps(void)
|
|||
int i;
|
||||
|
||||
uprintf("ISO label: '%s'", img_report.label);
|
||||
uprintf(" Size: %s", SizeToHumanReadable( img_report.projected_size, FALSE, FALSE));
|
||||
uprintf(" Size: %s (Projected)", SizeToHumanReadable(img_report.projected_size, FALSE, FALSE));
|
||||
PRINT_ISO_PROP(img_report.has_4GB_file, " Has a >4GB file");
|
||||
PRINT_ISO_PROP(img_report.has_long_filename, " Has a >64 chars filename");
|
||||
PRINT_ISO_PROP(HAS_SYSLINUX(img_report), " Uses: Syslinux/Isolinux v%s", img_report.sl_version_str);
|
||||
|
@ -1015,9 +1015,11 @@ DWORD WINAPI ISOScanThread(LPVOID param)
|
|||
PrintInfoDebug(0, MSG_202);
|
||||
user_notified = FALSE;
|
||||
EnableControls(FALSE);
|
||||
memset(&img_report, 0, sizeof(img_report));
|
||||
img_report.is_iso = (BOOLEAN)ExtractISO(image_path, "", TRUE);
|
||||
img_report.is_bootable_img = (BOOLEAN)IsBootableImage(image_path);
|
||||
if (!img_report.is_iso && !img_report.is_bootable_img) {
|
||||
|
||||
if ((img_report.image_size == 0) || (!img_report.is_iso && !img_report.is_bootable_img)) {
|
||||
// Failed to scan image
|
||||
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0);
|
||||
PrintInfoDebug(0, MSG_203);
|
||||
|
|
|
@ -277,6 +277,7 @@ typedef struct {
|
|||
char cfg_path[128]; /* path to the ISO's isolinux.cfg */
|
||||
char reactos_path[128]; /* path to the ISO's freeldr.sys or setupldr.sys */
|
||||
char install_wim_path[64]; /* path to install.wim or install.swm */
|
||||
uint64_t image_size;
|
||||
uint64_t projected_size;
|
||||
uint32_t install_wim_version;
|
||||
BOOLEAN is_iso;
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 242, 376
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_ACCEPTFILES
|
||||
CAPTION "Rufus 2.15.1098"
|
||||
CAPTION "Rufus 2.15.1099"
|
||||
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
||||
|
@ -334,8 +334,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,15,1098,0
|
||||
PRODUCTVERSION 2,15,1098,0
|
||||
FILEVERSION 2,15,1099,0
|
||||
PRODUCTVERSION 2,15,1099,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -352,13 +352,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "2.15.1098"
|
||||
VALUE "FileVersion", "2.15.1099"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "2.15.1098"
|
||||
VALUE "ProductVersion", "2.15.1099"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -293,19 +293,19 @@ BOOL IsBootableImage(const char* path)
|
|||
uprintf(" Could not get image size: %s", WindowsErrorString());
|
||||
goto out;
|
||||
}
|
||||
img_report.projected_size = (uint64_t)liImageSize.QuadPart;
|
||||
img_report.image_size = (uint64_t)liImageSize.QuadPart;
|
||||
|
||||
size = sizeof(vhd_footer);
|
||||
if ((img_report.compression_type == BLED_COMPRESSION_NONE) && (img_report.projected_size >= (512 + size))) {
|
||||
if ((img_report.compression_type == BLED_COMPRESSION_NONE) && (img_report.image_size >= (512 + size))) {
|
||||
footer = (vhd_footer*)malloc(size);
|
||||
ptr.QuadPart = img_report.projected_size - size;
|
||||
ptr.QuadPart = img_report.image_size - size;
|
||||
if ( (footer == NULL) || (!SetFilePointerEx(handle, ptr, NULL, FILE_BEGIN)) ||
|
||||
(!ReadFile(handle, footer, size, &size, NULL)) || (size != sizeof(vhd_footer)) ) {
|
||||
uprintf(" Could not read VHD footer");
|
||||
goto out;
|
||||
}
|
||||
if (memcmp(footer->cookie, conectix_str, sizeof(footer->cookie)) == 0) {
|
||||
img_report.projected_size -= sizeof(vhd_footer);
|
||||
img_report.image_size -= sizeof(vhd_footer);
|
||||
if ( (bswap_uint32(footer->file_format_version) != VHD_FOOTER_FILE_FORMAT_V1_0)
|
||||
|| (bswap_uint32(footer->disk_type) != VHD_FOOTER_TYPE_FIXED_HARD_DISK)) {
|
||||
uprintf(" Unsupported type of VHD image");
|
||||
|
|
Loading…
Reference in a new issue