[ui] produce a more explicit error message when an image can't be opened/read

* Closes #1843
* Also publish Coverity artifacts since upload to Coverity seems to be broken atm.
This commit is contained in:
Pete Batard 2022-01-07 13:25:46 +00:00
parent 52d05aa228
commit a47072c3c6
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
7 changed files with 34 additions and 20 deletions

View File

@ -50,8 +50,15 @@ jobs:
- name: Build with Coverity
run: cov-build.exe --dir cov-int msbuild ${{ env.SOLUTION_FILE_PATH }} /m /p:Configuration=${{ env.BUILD_CONFIGURATION }},Platform=${{ env.TARGET_PLATFORM }}
- name: Publish Coverity artifacts
uses: actions/upload-artifact@v2
with:
name: cov-int
path: cov-int/
- name: Upload Coverity build for analysis
run: |
7z a -r cov-int.zip cov-int
curl --form email=${{ env.EMAIL }} --form token=${{ secrets.COVERITY_SCAN_TOKEN }} --form file=@cov-int.zip --form version="${{ env.GITHUB_SHA }}" --form description="Automated build" https://scan.coverity.com/builds?project=${{ env.COVERITY_PROJECT_NAME }}

View File

@ -10,6 +10,7 @@ o v3.?? (????.??.??)
- *NEW* MSG_322 "Standard Windows 11 Installation (TPM 2.0 + Secure Boot)"
- *NEW* MSG_323 "Extended Windows 11 Installation (no TPM / no Secure Boot)"
- *NEW* MSG_324 "Removing Windows 11 installation restrictions: %s"
- *NEW* MSG_325 "Unable to open or read '%s'"
o v3.14 (2021.03.31)
- *UPDATED* MSG_068 "Error while partitioning drive." -> "Could not partition drive."

View File

@ -586,6 +586,7 @@ t MSG_321 "The image you have selected is an ISOHybrid, but its creators have no
t MSG_322 "Standard Windows 11 Installation (TPM 2.0 + Secure Boot)"
t MSG_323 "Extended Windows 11 Installation (no TPM / no Secure Boot)"
t MSG_324 "Removing Windows 11 installation restrictions: %s"
t MSG_325 "Unable to open or read '%s'"
#########################################################################
l "ar-SA" "Arabic (العربية)" 0x0401, 0x0801, 0x0c01, 0x1001, 0x1401, 0x1801, 0x1c01, 0x2001, 0x2401, 0x2801, 0x2c01, 0x3001, 0x3401, 0x3801, 0x3c01, 0x4001

View File

