From 9d43950db7bd5402e947b28ff73cbf4cac697b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 16 Sep 2018 23:22:04 +0200 Subject: [PATCH] [SERVICES] Add basic support for setting lpServiceStartName via RChangeServiceConfigW(). --- base/system/services/rpcserver.c | 49 +++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/base/system/services/rpcserver.c b/base/system/services/rpcserver.c index 77cf44be738..aa64233350d 100644 --- a/base/system/services/rpcserver.c +++ b/base/system/services/rpcserver.c @@ -2179,28 +2179,45 @@ RChangeServiceConfigW( goto done; } - if (lpPassword != NULL) + /* Start name and password are only used by Win32 services */ + if (lpService->Status.dwServiceType & SERVICE_WIN32) { - if (*(LPWSTR)lpPassword != 0) + /* Write service start name */ + if (lpServiceStartName != NULL && *lpServiceStartName != 0) { - /* FIXME: Decrypt the password */ - - /* Write the password */ - dwError = ScmSetServicePassword(lpService->szServiceName, - (LPCWSTR)lpPassword); + dwError = RegSetValueExW(hServiceKey, + L"ObjectName", + 0, + REG_SZ, + (LPBYTE)lpServiceStartName, + (DWORD)((wcslen(lpServiceStartName) + 1) * sizeof(WCHAR))); if (dwError != ERROR_SUCCESS) goto done; } - else - { - /* Delete the password */ - dwError = ScmSetServicePassword(lpService->szServiceName, - NULL); - if (dwError == ERROR_FILE_NOT_FOUND) - dwError = ERROR_SUCCESS; - if (dwError != ERROR_SUCCESS) - goto done; + if (lpPassword != NULL) + { + if (*(LPWSTR)lpPassword != 0) + { + /* FIXME: Decrypt the password */ + + /* Write the password */ + dwError = ScmSetServicePassword(lpService->szServiceName, + (LPCWSTR)lpPassword); + if (dwError != ERROR_SUCCESS) + goto done; + } + else + { + /* Delete the password */ + dwError = ScmSetServicePassword(lpService->szServiceName, + NULL); + if (dwError == ERROR_FILE_NOT_FOUND) + dwError = ERROR_SUCCESS; + + if (dwError != ERROR_SUCCESS) + goto done; + } } }