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)
{
case SERVICE_CONFIG_DESCRIPTION:
- Info.psd = (LPSERVICE_DESCRIPTIONW)&lpInfo;
+ Info.psd = (LPSERVICE_DESCRIPTIONW)lpInfo;
break;
case SERVICE_CONFIG_FAILURE_ACTIONS:
- Info.psfa = (LPSERVICE_FAILURE_ACTIONSW)&lpInfo;
+ Info.psfa = (LPSERVICE_FAILURE_ACTIONSW)lpInfo;
break;
default:
return FALSE;
}
- if (lpInfo == NULL)
- return TRUE;
-
RpcTryExcept
{
dwError = RChangeServiceConfig2W((SC_RPC_HANDLE)hService,
{
DWORD dwError;
DWORD dwDependenciesLength = 0;
- DWORD dwLength;
- LPSTR lpStr;
+ SIZE_T cchLength;
+ LPCSTR lpStr;
+ DWORD dwPasswordLength = 0;
+ LPBYTE lpEncryptedPassword = NULL;
TRACE("ChangeServiceConfigA() called\n");
/* Calculate the Dependencies length*/
if (lpDependencies != NULL)
{
- lpStr = (LPSTR)lpDependencies;
+ 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;
- LPWSTR lpStr;
+ SIZE_T cchLength;
+ LPCWSTR lpStr;
+ DWORD dwPasswordLength = 0;
+ LPBYTE lpEncryptedPassword = NULL;
TRACE("ChangeServiceConfigW() called\n");
/* Calculate the Dependencies length*/
if (lpDependencies != NULL)
{
- lpStr = (LPWSTR)lpDependencies;
+ 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;
- LPSTR lpStr;
+ SIZE_T cchLength;
+ LPCSTR lpStr;
+ DWORD dwPasswordLength = 0;
+ LPBYTE lpEncryptedPassword = NULL;
TRACE("CreateServiceA() called\n");
- TRACE("%p %s %s\n", hSCManager,
+ TRACE("%p %s %s\n", hSCManager,
lpServiceName, lpDisplayName);
if (!hSCManager)
return NULL;
}
- /* Calculate the Dependencies length*/
+ /* Calculate the Dependencies length */
if (lpDependencies != NULL)
{
- lpStr = (LPSTR)lpDependencies;
+ 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;
- LPWSTR lpStr;
+ SIZE_T cchLength;
+ LPCWSTR lpStr;
+ DWORD dwPasswordLength = 0;
+ LPBYTE lpEncryptedPassword = NULL;
TRACE("CreateServiceW() called\n");
- TRACE("%p %S %S\n", hSCManager,
+ TRACE("%p %S %S\n", hSCManager,
lpServiceName, lpDisplayName);
if (!hSCManager)
return NULL;
}
- /* Calculate the Dependencies length*/
+ /* Calculate the Dependencies length */
if (lpDependencies != NULL)
{
- lpStr = (LPWSTR)lpDependencies;
+ 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)
- {
- SetLastError(ERROR_INVALID_ADDRESS);
- return FALSE;
- }
-
- if (!lpServices && cbBufSize != 0)
+ if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
{
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 (lpPtr->lpDescription != NULL)
lpPtr->lpDescription =
- (LPSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpDescription);
+ (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpDescription);
}
break;
if (lpPtr->lpRebootMsg != NULL)
lpPtr->lpRebootMsg =
- (LPSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpRebootMsg);
+ (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpRebootMsg);
if (lpPtr->lpCommand != NULL)
lpPtr->lpCommand =
- (LPSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpCommand);
+ (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpCommand);
if (lpPtr->lpsaActions != NULL)
lpPtr->lpsaActions =
- (SC_ACTION*)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpsaActions);
+ (LPSC_ACTION)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpsaActions);
}
break;
}
if (bUseTempBuffer == TRUE)
{
TRACE("RQueryServiceConfig2W() returns ERROR_INSUFFICIENT_BUFFER\n");
+ *pcbBytesNeeded = dwBufferSize;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
if (lpPtr->lpDescription != NULL)
lpPtr->lpDescription =
- (LPWSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpDescription);
+ (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpDescription);
}
break;
if (lpPtr->lpRebootMsg != NULL)
lpPtr->lpRebootMsg =
- (LPWSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpRebootMsg);
+ (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpRebootMsg);
if (lpPtr->lpCommand != NULL)
lpPtr->lpCommand =
- (LPWSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpCommand);
+ (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpCommand);
if (lpPtr->lpsaActions != NULL)
lpPtr->lpsaActions =
- (SC_ACTION*)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpsaActions);
+ (LPSC_ACTION)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpsaActions);
}
break;
}
{
/* Call to services.exe using RPC */
dwError = RQueryServiceLockStatusA((SC_RPC_HANDLE)hSCManager,
- lpStatusPtr,
+ (LPBYTE)lpStatusPtr,
dwBufferSize,
pcbBytesNeeded);
}
if (lpStatusPtr->lpLockOwner != NULL)
{
lpStatusPtr->lpLockOwner =
- (LPSTR)((UINT_PTR)lpStatusPtr + (UINT_PTR)lpStatusPtr->lpLockOwner);
+ (LPSTR)((ULONG_PTR)lpStatusPtr + (ULONG_PTR)lpStatusPtr->lpLockOwner);
}
TRACE("QueryServiceLockStatusA() done\n");
{
/* Call to services.exe using RPC */
dwError = RQueryServiceLockStatusW((SC_RPC_HANDLE)hSCManager,
- lpStatusPtr,
+ (LPBYTE)lpStatusPtr,
dwBufferSize,
pcbBytesNeeded);
}
if (lpStatusPtr->lpLockOwner != NULL)
{
lpStatusPtr->lpLockOwner =
- (LPWSTR)((UINT_PTR)lpStatusPtr + (UINT_PTR)lpStatusPtr->lpLockOwner);
+ (LPWSTR)((ULONG_PTR)lpStatusPtr + (ULONG_PTR)lpStatusPtr->lpLockOwner);
}
TRACE("QueryServiceLockStatusW() done\n");