/**********************************************************************
* EnumServiceGroupW
*
- * @unimplemented
+ * @implemented
*/
-BOOL
-WINAPI
-EnumServiceGroupW(
- SC_HANDLE hSCManager,
- DWORD dwServiceType,
- DWORD dwServiceState,
- LPENUM_SERVICE_STATUSW lpServices,
- DWORD cbBufSize,
- LPDWORD pcbBytesNeeded,
- LPDWORD lpServicesReturned,
- LPDWORD lpResumeHandle,
- LPCWSTR lpGroup)
+BOOL WINAPI
+EnumServiceGroupW(SC_HANDLE hSCManager,
+ DWORD dwServiceType,
+ DWORD dwServiceState,
+ LPENUM_SERVICE_STATUSW lpServices,
+ DWORD cbBufSize,
+ LPDWORD pcbBytesNeeded,
+ LPDWORD lpServicesReturned,
+ LPDWORD lpResumeHandle,
+ LPCWSTR lpGroup)
{
- FIXME("EnumServiceGroupW is unimplemented\n");
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ LPENUM_SERVICE_STATUSW lpStatusPtr;
+ DWORD dwError;
+ DWORD dwCount;
+
+ TRACE("EnumServiceGroupW() called\n");
+
+ if (!hSCManager)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ RpcTryExcept
+ {
+ if (lpGroup == NULL)
+ {
+ dwError = REnumServicesStatusW((SC_RPC_HANDLE)hSCManager,
+ dwServiceType,
+ dwServiceState,
+ (LPBYTE)lpServices,
+ cbBufSize,
+ pcbBytesNeeded,
+ lpServicesReturned,
+ lpResumeHandle);
+ }
+ else
+ {
+ dwError = REnumServiceGroupW((SC_RPC_HANDLE)hSCManager,
+ dwServiceType,
+ dwServiceState,
+ (LPBYTE)lpServices,
+ cbBufSize,
+ pcbBytesNeeded,
+ lpServicesReturned,
+ lpResumeHandle,
+ lpGroup);
+ }
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
+ {
+ lpStatusPtr = (LPENUM_SERVICE_STATUSW)lpServices;
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ {
+ if (lpStatusPtr->lpServiceName)
+ lpStatusPtr->lpServiceName =
+ (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+
+ if (lpStatusPtr->lpDisplayName)
+ lpStatusPtr->lpDisplayName =
+ (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
+
+ lpStatusPtr++;
+ }
+ }
+
+ if (dwError != ERROR_SUCCESS)
+ {
+ TRACE("REnumServiceGroupW() failed (Error %lu)\n", dwError);
+ SetLastError(dwError);
+ return FALSE;
+ }
+
+ TRACE("EnumServiceGroupW() done\n");
+
+ return TRUE;
}
LPDWORD lpResumeHandle,
LPCSTR pszGroupName)
{
+ ENUM_SERVICE_STATUS_PROCESSA ServiceStatus;
LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr;
+ DWORD dwBufferSize;
DWORD dwError;
DWORD dwCount;
return FALSE;
}
+ if (lpServices == NULL ||
+ cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSA))
+ {
+ lpStatusPtr = &ServiceStatus;
+ dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSA);
+ }
+ else
+ {
+ lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
+ dwBufferSize = cbBufSize;
+ }
+
RpcTryExcept
{
dwError = REnumServicesStatusExA((SC_RPC_HANDLE)hSCManager,
InfoLevel,
dwServiceType,
dwServiceState,
- (LPBYTE)lpServices,
- cbBufSize,
+ (LPBYTE)lpStatusPtr,
+ dwBufferSize,
pcbBytesNeeded,
lpServicesReturned,
lpResumeHandle,
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
{
- lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ if (InfoLevel == SC_ENUM_PROCESS_INFO)
{
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ {
+ if (lpStatusPtr->lpServiceName)
+ lpStatusPtr->lpServiceName =
+ (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
- if (lpStatusPtr->lpDisplayName)
- lpStatusPtr->lpDisplayName =
- (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
+ if (lpStatusPtr->lpDisplayName)
+ lpStatusPtr->lpDisplayName =
+ (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
- lpStatusPtr++;
+ lpStatusPtr++;
+ }
}
}
LPDWORD lpResumeHandle,
LPCWSTR pszGroupName)
{
+ ENUM_SERVICE_STATUS_PROCESSW ServiceStatus;
LPENUM_SERVICE_STATUS_PROCESSW lpStatusPtr;
+ DWORD dwBufferSize;
DWORD dwError;
DWORD dwCount;
TRACE("EnumServicesStatusExW() called\n");
+ if (InfoLevel != SC_ENUM_PROCESS_INFO)
+ {
+ SetLastError(ERROR_INVALID_LEVEL);
+ return FALSE;
+ }
+
+ if (lpServices == NULL ||
+ cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSW))
+ {
+ lpStatusPtr = &ServiceStatus;
+ dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW);
+ }
+ else
+ {
+ lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
+ dwBufferSize = cbBufSize;
+ }
+
RpcTryExcept
{
dwError = REnumServicesStatusExW((SC_RPC_HANDLE)hSCManager,
InfoLevel,
dwServiceType,
dwServiceState,
- (LPBYTE)lpServices,
- cbBufSize,
+ (LPBYTE)lpStatusPtr,
+ dwBufferSize,
pcbBytesNeeded,
lpServicesReturned,
lpResumeHandle,
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
{
- lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ if (InfoLevel == SC_ENUM_PROCESS_INFO)
{
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ {
+ if (lpStatusPtr->lpServiceName)
+ lpStatusPtr->lpServiceName =
+ (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
- if (lpStatusPtr->lpDisplayName)
- lpStatusPtr->lpDisplayName =
- (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
+ if (lpStatusPtr->lpDisplayName)
+ lpStatusPtr->lpDisplayName =
+ (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
- lpStatusPtr++;
+ lpStatusPtr++;
+ }
}
}
TRACE("QueryServiceConfigW(%p, %p, %lu, %p)\n",
hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
-
+
+ if(pcbBytesNeeded)
+ *pcbBytesNeeded = 0;
+
RpcTryExcept
{
/* Call to services.exe using RPC */
if (dwError != ERROR_SUCCESS)
{
- TRACE("RStartServiceA() failed (Error %lu)\n", dwError);
+ ERR("RStartServiceA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
if (dwError != ERROR_SUCCESS)
{
- TRACE("RStartServiceW() failed (Error %lu)\n", dwError);
+ ERR("RStartServiceW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}