Skip to content

Commit b3947d5

Browse files
author
Kyle Katarn
authored
[SERVMAN] UI update and Error Management (reactos#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.
1 parent 140ec9d commit b3947d5

29 files changed

+138
-67
lines changed

base/applications/mscutils/servman/control.c

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
#include "precomp.h"
1111

12+
#define NDEBUG
13+
#include <debug.h>
14+
1215
#define MAX_WAIT_TIME 30000
1316

14-
BOOL
17+
DWORD
1518
DoControlService(LPWSTR ServiceName,
1619
HWND hProgress,
1720
DWORD Control)
@@ -27,6 +30,7 @@ DoControlService(LPWSTR ServiceName,
2730
DWORD MaxWait;
2831
DWORD ReqState, i;
2932
BOOL Result;
33+
DWORD dwResult = ERROR_SUCCESS;
3034

3135
/* Set the state we're interested in */
3236
switch (Control)
@@ -39,21 +43,23 @@ DoControlService(LPWSTR ServiceName,
3943
break;
4044
default:
4145
/* Unhandled control code */
42-
return FALSE;
46+
DPRINT1("Unknown control command: 0x%X\n", Control);
47+
return ERROR_INVALID_SERVICE_CONTROL;
4348
}
4449

4550
hSCManager = OpenSCManagerW(NULL,
4651
NULL,
4752
SC_MANAGER_CONNECT);
48-
if (!hSCManager) return FALSE;
53+
if (!hSCManager) return GetLastError();
4954

5055
hService = OpenServiceW(hSCManager,
5156
ServiceName,
5257
SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_QUERY_STATUS);
5358
if (!hService)
5459
{
60+
dwResult = GetLastError();
5561
CloseServiceHandle(hSCManager);
56-
return FALSE;
62+
return dwResult;
5763
}
5864

5965
/* Send the control message to the service */
@@ -109,6 +115,8 @@ DoControlService(LPWSTR ServiceName,
109115
&BytesNeeded))
110116
{
111117
/* Something went wrong... */
118+
dwResult = GetLastError();
119+
DPRINT1("QueryServiceStatusEx failed: %d\n", dwResult);
112120
break;
113121
}
114122

@@ -123,23 +131,33 @@ DoControlService(LPWSTR ServiceName,
123131
else
124132
{
125133
/* It's not, make sure we haven't exceeded our wait time */
126-
if(GetTickCount() >= StartTickCount + MaxWait)
134+
if (GetTickCount() >= StartTickCount + MaxWait)
127135
{
128136
/* We have, give up */
137+
DPRINT1("Timeout\n");
138+
dwResult = ERROR_SERVICE_REQUEST_TIMEOUT;
129139
break;
130140
}
131141
}
132142
}
133143
}
144+
else
145+
{
146+
dwResult = GetLastError();
147+
}
134148

135149
if (ServiceStatus.dwCurrentState == ReqState)
136150
{
137-
Result = TRUE;
151+
dwResult = ERROR_SUCCESS;
138152
}
139153
}
154+
else
155+
{
156+
dwResult = GetLastError();
157+
}
140158

141159
CloseServiceHandle(hService);
142160
CloseServiceHandle(hSCManager);
143161

144-
return Result;
162+
return dwResult;
145163
}

base/applications/mscutils/servman/lang/bg-BG.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
232232
CAPTION "Управление на услугите"
233233
FONT 8, "MS Shell Dlg", 0, 0
234234
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
235-
EXSTYLE WS_EX_TOOLWINDOW
236235
BEGIN
237236
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
238237
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

base/applications/mscutils/servman/lang/cs-CZ.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
232232
CAPTION "Ovldání služeb"
233233
FONT 8, "MS Shell Dlg", 0, 0
234234
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
235-
EXSTYLE WS_EX_TOOLWINDOW
236235
BEGIN
237236
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
238237
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

base/applications/mscutils/servman/lang/de-DE.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
232232
CAPTION "Dienststeuerung"
233233
FONT 8, "MS Shell Dlg", 0, 0
234234
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
235-
EXSTYLE WS_EX_TOOLWINDOW
236235
BEGIN
237236
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
238237
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

base/applications/mscutils/servman/lang/el-GR.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
232232
CAPTION "Service Control"
233233
FONT 8, "MS Shell Dlg", 0, 0
234234
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
235-
EXSTYLE WS_EX_TOOLWINDOW
236235
BEGIN
237236
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
238237
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

base/applications/mscutils/servman/lang/en-US.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
232232
CAPTION "Service Control"
233233
FONT 8, "MS Shell Dlg", 0, 0
234234
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
235-
EXSTYLE WS_EX_TOOLWINDOW
236235
BEGIN
237236
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
238237
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

base/applications/mscutils/servman/lang/es-ES.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
235235
CAPTION "Control de servicios"
236236
FONT 8, "MS Shell Dlg", 0, 0
237237
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
238-
EXSTYLE WS_EX_TOOLWINDOW
239238
BEGIN
240239
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
241240
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

base/applications/mscutils/servman/lang/fr-FR.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
232232
CAPTION "Contrôle du Service"
233233
FONT 8, "MS Shell Dlg", 0, 0
234234
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
235-
EXSTYLE WS_EX_TOOLWINDOW
236235
BEGIN
237236
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
238237
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

base/applications/mscutils/servman/lang/he-IL.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
232232
CAPTION "בקרת שירות"
233233
FONT 8, "MS Shell Dlg", 0, 0
234234
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
235-
EXSTYLE WS_EX_TOOLWINDOW
236235
BEGIN
237236
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
238237
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

base/applications/mscutils/servman/lang/id-ID.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
232232
CAPTION "Kontrol Layanan"
233233
FONT 8, "MS Shell Dlg", 0, 0
234234
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
235-
EXSTYLE WS_EX_TOOLWINDOW
236235
BEGIN
237236
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32", 0x50000000, 8, 46, 238, 13
238237
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11

0 commit comments

Comments
 (0)