/* Get buffer size needed for expanding env strings */
BufferSize = ExpandEnvironmentStringsW(L"%SystemRoot%\\", &Dest, 1);
-
if (BufferSize <= 1)
{
DPRINT("Error during a call to ExpandEnvironmentStringsW()\n");
&pcbBytesNeeded,
&dwServicesReturned);
- /* if pcbBytesNeeded returned a value then there are services running that are dependent on this service */
+ /* If pcbBytesNeeded returned a value then there are services running that are dependent on this service */
if (pcbBytesNeeded)
{
DPRINT("Deletion failed due to running dependencies.\n");
if (dwSecurityInformation == 0 ||
dwSecurityInformation & ~(OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION))
+ {
return ERROR_INVALID_PARAMETER;
+ }
if (!RtlValidSecurityDescriptor((PSECURITY_DESCRIPTOR)lpSecurityDescriptor))
return ERROR_INVALID_PARAMETER;
if ((dwSecurityInformation & OWNER_SECURITY_INFORMATION) &&
(((PISECURITY_DESCRIPTOR)lpSecurityDescriptor)->Owner == NULL))
+ {
return ERROR_INVALID_PARAMETER;
+ }
if ((dwSecurityInformation & GROUP_SECURITY_INFORMATION) &&
(((PISECURITY_DESCRIPTOR)lpSecurityDescriptor)->Group == NULL))
+ {
return ERROR_INVALID_PARAMETER;
+ }
if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
DesiredAccess))
(dwServiceType != SERVICE_FILE_SYSTEM_DRIVER) &&
((dwServiceType & ~SERVICE_INTERACTIVE_PROCESS) != SERVICE_WIN32_OWN_PROCESS) &&
((dwServiceType & ~SERVICE_INTERACTIVE_PROCESS) != SERVICE_WIN32_SHARE_PROCESS))
- return ERROR_INVALID_PARAMETER;
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
/* Check for invalid start type value */
if ((dwStartType != SERVICE_NO_CHANGE) &&
(dwStartType != SERVICE_AUTO_START) &&
(dwStartType != SERVICE_DEMAND_START) &&
(dwStartType != SERVICE_DISABLED))
+ {
return ERROR_INVALID_PARAMETER;
+ }
/* Only drivers can be boot start or system start services */
if ((dwStartType == SERVICE_BOOT_START) ||
(dwErrorControl != SERVICE_ERROR_NORMAL) &&
(dwErrorControl != SERVICE_ERROR_SEVERE) &&
(dwErrorControl != SERVICE_ERROR_CRITICAL))
+ {
return ERROR_INVALID_PARAMETER;
+ }
if (lpdwTagId && (!lpLoadOrderGroup || !*lpLoadOrderGroup))
{
if (lpPassword != NULL)
{
- if (wcslen((LPWSTR)lpPassword) != 0)
+ if (*(LPWSTR)lpPassword != 0)
{
/* FIXME: Decrypt the password */
return ERROR_ACCESS_DENIED;
}
- if (wcslen(lpServiceName) == 0)
- {
+ if (*lpServiceName == 0)
return ERROR_INVALID_NAME;
- }
- if (wcslen(lpBinaryPathName) == 0)
- {
+ if (*lpBinaryPathName == 0)
return ERROR_INVALID_PARAMETER;
- }
/* Check for invalid service type value */
if ((dwServiceType != SERVICE_KERNEL_DRIVER) &&
(dwServiceType != SERVICE_FILE_SYSTEM_DRIVER) &&
((dwServiceType & ~SERVICE_INTERACTIVE_PROCESS) != SERVICE_WIN32_OWN_PROCESS) &&
((dwServiceType & ~SERVICE_INTERACTIVE_PROCESS) != SERVICE_WIN32_SHARE_PROCESS))
- return ERROR_INVALID_PARAMETER;
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
/* Check for invalid start type value */
if ((dwStartType != SERVICE_BOOT_START) &&
(dwStartType != SERVICE_AUTO_START) &&
(dwStartType != SERVICE_DEMAND_START) &&
(dwStartType != SERVICE_DISABLED))
+ {
return ERROR_INVALID_PARAMETER;
+ }
/* Only drivers can be boot start or system start services */
if ((dwStartType == SERVICE_BOOT_START) ||
{
if ((dwServiceType != SERVICE_KERNEL_DRIVER) &&
(dwServiceType != SERVICE_FILE_SYSTEM_DRIVER))
+ {
return ERROR_INVALID_PARAMETER;
+ }
}
/* Check for invalid error control value */
(dwErrorControl != SERVICE_ERROR_NORMAL) &&
(dwErrorControl != SERVICE_ERROR_SEVERE) &&
(dwErrorControl != SERVICE_ERROR_CRITICAL))
+ {
return ERROR_INVALID_PARAMETER;
+ }
if ((dwServiceType == (SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS)) &&
(lpServiceStartName))
if (lpService->bDeleted)
return ERROR_SERVICE_MARKED_FOR_DELETE;
- /* Return Error exist */
+ /* Return service-exists error */
return ERROR_SERVICE_EXISTS;
}
if (dwError != ERROR_SUCCESS)
goto done;
- if (lpPassword != NULL && wcslen((LPWSTR)lpPassword) != 0)
+ if (lpPassword != NULL && *(LPWSTR)lpPassword != 0)
{
/* FIXME: Decrypt the password */
LPWSTR lpDependencies = NULL;
DWORD dwDependenciesLength = 0;
DWORD dwRequiredSize;
- WCHAR lpEmptyString[] = {0,0};
LPWSTR lpStr;
DPRINT("RQueryServiceConfigW() called\n");
}
else
{
- wcscpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpBinaryPathName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
}
else
{
- wcscpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpLoadOrderGroup = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
}
else
{
- wcscpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpDependencies = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
}
else
{
- wcscpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpServiceStartName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
}
else
{
- wcscpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpDisplayName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
/* If the service could not be found and lpcchBuffer is less than 2, windows
puts null in lpDisplayName and puts 2 in lpcchBuffer */
- if (*lpcchBuffer < 2)
+ if (*lpcchBuffer < sizeof(WCHAR))
{
- *lpcchBuffer = 2;
+ *lpcchBuffer = sizeof(WCHAR);
if (lpDisplayName != NULL)
{
*lpDisplayName = 0;
/* If the service could not be found and lpcchBuffer is less than 2, windows
puts null in lpDisplayName and puts 2 in lpcchBuffer */
- if (*lpcchBuffer < 2)
+ if (*lpcchBuffer < sizeof(WCHAR))
{
- *lpcchBuffer = 2;
+ *lpcchBuffer = sizeof(WCHAR);
if (lpServiceName != NULL)
{
*lpServiceName = 0;
LPWSTR lpDependencies = NULL;
DWORD dwDependenciesLength = 0;
DWORD dwRequiredSize;
- CHAR lpEmptyString[]={0,0};
LPSTR lpStr;
DPRINT("RQueryServiceConfigA() called\n");
if (lpImagePath != NULL)
dwRequiredSize += (DWORD)(wcslen(lpImagePath) + 1);
else
- dwRequiredSize += 2;
+ dwRequiredSize += 2 * sizeof(CHAR);
if ((lpService->lpGroup != NULL) && (lpService->lpGroup->lpGroupName != NULL))
dwRequiredSize += (DWORD)(wcslen(lpService->lpGroup->lpGroupName) + 1);
else
- dwRequiredSize += 2;
+ dwRequiredSize += 2 * sizeof(CHAR);
/* Add Dependencies length */
if (lpDependencies != NULL)
dwRequiredSize += dwDependenciesLength;
else
- dwRequiredSize += 2;
+ dwRequiredSize += 2 * sizeof(CHAR);
if (lpServiceStartName != NULL)
dwRequiredSize += (DWORD)(wcslen(lpServiceStartName) + 1);
else
- dwRequiredSize += 2;
+ dwRequiredSize += 2 * sizeof(CHAR);
if (lpService->lpDisplayName != NULL)
dwRequiredSize += (DWORD)(wcslen(lpService->lpDisplayName) + 1);
else
- dwRequiredSize += 2;
+ dwRequiredSize += 2 * sizeof(CHAR);
if (lpServiceConfig == NULL || cbBufSize < dwRequiredSize)
{
}
else
{
- strcpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpBinaryPathName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
}
else
{
- strcpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpLoadOrderGroup = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
}
else
{
- strcpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpDependencies = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
}
else
{
- strcpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpServiceStartName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
}
else
{
- strcpy(lpStr, lpEmptyString);
+ *lpStr = 0;
}
lpServiceConfig->lpDisplayName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig);
puts null in lpDisplayName and puts 1 in lpcchBuffer */
if (*lpcchBuffer == 0)
{
- *lpcchBuffer = 1;
+ *lpcchBuffer = sizeof(CHAR);
if (lpDisplayName != NULL)
{
*lpDisplayName = 0;
put null in lpDisplayName and puts 1 in lpcchBuffer, verified WINXP. */
if (*lpcchBuffer == 0)
{
- *lpcchBuffer = 1;
+ *lpcchBuffer = sizeof(CHAR);
if (lpServiceName != NULL)
{
*lpServiceName = 0;
if ((Info.dwInfoLevel < SERVICE_CONFIG_DESCRIPTION) ||
(Info.dwInfoLevel > SERVICE_CONFIG_FAILURE_ACTIONS))
+ {
return ERROR_INVALID_LEVEL;
+ }
InfoW.dwInfoLevel = Info.dwInfoLevel;
NULL,
&dwType,
NULL,
- &dwRequiredSize);
+ &dwRequiredSize);
if (dwError != ERROR_SUCCESS &&
dwError != ERROR_MORE_DATA &&
dwError != ERROR_FILE_NOT_FOUND)
+ {
return dwError;
+ }
dwRequiredSize = (dwType == REG_BINARY) ? max(sizeof(SERVICE_FAILURE_ACTIONSW), dwRequiredSize)
: sizeof(SERVICE_FAILURE_ACTIONSW);
if ((Info.dwInfoLevel < SERVICE_CONFIG_DESCRIPTION) ||
(Info.dwInfoLevel > SERVICE_CONFIG_FAILURE_ACTIONS))
+ {
return ERROR_INVALID_LEVEL;
+ }
hSvc = ScmGetServiceFromHandle(hService);
if (hSvc == NULL)
if ((dwInfoLevel < SERVICE_CONFIG_DESCRIPTION) ||
(dwInfoLevel > SERVICE_CONFIG_FAILURE_ACTIONS))
+ {
return ERROR_INVALID_LEVEL;
+ }
hSvc = ScmGetServiceFromHandle(hService);
if (hSvc == NULL)
if (dwError != ERROR_SUCCESS &&
dwError != ERROR_MORE_DATA &&
dwError != ERROR_FILE_NOT_FOUND)
+ {
goto done;
+ }
dwRequiredSize = (dwType == REG_BINARY) ? max(sizeof(SERVICE_FAILURE_ACTIONSA), dwRequiredSize)
: sizeof(SERVICE_FAILURE_ACTIONSA);
if ((dwInfoLevel < SERVICE_CONFIG_DESCRIPTION) ||
(dwInfoLevel > SERVICE_CONFIG_FAILURE_ACTIONS))
+ {
return ERROR_INVALID_LEVEL;
+ }
hSvc = ScmGetServiceFromHandle(hService);
if (hSvc == NULL)
if (dwError != ERROR_SUCCESS &&
dwError != ERROR_MORE_DATA &&
dwError != ERROR_FILE_NOT_FOUND)
+ {
goto done;
+ }
dwRequiredSize = (dwType == REG_BINARY) ? max(sizeof(SERVICE_FAILURE_ACTIONSW), dwRequiredSize)
: sizeof(SERVICE_FAILURE_ACTIONSW);
else
lpStatus->dwProcessId = lpService->lpImage->dwProcessId;
- lpStatus->dwServiceFlags = 0; /* FIXME */
+ lpStatus->dwServiceFlags = 0; /* FIXME */
/* Unlock the service database */
ScmUnlockDatabase();