- Implement ScmStartServiceA and revert the last modification of StartServiceA.

- Fix EnumServicesStatusExW.

svn path=/trunk/; revision=23521
This commit is contained in:
Eric Kohl
2006-08-07 22:13:26 +00:00
parent 2f021d099e
commit 4d64dd44c6
2 changed files with 54 additions and 14 deletions
+44 -1
View File
@@ -2093,8 +2093,51 @@ ScmrStartServiceA(handle_t BindingHandle,
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;
}
+10 -13
View File
@@ -1055,7 +1055,8 @@ EnumServicesStatusExW(SC_HANDLE hSCManager,
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,16 @@ StartServiceA(SC_HANDLE hService,
DWORD dwNumServiceArgs,
LPCSTR *lpServiceArgVectors)
{
LPWSTR lpBuffer;
LPWSTR lpStr;
LPSTR lpBuffer;
LPSTR 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 += (strlen(lpServiceArgVectors[i]) + 1);
}
DPRINT1("dwBufSize: %lu\n", dwBufSize);
@@ -1993,15 +1994,11 @@ StartServiceA(SC_HANDLE hService,
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;
strcpy(lpStr, lpServiceArgVectors[i]);
lpStr += (strlen(lpServiceArgVectors[i]) + 1);
}
dwError = ScmrStartServiceW(BindingHandle,
dwError = ScmrStartServiceA(BindingHandle,
(unsigned int)hService,
dwNumServiceArgs,
(unsigned char *)lpBuffer,
@@ -2011,7 +2008,7 @@ StartServiceA(SC_HANDLE hService,
if (dwError != ERROR_SUCCESS)
{
DPRINT1("ScmrStartServiceW() failed (Error %lu)\n", dwError);
DPRINT1("ScmrStartServiceA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}