Author: ekohl
Date: Tue Aug 8 02:13:26 2006
New Revision: 23521
URL:
http://svn.reactos.org/svn/reactos?rev=23521&view=rev
Log:
- Implement ScmStartServiceA and revert the last modification of StartServiceA.
- Fix EnumServicesStatusExW.
Modified:
trunk/reactos/base/system/services/rpcserver.c
trunk/reactos/dll/win32/advapi32/service/scm.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 (original)
+++ trunk/reactos/base/system/services/rpcserver.c Tue Aug 8 02:13:26 2006
@@ -2093,8 +2093,51 @@
unsigned char *lpServiceArgBuffer,
unsigned long cbBufSize)
{
+ DWORD dwError = ERROR_SUCCESS;
+ PSERVICE_HANDLE hSvc;
+ PSERVICE lpService = NULL;
+ NTSTATUS Status;
+
DPRINT1("ScmrStartServiceA() called\n");
- return ERROR_CALL_NOT_IMPLEMENTED;
+
+ if (ScmShutdown)
+ return ERROR_SHUTDOWN_IN_PROGRESS;
+
+ hSvc = (PSERVICE_HANDLE)hService;
+ if (hSvc->Handle.Tag != SERVICE_TAG)
+ {
+ DPRINT1("Invalid handle tag!\n");
+ return ERROR_INVALID_HANDLE;
+ }
+
+ if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
+ SERVICE_START))
+ {
+ DPRINT1("Insufficient access rights! 0x%lx\n",
hSvc->Handle.DesiredAccess);
+ return ERROR_ACCESS_DENIED;
+ }
+
+ lpService = hSvc->ServiceEntry;
+ if (lpService == NULL)
+ {
+ DPRINT1("lpService == NULL!\n");
+ return ERROR_INVALID_HANDLE;
+ }
+
+ if (lpService->dwStartType == SERVICE_DISABLED)
+ return ERROR_SERVICE_DISABLED;
+
+ if (lpService->bDeleted)
+ return ERROR_SERVICE_MARKED_FOR_DELETE;
+
+ /* FIXME: Convert argument vector to Unicode */
+
+ /* Start the service */
+ Status = ScmStartService(lpService);
+ if (!NT_SUCCESS(Status))
+ return RtlNtStatusToDosError(Status);
+
+ return dwError;
}
Modified: trunk/reactos/dll/win32/advapi32/service/scm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/scm.c (original)
+++ trunk/reactos/dll/win32/advapi32/service/scm.c Tue Aug 8 02:13:26 2006
@@ -1055,7 +1055,8 @@
lpStatusPtr++;
}
- if (dwError != ERROR_SUCCESS)
+ if (dwError != ERROR_SUCCESS &&
+ dwError != ERROR_MORE_DATA)
{
DPRINT1("ScmrEnumServicesStatusExW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
@@ -1970,16 +1971,72 @@
DWORD dwNumServiceArgs,
LPCSTR *lpServiceArgVectors)
{
+ LPSTR lpBuffer;
+ LPSTR lpStr;
+ DWORD dwError;
+ DWORD dwBufSize;
+ DWORD i;
+
+ dwBufSize = 0;
+ for (i = 0; i < dwNumServiceArgs; i++)
+ {
+ dwBufSize += (strlen(lpServiceArgVectors[i]) + 1);
+ }
+ DPRINT1("dwBufSize: %lu\n", dwBufSize);
+
+ lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
+ if (lpBuffer == NULL)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+
+ lpStr = lpBuffer;
+ for (i = 0; i < dwNumServiceArgs; i++)
+ {
+ strcpy(lpStr, lpServiceArgVectors[i]);
+ lpStr += (strlen(lpServiceArgVectors[i]) + 1);
+ }
+
+ dwError = ScmrStartServiceA(BindingHandle,
+ (unsigned int)hService,
+ dwNumServiceArgs,
+ (unsigned char *)lpBuffer,
+ dwBufSize);
+
+ HeapFree(GetProcessHeap(), 0, lpBuffer);
+
+ if (dwError != ERROR_SUCCESS)
+ {
+ DPRINT1("ScmrStartServiceA() failed (Error %lu)\n", dwError);
+ SetLastError(dwError);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/**********************************************************************
+ * StartServiceW
+ *
+ * @implemented
+ */
+BOOL STDCALL
+StartServiceW(SC_HANDLE hService,
+ DWORD dwNumServiceArgs,
+ LPCWSTR *lpServiceArgVectors)
+{
LPWSTR lpBuffer;
LPWSTR lpStr;
DWORD dwError;
DWORD dwBufSize;
- DWORD i, step;
+ DWORD i;
dwBufSize = 0;
for (i = 0; i < dwNumServiceArgs; i++)
{
- dwBufSize += MultiByteToWideChar(CP_ACP, 0, lpServiceArgVectors[i], -1, NULL,
0);
+ dwBufSize += ((wcslen(lpServiceArgVectors[i]) + 1) * sizeof(WCHAR));
}
DPRINT1("dwBufSize: %lu\n", dwBufSize);
@@ -1993,12 +2050,8 @@
lpStr = lpBuffer;
for (i = 0; i < dwNumServiceArgs; i++)
{
- step = MultiByteToWideChar(CP_ACP, 0,
- lpServiceArgVectors[i], -1,
- lpStr, lpBuffer + dwBufSize - lpStr);
- if (step == 0)
- return FALSE;
- lpStr += step + 1;
+ wcscpy(lpStr, lpServiceArgVectors[i]);
+ lpStr += (wcslen(lpServiceArgVectors[i]) + 1);
}
dwError = ScmrStartServiceW(BindingHandle,
@@ -2021,62 +2074,6 @@
/**********************************************************************
- * StartServiceW
- *
- * @implemented
- */
-BOOL STDCALL
-StartServiceW(SC_HANDLE hService,
- DWORD dwNumServiceArgs,
- LPCWSTR *lpServiceArgVectors)
-{
- LPWSTR lpBuffer;
- LPWSTR lpStr;
- DWORD dwError;
- DWORD dwBufSize;
- DWORD i;
-
- dwBufSize = 0;
- for (i = 0; i < dwNumServiceArgs; i++)
- {
- dwBufSize += ((wcslen(lpServiceArgVectors[i]) + 1) * sizeof(WCHAR));
- }
- DPRINT1("dwBufSize: %lu\n", dwBufSize);
-
- lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
- if (lpBuffer == NULL)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
-
- lpStr = lpBuffer;
- for (i = 0; i < dwNumServiceArgs; i++)
- {
- wcscpy(lpStr, lpServiceArgVectors[i]);
- lpStr += (wcslen(lpServiceArgVectors[i]) + 1);
- }
-
- dwError = ScmrStartServiceW(BindingHandle,
- (unsigned int)hService,
- dwNumServiceArgs,
- (unsigned char *)lpBuffer,
- dwBufSize);
-
- HeapFree(GetProcessHeap(), 0, lpBuffer);
-
- if (dwError != ERROR_SUCCESS)
- {
- DPRINT1("ScmrStartServiceW() failed (Error %lu)\n", dwError);
- SetLastError(dwError);
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/**********************************************************************
* UnlockServiceDatabase
*
* @implemented