[SERVMAN] UI update and Error Management (#2653)

Purpose
=======
- Current design does not warn user nor logs DEBUG traces when Service Start/Stop command fails or reach timeout.
- Current Service Start/Stop progress window are WS_EX_TOOLWINDOW which reduce lisibility, is a ReactOS specificity without good reason.

Proposed changes
================
- DPRINT1 traces added on failure cases.
- Error Message box presented to user upon failure with explicit root cause identification.
- Change Dialog definition to standard window.
This commit is contained in:
Kyle Katarn 2020-05-01 19:01:59 +02:00 committed by GitHub
parent 140ec9d037
commit b3947d5283
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 138 additions and 67 deletions

View file

@ -26,6 +26,25 @@ typedef struct _PROGRESS_DATA
} PROGRESS_DATA, *PPROGRESS_DATA;
VOID ShowError(DWORD dwLastError)
{
LPWSTR lpMsg;
if (!FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwLastError,
LANG_USER_DEFAULT,
(LPWSTR)&lpMsg,
0, NULL))
{
return;
}
MessageBoxW(NULL, lpMsg, NULL, MB_OK | MB_ICONERROR);
LocalFree(lpMsg);
}
static VOID
ResetProgressDialog(HWND hDlg,
@ -67,6 +86,7 @@ ResetProgressDialog(HWND hDlg,
unsigned int __stdcall ActionThread(void* Param)
{
PPROGRESS_DATA ProgressData = (PPROGRESS_DATA)Param;
DWORD dwResult;
if (ProgressData->Action == ACTION_START)
{
@ -76,13 +96,18 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_START);
/* Start the service */
if (DoStartService(ProgressData->ServiceName,
ProgressData->hProgress,
ProgressData->Param))
dwResult = DoStartService(ProgressData->ServiceName,
ProgressData->hProgress,
ProgressData->Param);
if (dwResult == ERROR_SUCCESS)
{
/* We're done, slide the progress bar up to the top */
CompleteProgressBar(ProgressData->hProgress);
}
else
{
ShowError(dwResult);
}
}
else if (ProgressData->Action == ACTION_STOP || ProgressData->Action == ACTION_RESTART)
{
@ -108,11 +133,16 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_STOP);
/* Stop the requested service */
if (DoStopService(ProgressData->ServiceName,
ProgressData->hProgress))
dwResult = DoStopService(ProgressData->ServiceName,
ProgressData->hProgress);
if (dwResult == ERROR_SUCCESS)
{
CompleteProgressBar(ProgressData->hProgress);
}
else
{
ShowError(dwResult);
}
/* Move onto the next string */
while (*lpStr != L'\0')
@ -124,11 +154,16 @@ unsigned int __stdcall ActionThread(void* Param)
ProgressData->ServiceName,
IDS_PROGRESS_INFO_STOP);
if (DoStopService(ProgressData->ServiceName,
ProgressData->hProgress))
dwResult = DoStopService(ProgressData->ServiceName,
ProgressData->hProgress);
if (dwResult == ERROR_SUCCESS)
{
CompleteProgressBar(ProgressData->hProgress);
}
else
{
ShowError(dwResult);
}
/* If this was a restart, we'll need to start the service back up */
@ -140,13 +175,18 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_START);
/* Start the service */
if (DoStartService(ProgressData->ServiceName,
ProgressData->hProgress,
NULL))
dwResult = DoStartService(ProgressData->ServiceName,
ProgressData->hProgress,
NULL);
if (dwResult == ERROR_SUCCESS)
{
/* We're done, slide the progress bar up to the top */
CompleteProgressBar(ProgressData->hProgress);
}
else
{
ShowError(dwResult);
}
}
}
else if (ProgressData->Action == ACTION_PAUSE)
@ -157,13 +197,18 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_PAUSE);
/* Pause the service */
if (DoControlService(ProgressData->ServiceName,
ProgressData->hProgress,
SERVICE_CONTROL_PAUSE))
dwResult = DoControlService(ProgressData->ServiceName,
ProgressData->hProgress,
SERVICE_CONTROL_PAUSE);
if (dwResult == ERROR_SUCCESS)
{
/* We're done, slide the progress bar up to the top */
CompleteProgressBar(ProgressData->hProgress);
}
else
{
ShowError(dwResult);
}
}
else if (ProgressData->Action == ACTION_RESUME)
{
@ -173,13 +218,18 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_RESUME);
/* resume the service */
if (DoControlService(ProgressData->ServiceName,
ProgressData->hProgress,
SERVICE_CONTROL_CONTINUE))
dwResult = DoControlService(ProgressData->ServiceName,
ProgressData->hProgress,
SERVICE_CONTROL_CONTINUE);
if (dwResult == ERROR_SUCCESS)
{
/* We're done, slide the progress bar up to the top */
CompleteProgressBar(ProgressData->hProgress);
}
else
{
ShowError(dwResult);
}
}