2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2004 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/installexecutesequence_table.asp
26 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/standard_actions_reference.asp
38 #include "wine/debug.h"
42 #include "msvcrt/fcntl.h"
49 #include "wine/unicode.h"
52 #define CUSTOM_ACTION_TYPE_MASK 0x3F
53 #define REG_PROGRESS_VALUE 13200
54 #define COMPONENT_PROGRESS_VALUE 24000
56 WINE_DEFAULT_DEBUG_CHANNEL(msi);
58 typedef struct tagMSIFEATURE
61 WCHAR Feature_Parent[96];
63 WCHAR Description[0x100];
69 INSTALLSTATE Installed;
70 INSTALLSTATE ActionRequest;
74 INT Components[1024]; /* yes hardcoded limit.... I am bad */
78 typedef struct tagMSICOMPONENT
81 WCHAR ComponentId[96];
84 WCHAR Condition[0x100];
87 INSTALLSTATE Installed;
88 INSTALLSTATE ActionRequest;
95 typedef struct tagMSIFOLDER
101 LPWSTR ResolvedTarget;
102 LPWSTR ResolvedSource;
103 LPWSTR Property; /* initially set property */
106 /* 0 = uninitialized */
108 /* 2 = created remove if empty */
109 /* 3 = created persist if empty */
114 typedef struct tagMSIFILE
126 /* 0 = uninitialize */
127 /* 1 = not present */
128 /* 2 = present but replace */
129 /* 3 = present do not replace */
139 static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran);
140 static UINT ACTION_ProcessUISequence(MSIPACKAGE *package);
142 static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq);
143 UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action);
145 static UINT ACTION_LaunchConditions(MSIPACKAGE *package);
146 static UINT ACTION_CostInitialize(MSIPACKAGE *package);
147 static UINT ACTION_CreateFolders(MSIPACKAGE *package);
148 static UINT ACTION_CostFinalize(MSIPACKAGE *package);
149 static UINT ACTION_FileCost(MSIPACKAGE *package);
150 static UINT ACTION_InstallFiles(MSIPACKAGE *package);
151 static UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
152 static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package);
153 static UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action);
154 static UINT ACTION_InstallInitialize(MSIPACKAGE *package);
155 static UINT ACTION_InstallValidate(MSIPACKAGE *package);
156 static UINT ACTION_ProcessComponents(MSIPACKAGE *package);
157 static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package);
158 static UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
159 static UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
160 static UINT ACTION_CreateShortcuts(MSIPACKAGE *package);
161 static UINT ACTION_PublishProduct(MSIPACKAGE *package);
163 static UINT HANDLE_CustomType1(MSIPACKAGE *package, const LPWSTR source,
164 const LPWSTR target, const INT type);
165 static UINT HANDLE_CustomType2(MSIPACKAGE *package, const LPWSTR source,
166 const LPWSTR target, const INT type);
167 static UINT HANDLE_CustomType18(MSIPACKAGE *package, const LPWSTR source,
168 const LPWSTR target, const INT type);
169 static UINT HANDLE_CustomType50(MSIPACKAGE *package, const LPWSTR source,
170 const LPWSTR target, const INT type);
171 static UINT HANDLE_CustomType34(MSIPACKAGE *package, const LPWSTR source,
172 const LPWSTR target, const INT type);
174 static DWORD deformat_string(MSIPACKAGE *package, WCHAR* ptr,WCHAR** data);
175 static LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name,
176 BOOL source, BOOL set_prop, MSIFOLDER **folder);
178 static int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path);
181 * consts and values used
183 static const WCHAR cszSourceDir[] = {'S','o','u','r','c','e','D','i','r',0};
184 static const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0};
185 static const WCHAR cszTargetDir[] = {'T','A','R','G','E','T','D','I','R',0};
186 static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
187 static const WCHAR cszDatabase[]={'D','A','T','A','B','A','S','E',0};
188 static const WCHAR c_collen[] = {'C',':','\\',0};
190 static const WCHAR cszlsb[]={'[',0};
191 static const WCHAR cszrsb[]={']',0};
192 static const WCHAR cszbs[]={'\\',0};
194 const static WCHAR szCreateFolders[] =
195 {'C','r','e','a','t','e','F','o','l','d','e','r','s',0};
196 const static WCHAR szCostFinalize[] =
197 {'C','o','s','t','F','i','n','a','l','i','z','e',0};
198 const static WCHAR szInstallFiles[] =
199 {'I','n','s','t','a','l','l','F','i','l','e','s',0};
200 const static WCHAR szDuplicateFiles[] =
201 {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0};
202 const static WCHAR szWriteRegistryValues[] =
203 {'W','r','i','t','e','R','e','g','i','s','t','r','y','V','a','l','u','e','s',0};
204 const static WCHAR szCostInitialize[] =
205 {'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0};
206 const static WCHAR szFileCost[] = {'F','i','l','e','C','o','s','t',0};
207 const static WCHAR szInstallInitialize[] =
208 {'I','n','s','t','a','l','l','I','n','i','t','i','a','l','i','z','e',0};
209 const static WCHAR szInstallValidate[] =
210 {'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e',0};
211 const static WCHAR szLaunchConditions[] =
212 {'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','s',0};
213 const static WCHAR szProcessComponents[] =
214 {'P','r','o','c','e','s','s','C','o','m','p','o','n','e','n','t','s',0};
215 const static WCHAR szRegisterTypeLibraries[] =
216 {'R','e','g','i','s','t','e','r','T','y','p','e','L','i','b','r','a','r',
218 const static WCHAR szRegisterClassInfo[] =
219 {'R','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0};
220 const static WCHAR szRegisterProgIdInfo[] =
221 {'R','e','g','i','s','t','e','r','P','r','o','g','I','d','I','n','f','o',0};
222 const static WCHAR szCreateShortcuts[] =
223 {'C','r','e','a','t','e','S','h','o','r','t','c','u','t','s',0};
224 const static WCHAR szPublishProduct[] =
225 {'P','u','b','l','i','s','h','P','r','o','d','u','c','t',0};
227 /********************************************************
228 * helper functions to get around current HACKS and such
229 ********************************************************/
230 inline static void reduce_to_longfilename(WCHAR* filename)
232 LPWSTR p = strchrW(filename,'|');
234 memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR));
237 inline static char *strdupWtoA( const WCHAR *str )
242 DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL
244 if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
245 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
250 inline static WCHAR *strdupAtoW( const char *str )
255 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
256 if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
257 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
262 static LPWSTR dupstrW(LPCWSTR src)
265 if (!src) return NULL;
266 dest = HeapAlloc(GetProcessHeap(), 0, (strlenW(src)+1)*sizeof(WCHAR));
271 inline static WCHAR *load_dynamic_stringW(MSIRECORD *row, INT index)
278 if (MSI_RecordIsNull(row,index))
281 rc = MSI_RecordGetStringW(row,index,NULL,&sz);
283 /* having an empty string is different than NULL */
286 ret = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR));
292 ret = HeapAlloc(GetProcessHeap(),0,sz * sizeof (WCHAR));
293 rc = MSI_RecordGetStringW(row,index,ret,&sz);
294 if (rc!=ERROR_SUCCESS)
296 ERR("Unable to load dynamic string\n");
297 HeapFree(GetProcessHeap(), 0, ret);
303 inline static LPWSTR load_dynamic_property(MSIPACKAGE *package, LPCWSTR prop,
310 r = MSI_GetPropertyW(package, prop, NULL, &sz);
311 if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
318 str = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR));
319 r = MSI_GetPropertyW(package, prop, str, &sz);
320 if (r != ERROR_SUCCESS)
322 HeapFree(GetProcessHeap(),0,str);
330 inline static int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component )
335 for (i = 0; i < package->loaded_components; i++)
337 if (strcmpW(Component,package->components[i].Component)==0)
346 inline static int get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature )
351 for (i = 0; i < package->loaded_features; i++)
353 if (strcmpW(Feature,package->features[i].Feature)==0)
362 inline static int get_loaded_file(MSIPACKAGE* package, LPCWSTR file)
367 for (i = 0; i < package->loaded_files; i++)
369 if (strcmpW(file,package->files[i].File)==0)
379 static int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path)
387 for (i=0; i < package->loaded_files; i++)
388 if (strcmpW(package->files[i].File,name)==0)
391 index = package->loaded_files;
392 package->loaded_files++;
393 if (package->loaded_files== 1)
394 package->files = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE));
396 package->files = HeapReAlloc(GetProcessHeap(),0,
397 package->files , package->loaded_files * sizeof(MSIFILE));
399 memset(&package->files[index],0,sizeof(MSIFILE));
401 package->files[index].File = dupstrW(name);
402 package->files[index].TargetPath = dupstrW(path);
403 package->files[index].Temporary = TRUE;
405 TRACE("Tracking tempfile (%s)\n",debugstr_w(package->files[index].File));
410 void ACTION_remove_tracked_tempfiles(MSIPACKAGE* package)
417 for (i = 0; i < package->loaded_files; i++)
419 if (package->files[i].Temporary)
421 TRACE("Cleaning up %s\n",debugstr_w(package->files[i].TargetPath));
422 DeleteFileW(package->files[i].TargetPath);
428 /* Called when the package is being closed */
429 extern void ACTION_free_package_structures( MSIPACKAGE* package)
433 TRACE("Freeing package action data\n");
435 /* No dynamic buffers in features */
436 if (package->features && package->loaded_features > 0)
437 HeapFree(GetProcessHeap(),0,package->features);
439 for (i = 0; i < package->loaded_folders; i++)
441 HeapFree(GetProcessHeap(),0,package->folders[i].Directory);
442 HeapFree(GetProcessHeap(),0,package->folders[i].TargetDefault);
443 HeapFree(GetProcessHeap(),0,package->folders[i].SourceDefault);
444 HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedTarget);
445 HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedSource);
446 HeapFree(GetProcessHeap(),0,package->folders[i].Property);
448 if (package->folders && package->loaded_folders > 0)
449 HeapFree(GetProcessHeap(),0,package->folders);
451 /* no dynamic buffers in components */
452 if (package->components && package->loaded_components > 0)
453 HeapFree(GetProcessHeap(),0,package->components);
455 for (i = 0; i < package->loaded_files; i++)
457 HeapFree(GetProcessHeap(),0,package->files[i].File);
458 HeapFree(GetProcessHeap(),0,package->files[i].FileName);
459 HeapFree(GetProcessHeap(),0,package->files[i].Version);
460 HeapFree(GetProcessHeap(),0,package->files[i].Language);
461 HeapFree(GetProcessHeap(),0,package->files[i].SourcePath);
462 HeapFree(GetProcessHeap(),0,package->files[i].TargetPath);
465 if (package->files && package->loaded_files > 0)
466 HeapFree(GetProcessHeap(),0,package->files);
469 static UINT ACTION_OpenQuery( MSIDATABASE *db, MSIQUERY **view, LPCWSTR fmt, ... )
476 /* figure out how much space we need to allocate */
478 sz = strlenW(fmt) + 1;
488 case 's': /* a string */
489 sz += strlenW(va_arg(va,LPCWSTR));
492 case 'i': /* an integer -2147483648 seems to be longest */
494 (void)va_arg(va,int);
496 case '%': /* a single % - leave it alone */
499 FIXME("Unhandled character type %c\n",*p);
505 /* construct the string */
506 szQuery = HeapAlloc(GetProcessHeap(), 0, sz*sizeof(WCHAR));
508 vsnprintfW(szQuery, sz, fmt, va);
511 /* perform the query */
512 rc = MSI_DatabaseOpenViewW(db, szQuery, view);
513 HeapFree(GetProcessHeap(), 0, szQuery);
517 static void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d )
521 row = MSI_CreateRecord(4);
522 MSI_RecordSetInteger(row,1,a);
523 MSI_RecordSetInteger(row,2,b);
524 MSI_RecordSetInteger(row,3,c);
525 MSI_RecordSetInteger(row,4,d);
526 MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row);
527 msiobj_release(&row->hdr);
530 static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record)
532 static const WCHAR Query_t[] =
533 {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','c','t','i','o',
534 'n','T','e','x','t',' ','w','h','e','r','e',' ','A','c','t','i','o','n',' ','=',
535 ' ','\'','%','s','\'',0};
542 if (!package->LastAction || strcmpW(package->LastAction,action))
544 rc = ACTION_OpenQuery(package->db, &view, Query_t, action);
545 if (rc != ERROR_SUCCESS)
548 rc = MSI_ViewExecute(view, 0);
549 if (rc != ERROR_SUCCESS)
554 rc = MSI_ViewFetch(view,&row);
555 if (rc != ERROR_SUCCESS)
561 if (MSI_RecordIsNull(row,3))
563 msiobj_release(&row->hdr);
565 msiobj_release(&view->hdr);
569 /* update the cached actionformat */
570 if (package->ActionFormat)
571 HeapFree(GetProcessHeap(),0,package->ActionFormat);
572 package->ActionFormat = load_dynamic_stringW(row,3);
574 if (package->LastAction)
575 HeapFree(GetProcessHeap(),0,package->LastAction);
576 package->LastAction = dupstrW(action);
578 msiobj_release(&row->hdr);
580 msiobj_release(&view->hdr);
584 ptr = package->ActionFormat;
592 ptr2 = strchrW(ptr,'[');
595 strncpyW(tmp,ptr,ptr2-ptr);
597 strcatW(message,tmp);
600 data = load_dynamic_stringW(record,field);
603 strcatW(message,data);
604 HeapFree(GetProcessHeap(),0,data);
606 ptr=strchrW(ptr2,']');
611 strcatW(message,ptr);
616 row = MSI_CreateRecord(1);
617 MSI_RecordSetStringW(row,1,message);
619 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row);
620 msiobj_release(&row->hdr);
624 static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action)
626 static const WCHAR template_s[]=
627 {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ','%','s','.',0};
628 static const WCHAR format[] =
629 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
630 static const WCHAR Query_t[] =
631 {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','c','t','i','o',
632 'n','T','e','x','t',' ','w','h','e','r','e',' ','A','c','t','i','o','n',' ','=',
633 ' ','\'','%','s','\'',0};
639 WCHAR *ActionText=NULL;
641 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
643 rc = ACTION_OpenQuery(package->db, &view, Query_t, action);
644 if (rc != ERROR_SUCCESS)
646 rc = MSI_ViewExecute(view, 0);
647 if (rc != ERROR_SUCCESS)
650 msiobj_release(&view->hdr);
653 rc = MSI_ViewFetch(view,&row);
654 if (rc != ERROR_SUCCESS)
657 msiobj_release(&view->hdr);
661 ActionText = load_dynamic_stringW(row,2);
662 msiobj_release(&row->hdr);
664 msiobj_release(&view->hdr);
666 sprintfW(message,template_s,timet,action,ActionText);
668 row = MSI_CreateRecord(1);
669 MSI_RecordSetStringW(row,1,message);
671 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, row);
672 msiobj_release(&row->hdr);
673 HeapFree(GetProcessHeap(),0,ActionText);
676 static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start,
680 static const WCHAR template_s[]=
681 {'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ','%','s',
683 static const WCHAR template_e[]=
684 {'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ','%','s',
685 '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ','%','i','.',0};
686 static const WCHAR format[] =
687 {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
691 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
693 sprintfW(message,template_s,timet,action);
695 sprintfW(message,template_e,timet,action,rc);
697 row = MSI_CreateRecord(1);
698 MSI_RecordSetStringW(row,1,message);
700 MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row);
701 msiobj_release(&row->hdr);
705 * build_directory_name()
707 * This function is to save messing round with directory names
708 * It handles adding backslashes between path segments,
709 * and can add \ at the end of the directory name if told to.
711 * It takes a variable number of arguments.
712 * It always allocates a new string for the result, so make sure
713 * to free the return value when finished with it.
715 * The first arg is the number of path segments that follow.
716 * The arguments following count are a list of path segments.
717 * A path segment may be NULL.
719 * Path segments will be added with a \ seperating them.
720 * A \ will not be added after the last segment, however if the
721 * last segment is NULL, then the last character will be a \
724 static LPWSTR build_directory_name(DWORD count, ...)
731 for(i=0; i<count; i++)
733 LPCWSTR str = va_arg(va,LPCWSTR);
735 sz += strlenW(str) + 1;
739 dir = HeapAlloc(GetProcessHeap(), 0, sz*sizeof(WCHAR));
743 for(i=0; i<count; i++)
745 LPCWSTR str = va_arg(va,LPCWSTR);
749 if( ((i+1)!=count) && dir[strlenW(dir)-1]!='\\')
756 /****************************************************
757 * TOP level entry points
758 *****************************************************/
760 UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath,
761 LPCWSTR szCommandLine)
766 static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
770 LPWSTR p, check, path;
772 path = dupstrW(szPackagePath);
773 p = strrchrW(path,'\\');
780 check = load_dynamic_property(package, cszSourceDir,NULL);
782 MSI_SetPropertyW(package, cszSourceDir, path);
784 HeapFree(GetProcessHeap(), 0, check);
786 HeapFree(GetProcessHeap(), 0, path);
792 ptr = (LPWSTR)szCommandLine;
799 TRACE("Looking at %s\n",debugstr_w(ptr));
801 ptr2 = strchrW(ptr,'=');
807 while (*ptr == ' ') ptr++;
809 prop = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
810 strncpyW(prop,ptr,len);
816 while (*ptr && (quote || (!quote && *ptr!=' ')))
829 val = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
830 strncpyW(val,ptr2,len);
833 if (strlenW(prop) > 0)
835 TRACE("Found commandline property (%s) = (%s)\n",
836 debugstr_w(prop), debugstr_w(val));
837 MSI_SetPropertyW(package,prop,val);
839 HeapFree(GetProcessHeap(),0,val);
840 HeapFree(GetProcessHeap(),0,prop);
847 if (MSI_GetPropertyW(package,szUILevel,buffer,&sz) == ERROR_SUCCESS)
849 if (atoiW(buffer) >= INSTALLUILEVEL_REDUCED)
851 rc = ACTION_ProcessUISequence(package);
852 if (rc == ERROR_SUCCESS)
853 rc = ACTION_ProcessExecSequence(package,TRUE);
856 rc = ACTION_ProcessExecSequence(package,FALSE);
859 rc = ACTION_ProcessExecSequence(package,FALSE);
861 /* process the ending type action */
862 if (rc == ERROR_SUCCESS)
863 rc = ACTION_PerformActionSequence(package,-1);
864 else if (rc == ERROR_FUNCTION_FAILED)
865 rc = ACTION_PerformActionSequence(package,-3);
870 static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq)
877 static const WCHAR ExecSeqQuery[] = {
878 's','e','l','e','c','t',' ','*',' ',
880 'I','n','s','t','a','l','l','E','x','e','c','u','t','e',
881 'S','e','q','u','e','n','c','e',' ',
882 'w','h','e','r','e',' ','S','e','q','u','e','n','c','e',' ',
885 rc = ACTION_OpenQuery(package->db, &view, ExecSeqQuery, seq);
887 if (rc == ERROR_SUCCESS)
889 rc = MSI_ViewExecute(view, 0);
891 if (rc != ERROR_SUCCESS)
894 msiobj_release(&view->hdr);
898 TRACE("Running the actions\n");
900 rc = MSI_ViewFetch(view,&row);
901 if (rc != ERROR_SUCCESS)
907 /* check conditions */
908 if (!MSI_RecordIsNull(row,2))
911 cond = load_dynamic_stringW(row,2);
915 /* this is a hack to skip errors in the condition code */
916 if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE)
918 HeapFree(GetProcessHeap(),0,cond);
919 msiobj_release(&row->hdr);
923 HeapFree(GetProcessHeap(),0,cond);
928 rc = MSI_RecordGetStringW(row,1,buffer,&sz);
929 if (rc != ERROR_SUCCESS)
931 ERR("Error is %x\n",rc);
932 msiobj_release(&row->hdr);
936 rc = ACTION_PerformAction(package,buffer);
937 msiobj_release(&row->hdr);
940 msiobj_release(&view->hdr);
948 static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran)
952 static const WCHAR ExecSeqQuery[] = {
953 's','e','l','e','c','t',' ','*',' ',
955 'I','n','s','t','a','l','l','E','x','e','c','u','t','e',
956 'S','e','q','u','e','n','c','e',' ',
957 'w','h','e','r','e',' ','S','e','q','u','e','n','c','e',' ',
958 '>',' ','%','i',' ','o','r','d','e','r',' ',
959 'b','y',' ','S','e','q','u','e','n','c','e',0 };
961 static const WCHAR IVQuery[] = {
962 's','e','l','e','c','t',' ','S','e','q','u','e','n','c','e',' ',
963 'f','r','o','m',' ','I','n','s','t','a','l','l',
964 'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e',' ',
965 'w','h','e','r','e',' ','A','c','t','i','o','n',' ','=',' ',
966 '`','I','n','s','t','a','l','l','V','a','l','i','d','a','t','e','`',
970 /* get the sequence number */
973 rc = MSI_DatabaseOpenViewW(package->db, IVQuery, &view);
974 if (rc != ERROR_SUCCESS)
976 rc = MSI_ViewExecute(view, 0);
977 if (rc != ERROR_SUCCESS)
980 msiobj_release(&view->hdr);
983 rc = MSI_ViewFetch(view,&row);
984 if (rc != ERROR_SUCCESS)
987 msiobj_release(&view->hdr);
990 seq = MSI_RecordGetInteger(row,1);
991 msiobj_release(&row->hdr);
993 msiobj_release(&view->hdr);
996 rc = ACTION_OpenQuery(package->db, &view, ExecSeqQuery, seq);
997 if (rc == ERROR_SUCCESS)
999 rc = MSI_ViewExecute(view, 0);
1001 if (rc != ERROR_SUCCESS)
1003 MSI_ViewClose(view);
1004 msiobj_release(&view->hdr);
1008 TRACE("Running the actions\n");
1012 WCHAR buffer[0x100];
1015 rc = MSI_ViewFetch(view,&row);
1016 if (rc != ERROR_SUCCESS)
1022 /* check conditions */
1023 if (!MSI_RecordIsNull(row,2))
1026 cond = load_dynamic_stringW(row,2);
1030 /* this is a hack to skip errors in the condition code */
1031 if (MSI_EvaluateConditionW(package, cond) ==
1034 HeapFree(GetProcessHeap(),0,cond);
1035 msiobj_release(&row->hdr);
1039 HeapFree(GetProcessHeap(),0,cond);
1044 rc = MSI_RecordGetStringW(row,1,buffer,&sz);
1045 if (rc != ERROR_SUCCESS)
1047 ERR("Error is %x\n",rc);
1048 msiobj_release(&row->hdr);
1052 rc = ACTION_PerformAction(package,buffer);
1054 if (rc == ERROR_FUNCTION_NOT_CALLED)
1057 if (rc != ERROR_SUCCESS)
1059 ERR("Execution halted due to error (%i)\n",rc);
1060 msiobj_release(&row->hdr);
1064 msiobj_release(&row->hdr);
1067 MSI_ViewClose(view);
1068 msiobj_release(&view->hdr);
1076 static UINT ACTION_ProcessUISequence(MSIPACKAGE *package)
1080 static const WCHAR ExecSeqQuery [] = {
1081 's','e','l','e','c','t',' ','*',' ',
1082 'f','r','o','m',' ','I','n','s','t','a','l','l',
1083 'U','I','S','e','q','u','e','n','c','e',' ',
1084 'w','h','e','r','e',' ','S','e','q','u','e','n','c','e',' ', '>',' ','0',' ',
1085 'o','r','d','e','r',' ','b','y',' ','S','e','q','u','e','n','c','e',0};
1087 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
1089 if (rc == ERROR_SUCCESS)
1091 rc = MSI_ViewExecute(view, 0);
1093 if (rc != ERROR_SUCCESS)
1095 MSI_ViewClose(view);
1096 msiobj_release(&view->hdr);
1100 TRACE("Running the actions \n");
1104 WCHAR buffer[0x100];
1106 MSIRECORD * row = 0;
1108 rc = MSI_ViewFetch(view,&row);
1109 if (rc != ERROR_SUCCESS)
1115 /* check conditions */
1116 if (!MSI_RecordIsNull(row,2))
1119 cond = load_dynamic_stringW(row,2);
1123 /* this is a hack to skip errors in the condition code */
1124 if (MSI_EvaluateConditionW(package, cond) ==
1127 HeapFree(GetProcessHeap(),0,cond);
1128 msiobj_release(&row->hdr);
1132 HeapFree(GetProcessHeap(),0,cond);
1137 rc = MSI_RecordGetStringW(row,1,buffer,&sz);
1138 if (rc != ERROR_SUCCESS)
1140 ERR("Error is %x\n",rc);
1141 msiobj_release(&row->hdr);
1145 rc = ACTION_PerformAction(package,buffer);
1147 if (rc == ERROR_FUNCTION_NOT_CALLED)
1150 if (rc != ERROR_SUCCESS)
1152 ERR("Execution halted due to error (%i)\n",rc);
1153 msiobj_release(&row->hdr);
1157 msiobj_release(&row->hdr);
1160 MSI_ViewClose(view);
1161 msiobj_release(&view->hdr);
1168 /********************************************************
1169 * ACTION helper functions and functions that perform the actions
1170 *******************************************************/
1173 * Alot of actions are really important even if they don't do anything
1174 * explicit.. Lots of properties are set at the beginning of the installation
1175 * CostFinalize does a bunch of work to translated the directories and such
1177 * But until I get write access to the database that is hard, so I am going to
1178 * hack it to see if I can get something to run.
1180 UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action)
1182 UINT rc = ERROR_SUCCESS;
1184 TRACE("Performing action (%s)\n",debugstr_w(action));
1185 ui_actioninfo(package, action, TRUE, 0);
1186 ui_actionstart(package, action);
1188 /* pre install, setup and configuration block */
1189 if (strcmpW(action,szLaunchConditions)==0)
1190 rc = ACTION_LaunchConditions(package);
1191 else if (strcmpW(action,szCostInitialize)==0)
1192 rc = ACTION_CostInitialize(package);
1193 else if (strcmpW(action,szFileCost)==0)
1194 rc = ACTION_FileCost(package);
1195 else if (strcmpW(action,szCostFinalize)==0)
1196 rc = ACTION_CostFinalize(package);
1197 else if (strcmpW(action,szInstallValidate)==0)
1198 rc = ACTION_InstallValidate(package);
1201 else if (strcmpW(action,szProcessComponents)==0)
1202 rc = ACTION_ProcessComponents(package);
1203 else if (strcmpW(action,szInstallInitialize)==0)
1204 rc = ACTION_InstallInitialize(package);
1205 else if (strcmpW(action,szCreateFolders)==0)
1206 rc = ACTION_CreateFolders(package);
1207 else if (strcmpW(action,szInstallFiles)==0)
1208 rc = ACTION_InstallFiles(package);
1209 else if (strcmpW(action,szDuplicateFiles)==0)
1210 rc = ACTION_DuplicateFiles(package);
1211 else if (strcmpW(action,szWriteRegistryValues)==0)
1212 rc = ACTION_WriteRegistryValues(package);
1213 else if (strcmpW(action,szRegisterTypeLibraries)==0)
1214 rc = ACTION_RegisterTypeLibraries(package);
1215 else if (strcmpW(action,szRegisterClassInfo)==0)
1216 rc = ACTION_RegisterClassInfo(package);
1217 else if (strcmpW(action,szRegisterProgIdInfo)==0)
1218 rc = ACTION_RegisterProgIdInfo(package);
1219 else if (strcmpW(action,szCreateShortcuts)==0)
1220 rc = ACTION_CreateShortcuts(package);
1221 else if (strcmpW(action,szPublishProduct)==0)
1222 rc = ACTION_PublishProduct(package);
1225 Called during iTunes but unimplemented and seem important
1227 ResolveSource (sets SourceDir)
1231 else if ((rc = ACTION_CustomAction(package,action)) != ERROR_SUCCESS)
1233 FIXME("UNHANDLED MSI ACTION %s\n",debugstr_w(action));
1234 rc = ERROR_FUNCTION_NOT_CALLED;
1237 ui_actioninfo(package, action, FALSE, rc);
1242 static UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action)
1244 UINT rc = ERROR_SUCCESS;
1246 MSIRECORD * row = 0;
1247 static const WCHAR ExecSeqQuery[] =
1248 {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','C','u','s','t','o'
1249 ,'m','A','c','t','i','o','n',' ','w','h','e','r','e',' ','`','A','c','t','i'
1250 ,'o','n','`',' ','=',' ','`','%','s','`',0};
1254 WCHAR *deformated=NULL;
1256 rc = ACTION_OpenQuery(package->db, &view, ExecSeqQuery, action);
1257 if (rc != ERROR_SUCCESS)
1260 rc = MSI_ViewExecute(view, 0);
1261 if (rc != ERROR_SUCCESS)
1263 MSI_ViewClose(view);
1264 msiobj_release(&view->hdr);
1268 rc = MSI_ViewFetch(view,&row);
1269 if (rc != ERROR_SUCCESS)
1271 MSI_ViewClose(view);
1272 msiobj_release(&view->hdr);
1276 type = MSI_RecordGetInteger(row,2);
1278 source = load_dynamic_stringW(row,3);
1279 target = load_dynamic_stringW(row,4);
1281 TRACE("Handling custom action %s (%x %s %s)\n",debugstr_w(action),type,
1282 debugstr_w(source), debugstr_w(target));
1284 /* we are ignoring ALOT of flags and important synchronization stuff */
1285 switch (type & CUSTOM_ACTION_TYPE_MASK)
1287 case 1: /* DLL file stored in a Binary table stream */
1288 rc = HANDLE_CustomType1(package,source,target,type);
1290 case 2: /* EXE file stored in a Binary table strem */
1291 rc = HANDLE_CustomType2(package,source,target,type);
1293 case 18: /*EXE file installed with package */
1294 rc = HANDLE_CustomType18(package,source,target,type);
1296 case 50: /*EXE file specified by a property value */
1297 rc = HANDLE_CustomType50(package,source,target,type);
1299 case 34: /*EXE to be run in specified directory */
1300 rc = HANDLE_CustomType34(package,source,target,type);
1302 case 35: /* Directory set with formatted text. */
1303 deformat_string(package,target,&deformated);
1304 MSI_SetTargetPathW(package, source, deformated);
1305 HeapFree(GetProcessHeap(),0,deformated);
1307 case 51: /* Property set with formatted text. */
1308 deformat_string(package,target,&deformated);
1309 rc = MSI_SetPropertyW(package,source,deformated);
1310 HeapFree(GetProcessHeap(),0,deformated);
1313 FIXME("UNHANDLED ACTION TYPE %i (%s %s)\n",
1314 type & CUSTOM_ACTION_TYPE_MASK, debugstr_w(source),
1315 debugstr_w(target));
1318 HeapFree(GetProcessHeap(),0,source);
1319 HeapFree(GetProcessHeap(),0,target);
1320 msiobj_release(&row->hdr);
1321 MSI_ViewClose(view);
1322 msiobj_release(&view->hdr);
1326 static UINT store_binary_to_temp(MSIPACKAGE *package, const LPWSTR source,
1331 if (MSI_GetPropertyW(package, cszTempFolder, tmp_file, &sz)
1333 GetTempPathW(MAX_PATH,tmp_file);
1335 strcatW(tmp_file,source);
1337 if (GetFileAttributesW(tmp_file) != INVALID_FILE_ATTRIBUTES)
1339 TRACE("File already exists\n");
1340 return ERROR_SUCCESS;
1344 /* write out the file */
1347 MSIRECORD * row = 0;
1348 static const WCHAR fmt[] =
1349 {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','B','i'
1350 ,'n','a','r','y',' ','w','h','e','r','e',' ','N','a','m','e','=','`','%','s','`',0};
1354 if (track_tempfile(package, source, tmp_file)!=0)
1355 FIXME("File Name in temp tracking collision\n");
1357 the_file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
1358 FILE_ATTRIBUTE_NORMAL, NULL);
1360 if (the_file == INVALID_HANDLE_VALUE)
1361 return ERROR_FUNCTION_FAILED;
1363 rc = ACTION_OpenQuery(package->db, &view, fmt, source);
1364 if (rc != ERROR_SUCCESS)
1367 rc = MSI_ViewExecute(view, 0);
1368 if (rc != ERROR_SUCCESS)
1370 MSI_ViewClose(view);
1371 msiobj_release(&view->hdr);
1375 rc = MSI_ViewFetch(view,&row);
1376 if (rc != ERROR_SUCCESS)
1378 MSI_ViewClose(view);
1379 msiobj_release(&view->hdr);
1387 rc = MSI_RecordReadStream(row,2,buffer,&sz);
1388 if (rc != ERROR_SUCCESS)
1390 ERR("Failed to get stream\n");
1391 CloseHandle(the_file);
1392 DeleteFileW(tmp_file);
1395 WriteFile(the_file,buffer,sz,&write,NULL);
1396 } while (sz == 1024);
1398 CloseHandle(the_file);
1400 msiobj_release(&row->hdr);
1401 MSI_ViewClose(view);
1402 msiobj_release(&view->hdr);
1405 return ERROR_SUCCESS;
1408 typedef UINT __stdcall CustomEntry(MSIHANDLE);
1411 MSIPACKAGE *package;
1416 static DWORD WINAPI DllThread(LPVOID info)
1420 thread_struct *stuff;
1423 stuff = (thread_struct*)info;
1425 TRACE("Asynchronous start (%s, %s) \n", debugstr_w(stuff->source),
1426 debugstr_w(stuff->target));
1428 DLL = LoadLibraryW(stuff->source);
1431 proc = strdupWtoA( stuff->target );
1432 fn = (CustomEntry*)GetProcAddress(DLL,proc);
1436 MSIPACKAGE *package = stuff->package;
1438 TRACE("Calling function\n");
1439 hPackage = msiobj_findhandle( &package->hdr );
1441 ERR("Handle for object %p not found\n", package );
1443 msiobj_release( &package->hdr );
1446 ERR("Cannot load functon\n");
1448 HeapFree(GetProcessHeap(),0,proc);
1452 ERR("Unable to load library\n");
1453 msiobj_release( &stuff->package->hdr );
1454 HeapFree(GetProcessHeap(),0,stuff->source);
1455 HeapFree(GetProcessHeap(),0,stuff->target);
1456 HeapFree(GetProcessHeap(), 0, stuff);
1460 static UINT HANDLE_CustomType1(MSIPACKAGE *package, const LPWSTR source,
1461 const LPWSTR target, const INT type)
1463 WCHAR tmp_file[MAX_PATH];
1468 store_binary_to_temp(package, source, tmp_file);
1470 TRACE("Calling function %s from %s\n",debugstr_w(target),
1471 debugstr_w(tmp_file));
1473 if (!strchrW(tmp_file,'.'))
1475 static const WCHAR dot[]={'.',0};
1476 strcatW(tmp_file,dot);
1482 HANDLE ThreadHandle;
1483 thread_struct *info = HeapAlloc( GetProcessHeap(), 0, sizeof(*info) );
1485 msiobj_addref( &package->hdr );
1486 info->package = package;
1487 info->target = dupstrW(target);
1488 info->source = dupstrW(tmp_file);
1489 TRACE("Start Asynchronous execution of dll\n");
1490 ThreadHandle = CreateThread(NULL,0,DllThread,(LPVOID)info,0,&ThreadId);
1491 CloseHandle(ThreadHandle);
1492 /* FIXME: release the package if the CreateThread fails */
1493 return ERROR_SUCCESS;
1496 DLL = LoadLibraryW(tmp_file);
1499 proc = strdupWtoA( target );
1500 fn = (CustomEntry*)GetProcAddress(DLL,proc);
1505 TRACE("Calling function\n");
1506 hPackage = msiobj_findhandle( &package->hdr );
1508 ERR("Handle for object %p not found\n", package );
1510 msiobj_release( &package->hdr );
1513 ERR("Cannot load functon\n");
1515 HeapFree(GetProcessHeap(),0,proc);
1519 ERR("Unable to load library\n");
1521 return ERROR_SUCCESS;
1524 static UINT HANDLE_CustomType2(MSIPACKAGE *package, const LPWSTR source,
1525 const LPWSTR target, const INT type)
1527 WCHAR tmp_file[MAX_PATH];
1529 PROCESS_INFORMATION info;
1534 static const WCHAR spc[] = {' ',0};
1536 memset(&si,0,sizeof(STARTUPINFOW));
1538 store_binary_to_temp(package, source, tmp_file);
1540 deformat_string(package,target,&deformated);
1542 len = strlenW(tmp_file) + strlenW(deformated) + 2;
1544 cmd = (WCHAR*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*len);
1546 strcpyW(cmd,tmp_file);
1548 strcatW(cmd,deformated);
1550 HeapFree(GetProcessHeap(),0,deformated);
1552 TRACE("executing exe %s \n",debugstr_w(cmd));
1554 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
1555 c_collen, &si, &info);
1557 HeapFree(GetProcessHeap(),0,cmd);
1561 ERR("Unable to execute command\n");
1562 return ERROR_SUCCESS;
1566 WaitForSingleObject(info.hProcess,INFINITE);
1568 CloseHandle( info.hProcess );
1569 CloseHandle( info.hThread );
1570 return ERROR_SUCCESS;
1573 static UINT HANDLE_CustomType18(MSIPACKAGE *package, const LPWSTR source,
1574 const LPWSTR target, const INT type)
1577 PROCESS_INFORMATION info;
1582 static const WCHAR spc[] = {' ',0};
1585 memset(&si,0,sizeof(STARTUPINFOW));
1587 index = get_loaded_file(package,source);
1589 len = strlenW(package->files[index].TargetPath);
1591 deformat_string(package,target,&deformated);
1592 len += strlenW(deformated);
1595 cmd = (WCHAR*)HeapAlloc(GetProcessHeap(),0,len * sizeof(WCHAR));
1597 strcpyW(cmd, package->files[index].TargetPath);
1599 strcatW(cmd, deformated);
1601 HeapFree(GetProcessHeap(),0,deformated);
1603 TRACE("executing exe %s \n",debugstr_w(cmd));
1605 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
1606 c_collen, &si, &info);
1608 HeapFree(GetProcessHeap(),0,cmd);
1612 ERR("Unable to execute command\n");
1613 return ERROR_SUCCESS;
1617 WaitForSingleObject(info.hProcess,INFINITE);
1619 CloseHandle( info.hProcess );
1620 CloseHandle( info.hThread );
1621 return ERROR_SUCCESS;
1624 static UINT HANDLE_CustomType50(MSIPACKAGE *package, const LPWSTR source,
1625 const LPWSTR target, const INT type)
1628 PROCESS_INFORMATION info;
1635 static const WCHAR spc[] = {' ',0};
1637 memset(&si,0,sizeof(STARTUPINFOW));
1638 memset(&info,0,sizeof(PROCESS_INFORMATION));
1640 prop = load_dynamic_property(package,source,&prc);
1644 deformat_string(package,target,&deformated);
1645 len = strlenW(prop) + strlenW(deformated) + 2;
1646 cmd = (WCHAR*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*len);
1650 strcatW(cmd,deformated);
1652 HeapFree(GetProcessHeap(),0,deformated);
1654 TRACE("executing exe %s \n",debugstr_w(cmd));
1656 rc = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
1657 c_collen, &si, &info);
1659 HeapFree(GetProcessHeap(),0,cmd);
1663 ERR("Unable to execute command\n");
1664 return ERROR_SUCCESS;
1668 WaitForSingleObject(info.hProcess,INFINITE);
1670 CloseHandle( info.hProcess );
1671 CloseHandle( info.hThread );
1672 return ERROR_SUCCESS;
1675 static UINT HANDLE_CustomType34(MSIPACKAGE *package, const LPWSTR source,
1676 const LPWSTR target, const INT type)
1678 LPWSTR filename, deformated;
1680 PROCESS_INFORMATION info;
1683 memset(&si,0,sizeof(STARTUPINFOW));
1685 filename = resolve_folder(package, source, FALSE, FALSE, NULL);
1688 return ERROR_FUNCTION_FAILED;
1690 SetCurrentDirectoryW(filename);
1691 HeapFree(GetProcessHeap(),0,filename);
1693 deformat_string(package,target,&deformated);
1695 TRACE("executing exe %s \n",debugstr_w(deformated));
1697 rc = CreateProcessW(NULL, deformated, NULL, NULL, FALSE, 0, NULL,
1698 c_collen, &si, &info);
1699 HeapFree(GetProcessHeap(),0,deformated);
1703 ERR("Unable to execute command\n");
1704 return ERROR_SUCCESS;
1708 WaitForSingleObject(info.hProcess,INFINITE);
1710 CloseHandle( info.hProcess );
1711 CloseHandle( info.hThread );
1712 return ERROR_SUCCESS;
1715 /***********************************************************************
1718 * Recursively create all directories in the path.
1720 * shamelessly stolen from setupapi/queue.c
1722 static BOOL create_full_pathW(const WCHAR *path)
1728 new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) *
1731 strcpyW(new_path, path);
1733 while((len = strlenW(new_path)) && new_path[len - 1] == '\\')
1734 new_path[len - 1] = 0;
1736 while(!CreateDirectoryW(new_path, NULL))
1739 DWORD last_error = GetLastError();
1740 if(last_error == ERROR_ALREADY_EXISTS)
1743 if(last_error != ERROR_PATH_NOT_FOUND)
1749 if(!(slash = strrchrW(new_path, '\\')))
1755 len = slash - new_path;
1757 if(!create_full_pathW(new_path))
1762 new_path[len] = '\\';
1765 HeapFree(GetProcessHeap(), 0, new_path);
1770 * Also we cannot enable/disable components either, so for now I am just going
1771 * to do all the directories for all the components.
1773 static UINT ACTION_CreateFolders(MSIPACKAGE *package)
1775 static const WCHAR ExecSeqQuery[] = {
1776 's','e','l','e','c','t',' ','D','i','r','e','c','t','o','r','y','_',' ',
1777 'f','r','o','m',' ','C','r','e','a','t','e','F','o','l','d','e','r',0 };
1782 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view );
1783 if (rc != ERROR_SUCCESS)
1784 return ERROR_SUCCESS;
1786 rc = MSI_ViewExecute(view, 0);
1787 if (rc != ERROR_SUCCESS)
1789 MSI_ViewClose(view);
1790 msiobj_release(&view->hdr);
1799 MSIRECORD *row = NULL, *uirow;
1801 rc = MSI_ViewFetch(view,&row);
1802 if (rc != ERROR_SUCCESS)
1809 rc = MSI_RecordGetStringW(row,1,dir,&sz);
1811 if (rc!= ERROR_SUCCESS)
1813 ERR("Unable to get folder id \n");
1814 msiobj_release(&row->hdr);
1819 full_path = resolve_folder(package,dir,FALSE,FALSE,&folder);
1822 ERR("Unable to resolve folder id %s\n",debugstr_w(dir));
1823 msiobj_release(&row->hdr);
1827 TRACE("Folder is %s\n",debugstr_w(full_path));
1830 uirow = MSI_CreateRecord(1);
1831 MSI_RecordSetStringW(uirow,1,full_path);
1832 ui_actiondata(package,szCreateFolders,uirow);
1833 msiobj_release( &uirow->hdr );
1835 if (folder->State == 0)
1836 create_full_pathW(full_path);
1840 msiobj_release(&row->hdr);
1841 HeapFree(GetProcessHeap(),0,full_path);
1843 MSI_ViewClose(view);
1844 msiobj_release(&view->hdr);
1849 static int load_component(MSIPACKAGE* package, MSIRECORD * row)
1851 int index = package->loaded_components;
1854 /* fill in the data */
1856 package->loaded_components++;
1857 if (package->loaded_components == 1)
1858 package->components = HeapAlloc(GetProcessHeap(),0,
1859 sizeof(MSICOMPONENT));
1861 package->components = HeapReAlloc(GetProcessHeap(),0,
1862 package->components, package->loaded_components *
1863 sizeof(MSICOMPONENT));
1865 memset(&package->components[index],0,sizeof(MSICOMPONENT));
1868 MSI_RecordGetStringW(row,1,package->components[index].Component,&sz);
1870 TRACE("Loading Component %s\n",
1871 debugstr_w(package->components[index].Component));
1874 if (!MSI_RecordIsNull(row,2))
1875 MSI_RecordGetStringW(row,2,package->components[index].ComponentId,&sz);
1878 MSI_RecordGetStringW(row,3,package->components[index].Directory,&sz);
1880 package->components[index].Attributes = MSI_RecordGetInteger(row,4);
1883 MSI_RecordGetStringW(row,5,package->components[index].Condition,&sz);
1886 MSI_RecordGetStringW(row,6,package->components[index].KeyPath,&sz);
1888 package->components[index].Installed = INSTALLSTATE_ABSENT;
1889 package->components[index].Action = INSTALLSTATE_UNKNOWN;
1890 package->components[index].ActionRequest = INSTALLSTATE_UNKNOWN;
1892 package->components[index].Enabled = TRUE;
1897 static void load_feature(MSIPACKAGE* package, MSIRECORD * row)
1899 int index = package->loaded_features;
1901 static const WCHAR Query1[] = {'S','E','L','E','C','T',' ','C','o','m','p',
1902 'o','n','e','n','t','_',' ','F','R','O','M',' ','F','e','a','t','u','r','e',
1903 'C','o','m','p','o','n','e','n','t','s',' ','W','H','E','R','E',' ','F','e',
1904 'a','t','u','r','e','_','=','\'','%','s','\'',0};
1905 static const WCHAR Query2[] = {'S','E','L','E','C','T',' ','*',' ','F','R',
1906 'O','M',' ','C','o','m','p','o','n','e','n','t',' ','W','H','E','R','E',' ','C',
1907 'o','m','p','o','n','e','n','t','=','\'','%','s','\'',0};
1914 /* fill in the data */
1916 package->loaded_features ++;
1917 if (package->loaded_features == 1)
1918 package->features = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFEATURE));
1920 package->features = HeapReAlloc(GetProcessHeap(),0,package->features,
1921 package->loaded_features * sizeof(MSIFEATURE));
1923 memset(&package->features[index],0,sizeof(MSIFEATURE));
1926 MSI_RecordGetStringW(row,1,package->features[index].Feature,&sz);
1928 TRACE("Loading feature %s\n",debugstr_w(package->features[index].Feature));
1931 if (!MSI_RecordIsNull(row,2))
1932 MSI_RecordGetStringW(row,2,package->features[index].Feature_Parent,&sz);
1935 if (!MSI_RecordIsNull(row,3))
1936 MSI_RecordGetStringW(row,3,package->features[index].Title,&sz);
1939 if (!MSI_RecordIsNull(row,4))
1940 MSI_RecordGetStringW(row,4,package->features[index].Description,&sz);
1942 if (!MSI_RecordIsNull(row,5))
1943 package->features[index].Display = MSI_RecordGetInteger(row,5);
1945 package->features[index].Level= MSI_RecordGetInteger(row,6);
1948 if (!MSI_RecordIsNull(row,7))
1949 MSI_RecordGetStringW(row,7,package->features[index].Directory,&sz);
1951 package->features[index].Attributes= MSI_RecordGetInteger(row,8);
1953 package->features[index].Installed = INSTALLSTATE_ABSENT;
1954 package->features[index].Action = INSTALLSTATE_UNKNOWN;
1955 package->features[index].ActionRequest = INSTALLSTATE_UNKNOWN;
1957 /* load feature components */
1959 rc = ACTION_OpenQuery(package->db, &view, Query1, package->features[index].Feature);
1960 if (rc != ERROR_SUCCESS)
1962 rc = MSI_ViewExecute(view,0);
1963 if (rc != ERROR_SUCCESS)
1965 MSI_ViewClose(view);
1966 msiobj_release(&view->hdr);
1972 WCHAR buffer[0x100];
1975 INT cnt = package->features[index].ComponentCount;
1977 rc = MSI_ViewFetch(view,&row2);
1978 if (rc != ERROR_SUCCESS)
1982 MSI_RecordGetStringW(row2,1,buffer,&sz);
1984 /* check to see if the component is already loaded */
1985 c_indx = get_loaded_component(package,buffer);
1988 TRACE("Component %s already loaded at %i\n", debugstr_w(buffer),
1990 package->features[index].Components[cnt] = c_indx;
1991 package->features[index].ComponentCount ++;
1995 rc = ACTION_OpenQuery(package->db, &view2, Query2, buffer);
1996 if (rc != ERROR_SUCCESS)
1998 msiobj_release( &row2->hdr );
2001 rc = MSI_ViewExecute(view2,0);
2002 if (rc != ERROR_SUCCESS)
2004 msiobj_release( &row2->hdr );
2005 MSI_ViewClose(view2);
2006 msiobj_release( &view2->hdr );
2013 rc = MSI_ViewFetch(view2,&row3);
2014 if (rc != ERROR_SUCCESS)
2016 c_indx = load_component(package,row3);
2017 msiobj_release( &row3->hdr );
2019 package->features[index].Components[cnt] = c_indx;
2020 package->features[index].ComponentCount ++;
2021 TRACE("Loaded new component to index %i\n",c_indx);
2023 MSI_ViewClose(view2);
2024 msiobj_release( &view2->hdr );
2025 msiobj_release( &row2->hdr );
2027 MSI_ViewClose(view);
2028 msiobj_release(&view->hdr);
2032 * I am not doing any of the costing functionality yet.
2033 * Mostly looking at doing the Component and Feature loading
2035 * The native MSI does ALOT of modification to tables here. Mostly adding alot
2036 * of temporary columns to the Feature and Component tables.
2038 * note: native msi also tracks the short filename. but I am only going to
2039 * track the long ones. Also looking at this directory table
2040 * it appears that the directory table does not get the parents
2041 * resolved base on property only based on their entrys in the
2044 static UINT ACTION_CostInitialize(MSIPACKAGE *package)
2049 static const WCHAR Query_all[] = {
2050 'S','E','L','E','C','T',' ','*',' ',
2051 'F','R','O','M',' ','F','e','a','t','u','r','e',0};
2052 static const WCHAR szCosting[] = {
2053 'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
2054 static const WCHAR szZero[] = { '0', 0 };
2056 MSI_SetPropertyW(package, szCosting, szZero);
2057 MSI_SetPropertyW(package, cszRootDrive , c_collen);
2059 rc = MSI_DatabaseOpenViewW(package->db,Query_all,&view);
2060 if (rc != ERROR_SUCCESS)
2062 rc = MSI_ViewExecute(view,0);
2063 if (rc != ERROR_SUCCESS)
2065 MSI_ViewClose(view);
2066 msiobj_release(&view->hdr);
2073 rc = MSI_ViewFetch(view,&row);
2074 if (rc != ERROR_SUCCESS)
2077 load_feature(package,row);
2078 msiobj_release(&row->hdr);
2080 MSI_ViewClose(view);
2081 msiobj_release(&view->hdr);
2083 return ERROR_SUCCESS;
2086 static UINT load_file(MSIPACKAGE* package, MSIRECORD * row)
2088 DWORD index = package->loaded_files;
2092 /* fill in the data */
2094 package->loaded_files++;
2095 if (package->loaded_files== 1)
2096 package->files = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE));
2098 package->files = HeapReAlloc(GetProcessHeap(),0,
2099 package->files , package->loaded_files * sizeof(MSIFILE));
2101 memset(&package->files[index],0,sizeof(MSIFILE));
2103 package->files[index].File = load_dynamic_stringW(row, 1);
2104 buffer = load_dynamic_stringW(row, 2);
2106 package->files[index].ComponentIndex = -1;
2107 for (i = 0; i < package->loaded_components; i++)
2108 if (strcmpW(package->components[i].Component,buffer)==0)
2110 package->files[index].ComponentIndex = i;
2113 if (package->files[index].ComponentIndex == -1)
2114 ERR("Unfound Component %s\n",debugstr_w(buffer));
2115 HeapFree(GetProcessHeap(), 0, buffer);
2117 package->files[index].FileName = load_dynamic_stringW(row,3);
2119 reduce_to_longfilename(package->files[index].FileName);
2121 package->files[index].FileSize = MSI_RecordGetInteger(row,4);
2122 package->files[index].Version = load_dynamic_stringW(row, 5);
2123 package->files[index].Language = load_dynamic_stringW(row, 6);
2124 package->files[index].Attributes= MSI_RecordGetInteger(row,7);
2125 package->files[index].Sequence= MSI_RecordGetInteger(row,8);
2127 package->files[index].Temporary = FALSE;
2128 package->files[index].State = 0;
2130 TRACE("File Loaded (%s)\n",debugstr_w(package->files[index].File));
2132 return ERROR_SUCCESS;
2135 static UINT ACTION_FileCost(MSIPACKAGE *package)
2140 static const WCHAR Query[] = {
2141 'S','E','L','E','C','T',' ','*',' ',
2142 'F','R','O','M',' ','F','i','l','e',' ',
2143 'O','r','d','e','r',' ','b','y',' ','S','e','q','u','e','n','c','e', 0};
2146 return ERROR_INVALID_HANDLE;
2148 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
2149 if (rc != ERROR_SUCCESS)
2150 return ERROR_SUCCESS;
2152 rc = MSI_ViewExecute(view, 0);
2153 if (rc != ERROR_SUCCESS)
2155 MSI_ViewClose(view);
2156 msiobj_release(&view->hdr);
2157 return ERROR_SUCCESS;
2162 rc = MSI_ViewFetch(view,&row);
2163 if (rc != ERROR_SUCCESS)
2168 load_file(package,row);
2169 msiobj_release(&row->hdr);
2171 MSI_ViewClose(view);
2172 msiobj_release(&view->hdr);
2174 return ERROR_SUCCESS;
2177 static INT load_folder(MSIPACKAGE *package, const WCHAR* dir)
2180 static const WCHAR Query[] =
2181 {'s','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','D','i','r','e','c',
2182 't','o','r','y',' ','w','h','e','r','e',' ','`','D','i','r','e','c','t',
2183 'o','r','y','`',' ','=',' ','`','%','s','`',0};
2186 LPWSTR targetdir, parent, srcdir;
2187 MSIRECORD * row = 0;
2191 TRACE("Looking for dir %s\n",debugstr_w(dir));
2193 for (i = 0; i < package->loaded_folders; i++)
2195 if (strcmpW(package->folders[i].Directory,dir)==0)
2197 TRACE(" %s retuning on index %lu\n",debugstr_w(dir),i);
2202 TRACE("Working to load %s\n",debugstr_w(dir));
2204 index = package->loaded_folders++;
2205 if (package->loaded_folders==1)
2206 package->folders = HeapAlloc(GetProcessHeap(),0,
2209 package->folders= HeapReAlloc(GetProcessHeap(),0,
2210 package->folders, package->loaded_folders*
2213 memset(&package->folders[index],0,sizeof(MSIFOLDER));
2215 package->folders[index].Directory = dupstrW(dir);
2217 rc = ACTION_OpenQuery(package->db, &view, Query, dir);
2218 if (rc != ERROR_SUCCESS)
2221 rc = MSI_ViewExecute(view, 0);
2222 if (rc != ERROR_SUCCESS)
2224 MSI_ViewClose(view);
2225 msiobj_release(&view->hdr);
2229 rc = MSI_ViewFetch(view,&row);
2230 if (rc != ERROR_SUCCESS)
2232 MSI_ViewClose(view);
2233 msiobj_release(&view->hdr);
2237 targetdir = load_dynamic_stringW(row,3);
2239 /* split src and target dir */
2240 if (strchrW(targetdir,':'))
2242 srcdir=strchrW(targetdir,':');
2249 /* for now only pick long filename versions */
2250 if (strchrW(targetdir,'|'))
2252 targetdir = strchrW(targetdir,'|');
2256 if (srcdir && strchrW(srcdir,'|'))
2258 srcdir= strchrW(srcdir,'|');
2263 /* now check for root dirs */
2264 if (targetdir[0] == '.' && targetdir[1] == 0)
2267 if (srcdir && srcdir[0] == '.' && srcdir[1] == 0)
2272 TRACE(" TargetDefault = %s\n",debugstr_w(targetdir));
2273 if (package->folders[index].TargetDefault)
2274 HeapFree(GetProcessHeap(),0, package->folders[index].TargetDefault);
2275 package->folders[index].TargetDefault = dupstrW(targetdir);
2279 package->folders[index].SourceDefault = dupstrW(srcdir);
2281 package->folders[index].SourceDefault = dupstrW(targetdir);
2282 HeapFree(GetProcessHeap(), 0, targetdir);
2284 parent = load_dynamic_stringW(row,2);
2287 i = load_folder(package,parent);
2288 package->folders[index].ParentIndex = i;
2289 TRACE("Parent is index %i... %s %s\n",
2290 package->folders[index].ParentIndex,
2291 debugstr_w(package->folders[package->folders[index].ParentIndex].Directory),
2292 debugstr_w(parent));
2295 package->folders[index].ParentIndex = -2;
2296 HeapFree(GetProcessHeap(), 0, parent);
2298 package->folders[index].Property = load_dynamic_property(package, dir,NULL);
2300 msiobj_release(&row->hdr);
2301 MSI_ViewClose(view);
2302 msiobj_release(&view->hdr);
2303 TRACE(" %s retuning on index %i\n",debugstr_w(dir),index);
2308 static LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name,
2309 BOOL source, BOOL set_prop, MSIFOLDER **folder)
2312 LPWSTR p, path = NULL;
2314 TRACE("Working to resolve %s\n",debugstr_w(name));
2316 /* special resolving for Target and Source root dir */
2317 if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
2321 path = load_dynamic_property(package,cszTargetDir,NULL);
2324 path = load_dynamic_property(package,cszRootDrive,NULL);
2326 MSI_SetPropertyW(package,cszTargetDir,path);
2330 for (i = 0; i < package->loaded_folders; i++)
2332 if (strcmpW(package->folders[i].Directory,name)==0)
2335 *folder = &(package->folders[i]);
2341 path = load_dynamic_property(package,cszSourceDir,NULL);
2344 path = load_dynamic_property(package,cszDatabase,NULL);
2347 p = strrchrW(path,'\\');
2354 for (i = 0; i < package->loaded_folders; i++)
2356 if (strcmpW(package->folders[i].Directory,name)==0)
2359 *folder = &(package->folders[i]);
2365 for (i = 0; i < package->loaded_folders; i++)
2367 if (strcmpW(package->folders[i].Directory,name)==0)
2371 if (i >= package->loaded_folders)
2375 *folder = &(package->folders[i]);
2377 if (!source && package->folders[i].ResolvedTarget)
2379 path = dupstrW(package->folders[i].ResolvedTarget);
2380 TRACE(" already resolved to %s\n",debugstr_w(path));
2383 else if (source && package->folders[i].ResolvedSource)
2385 path = dupstrW(package->folders[i].ResolvedSource);
2388 else if (!source && package->folders[i].Property)
2390 path = dupstrW(package->folders[i].Property);
2391 TRACE(" internally set to %s\n",debugstr_w(path));
2393 MSI_SetPropertyW(package,name,path);
2397 if (package->folders[i].ParentIndex >= 0)
2399 LPWSTR parent = package->folders[package->folders[i].ParentIndex].Directory;
2401 TRACE(" ! Parent is %s\n", debugstr_w(parent));
2403 p = resolve_folder(package, parent, source, set_prop, NULL);
2406 TRACE(" TargetDefault = %s\n",debugstr_w(package->folders[i].TargetDefault));
2407 path = build_directory_name(3, p, package->folders[i].TargetDefault, NULL);
2408 package->folders[i].ResolvedTarget = dupstrW(path);
2409 TRACE(" resolved into %s\n",debugstr_w(path));
2411 MSI_SetPropertyW(package,name,path);
2415 path = build_directory_name(3, p, package->folders[i].SourceDefault, NULL);
2416 package->folders[i].ResolvedSource = dupstrW(path);
2418 HeapFree(GetProcessHeap(),0,p);
2423 static UINT SetFeatureStates(MSIPACKAGE *package)
2429 LPWSTR override = NULL;
2430 static const WCHAR all[]={'A','L','L',0};
2431 static const WCHAR szlevel[] = {
2432 'I','N','S','T','A','L','L','L','E','V','E','L',0};
2433 static const WCHAR szAddLocal[] = {
2434 'A','D','D','L','O','C','A','L',0};
2436 /* I do not know if this is where it should happen.. but */
2438 TRACE("Checking Install Level\n");
2440 level = load_dynamic_property(package,szlevel,NULL);
2443 install_level = atoiW(level);
2444 HeapFree(GetProcessHeap(), 0, level);
2449 /* ok hereis the rub
2450 * ADDLOCAL and its friend OVERRIDE INSTALLLEVLE
2451 * I have confirmed this if ADDLOCALis stated then the INSTALLLEVEL is
2452 * itnored for all the features. seems strange, epsecially since it is not
2453 * documented anywhere, but it is how it works.
2456 override = load_dynamic_property(package,szAddLocal,NULL);
2460 for(i = 0; i < package->loaded_features; i++)
2462 if (strcmpiW(override,all)==0)
2464 package->features[i].ActionRequest= INSTALLSTATE_LOCAL;
2465 package->features[i].Action = INSTALLSTATE_LOCAL;
2469 LPWSTR ptr = override;
2470 LPWSTR ptr2 = strchrW(override,',');
2475 strncmpW(ptr,package->features[i].Feature, ptr2-ptr)==0)
2477 strcmpW(ptr,package->features[i].Feature)==0))
2479 package->features[i].ActionRequest= INSTALLSTATE_LOCAL;
2480 package->features[i].Action = INSTALLSTATE_LOCAL;
2486 ptr2 = strchrW(ptr,',');
2493 HeapFree(GetProcessHeap(),0,override);
2497 for(i = 0; i < package->loaded_features; i++)
2499 BOOL feature_state= ((package->features[i].Level > 0) &&
2500 (package->features[i].Level <= install_level));
2504 package->features[i].ActionRequest= INSTALLSTATE_LOCAL;
2505 package->features[i].Action = INSTALLSTATE_LOCAL;
2511 * now we want to enable or disable components base on feature
2514 for(i = 0; i < package->loaded_features; i++)
2516 MSIFEATURE* feature = &package->features[i];
2517 TRACE("Examining Feature %s (Installed %i, Action %i, Request %i)\n",
2518 debugstr_w(feature->Feature), feature->Installed, feature->Action,
2519 feature->ActionRequest);
2521 for( j = 0; j < feature->ComponentCount; j++)
2523 MSICOMPONENT* component = &package->components[
2524 feature->Components[j]];
2526 if (!component->Enabled)
2528 component->Action = INSTALLSTATE_ABSENT;
2529 component->ActionRequest = INSTALLSTATE_ABSENT;
2533 if (feature->Action == INSTALLSTATE_LOCAL)
2534 component->Action = INSTALLSTATE_LOCAL;
2535 if (feature->ActionRequest == INSTALLSTATE_LOCAL)
2536 component->ActionRequest = INSTALLSTATE_LOCAL;
2541 for(i = 0; i < package->loaded_components; i++)
2543 MSICOMPONENT* component= &package->components[i];
2545 TRACE("Result: Component %s (Installed %i, Action %i, Request %i)\n",
2546 debugstr_w(component->Component), component->Installed,
2547 component->Action, component->ActionRequest);
2551 return ERROR_SUCCESS;
2555 * Alot is done in this function aside from just the costing.
2556 * The costing needs to be implemented at some point but for now I am going
2557 * to focus on the directory building
2560 static UINT ACTION_CostFinalize(MSIPACKAGE *package)
2562 static const WCHAR ExecSeqQuery[] = {
2563 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ',
2564 'D','i','r','e','c','t','o','r','y',0};
2565 static const WCHAR ConditionQuery[] = {
2566 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ',
2567 'C','o','n','d','i','t','i','o','n',0};
2568 static const WCHAR szCosting[] = {
2569 'C','o','s','t','i','n','g','C','o','m','p','l','e','t','e',0 };
2570 static const WCHAR szlevel[] = {
2571 'I','N','S','T','A','L','L','L','E','V','E','L',0};
2572 static const WCHAR szOne[] = { '1', 0 };
2578 TRACE("Building Directory properties\n");
2580 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
2581 if (rc == ERROR_SUCCESS)
2583 rc = MSI_ViewExecute(view, 0);
2584 if (rc != ERROR_SUCCESS)
2586 MSI_ViewClose(view);
2587 msiobj_release(&view->hdr);
2595 MSIRECORD * row = 0;
2598 rc = MSI_ViewFetch(view,&row);
2599 if (rc != ERROR_SUCCESS)
2606 MSI_RecordGetStringW(row,1,name,&sz);
2608 /* This helper function now does ALL the work */
2609 TRACE("Dir %s ...\n",debugstr_w(name));
2610 load_folder(package,name);
2611 path = resolve_folder(package,name,FALSE,TRUE,NULL);
2612 TRACE("resolves to %s\n",debugstr_w(path));
2613 HeapFree( GetProcessHeap(), 0, path);
2615 msiobj_release(&row->hdr);
2617 MSI_ViewClose(view);
2618 msiobj_release(&view->hdr);
2621 TRACE("File calculations %i files\n",package->loaded_files);
2623 for (i = 0; i < package->loaded_files; i++)
2625 MSICOMPONENT* comp = NULL;
2626 MSIFILE* file= NULL;
2628 file = &package->files[i];
2629 if (file->ComponentIndex >= 0)
2630 comp = &package->components[file->ComponentIndex];
2632 if (file->Temporary == TRUE)
2639 /* calculate target */
2640 p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL);
2642 if (file->TargetPath)
2643 HeapFree(GetProcessHeap(),0,file->TargetPath);
2645 TRACE("file %s is named %s\n",
2646 debugstr_w(file->File),debugstr_w(file->FileName));
2648 file->TargetPath = build_directory_name(2, p, file->FileName);
2650 HeapFree(GetProcessHeap(),0,p);
2652 TRACE("file %s resolves to %s\n",
2653 debugstr_w(file->File),debugstr_w(file->TargetPath));
2655 if (GetFileAttributesW(file->TargetPath) == INVALID_FILE_ATTRIBUTES)
2658 comp->Cost += file->FileSize;
2668 static const WCHAR name[] =
2670 static const WCHAR name_fmt[] =
2671 {'%','u','.','%','u','.','%','u','.','%','u',0};
2672 WCHAR filever[0x100];
2673 VS_FIXEDFILEINFO *lpVer;
2675 FIXME("Version comparison.. \n");
2676 versize = GetFileVersionInfoSizeW(file->TargetPath,&handle);
2677 version = HeapAlloc(GetProcessHeap(),0,versize);
2678 GetFileVersionInfoW(file->TargetPath, 0, versize, version);
2680 VerQueryValueW(version, name, (LPVOID*)&lpVer, &sz);
2682 sprintfW(filever,name_fmt,
2683 HIWORD(lpVer->dwFileVersionMS),
2684 LOWORD(lpVer->dwFileVersionMS),
2685 HIWORD(lpVer->dwFileVersionLS),
2686 LOWORD(lpVer->dwFileVersionLS));
2688 TRACE("new %s old %s\n", debugstr_w(file->Version),
2689 debugstr_w(filever));
2690 if (strcmpiW(filever,file->Version)<0)
2693 FIXME("cost should be diff in size\n");
2694 comp->Cost += file->FileSize;
2698 HeapFree(GetProcessHeap(),0,version);
2706 TRACE("Evaluating Condition Table\n");
2708 rc = MSI_DatabaseOpenViewW(package->db, ConditionQuery, &view);
2709 if (rc == ERROR_SUCCESS)
2711 rc = MSI_ViewExecute(view, 0);
2712 if (rc != ERROR_SUCCESS)
2714 MSI_ViewClose(view);
2715 msiobj_release(&view->hdr);
2721 WCHAR Feature[0x100];
2722 MSIRECORD * row = 0;
2726 rc = MSI_ViewFetch(view,&row);
2728 if (rc != ERROR_SUCCESS)
2735 MSI_RecordGetStringW(row,1,Feature,&sz);
2737 feature_index = get_loaded_feature(package,Feature);
2738 if (feature_index < 0)
2739 ERR("FAILED to find loaded feature %s\n",debugstr_w(Feature));
2743 Condition = load_dynamic_stringW(row,3);
2745 if (MSI_EvaluateConditionW(package,Condition) ==
2748 int level = MSI_RecordGetInteger(row,2);
2749 TRACE("Reseting feature %s to level %i\n",
2750 debugstr_w(Feature), level);
2751 package->features[feature_index].Level = level;
2753 HeapFree(GetProcessHeap(),0,Condition);
2756 msiobj_release(&row->hdr);
2758 MSI_ViewClose(view);
2759 msiobj_release(&view->hdr);
2762 TRACE("Enabling or Disabling Components\n");
2763 for (i = 0; i < package->loaded_components; i++)
2765 if (package->components[i].Condition[0])
2767 if (MSI_EvaluateConditionW(package,
2768 package->components[i].Condition) == MSICONDITION_FALSE)
2770 TRACE("Disabling component %s\n",
2771 debugstr_w(package->components[i].Component));
2772 package->components[i].Enabled = FALSE;
2777 MSI_SetPropertyW(package,szCosting,szOne);
2778 /* set default run level if not set */
2779 level = load_dynamic_property(package,szlevel,NULL);
2781 MSI_SetPropertyW(package,szlevel, szOne);
2783 HeapFree(GetProcessHeap(),0,level);
2785 return SetFeatureStates(package);
2790 * This is a helper function for handling embedded cabinet media
2792 static UINT writeout_cabinet_stream(MSIPACKAGE *package, WCHAR* stream_name,
2800 WCHAR tmp[MAX_PATH];
2802 rc = read_raw_stream_data(package->db,stream_name,&data,&size);
2803 if (rc != ERROR_SUCCESS)
2807 if (MSI_GetPropertyW(package, cszTempFolder, tmp, &write))
2808 GetTempPathW(MAX_PATH,tmp);
2810 GetTempFileNameW(tmp,stream_name,0,source);
2812 track_tempfile(package,strrchrW(source,'\\'), source);
2813 the_file = CreateFileW(source, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2814 FILE_ATTRIBUTE_NORMAL, NULL);
2816 if (the_file == INVALID_HANDLE_VALUE)
2818 rc = ERROR_FUNCTION_FAILED;
2822 WriteFile(the_file,data,size,&write,NULL);
2823 CloseHandle(the_file);
2824 TRACE("wrote %li bytes to %s\n",write,debugstr_w(source));
2826 HeapFree(GetProcessHeap(),0,data);
2831 /* Support functions for FDI functions */
2834 MSIPACKAGE* package;
2839 static void * cabinet_alloc(ULONG cb)
2841 return HeapAlloc(GetProcessHeap(), 0, cb);
2844 static void cabinet_free(void *pv)
2846 HeapFree(GetProcessHeap(), 0, pv);
2849 static INT_PTR cabinet_open(char *pszFile, int oflag, int pmode)
2852 DWORD dwShareMode = 0;
2853 DWORD dwCreateDisposition = OPEN_EXISTING;
2854 switch (oflag & _O_ACCMODE)
2857 dwAccess = GENERIC_READ;
2858 dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;
2861 dwAccess = GENERIC_WRITE;
2862 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
2865 dwAccess = GENERIC_READ | GENERIC_WRITE;
2866 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
2869 if ((oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
2870 dwCreateDisposition = CREATE_NEW;
2871 else if (oflag & _O_CREAT)
2872 dwCreateDisposition = CREATE_ALWAYS;
2873 return (INT_PTR)CreateFileA(pszFile, dwAccess, dwShareMode, NULL, dwCreateDisposition, 0, NULL);
2876 static UINT cabinet_read(INT_PTR hf, void *pv, UINT cb)
2879 if (ReadFile((HANDLE)hf, pv, cb, &dwRead, NULL))
2884 static UINT cabinet_write(INT_PTR hf, void *pv, UINT cb)
2887 if (WriteFile((HANDLE)hf, pv, cb, &dwWritten, NULL))
2892 static int cabinet_close(INT_PTR hf)
2894 return CloseHandle((HANDLE)hf) ? 0 : -1;
2897 static long cabinet_seek(INT_PTR hf, long dist, int seektype)
2899 /* flags are compatible and so are passed straight through */
2900 return SetFilePointer((HANDLE)hf, dist, NULL, seektype);
2903 static INT_PTR cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
2905 /* FIXME: try to do more processing in this function */
2908 case fdintCOPY_FILE:
2910 CabData *data = (CabData*) pfdin->pv;
2911 ULONG len = strlen(data->cab_path) + strlen(pfdin->psz1);
2916 LPWSTR tracknametmp;
2917 static const WCHAR tmpprefix[] = {'C','A','B','T','M','P','_',0};
2919 if (data->file_name && strcmp(data->file_name,pfdin->psz1))
2922 file = cabinet_alloc((len+1)*sizeof(char));
2923 strcpy(file, data->cab_path);
2924 strcat(file, pfdin->psz1);
2926 TRACE("file: %s\n", debugstr_a(file));
2928 /* track this file so it can be deleted if not installed */
2929 trackpath=strdupAtoW(file);
2930 tracknametmp=strdupAtoW(strrchr(file,'\\')+1);
2931 trackname = HeapAlloc(GetProcessHeap(),0,(strlenW(tracknametmp) +
2932 strlenW(tmpprefix)+1) * sizeof(WCHAR));
2934 strcpyW(trackname,tmpprefix);
2935 strcatW(trackname,tracknametmp);
2937 track_tempfile(data->package, trackname, trackpath);
2939 HeapFree(GetProcessHeap(),0,trackpath);
2940 HeapFree(GetProcessHeap(),0,trackname);
2941 HeapFree(GetProcessHeap(),0,tracknametmp);
2943 return cabinet_open(file, _O_WRONLY | _O_CREAT, 0);
2945 case fdintCLOSE_FILE_INFO:
2949 if (!DosDateTimeToFileTime(pfdin->date, pfdin->time, &ft))
2951 if (!LocalFileTimeToFileTime(&ft, &ftLocal))
2953 if (!SetFileTime((HANDLE)pfdin->hf, &ftLocal, 0, &ftLocal))
2956 cabinet_close(pfdin->hf);
2964 /***********************************************************************
2965 * extract_cabinet_file
2967 * Extract files from a cab file.
2969 static BOOL extract_a_cabinet_file(MSIPACKAGE* package, const WCHAR* source,
2970 const WCHAR* path, const WCHAR* file)
2980 TRACE("Extracting %s (%s) to %s\n",debugstr_w(source),
2981 debugstr_w(file), debugstr_w(path));
2983 hfdi = FDICreate(cabinet_alloc,
2994 ERR("FDICreate failed\n");
2998 if (!(cabinet = strdupWtoA( source )))
3003 if (!(cab_path = strdupWtoA( path )))
3006 HeapFree(GetProcessHeap(), 0, cabinet);
3010 data.package = package;
3011 data.cab_path = cab_path;
3012 file_name = strdupWtoA(file);
3013 data.file_name = file_name;
3015 ret = FDICopy(hfdi, cabinet, "", 0, cabinet_notify, NULL, &data);
3018 ERR("FDICopy failed\n");
3022 HeapFree(GetProcessHeap(), 0, cabinet);
3023 HeapFree(GetProcessHeap(), 0, cab_path);
3024 HeapFree(GetProcessHeap(), 0, file_name);
3029 static UINT ready_media_for_file(MSIPACKAGE *package, UINT sequence,
3030 WCHAR* path, WCHAR* file)
3034 MSIRECORD * row = 0;
3035 static WCHAR source[MAX_PATH];
3036 static const WCHAR ExecSeqQuery[] = {
3037 's','e','l','e','c','t',' ','*',' ',
3038 'f','r','o','m',' ','M','e','d','i','a',' ',
3039 'w','h','e','r','e',' ','L','a','s','t','S','e','q','u','e','n','c','e',' ','>','=',' ','%','i',' ',
3040 'o','r','d','e','r',' ','b','y',' ','L','a','s','t','S','e','q','u','e','n','c','e',0};
3045 static UINT last_sequence = 0;
3047 if (sequence <= last_sequence)
3049 TRACE("Media already ready (%u, %u)\n",sequence,last_sequence);
3050 extract_a_cabinet_file(package, source,path,file);
3051 return ERROR_SUCCESS;
3054 sprintfW(Query,ExecSeqQuery,sequence);
3056 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
3057 if (rc != ERROR_SUCCESS)
3060 rc = MSI_ViewExecute(view, 0);
3061 if (rc != ERROR_SUCCESS)
3063 MSI_ViewClose(view);
3064 msiobj_release(&view->hdr);
3068 rc = MSI_ViewFetch(view,&row);
3069 if (rc != ERROR_SUCCESS)
3071 MSI_ViewClose(view);
3072 msiobj_release(&view->hdr);
3075 seq = MSI_RecordGetInteger(row,2);
3076 last_sequence = seq;
3078 if (!MSI_RecordIsNull(row,4))
3081 MSI_RecordGetStringW(row,4,cab,&sz);
3082 TRACE("Source is CAB %s\n",debugstr_w(cab));
3083 /* the stream does not contain the # character */
3086 writeout_cabinet_stream(package,&cab[1],source);
3087 strcpyW(path,source);
3088 *(strrchrW(path,'\\')+1)=0;
3093 if (MSI_GetPropertyW(package, cszSourceDir, source, &sz))
3095 ERR("No Source dir defined \n");
3096 rc = ERROR_FUNCTION_FAILED;
3100 strcpyW(path,source);
3101 strcatW(source,cab);
3102 /* extract the cab file into a folder in the temp folder */
3104 if (MSI_GetPropertyW(package, cszTempFolder,path, &sz)
3106 GetTempPathW(MAX_PATH,path);
3109 rc = !extract_a_cabinet_file(package, source,path,file);
3111 msiobj_release(&row->hdr);
3112 MSI_ViewClose(view);
3113 msiobj_release(&view->hdr);
3117 inline static UINT create_component_directory ( MSIPACKAGE* package, INT component)
3121 LPWSTR install_path;
3123 install_path = resolve_folder(package, package->components[component].Directory,
3124 FALSE, FALSE, &folder);
3126 return ERROR_FUNCTION_FAILED;
3128 /* create the path */
3129 if (folder->State == 0)
3131 create_full_pathW(install_path);
3134 HeapFree(GetProcessHeap(), 0, install_path);
3139 static UINT ACTION_InstallFiles(MSIPACKAGE *package)
3141 UINT rc = ERROR_SUCCESS;
3144 WCHAR uipath[MAX_PATH];
3147 return ERROR_INVALID_HANDLE;
3149 /* increment progress bar each time action data is sent */
3150 ui_progress(package,1,1,0,0);
3152 for (index = 0; index < package->loaded_files; index++)
3154 WCHAR path_to_source[MAX_PATH];
3157 file = &package->files[index];
3159 if (file->Temporary)
3162 if (package->components[file->ComponentIndex].ActionRequest !=
3165 ui_progress(package,2,file->FileSize,0,0);
3166 TRACE("File %s is not scheduled for install\n",
3167 debugstr_w(file->File));
3172 if ((file->State == 1) || (file->State == 2))
3174 TRACE("Installing %s\n",debugstr_w(file->File));
3175 rc = ready_media_for_file(package,file->Sequence,path_to_source,
3179 * our file table could change here because a new temp file
3180 * may have been created
3182 file = &package->files[index];
3183 if (rc != ERROR_SUCCESS)
3185 ERR("Unable to ready media\n");
3186 rc = ERROR_FUNCTION_FAILED;
3190 create_component_directory( package, file->ComponentIndex);
3192 strcpyW(file->SourcePath, path_to_source);
3193 strcatW(file->SourcePath, file->File);
3195 TRACE("file paths %s to %s\n",debugstr_w(file->SourcePath),
3196 debugstr_w(file->TargetPath));
3199 uirow=MSI_CreateRecord(9);
3200 MSI_RecordSetStringW(uirow,1,file->File);
3201 strcpyW(uipath,file->TargetPath);
3202 *(strrchrW(uipath,'\\')+1)=0;
3203 MSI_RecordSetStringW(uirow,9,uipath);
3204 MSI_RecordSetInteger(uirow,6,file->FileSize);
3205 ui_actiondata(package,szInstallFiles,uirow);
3206 msiobj_release( &uirow->hdr );
3207 ui_progress(package,2,file->FileSize,0,0);
3209 if (!MoveFileW(file->SourcePath,file->TargetPath))
3211 rc = GetLastError();
3212 ERR("Unable to move file (%s -> %s) (error %d)\n",
3213 debugstr_w(file->SourcePath), debugstr_w(file->TargetPath),
3215 if (rc == ERROR_ALREADY_EXISTS && file->State == 2)
3217 CopyFileW(file->SourcePath,file->TargetPath,FALSE);
3218 DeleteFileW(file->SourcePath);
3221 else if (rc == ERROR_FILE_NOT_FOUND)
3223 ERR("Source File Not Found! Continueing\n");
3228 ERR("Ignoring Error and continuing...\n");
3240 inline static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key,
3241 LPWSTR* file_source)
3246 return ERROR_INVALID_HANDLE;
3248 for (index = 0; index < package->loaded_files; index ++)
3250 if (strcmpW(file_key,package->files[index].File)==0)
3252 if (package->files[index].State >= 3)
3254 *file_source = dupstrW(package->files[index].TargetPath);
3255 return ERROR_SUCCESS;
3258 return ERROR_FILE_NOT_FOUND;
3262 return ERROR_FUNCTION_FAILED;
3265 static UINT ACTION_DuplicateFiles(MSIPACKAGE *package)
3269 MSIRECORD * row = 0;
3270 static const WCHAR ExecSeqQuery[] = {
3271 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ',
3272 'D','u','p','l','i','c','a','t','e','F','i','l','e',0};
3275 return ERROR_INVALID_HANDLE;
3277 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3278 if (rc != ERROR_SUCCESS)
3279 return ERROR_SUCCESS;
3281 rc = MSI_ViewExecute(view, 0);
3282 if (rc != ERROR_SUCCESS)
3284 MSI_ViewClose(view);
3285 msiobj_release(&view->hdr);
3291 WCHAR file_key[0x100];
3292 WCHAR *file_source = NULL;
3293 WCHAR dest_name[0x100];
3294 LPWSTR dest_path, dest;
3295 WCHAR component[0x100];
3296 INT component_index;
3300 rc = MSI_ViewFetch(view,&row);
3301 if (rc != ERROR_SUCCESS)
3308 rc = MSI_RecordGetStringW(row,2,component,&sz);
3309 if (rc != ERROR_SUCCESS)
3311 ERR("Unable to get component\n");
3312 msiobj_release(&row->hdr);
3316 component_index = get_loaded_component(package,component);
3317 if (package->components[component_index].ActionRequest !=
3320 TRACE("Skipping copy due to disabled component\n");
3321 msiobj_release(&row->hdr);
3326 rc = MSI_RecordGetStringW(row,3,file_key,&sz);
3327 if (rc != ERROR_SUCCESS)
3329 ERR("Unable to get file key\n");
3330 msiobj_release(&row->hdr);
3334 rc = get_file_target(package,file_key,&file_source);
3336 if (rc != ERROR_SUCCESS)
3338 ERR("Original file unknown %s\n",debugstr_w(file_key));
3339 msiobj_release(&row->hdr);
3341 HeapFree(GetProcessHeap(),0,file_source);
3345 if (MSI_RecordIsNull(row,4))
3347 strcpyW(dest_name,strrchrW(file_source,'\\')+1);
3352 MSI_RecordGetStringW(row,4,dest_name,&sz);
3353 reduce_to_longfilename(dest_name);
3356 if (MSI_RecordIsNull(row,5))
3359 dest_path = dupstrW(file_source);
3360 p = strrchrW(dest_path,'\\');
3366 WCHAR destkey[0x100];
3368 MSI_RecordGetStringW(row,5,destkey,&sz);
3370 dest_path = resolve_folder(package, destkey, FALSE,FALSE,NULL);
3373 ERR("Unable to get destination folder\n");
3374 msiobj_release(&row->hdr);
3376 HeapFree(GetProcessHeap(),0,file_source);
3381 dest = build_directory_name(2, dest_path, dest_name);
3382 HeapFree(GetProcessHeap(), 0, dest_path);
3384 TRACE("Duplicating file %s to %s\n",debugstr_w(file_source),
3387 if (strcmpW(file_source,dest))
3388 rc = !CopyFileW(file_source,dest,TRUE);
3392 if (rc != ERROR_SUCCESS)
3393 ERR("Failed to copy file\n");
3395 FIXME("We should track these duplicate files as well\n");
3397 msiobj_release(&row->hdr);
3398 HeapFree(GetProcessHeap(),0,dest);
3399 HeapFree(GetProcessHeap(),0,file_source);
3401 MSI_ViewClose(view);
3402 msiobj_release(&view->hdr);
3407 /* OK this value is "interpretted" and then formatted based on the
3408 first few characters */
3409 static LPSTR parse_value(MSIPACKAGE *package, WCHAR *value, DWORD *type,
3413 if (value[0]=='#' && value[1]!='#' && value[1]!='%')
3422 deformat_string(package, &value[2], &deformated);
3424 /* binary value type */
3427 *size = strlenW(ptr)/2;
3428 data = HeapAlloc(GetProcessHeap(),0,*size);
3440 data[count] = (BYTE)strtol(byte,NULL,0);
3443 HeapFree(GetProcessHeap(),0,deformated);
3445 TRACE("Data %li bytes(%i)\n",*size,count);
3450 deformat_string(package, &value[1], &deformated);
3453 *size = sizeof(DWORD);
3454 data = HeapAlloc(GetProcessHeap(),0,*size);
3455 *(LPDWORD)data = atoiW(deformated);
3456 TRACE("DWORD %i\n",*data);
3458 HeapFree(GetProcessHeap(),0,deformated);
3471 *type=REG_EXPAND_SZ;
3479 *size = deformat_string(package, ptr,(LPWSTR*)&data);
3484 static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package)
3488 MSIRECORD * row = 0;
3489 static const WCHAR ExecSeqQuery[] = {
3490 's','e','l','e','c','t',' ','*',' ',
3491 'f','r','o','m',' ','R','e','g','i','s','t','r','y',0 };
3494 return ERROR_INVALID_HANDLE;
3496 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3497 if (rc != ERROR_SUCCESS)
3498 return ERROR_SUCCESS;
3500 rc = MSI_ViewExecute(view, 0);
3501 if (rc != ERROR_SUCCESS)
3503 MSI_ViewClose(view);
3504 msiobj_release(&view->hdr);
3508 /* increment progress bar each time action data is sent */
3509 ui_progress(package,1,REG_PROGRESS_VALUE,1,0);
3513 static const WCHAR szHCR[] =
3514 {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T','\\',0};
3515 static const WCHAR szHCU[] =
3516 {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\',0};
3517 static const WCHAR szHLM[] =
3518 {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',
3520 static const WCHAR szHU[] =
3521 {'H','K','E','Y','_','U','S','E','R','S','\\',0};
3523 LPSTR value_data = NULL;
3524 HKEY root_key, hkey;
3526 LPWSTR value, key, name, component;
3528 INT component_index;
3533 rc = MSI_ViewFetch(view,&row);
3534 if (rc != ERROR_SUCCESS)
3539 ui_progress(package,2,0,0,0);
3546 component = load_dynamic_stringW(row, 6);
3547 component_index = get_loaded_component(package,component);
3549 if (package->components[component_index].ActionRequest !=
3552 TRACE("Skipping write due to disabled component\n");
3553 msiobj_release(&row->hdr);
3557 /* null values have special meanings during uninstalls and such */
3559 if(MSI_RecordIsNull(row,5))
3561 msiobj_release(&row->hdr);
3565 root = MSI_RecordGetInteger(row,2);
3566 key = load_dynamic_stringW(row, 3);
3568 name = load_dynamic_stringW(row, 4);
3570 /* get the root key */
3573 case 0: root_key = HKEY_CLASSES_ROOT;
3576 case 1: root_key = HKEY_CURRENT_USER;
3579 case 2: root_key = HKEY_LOCAL_MACHINE;
3582 case 3: root_key = HKEY_USERS;
3586 ERR("Unknown root %i\n",root);
3593 msiobj_release(&row->hdr);
3597 size = strlenW(key) + strlenW(szRoot) + 1;
3598 uikey = HeapAlloc(GetProcessHeap(), 0, size*sizeof(WCHAR));
3599 strcpyW(uikey,szRoot);
3601 if (RegCreateKeyW( root_key, key, &hkey))
3603 ERR("Could not create key %s\n",debugstr_w(key));
3604 msiobj_release(&row->hdr);
3608 value = load_dynamic_stringW(row,5);
3609 value_data = parse_value(package, value, &type, &size);
3613 TRACE("Setting value %s\n",debugstr_w(name));
3614 RegSetValueExW(hkey, name, 0, type, value_data, size);
3616 uirow = MSI_CreateRecord(3);
3617 MSI_RecordSetStringW(uirow,2,name);
3618 MSI_RecordSetStringW(uirow,1,uikey);
3621 MSI_RecordSetStringW(uirow,3,(LPWSTR)value_data);
3623 MSI_RecordSetStringW(uirow,3,value);
3625 ui_actiondata(package,szWriteRegistryValues,uirow);
3626 msiobj_release( &uirow->hdr );
3628 HeapFree(GetProcessHeap(),0,value_data);
3630 HeapFree(GetProcessHeap(),0,value);
3632 msiobj_release(&row->hdr);
3636 HeapFree(GetProcessHeap(),0,uikey);
3638 HeapFree(GetProcessHeap(),0,key);
3640 HeapFree(GetProcessHeap(),0,name);
3642 HeapFree(GetProcessHeap(),0,component);
3644 MSI_ViewClose(view);
3645 msiobj_release(&view->hdr);
3650 * This helper function should probably go alot of places
3652 * Thinking about this, maybe this should become yet another Bison file
3654 static DWORD deformat_string(MSIPACKAGE *package, WCHAR* ptr,WCHAR** data)
3666 TRACE("Deformatting NULL string\n");
3670 /* scan for special characters */
3671 if (!strchrW(ptr,'[') || (strchrW(ptr,'[') && !strchrW(ptr,']')))
3674 size = (strlenW(ptr)+1) * sizeof(WCHAR);
3675 *data = HeapAlloc(GetProcessHeap(),0,size);
3680 /* formatted string located */
3681 mark = strchrW(ptr,'[');
3684 INT cnt = (mark - ptr);
3685 TRACE("%i (%i) characters before marker\n",cnt,(mark-ptr));
3686 size = cnt * sizeof(WCHAR);
3687 size += sizeof(WCHAR);
3688 *data = HeapAlloc(GetProcessHeap(),0,size);
3689 strncpyW(*data,ptr,cnt);
3694 size = sizeof(WCHAR);
3695 *data = HeapAlloc(GetProcessHeap(),0,size);
3700 *strchrW(key,']')=0;
3701 mark = strchrW(mark,']');
3703 TRACE("Current %s .. %s\n",debugstr_w(*data),debugstr_w(mark));
3705 rc = MSI_GetPropertyW(package, key, NULL, &sz);
3706 if ((rc == ERROR_SUCCESS) || (rc == ERROR_MORE_DATA))
3711 value = HeapAlloc(GetProcessHeap(),0,sz * sizeof(WCHAR));
3712 MSI_GetPropertyW(package, key, value, &sz);
3714 chunk = (strlenW(value)+1) * sizeof(WCHAR);
3716 newdata = HeapReAlloc(GetProcessHeap(),0,*data,size);
3718 strcatW(*data,value);
3720 TRACE("Current %s .. %s\n",debugstr_w(*data),debugstr_w(mark));
3724 chunk = (strlenW(mark)+1) * sizeof(WCHAR);
3726 newdata = HeapReAlloc(GetProcessHeap(),0,*data,size);
3728 strcatW(*data,mark);
3730 (*data)[strlenW(*data)]=0;
3731 TRACE("Current %s .. %s\n",debugstr_w(*data),debugstr_w(mark));
3733 /* recursively do this to clean up */
3734 mark = HeapAlloc(GetProcessHeap(),0,size);
3735 strcpyW(mark,*data);
3736 TRACE("String at this point %s\n",debugstr_w(mark));
3737 size = deformat_string(package,mark,data);
3738 HeapFree(GetProcessHeap(),0,mark);
3742 static UINT ACTION_InstallInitialize(MSIPACKAGE *package)
3744 return ERROR_SUCCESS;
3748 static UINT ACTION_InstallValidate(MSIPACKAGE *package)
3752 static const WCHAR q1[]={
3753 'S','E','L','E','C','T',' ','*',' ',
3754 'F','R','O','M',' ','R','e','g','i','s','t','r','y',0};
3757 MSIRECORD * row = 0;
3760 TRACE(" InstallValidate \n");
3762 rc = MSI_DatabaseOpenViewW(package->db, q1, &view);
3763 if (rc != ERROR_SUCCESS)
3764 return ERROR_SUCCESS;
3766 rc = MSI_ViewExecute(view, 0);
3767 if (rc != ERROR_SUCCESS)
3769 MSI_ViewClose(view);
3770 msiobj_release(&view->hdr);
3775 rc = MSI_ViewFetch(view,&row);
3776 if (rc != ERROR_SUCCESS)
3783 msiobj_release(&row->hdr);
3785 MSI_ViewClose(view);
3786 msiobj_release(&view->hdr);
3788 total = total + progress * REG_PROGRESS_VALUE;
3789 total = total + package->loaded_components * COMPONENT_PROGRESS_VALUE;
3790 for (i=0; i < package->loaded_files; i++)
3791 total += package->files[i].FileSize;
3792 ui_progress(package,0,total,0,0);
3794 return ERROR_SUCCESS;
3797 static UINT ACTION_LaunchConditions(MSIPACKAGE *package)
3800 MSIQUERY * view = NULL;
3801 MSIRECORD * row = 0;
3802 static const WCHAR ExecSeqQuery[] = {
3803 'S','E','L','E','C','T',' ','*',' ',
3804 'f','r','o','m',' ','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n',0};
3805 static const WCHAR title[]=
3806 {'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0};
3808 TRACE("Checking launch conditions\n");
3810 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
3811 if (rc != ERROR_SUCCESS)
3812 return ERROR_SUCCESS;
3814 rc = MSI_ViewExecute(view, 0);
3815 if (rc != ERROR_SUCCESS)
3817 MSI_ViewClose(view);
3818 msiobj_release(&view->hdr);
3823 while (rc == ERROR_SUCCESS)
3826 LPWSTR message = NULL;
3828 rc = MSI_ViewFetch(view,&row);
3829 if (rc != ERROR_SUCCESS)
3835 cond = load_dynamic_stringW(row,1);
3837 if (MSI_EvaluateConditionW(package,cond) != MSICONDITION_TRUE)
3839 message = load_dynamic_stringW(row,2);
3840 MessageBoxW(NULL,message,title,MB_OK);
3841 HeapFree(GetProcessHeap(),0,message);
3842 rc = ERROR_FUNCTION_FAILED;
3844 HeapFree(GetProcessHeap(),0,cond);
3845 msiobj_release(&row->hdr);
3847 MSI_ViewClose(view);
3848 msiobj_release(&view->hdr);
3852 static LPWSTR resolve_keypath( MSIPACKAGE* package, INT
3855 MSICOMPONENT* cmp = &package->components[component_index];
3857 if (cmp->KeyPath[0]==0)
3859 LPWSTR p = resolve_folder(package,cmp->Directory,FALSE,FALSE,NULL);
3862 if ((cmp->Attributes & 0x4) || (cmp->Attributes & 0x20))
3864 FIXME("UNIMPLEMENTED keypath as Registry or ODBC Source\n");
3870 j = get_loaded_file(package,cmp->KeyPath);
3874 LPWSTR p = dupstrW(package->files[j].TargetPath);
3882 * Ok further analysis makes me think that this work is
3883 * actually done in the PublishComponents and PublishFeatures
3884 * step, and not here. It appears like the keypath and all that is
3885 * resolved in this step, however actually written in the Publish steps.
3886 * But we will leave it here for now because it is unclear
3888 static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
3891 WCHAR squished_pc[0x100];
3892 WCHAR squished_cc[0x100];
3895 HKEY hkey=0,hkey2=0,hkey3=0;
3896 static const WCHAR szProductCode[]=
3897 {'P','r','o','d','u','c','t','C','o','d','e',0};
3898 static const WCHAR szInstaller[] = {
3899 'S','o','f','t','w','a','r','e','\\',
3900 'M','i','c','r','o','s','o','f','t','\\',
3901 'W','i','n','d','o','w','s','\\',
3902 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3903 'I','n','s','t','a','l','l','e','r',0 };
3904 static const WCHAR szFeatures[] = {
3905 'F','e','a','t','u','r','e','s',0 };
3906 static const WCHAR szComponents[] = {
3907 'C','o','m','p','o','n','e','n','t','s',0 };
3910 return ERROR_INVALID_HANDLE;
3912 /* writes the Component and Features values to the registry */
3913 productcode = load_dynamic_property(package,szProductCode,&rc);
3917 squash_guid(productcode,squished_pc);
3918 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,szInstaller,&hkey);
3919 if (rc != ERROR_SUCCESS)
3922 rc = RegCreateKeyW(hkey,szFeatures,&hkey2);
3923 if (rc != ERROR_SUCCESS)
3926 rc = RegCreateKeyW(hkey2,squished_pc,&hkey3);
3927 if (rc != ERROR_SUCCESS)
3930 /* here the guids are base 85 encoded */
3931 for (i = 0; i < package->loaded_features; i++)
3938 size = package->features[i].ComponentCount*21*sizeof(WCHAR);
3939 data = HeapAlloc(GetProcessHeap(), 0, size);
3942 for (j = 0; j < package->features[i].ComponentCount; j++)
3945 TRACE("From %s\n",debugstr_w(package->components
3946 [package->features[i].Components[j]].ComponentId));
3947 CLSIDFromString(package->components
3948 [package->features[i].Components[j]].ComponentId,
3950 encode_base85_guid(&clsid,buf);
3951 TRACE("to %s\n",debugstr_w(buf));
3955 size = strlenW(data)*sizeof(WCHAR);
3956 RegSetValueExW(hkey3,package->features[i].Feature,0,REG_SZ,
3958 HeapFree(GetProcessHeap(),0,data);
3964 rc = RegCreateKeyW(hkey,szComponents,&hkey2);
3965 if (rc != ERROR_SUCCESS)
3968 ui_progress(package,1,COMPONENT_PROGRESS_VALUE,1,0);
3969 for (i = 0; i < package->loaded_components; i++)
3971 ui_progress(package,2,0,0,0);
3972 if (package->components[i].ComponentId[0]!=0)
3974 WCHAR *keypath = NULL;
3977 squash_guid(package->components[i].ComponentId,squished_cc);
3978 rc = RegCreateKeyW(hkey2,squished_cc,&hkey3);
3979 if (rc != ERROR_SUCCESS)
3982 keypath = resolve_keypath(package,i);
3985 RegSetValueExW(hkey3,squished_pc,0,REG_SZ,(LPVOID)keypath,
3986 (strlenW(keypath)+1)*sizeof(WCHAR));
3990 uirow = MSI_CreateRecord(3);
3991 MSI_RecordSetStringW(uirow,1,productcode);
3992 MSI_RecordSetStringW(uirow,2,package->components[i].
3994 MSI_RecordSetStringW(uirow,3,keypath);
3995 ui_actiondata(package,szProcessComponents,uirow);
3996 msiobj_release( &uirow->hdr );
3997 HeapFree(GetProcessHeap(),0,keypath);
4002 HeapFree(GetProcessHeap(), 0, productcode);
4008 static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package)
4011 * OK this is a bit confusing.. I am given a _Component key and I believe
4012 * that the file that is being registered as a type library is the "key file
4013 * of that component" which I interpret to mean "The file in the KeyPath of
4018 MSIRECORD * row = 0;
4019 static const WCHAR Query[] = {
4020 'S','E','L','E','C','T',' ','*',' ',
4021 'f','r','o','m',' ','T','y','p','e','L','i','b',0};
4026 return ERROR_INVALID_HANDLE;
4028 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
4029 if (rc != ERROR_SUCCESS)
4030 return ERROR_SUCCESS;
4032 rc = MSI_ViewExecute(view, 0);
4033 if (rc != ERROR_SUCCESS)
4035 MSI_ViewClose(view);
4036 msiobj_release(&view->hdr);
4042 WCHAR component[0x100];
4046 rc = MSI_ViewFetch(view,&row);
4047 if (rc != ERROR_SUCCESS)
4054 MSI_RecordGetStringW(row,3,component,&sz);
4056 index = get_loaded_component(package,component);
4059 msiobj_release(&row->hdr);
4063 if (package->components[index].ActionRequest != INSTALLSTATE_LOCAL)
4065 TRACE("Skipping typelib reg due to disabled component\n");
4066 msiobj_release(&row->hdr);
4070 index = get_loaded_file(package,package->components[index].KeyPath);
4074 msiobj_release(&row->hdr);
4078 res = LoadTypeLib(package->files[index].TargetPath,&ptLib);
4082 WCHAR helpid[0x100];
4085 MSI_RecordGetStringW(row,6,helpid,&sz);
4087 help = resolve_folder(package,helpid,FALSE,FALSE,NULL);
4088 res = RegisterTypeLib(ptLib,package->files[index].TargetPath,help);
4089 HeapFree(GetProcessHeap(),0,help);
4091 if (!SUCCEEDED(res))
4092 ERR("Failed to register type library %s\n",
4093 debugstr_w(package->files[index].TargetPath));
4096 /* Yes the row has more fields than I need, but #1 is
4097 correct and the only one I need. Why make a new row? */
4099 ui_actiondata(package,szRegisterTypeLibraries,row);
4101 TRACE("Registered %s\n",
4102 debugstr_w(package->files[index].TargetPath));
4106 ITypeLib_Release(ptLib);
4109 ERR("Failed to load type library %s\n",
4110 debugstr_w(package->files[index].TargetPath));
4112 msiobj_release(&row->hdr);
4114 MSI_ViewClose(view);
4115 msiobj_release(&view->hdr);
4120 static UINT register_appid(MSIPACKAGE *package, LPCWSTR clsid, LPCWSTR app )
4122 static const WCHAR szAppID[] = { 'A','p','p','I','D',0 };
4125 MSIRECORD * row = 0;
4126 static const WCHAR ExecSeqQuery[] =
4127 {'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ','A','p','p','I'
4128 ,'d',' ','w','h','e','r','e',' ','A','p','p','I','d','=','`','%','s','`',0};
4133 return ERROR_INVALID_HANDLE;
4135 rc = ACTION_OpenQuery(package->db, &view, ExecSeqQuery, clsid);
4136 if (rc != ERROR_SUCCESS)
4139 rc = MSI_ViewExecute(view, 0);
4140 if (rc != ERROR_SUCCESS)
4142 MSI_ViewClose(view);
4143 msiobj_release(&view->hdr);
4147 RegCreateKeyW(HKEY_CLASSES_ROOT,szAppID,&hkey2);
4148 RegCreateKeyW(hkey2,clsid,&hkey3);
4149 RegSetValueExW(hkey3,NULL,0,REG_SZ,(LPVOID)app,
4150 (strlenW(app)+1)*sizeof(WCHAR));
4152 rc = MSI_ViewFetch(view,&row);
4153 if (rc != ERROR_SUCCESS)
4155 MSI_ViewClose(view);
4156 msiobj_release(&view->hdr);
4160 if (!MSI_RecordIsNull(row,2))
4162 LPWSTR deformated=0;
4164 static const WCHAR szRemoteServerName[] =
4165 {'R','e','m','o','t','e','S','e','r','v','e','r','N','a','m','e',0};
4166 buffer = load_dynamic_stringW(row,2);
4167 size = deformat_string(package,buffer,&deformated);
4168 RegSetValueExW(hkey3,szRemoteServerName,0,REG_SZ,(LPVOID)deformated,
4170 HeapFree(GetProcessHeap(),0,deformated);
4171 HeapFree(GetProcessHeap(),0,buffer);
4174 if (!MSI_RecordIsNull(row,3))
4176 static const WCHAR szLocalService[] =
4177 {'L','o','c','a','l','S','e','r','v','i','c','e',0};
4179 buffer = load_dynamic_stringW(row,3);
4180 size = (strlenW(buffer)+1) * sizeof(WCHAR);
4181 RegSetValueExW(hkey3,szLocalService,0,REG_SZ,(LPVOID)buffer,size);
4182 HeapFree(GetProcessHeap(),0,buffer);
4185 if (!MSI_RecordIsNull(row,4))
4187 static const WCHAR szService[] =
4188 {'S','e','r','v','i','c','e','P','a','r','a','m','e','t','e','r','s',0};
4190 buffer = load_dynamic_stringW(row,4);
4191 size = (strlenW(buffer)+1) * sizeof(WCHAR);
4192 RegSetValueExW(hkey3,szService,0,REG_SZ,(LPVOID)buffer,size);
4193 HeapFree(GetProcessHeap(),0,buffer);
4196 if (!MSI_RecordIsNull(row,5))
4198 static const WCHAR szDLL[] =
4199 {'D','l','l','S','u','r','r','o','g','a','t','e',0};
4201 buffer = load_dynamic_stringW(row,5);
4202 size = (strlenW(buffer)+1) * sizeof(WCHAR);
4203 RegSetValueExW(hkey3,szDLL,0,REG_SZ,(LPVOID)buffer,size);
4204 HeapFree(GetProcessHeap(),0,buffer);
4207 if (!MSI_RecordIsNull(row,6))
4209 static const WCHAR szActivate[] =
4210 {'A','c','t','i','v','a','t','e','A','s','S','t','o','r','a','g','e',0};
4211 static const WCHAR szY[] = {'Y',0};
4213 if (MSI_RecordGetInteger(row,6))
4214 RegSetValueExW(hkey3,szActivate,0,REG_SZ,(LPVOID)szY,4);
4217 if (!MSI_RecordIsNull(row,7))
4219 static const WCHAR szRunAs[] = {'R','u','n','A','s',0};
4220 static const WCHAR szUser[] =
4221 {'I','n','t','e','r','a','c','t','i','v','e',' ','U','s','e','r',0};
4223 if (MSI_RecordGetInteger(row,7))
4224 RegSetValueExW(hkey3,szRunAs,0,REG_SZ,(LPVOID)szUser,34);
4227 msiobj_release(&row->hdr);
4228 MSI_ViewClose(view);
4229 msiobj_release(&view->hdr);
4235 static UINT ACTION_RegisterClassInfo(MSIPACKAGE *package)
4238 * Again I am assuming the words, "Whose key file represents" when referring
4239 * to a Component as to meaning that Components KeyPath file
4241 * Also there is a very strong connection between ClassInfo and ProgID
4242 * that I am mostly glossing over.
4243 * What would be more propper is to load the ClassInfo and the ProgID info
4244 * into memory data structures and then be able to enable and disable them
4245 * based on component.
4250 MSIRECORD * row = 0;
4251 static const WCHAR ExecSeqQuery[] = {
4252 'S','E','L','E','C','T',' ','*',' ',
4253 'f','r','o','m',' ','C','l','a','s','s',0};
4254 static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 };
4255 static const WCHAR szProgID[] = { 'P','r','o','g','I','D',0 };
4256 static const WCHAR szAppID[] = { 'A','p','p','I','D',0 };
4257 HKEY hkey,hkey2,hkey3;
4260 return ERROR_INVALID_HANDLE;
4262 rc = RegCreateKeyW(HKEY_CLASSES_ROOT,szCLSID,&hkey);
4263 if (rc != ERROR_SUCCESS)
4264 return ERROR_FUNCTION_FAILED;
4266 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
4267 if (rc != ERROR_SUCCESS)
4273 rc = MSI_ViewExecute(view, 0);
4274 if (rc != ERROR_SUCCESS)
4276 MSI_ViewClose(view);
4277 msiobj_release(&view->hdr);
4284 WCHAR buffer[0x100];
4289 rc = MSI_ViewFetch(view,&row);
4290 if (rc != ERROR_SUCCESS)
4297 MSI_RecordGetStringW(row,3,buffer,&sz);
4299 index = get_loaded_component(package,buffer);
4303 msiobj_release(&row->hdr);
4307 if (package->components[index].ActionRequest != INSTALLSTATE_LOCAL)
4309 TRACE("Skipping class reg due to disabled component\n");
4310 msiobj_release(&row->hdr);
4315 MSI_RecordGetStringW(row,1,clsid,&sz);
4316 RegCreateKeyW(hkey,clsid,&hkey2);
4318 if (!MSI_RecordIsNull(row,5))
4321 MSI_RecordGetStringW(row,5,desc,&sz);
4323 RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)desc,
4324 (strlenW(desc)+1)*sizeof(WCHAR));
4330 MSI_RecordGetStringW(row,2,buffer,&sz);
4332 RegCreateKeyW(hkey2,buffer,&hkey3);
4334 index = get_loaded_file(package,package->components[index].KeyPath);
4335 RegSetValueExW(hkey3,NULL,0,REG_SZ,
4336 (LPVOID)package->files[index].TargetPath,
4337 (strlenW(package->files[index].TargetPath)+1)
4342 if (!MSI_RecordIsNull(row,4))
4345 MSI_RecordGetStringW(row,4,buffer,&sz);
4347 RegCreateKeyW(hkey2,szProgID,&hkey3);
4349 RegSetValueExW(hkey3,NULL,0,REG_SZ,(LPVOID)buffer,
4350 (strlenW(buffer)+1)*sizeof(WCHAR));
4355 if (!MSI_RecordIsNull(row,6))
4358 MSI_RecordGetStringW(row,6,buffer,&sz);
4360 RegSetValueExW(hkey2,szAppID,0,REG_SZ,(LPVOID)buffer,
4361 (strlenW(buffer)+1)*sizeof(WCHAR));
4363 register_appid(package,buffer,desc);
4368 FIXME("Process the rest of the fields >7\n");
4370 ui_actiondata(package,szRegisterClassInfo,row);
4372 msiobj_release(&row->hdr);
4374 MSI_ViewClose(view);
4375 msiobj_release(&view->hdr);
4382 static UINT register_progid_base(MSIRECORD * row, LPWSTR clsid)
4384 static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 };
4386 WCHAR buffer[0x100];
4391 MSI_RecordGetStringW(row,1,buffer,&sz);
4392 RegCreateKeyW(HKEY_CLASSES_ROOT,buffer,&hkey);
4394 if (!MSI_RecordIsNull(row,4))
4397 MSI_RecordGetStringW(row,4,buffer,&sz);
4398 RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer, (strlenW(buffer)+1) *
4402 if (!MSI_RecordIsNull(row,3))
4406 MSI_RecordGetStringW(row,3,buffer,&sz);
4407 RegCreateKeyW(hkey,szCLSID,&hkey2);
4408 RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)buffer, (strlenW(buffer)+1) *
4412 strcpyW(clsid,buffer);
4418 FIXME("UNHANDLED case, Parent progid but classid is NULL\n");
4419 return ERROR_FUNCTION_FAILED;
4421 if (!MSI_RecordIsNull(row,5))
4422 FIXME ("UNHANDLED icon in Progid\n");
4423 return ERROR_SUCCESS;
4426 static UINT register_progid(MSIPACKAGE *package, MSIRECORD * row, LPWSTR clsid);
4428 static UINT register_parent_progid(MSIPACKAGE *package, LPCWSTR parent,
4433 MSIRECORD * row = 0;
4434 static const WCHAR Query_t[] =
4435 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','P','r','o','g'
4436 ,'I','d',' ','w','h','e','r','e',' ','P','r','o','g','I','d',' ','=',' ','`'
4440 return ERROR_INVALID_HANDLE;
4442 rc = ACTION_OpenQuery(package->db, &view, Query_t, parent);
4443 if (rc != ERROR_SUCCESS)
4446 rc = MSI_ViewExecute(view, 0);
4447 if (rc != ERROR_SUCCESS)
4449 MSI_ViewClose(view);
4450 msiobj_release(&view->hdr);
4454 rc = MSI_ViewFetch(view,&row);
4455 if (rc != ERROR_SUCCESS)
4457 MSI_ViewClose(view);
4458 msiobj_release(&view->hdr);
4462 register_progid(package,row,clsid);
4464 msiobj_release(&row->hdr);
4465 MSI_ViewClose(view);
4466 msiobj_release(&view->hdr);
4470 static UINT register_progid(MSIPACKAGE *package, MSIRECORD * row, LPWSTR clsid)
4472 UINT rc = ERROR_SUCCESS;
4474 if (MSI_RecordIsNull(row,2))
4475 rc = register_progid_base(row,clsid);
4478 WCHAR buffer[0x1000];
4481 static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 };
4483 /* check if already registered */
4485 MSI_RecordGetStringW(row,1,buffer,&sz);
4486 RegCreateKeyExW(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0,
4487 KEY_ALL_ACCESS, NULL, &hkey, &disp );
4488 if (disp == REG_OPENED_EXISTING_KEY)
4490 TRACE("Key already registered\n");
4494 /* clsid is same as parent */
4495 RegCreateKeyW(hkey,szCLSID,&hkey2);
4496 RegSetValueExW(hkey2,NULL,0,REG_SZ,(LPVOID)clsid, (strlenW(clsid)+1) *
4502 MSI_RecordGetStringW(row,2,buffer,&sz);
4503 rc = register_parent_progid(package,buffer,clsid);
4505 if (!MSI_RecordIsNull(row,4))
4508 MSI_RecordGetStringW(row,4,buffer,&sz);
4509 RegSetValueExW(hkey,NULL,0,REG_SZ,(LPVOID)buffer,
4510 (strlenW(buffer)+1) * sizeof(WCHAR));
4513 if (!MSI_RecordIsNull(row,5))
4514 FIXME ("UNHANDLED icon in Progid\n");
4521 static UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package)
4524 * Sigh, here I am just brute force registering all progids
4525 * this needs to be linked to the Classes that have been registered
4526 * but the easiest way to do that is to load all these stuff into
4527 * memory for easy checking.
4529 * Gives me something to continue to work toward.
4533 MSIRECORD * row = 0;
4534 static const WCHAR Query[] = {
4535 'S','E','L','E','C','T',' ','*',' ',
4536 'F','R','O','M',' ','P','r','o','g','I','d',0};
4539 return ERROR_INVALID_HANDLE;
4541 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
4542 if (rc != ERROR_SUCCESS)
4543 return ERROR_SUCCESS;
4545 rc = MSI_ViewExecute(view, 0);
4546 if (rc != ERROR_SUCCESS)
4548 MSI_ViewClose(view);
4549 msiobj_release(&view->hdr);
4555 WCHAR clsid[0x1000];
4557 rc = MSI_ViewFetch(view,&row);
4558 if (rc != ERROR_SUCCESS)
4564 register_progid(package,row,clsid);
4565 ui_actiondata(package,szRegisterProgIdInfo,row);
4567 msiobj_release(&row->hdr);
4569 MSI_ViewClose(view);
4570 msiobj_release(&view->hdr);
4574 static UINT build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name,
4578 LPWSTR SystemFolder;
4582 static const WCHAR szInstaller[] =
4583 {'I','n','s','t','a','l','l','e','r','\\',0};
4584 static const WCHAR szProductCode[] =
4585 {'P','r','o','d','u','c','t','C','o','d','e',0};
4586 static const WCHAR szFolder[] =
4587 {'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
4589 ProductCode = load_dynamic_property(package,szProductCode,&rc);
4593 SystemFolder = load_dynamic_property(package,szFolder,NULL);
4595 dest = build_directory_name(3, SystemFolder, szInstaller, ProductCode);
4597 create_full_pathW(dest);
4599 *FilePath = build_directory_name(2, dest, icon_name);
4601 HeapFree(GetProcessHeap(),0,SystemFolder);
4602 HeapFree(GetProcessHeap(),0,ProductCode);
4603 HeapFree(GetProcessHeap(),0,dest);
4604 return ERROR_SUCCESS;
4607 static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
4611 MSIRECORD * row = 0;
4612 static const WCHAR Query[] = {
4613 'S','E','L','E','C','T',' ','*',' ','f','r','o','m',' ',
4614 'S','h','o','r','t','c','u','t',0};
4620 return ERROR_INVALID_HANDLE;
4622 res = CoInitialize( NULL );
4625 ERR("CoInitialize failed\n");
4626 return ERROR_FUNCTION_FAILED;
4629 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
4630 if (rc != ERROR_SUCCESS)
4631 return ERROR_SUCCESS;
4633 rc = MSI_ViewExecute(view, 0);
4634 if (rc != ERROR_SUCCESS)
4636 MSI_ViewClose(view);
4637 msiobj_release(&view->hdr);
4643 LPWSTR target_file, target_folder;
4644 WCHAR buffer[0x100];
4647 static const WCHAR szlnk[]={'.','l','n','k',0};
4649 rc = MSI_ViewFetch(view,&row);
4650 if (rc != ERROR_SUCCESS)
4657 MSI_RecordGetStringW(row,4,buffer,&sz);
4659 index = get_loaded_component(package,buffer);
4663 msiobj_release(&row->hdr);
4667 if (package->components[index].ActionRequest != INSTALLSTATE_LOCAL)
4669 TRACE("Skipping shortcut creation due to disabled component\n");
4670 msiobj_release(&row->hdr);
4674 ui_actiondata(package,szCreateShortcuts,row);
4676 res = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
4677 &IID_IShellLinkW, (LPVOID *) &sl );
4681 ERR("Is IID_IShellLink\n");
4682 msiobj_release(&row->hdr);
4686 res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf );
4689 ERR("Is IID_IPersistFile\n");
4690 msiobj_release(&row->hdr);
4695 MSI_RecordGetStringW(row,2,buffer,&sz);
4696 target_folder = resolve_folder(package, buffer,FALSE,FALSE,NULL);
4698 /* may be needed because of a bug somehwere else */
4699 create_full_pathW(target_folder);
4702 MSI_RecordGetStringW(row,3,buffer,&sz);
4703 reduce_to_longfilename(buffer);
4704 if (!strchrW(buffer,'.'))
4705 strcatW(buffer,szlnk);
4706 target_file = build_directory_name(2, target_folder, buffer);
4707 HeapFree(GetProcessHeap(),0,target_folder);
4710 MSI_RecordGetStringW(row,5,buffer,&sz);
4711 if (strchrW(buffer,'['))
4714 deformat_string(package,buffer,&deformated);
4715 IShellLinkW_SetPath(sl,deformated);
4716 HeapFree(GetProcessHeap(),0,deformated);
4720 FIXME("UNHANDLED shortcut format, advertised shortcut\n");
4721 IPersistFile_Release( pf );
4722 IShellLinkW_Release( sl );
4723 msiobj_release(&row->hdr);
4727 if (!MSI_RecordIsNull(row,6))
4731 MSI_RecordGetStringW(row,6,buffer,&sz);
4732 deformat_string(package,buffer,&deformated);
4733 IShellLinkW_SetArguments(sl,deformated);
4734 HeapFree(GetProcessHeap(),0,deformated);
4737 if (!MSI_RecordIsNull(row,7))
4740 deformated = load_dynamic_stringW(row,7);
4741 IShellLinkW_SetDescription(sl,deformated);
4742 HeapFree(GetProcessHeap(),0,deformated);
4745 if (!MSI_RecordIsNull(row,8))
4746 IShellLinkW_SetHotkey(sl,MSI_RecordGetInteger(row,8));
4748 if (!MSI_RecordIsNull(row,9))
4754 MSI_RecordGetStringW(row,9,buffer,&sz);
4756 build_icon_path(package,buffer,&Path);
4757 index = MSI_RecordGetInteger(row,10);
4759 IShellLinkW_SetIconLocation(sl,Path,index);
4760 HeapFree(GetProcessHeap(),0,Path);
4763 if (!MSI_RecordIsNull(row,11))
4764 IShellLinkW_SetShowCmd(sl,MSI_RecordGetInteger(row,11));
4766 if (!MSI_RecordIsNull(row,12))
4770 MSI_RecordGetStringW(row,12,buffer,&sz);
4771 Path = resolve_folder(package, buffer, FALSE, FALSE, NULL);
4772 IShellLinkW_SetWorkingDirectory(sl,Path);
4773 HeapFree(GetProcessHeap(), 0, Path);
4776 TRACE("Writing shortcut to %s\n",debugstr_w(target_file));
4777 IPersistFile_Save(pf,target_file,FALSE);
4779 HeapFree(GetProcessHeap(),0,target_file);
4781 IPersistFile_Release( pf );
4782 IShellLinkW_Release( sl );
4784 msiobj_release(&row->hdr);
4786 MSI_ViewClose(view);
4787 msiobj_release(&view->hdr);
4797 * 99% of the work done here is only done for
4798 * advertised installs. However this is where the
4799 * Icon table is processed and written out
4800 * so that is what I am going to do here.
4802 static UINT ACTION_PublishProduct(MSIPACKAGE *package)
4806 MSIRECORD * row = 0;
4807 static const WCHAR Query[]={
4808 'S','E','L','E','C','T',' ','*',' ',
4809 'f','r','o','m',' ','I','c','o','n',0};
4813 return ERROR_INVALID_HANDLE;
4815 rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
4816 if (rc != ERROR_SUCCESS)
4817 return ERROR_SUCCESS;
4819 rc = MSI_ViewExecute(view, 0);
4820 if (rc != ERROR_SUCCESS)
4822 MSI_ViewClose(view);
4823 msiobj_release(&view->hdr);
4830 WCHAR *FilePath=NULL;
4831 WCHAR *FileName=NULL;
4834 rc = MSI_ViewFetch(view,&row);
4835 if (rc != ERROR_SUCCESS)
4841 FileName = load_dynamic_stringW(row,1);
4844 ERR("Unable to get FileName\n");
4845 msiobj_release(&row->hdr);
4849 build_icon_path(package,FileName,&FilePath);
4851 HeapFree(GetProcessHeap(),0,FileName);
4853 TRACE("Creating icon file at %s\n",debugstr_w(FilePath));
4855 the_file = CreateFileW(FilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
4856 FILE_ATTRIBUTE_NORMAL, NULL);
4858 if (the_file == INVALID_HANDLE_VALUE)
4860 ERR("Unable to create file %s\n",debugstr_w(FilePath));
4861 msiobj_release(&row->hdr);
4862 HeapFree(GetProcessHeap(),0,FilePath);
4870 rc = MSI_RecordReadStream(row,2,buffer,&sz);
4871 if (rc != ERROR_SUCCESS)
4873 ERR("Failed to get stream\n");
4874 CloseHandle(the_file);
4875 DeleteFileW(FilePath);
4878 WriteFile(the_file,buffer,sz,&write,NULL);
4879 } while (sz == 1024);
4881 HeapFree(GetProcessHeap(),0,FilePath);
4883 CloseHandle(the_file);
4884 msiobj_release(&row->hdr);
4886 MSI_ViewClose(view);
4887 msiobj_release(&view->hdr);
4892 /* Msi functions that seem appropriate here */
4893 UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction )
4898 TRACE(" exteral attempt at action %s\n",szAction);
4901 return ERROR_FUNCTION_FAILED;
4903 return ERROR_FUNCTION_FAILED;
4905 szwAction = strdupAtoW(szAction);
4908 return ERROR_FUNCTION_FAILED;
4911 rc = MsiDoActionW(hInstall, szwAction);
4912 HeapFree(GetProcessHeap(),0,szwAction);
4916 UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction )
4918 MSIPACKAGE *package;
4919 UINT ret = ERROR_INVALID_HANDLE;
4921 TRACE(" external attempt at action %s \n",debugstr_w(szAction));
4923 package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
4926 ret = ACTION_PerformAction(package,szAction);
4927 msiobj_release( &package->hdr );
4932 UINT WINAPI MsiGetTargetPathA( MSIHANDLE hInstall, LPCSTR szFolder,
4933 LPSTR szPathBuf, DWORD* pcchPathBuf)
4939 TRACE("getting folder %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf);
4942 return ERROR_FUNCTION_FAILED;
4944 return ERROR_FUNCTION_FAILED;
4946 szwFolder = strdupAtoW(szFolder);
4949 return ERROR_FUNCTION_FAILED;
4951 szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR));
4953 rc = MsiGetTargetPathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf);
4955 WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf,
4956 *pcchPathBuf, NULL, NULL );
4958 HeapFree(GetProcessHeap(),0,szwFolder);
4959 HeapFree(GetProcessHeap(),0,szwPathBuf);
4964 UINT WINAPI MsiGetTargetPathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR
4965 szPathBuf, DWORD* pcchPathBuf)
4968 UINT rc = ERROR_FUNCTION_FAILED;
4969 MSIPACKAGE *package;
4971 TRACE("(%s %p %li)\n",debugstr_w(szFolder),szPathBuf,*pcchPathBuf);
4973 package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
4975 return ERROR_INVALID_HANDLE;
4976 path = resolve_folder(package, szFolder, FALSE, FALSE, NULL);
4977 msiobj_release( &package->hdr );
4979 if (path && (strlenW(path) > *pcchPathBuf))
4981 *pcchPathBuf = strlenW(path)+1;
4982 rc = ERROR_MORE_DATA;
4986 *pcchPathBuf = strlenW(path)+1;
4987 strcpyW(szPathBuf,path);
4988 TRACE("Returning Path %s\n",debugstr_w(path));
4991 HeapFree(GetProcessHeap(),0,path);
4997 UINT WINAPI MsiGetSourcePathA( MSIHANDLE hInstall, LPCSTR szFolder,
4998 LPSTR szPathBuf, DWORD* pcchPathBuf)
5004 TRACE("getting source %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf);
5007 return ERROR_FUNCTION_FAILED;
5009 return ERROR_FUNCTION_FAILED;
5011 szwFolder = strdupAtoW(szFolder);
5013 return ERROR_FUNCTION_FAILED;
5015 szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR));
5017 rc = MsiGetSourcePathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf);
5019 WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf,
5020 *pcchPathBuf, NULL, NULL );
5022 HeapFree(GetProcessHeap(),0,szwFolder);
5023 HeapFree(GetProcessHeap(),0,szwPathBuf);
5028 UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR
5029 szPathBuf, DWORD* pcchPathBuf)
5032 UINT rc = ERROR_FUNCTION_FAILED;
5033 MSIPACKAGE *package;
5035 TRACE("(%s %p %li)\n",debugstr_w(szFolder),szPathBuf,*pcchPathBuf);
5037 package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
5039 return ERROR_INVALID_HANDLE;
5040 path = resolve_folder(package, szFolder, TRUE, FALSE, NULL);
5041 msiobj_release( &package->hdr );
5043 if (path && strlenW(path) > *pcchPathBuf)
5045 *pcchPathBuf = strlenW(path)+1;
5046 rc = ERROR_MORE_DATA;
5050 *pcchPathBuf = strlenW(path)+1;
5051 strcpyW(szPathBuf,path);
5052 TRACE("Returning Path %s\n",debugstr_w(path));
5055 HeapFree(GetProcessHeap(),0,path);
5061 UINT WINAPI MsiSetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder,
5062 LPCSTR szFolderPath)
5065 LPWSTR szwFolderPath;
5069 return ERROR_FUNCTION_FAILED;
5071 return ERROR_FUNCTION_FAILED;
5073 szwFolder = strdupAtoW(szFolder);
5075 return ERROR_FUNCTION_FAILED;
5077 szwFolderPath = strdupAtoW(szFolderPath);
5080 HeapFree(GetProcessHeap(),0,szwFolder);
5081 return ERROR_FUNCTION_FAILED;
5084 rc = MsiSetTargetPathW(hInstall, szwFolder, szwFolderPath);
5086 HeapFree(GetProcessHeap(),0,szwFolder);
5087 HeapFree(GetProcessHeap(),0,szwFolderPath);
5092 UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder,
5093 LPCWSTR szFolderPath)
5097 LPWSTR path2 = NULL;
5101 TRACE("(%p %s %s)\n",package, debugstr_w(szFolder),debugstr_w(szFolderPath));
5104 return ERROR_INVALID_HANDLE;
5106 if (szFolderPath[0]==0)
5107 return ERROR_FUNCTION_FAILED;
5109 if (GetFileAttributesW(szFolderPath) == INVALID_FILE_ATTRIBUTES)
5110 return ERROR_FUNCTION_FAILED;
5112 path = resolve_folder(package,szFolder,FALSE,FALSE,&folder);
5115 return ERROR_INVALID_PARAMETER;
5117 if (folder->Property)
5118 HeapFree(GetProcessHeap(),0,folder->Property);
5120 len = strlenW(szFolderPath);
5122 if (szFolderPath[len-1]!='\\')
5125 folder->Property = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
5126 strcpyW(folder->Property,szFolderPath);
5127 strcatW(folder->Property,cszbs);
5130 folder->Property = dupstrW(szFolderPath);
5132 if (strcmpiW(path, szFolderPath) == 0)
5135 * Resolved Target has not really changed, so just
5136 * set this folder and do not recalculate everything.
5138 HeapFree(GetProcessHeap(),0,folder->ResolvedTarget);
5139 folder->ResolvedTarget = NULL;
5140 path2 = resolve_folder(package,szFolder,FALSE,TRUE,NULL);
5141 HeapFree(GetProcessHeap(),0,path2);
5145 for (i = 0; i < package->loaded_folders; i++)
5147 if (package->folders[i].ResolvedTarget)
5148 HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedTarget);
5149 package->folders[i].ResolvedTarget=NULL;
5152 for (i = 0; i < package->loaded_folders; i++)
5154 path2=resolve_folder(package, package->folders[i].Directory, FALSE,
5156 HeapFree(GetProcessHeap(),0,path2);
5159 HeapFree(GetProcessHeap(),0,path);
5161 return ERROR_SUCCESS;
5164 UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder,
5165 LPCWSTR szFolderPath)
5167 MSIPACKAGE *package;
5170 TRACE("(%s %s)\n",debugstr_w(szFolder),debugstr_w(szFolderPath));
5172 package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
5173 ret = MSI_SetTargetPathW( package, szFolder, szFolderPath );
5174 msiobj_release( &package->hdr );
5178 /***********************************************************************
5179 * MsiGetMode (MSI.@)
5181 * Returns an internal installer state (if it is running in a mode iRunMode)
5184 * hInstall [I] Handle to the installation
5185 * hRunMode [I] Checking run mode
5186 * MSIRUNMODE_ADMIN Administrative mode
5187 * MSIRUNMODE_ADVERTISE Advertisement mode
5188 * MSIRUNMODE_MAINTENANCE Maintenance mode
5189 * MSIRUNMODE_ROLLBACKENABLED Rollback is enabled
5190 * MSIRUNMODE_LOGENABLED Log file is writing
5191 * MSIRUNMODE_OPERATIONS Operations in progress??
5192 * MSIRUNMODE_REBOOTATEND We need to reboot after installation completed
5193 * MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation
5194 * MSIRUNMODE_CABINET Files from cabinet are installed
5195 * MSIRUNMODE_SOURCESHORTNAMES Long names in source files is supressed
5196 * MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is supressed
5197 * MSIRUNMODE_RESERVED11 Reserved
5198 * MSIRUNMODE_WINDOWS9X Running under Windows95/98
5199 * MSIRUNMODE_ZAWENABLED Demand installation is supported
5200 * MSIRUNMODE_RESERVED14 Reserved
5201 * MSIRUNMODE_RESERVED15 Reserved
5202 * MSIRUNMODE_SCHEDULED called from install script
5203 * MSIRUNMODE_ROLLBACK called from rollback script
5204 * MSIRUNMODE_COMMIT called from commit script
5207 * In the state: TRUE
5208 * Not in the state: FALSE
5212 BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode)
5214 FIXME("STUB (iRunMode=%i)\n",iRunMode);
5219 * According to the docs, when this is called it immediately recalculates
5220 * all the component states as well
5222 UINT WINAPI MsiSetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature,
5223 INSTALLSTATE iState)
5225 LPWSTR szwFeature = NULL;
5228 szwFeature = strdupAtoW(szFeature);
5231 return ERROR_FUNCTION_FAILED;
5233 rc = MsiSetFeatureStateW(hInstall,szwFeature, iState);
5235 HeapFree(GetProcessHeap(),0,szwFeature);
5240 UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
5241 INSTALLSTATE iState)
5243 MSIPACKAGE* package;
5246 TRACE(" %s to %i\n",debugstr_w(szFeature), iState);
5248 package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
5250 return ERROR_INVALID_HANDLE;
5252 index = get_loaded_feature(package,szFeature);
5254 return ERROR_UNKNOWN_FEATURE;
5256 package->features[index].ActionRequest= iState;
5258 return ERROR_SUCCESS;
5261 UINT WINAPI MsiGetFeatureStateA(MSIHANDLE hInstall, LPSTR szFeature,
5262 INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
5264 LPWSTR szwFeature = NULL;
5267 szwFeature = strdupAtoW(szFeature);
5269 rc = MsiGetFeatureStateW(hInstall,szwFeature,piInstalled, piAction);
5271 HeapFree( GetProcessHeap(), 0 , szwFeature);
5276 UINT MSI_GetFeatureStateW(MSIPACKAGE *package, LPWSTR szFeature,
5277 INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
5281 index = get_loaded_feature(package,szFeature);
5283 return ERROR_UNKNOWN_FEATURE;
5286 *piInstalled = package->features[index].Installed;
5289 *piAction = package->features[index].Action;
5291 TRACE("returning %i %i\n",*piInstalled,*piAction);
5293 return ERROR_SUCCESS;
5296 UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPWSTR szFeature,
5297 INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
5299 MSIPACKAGE* package;
5302 TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled,
5305 package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
5307 return ERROR_INVALID_HANDLE;
5308 ret = MSI_GetFeatureStateW(package, szFeature, piInstalled, piAction);
5309 msiobj_release( &package->hdr );
5313 UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPSTR szComponent,
5314 INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
5316 LPWSTR szwComponent= NULL;
5319 szwComponent= strdupAtoW(szComponent);
5321 rc = MsiGetComponentStateW(hInstall,szwComponent,piInstalled, piAction);
5323 HeapFree( GetProcessHeap(), 0 , szwComponent);
5328 UINT MSI_GetComponentStateW(MSIPACKAGE *package, LPWSTR szComponent,
5329 INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
5333 TRACE("%p %s %p %p\n", package, debugstr_w(szComponent), piInstalled,
5336 index = get_loaded_component(package,szComponent);
5338 return ERROR_UNKNOWN_COMPONENT;
5341 *piInstalled = package->components[index].Installed;
5344 *piInstalled = package->components[index].Action;
5346 return ERROR_SUCCESS;
5349 UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPWSTR szComponent,
5350 INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
5352 MSIPACKAGE* package;
5355 TRACE("%ld %s %p %p\n", hInstall, debugstr_w(szComponent),
5356 piInstalled, piAction);
5358 package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
5360 return ERROR_INVALID_HANDLE;
5361 ret = MSI_GetComponentStateW( package, szComponent, piInstalled, piAction);
5362 msiobj_release( &package->hdr );
5367 static UINT ACTION_Template(MSIPACKAGE *package)
5371 MSIRECORD * row = 0;
5372 static const WCHAR ExecSeqQuery[] = {0};
5374 rc = MsiDatabaseOpenViewW(package->db, ExecSeqQuery, &view);
5375 if (rc != ERROR_SUCCESS)
5378 rc = MsiViewExecute(view, 0);
5379 if (rc != ERROR_SUCCESS)
5382 msiobj_release(&view->hdr);
5388 rc = MsiViewFetch(view,&row);
5389 if (rc != ERROR_SUCCESS)
5395 msiobj_release(&row->hdr);
5398 msiobj_release(&view->hdr);