Author: ekohl Date: Sat Feb 6 15:10:18 2010 New Revision: 45459
URL: http://svn.reactos.org/svn/reactos?rev=45459&view=rev Log: Convert offset to pointers when enumeration functions return ERROR_SUCCESS or ERROR_MORE_DATA because there is something to convert in both cases.
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 [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] Sat Feb 6 15:10:18 2010 @@ -820,25 +820,28 @@ } 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) { ERR("REnumDependentServicesA() failed (Error %lu)\n", dwError); SetLastError(dwError); 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"); @@ -881,25 +884,28 @@ } 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) { ERR("REnumDependentServicesW() failed (Error %lu)\n", dwError); SetLastError(dwError); 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"); @@ -1012,25 +1018,28 @@ } 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) { ERR("REnumServicesStatusA() failed (Error %lu)\n", dwError); SetLastError(dwError); 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"); @@ -1083,25 +1092,28 @@ } 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) { ERR("REnumServicesStatusW() failed (Error %lu)\n", dwError); SetLastError(dwError); 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"); @@ -1145,7 +1157,6 @@ return FALSE; }
- RpcTryExcept { dwError = REnumServicesStatusExA((SC_RPC_HANDLE)hSCManager, @@ -1165,13 +1176,7 @@ } RpcEndExcept;
- if (dwError == ERROR_MORE_DATA) - { - WARN("Required buffer size %ul\n", *pcbBytesNeeded); - SetLastError(dwError); - return FALSE; - } - else if (dwError == ERROR_SUCCESS) + if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA) { lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices; for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) @@ -1187,7 +1192,8 @@ lpStatusPtr++; } } - else + + if (dwError != ERROR_SUCCESS) { ERR("REnumServicesStatusExA() failed (Error %lu)\n", dwError); SetLastError(dwError); @@ -1242,13 +1248,7 @@ } RpcEndExcept;
- if (dwError == ERROR_MORE_DATA) - { - WARN("Required buffer size %ul\n", *pcbBytesNeeded); - SetLastError(dwError); - return FALSE; - } - else if (dwError == ERROR_SUCCESS) + if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA) { lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices; for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++) @@ -1264,7 +1264,8 @@ lpStatusPtr++; } } - else + + if (dwError != ERROR_SUCCESS) { ERR("REnumServicesStatusExW() failed (Error %lu)\n", dwError); SetLastError(dwError);