mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[misc] remove the need for endpoint duplication in RunCommand()
This commit is contained in:
parent
336e24c8c7
commit
081d7b3a0b
2 changed files with 10 additions and 13 deletions
10
src/rufus.rc
10
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.1440"
|
||||
CAPTION "Rufus 3.5.1441"
|
||||
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,1440,0
|
||||
PRODUCTVERSION 3,5,1440,0
|
||||
FILEVERSION 3,5,1441,0
|
||||
PRODUCTVERSION 3,5,1441,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.1440"
|
||||
VALUE "FileVersion", "3.5.1441"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2018 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.1440"
|
||||
VALUE "ProductVersion", "3.5.1441"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
13
src/stdfn.c
13
src/stdfn.c
|
@ -594,26 +594,23 @@ DWORD RunCommand(const char* cmd, const char* dir, BOOL log)
|
|||
DWORD ret, dwRead, dwAvail, dwPipeSize = 4096;
|
||||
STARTUPINFOA si = {0};
|
||||
PROCESS_INFORMATION pi = {0};
|
||||
SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
|
||||
HANDLE hOutputRead = INVALID_HANDLE_VALUE, hOutputWrite = INVALID_HANDLE_VALUE;
|
||||
HANDLE hDupOutputWrite = INVALID_HANDLE_VALUE;
|
||||
static char* output;
|
||||
|
||||
si.cb = sizeof(si);
|
||||
if (log) {
|
||||
// NB: The size of a pipe is a suggestion, NOT an absolute guarantee
|
||||
// This means that you may get a pipe of 4K even if you requested 1K
|
||||
if (!CreatePipe(&hOutputRead, &hOutputWrite, NULL, dwPipeSize)) {
|
||||
if (!CreatePipe(&hOutputRead, &hOutputWrite, &sa, dwPipeSize)) {
|
||||
ret = GetLastError();
|
||||
uprintf("Could not set commandline pipe: %s", WindowsErrorString());
|
||||
goto out;
|
||||
}
|
||||
// We need an inheritable pipe endpoint handle
|
||||
DuplicateHandle(GetCurrentProcess(), hOutputWrite, GetCurrentProcess(), &hDupOutputWrite,
|
||||
0L, TRUE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS);
|
||||
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
||||
si.wShowWindow = SW_HIDE;
|
||||
si.hStdOutput = hDupOutputWrite;
|
||||
si.hStdError = hDupOutputWrite;
|
||||
si.hStdOutput = hOutputWrite;
|
||||
si.hStdError = hOutputWrite;
|
||||
}
|
||||
|
||||
if (!CreateProcessU(NULL, cmd, NULL, NULL, TRUE,
|
||||
|
@ -651,7 +648,7 @@ DWORD RunCommand(const char* cmd, const char* dir, BOOL log)
|
|||
CloseHandle(pi.hThread);
|
||||
|
||||
out:
|
||||
safe_closehandle(hDupOutputWrite);
|
||||
safe_closehandle(hOutputWrite);
|
||||
safe_closehandle(hOutputRead);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue