/* INCLUDES ****************************************************************/
#include "services.h"
-#include "svcctl_s.h"
#define NDEBUG
#include <debug.h>
ScmServiceMapping = {SERVICE_READ,
SERVICE_WRITE,
SERVICE_EXECUTE,
- SC_MANAGER_ALL_ACCESS};
+ SERVICE_ALL_ACCESS};
/* FUNCTIONS ***************************************************************/
lpService = hSvc->ServiceEntry;
if (lpService == NULL)
{
- DPRINT1("lpService == NULL!\n");
+ DPRINT1("lpService == NULL!\n");
return ERROR_INVALID_HANDLE;
}
TRUE,
&hToken);
if (!NT_SUCCESS(Status))
- return RtlNtStatusToDosError(Status);
+ return RtlNtStatusToDosError(Status);
RpcRevertToSelf();
}
/* Do a real query now */
- LinkTarget.Length = BufferSize;
+ LinkTarget.Length = (USHORT)BufferSize;
LinkTarget.MaximumLength = LinkTarget.Length + sizeof(WCHAR);
Status = NtQuerySymbolicLinkObject(SymbolicLinkHandle, &LinkTarget, &BufferSize);
dwRequiredSize += dwSize;
}
- if (dwError == 0)
+ if (dwError == 0)
{
*pcbBytesNeeded = 0;
if (lpResumeHandle) *lpResumeHandle = 0;
DWORD dwError = ERROR_SUCCESS;
PSERVICE_HANDLE hSvc;
PSERVICE lpService = NULL;
+ DWORD i;
- DPRINT("RStartServiceW() called\n");
+ DPRINT("RStartServiceW(%p %lu %p) called\n", hService, argc, argv);
+ DPRINT(" argc: %lu\n", argc);
+ if (argv != NULL)
+ {
+ for (i = 0; i < argc; i++)
+ {
+ DPRINT(" argv[%lu]: %S\n", i, argv[i]);
+ }
+ }
if (ScmShutdown)
return ERROR_SHUTDOWN_IN_PROGRESS;
if (lpService->bDeleted)
return ERROR_SERVICE_MARKED_FOR_DELETE;
- if (argv) {
- UNIMPLEMENTED;
- argv = NULL;
- }
-
/* Start the service */
- dwError = ScmStartService(lpService, argc, (LPWSTR *)argv);
+ dwError = ScmStartService(lpService, argc, (LPWSTR*)argv);
return dwError;
}
lpStatusPtrA = (LPENUM_SERVICE_STATUSA)lpBuffer;
lpStringPtrA = (LPSTR)((ULONG_PTR)lpBuffer +
*lpServicesReturned * sizeof(ENUM_SERVICE_STATUSA));
- lpStringPtrW = (LPWSTR)((ULONG_PTR)lpStatusPtrW +
+ lpStringPtrW = (LPWSTR)((ULONG_PTR)lpStatusPtrW +
*lpServicesReturned * sizeof(ENUM_SERVICE_STATUSW));
for (dwServiceCount = 0; dwServiceCount < *lpServicesReturned; dwServiceCount++)
DWORD dwError = ERROR_SUCCESS;
PSERVICE_HANDLE hSvc;
PSERVICE lpService = NULL;
+ LPWSTR *lpVector = NULL;
+ DWORD i;
+ DWORD dwLength;
DPRINT("RStartServiceA() called\n");
if (lpService->bDeleted)
return ERROR_SERVICE_MARKED_FOR_DELETE;
- /* FIXME: Convert argument vector to Unicode */
+ /* Build a Unicode argument vector */
+ if (argc > 0)
+ {
+ lpVector = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ argc * sizeof(LPWSTR));
+ if (lpVector == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
+
+ for (i = 0; i < argc; i++)
+ {
+ dwLength = MultiByteToWideChar(CP_ACP,
+ 0,
+ ((LPSTR*)argv)[i],
+ -1,
+ NULL,
+ 0);
+
+ lpVector[i] = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ dwLength * sizeof(WCHAR));
+ if (lpVector[i] == NULL)
+ {
+ dwError = ERROR_NOT_ENOUGH_MEMORY;
+ goto done;
+ }
+
+ MultiByteToWideChar(CP_ACP,
+ 0,
+ ((LPSTR*)argv)[i],
+ -1,
+ lpVector[i],
+ dwLength);
+ }
+ }
/* Start the service */
- dwError = ScmStartService(lpService, 0, NULL);
+ dwError = ScmStartService(lpService, argc, lpVector);
- /* FIXME: Free argument vector */
+done:
+ /* Free the Unicode argument vector */
+ if (lpVector != NULL)
+ {
+ for (i = 0; i < argc; i++)
+ {
+ if (lpVector[i] != NULL)
+ HeapFree(GetProcessHeap(), 0, lpVector[i]);
+ }
+ HeapFree(GetProcessHeap(), 0, lpVector);
+ }
return dwError;
}
goto done;
}
- lpFailureActions->cActions = 0;
+ lpFailureActions->cActions = 0;
lpFailureActions->dwResetPeriod = 0;
lpFailureActions->lpCommand = NULL;
lpFailureActions->lpRebootMsg = NULL;
lpStatusPtrA = (LPENUM_SERVICE_STATUS_PROCESSA)lpBuffer;
lpStringPtrA = (LPSTR)((ULONG_PTR)lpBuffer +
*lpServicesReturned * sizeof(ENUM_SERVICE_STATUS_PROCESSA));
- lpStringPtrW = (LPWSTR)((ULONG_PTR)lpStatusPtrW +
+ lpStringPtrW = (LPWSTR)((ULONG_PTR)lpStatusPtrW +
*lpServicesReturned * sizeof(ENUM_SERVICE_STATUS_PROCESSW));
for (dwServiceCount = 0; dwServiceCount < *lpServicesReturned; dwServiceCount++)
}
}
- if (dwError == 0)
+ if (dwError == 0)
{
*pcbBytesNeeded = 0;
if (lpResumeIndex)