[ADVAPI32/SERVICES]

Little improvements to advapi32.dll / services.exe.
Patch by Hermes Belusca.
See issue #7239 for more details.

svn path=/trunk/; revision=57146
This commit is contained in:
Eric Kohl 2012-08-23 20:24:00 +00:00
parent 6431b75749
commit 5fd0a21ec7
3 changed files with 34 additions and 19 deletions

View file

@ -1955,7 +1955,7 @@ DWORD RChangeServiceConfigW(
if (lpPassword != NULL)
{
/* FIXME: Write password */
/* FIXME: Decrypt and write password */
}
done:
@ -2293,7 +2293,7 @@ DWORD RCreateServiceW(
if (lpPassword != NULL)
{
/* FIXME: Write password */
/* FIXME: Decrypt and write password */
}
dwError = ScmCreateServiceHandle(lpService,
@ -3118,7 +3118,7 @@ DWORD RChangeServiceConfigA(
LPSTR lpBinaryPathName,
LPSTR lpLoadOrderGroup,
LPDWORD lpdwTagId,
LPSTR lpDependencies,
LPBYTE lpDependencies,
DWORD dwDependSize,
LPSTR lpServiceStartName,
LPBYTE lpPassword,
@ -3134,7 +3134,6 @@ DWORD RChangeServiceConfigA(
LPWSTR lpCanonicalImagePathW = NULL;
LPWSTR lpLoadOrderGroupW = NULL;
LPWSTR lpDependenciesW = NULL;
// LPWSTR lpPasswordW = NULL;
DPRINT("RChangeServiceConfigA() called\n");
DPRINT("dwServiceType = %lu\n", dwServiceType);
@ -3374,7 +3373,7 @@ DWORD RChangeServiceConfigA(
{
lpDependenciesW = HeapAlloc(GetProcessHeap(),
0,
(strlen(lpDependencies) + 1) * sizeof(WCHAR));
(strlen((LPSTR)lpDependencies) + 1) * sizeof(WCHAR));
if (lpDependenciesW == NULL)
{
dwError = ERROR_NOT_ENOUGH_MEMORY;
@ -3383,10 +3382,10 @@ DWORD RChangeServiceConfigA(
MultiByteToWideChar(CP_ACP,
0,
lpDependencies,
(LPSTR)lpDependencies,
dwDependSize,
lpDependenciesW,
(int)(strlen(lpDependencies) + 1));
(int)(strlen((LPSTR)lpDependencies) + 1));
dwError = ScmWriteDependencies(hServiceKey,
(LPWSTR)lpDependenciesW,
@ -3397,7 +3396,7 @@ DWORD RChangeServiceConfigA(
if (lpPassword != NULL)
{
/* FIXME: Write password */
/* FIXME: Decrypt and write password */
}
done:

View file

@ -289,6 +289,8 @@ ChangeServiceConfigA(SC_HANDLE hService,
DWORD dwDependenciesLength = 0;
DWORD dwLength;
LPCSTR lpStr;
DWORD dwPasswordLength = 0;
LPBYTE lpEncryptedPassword = NULL;
TRACE("ChangeServiceConfigA() called\n");
@ -306,6 +308,8 @@ ChangeServiceConfigA(SC_HANDLE hService,
}
/* FIXME: Encrypt the password */
lpEncryptedPassword = (LPBYTE)lpPassword;
dwPasswordLength = (strlen(lpPassword) + 1) * sizeof(CHAR);
RpcTryExcept
{
@ -317,11 +321,11 @@ ChangeServiceConfigA(SC_HANDLE hService,
(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)
@ -363,6 +367,8 @@ ChangeServiceConfigW(SC_HANDLE hService,
DWORD dwDependenciesLength = 0;
DWORD dwLength;
LPCWSTR lpStr;
DWORD dwPasswordLength = 0;
LPBYTE lpEncryptedPassword = NULL;
TRACE("ChangeServiceConfigW() called\n");
@ -380,6 +386,8 @@ ChangeServiceConfigW(SC_HANDLE hService,
}
/* FIXME: Encrypt the password */
lpEncryptedPassword = (LPBYTE)lpPassword;
dwPasswordLength = (wcslen(lpPassword) + 1) * sizeof(WCHAR);
RpcTryExcept
{
@ -394,8 +402,8 @@ ChangeServiceConfigW(SC_HANDLE hService,
(LPBYTE)lpDependencies,
dwDependenciesLength,
(LPWSTR)lpServiceStartName,
NULL, /* FIXME: lpPassword */
0, /* FIXME: dwPasswordLength */
lpEncryptedPassword,
dwPasswordLength,
(LPWSTR)lpDisplayName);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
@ -541,6 +549,8 @@ CreateServiceA(SC_HANDLE hSCManager,
DWORD dwError;
DWORD dwLength;
LPCSTR lpStr;
DWORD dwPasswordLength = 0;
LPBYTE lpEncryptedPassword = NULL;
TRACE("CreateServiceA() called\n");
TRACE("%p %s %s\n", hSCManager,
@ -566,6 +576,8 @@ CreateServiceA(SC_HANDLE hSCManager,
}
/* FIXME: Encrypt the password */
lpEncryptedPassword = (LPBYTE)lpPassword;
dwPasswordLength = (strlen(lpPassword) + 1) * sizeof(CHAR);
RpcTryExcept
{
@ -583,8 +595,8 @@ CreateServiceA(SC_HANDLE hSCManager,
(LPBYTE)lpDependencies,
dwDependenciesLength,
(LPSTR)lpServiceStartName,
NULL, /* FIXME: lpPassword */
0, /* FIXME: dwPasswordLength */
lpEncryptedPassword,
dwPasswordLength,
(SC_RPC_HANDLE *)&hService);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
@ -629,6 +641,8 @@ CreateServiceW(SC_HANDLE hSCManager,
DWORD dwError;
DWORD dwLength;
LPCWSTR lpStr;
DWORD dwPasswordLength = 0;
LPBYTE lpEncryptedPassword = NULL;
TRACE("CreateServiceW() called\n");
TRACE("%p %S %S\n", hSCManager,
@ -656,6 +670,8 @@ CreateServiceW(SC_HANDLE hSCManager,
}
/* FIXME: Encrypt the password */
lpEncryptedPassword = (LPBYTE)lpPassword;
dwPasswordLength = (wcslen(lpPassword) + 1) * sizeof(WCHAR);
RpcTryExcept
{
@ -673,8 +689,8 @@ CreateServiceW(SC_HANDLE hSCManager,
(LPBYTE)lpDependencies,
dwDependenciesLength,
lpServiceStartName,
NULL, /* FIXME: lpPassword */
0, /* FIXME: dwPasswordLength */
lpEncryptedPassword,
dwPasswordLength,
(SC_RPC_HANDLE *)&hService);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)

View file

@ -4,7 +4,7 @@
#include <ms-dtyp.idl>
const unsigned int MAX_SERVICE_NAME_LENGTH = 255;
const unsigned int MAX_SERVICE_NAME_LENGTH = 256;
const unsigned short SC_MAX_DEPEND_SIZE = 4 * 1024;
const unsigned short SC_MAX_NAME_LENGTH = MAX_SERVICE_NAME_LENGTH + 1;
const unsigned short SC_MAX_PATH_LENGTH = 32 * 1024;
@ -485,7 +485,7 @@ interface svcctl
[in, string, unique] LPSTR lpBinaryPathName,
[in, string, unique] LPSTR lpLoadOrderGroup,
[in, out, unique] LPDWORD lpdwTagId,
[in, unique, size_is(dwDependSize)] LPSTR lpDependencies,
[in, unique, size_is(dwDependSize)] LPBYTE lpDependencies,
[in, range(0, SC_MAX_DEPEND_SIZE)] DWORD dwDependSize,
[in, string, unique] LPSTR lpServiceStartName,
[in, unique, size_is(dwPwSize)] LPBYTE lpPassword,