[misc] fix application closing when terminating console, when -g is used

* Closes #1243
* Closes #1244
This commit is contained in:
Charles Stevens 2018-11-10 13:52:58 -06:00 committed by Pete Batard
parent 08019ea67c
commit 2ba62fa891
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
2 changed files with 18 additions and 20 deletions

28
src/rufus.c Normal file → Executable file
View File

@ -2694,7 +2694,7 @@ static void PrintUsage(char* appname)
printf(" This usage guide.\n");
}
static HANDLE SetHogger(BOOL attached_console, BOOL disable_hogger)
static HANDLE SetHogger(void)
{
INPUT* input;
BYTE* hog_data;
@ -2702,12 +2702,9 @@ static HANDLE SetHogger(BOOL attached_console, BOOL disable_hogger)
HANDLE hogmutex = NULL, hFile = NULL;
int i;
if (!attached_console)
return NULL;
hog_data = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_XT_HOGGER),
_RT_RCDATA, cmdline_hogger, &hog_size, FALSE);
if ((hog_data != NULL) && (!disable_hogger)) {
if (hog_data != NULL) {
// Create our synchronisation mutex
hogmutex = CreateMutexA(NULL, TRUE, "Global/Rufus_CmdLine");
@ -2806,15 +2803,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
uprintf("*** " APPLICATION_NAME " init ***\n");
// Reattach the console, if we were started from commandline
if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
attached_console = TRUE;
IGNORE_RETVAL(freopen("CONIN$", "r", stdin));
IGNORE_RETVAL(freopen("CONOUT$", "w", stdout));
IGNORE_RETVAL(freopen("CONOUT$", "w", stderr));
_flushall();
}
// We have to process the arguments before we acquire the lock and process the locale
PF_INIT(__wgetmainargs, Msvcrt);
if (pf__wgetmainargs != NULL) {
@ -2843,7 +2831,17 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
ini_flags[0] = 'a';
// Now enable the hogger before processing the rest of the arguments
hogmutex = SetHogger(attached_console, disable_hogger);
if (!disable_hogger) {
// Reattach the console, if we were started from commandline
if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
attached_console = TRUE;
IGNORE_RETVAL(freopen("CONIN$", "r", stdin));
IGNORE_RETVAL(freopen("CONOUT$", "w", stdout));
IGNORE_RETVAL(freopen("CONOUT$", "w", stderr));
_flushall();
hogmutex = SetHogger();
}
}
while ((opt = getopt_long(argc, argv, "?xghf:i:w:l:", long_options, &option_index)) != EOF) {
switch (opt) {

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.4.1422"
CAPTION "Rufus 3.4.1423"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,4,1422,0
PRODUCTVERSION 3,4,1422,0
FILEVERSION 3,4,1423,0
PRODUCTVERSION 3,4,1423,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.4.1422"
VALUE "FileVersion", "3.4.1423"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.4.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.4.1422"
VALUE "ProductVersion", "3.4.1423"
END
END
BLOCK "VarFileInfo"