mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
[ADVAPI32]
Fix EnumServicesStatusEx[A/W]: - If lpServices is NULL or cbBufSize is less than sizeof(ENUM_SERVICE_STATUS_PROCESS) pass a pointer to an internal status buffer to REnumServicesStatusExA/W. Adding 'in' and 'unique' attributes in the idl file is NOT an option because this is not compatible with Windows. - Check the InfoLevel. svn path=/trunk/; revision=53201
This commit is contained in:
parent
86f6c946e7
commit
33e3cab77d
1 changed files with 60 additions and 22 deletions
|
@ -1150,7 +1150,9 @@ EnumServicesStatusExA(SC_HANDLE hSCManager,
|
|||
LPDWORD lpResumeHandle,
|
||||
LPCSTR pszGroupName)
|
||||
{
|
||||
ENUM_SERVICE_STATUS_PROCESSA ServiceStatus;
|
||||
LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr;
|
||||
DWORD dwBufferSize;
|
||||
DWORD dwError;
|
||||
DWORD dwCount;
|
||||
|
||||
|
@ -1168,14 +1170,26 @@ EnumServicesStatusExA(SC_HANDLE hSCManager,
|
|||
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,
|
||||
|
@ -1189,7 +1203,8 @@ EnumServicesStatusExA(SC_HANDLE hSCManager,
|
|||
|
||||
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||
{
|
||||
lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
|
||||
if (InfoLevel == SC_ENUM_PROCESS_INFO)
|
||||
{
|
||||
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
|
||||
{
|
||||
if (lpStatusPtr->lpServiceName)
|
||||
|
@ -1203,6 +1218,7 @@ EnumServicesStatusExA(SC_HANDLE hSCManager,
|
|||
lpStatusPtr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -1234,20 +1250,40 @@ EnumServicesStatusExW(SC_HANDLE hSCManager,
|
|||
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,
|
||||
|
@ -1261,7 +1297,8 @@ EnumServicesStatusExW(SC_HANDLE hSCManager,
|
|||
|
||||
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||
{
|
||||
lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
|
||||
if (InfoLevel == SC_ENUM_PROCESS_INFO)
|
||||
{
|
||||
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
|
||||
{
|
||||
if (lpStatusPtr->lpServiceName)
|
||||
|
@ -1275,6 +1312,7 @@ EnumServicesStatusExW(SC_HANDLE hSCManager,
|
|||
lpStatusPtr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue