Ptr = (MANAGER_HANDLE*) HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
- sizeof(MANAGER_HANDLE) + wcslen(lpDatabaseName) * sizeof(WCHAR));
+ sizeof(MANAGER_HANDLE) + (wcslen(lpDatabaseName) + 1) * sizeof(WCHAR));
if (Ptr == NULL)
return ERROR_NOT_ENOUGH_MEMORY;
ASSERT(lpService->dwRefCount > 0);
lpService->dwRefCount--;
- DPRINT1("CloseServiceHandle - lpService->dwRefCount %u\n",
- lpService->dwRefCount);
+ DPRINT("CloseServiceHandle - lpService->dwRefCount %u\n",
+ lpService->dwRefCount);
if (lpService->dwRefCount == 0)
{
/* if pcbBytesNeeded returned a value then there are services running that are dependent on this service*/
if (pcbBytesNeeded)
{
- DPRINT1("Deletion failed due to running dependencies.\n",
- lpService->lpServiceName);
+ DPRINT1("Deletion failed due to running dependencies.\n");
RegCloseKey(hServicesKey);
return ERROR_SUCCESS;
}
}
+static BOOL
+ScmIsValidServiceState(DWORD dwCurrentState)
+{
+ switch (dwCurrentState)
+ {
+ case SERVICE_STOPPED:
+ case SERVICE_START_PENDING:
+ case SERVICE_STOP_PENDING:
+ case SERVICE_RUNNING:
+ case SERVICE_CONTINUE_PENDING:
+ case SERVICE_PAUSE_PENDING:
+ case SERVICE_PAUSED:
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+}
+
+
/* Function 7 */
DWORD RSetServiceStatus(
handle_t BindingHandle,
PSERVICE lpService;
DPRINT("RSetServiceStatus() called\n");
-
- if (ScmShutdown)
- return ERROR_SHUTDOWN_IN_PROGRESS;
+ DPRINT("hServiceStatus = %p\n", hServiceStatus);
+ DPRINT("dwServiceType = %lu\n", lpServiceStatus->dwServiceType);
+ DPRINT("dwCurrentState = %lu\n", lpServiceStatus->dwCurrentState);
+ DPRINT("dwControlsAccepted = %lu\n", lpServiceStatus->dwControlsAccepted);
+ DPRINT("dwWin32ExitCode = %lu\n", lpServiceStatus->dwWin32ExitCode);
+ DPRINT("dwServiceSpecificExitCode = %lu\n", lpServiceStatus->dwServiceSpecificExitCode);
+ DPRINT("dwCheckPoint = %lu\n", lpServiceStatus->dwCheckPoint);
+ DPRINT("dwWaitHint = %lu\n", lpServiceStatus->dwWaitHint);
+
+ if (hServiceStatus == 0)
+ {
+ DPRINT1("hServiceStatus == NULL!\n");
+ return ERROR_INVALID_HANDLE;
+ }
lpService = ScmGetServiceEntryByClientHandle((ULONG)hServiceStatus);
if (lpService == NULL)
return ERROR_INVALID_HANDLE;
}
+ /* Check current state */
+ if (!ScmIsValidServiceState(lpServiceStatus->dwCurrentState))
+ {
+ DPRINT1("Invalid service state!\n");
+ return ERROR_INVALID_DATA;
+ }
+
+ /* Check service type */
+ if (!(lpServiceStatus->dwServiceType & SERVICE_WIN32) &&
+ (lpServiceStatus->dwServiceType & SERVICE_DRIVER))
+ {
+ DPRINT1("Invalid service type!\n");
+ return ERROR_INVALID_DATA;
+ }
+
+ /* Check accepted controls */
+ if (lpServiceStatus->dwControlsAccepted == 0 ||
+ lpServiceStatus->dwControlsAccepted & ~0xFF)
+ {
+ DPRINT1("Invalid controls accepted!\n");
+ return ERROR_INVALID_DATA;
+ }
+
+
RtlCopyMemory(&lpService->Status,
lpServiceStatus,
sizeof(SERVICE_STATUS));
/* Function 10 */
-DWORD RSetServiceBitsW(
+DWORD RI_ScSetServiceBitsW(
handle_t BindingHandle,
SC_RPC_HANDLE hServiceStatus,
DWORD dwServiceBits,
goto done;
lpService->dwRefCount = 1;
- DPRINT1("CreateService - lpService->dwRefCount %u\n", lpService->dwRefCount);
+ DPRINT("CreateService - lpService->dwRefCount %u\n", lpService->dwRefCount);
done:;
if (hServiceKey != NULL)
}
lpService->dwRefCount++;
- DPRINT1("OpenService - lpService->dwRefCount %u\n",lpService->dwRefCount);
+ DPRINT("OpenService - lpService->dwRefCount %u\n",lpService->dwRefCount);
*lpServiceHandle = (SC_RPC_HANDLE)hHandle;
DPRINT("*hService = %p\n", *lpServiceHandle);
/* Function 22 */
-DWORD RSetServiceBitsA(
+DWORD RI_ScSetServiceBitsA(
handle_t BindingHandle,
SC_RPC_HANDLE hServiceStatus,
DWORD dwServiceBits,
lpDisplayName,
-1,
lpDisplayNameW,
- (wcslen(lpDisplayNameW) + 1) * sizeof(WCHAR));
+ wcslen(lpDisplayNameW) + 1);
RegSetValueExW(hServiceKey,
L"DisplayName",
if (lpBinaryPathName != NULL && *lpBinaryPathName != 0)
{
lpBinaryPathNameW=HeapAlloc(GetProcessHeap(),0, (strlen(lpBinaryPathName)+1) * sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, lpBinaryPathNameW, (wcslen(lpBinaryPathNameW)+1) * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, lpBinaryPathNameW, wcslen(lpBinaryPathNameW)+1);
dwError = RegSetValueExW(hServiceKey,
L"ImagePath",
0,
lpLoadOrderGroup,
-1,
lpLoadOrderGroupW,
- (wcslen(lpLoadOrderGroupW) + 1) * sizeof(WCHAR));
+ wcslen(lpLoadOrderGroupW) + 1);
dwError = RegSetValueExW(hServiceKey,
L"Group",
lpDependencies,
dwDependSize,
lpDependenciesW,
- (wcslen(lpDependenciesW)+1) * sizeof(WCHAR));
+ wcslen(lpDependenciesW)+1);
dwError = ScmWriteDependencies(hServiceKey,
(LPWSTR)lpDependenciesW,
/* Function 34 */
-DWORD RGetCurrentGroupStateW(
- handle_t BindingHandle)
+DWORD RI_ScGetCurrentGroupStateW(
+ handle_t BindingHandle,
+ SC_RPC_HANDLE hSCManager,
+ LPWSTR lpLoadOrderGroup,
+ LPDWORD lpState)
{
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;