mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[misc] improve the code related to the commandline hogger deletion
* Also small additional code improvements
This commit is contained in:
parent
58c56eb398
commit
e0b5c6d96f
3 changed files with 22 additions and 22 deletions
|
@ -1,2 +1,2 @@
|
||||||
@echo off
|
@echo off
|
||||||
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64\signtool" sign /v /sha1 3dbc3a2a0e9ce8803b422cfdbc60acd33164965d /fd SHA256 /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td SHA256 %1
|
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64\signtool" sign /v /sha1 3dbc3a2a0e9ce8803b422cfdbc60acd33164965d /fd SHA256 /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td SHA256 %*
|
||||||
|
|
32
src/rufus.c
32
src/rufus.c
|
@ -3364,8 +3364,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
// and the automated VS2019 package building process doesn't like renaming the .exe
|
// and the automated VS2019 package building process doesn't like renaming the .exe
|
||||||
// right under its nose (else we would use the same trick as for portable vs regular)
|
// right under its nose (else we would use the same trick as for portable vs regular)
|
||||||
// we use yet another workaround to detect if we are running the AppStore version...
|
// we use yet another workaround to detect if we are running the AppStore version...
|
||||||
static_sprintf(ini_path, "%srufus.app", app_dir);
|
static_sprintf(tmp_path, "%srufus.app", app_dir);
|
||||||
if (PathFileExistsU(ini_path)) {
|
if (PathFileExistsU(tmp_path)) {
|
||||||
appstore_version = TRUE;
|
appstore_version = TRUE;
|
||||||
goto skip_args_processing;
|
goto skip_args_processing;
|
||||||
}
|
}
|
||||||
|
@ -3507,7 +3507,7 @@ skip_args_processing:
|
||||||
static_strcpy(app_data_dir, app_dir);
|
static_strcpy(app_data_dir, app_dir);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
uprintf("Will use settings from %s", (ini_file != NULL)?"INI file":"registry");
|
uprintf("Will use settings from %s", (ini_file != NULL) ? "INI file" : "registry");
|
||||||
|
|
||||||
// Use the locale specified by the settings, if any
|
// Use the locale specified by the settings, if any
|
||||||
tmp = ReadSettingStr(SETTING_LOCALE);
|
tmp = ReadSettingStr(SETTING_LOCALE);
|
||||||
|
@ -3629,7 +3629,7 @@ skip_args_processing:
|
||||||
|
|
||||||
// Prevent 2 applications from running at the same time, unless "/W" is passed as an option
|
// Prevent 2 applications from running at the same time, unless "/W" is passed as an option
|
||||||
// in which case we wait for the mutex to be relinquished
|
// in which case we wait for the mutex to be relinquished
|
||||||
if ((safe_strlen(lpCmdLine)==2) && (lpCmdLine[0] == '/') && (lpCmdLine[1] == 'W'))
|
if ((safe_strlen(lpCmdLine) == 2) && (lpCmdLine[0] == '/') && (lpCmdLine[1] == 'W'))
|
||||||
wait_for_mutex = 150; // Try to acquire the mutex for 15 seconds
|
wait_for_mutex = 150; // Try to acquire the mutex for 15 seconds
|
||||||
mutex = CreateMutexA(NULL, TRUE, "Global/" APPLICATION_NAME);
|
mutex = CreateMutexA(NULL, TRUE, "Global/" APPLICATION_NAME);
|
||||||
for (;(wait_for_mutex>0) && (mutex != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS); wait_for_mutex--) {
|
for (;(wait_for_mutex>0) && (mutex != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS); wait_for_mutex--) {
|
||||||
|
@ -3653,9 +3653,8 @@ skip_args_processing:
|
||||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||||
|
|
||||||
// Some dialogs have Rich Edit controls and won't display without this
|
// Some dialogs have Rich Edit controls and won't display without this
|
||||||
if (GetLibraryHandle("Riched20") == NULL) {
|
if (GetLibraryHandle("Riched20") == NULL)
|
||||||
uprintf("Could not load RichEdit library - some dialogs may not display: %s\n", WindowsErrorString());
|
uprintf("Could not load RichEdit library - some dialogs may not display: %s", WindowsErrorString());
|
||||||
}
|
|
||||||
|
|
||||||
// Increase the application privileges (SE_DEBUG_PRIVILEGE), so that we can report
|
// Increase the application privileges (SE_DEBUG_PRIVILEGE), so that we can report
|
||||||
// the Windows Services preventing access to the disk or volume we want to format.
|
// the Windows Services preventing access to the disk or volume we want to format.
|
||||||
|
@ -4101,10 +4100,14 @@ extern int TestHashes(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
_chdirU(app_dir);
|
||||||
// Destroy the hogger mutex first, so that the cmdline app can exit and we can delete it
|
// Destroy the hogger mutex first, so that the cmdline app can exit and we can delete it
|
||||||
if (attached_console && !disable_hogger) {
|
if (hogmutex != NULL) {
|
||||||
ReleaseMutex(hogmutex);
|
ReleaseMutex(hogmutex);
|
||||||
safe_closehandle(hogmutex);
|
safe_closehandle(hogmutex);
|
||||||
|
// Unconditional delete with retry, just in case...
|
||||||
|
for (i = 0; (!DeleteFileA(cmdline_hogger)) && (i <= 10); i++)
|
||||||
|
Sleep(200);
|
||||||
}
|
}
|
||||||
// Kill the update check thread if running
|
// Kill the update check thread if running
|
||||||
if (update_check_thread != NULL)
|
if (update_check_thread != NULL)
|
||||||
|
@ -4126,7 +4129,8 @@ out:
|
||||||
safe_free(fido_script);
|
safe_free(fido_script);
|
||||||
safe_free(pe256ssp);
|
safe_free(pe256ssp);
|
||||||
if (argv != NULL) {
|
if (argv != NULL) {
|
||||||
for (i=0; i<argc; i++) safe_free(argv[i]);
|
for (i = 0; i < argc; i++)
|
||||||
|
safe_free(argv[i]);
|
||||||
safe_free(argv);
|
safe_free(argv);
|
||||||
}
|
}
|
||||||
if (lgp_set)
|
if (lgp_set)
|
||||||
|
@ -4134,17 +4138,13 @@ out:
|
||||||
if ((!automount) && (!SetAutoMount(FALSE)))
|
if ((!automount) && (!SetAutoMount(FALSE)))
|
||||||
uprintf("Failed to restore AutoMount to disabled");
|
uprintf("Failed to restore AutoMount to disabled");
|
||||||
ubflush();
|
ubflush();
|
||||||
_chdirU(app_dir);
|
|
||||||
// Unconditional delete with retry, just in case...
|
|
||||||
for (i = 0; (!DeleteFileA(cmdline_hogger)) && (i <= 10); i++)
|
|
||||||
Sleep(200);
|
|
||||||
CloseHandle(mutex);
|
|
||||||
CoUninitialize();
|
|
||||||
CLOSE_OPENED_LIBRARIES;
|
|
||||||
if (attached_console) {
|
if (attached_console) {
|
||||||
SetWindowPos(GetConsoleWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
SetWindowPos(GetConsoleWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
}
|
}
|
||||||
|
CoUninitialize();
|
||||||
|
CLOSE_OPENED_LIBRARIES;
|
||||||
|
safe_closehandle(mutex);
|
||||||
uprintf("*** " APPLICATION_NAME " exit ***\n");
|
uprintf("*** " APPLICATION_NAME " exit ***\n");
|
||||||
#ifdef _CRTDBG_MAP_ALLOC
|
#ifdef _CRTDBG_MAP_ALLOC
|
||||||
_CrtDumpMemoryLeaks();
|
_CrtDumpMemoryLeaks();
|
||||||
|
|
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 4.4.2091"
|
CAPTION "Rufus 4.4.2092"
|
||||||
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
|
||||||
|
@ -392,8 +392,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 4,4,2091,0
|
FILEVERSION 4,4,2092,0
|
||||||
PRODUCTVERSION 4,4,2091,0
|
PRODUCTVERSION 4,4,2092,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -411,13 +411,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", "4.4.2091"
|
VALUE "FileVersion", "4.4.2092"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2023 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-4.4.exe"
|
VALUE "OriginalFilename", "rufus-4.4.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "4.4.2091"
|
VALUE "ProductVersion", "4.4.2092"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue