[SERVICES]

Remove "size_t to DWORD/int..." conversion warnings in x64 build.
Patch by Hermes Belusca.

I replaced size_t by SIZE_T, as this is the proper Win32 type. And I also used the prefix 'cch' (count of characters) instead of the generic 'dw'.

See issue #7149 for more details.

svn path=/trunk/; revision=57108
This commit is contained in:
Eric Kohl 2012-08-19 10:01:05 +00:00
parent 0813b21bc8
commit 50f30b7887
3 changed files with 126 additions and 124 deletions

View file

@ -98,9 +98,9 @@ ScmWriteDependencies(HKEY hServiceKey,
DWORD dwDependenciesLength) DWORD dwDependenciesLength)
{ {
DWORD dwError = ERROR_SUCCESS; DWORD dwError = ERROR_SUCCESS;
DWORD dwGroupLength = 0; SIZE_T cchGroupLength = 0;
DWORD dwServiceLength = 0; SIZE_T cchServiceLength = 0;
DWORD dwLength; SIZE_T cchLength;
LPWSTR lpGroupDeps; LPWSTR lpGroupDeps;
LPWSTR lpServiceDeps; LPWSTR lpServiceDeps;
LPCWSTR lpSrc; LPCWSTR lpSrc;
@ -125,46 +125,46 @@ ScmWriteDependencies(HKEY hServiceKey,
lpDst = lpGroupDeps; lpDst = lpGroupDeps;
while (*lpSrc != 0) while (*lpSrc != 0)
{ {
dwLength = wcslen(lpSrc) + 1; cchLength = wcslen(lpSrc) + 1;
if (*lpSrc == SC_GROUP_IDENTIFIERW) if (*lpSrc == SC_GROUP_IDENTIFIERW)
{ {
lpSrc++; lpSrc++;
dwGroupLength += dwLength; cchGroupLength += cchLength;
wcscpy(lpDst, lpSrc); wcscpy(lpDst, lpSrc);
lpDst = lpDst + dwLength; lpDst = lpDst + cchLength;
} }
lpSrc = lpSrc + dwLength; lpSrc = lpSrc + cchLength;
} }
*lpDst = 0; *lpDst = 0;
lpDst++; lpDst++;
dwGroupLength++; cchGroupLength++;
lpSrc = lpDependencies; lpSrc = lpDependencies;
lpServiceDeps = lpDst; lpServiceDeps = lpDst;
while (*lpSrc != 0) while (*lpSrc != 0)
{ {
dwLength = wcslen(lpSrc) + 1; cchLength = wcslen(lpSrc) + 1;
if (*lpSrc != SC_GROUP_IDENTIFIERW) if (*lpSrc != SC_GROUP_IDENTIFIERW)
{ {
dwServiceLength += dwLength; cchServiceLength += cchLength;
wcscpy(lpDst, lpSrc); wcscpy(lpDst, lpSrc);
lpDst = lpDst + dwLength; lpDst = lpDst + cchLength;
} }
lpSrc = lpSrc + dwLength; lpSrc = lpSrc + cchLength;
} }
*lpDst = 0; *lpDst = 0;
dwServiceLength++; cchServiceLength++;
if (dwGroupLength > 1) if (cchGroupLength > 1)
{ {
dwError = RegSetValueExW(hServiceKey, dwError = RegSetValueExW(hServiceKey,
L"DependOnGroup", L"DependOnGroup",
0, 0,
REG_MULTI_SZ, REG_MULTI_SZ,
(LPBYTE)lpGroupDeps, (LPBYTE)lpGroupDeps,
dwGroupLength * sizeof(WCHAR)); (DWORD)(cchGroupLength * sizeof(WCHAR)));
} }
else else
{ {
@ -174,14 +174,14 @@ ScmWriteDependencies(HKEY hServiceKey,
if (dwError == ERROR_SUCCESS) if (dwError == ERROR_SUCCESS)
{ {
if (dwServiceLength > 1) if (cchServiceLength > 1)
{ {
dwError = RegSetValueExW(hServiceKey, dwError = RegSetValueExW(hServiceKey,
L"DependOnService", L"DependOnService",
0, 0,
REG_MULTI_SZ, REG_MULTI_SZ,
(LPBYTE)lpServiceDeps, (LPBYTE)lpServiceDeps,
dwServiceLength * sizeof(WCHAR)); (DWORD)(cchServiceLength * sizeof(WCHAR)));
} }
else else
{ {
@ -324,12 +324,12 @@ ScmReadDependencies(HKEY hServiceKey,
{ {
LPWSTR lpGroups = NULL; LPWSTR lpGroups = NULL;
LPWSTR lpServices = NULL; LPWSTR lpServices = NULL;
DWORD dwGroupsLength = 0; SIZE_T cchGroupsLength = 0;
DWORD dwServicesLength = 0; SIZE_T cchServicesLength = 0;
LPWSTR lpSrc; LPWSTR lpSrc;
LPWSTR lpDest; LPWSTR lpDest;
DWORD len; SIZE_T cchLength;
DWORD dwTotalLength; SIZE_T cchTotalLength;
*lpDependencies = NULL; *lpDependencies = NULL;
*lpdwDependenciesLength = 0; *lpdwDependenciesLength = 0;
@ -356,10 +356,10 @@ ScmReadDependencies(HKEY hServiceKey,
{ {
DPRINT(" %S\n", lpSrc); DPRINT(" %S\n", lpSrc);
len = wcslen(lpSrc) + 1; cchLength = wcslen(lpSrc) + 1;
dwGroupsLength += len + 1; cchGroupsLength += cchLength + 1;
lpSrc = lpSrc + len; lpSrc = lpSrc + cchLength;
} }
} }
@ -371,18 +371,18 @@ ScmReadDependencies(HKEY hServiceKey,
{ {
DPRINT(" %S\n", lpSrc); DPRINT(" %S\n", lpSrc);
len = wcslen(lpSrc) + 1; cchLength = wcslen(lpSrc) + 1;
dwServicesLength += len; cchServicesLength += cchLength;
lpSrc = lpSrc + len; lpSrc = lpSrc + cchLength;
} }
} }
dwTotalLength = dwGroupsLength + dwServicesLength + 1; cchTotalLength = cchGroupsLength + cchServicesLength + 1;
DPRINT("dwTotalLength: %lu\n", dwTotalLength); DPRINT("cchTotalLength: %lu\n", cchTotalLength);
/* Allocate the common buffer for the dependencies */ /* Allocate the common buffer for the dependencies */
*lpDependencies = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwTotalLength * sizeof(WCHAR)); *lpDependencies = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cchTotalLength * sizeof(WCHAR));
if (*lpDependencies == NULL) if (*lpDependencies == NULL)
{ {
if (lpGroups) if (lpGroups)
@ -395,7 +395,7 @@ ScmReadDependencies(HKEY hServiceKey,
} }
/* Return the allocated buffer length in characters */ /* Return the allocated buffer length in characters */
*lpdwDependenciesLength = dwTotalLength; *lpdwDependenciesLength = (DWORD)cchTotalLength;
/* Copy the service dependencies into the common buffer */ /* Copy the service dependencies into the common buffer */
lpDest = *lpDependencies; lpDest = *lpDependencies;
@ -403,9 +403,9 @@ ScmReadDependencies(HKEY hServiceKey,
{ {
memcpy(lpDest, memcpy(lpDest,
lpServices, lpServices,
dwServicesLength * sizeof(WCHAR)); cchServicesLength * sizeof(WCHAR));
lpDest = lpDest + dwServicesLength; lpDest = lpDest + cchServicesLength;
} }
/* Copy the group dependencies into the common buffer */ /* Copy the group dependencies into the common buffer */
@ -414,15 +414,15 @@ ScmReadDependencies(HKEY hServiceKey,
lpSrc = lpGroups; lpSrc = lpGroups;
while (*lpSrc != 0) while (*lpSrc != 0)
{ {
len = wcslen(lpSrc) + 1; cchLength = wcslen(lpSrc) + 1;
*lpDest = SC_GROUP_IDENTIFIERW; *lpDest = SC_GROUP_IDENTIFIERW;
lpDest++; lpDest++;
wcscpy(lpDest, lpSrc); wcscpy(lpDest, lpSrc);
lpDest = lpDest + len; lpDest = lpDest + cchLength;
lpSrc = lpSrc + len; lpSrc = lpSrc + cchLength;
} }
} }

View file

@ -902,7 +902,7 @@ ScmControlService(PSERVICE Service,
/* Calculate the total length of the start command line */ /* Calculate the total length of the start command line */
PacketSize = sizeof(SCM_CONTROL_PACKET); PacketSize = sizeof(SCM_CONTROL_PACKET);
PacketSize += (wcslen(Service->lpServiceName) + 1) * sizeof(WCHAR); PacketSize += (DWORD)((wcslen(Service->lpServiceName) + 1) * sizeof(WCHAR));
ControlPacket = HeapAlloc(GetProcessHeap(), ControlPacket = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
@ -1117,7 +1117,7 @@ ScmSendStartCommand(PSERVICE Service,
/* Calculate the total length of the start command line */ /* Calculate the total length of the start command line */
PacketSize = sizeof(SCM_CONTROL_PACKET) + PacketSize = sizeof(SCM_CONTROL_PACKET) +
(wcslen(Service->lpServiceName) + 1) * sizeof(WCHAR); (DWORD)((wcslen(Service->lpServiceName) + 1) * sizeof(WCHAR));
/* Calculate the required packet size for the start arguments */ /* Calculate the required packet size for the start arguments */
if (argc > 0 && argv != NULL) if (argc > 0 && argv != NULL)
@ -1128,7 +1128,7 @@ ScmSendStartCommand(PSERVICE Service,
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
{ {
DPRINT("Argv[%lu]: %S\n", i, argv[i]); DPRINT("Argv[%lu]: %S\n", i, argv[i]);
PacketSize += (wcslen(argv[i]) + 1) * sizeof(WCHAR) + sizeof(PWSTR); PacketSize += (DWORD)((wcslen(argv[i]) + 1) * sizeof(WCHAR) + sizeof(PWSTR));
} }
} }

View file

@ -395,7 +395,8 @@ cleanup:
DWORD DWORD
ScmConvertToBootPathName(wchar_t *CanonName, wchar_t **RelativeName) ScmConvertToBootPathName(wchar_t *CanonName, wchar_t **RelativeName)
{ {
DWORD ServiceNameLen, BufferSize, ExpandedLen; SIZE_T ServiceNameLen, ExpandedLen;
DWORD BufferSize;
WCHAR Dest; WCHAR Dest;
WCHAR *Expanded; WCHAR *Expanded;
UNICODE_STRING NtPathName, SystemRoot, LinkTarget; UNICODE_STRING NtPathName, SystemRoot, LinkTarget;
@ -652,7 +653,8 @@ ScmCanonDriverImagePath(DWORD dwStartType,
const wchar_t *lpServiceName, const wchar_t *lpServiceName,
wchar_t **lpCanonName) wchar_t **lpCanonName)
{ {
DWORD ServiceNameLen, Result; DWORD Result;
SIZE_T ServiceNameLen;
UNICODE_STRING NtServiceName; UNICODE_STRING NtServiceName;
WCHAR *RelativeName; WCHAR *RelativeName;
const WCHAR *SourceName = lpServiceName; const WCHAR *SourceName = lpServiceName;
@ -895,8 +897,8 @@ Int_EnumDependentServicesW(HKEY hServicesKey,
{ {
/* Calculate the required size */ /* Calculate the required size */
dwRequiredSize += sizeof(SERVICE_STATUS); dwRequiredSize += sizeof(SERVICE_STATUS);
dwRequiredSize += ((wcslen(lpCurrentService->lpServiceName) + 1) * sizeof(WCHAR)); dwRequiredSize += (DWORD)((wcslen(lpCurrentService->lpServiceName) + 1) * sizeof(WCHAR));
dwRequiredSize += ((wcslen(lpCurrentService->lpDisplayName) + 1) * sizeof(WCHAR)); dwRequiredSize += (DWORD)((wcslen(lpCurrentService->lpDisplayName) + 1) * sizeof(WCHAR));
/* Add the size for service name and display name pointers */ /* Add the size for service name and display name pointers */
dwRequiredSize += (2 * sizeof(PVOID)); dwRequiredSize += (2 * sizeof(PVOID));
@ -923,7 +925,7 @@ Int_EnumDependentServicesW(HKEY hServicesKey,
} }
} }
dwDependServiceStrPtr += (wcslen(lpszValueBuf + dwDependServiceStrPtr) + 1); dwDependServiceStrPtr += (DWORD)(wcslen(lpszValueBuf + dwDependServiceStrPtr) + 1);
} }
} }
else if (*pcbBytesNeeded) else if (*pcbBytesNeeded)
@ -1813,7 +1815,7 @@ DWORD RChangeServiceConfigW(
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpDisplayName, (LPBYTE)lpDisplayName,
(wcslen(lpDisplayName) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpDisplayName) + 1) * sizeof(WCHAR)));
/* Update the display name */ /* Update the display name */
lpDisplayNameW = HeapAlloc(GetProcessHeap(), lpDisplayNameW = HeapAlloc(GetProcessHeap(),
@ -1896,7 +1898,7 @@ DWORD RChangeServiceConfigW(
0, 0,
REG_EXPAND_SZ, REG_EXPAND_SZ,
(LPBYTE)lpImagePathW, (LPBYTE)lpImagePathW,
(wcslen(lpImagePathW) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpImagePathW) + 1) * sizeof(WCHAR)));
if (lpImagePathW != lpBinaryPathName) if (lpImagePathW != lpBinaryPathName)
HeapFree(GetProcessHeap(), 0, lpImagePathW); HeapFree(GetProcessHeap(), 0, lpImagePathW);
@ -1913,7 +1915,7 @@ DWORD RChangeServiceConfigW(
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpLoadOrderGroup, (LPBYTE)lpLoadOrderGroup,
(wcslen(lpLoadOrderGroup) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpLoadOrderGroup) + 1) * sizeof(WCHAR)));
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto done; goto done;
@ -2183,7 +2185,7 @@ DWORD RCreateServiceW(
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpDisplayName, (LPBYTE)lpDisplayName,
(wcslen(lpDisplayName) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpDisplayName) + 1) * sizeof(WCHAR)));
} }
/* Set the service type */ /* Set the service type */
@ -2224,7 +2226,7 @@ DWORD RCreateServiceW(
0, 0,
REG_EXPAND_SZ, REG_EXPAND_SZ,
(LPBYTE)lpBinaryPathName, (LPBYTE)lpBinaryPathName,
(wcslen(lpBinaryPathName) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpBinaryPathName) + 1) * sizeof(WCHAR)));
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto done; goto done;
} }
@ -2235,7 +2237,7 @@ DWORD RCreateServiceW(
0, 0,
REG_EXPAND_SZ, REG_EXPAND_SZ,
(LPBYTE)lpImagePath, (LPBYTE)lpImagePath,
(wcslen(lpImagePath) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpImagePath) + 1) * sizeof(WCHAR)));
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto done; goto done;
} }
@ -2248,7 +2250,7 @@ DWORD RCreateServiceW(
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpLoadOrderGroup, (LPBYTE)lpLoadOrderGroup,
(wcslen(lpLoadOrderGroup) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpLoadOrderGroup) + 1) * sizeof(WCHAR)));
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto done; goto done;
} }
@ -2284,7 +2286,7 @@ DWORD RCreateServiceW(
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpObjectName, (LPBYTE)lpObjectName,
(wcslen(lpObjectName) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpObjectName) + 1) * sizeof(WCHAR)));
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto done; goto done;
} }
@ -2716,12 +2718,12 @@ DWORD RQueryServiceConfigW(
dwRequiredSize = sizeof(QUERY_SERVICE_CONFIGW); dwRequiredSize = sizeof(QUERY_SERVICE_CONFIGW);
if (lpImagePath != NULL) if (lpImagePath != NULL)
dwRequiredSize += ((wcslen(lpImagePath) + 1) * sizeof(WCHAR)); dwRequiredSize += (DWORD)((wcslen(lpImagePath) + 1) * sizeof(WCHAR));
else else
dwRequiredSize += 2 * sizeof(WCHAR); dwRequiredSize += 2 * sizeof(WCHAR);
if (lpService->lpGroup != NULL) if (lpService->lpGroup != NULL)
dwRequiredSize += ((wcslen(lpService->lpGroup->lpGroupName) + 1) * sizeof(WCHAR)); dwRequiredSize += (DWORD)((wcslen(lpService->lpGroup->lpGroupName) + 1) * sizeof(WCHAR));
else else
dwRequiredSize += 2 * sizeof(WCHAR); dwRequiredSize += 2 * sizeof(WCHAR);
@ -2731,12 +2733,12 @@ DWORD RQueryServiceConfigW(
dwRequiredSize += 2 * sizeof(WCHAR); dwRequiredSize += 2 * sizeof(WCHAR);
if (lpServiceStartName != NULL) if (lpServiceStartName != NULL)
dwRequiredSize += ((wcslen(lpServiceStartName) + 1) * sizeof(WCHAR)); dwRequiredSize += (DWORD)((wcslen(lpServiceStartName) + 1) * sizeof(WCHAR));
else else
dwRequiredSize += 2 * sizeof(WCHAR); dwRequiredSize += 2 * sizeof(WCHAR);
if (lpService->lpDisplayName != NULL) if (lpService->lpDisplayName != NULL)
dwRequiredSize += ((wcslen(lpService->lpDisplayName) + 1) * sizeof(WCHAR)); dwRequiredSize += (DWORD)((wcslen(lpService->lpDisplayName) + 1) * sizeof(WCHAR));
else else
dwRequiredSize += 2 * sizeof(WCHAR); dwRequiredSize += 2 * sizeof(WCHAR);
@ -2995,7 +2997,7 @@ DWORD RGetServiceDisplayNameW(
*lpcchBuffer = 2; *lpcchBuffer = 2;
if (lpDisplayName != NULL) if (lpDisplayName != NULL)
{ {
*lpDisplayName = '\0'; *lpDisplayName = 0;
} }
} }
@ -3004,7 +3006,7 @@ DWORD RGetServiceDisplayNameW(
if (!lpService->lpDisplayName) if (!lpService->lpDisplayName)
{ {
dwLength = wcslen(lpService->lpServiceName); dwLength = (DWORD)wcslen(lpService->lpServiceName);
if (lpDisplayName != NULL && if (lpDisplayName != NULL &&
*lpcchBuffer > dwLength) *lpcchBuffer > dwLength)
@ -3014,7 +3016,7 @@ DWORD RGetServiceDisplayNameW(
} }
else else
{ {
dwLength = wcslen(lpService->lpDisplayName); dwLength = (DWORD)wcslen(lpService->lpDisplayName);
if (lpDisplayName != NULL && if (lpDisplayName != NULL &&
*lpcchBuffer > dwLength) *lpcchBuffer > dwLength)
@ -3069,14 +3071,14 @@ DWORD RGetServiceKeyNameW(
*lpcchBuffer = 2; *lpcchBuffer = 2;
if (lpServiceName != NULL) if (lpServiceName != NULL)
{ {
*lpServiceName = '\0'; *lpServiceName = 0;
} }
} }
return ERROR_SERVICE_DOES_NOT_EXIST; return ERROR_SERVICE_DOES_NOT_EXIST;
} }
dwLength = wcslen(lpService->lpServiceName); dwLength = (DWORD)wcslen(lpService->lpServiceName);
if (lpServiceName != NULL && if (lpServiceName != NULL &&
*lpcchBuffer > dwLength) *lpcchBuffer > dwLength)
@ -3202,14 +3204,14 @@ DWORD RChangeServiceConfigA(
lpDisplayName, lpDisplayName,
-1, -1,
lpDisplayNameW, lpDisplayNameW,
strlen(lpDisplayName) + 1); (int)(strlen(lpDisplayName) + 1));
RegSetValueExW(hServiceKey, RegSetValueExW(hServiceKey,
L"DisplayName", L"DisplayName",
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpDisplayNameW, (LPBYTE)lpDisplayNameW,
(wcslen(lpDisplayNameW) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpDisplayNameW) + 1) * sizeof(WCHAR)));
/* Update lpService->lpDisplayName */ /* Update lpService->lpDisplayName */
if (lpService->lpDisplayName) if (lpService->lpDisplayName)
@ -3280,7 +3282,7 @@ DWORD RChangeServiceConfigA(
lpBinaryPathName, lpBinaryPathName,
-1, -1,
lpBinaryPathNameW, lpBinaryPathNameW,
strlen(lpBinaryPathName) + 1); (int)(strlen(lpBinaryPathName) + 1));
if (lpService->Status.dwServiceType & SERVICE_DRIVER) if (lpService->Status.dwServiceType & SERVICE_DRIVER)
{ {
@ -3301,7 +3303,7 @@ DWORD RChangeServiceConfigA(
0, 0,
REG_EXPAND_SZ, REG_EXPAND_SZ,
(LPBYTE)lpBinaryPathNameW, (LPBYTE)lpBinaryPathNameW,
(wcslen(lpBinaryPathNameW) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpBinaryPathNameW) + 1) * sizeof(WCHAR)));
HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW); HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
@ -3326,14 +3328,14 @@ DWORD RChangeServiceConfigA(
lpLoadOrderGroup, lpLoadOrderGroup,
-1, -1,
lpLoadOrderGroupW, lpLoadOrderGroupW,
strlen(lpLoadOrderGroup) + 1); (int)(strlen(lpLoadOrderGroup) + 1));
dwError = RegSetValueExW(hServiceKey, dwError = RegSetValueExW(hServiceKey,
L"Group", L"Group",
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpLoadOrderGroupW, (LPBYTE)lpLoadOrderGroupW,
(wcslen(lpLoadOrderGroupW) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpLoadOrderGroupW) + 1) * sizeof(WCHAR)));
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
{ {
HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW); HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
@ -3384,7 +3386,7 @@ DWORD RChangeServiceConfigA(
lpDependencies, lpDependencies,
dwDependSize, dwDependSize,
lpDependenciesW, lpDependenciesW,
strlen(lpDependencies) + 1); (int)(strlen(lpDependencies) + 1));
dwError = ScmWriteDependencies(hServiceKey, dwError = ScmWriteDependencies(hServiceKey,
(LPWSTR)lpDependenciesW, (LPWSTR)lpDependenciesW,
@ -3438,7 +3440,7 @@ DWORD RCreateServiceA(
LPWSTR lpDependenciesW = NULL; LPWSTR lpDependenciesW = NULL;
LPWSTR lpServiceStartNameW = NULL; LPWSTR lpServiceStartNameW = NULL;
DWORD dwDependenciesLength = 0; DWORD dwDependenciesLength = 0;
DWORD dwLength; SIZE_T cchLength;
int len; int len;
LPCSTR lpStr; LPCSTR lpStr;
@ -3495,9 +3497,9 @@ DWORD RCreateServiceA(
lpStr = (LPCSTR)lpDependencies; lpStr = (LPCSTR)lpDependencies;
while (*lpStr) while (*lpStr)
{ {
dwLength = strlen(lpStr) + 1; cchLength = strlen(lpStr) + 1;
dwDependenciesLength += dwLength; dwDependenciesLength += (DWORD)cchLength;
lpStr = lpStr + dwLength; lpStr = lpStr + cchLength;
} }
dwDependenciesLength++; dwDependenciesLength++;
@ -3679,7 +3681,7 @@ DWORD REnumDependentServicesA(
lpService->lpDisplayName, lpService->lpDisplayName,
-1, -1,
lpStr, lpStr,
wcslen(lpService->lpDisplayName), (int)wcslen(lpService->lpDisplayName),
0, 0,
0); 0);
lpServicesPtr->lpDisplayName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServices); lpServicesPtr->lpDisplayName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServices);
@ -3691,7 +3693,7 @@ DWORD REnumDependentServicesA(
lpService->lpServiceName, lpService->lpServiceName,
-1, -1,
lpStr, lpStr,
wcslen(lpService->lpServiceName), (int)wcslen(lpService->lpServiceName),
0, 0,
0); 0);
lpServicesPtr->lpServiceName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServices); lpServicesPtr->lpServiceName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServices);
@ -3773,7 +3775,7 @@ DWORD REnumServicesStatusA(
lpStringPtrW, lpStringPtrW,
-1, -1,
lpStringPtrA, lpStringPtrA,
wcslen(lpStringPtrW), (int)wcslen(lpStringPtrW),
0, 0,
0); 0);
@ -3787,7 +3789,7 @@ DWORD REnumServicesStatusA(
lpStringPtrW, lpStringPtrW,
-1, -1,
lpStringPtrA, lpStringPtrA,
wcslen(lpStringPtrW), (int)wcslen(lpStringPtrW),
0, 0,
0); 0);
@ -3954,12 +3956,12 @@ DWORD RQueryServiceConfigA(
dwRequiredSize = sizeof(QUERY_SERVICE_CONFIGA); dwRequiredSize = sizeof(QUERY_SERVICE_CONFIGA);
if (lpImagePath != NULL) if (lpImagePath != NULL)
dwRequiredSize += wcslen(lpImagePath) + 1; dwRequiredSize += (DWORD)(wcslen(lpImagePath) + 1);
else else
dwRequiredSize += 2; dwRequiredSize += 2;
if ((lpService->lpGroup != NULL) && (lpService->lpGroup->lpGroupName != NULL)) if ((lpService->lpGroup != NULL) && (lpService->lpGroup->lpGroupName != NULL))
dwRequiredSize += wcslen(lpService->lpGroup->lpGroupName) + 1; dwRequiredSize += (DWORD)(wcslen(lpService->lpGroup->lpGroupName) + 1);
else else
dwRequiredSize += 2; dwRequiredSize += 2;
@ -3970,12 +3972,12 @@ DWORD RQueryServiceConfigA(
dwRequiredSize += 2; dwRequiredSize += 2;
if (lpServiceStartName != NULL) if (lpServiceStartName != NULL)
dwRequiredSize += wcslen(lpServiceStartName) + 1; dwRequiredSize += (DWORD)(wcslen(lpServiceStartName) + 1);
else else
dwRequiredSize += 2; dwRequiredSize += 2;
if (lpService->lpDisplayName != NULL) if (lpService->lpDisplayName != NULL)
dwRequiredSize += wcslen(lpService->lpDisplayName) + 1; dwRequiredSize += (DWORD)(wcslen(lpService->lpDisplayName) + 1);
else else
dwRequiredSize += 2; dwRequiredSize += 2;
@ -4003,7 +4005,7 @@ DWORD RQueryServiceConfigA(
lpImagePath, lpImagePath,
-1, -1,
lpStr, lpStr,
wcslen(lpImagePath) + 1, (int)(wcslen(lpImagePath) + 1),
0, 0,
0); 0);
} }
@ -4022,7 +4024,7 @@ DWORD RQueryServiceConfigA(
lpService->lpGroup->lpGroupName, lpService->lpGroup->lpGroupName,
-1, -1,
lpStr, lpStr,
wcslen(lpService->lpGroup->lpGroupName) + 1, (int)(wcslen(lpService->lpGroup->lpGroupName) + 1),
0, 0,
0); 0);
} }
@ -4064,7 +4066,7 @@ DWORD RQueryServiceConfigA(
lpServiceStartName, lpServiceStartName,
-1, -1,
lpStr, lpStr,
wcslen(lpServiceStartName) + 1, (int)(wcslen(lpServiceStartName) + 1),
0, 0,
0); 0);
} }
@ -4083,7 +4085,7 @@ DWORD RQueryServiceConfigA(
lpService->lpDisplayName, lpService->lpDisplayName,
-1, -1,
lpStr, lpStr,
wcslen(lpService->lpDisplayName) + 1, (int)(wcslen(lpService->lpDisplayName) + 1),
0, 0,
0); 0);
} }
@ -4298,7 +4300,7 @@ DWORD RGetServiceDisplayNameA(
if (lpServiceName != NULL) if (lpServiceName != NULL)
{ {
dwLength = strlen(lpServiceName) + 1; dwLength = (DWORD)(strlen(lpServiceName) + 1);
lpServiceNameW = HeapAlloc(GetProcessHeap(), lpServiceNameW = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
dwLength * sizeof(WCHAR)); dwLength * sizeof(WCHAR));
@ -4328,7 +4330,7 @@ DWORD RGetServiceDisplayNameA(
*lpcchBuffer = 1; *lpcchBuffer = 1;
if (lpDisplayName != NULL) if (lpDisplayName != NULL)
{ {
*lpDisplayName = '\0'; *lpDisplayName = 0;
} }
} }
return ERROR_SERVICE_DOES_NOT_EXIST; return ERROR_SERVICE_DOES_NOT_EXIST;
@ -4336,14 +4338,14 @@ DWORD RGetServiceDisplayNameA(
if (!lpService->lpDisplayName) if (!lpService->lpDisplayName)
{ {
dwLength = wcslen(lpService->lpServiceName); dwLength = (DWORD)wcslen(lpService->lpServiceName);
if (lpDisplayName != NULL && if (lpDisplayName != NULL &&
*lpcchBuffer > dwLength) *lpcchBuffer > dwLength)
{ {
WideCharToMultiByte(CP_ACP, WideCharToMultiByte(CP_ACP,
0, 0,
lpService->lpServiceName, lpService->lpServiceName,
wcslen(lpService->lpServiceName), (int)wcslen(lpService->lpServiceName),
lpDisplayName, lpDisplayName,
dwLength + 1, dwLength + 1,
NULL, NULL,
@ -4353,14 +4355,14 @@ DWORD RGetServiceDisplayNameA(
} }
else else
{ {
dwLength = wcslen(lpService->lpDisplayName); dwLength = (DWORD)wcslen(lpService->lpDisplayName);
if (lpDisplayName != NULL && if (lpDisplayName != NULL &&
*lpcchBuffer > dwLength) *lpcchBuffer > dwLength)
{ {
WideCharToMultiByte(CP_ACP, WideCharToMultiByte(CP_ACP,
0, 0,
lpService->lpDisplayName, lpService->lpDisplayName,
wcslen(lpService->lpDisplayName), (int)wcslen(lpService->lpDisplayName),
lpDisplayName, lpDisplayName,
dwLength + 1, dwLength + 1,
NULL, NULL,
@ -4395,7 +4397,7 @@ DWORD RGetServiceKeyNameA(
DPRINT("lpServiceName: %p\n", lpServiceName); DPRINT("lpServiceName: %p\n", lpServiceName);
DPRINT("*lpcchBuffer: %lu\n", *lpcchBuffer); DPRINT("*lpcchBuffer: %lu\n", *lpcchBuffer);
dwLength = strlen(lpDisplayName) + 1; dwLength = (DWORD)(strlen(lpDisplayName) + 1);
lpDisplayNameW = HeapAlloc(GetProcessHeap(), lpDisplayNameW = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
dwLength * sizeof(WCHAR)); dwLength * sizeof(WCHAR));
@ -4424,21 +4426,21 @@ DWORD RGetServiceKeyNameA(
*lpcchBuffer = 1; *lpcchBuffer = 1;
if (lpServiceName != NULL) if (lpServiceName != NULL)
{ {
*lpServiceName = '\0'; *lpServiceName = 0;
} }
} }
return ERROR_SERVICE_DOES_NOT_EXIST; return ERROR_SERVICE_DOES_NOT_EXIST;
} }
dwLength = wcslen(lpService->lpServiceName); dwLength = (DWORD)wcslen(lpService->lpServiceName);
if (lpServiceName != NULL && if (lpServiceName != NULL &&
*lpcchBuffer > dwLength) *lpcchBuffer > dwLength)
{ {
WideCharToMultiByte(CP_ACP, WideCharToMultiByte(CP_ACP,
0, 0,
lpService->lpServiceName, lpService->lpServiceName,
wcslen(lpService->lpServiceName), (int)wcslen(lpService->lpServiceName),
lpServiceName, lpServiceName,
dwLength + 1, dwLength + 1,
NULL, NULL,
@ -4578,8 +4580,8 @@ DWORD REnumServiceGroupW(
} }
dwSize = sizeof(ENUM_SERVICE_STATUSW) + dwSize = sizeof(ENUM_SERVICE_STATUSW) +
((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) + (DWORD)((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) +
((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR));
if (dwRequiredSize + dwSize > cbBufSize) if (dwRequiredSize + dwSize > cbBufSize)
{ {
@ -4630,8 +4632,8 @@ DWORD REnumServiceGroupW(
} }
dwRequiredSize += (sizeof(ENUM_SERVICE_STATUSW) + dwRequiredSize += (sizeof(ENUM_SERVICE_STATUSW) +
((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) + (DWORD)((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) +
((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR))); (DWORD)((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR)));
dwError = ERROR_MORE_DATA; dwError = ERROR_MORE_DATA;
} }
@ -4683,8 +4685,8 @@ DWORD REnumServiceGroupW(
} }
dwSize = sizeof(ENUM_SERVICE_STATUSW) + dwSize = sizeof(ENUM_SERVICE_STATUSW) +
((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) + (DWORD)((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) +
((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR));
if (dwRequiredSize + dwSize > cbBufSize) if (dwRequiredSize + dwSize > cbBufSize)
break; break;
@ -4751,7 +4753,7 @@ DWORD RChangeServiceConfig2A(
///if (lpServiceDescriptonA && ///if (lpServiceDescriptonA &&
///lpServiceDescriptonA->lpDescription) ///lpServiceDescriptonA->lpDescription)
///{ ///{
dwLength = (strlen(Info.lpDescription) + 1) * sizeof(WCHAR); dwLength = (DWORD)((strlen(Info.lpDescription) + 1) * sizeof(WCHAR));
lpServiceDescriptonW = HeapAlloc(GetProcessHeap(), lpServiceDescriptonW = HeapAlloc(GetProcessHeap(),
0, 0,
@ -4787,11 +4789,11 @@ DWORD RChangeServiceConfig2A(
{ {
if (lpServiceFailureActionsA->lpRebootMsg) if (lpServiceFailureActionsA->lpRebootMsg)
{ {
dwRebootLen = (strlen(lpServiceFailureActionsA->lpRebootMsg) + 1) * sizeof(WCHAR); dwRebootLen = (DWORD)((strlen(lpServiceFailureActionsA->lpRebootMsg) + 1) * sizeof(WCHAR));
} }
if (lpServiceFailureActionsA->lpCommand) if (lpServiceFailureActionsA->lpCommand)
{ {
dwCommandLen = (strlen(lpServiceFailureActionsA->lpCommand) + 1) * sizeof(WCHAR); dwCommandLen = (DWORD)((strlen(lpServiceFailureActionsA->lpCommand) + 1) * sizeof(WCHAR));
} }
dwLength = dwRebootLen + dwCommandLen + sizeof(SERVICE_FAILURE_ACTIONSW); dwLength = dwRebootLen + dwCommandLen + sizeof(SERVICE_FAILURE_ACTIONSW);
@ -5068,7 +5070,7 @@ ScmSetFailureActions(PSERVICE_HANDLE hSvc,
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpFailureActions->lpRebootMsg, (LPBYTE)lpFailureActions->lpRebootMsg,
(wcslen(lpFailureActions->lpRebootMsg) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpFailureActions->lpRebootMsg) + 1) * sizeof(WCHAR)));
} }
} }
@ -5089,7 +5091,7 @@ ScmSetFailureActions(PSERVICE_HANDLE hSvc,
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpFailureActions->lpCommand, (LPBYTE)lpFailureActions->lpCommand,
(wcslen(lpFailureActions->lpCommand) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpFailureActions->lpCommand) + 1) * sizeof(WCHAR)));
} }
} }
} }
@ -5184,7 +5186,7 @@ DWORD RChangeServiceConfig2W(
0, 0,
REG_SZ, REG_SZ,
(LPBYTE)lpServiceDescription->lpDescription, (LPBYTE)lpServiceDescription->lpDescription,
(wcslen(lpServiceDescription->lpDescription) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(lpServiceDescription->lpDescription) + 1) * sizeof(WCHAR)));
} }
} }
else else
@ -5283,7 +5285,7 @@ DWORD RQueryServiceConfig2A(
*pcbBytesNeeded = sizeof(SERVICE_DESCRIPTIONA); *pcbBytesNeeded = sizeof(SERVICE_DESCRIPTIONA);
if (dwError == ERROR_SUCCESS) if (dwError == ERROR_SUCCESS)
*pcbBytesNeeded += ((wcslen(lpDescriptionW) + 1) * sizeof(WCHAR)); *pcbBytesNeeded += (DWORD)((wcslen(lpDescriptionW) + 1) * sizeof(WCHAR));
if (cbBufSize < *pcbBytesNeeded) if (cbBufSize < *pcbBytesNeeded)
{ {
@ -5300,7 +5302,7 @@ DWORD RQueryServiceConfig2A(
lpDescriptionW, lpDescriptionW,
-1, -1,
lpStr, lpStr,
wcslen(lpDescriptionW), (int)wcslen(lpDescriptionW),
NULL, NULL,
NULL); NULL);
lpServiceDescription->lpDescription = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceDescription); lpServiceDescription->lpDescription = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceDescription);
@ -5341,10 +5343,10 @@ DWORD RQueryServiceConfig2A(
&lpRebootMessageW); &lpRebootMessageW);
if (lpRebootMessageW) if (lpRebootMessageW)
dwRequiredSize += (wcslen(lpRebootMessageW) + 1) * sizeof(WCHAR); dwRequiredSize += (DWORD)((wcslen(lpRebootMessageW) + 1) * sizeof(WCHAR));
if (lpFailureCommandW) if (lpFailureCommandW)
dwRequiredSize += (wcslen(lpFailureCommandW) + 1) * sizeof(WCHAR); dwRequiredSize += (DWORD)((wcslen(lpFailureCommandW) + 1) * sizeof(WCHAR));
if (cbBufSize < dwRequiredSize) if (cbBufSize < dwRequiredSize)
{ {
@ -5404,7 +5406,7 @@ DWORD RQueryServiceConfig2A(
lpRebootMessageW, lpRebootMessageW,
-1, -1,
lpStr, lpStr,
wcslen(lpRebootMessageW), (int)wcslen(lpRebootMessageW),
NULL, NULL,
NULL); NULL);
lpFailureActions->lpRebootMsg = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpFailureActions); lpFailureActions->lpRebootMsg = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpFailureActions);
@ -5418,7 +5420,7 @@ DWORD RQueryServiceConfig2A(
lpFailureCommandW, lpFailureCommandW,
-1, -1,
lpStr, lpStr,
wcslen(lpFailureCommandW), (int)wcslen(lpFailureCommandW),
NULL, NULL,
NULL); NULL);
lpFailureActions->lpCommand = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpFailureActions); lpFailureActions->lpCommand = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpFailureActions);
@ -5519,7 +5521,7 @@ DWORD RQueryServiceConfig2W(
*pcbBytesNeeded = sizeof(SERVICE_DESCRIPTIONW); *pcbBytesNeeded = sizeof(SERVICE_DESCRIPTIONW);
if (dwError == ERROR_SUCCESS) if (dwError == ERROR_SUCCESS)
*pcbBytesNeeded += ((wcslen(lpDescription) + 1) * sizeof(WCHAR)); *pcbBytesNeeded += (DWORD)((wcslen(lpDescription) + 1) * sizeof(WCHAR));
if (cbBufSize < *pcbBytesNeeded) if (cbBufSize < *pcbBytesNeeded)
{ {
@ -5569,10 +5571,10 @@ DWORD RQueryServiceConfig2W(
&lpRebootMessage); &lpRebootMessage);
if (lpRebootMessage) if (lpRebootMessage)
dwRequiredSize += (wcslen(lpRebootMessage) + 1) * sizeof(WCHAR); dwRequiredSize += (DWORD)((wcslen(lpRebootMessage) + 1) * sizeof(WCHAR));
if (lpFailureCommand) if (lpFailureCommand)
dwRequiredSize += (wcslen(lpFailureCommand) + 1) * sizeof(WCHAR); dwRequiredSize += (DWORD)((wcslen(lpFailureCommand) + 1) * sizeof(WCHAR));
if (cbBufSize < dwRequiredSize) if (cbBufSize < dwRequiredSize)
{ {
@ -5768,7 +5770,7 @@ DWORD REnumServicesStatusExA(
pszGroupName, pszGroupName,
-1, -1,
pszGroupNameW, pszGroupNameW,
strlen(pszGroupName) + 1); (int)(strlen(pszGroupName) + 1));
} }
if ((cbBufSize > 0) && (lpBuffer)) if ((cbBufSize > 0) && (lpBuffer))
@ -5811,7 +5813,7 @@ DWORD REnumServicesStatusExA(
lpStringPtrW, lpStringPtrW,
-1, -1,
lpStringPtrA, lpStringPtrA,
wcslen(lpStringPtrW), (int)wcslen(lpStringPtrW),
0, 0,
0); 0);
@ -5825,7 +5827,7 @@ DWORD REnumServicesStatusExA(
lpStringPtrW, lpStringPtrW,
-1, -1,
lpStringPtrA, lpStringPtrA,
wcslen(lpStringPtrW), (int)wcslen(lpStringPtrW),
0, 0,
0); 0);
@ -5975,8 +5977,8 @@ DWORD REnumServicesStatusExW(
} }
dwSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW) + dwSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW) +
((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) + (DWORD)((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) +
((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR));
if (dwRequiredSize + dwSize <= cbBufSize) if (dwRequiredSize + dwSize <= cbBufSize)
{ {
@ -6030,8 +6032,8 @@ DWORD REnumServicesStatusExW(
} }
dwRequiredSize += (sizeof(ENUM_SERVICE_STATUS_PROCESSW) + dwRequiredSize += (sizeof(ENUM_SERVICE_STATUS_PROCESSW) +
((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) + (DWORD)((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) +
((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR))); (DWORD)((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR)));
dwError = ERROR_MORE_DATA; dwError = ERROR_MORE_DATA;
} }
@ -6090,8 +6092,8 @@ DWORD REnumServicesStatusExW(
} }
dwSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW) + dwSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW) +
((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) + (DWORD)((wcslen(CurrentService->lpServiceName) + 1) * sizeof(WCHAR)) +
((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR)); (DWORD)((wcslen(CurrentService->lpDisplayName) + 1) * sizeof(WCHAR));
if (dwRequiredSize + dwSize <= cbBufSize) if (dwRequiredSize + dwSize <= cbBufSize)
{ {