Commit 871635c6 authored by Alexander Yaworsky's avatar Alexander Yaworsky Committed by Alexandre Julliard

Expand ImagePath in QueryServiceConfigW.

parent 4cb6c5c9
...@@ -1026,6 +1026,7 @@ QueryServiceConfigW( SC_HANDLE hService, ...@@ -1026,6 +1026,7 @@ QueryServiceConfigW( SC_HANDLE hService,
static const WCHAR szDependencies[] = { static const WCHAR szDependencies[] = {
'D','e','p','e','n','d','e','n','c','i','e','s',0}; 'D','e','p','e','n','d','e','n','c','i','e','s',0};
HKEY hKey = ((struct sc_handle*) hService)->u.service.hkey; HKEY hKey = ((struct sc_handle*) hService)->u.service.hkey;
WCHAR str_buffer[ MAX_PATH ];
LONG r; LONG r;
DWORD type, val, sz, total, n; DWORD type, val, sz, total, n;
LPBYTE p; LPBYTE p;
...@@ -1036,10 +1037,20 @@ QueryServiceConfigW( SC_HANDLE hService, ...@@ -1036,10 +1037,20 @@ QueryServiceConfigW( SC_HANDLE hService,
/* calculate the size required first */ /* calculate the size required first */
total = sizeof (QUERY_SERVICE_CONFIGW); total = sizeof (QUERY_SERVICE_CONFIGW);
sz = 0; sz = sizeof(str_buffer);
r = RegQueryValueExW( hKey, szImagePath, 0, &type, NULL, &sz ); r = RegQueryValueExW( hKey, szImagePath, 0, &type, (LPBYTE) str_buffer, &sz );
if( ( r == ERROR_SUCCESS ) && ( type == REG_SZ ) ) if( ( r == ERROR_SUCCESS ) && ( type == REG_SZ || type == REG_EXPAND_SZ ) )
total += sz; {
sz = ExpandEnvironmentStringsW(str_buffer,NULL,0);
if( 0 == sz ) return FALSE;
total += sizeof(WCHAR) * sz;
}
else
{
/* FIXME: set last error */
return FALSE;
}
sz = 0; sz = 0;
r = RegQueryValueExW( hKey, szGroup, 0, &type, NULL, &sz ); r = RegQueryValueExW( hKey, szGroup, 0, &type, NULL, &sz );
...@@ -1091,14 +1102,23 @@ QueryServiceConfigW( SC_HANDLE hService, ...@@ -1091,14 +1102,23 @@ QueryServiceConfigW( SC_HANDLE hService,
p = (LPBYTE) &lpServiceConfig[1]; p = (LPBYTE) &lpServiceConfig[1];
n = total - sizeof (QUERY_SERVICE_CONFIGW); n = total - sizeof (QUERY_SERVICE_CONFIGW);
sz = n; sz = sizeof(str_buffer);
r = RegQueryValueExW( hKey, szImagePath, 0, &type, p, &sz ); r = RegQueryValueExW( hKey, szImagePath, 0, &type, (LPBYTE) str_buffer, &sz );
if( ( r == ERROR_SUCCESS ) || ( type == REG_SZ ) ) if( ( r == ERROR_SUCCESS ) && ( type == REG_SZ || type == REG_EXPAND_SZ ) )
{ {
sz = ExpandEnvironmentStringsW(str_buffer, (LPWSTR) p, n);
sz *= sizeof(WCHAR);
if( 0 == sz || sz > n ) return FALSE;
lpServiceConfig->lpBinaryPathName = (LPWSTR) p; lpServiceConfig->lpBinaryPathName = (LPWSTR) p;
p += sz; p += sz;
n -= sz; n -= sz;
} }
else
{
/* FIXME: set last error */
return FALSE;
}
sz = n; sz = n;
r = RegQueryValueExW( hKey, szGroup, 0, &type, p, &sz ); r = RegQueryValueExW( hKey, szGroup, 0, &type, p, &sz );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment