--- trunk/reactos/lib/msi/helpers.c 2005-11-25 23:10:34 UTC (rev 19588)
+++ trunk/reactos/lib/msi/helpers.c 2005-11-25 23:12:29 UTC (rev 19589)
@@ -221,40 +221,42 @@
if (!name)
return NULL;
- /* special resolving for Target and Source root dir */
- if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
+ /* source directories appear to always be at the root */
+ if (source)
{
- if (!source)
+ path = msi_dup_property( package, cszSourceDir );
+ if (!path)
{
- LPWSTR check_path;
- check_path = msi_dup_property( package, cszTargetDir );
- if (!check_path)
+ path = msi_dup_property( package, cszDatabase );
+ if (path)
{
- check_path = msi_dup_property( package, cszRootDrive );
- if (set_prop)
- MSI_SetPropertyW(package,cszTargetDir,check_path);
+ p = strrchrW(path,'\\');
+ if (p)
+ *(p+1) = 0;
}
-
- /* correct misbuilt target dir */
- path = build_directory_name(2, check_path, NULL);
- if (strcmpiW(path,check_path)!=0)
- MSI_SetPropertyW(package,cszTargetDir,path);
- msi_free(check_path);
}
- else
+ if (folder)
+ *folder = get_loaded_folder( package, name );
+ return path;
+ }
+
+ /* special resolving for Target and Source root dir */
+ if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
+ {
+ LPWSTR check_path;
+ check_path = msi_dup_property( package, cszTargetDir );
+ if (!check_path)
{
- path = msi_dup_property( package, cszSourceDir );
- if (!path)
- {
- path = msi_dup_property( package, cszDatabase );
- if (path)
- {
- p = strrchrW(path,'\\');
- if (p)
- *(p+1) = 0;
- }
- }
+ check_path = msi_dup_property( package, cszRootDrive );
+ if (set_prop)
+ MSI_SetPropertyW(package,cszTargetDir,check_path);
}
+
+ /* correct misbuilt target dir */
+ path = build_directory_name(2, check_path, NULL);
+ if (strcmpiW(path,check_path)!=0)
+ MSI_SetPropertyW(package,cszTargetDir,path);
+ msi_free(check_path);
if (folder)
*folder = get_loaded_folder( package, name );
return path;
@@ -267,20 +269,14 @@
if (folder)
*folder = f;
- if (!source && f->ResolvedTarget)
+ if (f->ResolvedTarget)
{
path = strdupW( f->ResolvedTarget );
TRACE(" already resolved to %s\n",debugstr_w(path));
return path;
}
- else if (source && f->ResolvedSource)
+ else if (f->Property)
{
- path = strdupW( f->ResolvedSource );
- TRACE(" (source)already resolved to %s\n",debugstr_w(path));
- return path;
- }
- else if (!source && f->Property)
- {
path = build_directory_name( 2, f->Property, NULL );
TRACE(" internally set to %s\n",debugstr_w(path));
@@ -296,25 +292,13 @@
TRACE(" ! Parent is %s\n", debugstr_w(parent));
p = resolve_folder(package, parent, source, set_prop, NULL);
- if (!source)
- {
- TRACE(" TargetDefault = %s\n", debugstr_w(f->TargetDefault));
+ TRACE(" TargetDefault = %s\n", debugstr_w(f->TargetDefault));
- path = build_directory_name( 3, p, f->TargetDefault, NULL );
- f->ResolvedTarget = strdupW( path );
- TRACE(" resolved into %s\n",debugstr_w(path));
- if (set_prop)
- MSI_SetPropertyW(package,name,path);
- }
- else
- {
- if (f->SourceDefault && f->SourceDefault[0]!='.')
- path = build_directory_name( 3, p, f->SourceDefault, NULL );
- else
- path = strdupW(p);
- TRACE(" (source)resolved into %s\n",debugstr_w(path));
- f->ResolvedSource = strdupW( path );
- }
+ path = build_directory_name( 3, p, f->TargetDefault, NULL );
+ f->ResolvedTarget = strdupW( path );
+ TRACE(" resolved into %s\n",debugstr_w(path));
+ if (set_prop)
+ MSI_SetPropertyW(package,name,path);
msi_free(p);
}
return path;
--- trunk/reactos/lib/msi/registry.c 2005-11-25 23:10:34 UTC (rev 19588)
+++ trunk/reactos/lib/msi/registry.c 2005-11-25 23:12:29 UTC (rev 19589)
@@ -773,7 +773,7 @@
awstring *lpQualBuf, DWORD* pcchQual,
awstring *lpAppBuf, DWORD* pcchAppBuf )
{
- DWORD name_sz, val_sz, type, ofs;
+ DWORD name_sz, val_sz, name_max, val_max, type, ofs;
LPWSTR name = NULL, val = NULL;
UINT r, r2;
HKEY key;
@@ -789,41 +789,58 @@
return ERROR_UNKNOWN_COMPONENT;
/* figure out how big the name is we want to return */
- name_sz = 0;
- if (pcchQual)
- {
- r = ERROR_OUTOFMEMORY;
- name_sz = *pcchQual * 4;
- name = msi_alloc( name_sz * sizeof(WCHAR) );
- if (!name)
- goto end;
- }
+ name_max = 0x10;
+ r = ERROR_OUTOFMEMORY;
+ name = msi_alloc( name_max * sizeof(WCHAR) );
+ if (!name)
+ goto end;
- /* figure out how big the value is */
- type = 0;
- val_sz = 0;
- r = RegEnumValueW( key, iIndex, NULL, NULL,
- NULL, &type, NULL, &val_sz );
- if (r != ERROR_SUCCESS)
+ val_max = 0x10;
+ r = ERROR_OUTOFMEMORY;
+ val = msi_alloc( val_max );
+ if (!val)
goto end;
- if (type != REG_MULTI_SZ)
+ /* loop until we allocate enough memory */
+ while (1)
{
- ERR("component data has wrong type (%ld)\n", type);
+ name_sz = name_max;
+ val_sz = val_max;
+ r = RegEnumValueW( key, iIndex, name, &name_sz,
+ NULL, &type, (LPBYTE)val, &val_sz );
+ if (r == ERROR_SUCCESS)
+ break;
+ if (r != ERROR_MORE_DATA)
+ goto end;
+
+ if (type != REG_MULTI_SZ)
+ {
+ ERR("component data has wrong type (%ld)\n", type);
+ goto end;
+ }
+
+ r = ERROR_OUTOFMEMORY;
+ if ((name_sz+1) >= name_max)
+ {
+ name_max *= 2;
+ msi_free( name );
+ name = msi_alloc( name_max * sizeof (WCHAR) );
+ if (!name)
+ goto end;
+ continue;
+ }
+ if (val_sz > val_max)
+ {
+ val_max = val_sz + sizeof (WCHAR);
+ val = msi_alloc( val_max * sizeof (WCHAR) );
+ if (!val)
+ goto end;
+ continue;
+ }
+ ERR("should be enough data, but isn't %ld %ld\n", name_sz, val_sz );
goto end;
}
- /* the value size is in bytes */
- val_sz += sizeof(WCHAR);
- val = msi_alloc( val_sz );
- if (!val)
- goto end;
-
- r = RegEnumValueW( key, iIndex, name, &name_sz,
- NULL, &type, (LPBYTE)val, &val_sz );
- if (r != ERROR_SUCCESS)
- goto end;
-
ofs = 0;
r = MsiDecomposeDescriptorW( val, NULL, NULL, NULL, &ofs );
if (r != ERROR_SUCCESS)