Skip to content

Commit

Permalink
Enable service progress dialog #395
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex committed Jun 30, 2024
1 parent 7ddd7ba commit 653375f
Showing 1 changed file with 20 additions and 69 deletions.
89 changes: 20 additions & 69 deletions SystemInformer/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3600,8 +3600,14 @@ HRESULT CALLBACK PhpUiServiceProgressDialogCallbackProc(
break;
case TDN_BUTTON_CLICKED:
{
return S_FALSE;
ULONG buttonId = (ULONG)wParam;

if (buttonId != IDCANCEL)
{
return S_FALSE;
}
}
break;
}

return S_OK;
Expand Down Expand Up @@ -3726,7 +3732,7 @@ static LRESULT CALLBACK PhpUiServiceProgressDialogWndProc(
context = PhGetWindowContext(WindowHandle, MAXCHAR);

if (!context)
return 0;
goto DefaultWndProc;

oldWndProc = context->OldWndProc;

Expand All @@ -3743,21 +3749,22 @@ static LRESULT CALLBACK PhpUiServiceProgressDialogWndProc(
PPH_STRING message;
PPH_STRING content;

message = context->StatusMessage;
content = context->StatusContent;
context->StatusMessage = NULL;
context->StatusContent = NULL;
message = InterlockedExchangePointer(&context->StatusMessage, NULL);
content = InterlockedExchangePointer(&context->StatusContent, NULL);

PhUiNavigateServiceErrorDialogPage(
context,
message,
content
);

PhClearReference(&message);
PhClearReference(&content);
}
goto DefaultWndProc;
case WM_PHSVC_EXIT:
{
SendMessage(WindowHandle, TDM_CLICK_BUTTON, IDCANCEL, 0);
CallWindowProc(oldWndProc, WindowHandle, TDM_CLICK_BUTTON, IDCANCEL, 0);
}
goto DefaultWndProc;
}
Expand Down Expand Up @@ -3788,9 +3795,9 @@ HRESULT CALLBACK PhpUiServiceInitializeDialogCallbackProc(

PhCenterWindow(WindowHandle, context->ParentWindowHandle);

context->OldWndProc = (WNDPROC)GetWindowLongPtr(WindowHandle, GWLP_WNDPROC);
context->OldWndProc = PhGetWindowProcedure(WindowHandle);
PhSetWindowContext(WindowHandle, MAXCHAR, context);
SetWindowLongPtr(WindowHandle, GWLP_WNDPROC, (LONG_PTR)PhpUiServiceProgressDialogWndProc);
PhSetWindowProcedure(WindowHandle, PhpUiServiceProgressDialogWndProc);

PhShowServiceProgressDialogConfirmMessage(context);
}
Expand Down Expand Up @@ -3929,7 +3936,10 @@ static BOOLEAN PhpShowContinueMessageServices(
return cont;
}

