[SC][SERVICES] Support SERVICE_CONTROL_PARAMCHANGE and SERVICE_CONTROL_NETBIND* control codes

This commit is contained in:
Eric Kohl 2018-02-25 11:07:14 +01:00
parent 1986049a38
commit 9f0c54fcd3
2 changed files with 29 additions and 7 deletions

View File

@ -44,10 +44,12 @@ Control(DWORD Control,
break;
case SERVICE_CONTROL_PAUSE:
dwDesiredAccess = SERVICE_PAUSE_CONTINUE;
break;
case SERVICE_CONTROL_CONTINUE:
case SERVICE_CONTROL_PARAMCHANGE:
case SERVICE_CONTROL_NETBINDADD:
case SERVICE_CONTROL_NETBINDREMOVE:
case SERVICE_CONTROL_NETBINDENABLE:
case SERVICE_CONTROL_NETBINDDISABLE:
dwDesiredAccess = SERVICE_PAUSE_CONTINUE;
break;
@ -55,10 +57,12 @@ Control(DWORD Control,
dwDesiredAccess = SERVICE_INTERROGATE;
break;
case SERVICE_CONTROL_SHUTDOWN:
dwDesiredAccess = 0;
default:
if (Control >= 128 && Control <= 255)
dwDesiredAccess = SERVICE_USER_DEFINED_CONTROL;
else
dwDesiredAccess = 0;
break;
}
hSCManager = OpenSCManager(NULL,

View File

@ -1112,6 +1112,11 @@ RControlService(
case SERVICE_CONTROL_PAUSE:
case SERVICE_CONTROL_CONTINUE:
case SERVICE_CONTROL_PARAMCHANGE:
case SERVICE_CONTROL_NETBINDADD:
case SERVICE_CONTROL_NETBINDREMOVE:
case SERVICE_CONTROL_NETBINDENABLE:
case SERVICE_CONTROL_NETBINDDISABLE:
DesiredAccess = SERVICE_PAUSE_CONTINUE;
break;
@ -1226,6 +1231,19 @@ RControlService(
if ((dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) == 0)
return ERROR_INVALID_SERVICE_CONTROL;
break;
case SERVICE_CONTROL_PARAMCHANGE:
if ((dwControlsAccepted & SERVICE_ACCEPT_PARAMCHANGE) == 0)
return ERROR_INVALID_SERVICE_CONTROL;
break;
case SERVICE_CONTROL_NETBINDADD:
case SERVICE_CONTROL_NETBINDREMOVE:
case SERVICE_CONTROL_NETBINDENABLE:
case SERVICE_CONTROL_NETBINDDISABLE:
if ((dwControlsAccepted & SERVICE_ACCEPT_NETBINDCHANGE) == 0)
return ERROR_INVALID_SERVICE_CONTROL;
break;
}
/* Send control code to the service */
@ -1728,7 +1746,7 @@ RSetServiceStatus(
/* Restore the previous service type */
lpService->Status.dwServiceType = dwPreviousType;
/* Handle a stopped service */
/* Dereference a stopped service */
if ((lpServiceStatus->dwServiceType & SERVICE_WIN32) &&
(lpServiceStatus->dwCurrentState == SERVICE_STOPPED))
{