diff --git a/src/iso.c b/src/iso.c index f1221431..eeb1f323 100644 --- a/src/iso.c +++ b/src/iso.c @@ -89,8 +89,9 @@ static const char* ldlinux_c32 = "ldlinux.c32"; static const char* md5sum_name[] = { "MD5SUMS", "md5sum.txt" }; static const char* casper_dirname = "/casper"; static const char* efi_dirname = "/efi/boot"; -static const char* efi_bootname[MAX_ARCHS] = - { "bootia32.efi", "bootia64.efi", "bootx64.efi", "bootarm.efi", "bootaa64.efi", "bootebc.efi" }; +static const char* efi_bootname[MAX_ARCHS] = { + "bootia32.efi", "bootia64.efi", "bootx64.efi", "bootarm.efi", "bootaa64.efi", + "bootebc.efi", "bootriscv32.efi", "bootriscv64.efi", "bootriscv128.efi" }; static const char* sources_str = "/sources"; static const char* wininst_name[] = { "install.wim", "install.esd", "install.swm" }; // We only support GRUB/BIOS (x86) that uses a standard config dir (/boot/grub/i386-pc/) @@ -1020,7 +1021,7 @@ out: } } if (!IS_EFI_BOOTABLE(img_report) && HAS_EFI_IMG(img_report) && HasEfiImgBootLoaders()) { - img_report.has_efi = 0x80; + img_report.has_efi = 0x8000; } if (HAS_WINPE(img_report)) { // In case we have a WinPE 1.x based iso, we extract and parse txtsetup.sif @@ -1045,6 +1046,7 @@ out: if (img_report.has_grub2) { // In case we have a GRUB2 based iso, we extract boot/grub/i386-pc/normal.mod to parse its version img_report.grub2_version[0] = 0; + // coverity[swapped_arguments] if (GetTempFileNameU(temp_dir, APPLICATION_NAME, 0, path) != 0) { size = (size_t)ExtractISOFile(src_iso, "boot/grub/i386-pc/normal.mod", path, FILE_ATTRIBUTE_NORMAL); buf = (char*)calloc(size, 1); @@ -1071,7 +1073,7 @@ out: SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0); } else { // Solus and other ISOs only provide EFI boot files in a FAT efi.img - if (img_report.has_efi == 0x80) + if (img_report.has_efi == 0x8000) DumpFatDir(dest_dir, 0); if (HAS_SYSLINUX(img_report)) { static_sprintf(path, "%s\\syslinux.cfg", dest_dir); diff --git a/src/missing.h b/src/missing.h index 0a21ab2a..be0b2c23 100644 --- a/src/missing.h +++ b/src/missing.h @@ -125,3 +125,14 @@ static __inline void *_reallocf(void *ptr, size_t size) { /* The following is used for native ISO mounting in Windows 8 or later */ #define VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT \ { 0xEC984AECL, 0xA0F9, 0x47e9, { 0x90, 0x1F, 0x71, 0x41, 0x5A, 0x66, 0x34, 0x5B } } + +/* RISC-V is still bleeding edge */ +#ifndef IMAGE_FILE_MACHINE_RISCV32 +#define IMAGE_FILE_MACHINE_RISCV32 0x5032 +#endif +#ifndef IMAGE_FILE_MACHINE_RISCV64 +#define IMAGE_FILE_MACHINE_RISCV64 0x5064 +#endif +#ifndef IMAGE_FILE_MACHINE_RISCV128 +#define IMAGE_FILE_MACHINE_RISCV128 0x5128 +#endif diff --git a/src/rufus.c b/src/rufus.c index 19a2d689..e7652755 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -62,7 +62,8 @@ enum bootcheck_return { static const char* cmdline_hogger = "rufus.com"; static const char* ep_reg = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"; static const char* vs_reg = "Software\\Microsoft\\VisualStudio"; -static const char* arch_name[MAX_ARCHS] = { "x86_32", "Itanic", "x86_64", "ARM", "ARM64", "EBC" }; +static const char* arch_name[MAX_ARCHS] = { + "x86_32", "Itanic", "x86_64", "ARM", "ARM64", "EBC","Risc-V 32", "Risc-V 64", "Risc-V 128" }; static BOOL existing_key = FALSE; // For LGP set/restore static BOOL size_check = TRUE; static BOOL log_displayed = FALSE; @@ -1167,6 +1168,15 @@ static uint8_t FindArch(const char* filename) case IMAGE_FILE_MACHINE_EBC: ret = 6; break; + case IMAGE_FILE_MACHINE_RISCV32: + ret = 7; + break; + case IMAGE_FILE_MACHINE_RISCV64: + ret = 8; + break; + case IMAGE_FILE_MACHINE_RISCV128: + ret = 9; + break; } out: @@ -1212,12 +1222,13 @@ DWORD WINAPI ImageScanThread(LPVOID param) if (img_report.is_windows_img) { selection_default = BT_IMAGE; + // coverity[swapped_arguments] if (GetTempFileNameU(temp_dir, APPLICATION_NAME, 0, tmp_path) != 0) { // Only look at index 1 for now. If people complain, we may look for more. if (WimExtractFile(image_path, 1, "Windows\\Boot\\EFI\\bootmgr.efi", tmp_path, TRUE)) { arch = FindArch(tmp_path); if (arch != 0) { - uprintf(" Image contains an %s EFI boot manager", arch_name[arch - 1]); + uprintf(" Image contains a%s %s EFI boot manager", arch_name[arch - 1], (arch < 7) ? "n" : ""); img_report.has_efi = 1 | (1 << arch); img_report.has_bootmgr_efi = TRUE; img_report.wininst_index = 1; @@ -1727,7 +1738,7 @@ static void InitDialog(HWND hDlg) // Count on Microsoft for making it more attractive to read a // version using strtok() than using GetFileVersionInfo() token = strtok(tmp, " "); - for (i=0; (i<3) && ((token = strtok(NULL, ".")) != NULL); i++) + for (i = 0; (i < 3) && ((token = strtok(NULL, ".")) != NULL); i++) rufus_version[i] = (uint16_t)atoi(token); // Redefine the title to be able to add "Alpha" or "Beta" @@ -1738,7 +1749,7 @@ static void InitDialog(HWND hDlg) dialog_handle = FindWindowA(NULL, tmp); uprintf(APPLICATION_NAME " " APPLICATION_ARCH " v%d.%d.%d%s%s", rufus_version[0], rufus_version[1], rufus_version[2], IsAlphaOrBeta(), (ini_file != NULL)?"(Portable)":""); - for (i=0; i