TRACE("ChangeServiceConfig2A() called\n");
+ if (lpInfo == NULL) return TRUE;
+
/* Fill relevent field of the Info structure */
Info.dwInfoLevel = dwInfoLevel;
switch (dwInfoLevel)
return FALSE;
}
- if (lpInfo == NULL)
- return TRUE;
-
RpcTryExcept
{
dwError = RChangeServiceConfig2A((SC_RPC_HANDLE)hService,
TRACE("ChangeServiceConfig2W() called\n");
+ if (lpInfo == NULL) return TRUE;
+
/* Fill relevent field of the Info structure */
Info.dwInfoLevel = dwInfoLevel;
switch (dwInfoLevel)
return FALSE;
}
- if (lpInfo == NULL)
- return TRUE;
-
RpcTryExcept
{
dwError = RChangeServiceConfig2W((SC_RPC_HANDLE)hService,
{
DWORD dwError;
DWORD dwDependenciesLength = 0;
- DWORD dwLength;
+ SIZE_T cchLength;
LPCSTR lpStr;
+ DWORD dwPasswordLength = 0;
+ LPBYTE lpEncryptedPassword = NULL;
TRACE("ChangeServiceConfigA() called\n");
lpStr = lpDependencies;
while (*lpStr)
{
- dwLength = strlen(lpStr) + 1;
- dwDependenciesLength += dwLength;
- lpStr = lpStr + dwLength;
+ cchLength = strlen(lpStr) + 1;
+ dwDependenciesLength += (DWORD)cchLength;
+ lpStr = lpStr + cchLength;
}
dwDependenciesLength++;
}
/* FIXME: Encrypt the password */
+ lpEncryptedPassword = (LPBYTE)lpPassword;
+ dwPasswordLength = (DWORD)(lpPassword ? (strlen(lpPassword) + 1) * sizeof(CHAR) : 0);
RpcTryExcept
{
(LPSTR)lpBinaryPathName,
(LPSTR)lpLoadOrderGroup,
lpdwTagId,
- (LPSTR)lpDependencies,
+ (LPBYTE)lpDependencies,
dwDependenciesLength,
(LPSTR)lpServiceStartName,
- NULL, /* FIXME: lpPassword */
- 0, /* FIXME: dwPasswordLength */
+ lpEncryptedPassword,
+ dwPasswordLength,
(LPSTR)lpDisplayName);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
DWORD dwError;
DWORD dwDependenciesLength = 0;
- DWORD dwLength;
+ SIZE_T cchLength;
LPCWSTR lpStr;
+ DWORD dwPasswordLength = 0;
+ LPBYTE lpEncryptedPassword = NULL;
TRACE("ChangeServiceConfigW() called\n");
lpStr = lpDependencies;
while (*lpStr)
{
- dwLength = wcslen(lpStr) + 1;
- dwDependenciesLength += dwLength;
- lpStr = lpStr + dwLength;
+ cchLength = wcslen(lpStr) + 1;
+ dwDependenciesLength += (DWORD)cchLength;
+ lpStr = lpStr + cchLength;
}
dwDependenciesLength++;
+ dwDependenciesLength *= sizeof(WCHAR);
}
/* FIXME: Encrypt the password */
+ lpEncryptedPassword = (LPBYTE)lpPassword;
+ dwPasswordLength = (lpPassword ? (wcslen(lpPassword) + 1) * sizeof(WCHAR) : 0);
RpcTryExcept
{
(LPBYTE)lpDependencies,
dwDependenciesLength,
(LPWSTR)lpServiceStartName,
- NULL, /* FIXME: lpPassword */
- 0, /* FIXME: dwPasswordLength */
+ lpEncryptedPassword,
+ dwPasswordLength,
(LPWSTR)lpDisplayName);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
SC_HANDLE hService = NULL;
DWORD dwDependenciesLength = 0;
DWORD dwError;
- DWORD dwLength;
+ SIZE_T cchLength;
LPCSTR lpStr;
+ DWORD dwPasswordLength = 0;
+ LPBYTE lpEncryptedPassword = NULL;
TRACE("CreateServiceA() called\n");
TRACE("%p %s %s\n", hSCManager,
lpStr = lpDependencies;
while (*lpStr)
{
- dwLength = strlen(lpStr) + 1;
- dwDependenciesLength += dwLength;
- lpStr = lpStr + dwLength;
+ cchLength = strlen(lpStr) + 1;
+ dwDependenciesLength += (DWORD)cchLength;
+ lpStr = lpStr + cchLength;
}
dwDependenciesLength++;
}
/* FIXME: Encrypt the password */
+ lpEncryptedPassword = (LPBYTE)lpPassword;
+ dwPasswordLength = (DWORD)(lpPassword ? (strlen(lpPassword) + 1) * sizeof(CHAR) : 0);
RpcTryExcept
{
(LPBYTE)lpDependencies,
dwDependenciesLength,
(LPSTR)lpServiceStartName,
- NULL, /* FIXME: lpPassword */
- 0, /* FIXME: dwPasswordLength */
+ lpEncryptedPassword,
+ dwPasswordLength,
(SC_RPC_HANDLE *)&hService);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
SC_HANDLE hService = NULL;
DWORD dwDependenciesLength = 0;
DWORD dwError;
- DWORD dwLength;
+ SIZE_T cchLength;
LPCWSTR lpStr;
+ DWORD dwPasswordLength = 0;
+ LPBYTE lpEncryptedPassword = NULL;
TRACE("CreateServiceW() called\n");
TRACE("%p %S %S\n", hSCManager,
lpStr = lpDependencies;
while (*lpStr)
{
- dwLength = wcslen(lpStr) + 1;
- dwDependenciesLength += dwLength;
- lpStr = lpStr + dwLength;
+ cchLength = wcslen(lpStr) + 1;
+ dwDependenciesLength += (DWORD)cchLength;
+ lpStr = lpStr + cchLength;
}
dwDependenciesLength++;
-
dwDependenciesLength *= sizeof(WCHAR);
}
/* FIXME: Encrypt the password */
+ lpEncryptedPassword = (LPBYTE)lpPassword;
+ dwPasswordLength = (DWORD)(lpPassword ? (wcslen(lpPassword) + 1) * sizeof(WCHAR) : 0);
RpcTryExcept
{
(LPBYTE)lpDependencies,
dwDependenciesLength,
lpServiceStartName,
- NULL, /* FIXME: lpPassword */
- 0, /* FIXME: dwPasswordLength */
+ lpEncryptedPassword,
+ dwPasswordLength,
(SC_RPC_HANDLE *)&hService);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
{
- if (*lpServicesReturned > 0)
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
{
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
- {
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ 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++;
}
}
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
{
- if (*lpServicesReturned > 0)
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
{
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
- {
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ 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++;
}
}
return FALSE;
}
+ if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
+ {
+ SetLastError(ERROR_INVALID_ADDRESS);
+ return FALSE;
+ }
+
if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
{
lpStatusPtr = &ServiceStatus;
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
{
- if (*lpServicesReturned > 0)
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
{
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
- {
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ 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++;
}
}
return FALSE;
}
- if (dwServiceType != SERVICE_DRIVER && dwServiceType != SERVICE_WIN32)
- {
- if (pcbBytesNeeded && lpServicesReturned)
- {
- *pcbBytesNeeded = 0;
- *lpServicesReturned = 0;
- }
-
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- if (dwServiceState != SERVICE_ACTIVE && dwServiceState != SERVICE_INACTIVE && dwServiceState != SERVICE_STATE_ALL)
- {
- if (pcbBytesNeeded)
- *pcbBytesNeeded = 0;
-
- if (lpServicesReturned)
- *lpServicesReturned = 0;
-
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- if (!pcbBytesNeeded || !lpServicesReturned)
+ if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
{
SetLastError(ERROR_INVALID_ADDRESS);
return FALSE;
}
- if (!lpServices && cbBufSize != 0)
- {
- SetLastError(ERROR_INVALID_ADDRESS);
- return FALSE;
- }
-
- if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
+ if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSA))
{
lpStatusPtr = &ServiceStatus;
- dwBufferSize = sizeof(ENUM_SERVICE_STATUSW);
+ dwBufferSize = sizeof(ENUM_SERVICE_STATUSA);
}
else
{
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
{
- if (*lpServicesReturned > 0)
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
{
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
- {
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ 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++;
}
}
return FALSE;
}
+ if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
+ {
+ SetLastError(ERROR_INVALID_ADDRESS);
+ return FALSE;
+ }
+
if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
{
lpStatusPtr = &ServiceStatus;
if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
{
- if (*lpServicesReturned > 0)
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
{
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
- {
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ 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++;
}
}
return FALSE;
}
- if (lpServices == NULL ||
- cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSA))
+ if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
+ {
+ SetLastError(ERROR_INVALID_ADDRESS);
+ return FALSE;
+ }
+
+ if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSA))
{
lpStatusPtr = &ServiceStatus;
dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSA);
return FALSE;
}
- if (lpServices == NULL ||
- cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSW))
+ if (!hSCManager)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
+ {
+ SetLastError(ERROR_INVALID_ADDRESS);
+ return FALSE;
+ }
+
+ if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSW))
{
lpStatusPtr = &ServiceStatus;
dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW);
TRACE("WaitForSCManager() called\n");
/* Try to open the existing event */
- hEvent = OpenEventW(SYNCHRONIZE,
- FALSE,
- L"SvcctrlStartEvent_A3752DX");
+ hEvent = OpenEventW(SYNCHRONIZE, FALSE, SCM_START_EVENT);
if (hEvent == NULL)
{
- if (GetLastError() != ERROR_FILE_NOT_FOUND)
- return;
+ if (GetLastError() != ERROR_FILE_NOT_FOUND) return;
/* Try to create a new event */
- hEvent = CreateEventW(NULL,
- TRUE,
- FALSE,
- L"SvcctrlStartEvent_A3752DX");
- if (hEvent == NULL)
- {
- /* Try to open the existing event again */
- hEvent = OpenEventW(SYNCHRONIZE,
- FALSE,
- L"SvcctrlStartEvent_A3752DX");
- if (hEvent == NULL)
- return;
- }
+ hEvent = CreateEventW(NULL, TRUE, FALSE, SCM_START_EVENT);
+ if (hEvent == NULL) return;
}
/* Wait for 3 minutes */
if (bUseTempBuffer == TRUE)
{
TRACE("RQueryServiceConfig2A() returns ERROR_INSUFFICIENT_BUFFER\n");
+ *pcbBytesNeeded = dwBufferSize;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
if (bUseTempBuffer == TRUE)
{
TRACE("RQueryServiceConfig2W() returns ERROR_INSUFFICIENT_BUFFER\n");
+ *pcbBytesNeeded = dwBufferSize;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
{
/* Call to services.exe using RPC */
dwError = RQueryServiceLockStatusA((SC_RPC_HANDLE)hSCManager,
- lpStatusPtr,
+ (LPBYTE)lpStatusPtr,
dwBufferSize,
pcbBytesNeeded);
}
{
/* Call to services.exe using RPC */
dwError = RQueryServiceLockStatusW((SC_RPC_HANDLE)hSCManager,
- lpStatusPtr,
+ (LPBYTE)lpStatusPtr,
dwBufferSize,
pcbBytesNeeded);
}