diff --git a/reactos/dll/win32/advapi32/service/scm.c b/reactos/dll/win32/advapi32/service/scm.c index 4976381d6a0..f0802e3f170 100644 --- a/reactos/dll/win32/advapi32/service/scm.c +++ b/reactos/dll/win32/advapi32/service/scm.c @@ -602,6 +602,12 @@ CreateServiceA(SC_HANDLE hSCManager, int len; LPSTR lpStr; + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + if (lpServiceName) { len = MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, NULL, 0); @@ -1299,6 +1305,12 @@ GetServiceDisplayNameA(SC_HANDLE hSCManager, TRACE("%p %s %p %p\n", hSCManager, debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer); + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (!lpDisplayName) *lpcchBuffer = 0; @@ -1386,6 +1398,19 @@ GetServiceKeyNameA(SC_HANDLE hSCManager, TRACE("GetServiceKeyNameA() called\n"); + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (!lpDisplayName) + { + SetLastError(ERROR_INVALID_ADDRESS); + *lpcchBuffer = 1; + return FALSE; + } + if (!lpServiceName) *lpcchBuffer = 0; @@ -1639,6 +1664,12 @@ OpenServiceA(SC_HANDLE hSCManager, TRACE("OpenServiceA(%p, %s, %lx)\n", hSCManager, lpServiceName, dwDesiredAccess); + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + RpcTryExcept { /* Call to services.exe using RPC */