Update ShellExecute return status

This commit is contained in:
dmex
2024-04-05 06:24:33 +11:00
parent d7afafbfd5
commit 4fc3979b75
15 changed files with 173 additions and 151 deletions
+29 -27
View File
@@ -54,17 +54,17 @@ static PH_PHSVC_MODE PhSvcCurrentMode;
static PH_QUEUED_LOCK PhSvcStartLock = PH_QUEUED_LOCK_INIT;
HRESULT CALLBACK PhpElevateActionCallbackProc(
_In_ HWND hwnd,
_In_ UINT uNotification,
_In_ HWND WindowHandle,
_In_ UINT Notification,
_In_ WPARAM wParam,
_In_ LPARAM lParam,
_In_ LONG_PTR dwRefData
_In_ LONG_PTR Context
)
{
switch (uNotification)
switch (Notification)
{
case TDN_CREATED:
SendMessage(hwnd, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, IDYES, TRUE);
SendMessage(WindowHandle, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, IDYES, TRUE);
break;
}
@@ -124,7 +124,7 @@ BOOLEAN PhpShowElevatePrompt(
/**
* Shows an error, prompts for elevation, and executes a command.
*
* \param hWnd The window to display user interface components on.
* \param WindowHandle The window to display user interface components on.
* \param Message A message describing the operation that failed.
* \param Status A NTSTATUS value.
* \param Command The arguments to pass to the new instance of
@@ -137,7 +137,7 @@ BOOLEAN PhpShowElevatePrompt(
*/
_Success_(return)
BOOLEAN PhpShowErrorAndElevateAction(
_In_ HWND hWnd,
_In_ HWND WindowHandle,
_In_ PWSTR Message,
_In_ NTSTATUS Status,
_In_ PWSTR Command,
@@ -165,7 +165,7 @@ BOOLEAN PhpShowErrorAndElevateAction(
if (elevationLevel == PromptElevateAction)
{
if (!PhpShowElevatePrompt(hWnd, Message, &button))
if (!PhpShowElevatePrompt(WindowHandle, Message, NULL, &button))
return FALSE;
}
@@ -175,15 +175,17 @@ BOOLEAN PhpShowErrorAndElevateAction(
LARGE_INTEGER timeout;
PROCESS_BASIC_INFORMATION basicInfo;
if (PhShellProcessHacker(
hWnd,
status = PhShellProcessHacker(
WindowHandle,
Command,
SW_SHOW,
PH_SHELL_EXECUTE_ADMIN,
PH_SHELL_APP_PROPAGATE_PARAMETERS,
0,
&processHandle
))
);
if (NT_SUCCESS(status))
{
timeout.QuadPart = -(LONGLONG)UInt32x32To64(10, PH_TIMEOUT_SEC);
status = NtWaitForSingleObject(processHandle, FALSE, &timeout);
@@ -203,7 +205,7 @@ BOOLEAN PhpShowErrorAndElevateAction(
if (Success)
*Success = NT_SUCCESS(status);
if (!NT_SUCCESS(status))
PhShowStatus(hWnd, Message, status, 0);
PhShowStatus(WindowHandle, Message, status, 0);
return TRUE;
}
@@ -274,17 +276,17 @@ BOOLEAN PhpShowErrorAndConnectToPhSvc(
/**
* Connects to phsvc.
*
* \param hWnd The window to display user interface components on.
* \param WindowHandle The window to display user interface components on.
* \param ConnectOnly TRUE to only try to connect to phsvc, otherwise
* FALSE to try to elevate and start phsvc if the initial connection
* attempt failed.
*/
BOOLEAN PhUiConnectToPhSvc(
_In_opt_ HWND hWnd,
_In_opt_ HWND WindowHandle,
_In_ BOOLEAN ConnectOnly
)
{
return PhUiConnectToPhSvcEx(hWnd, ElevatedPhSvcMode, ConnectOnly);
return PhUiConnectToPhSvcEx(WindowHandle, ElevatedPhSvcMode, ConnectOnly);
}
VOID PhpGetPhSvcPortName(
@@ -310,22 +312,22 @@ VOID PhpGetPhSvcPortName(
}
BOOLEAN PhpStartPhSvcProcess(
_In_opt_ HWND hWnd,
_In_opt_ HWND WindowHandle,
_In_ PH_PHSVC_MODE Mode
)
{
switch (Mode)
{
case ElevatedPhSvcMode:
if (PhShellProcessHacker(
hWnd,
if (NT_SUCCESS(PhShellProcessHacker(
WindowHandle,
L"-phsvc",
SW_HIDE,
PH_SHELL_EXECUTE_ADMIN,
0,
0,
NULL
))
)))
{
return TRUE;
}
@@ -370,8 +372,8 @@ BOOLEAN PhpStartPhSvcProcess(
if (PhDoesFileExistWin32(PhGetString(fileName)))
{
if (PhShellProcessHackerEx(
hWnd,
if (NT_SUCCESS(PhShellProcessHackerEx(
WindowHandle,
PhGetString(fileName),
L"-phsvc",
SW_HIDE,
@@ -379,7 +381,7 @@ BOOLEAN PhpStartPhSvcProcess(
0,
0,
NULL
))
)))
{
PhDereferenceObject(fileName);
PhDereferenceObject(applicationFileName);
@@ -403,14 +405,14 @@ BOOLEAN PhpStartPhSvcProcess(
/**
* Connects to phsvc.
*
* \param hWnd The window to display user interface components on.
* \param WindowHandle The window to display user interface components on.
* \param Mode The type of phsvc instance to connect to.
* \param ConnectOnly TRUE to only try to connect to phsvc, otherwise
* FALSE to try to elevate and start phsvc if the initial connection
* attempt failed.
*/
BOOLEAN PhUiConnectToPhSvcEx(
_In_opt_ HWND hWnd,
_In_opt_ HWND WindowHandle,
_In_ PH_PHSVC_MODE Mode,
_In_ BOOLEAN ConnectOnly
)
@@ -453,12 +455,12 @@ BOOLEAN PhUiConnectToPhSvcEx(
{
// Prompt for elevation, and then try to connect to the server.
if (PhpStartPhSvcProcess(hWnd, Mode))
if (PhpStartPhSvcProcess(WindowHandle, Mode))
started = TRUE;
if (started)
{
ULONG attempts = 50;
ULONG attempts = 10;
// Try to connect several times because the server may take
// a while to initialize.
@@ -469,7 +471,7 @@ BOOLEAN PhUiConnectToPhSvcEx(
if (NT_SUCCESS(status))
break;
PhDelayExecution(100);
PhDelayExecution(1000);
} while (--attempts != 0);
+31 -9
View File
@@ -1202,7 +1202,7 @@ VOID PhWritePhTextHeader(
PhDereferenceObject(timeString);
}
BOOLEAN PhShellProcessHacker(
NTSTATUS PhShellProcessHacker(
_In_opt_ HWND WindowHandle,
_In_opt_ PWSTR Parameters,
_In_ ULONG ShowWindowType,
@@ -1241,7 +1241,7 @@ VOID PhpAppendCommandLineArgument(
PhAppendCharStringBuilder(StringBuilder, L'\"');
}
BOOLEAN PhShellProcessHackerEx(
NTSTATUS PhShellProcessHackerEx(
_In_opt_ HWND WindowHandle,
_In_opt_ PWSTR FileName,
_In_opt_ PWSTR Parameters,
@@ -1252,7 +1252,7 @@ BOOLEAN PhShellProcessHackerEx(
_Out_opt_ PHANDLE ProcessHandle
)
{
BOOLEAN result;
NTSTATUS status;
PPH_STRING applicationFileName;
PH_STRING_BUILDER sb;
PWSTR parameters;
@@ -1349,7 +1349,7 @@ BOOLEAN PhShellProcessHackerEx(
parameters = Parameters;
}
result = PhShellExecuteEx(
status = PhShellExecuteEx(
WindowHandle,
FileName ? FileName : PhGetString(applicationFileName),
parameters,
@@ -1365,7 +1365,7 @@ BOOLEAN PhShellProcessHackerEx(
PhDereferenceObject(applicationFileName);
return result;
return status;
}
BOOLEAN PhCreateProcessIgnoreIfeoDebugger(
@@ -2137,16 +2137,38 @@ VOID PhShellOpenKey(
if (PhGetOwnTokenAttributes().Elevated)
{
if (!PhShellExecuteEx(WindowHandle, regeditFileName->Buffer, NULL, NULL, SW_SHOW, 0, 0, NULL))
status = PhShellExecuteEx(
WindowHandle,
regeditFileName->Buffer,
NULL,
NULL,
SW_SHOW,
0,
0,
NULL
);
if (!NT_SUCCESS(status))
{
PhShowStatus(WindowHandle, L"Unable to execute the program.", 0, GetLastError());
PhShowStatus(WindowHandle, L"Unable to execute the program.", status, 0);
}
}
else
{
if (!PhShellExecuteEx(WindowHandle, regeditFileName->Buffer, NULL, NULL, SW_SHOW, PH_SHELL_EXECUTE_ADMIN, 0, NULL))
status = PhShellExecuteEx(
WindowHandle,
regeditFileName->Buffer,
NULL,
NULL,
SW_SHOW,
PH_SHELL_EXECUTE_ADMIN,
0,
NULL
);
if (!NT_SUCCESS(status))
{
PhShowStatus(WindowHandle, L"Unable to execute the program.", 0, GetLastError());
PhShowStatus(WindowHandle, L"Unable to execute the program.", status, 0);
}
}
+2 -2
View File
@@ -253,7 +253,7 @@ PhWritePhTextHeader(
#define PH_SHELL_APP_PROPAGATE_PARAMETERS_IGNORE_VISIBILITY 0x2
PHAPPAPI
BOOLEAN
NTSTATUS
NTAPI
PhShellProcessHacker(
_In_opt_ HWND WindowHandle,
@@ -266,7 +266,7 @@ PhShellProcessHacker(
);
// end_phapppub
BOOLEAN PhShellProcessHackerEx(
NTSTATUS PhShellProcessHackerEx(
_In_opt_ HWND WindowHandle,
_In_opt_ PWSTR FileName,
_In_opt_ PWSTR Parameters,
+1 -1
View File
@@ -411,7 +411,7 @@ INT_PTR CALLBACK PhOptionsDialogProc(
{
ProcessHacker_PrepareForEarlyShutdown();
PhResetSettings(hwndDlg);
PhResetSettings(PhMainWndHandle);
if (!PhIsNullOrEmptyString(PhSettingsFileName))
PhSaveSettings(&PhSettingsFileName->sr);
+2 -2
View File
@@ -36,7 +36,7 @@ NTSTATUS PhSvcConnectToServer(
return STATUS_ADDRESS_ALREADY_EXISTS;
if (PortSectionSize == 0)
PortSectionSize = UInt32x32To64(2, 1024 * 1024); // 2 MB
PortSectionSize = UInt32x32To64(8, 1024 * 1024); // 8 MB
// Create the port section and connect to the port.
@@ -147,7 +147,7 @@ PVOID PhSvcpAllocateHeap(
if (!PhSvcClPortHeap)
return NULL;
memory = RtlAllocateHeap(PhSvcClPortHeap, 0, Size);
memory = RtlAllocateHeap(PhSvcClPortHeap, HEAP_ZERO_MEMORY, Size);
if (!memory)
return NULL;
+50 -29
View File
@@ -6,16 +6,14 @@
* Authors:
*
* wj32 2010-2015
* dmex 2017-2023
* dmex 2017-2024
*
*/
#include <phapp.h>
#include <phplug.h>
#include <emenu.h>
#include <colmgr.h>
#include <emenu.h>
#include <extmgri.h>
#include <phsvccl.h>
#include <procprv.h>
@@ -571,18 +569,18 @@ NTSTATUS PhLoadPlugin(
{
if (PhPluginsLoadNative)
{
NTSTATUS status;
PPH_STRING fileName;
PVOID baseAddress;
if (fileName = PhResolveDevicePrefix(FileName))
{
baseAddress = LoadLibraryEx(PhGetString(fileName), NULL, 0);
PhDereferenceObject(fileName);
if (baseAddress)
return STATUS_SUCCESS;
if (LoadLibraryEx(PhGetString(fileName), NULL, 0))
status = STATUS_SUCCESS;
else
return PhGetLastWin32ErrorAsNtStatus();
status = PhGetLastWin32ErrorAsNtStatus();
PhDereferenceObject(fileName);
return status;
}
return STATUS_UNSUCCESSFUL;
@@ -730,24 +728,6 @@ PPH_PLUGIN PhRegisterPlugin(
return plugin;
}
/**
* Locates a plugin instance structure.
*
* \param Name The name of the plugin.
*
* \return A plugin instance structure, or NULL if the plugin was not found.
*/
PPH_PLUGIN PhFindPlugin(
_In_ PWSTR Name
)
{
PH_STRINGREF name;
PhInitializeStringRefLongHint(&name, Name);
return PhFindPlugin2(&name);
}
/**
* Locates a plugin instance structure.
*
@@ -771,6 +751,47 @@ PPH_PLUGIN PhFindPlugin2(
return NULL;
}
/**
* Gets a pointer to a plugin's additional information block.
*
* \param Name The name of the plugin.
* \param Version The version of the interface.
*
* \return The plugin's internal interface.
*/
PVOID PhGetPluginInterface(
_In_ PPH_STRINGREF Name,
_In_opt_ ULONG Version
)
{
PPH_PLUGIN plugin;
PVOID interface;
if (plugin = PhFindPlugin2(Name))
{
interface = PhGetPluginInformation(plugin)->Interface;
if (Version)
{
struct
{
ULONG Version;
} *Interface = interface;
if (Interface->Version <= Version)
{
return interface;
}
}
else
{
return interface;
}
}
return NULL;
}
/**
* Gets a pointer to a plugin's additional information block.
*
+5 -19
View File
@@ -1903,7 +1903,7 @@ BOOLEAN PhRunAsExecuteCommandPrompt(
commandFileName = PhGetSystemDirectoryWin32Z(L"\\cmd.exe");
commandDirectory = PhpQueryRunFileParentDirectory(elevated);
if (PhShellExecuteEx(
status = PhShellExecuteEx(
WindowHandle,
PhGetString(commandFileName),
NULL,
@@ -1912,14 +1912,7 @@ BOOLEAN PhRunAsExecuteCommandPrompt(
PH_SHELL_EXECUTE_DEFAULT,
0,
NULL
))
{
status = STATUS_SUCCESS;
}
else
{
status = PhGetLastWin32ErrorAsNtStatus();
}
);
PhClearReference(&commandDirectory);
PhClearReference(&commandFileName);
@@ -1939,7 +1932,7 @@ NTSTATUS PhRunAsShellExecute(
parentDirectory = PhpQueryRunFileParentDirectory(Elevated);
if (PhShellExecuteEx(
status = PhShellExecuteEx(
WindowHandle,
FileName,
Parameters,
@@ -1948,14 +1941,7 @@ NTSTATUS PhRunAsShellExecute(
Elevated ? PH_SHELL_EXECUTE_ADMIN : PH_SHELL_EXECUTE_DEFAULT,
0,
NULL
))
{
status = STATUS_SUCCESS;
}
else
{
status = PhGetLastWin32ErrorAsNtStatus();
}
);
PhClearReference(&parentDirectory);
@@ -2116,7 +2102,7 @@ NTSTATUS PhpRunFileProgram(
FALSE
);
if (WIN32_FROM_NTSTATUS(status) == ERROR_ELEVATION_REQUIRED)
if (status == STATUS_ELEVATION_REQUIRED)
{
status = PhRunAsShellExecute(
Context->WindowHandle,
+1 -2
View File
@@ -1310,8 +1310,7 @@ PhShellExecute(
#define PH_SHELL_EXECUTE_PUMP_MESSAGES 0x2
PHLIBAPI
_Success_(return)
BOOLEAN
NTSTATUS
NTAPI
PhShellExecuteEx(
_In_opt_ HWND WindowHandle,
+15 -13
View File
@@ -5105,8 +5105,7 @@ VOID PhShellExecute(
* after the application is started.
* \param ProcessHandle A variable which receives a handle to the new process.
*/
_Success_(return)
BOOLEAN PhShellExecuteEx(
NTSTATUS PhShellExecuteEx(
_In_opt_ HWND WindowHandle,
_In_ PWSTR FileName,
_In_opt_ PWSTR Parameters,
@@ -5117,33 +5116,36 @@ BOOLEAN PhShellExecuteEx(
_Out_opt_ PHANDLE ProcessHandle
)
{
SHELLEXECUTEINFO info = { sizeof(SHELLEXECUTEINFO) };
SHELLEXECUTEINFO info;
memset(&info, 0, sizeof(SHELLEXECUTEINFO));
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI | SEE_MASK_NOZONECHECKS;
info.hwnd = WindowHandle;
info.lpFile = FileName;
info.lpParameters = Parameters;
info.lpDirectory = Directory;
info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOZONECHECKS;
info.nShow = ShowWindowType;
info.hwnd = WindowHandle;
if (Flags & PH_SHELL_EXECUTE_ADMIN)
if (FlagOn(Flags, PH_SHELL_EXECUTE_ADMIN))
{
info.lpVerb = L"runas";
if (PhShellExecuteWin32(&info))
{
if (Timeout)
{
if (!(Flags & PH_SHELL_EXECUTE_PUMP_MESSAGES))
if (FlagOn(Flags, PH_SHELL_EXECUTE_PUMP_MESSAGES))
{
PhWaitForMultipleObjectsAndPump(NULL, 1, &info.hProcess, Timeout, QS_ALLEVENTS);
}
else
{
if (info.hProcess)
{
PhWaitForSingleObject(info.hProcess, PhTimeoutFromMillisecondsEx(Timeout));
}
}
else
{
PhWaitForMultipleObjectsAndPump(NULL, 1, &info.hProcess, Timeout, QS_ALLEVENTS);
}
}
if (ProcessHandle)
@@ -5151,11 +5153,11 @@ BOOLEAN PhShellExecuteEx(
else if (info.hProcess)
NtClose(info.hProcess);
return TRUE;
return STATUS_SUCCESS;
}
else
{
return FALSE;
return PhGetLastWin32ErrorAsNtStatus();
}
}
+12 -12
View File
@@ -12,13 +12,13 @@
#include "updater.h"
INT_PTR CALLBACK OptionsDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ HWND WindowHandle,
_In_ UINT WindowMessage,
_In_ WPARAM wParam,
_In_ LPARAM lParam
)
{
switch (uMsg)
switch (WindowMessage)
{
case WM_INITDIALOG:
{
@@ -27,7 +27,7 @@ INT_PTR CALLBACK OptionsDlgProc(
ULONG64 lastUpdateTimeTicks;
PPH_STRING lastUpdateTimeString;
Button_SetCheck(GetDlgItem(hwndDlg, IDC_AUTOCHECKBOX), BST_CHECKED);
Button_SetCheck(GetDlgItem(WindowHandle, IDC_AUTOCHECKBOX), BST_CHECKED);
if (lastUpdateTimeString = PhGetStringSetting(SETTING_NAME_LAST_CHECK))
{
@@ -46,7 +46,7 @@ INT_PTR CALLBACK OptionsDlgProc(
PhQuerySystemTime(&currentTime);
timeRelativeString = PH_AUTO(PhFormatTimeSpanRelative(currentTime.QuadPart - lastUpdateTimeTicks));
PhSetDialogItemText(hwndDlg, IDC_TEXT, PhaFormatString(
PhSetDialogItemText(WindowHandle, IDC_TEXT, PhaFormatString(
L"Last update check: %s (%s ago)",
PhGetStringOrEmpty(timeString),
PhGetStringOrEmpty(timeRelativeString)
@@ -60,7 +60,7 @@ INT_PTR CALLBACK OptionsDlgProc(
if (time.QuadPart > 0)
{
timeRelativeString = PH_AUTO(PhFormatTimeSpanRelative(time.QuadPart));
PhSetDialogItemText(hwndDlg, IDC_TEXT2, PhaFormatString(
PhSetDialogItemText(WindowHandle, IDC_TEXT2, PhaFormatString(
L"Next update check: %s (%s)",
PhGetStringOrEmpty(timeString),
PhGetStringOrEmpty(timeRelativeString)
@@ -68,7 +68,7 @@ INT_PTR CALLBACK OptionsDlgProc(
}
else
{
PhSetDialogItemText(hwndDlg, IDC_TEXT2, PhaFormatString(
PhSetDialogItemText(WindowHandle, IDC_TEXT2, PhaFormatString(
L"Next update check: %s",
PhGetStringOrEmpty(timeString)
)->Buffer);
@@ -81,12 +81,12 @@ INT_PTR CALLBACK OptionsDlgProc(
if (PhGetIntegerSetting(SETTING_NAME_UPDATE_MODE))
{
Button_SetCheck(GetDlgItem(hwndDlg, IDC_SHOWSTARTPROMPTCHECK), BST_CHECKED);
Button_SetCheck(GetDlgItem(WindowHandle, IDC_SHOWSTARTPROMPTCHECK), BST_CHECKED);
}
if (PhGetIntegerSetting(SETTING_NAME_AUTO_CHECK_PAGE))
{
Button_SetCheck(GetDlgItem(hwndDlg, IDC_SKIPWELCOMEPAGECHECK), BST_CHECKED);
Button_SetCheck(GetDlgItem(WindowHandle, IDC_SKIPWELCOMEPAGECHECK), BST_CHECKED);
}
}
break;
@@ -116,11 +116,11 @@ INT_PTR CALLBACK OptionsDlgProc(
}
break;
case WM_CTLCOLORBTN:
return HANDLE_WM_CTLCOLORBTN(hwndDlg, wParam, lParam, PhWindowThemeControlColor);
return HANDLE_WM_CTLCOLORBTN(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
case WM_CTLCOLORDLG:
return HANDLE_WM_CTLCOLORDLG(hwndDlg, wParam, lParam, PhWindowThemeControlColor);
return HANDLE_WM_CTLCOLORDLG(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
case WM_CTLCOLORSTATIC:
return HANDLE_WM_CTLCOLORSTATIC(hwndDlg, wParam, lParam, PhWindowThemeControlColor);
return HANDLE_WM_CTLCOLORSTATIC(WindowHandle, wParam, lParam, PhWindowThemeControlColor);
}
return FALSE;
+3 -1
View File
@@ -55,8 +55,10 @@ HRESULT CALLBACK FinalTaskDialogCallbackProc(
}
else if (buttonId == IDYES)
{
if (!UpdateShellExecute(context, hwndDlg))
if (!NT_SUCCESS(UpdateShellExecute(context, hwndDlg)))
{
return S_FALSE;
}
}
}
break;
+13 -25
View File
@@ -5,7 +5,7 @@
*
* Authors:
*
* dmex 2011-2023
* dmex 2011-2024
*
*/
@@ -73,25 +73,26 @@ PPH_UPDATER_CONTEXT CreateUpdateContext(
return context;
}
BOOLEAN UpdateShellExecute(
NTSTATUS UpdateShellExecute(
_In_ PPH_UPDATER_CONTEXT Context,
_In_opt_ HWND WindowHandle
)
{
NTSTATUS status;
PPH_STRING parameters;
// Reset the cache so we don't prompt again after the update.
PhSetStringSetting(SETTING_NAME_UPDATE_DATA, L"");
if (PhIsNullOrEmptyString(Context->SetupFilePath))
return FALSE;
return STATUS_FAIL_CHECK;
parameters = PH_AUTO(PhCreateKsiSettingsBlob());
parameters = PH_AUTO(PhConcatStrings(3, L"-update \"", PhGetStringOrEmpty(parameters), L"\""));
ProcessHacker_PrepareForEarlyShutdown();
if (PhShellExecuteEx(
status = PhShellExecuteEx(
WindowHandle,
PhGetString(Context->SetupFilePath),
PhGetString(parameters),
@@ -100,34 +101,30 @@ BOOLEAN UpdateShellExecute(
Context->DirectoryElevationRequired ? PH_SHELL_EXECUTE_ADMIN : PH_SHELL_EXECUTE_DEFAULT,
0,
NULL
))
);
if (NT_SUCCESS(status))
{
Context->Cleanup = FALSE;
ProcessHacker_Destroy();
return TRUE;
}
else
{
ULONG errorCode = GetLastError();
// Install failed, cancel the shutdown.
ProcessHacker_CancelEarlyShutdown();
// Show error dialog.
if (errorCode != ERROR_CANCELLED) // Ignore UAC decline.
if (status != STATUS_CANCELLED) // Ignore UAC decline.
{
PhShowStatus(WindowHandle, L"Unable to execute the setup.", 0, errorCode);
PhShowStatus(WindowHandle, L"Unable to execute the setup.", status, 0);
if (Context->StartupCheck)
ShowAvailableDialog(Context);
else
ShowCheckForUpdatesDialog(Context);
}
return FALSE;
}
return status;
}
BOOLEAN UpdateCheckDirectoryElevationRequired(
@@ -280,16 +277,7 @@ PPH_STRING UpdateVersionString(
}
else
{
PPH_STRING currentVersion = NULL;
PPH_STRING stringFormat;
if (stringFormat = PhFormatString(L"%lu.%lu.%lu.%lu", majorVersion, minorVersion, buildVersion, revisionVersion))
{
currentVersion = PhConcatStringRef2(&versionHeader, &stringFormat->sr);
PhDereferenceObject(currentVersion);
}
return currentVersion;
return PhFormat(format, RTL_NUMBER_OF(format), 0);
}
}
+4 -4
View File
@@ -5,7 +5,7 @@
*
* Authors:
*
* dmex 2011-2023
* dmex 2011-2024
*
*/
@@ -189,7 +189,7 @@ VOID ShowUpdateFailedDialog(
// updater.c
BOOLEAN UpdateShellExecute(
NTSTATUS UpdateShellExecute(
_In_ PPH_UPDATER_CONTEXT Context,
_In_opt_ HWND WindowHandle
);
@@ -217,8 +217,8 @@ ULONG64 ParseVersionString(
// options.c
INT_PTR CALLBACK OptionsDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ HWND WindowHandle,
_In_ UINT WindowMessage,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
+2 -2
View File
@@ -179,7 +179,7 @@ INT WINAPI wWinMain(
AllowSetForegroundWindow(ASFW_ANY);
if (PhShellExecuteEx(
if (NT_SUCCESS(PhShellExecuteEx(
NULL,
PhGetString(applicationFileName),
PvFileName->Buffer,
@@ -188,7 +188,7 @@ INT WINAPI wWinMain(
PH_SHELL_EXECUTE_DEFAULT,
0,
NULL
))
)))
{
PhExitApplication(STATUS_SUCCESS);
}
+3 -3
View File
@@ -95,7 +95,7 @@ BOOLEAN PvShellExecuteRestart(
)
{
static PH_STRINGREF seperator = PH_STRINGREF_INIT(L"\"");
BOOLEAN result;
NTSTATUS status;
PPH_STRING filename;
PPH_STRING parameters;
@@ -108,7 +108,7 @@ BOOLEAN PvShellExecuteRestart(
&seperator
);
result = PhShellExecuteEx(
status = PhShellExecuteEx(
WindowHandle,
PhGetString(filename),
PhGetString(parameters),
@@ -122,7 +122,7 @@ BOOLEAN PvShellExecuteRestart(
PhDereferenceObject(parameters);
PhDereferenceObject(filename);
return result;
return NT_SUCCESS(status);
}
VOID PvLoadGeneralPage(