@ -335,7 +335,7 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target)
if (HAS_WINDOWS(img_report) && img_report.has_efi)
preferred_pt = allow_dual_uefi_bios? PARTITION_STYLE_MBR :
((selected_pt >= 0) ? selected_pt : PARTITION_STYLE_GPT);
if (img_report.is_bootable_img)
if (IS_DD_BOOTABLE(img_report))
preferred_pt = (selected_pt >= 0) ? selected_pt : PARTITION_STYLE_MBR;
}
SetComboEntry(hPartitionScheme, preferred_pt);
@ -841,7 +841,7 @@ static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes)
actual_enable = FALSE;
actual_enable_bb = actual_enable;
// If we are dealing with a pure DD image, remove all options except Bad Blocks check
if ((boot_type == BT_IMAGE) && (img_report.is_bootable_img) && (!img_report.is_iso))
if ((boot_type == BT_IMAGE) && IS_DD_BOOTABLE(img_report) && (!img_report.is_iso))
actual_enable = FALSE;
EnableWindow(hImageOption, actual_enable);
@ -1284,17 +1284,20 @@ DWORD WINAPI ImageScanThread(LPVOID param)
if ((FormatStatus == (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_CANCELLED)) ||
(img_report.image_size == 0) ||
(!img_report.is_iso && !img_report.is_bootable_img && !img_report.is_windows_img)) {
(!img_report.is_iso && (img_report.is_bootable_img <= 0) && !img_report.is_windows_img)) {
// Failed to scan image
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0);
safe_free(image_path);
UpdateImage(FALSE);
SetMBRProps();
PopulateProperties();
PrintInfoDebug(0, MSG_203);
PrintStatus(0, MSG_203);
EnableControls(TRUE, FALSE);
MessageBoxExU(hMainDialog, lmprintf(MSG_082), lmprintf(MSG_081), MB_OK | MB_ICONINFORMATION | MB_IS_RTL, selected_langid);
if (img_report.is_bootable_img < 0)
MessageBoxExU(hMainDialog, lmprintf(MSG_325, image_path), lmprintf(MSG_042), MB_OK | MB_ICONERROR | MB_IS_RTL, selected_langid);
else
MessageBoxExU(hMainDialog, lmprintf(MSG_082), lmprintf(MSG_081), MB_OK | MB_ICONINFORMATION | MB_IS_RTL, selected_langid);
safe_free(image_path);
goto out;
}
@ -1317,7 +1320,7 @@ DWORD WINAPI ImageScanThread(LPVOID param)
DeleteFileU(tmp_path);
}
uprintf(" Image is %sa UEFI bootable Windows installation image", img_report.has_efi ? "" : "NOT ");
} else if (img_report.is_bootable_img) {
} else if (IS_DD_BOOTABLE(img_report)) {
if (img_report.is_bootable_img == 2)
uprintf(" Image is a FORCED non-bootable image");
else

View File

@ -333,8 +333,8 @@ enum checksum_type {
#define HAS_WINDOWS(r) (HAS_BOOTMGR(r) || (r.uses_minint) || HAS_WINPE(r))
#define HAS_WIN7_EFI(r) ((r.has_efi == 1) && HAS_WININST(r))
#define HAS_EFI_IMG(r) (r.efi_img_path[0] != 0)
#define IS_DD_BOOTABLE(r) (r.is_bootable_img)
#define IS_DD_ONLY(r) (r.is_bootable_img && (!r.is_iso || r.disable_iso))
#define IS_DD_BOOTABLE(r) (r.is_bootable_img > 0)
#define IS_DD_ONLY(r) ((r.is_bootable_img > 0) && (!r.is_iso || r.disable_iso))
#define IS_EFI_BOOTABLE(r) (r.has_efi != 0)
#define IS_BIOS_BOOTABLE(r) (HAS_BOOTMGR(r) || HAS_SYSLINUX(r) || HAS_WINPE(r) || HAS_GRUB(r) || HAS_REACTOS(r) || HAS_KOLIBRIOS(r))
#define HAS_WINTOGO(r) (HAS_BOOTMGR(r) && IS_EFI_BOOTABLE(r) && HAS_WININST(r))
@ -363,7 +363,7 @@ typedef struct {
int64_t mismatch_size;
uint32_t wininst_version;
BOOLEAN is_iso;
uint8_t is_bootable_img;
int8_t is_bootable_img;
BOOLEAN is_vhd;
BOOLEAN is_windows_img;
BOOLEAN disable_iso;
@ -598,7 +598,7 @@ extern BOOL WimExtractFile_7z(const char* image, int index, const char* src, con
extern BOOL WimApplyImage(const char* image, int index, const char* dst);
extern char* WimMountImage(const char* image, int index);
extern BOOL WimUnmountImage(const char* image, int index);
extern uint8_t IsBootableImage(const char* path);
extern int8_t IsBootableImage(const char* path);
extern BOOL AppendVHDFooter(const char* vhd_path);
extern int SetWinToGoIndex(void);
extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid);

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.18.1860"
CAPTION "Rufus 3.18.1861"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -395,8 +395,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,18,1860,0
PRODUCTVERSION 3,18,1860,0
FILEVERSION 3,18,1861,0
PRODUCTVERSION 3,18,1861,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.18.1860"
VALUE "FileVersion", "3.18.1861"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.18.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.18.1860"
VALUE "ProductVersion", "3.18.1861"
END
END
BLOCK "VarFileInfo"

View File

@ -326,7 +326,7 @@ BOOL IsCompressedBootableImage(const char* path)
}
// 0: non-bootable, 1: bootable, 2: forced bootable
uint8_t IsBootableImage(const char* path)
int8_t IsBootableImage(const char* path)
{
HANDLE handle = INVALID_HANDLE_VALUE;
LARGE_INTEGER liImageSize;
@ -336,13 +336,13 @@ uint8_t IsBootableImage(const char* path)
uint32_t checksum, old_checksum;
uint64_t wim_magic = 0;
LARGE_INTEGER ptr = { 0 };
uint8_t is_bootable_img = 0;
int8_t is_bootable_img;
uprintf("Disk image analysis:");
handle = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
handle = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (handle == INVALID_HANDLE_VALUE) {
uprintf(" Could not open image '%s'", path);
is_bootable_img = -1;
goto out;
}
@ -352,6 +352,7 @@ uint8_t IsBootableImage(const char* path)
if (!GetFileSizeEx(handle, &liImageSize)) {
uprintf(" Could not get image size: %s", WindowsErrorString());
is_bootable_img = -2;
goto out;
}
img_report.image_size = (uint64_t)liImageSize.QuadPart;
@ -368,6 +369,7 @@ uint8_t IsBootableImage(const char* path)
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");
is_bootable_img = -3;
goto out;
}
if (memcmp(footer->cookie, conectix_str, sizeof(footer->cookie)) == 0) {
@ -381,7 +383,7 @@ uint8_t IsBootableImage(const char* path)
// Might as well validate the checksum while we're at it
old_checksum = bswap_uint32(footer->checksum);
footer->checksum = 0;
for (checksum=0, i=0; i<sizeof(vhd_footer); i++)
for (checksum = 0, i = 0; i < sizeof(vhd_footer); i++)
checksum += ((uint8_t*)footer)[i];
checksum = ~checksum;
if (checksum != old_checksum)