- ensure SetLastError is called when EnumServicesStatusEx is returning required buffer sizes

- servman.exe now lists all ReactOS services

svn path=/trunk/; revision=27423
This commit is contained in:
Ged Murphy 2007-07-06 13:53:29 +00:00
parent 771911b3ab
commit 843b40c7ad

View file

@ -962,21 +962,29 @@ EnumServicesStatusExA(SC_HANDLE hSCManager,
lpResumeHandle, lpResumeHandle,
(char *)pszGroupName); (char *)pszGroupName);
lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices; if (dwError == ERROR_MORE_DATA)
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
{ {
if (lpStatusPtr->lpServiceName) DPRINT("Required buffer size %ul\n", *pcbBytesNeeded);
lpStatusPtr->lpServiceName = SetLastError(dwError);
(LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName); return FALSE;
if (lpStatusPtr->lpDisplayName)
lpStatusPtr->lpDisplayName =
(LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
lpStatusPtr++;
} }
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 (dwError != ERROR_SUCCESS) if (lpStatusPtr->lpDisplayName)
lpStatusPtr->lpDisplayName =
(LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
lpStatusPtr++;
}
}
else
{ {
DPRINT1("ScmrEnumServicesStatusExA() failed (Error %lu)\n", dwError); DPRINT1("ScmrEnumServicesStatusExA() failed (Error %lu)\n", dwError);
SetLastError(dwError); SetLastError(dwError);
@ -1026,22 +1034,29 @@ EnumServicesStatusExW(SC_HANDLE hSCManager,
lpResumeHandle, lpResumeHandle,
(wchar_t *)pszGroupName); (wchar_t *)pszGroupName);
lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices; if (dwError == ERROR_MORE_DATA)
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
{ {
if (lpStatusPtr->lpServiceName) DPRINT("Required buffer size %ul\n", *pcbBytesNeeded);
lpStatusPtr->lpServiceName = SetLastError(dwError);
(LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName); return FALSE;
if (lpStatusPtr->lpDisplayName)
lpStatusPtr->lpDisplayName =
(LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
lpStatusPtr++;
} }
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 (dwError != ERROR_SUCCESS && if (lpStatusPtr->lpDisplayName)
dwError != ERROR_MORE_DATA) lpStatusPtr->lpDisplayName =
(LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
lpStatusPtr++;
}
}
else
{ {
DPRINT1("ScmrEnumServicesStatusExW() failed (Error %lu)\n", dwError); DPRINT1("ScmrEnumServicesStatusExW() failed (Error %lu)\n", dwError);
SetLastError(dwError); SetLastError(dwError);