Author: gedmurphy Date: Fri Jul 6 17:53:29 2007 New Revision: 27423
URL: http://svn.reactos.org/svn/reactos?rev=27423&view=rev Log: - ensure SetLastError is called when EnumServicesStatusEx is returning required buffer sizes - servman.exe now lists all ReactOS services
Modified: trunk/reactos/dll/win32/advapi32/service/scm.c
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 Fri Jul 6 17:53:29 2007 @@ -962,21 +962,29 @@ lpResumeHandle, (char *)pszGroupName);
- lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices; - 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); - - lpStatusPtr++; - } - - if (dwError != ERROR_SUCCESS) + if (dwError == ERROR_MORE_DATA) + { + DPRINT("Required buffer size %ul\n", *pcbBytesNeeded); + SetLastError(dwError); + return FALSE; + } + else if (dwError == ERROR_SUCCESS) + { + lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices; + 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); + + lpStatusPtr++; + } + } + else { DPRINT1("ScmrEnumServicesStatusExA() failed (Error %lu)\n", dwError); SetLastError(dwError); @@ -1026,22 +1034,29 @@ lpResumeHandle, (wchar_t *)pszGroupName);
- lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)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 && - dwError != ERROR_MORE_DATA) + if (dwError == ERROR_MORE_DATA) + { + DPRINT("Required buffer size %ul\n", *pcbBytesNeeded); + SetLastError(dwError); + return FALSE; + } + else if (dwError == ERROR_SUCCESS) + { + lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)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++; + } + } + else { DPRINT1("ScmrEnumServicesStatusExW() failed (Error %lu)\n", dwError); SetLastError(dwError);