Author: ekohl
Date: Sun Sep 4 14:42:08 2011
New Revision: 53579
URL:
http://svn.reactos.org/svn/reactos?rev=53579&view=rev
Log:
[SERVICES]
RStartServiceA: Convert the ANSI start arguments vector to a UNICODE vector and pass it to
ScmStartService. Calls to StartServiceA can now be used to pass arguments to a starting
service.
Modified:
trunk/reactos/base/system/services/rpcserver.c
Modified: trunk/reactos/base/system/services/rpcserver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
==============================================================================
--- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Sep 4 14:42:08 2011
@@ -4086,6 +4086,9 @@
DWORD dwError = ERROR_SUCCESS;
PSERVICE_HANDLE hSvc;
PSERVICE lpService = NULL;
+ LPWSTR *lpVector = NULL;
+ DWORD i;
+ DWORD dwLength;
DPRINT("RStartServiceA() called\n");
@@ -4119,12 +4122,56 @@
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);
-
- /* FIXME: Free argument vector */
+ dwError = ScmStartService(lpService, argc, lpVector);
+
+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;
}