mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
[ADVAPI32]
Fix and EnumDependentServices[A/W]: - If lpServices is NULL or cbBufSize is less than sizeof(ENUM_SERVICE_STATUS/W) pass a pointer to an internal status buffer to REnumDependentServicesA/W. svn path=/trunk/; revision=53214
This commit is contained in:
parent
d292220a34
commit
fb59583ee0
1 changed files with 54 additions and 24 deletions
|
@ -744,18 +744,31 @@ EnumDependentServicesA(SC_HANDLE hService,
|
|||
LPDWORD pcbBytesNeeded,
|
||||
LPDWORD lpServicesReturned)
|
||||
{
|
||||
ENUM_SERVICE_STATUSA ServiceStatus;
|
||||
LPENUM_SERVICE_STATUSA lpStatusPtr;
|
||||
DWORD dwBufferSize;
|
||||
DWORD dwError;
|
||||
DWORD dwCount;
|
||||
|
||||
TRACE("EnumServicesStatusA() called\n");
|
||||
TRACE("EnumDependentServicesA() called\n");
|
||||
|
||||
if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSA))
|
||||
{
|
||||
lpStatusPtr = &ServiceStatus;
|
||||
dwBufferSize = sizeof(ENUM_SERVICE_STATUSA);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpStatusPtr = lpServices;
|
||||
dwBufferSize = cbBufSize;
|
||||
}
|
||||
|
||||
RpcTryExcept
|
||||
{
|
||||
dwError = REnumDependentServicesA((SC_RPC_HANDLE)hService,
|
||||
dwServiceState,
|
||||
(LPBYTE)lpServices,
|
||||
cbBufSize,
|
||||
(LPBYTE)lpStatusPtr,
|
||||
dwBufferSize,
|
||||
pcbBytesNeeded,
|
||||
lpServicesReturned);
|
||||
}
|
||||
|
@ -767,18 +780,20 @@ EnumDependentServicesA(SC_HANDLE hService,
|
|||
|
||||
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||
{
|
||||
lpStatusPtr = (LPENUM_SERVICE_STATUSA)lpServices;
|
||||
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
|
||||
if (*lpServicesReturned > 0)
|
||||
{
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -808,18 +823,31 @@ EnumDependentServicesW(SC_HANDLE hService,
|
|||
LPDWORD pcbBytesNeeded,
|
||||
LPDWORD lpServicesReturned)
|
||||
{
|
||||
ENUM_SERVICE_STATUSW ServiceStatus;
|
||||
LPENUM_SERVICE_STATUSW lpStatusPtr;
|
||||
DWORD dwBufferSize;
|
||||
DWORD dwError;
|
||||
DWORD dwCount;
|
||||
|
||||
TRACE("EnumServicesStatusW() called\n");
|
||||
TRACE("EnumDependentServicesW() called\n");
|
||||
|
||||
if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
|
||||
{
|
||||
lpStatusPtr = &ServiceStatus;
|
||||
dwBufferSize = sizeof(ENUM_SERVICE_STATUSW);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpStatusPtr = lpServices;
|
||||
dwBufferSize = cbBufSize;
|
||||
}
|
||||
|
||||
RpcTryExcept
|
||||
{
|
||||
dwError = REnumDependentServicesW((SC_RPC_HANDLE)hService,
|
||||
dwServiceState,
|
||||
(LPBYTE)lpServices,
|
||||
cbBufSize,
|
||||
(LPBYTE)lpStatusPtr,
|
||||
dwBufferSize,
|
||||
pcbBytesNeeded,
|
||||
lpServicesReturned);
|
||||
}
|
||||
|
@ -831,18 +859,20 @@ EnumDependentServicesW(SC_HANDLE hService,
|
|||
|
||||
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||
{
|
||||
lpStatusPtr = (LPENUM_SERVICE_STATUSW)lpServices;
|
||||
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
|
||||
if (*lpServicesReturned > 0)
|
||||
{
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue