diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c index d2ef54d2f87..d594416ebf3 100644 --- a/dlls/advapi32/tests/service.c +++ b/dlls/advapi32/tests/service.c @@ -2095,7 +2095,7 @@ static DWORD try_start_stop(SC_HANDLE svc_handle, const char* name, DWORD is_nt4 ret = ControlService(svc_handle, SERVICE_CONTROL_STOP, &status); le2 = GetLastError(); ok(!ret, "%s: ControlService() should have failed\n", name); - todo_wine ok(le2 == ERROR_SERVICE_NOT_ACTIVE, "%s: %d != ERROR_SERVICE_NOT_ACTIVE\n", name, le2); + ok(le2 == ERROR_SERVICE_NOT_ACTIVE, "%s: %d != ERROR_SERVICE_NOT_ACTIVE\n", name, le2); ok(status.dwCurrentState == SERVICE_STOPPED || broken(is_nt4), /* NT4 returns a random value */ "%s: should be stopped state=%x\n", name, status.dwCurrentState); diff --git a/programs/services/rpc.c b/programs/services/rpc.c index 573b748fe3b..2d853c04800 100644 --- a/programs/services/rpc.c +++ b/programs/services/rpc.c @@ -1023,12 +1023,6 @@ DWORD __cdecl svcctl_ControlService( lpServiceStatus->dwWaitHint = service->service_entry->status.dwWaitHint; } - if (!service_accepts_control(service->service_entry, dwControl)) - { - service_unlock(service->service_entry); - return ERROR_INVALID_SERVICE_CONTROL; - } - switch (service->service_entry->status.dwCurrentState) { case SERVICE_STOPPED: @@ -1043,6 +1037,12 @@ DWORD __cdecl svcctl_ControlService( return ERROR_SERVICE_CANNOT_ACCEPT_CTRL; } + if (!service_accepts_control(service->service_entry, dwControl)) + { + service_unlock(service->service_entry); + return ERROR_INVALID_SERVICE_CONTROL; + } + /* prevent races by caching these variables and clearing them on * stop here instead of outside the services lock */ control_mutex = service->service_entry->control_mutex;