mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[misc] fix log potentially not being saved on exit
* Also ensures that if the user deleted the directory we don't recreate it for the log. * Also fix typos and Coverity warnings.
This commit is contained in:
parent
9dc045a701
commit
deee38d4e5
5 changed files with 20 additions and 14 deletions
|
@ -11,7 +11,7 @@
|
||||||
<Identity
|
<Identity
|
||||||
Name="19453.net.Rufus"
|
Name="19453.net.Rufus"
|
||||||
Publisher="CN=7AC86D13-3E5A-491A-ADD5-80095C212740"
|
Publisher="CN=7AC86D13-3E5A-491A-ADD5-80095C212740"
|
||||||
Version="3.16.1820.0" />
|
Version="3.16.1821.0" />
|
||||||
|
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>Rufus</DisplayName>
|
<DisplayName>Rufus</DisplayName>
|
||||||
|
|
|
@ -739,10 +739,12 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi
|
||||||
goto out;
|
goto out;
|
||||||
CHECK_FOR_USER_CANCEL;
|
CHECK_FOR_USER_CANCEL;
|
||||||
liFilePointer.QuadPart = DiskSize - (LONGLONG)SectorSize * MAX_SECTORS_TO_CLEAR;
|
liFilePointer.QuadPart = DiskSize - (LONGLONG)SectorSize * MAX_SECTORS_TO_CLEAR;
|
||||||
SetFilePointerEx(hPhysicalDrive, liFilePointer, &liFilePointer, FILE_BEGIN);
|
|
||||||
// Windows seems to be an ass about keeping a lock on a backup GPT,
|
// Windows seems to be an ass about keeping a lock on a backup GPT,
|
||||||
// so we try to be lenient about not being able to clear it.
|
// so we try to be lenient about not being able to clear it.
|
||||||
WriteFileWithRetry(hPhysicalDrive, pZeroBuf, SectorSize * MAX_SECTORS_TO_CLEAR, NULL, WRITE_RETRIES);
|
if (SetFilePointerEx(hPhysicalDrive, liFilePointer, &liFilePointer, FILE_BEGIN)) {
|
||||||
|
IGNORE_RETVAL(WriteFileWithRetry(hPhysicalDrive, pZeroBuf,
|
||||||
|
SectorSize * MAX_SECTORS_TO_CLEAR, NULL, WRITE_RETRIES));
|
||||||
|
}
|
||||||
r = TRUE;
|
r = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -894,7 +894,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
|
||||||
p_udf = udf_open(src_iso);
|
p_udf = udf_open(src_iso);
|
||||||
if (p_udf == NULL)
|
if (p_udf == NULL)
|
||||||
goto try_iso;
|
goto try_iso;
|
||||||
uprintf("%sImage is an UDF image", spacing);
|
uprintf("%sImage is a UDF image", spacing);
|
||||||
|
|
||||||
p_udf_root = udf_get_root(p_udf, true, 0);
|
p_udf_root = udf_get_root(p_udf, true, 0);
|
||||||
if (p_udf_root == NULL) {
|
if (p_udf_root == NULL) {
|
||||||
|
|
14
src/rufus.c
14
src/rufus.c
|
@ -72,6 +72,7 @@ static BOOL user_notified = FALSE;
|
||||||
static BOOL relaunch = FALSE;
|
static BOOL relaunch = FALSE;
|
||||||
static BOOL dont_display_image_name = FALSE;
|
static BOOL dont_display_image_name = FALSE;
|
||||||
static BOOL user_changed_label = FALSE;
|
static BOOL user_changed_label = FALSE;
|
||||||
|
static BOOL user_deleted_rufus_dir = FALSE;
|
||||||
static BOOL app_changed_label = FALSE;
|
static BOOL app_changed_label = FALSE;
|
||||||
static BOOL allowed_filesystem[FS_MAX] = { 0 };
|
static BOOL allowed_filesystem[FS_MAX] = { 0 };
|
||||||
static int64_t last_iso_blocking_status;
|
static int64_t last_iso_blocking_status;
|
||||||
|
@ -2217,11 +2218,13 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
|
|
||||||
// Save the current log to %LocalAppData%\Rufus\rufus.log
|
// Save the current log to %LocalAppData%\Rufus\rufus.log
|
||||||
log_size = GetWindowTextLengthU(hLog);
|
log_size = GetWindowTextLengthU(hLog);
|
||||||
if ((log_size > 0) && ((log_buffer = (char*)malloc(log_size)) != NULL)) {
|
if ((!user_deleted_rufus_dir) && (log_size > 0) && ((log_buffer = (char*)malloc(log_size)) != NULL)) {
|
||||||
log_size = GetDlgItemTextU(hLogDialog, IDC_LOG_EDIT, log_buffer, log_size);
|
log_size = GetDlgItemTextU(hLogDialog, IDC_LOG_EDIT, log_buffer, log_size);
|
||||||
if (log_size-- > 1) {
|
if (log_size-- > 1) {
|
||||||
static_sprintf(tmp, "%s\\%s\\rufus.log", app_data_dir, FILES_DIR);
|
IGNORE_RETVAL(_chdirU(app_data_dir));
|
||||||
FileIO(TRUE, tmp, &log_buffer, &log_size);
|
IGNORE_RETVAL(_mkdir(FILES_DIR));
|
||||||
|
IGNORE_RETVAL(_chdir(FILES_DIR));
|
||||||
|
FileIO(TRUE, "rufus.log", &log_buffer, &log_size);
|
||||||
}
|
}
|
||||||
safe_free(log_buffer);
|
safe_free(log_buffer);
|
||||||
}
|
}
|
||||||
|
@ -3669,11 +3672,12 @@ relaunch:
|
||||||
CyclePort(index);
|
CyclePort(index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Alt-D => Delete the 'rufus_files' subdirectory
|
// Alt-D => Delete the subdirectory where Rufus keeps its files
|
||||||
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'D')) {
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'D')) {
|
||||||
static_sprintf(tmp_path, "%s\\%s", app_data_dir, FILES_DIR);
|
static_sprintf(tmp_path, "%s\\%s", app_data_dir, FILES_DIR);
|
||||||
PrintStatus(STATUS_MSG_TIMEOUT, MSG_264, tmp_path);
|
PrintStatusDebug(STATUS_MSG_TIMEOUT, MSG_264, tmp_path);
|
||||||
SHDeleteDirectoryExU(NULL, tmp_path, FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION);
|
SHDeleteDirectoryExU(NULL, tmp_path, FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION);
|
||||||
|
user_deleted_rufus_dir = TRUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Alt-E => Enhanced installation mode (allow dual UEFI/BIOS mode and FAT32 for Windows)
|
// Alt-E => Enhanced installation mode (allow dual UEFI/BIOS mode and FAT32 for Windows)
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 3.16.1820"
|
CAPTION "Rufus 3.16.1821"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -395,8 +395,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,16,1820,0
|
FILEVERSION 3,16,1821,0
|
||||||
PRODUCTVERSION 3,16,1820,0
|
PRODUCTVERSION 3,16,1821,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -414,13 +414,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "3.16.1820"
|
VALUE "FileVersion", "3.16.1821"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-3.16.exe"
|
VALUE "OriginalFilename", "rufus-3.16.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.16.1820"
|
VALUE "ProductVersion", "3.16.1821"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue