Expand ImagePath in QueryServiceConfigW
Alexander Yaworsky
yaworsky at migusoft.ru
Tue Aug 31 03:12:37 CDT 2004
Hello
ChangeLog:
Expand ImagePath in QueryServiceConfigW
Index: dlls/advapi32/service.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/service.c,v
retrieving revision 1.48
diff -u -r1.48 service.c
--- dlls/advapi32/service.c 30 Aug 2004 23:57:03 -0000 1.48
+++ dlls/advapi32/service.c 31 Aug 2004 07:51:43 -0000
@@ -1023,6 +1023,7 @@
static const WCHAR szDependencies[] = {
'D','e','p','e','n','d','e','n','c','i','e','s',0};
HKEY hKey = ((struct sc_handle*) hService)->u.service.hkey;
+ WCHAR str_buffer[ MAX_PATH ];
LONG r;
DWORD type, val, sz, total, n;
LPBYTE p;
@@ -1033,10 +1034,20 @@
/* calculate the size required first */
total = sizeof (QUERY_SERVICE_CONFIGW);
- sz = 0;
- r = RegQueryValueExW( hKey, szImagePath, 0, &type, NULL, &sz );
- if( ( r == ERROR_SUCCESS ) && ( type == REG_SZ ) )
- total += sz;
+ sz = sizeof(str_buffer);
+ r = RegQueryValueExW( hKey, szImagePath, 0, &type, (LPBYTE) str_buffer, &sz );
+ if( ( r == ERROR_SUCCESS ) && ( type == REG_SZ || type == REG_EXPAND_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;
r = RegQueryValueExW( hKey, szGroup, 0, &type, NULL, &sz );
@@ -1088,13 +1099,22 @@
p = (LPBYTE) &lpServiceConfig[1];
n = total - sizeof (QUERY_SERVICE_CONFIGW);
- sz = n;
- r = RegQueryValueExW( hKey, szImagePath, 0, &type, p, &sz );
- if( ( r == ERROR_SUCCESS ) || ( type == REG_SZ ) )
+ sz = sizeof(str_buffer);
+ r = RegQueryValueExW( hKey, szImagePath, 0, &type, (LPBYTE) str_buffer, &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;
p += sz;
n -= sz;
+ }
+ else
+ {
+ /* FIXME: set last error */
+ return FALSE;
}
sz = n;
More information about the wine-patches
mailing list