services: Fix handling of user defined service controls. (v2)
Sebastian Lackner
sebastian at fds-team.de
Wed Aug 10 03:42:35 CDT 2016
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
programs/services/rpc.c | 3 +++
programs/services/tests/service.c | 7 +++++++
2 files changed, 10 insertions(+)
Changes in v2:
* Do not use SERVICE_USER_DEFINED_CONTROL as accepted control, it does not seem
to be necessary (and the example I was taking a look at was a bit misleading).
diff --git a/programs/services/rpc.c b/programs/services/rpc.c
index 3ebf378..f0e9f6b 100644
--- a/programs/services/rpc.c
+++ b/programs/services/rpc.c
@@ -941,6 +941,9 @@ static BOOL service_accepts_control(const struct service_entry *service, DWORD d
{
DWORD a = service->status.dwControlsAccepted;
+ if (dwControl >= 128 && dwControl <= 255)
+ return TRUE;
+
switch (dwControl)
{
case SERVICE_CONTROL_INTERROGATE:
diff --git a/programs/services/tests/service.c b/programs/services/tests/service.c
index 85b8e86..fea6363 100644
--- a/programs/services/tests/service.c
+++ b/programs/services/tests/service.c
@@ -83,6 +83,9 @@ static DWORD WINAPI service_handler(DWORD ctrl, DWORD event_type, void *event_da
SetServiceStatus(service_handle, &status);
SetEvent(service_stop_event);
return NO_ERROR;
+ case 128:
+ service_event("CUSTOM");
+ return 0xdeadbeef;
default:
status.dwCurrentState = SERVICE_RUNNING;
SetServiceStatus( service_handle, &status );
@@ -346,6 +349,10 @@ static void test_service(void)
ok(status.dwCheckPoint == 0, "status.dwCheckPoint = %d\n", status.dwCheckPoint);
todo_wine ok(status.dwWaitHint == 0, "status.dwWaitHint = %d\n", status.dwWaitHint);
+ res = ControlService(service_handle, 128, &status);
+ ok(res, "ControlService failed: %u\n", GetLastError());
+ expect_event("CUSTOM");
+
res = ControlService(service_handle, SERVICE_CONTROL_STOP, &status);
ok(res, "ControlService failed: %u\n", GetLastError());
expect_event("STOP");
--
2.9.0
More information about the wine-patches
mailing list