diff --git a/src/dev.c b/src/dev.c index bdf483be..c7b44dc9 100644 --- a/src/dev.c +++ b/src/dev.c @@ -340,7 +340,7 @@ BOOL GetDevices(DWORD devnum) // See http://itdoc.hitachi.co.jp/manuals/3021/30213B5200e/DMDS0094.HTM // Also http://www.carrona.org/dvrref.php. NB: These should be reported // as enumerators by Rufus when Enum Debug is enabled - "SD", "PCISTOR", "RTSOR", "JMCR", "JMCF", "RIMMPTSK", "RIMSPTSK", "RIXDPTSK", + "SD", "PCISTOR", "RTSOR", "JMCR", "JMCF", "RIMMPTSK", "RIMSPTSK", "RISD", "RIXDPTSK", "TI21SONY", "ESD7SK", "ESM7SK", "O2MD", "O2SD", "VIACR" }; // Oh, and we also have card devices (e.g. 'SCSI\DiskO2Micro_SD_...') under the SCSI enumerator... diff --git a/src/format.c b/src/format.c index 5b63b4f7..93e7964a 100644 --- a/src/format.c +++ b/src/format.c @@ -2146,7 +2146,7 @@ DWORD WINAPI FormatThread(void* param) } } // EFI mode selected, with no 'boot###.efi' but Windows 7 x64's 'bootmgr.efi' (bit #0) - if ((tt == TT_UEFI) && HAS_WIN7_EFI(img_report)) { + if (((tt == TT_UEFI) || allow_dual_uefi_bios) && HAS_WIN7_EFI(img_report)) { PrintInfoDebug(0, MSG_232); img_report.wininst_path[0][0] = drive_name[0]; efi_dst[0] = drive_name[0]; diff --git a/src/msapi_utf8.h b/src/msapi_utf8.h index 9056dbdd..617226c9 100644 --- a/src/msapi_utf8.h +++ b/src/msapi_utf8.h @@ -694,6 +694,23 @@ static __inline DWORD GetFileAttributesU(const char* lpFileName) return ret; } +static __inline BOOL SetFileAttributesU(const char* lpFileName, DWORD dwFileAttributes) +{ + BOOL ret = FALSE, err = ERROR_INVALID_DATA; + wconvert(lpFileName); + // Unlike Microsoft's version, ours doesn't fail if the string is quoted + if ((wlpFileName[0] == L'"') && (wlpFileName[wcslen(wlpFileName) - 1] == L'"')) { + wlpFileName[wcslen(wlpFileName) - 1] = 0; + ret = SetFileAttributesW(&wlpFileName[1], dwFileAttributes); + } else { + ret = SetFileAttributesW(wlpFileName, dwFileAttributes); + } + err = GetLastError(); + wfree(lpFileName); + SetLastError(err); + return ret; +} + static __inline int SHCreateDirectoryExU(HWND hwnd, const char* pszPath, SECURITY_ATTRIBUTES *psa) { int ret = ERROR_INVALID_DATA; diff --git a/src/net.c b/src/net.c index 923b08ce..6a3b9925 100644 --- a/src/net.c +++ b/src/net.c @@ -949,7 +949,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) assert((fido_script != NULL) && (fido_len != 0)); static_sprintf(script_path, "%s%s.ps1", temp_dir, GuidToString(&guid)); - hFile = CreateFileU(script_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileU(script_path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_READONLY, NULL); if (hFile == INVALID_HANDLE_VALUE) { uprintf("Unable to create download script '%s': %s", script_path, WindowsErrorString()); goto out; @@ -958,7 +958,8 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) uprintf("Unable to write download script '%s': %s", script_path, WindowsErrorString()); goto out; } - // TODO: Try to Harden this so that only us and the powershell we launch can access the file + // Why oh why does PowerShell refuse to open read-only files that haven't been closed? + // Because of this limitation, we can't use LockFileEx() on the file we create... safe_closehandle(hFile); #endif static_sprintf(powershell_path, "%s\\WindowsPowerShell\\v1.0\\powershell.exe", system_dir); @@ -973,6 +974,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) dwPipeSize, dwPipeSize, 0, NULL); if (hPipe == INVALID_HANDLE_VALUE) { uprintf("Could not create pipe '%s': %s", pipe, WindowsErrorString); + goto out; } static_sprintf(cmdline, "%s -NonInteractive -Sta -NoProfile –ExecutionPolicy Bypass " @@ -1027,8 +1029,10 @@ out: if (icon_path[0] != 0) DeleteFileU(icon_path); #if !defined(RUFUS_TEST) - if (script_path[0] != 0) + if (script_path[0] != 0) { + SetFileAttributesU(script_path, FILE_ATTRIBUTE_NORMAL); DeleteFileU(script_path); + } #endif free(url); SendMessage(hMainDialog, UM_ENABLE_CONTROLS, 0, 0); diff --git a/src/rufus.rc b/src/rufus.rc index ec58ec70..a107ed46 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -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.5.1495" +CAPTION "Rufus 3.5.1496" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -394,8 +394,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,5,1495,0 - PRODUCTVERSION 3,5,1495,0 + FILEVERSION 3,5,1496,0 + PRODUCTVERSION 3,5,1496,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -413,13 +413,13 @@ BEGIN VALUE "Comments", "https://akeo.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.5.1495" + VALUE "FileVersion", "3.5.1496" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus-3.5.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.5.1495" + VALUE "ProductVersion", "3.5.1496" END END BLOCK "VarFileInfo"