mirror of
https://github.com/reactos/reactos.git
synced 2024-08-07 11:48:03 +00:00
Convert offset to pointers when enumeration functions return ERROR_SUCCESS or ERROR_MORE_DATA because there is something to convert in both cases.
svn path=/trunk/; revision=45459
This commit is contained in:
parent
fb88430110
commit
b5f68e4981
|
@ -820,6 +820,23 @@ EnumDependentServicesA(SC_HANDLE hService,
|
||||||
}
|
}
|
||||||
RpcEndExcept;
|
RpcEndExcept;
|
||||||
|
|
||||||
|
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
|
lpStatusPtr = (LPENUM_SERVICE_STATUSA)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_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("REnumDependentServicesA() failed (Error %lu)\n", dwError);
|
ERR("REnumDependentServicesA() failed (Error %lu)\n", dwError);
|
||||||
|
@ -827,20 +844,6 @@ EnumDependentServicesA(SC_HANDLE hService,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
lpStatusPtr = (LPENUM_SERVICE_STATUSA)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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("EnumDependentServicesA() done\n");
|
TRACE("EnumDependentServicesA() done\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -881,6 +884,23 @@ EnumDependentServicesW(SC_HANDLE hService,
|
||||||
}
|
}
|
||||||
RpcEndExcept;
|
RpcEndExcept;
|
||||||
|
|
||||||
|
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
|
lpStatusPtr = (LPENUM_SERVICE_STATUSW)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)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("REnumDependentServicesW() failed (Error %lu)\n", dwError);
|
ERR("REnumDependentServicesW() failed (Error %lu)\n", dwError);
|
||||||
|
@ -888,20 +908,6 @@ EnumDependentServicesW(SC_HANDLE hService,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
lpStatusPtr = (LPENUM_SERVICE_STATUSW)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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("EnumDependentServicesW() done\n");
|
TRACE("EnumDependentServicesW() done\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1012,6 +1018,23 @@ EnumServicesStatusA(SC_HANDLE hSCManager,
|
||||||
}
|
}
|
||||||
RpcEndExcept;
|
RpcEndExcept;
|
||||||
|
|
||||||
|
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
|
lpStatusPtr = (LPENUM_SERVICE_STATUSA)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_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("REnumServicesStatusA() failed (Error %lu)\n", dwError);
|
ERR("REnumServicesStatusA() failed (Error %lu)\n", dwError);
|
||||||
|
@ -1019,20 +1042,6 @@ EnumServicesStatusA(SC_HANDLE hSCManager,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
lpStatusPtr = (LPENUM_SERVICE_STATUSA)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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("EnumServicesStatusA() done\n");
|
TRACE("EnumServicesStatusA() done\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1083,6 +1092,23 @@ EnumServicesStatusW(SC_HANDLE hSCManager,
|
||||||
}
|
}
|
||||||
RpcEndExcept;
|
RpcEndExcept;
|
||||||
|
|
||||||
|
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
|
lpStatusPtr = (LPENUM_SERVICE_STATUSW)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)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("REnumServicesStatusW() failed (Error %lu)\n", dwError);
|
ERR("REnumServicesStatusW() failed (Error %lu)\n", dwError);
|
||||||
|
@ -1090,20 +1116,6 @@ EnumServicesStatusW(SC_HANDLE hSCManager,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
lpStatusPtr = (LPENUM_SERVICE_STATUSW)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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("EnumServicesStatusW() done\n");
|
TRACE("EnumServicesStatusW() done\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1145,7 +1157,6 @@ EnumServicesStatusExA(SC_HANDLE hSCManager,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RpcTryExcept
|
RpcTryExcept
|
||||||
{
|
{
|
||||||
dwError = REnumServicesStatusExA((SC_RPC_HANDLE)hSCManager,
|
dwError = REnumServicesStatusExA((SC_RPC_HANDLE)hSCManager,
|
||||||
|
@ -1165,13 +1176,7 @@ EnumServicesStatusExA(SC_HANDLE hSCManager,
|
||||||
}
|
}
|
||||||
RpcEndExcept;
|
RpcEndExcept;
|
||||||
|
|
||||||
if (dwError == ERROR_MORE_DATA)
|
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||||
{
|
|
||||||
WARN("Required buffer size %ul\n", *pcbBytesNeeded);
|
|
||||||
SetLastError(dwError);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else if (dwError == ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
|
lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
|
||||||
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
|
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
|
||||||
|
@ -1187,7 +1192,8 @@ EnumServicesStatusExA(SC_HANDLE hSCManager,
|
||||||
lpStatusPtr++;
|
lpStatusPtr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("REnumServicesStatusExA() failed (Error %lu)\n", dwError);
|
ERR("REnumServicesStatusExA() failed (Error %lu)\n", dwError);
|
||||||
SetLastError(dwError);
|
SetLastError(dwError);
|
||||||
|
@ -1242,13 +1248,7 @@ EnumServicesStatusExW(SC_HANDLE hSCManager,
|
||||||
}
|
}
|
||||||
RpcEndExcept;
|
RpcEndExcept;
|
||||||
|
|
||||||
if (dwError == ERROR_MORE_DATA)
|
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
|
||||||
{
|
|
||||||
WARN("Required buffer size %ul\n", *pcbBytesNeeded);
|
|
||||||
SetLastError(dwError);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else if (dwError == ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
|
lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
|
||||||
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
|
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
|
||||||
|
@ -1264,7 +1264,8 @@ EnumServicesStatusExW(SC_HANDLE hSCManager,
|
||||||
lpStatusPtr++;
|
lpStatusPtr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("REnumServicesStatusExW() failed (Error %lu)\n", dwError);
|
ERR("REnumServicesStatusExW() failed (Error %lu)\n", dwError);
|
||||||
SetLastError(dwError);
|
SetLastError(dwError);
|
||||||
|
|
Loading…
Reference in a new issue