static NTSTATUS PhpCHeckServiceStatus(_In_ SC_HANDLE ServiceHandle, ULONG CurrentState, ULONG WaitForState)
static NTSTATUS PhpCheckServiceStatus(
_In_ SC_HANDLE ServiceHandle,
_In_ ULONG CurrentState,
_In_ ULONG WaitForState)
{
NTSTATUS status;
SERVICE_STATUS_PROCESS serviceStatus;
Expand Down Expand Up @@ -4029,7 +4039,6 @@ BOOLEAN PhUiStartServices(
BOOLEAN cancelled = FALSE;
ULONG i;

#ifdef PH_SERVICE_PROGRESS_DIALOG
if (PhGetIntegerSetting(L"EnableServiceProgressDialog"))
{
PhShowServiceProgressDialog(
Expand All @@ -4044,7 +4053,6 @@ BOOLEAN PhUiStartServices(
);
return FALSE;
}
#endif

if (!PhpShowContinueMessageServices(
WindowHandle,
Expand Down Expand Up @@ -4227,7 +4235,6 @@ BOOLEAN PhUiContinueServices(
BOOLEAN cancelled = FALSE;
ULONG i;

#ifdef PH_SERVICE_PROGRESS_DIALOG
if (PhGetIntegerSetting(L"EnableServiceProgressDialog"))
{
PhShowServiceProgressDialog(
Expand All @@ -4242,7 +4249,6 @@ BOOLEAN PhUiContinueServices(
);
return FALSE;
}
#endif

if (!PhpShowContinueMessageServices(
WindowHandle,
Expand Down Expand Up @@ -4352,23 +4358,6 @@ BOOLEAN PhUiContinueService(
NTSTATUS status;
BOOLEAN success = FALSE;

#ifdef PH_SERVICE_PROGRESS_DIALOG
if (PhGetIntegerSetting(L"EnableServiceProgressDialog"))
{
PhShowServiceProgressDialog(
WindowHandle,
L"continue",
L"Continuing a service might prevent the system from functioning properly.",
FALSE,
&Service,
1,
PhUiServiceContinueCallback,
PhSvcControlServiceContinue
);
return FALSE;
}
#endif

status = PhOpenService(&serviceHandle, SERVICE_PAUSE_CONTINUE, PhGetString(Service->Name));

if (NT_SUCCESS(status))
Expand Down Expand Up @@ -4444,7 +4433,6 @@ BOOLEAN PhUiPauseServices(
BOOLEAN cancelled = FALSE;
ULONG i;

#ifdef PH_SERVICE_PROGRESS_DIALOG
if (PhGetIntegerSetting(L"EnableServiceProgressDialog"))
{
PhShowServiceProgressDialog(
Expand All @@ -4459,7 +4447,6 @@ BOOLEAN PhUiPauseServices(
);
return FALSE;
}
#endif

if (!PhpShowContinueMessageServices(
WindowHandle,
Expand Down Expand Up @@ -4569,23 +4556,6 @@ BOOLEAN PhUiPauseService(
NTSTATUS status;
BOOLEAN success = FALSE;

#ifdef PH_SERVICE_PROGRESS_DIALOG
if (PhGetIntegerSetting(L"EnableServiceProgressDialog"))
{
PhShowServiceProgressDialog(
WindowHandle,
L"pause",
L"Pausing a service might prevent the system from functioning properly.",
FALSE,
&Service,
1,
PhUiServicePauseCallback,
PhSvcControlServicePause
);
return FALSE;
}
#endif

status = PhOpenService(&serviceHandle, SERVICE_PAUSE_CONTINUE, PhGetString(Service->Name));

if (NT_SUCCESS(status))
Expand Down Expand Up @@ -4661,7 +4631,6 @@ BOOLEAN PhUiStopServices(
BOOLEAN cancelled = FALSE;
ULONG i;

#ifdef PH_SERVICE_PROGRESS_DIALOG
if (PhGetIntegerSetting(L"EnableServiceProgressDialog"))
{
PhShowServiceProgressDialog(
Expand All @@ -4676,7 +4645,6 @@ BOOLEAN PhUiStopServices(
);
return FALSE;
}
#endif

if (!PhpShowContinueMessageServices(
WindowHandle,
Expand Down Expand Up @@ -4786,23 +4754,6 @@ BOOLEAN PhUiStopService(
NTSTATUS status;
BOOLEAN success = FALSE;

#ifdef PH_SERVICE_PROGRESS_DIALOG
if (PhGetIntegerSetting(L"EnableServiceProgressDialog"))
{
PhShowServiceProgressDialog(
WindowHandle,
L"stop",
L"Stopping a service might prevent the system from functioning properly.",
FALSE,
&Service,
1,
PhUiServiceStopCallback,
PhSvcControlServiceStop
);
return FALSE;
}
#endif

status = PhOpenService(&serviceHandle, SERVICE_STOP, PhGetString(Service->Name));

if (NT_SUCCESS(status))
Expand Down

0 comments on commit 653375f

Please sign in to comment.