Index: dll/win32/advapi32/service/scm.c =================================================================== --- dll/win32/advapi32/service/scm.c (révision 56741) +++ dll/win32/advapi32/service/scm.c (copie de travail) @@ -777,20 +777,17 @@ if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA) { - if (*lpServicesReturned > 0) + for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) { - for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) - { - if (lpStatusPtr->lpServiceName) - lpStatusPtr->lpServiceName = - (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName); + 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++; } } @@ -856,20 +853,17 @@ if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA) { - if (*lpServicesReturned > 0) + for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) { - for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) - { - if (lpStatusPtr->lpServiceName) - lpStatusPtr->lpServiceName = - (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName); + 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++; } } @@ -961,20 +955,17 @@ if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA) { - if (*lpServicesReturned > 0) + for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) { - for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) - { - if (lpStatusPtr->lpServiceName) - lpStatusPtr->lpServiceName = - (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName); + 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++; } } @@ -1020,30 +1011,6 @@ return FALSE; } - if (dwServiceType != SERVICE_DRIVER && dwServiceType != SERVICE_WIN32) - { - if (pcbBytesNeeded && lpServicesReturned) - { - *pcbBytesNeeded = 0; - *lpServicesReturned = 0; - } - - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if (dwServiceState != SERVICE_ACTIVE && dwServiceState != SERVICE_INACTIVE && dwServiceState != SERVICE_STATE_ALL) - { - if (pcbBytesNeeded) - *pcbBytesNeeded = 0; - - if (lpServicesReturned) - *lpServicesReturned = 0; - - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - if (!pcbBytesNeeded || !lpServicesReturned) { SetLastError(ERROR_INVALID_ADDRESS); @@ -1056,10 +1023,10 @@ return FALSE; } - if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW)) + if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSA)) { lpStatusPtr = &ServiceStatus; - dwBufferSize = sizeof(ENUM_SERVICE_STATUSW); + dwBufferSize = sizeof(ENUM_SERVICE_STATUSA); } else { @@ -1086,20 +1053,17 @@ if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA) { - if (*lpServicesReturned > 0) + for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) { - for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) - { - if (lpStatusPtr->lpServiceName) - lpStatusPtr->lpServiceName = - (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName); + 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++; } } @@ -1131,77 +1095,16 @@ LPDWORD lpServicesReturned, LPDWORD lpResumeHandle) { - ENUM_SERVICE_STATUSW ServiceStatus; - LPENUM_SERVICE_STATUSW lpStatusPtr; - DWORD dwBufferSize; - DWORD dwError; - DWORD dwCount; - - TRACE("EnumServicesStatusW() called\n"); - - if (!hSCManager) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - - if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW)) - { - lpStatusPtr = &ServiceStatus; - dwBufferSize = sizeof(ENUM_SERVICE_STATUSW); - } - else - { - lpStatusPtr = lpServices; - dwBufferSize = cbBufSize; - } - - RpcTryExcept - { - dwError = REnumServicesStatusW((SC_RPC_HANDLE)hSCManager, - dwServiceType, - dwServiceState, - (LPBYTE)lpStatusPtr, - dwBufferSize, - pcbBytesNeeded, - lpServicesReturned, - lpResumeHandle); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - dwError = ScmRpcStatusToWinError(RpcExceptionCode()); - } - RpcEndExcept; - - if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA) - { - if (*lpServicesReturned > 0) - { - 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("REnumServicesStatusW() failed (Error %lu)\n", dwError); - SetLastError(dwError); - return FALSE; - } - - TRACE("EnumServicesStatusW() done\n"); - - return TRUE; + /* Enumerate all the services, not regarding of their group */ + return EnumServiceGroupW(hSCManager, + dwServiceType, + dwServiceState, + lpServices, + cbBufSize, + pcbBytesNeeded, + lpServicesReturned, + lpResumeHandle, + NULL); } @@ -1336,6 +1239,12 @@ return FALSE; } + if (!hSCManager) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSW)) {