msi: Handle signature filenames in short|long notation.
[wine] / dlls / msi / tests / install.c
1 /*
2  * Copyright (C) 2006 James Hawkins
3  *
4  * A test program for installing MSI products.
5  *
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.
10  *
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.
15  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #define _WIN32_MSI 300
22 #define COBJMACROS
23
24 #include <stdio.h>
25
26 #include <windows.h>
27 #include <msiquery.h>
28 #include <msidefs.h>
29 #include <msi.h>
30 #include <fci.h>
31 #include <objidl.h>
32 #include <srrestoreptapi.h>
33 #include <shlobj.h>
34
35 #include "wine/test.h"
36
37 static UINT (WINAPI *pMsiQueryComponentStateA)
38     (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
39 static UINT (WINAPI *pMsiSetExternalUIRecord)
40     (INSTALLUI_HANDLER_RECORD, DWORD, LPVOID, PINSTALLUI_HANDLER_RECORD);
41 static UINT (WINAPI *pMsiSourceListEnumSourcesA)
42     (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, DWORD, LPSTR, LPDWORD);
43 static UINT (WINAPI *pMsiSourceListGetInfoA)
44     (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
45
46 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
47 static BOOL (WINAPI *pGetTokenInformation)( HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD );
48 static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
49 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
50 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
51
52 static HMODULE hsrclient = 0;
53 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
54 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
55
56 static BOOL on_win9x = FALSE;
57
58 static const char *msifile = "msitest.msi";
59 static const char *msifile2 = "winetest2.msi";
60 static const char *mstfile = "winetest.mst";
61 static CHAR CURR_DIR[MAX_PATH];
62 static CHAR PROG_FILES_DIR[MAX_PATH];
63 static CHAR COMMON_FILES_DIR[MAX_PATH];
64 static CHAR APP_DATA_DIR[MAX_PATH];
65 static CHAR WINDOWS_DIR[MAX_PATH];
66
67 /* msi database data */
68
69 static const CHAR component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
70                                     "s72\tS38\ts72\ti2\tS255\tS72\n"
71                                     "Component\tComponent\n"
72                                     "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
73                                     "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
74                                     "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\tNOT REINSTALL\tone.txt\n"
75                                     "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
76                                     "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
77                                     "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
78                                     "component\t\tMSITESTDIR\t0\t1\tfile\n"
79                                     "service_comp\t\tMSITESTDIR\t0\t1\tservice_file";
80
81 static const CHAR directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
82                                     "s72\tS72\tl255\n"
83                                     "Directory\tDirectory\n"
84                                     "CABOUTDIR\tMSITESTDIR\tcabout\n"
85                                     "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
86                                     "FIRSTDIR\tMSITESTDIR\tfirst\n"
87                                     "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
88                                     "NEWDIR\tCABOUTDIR\tnew\n"
89                                     "ProgramFilesFolder\tTARGETDIR\t.\n"
90                                     "TARGETDIR\t\tSourceDir";
91
92 static const CHAR feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
93                                   "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
94                                   "Feature\tFeature\n"
95                                   "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
96                                   "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
97                                   "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
98                                   "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
99                                   "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
100                                   "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
101                                   "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";
102
103 static const CHAR feature_comp_dat[] = "Feature_\tComponent_\n"
104                                        "s38\ts72\n"
105                                        "FeatureComponents\tFeature_\tComponent_\n"
106                                        "Five\tFive\n"
107                                        "Four\tFour\n"
108                                        "One\tOne\n"
109                                        "Three\tThree\n"
110                                        "Two\tTwo\n"
111                                        "feature\tcomponent\n"
112                                        "service_feature\tservice_comp\n";
113
114 static const CHAR file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
115                                "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
116                                "File\tFile\n"
117                                "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
118                                "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
119                                "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
120                                "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
121                                "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
122                                "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
123                                "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
124
125 static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
126                                            "s72\tS255\tI2\n"
127                                            "InstallExecuteSequence\tAction\n"
128                                            "AllocateRegistrySpace\tNOT Installed\t1550\n"
129                                            "CostFinalize\t\t1000\n"
130                                            "CostInitialize\t\t800\n"
131                                            "FileCost\t\t900\n"
132                                            "ResolveSource\t\t950\n"
133                                            "MoveFiles\t\t1700\n"
134                                            "InstallFiles\t\t4000\n"
135                                            "DuplicateFiles\t\t4500\n"
136                                            "WriteEnvironmentStrings\t\t4550\n"
137                                            "CreateShortcuts\t\t4600\n"
138                                            "InstallServices\t\t5000\n"
139                                            "InstallFinalize\t\t6600\n"
140                                            "InstallInitialize\t\t1500\n"
141                                            "InstallValidate\t\t1400\n"
142                                            "LaunchConditions\t\t100\n"
143                                            "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
144
145 static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
146                                 "i2\ti4\tL64\tS255\tS32\tS72\n"
147                                 "Media\tDiskId\n"
148                                 "1\t3\t\t\tDISK1\t\n"
149                                 "2\t5\t\tmsitest.cab\tDISK2\t\n";
150
151 static const CHAR property_dat[] = "Property\tValue\n"
152                                    "s72\tl0\n"
153                                    "Property\tProperty\n"
154                                    "DefaultUIFont\tDlgFont8\n"
155                                    "HASUIRUN\t0\n"
156                                    "INSTALLLEVEL\t3\n"
157                                    "InstallMode\tTypical\n"
158                                    "Manufacturer\tWine\n"
159                                    "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
160                                    "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
161                                    "ProductID\tnone\n"
162                                    "ProductLanguage\t1033\n"
163                                    "ProductName\tMSITEST\n"
164                                    "ProductVersion\t1.1.1\n"
165                                    "PROMPTROLLBACKCOST\tP\n"
166                                    "Setup\tSetup\n"
167                                    "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
168                                    "AdminProperties\tPOSTADMIN\n"
169                                    "ROOTDRIVE\tC:\\\n"
170                                    "SERVNAME\tTestService\n"
171                                    "SERVDISP\tTestServiceDisp\n";
172
173 static const CHAR aup_property_dat[] = "Property\tValue\n"
174                                        "s72\tl0\n"
175                                        "Property\tProperty\n"
176                                        "DefaultUIFont\tDlgFont8\n"
177                                        "HASUIRUN\t0\n"
178                                        "ALLUSERS\t1\n"
179                                        "INSTALLLEVEL\t3\n"
180                                        "InstallMode\tTypical\n"
181                                        "Manufacturer\tWine\n"
182                                        "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
183                                        "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
184                                        "ProductID\tnone\n"
185                                        "ProductLanguage\t1033\n"
186                                        "ProductName\tMSITEST\n"
187                                        "ProductVersion\t1.1.1\n"
188                                        "PROMPTROLLBACKCOST\tP\n"
189                                        "Setup\tSetup\n"
190                                        "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
191                                        "AdminProperties\tPOSTADMIN\n"
192                                        "ROOTDRIVE\tC:\\\n"
193                                        "SERVNAME\tTestService\n"
194                                        "SERVDISP\tTestServiceDisp\n";
195
196 static const CHAR aup2_property_dat[] = "Property\tValue\n"
197                                         "s72\tl0\n"
198                                         "Property\tProperty\n"
199                                         "DefaultUIFont\tDlgFont8\n"
200                                         "HASUIRUN\t0\n"
201                                         "ALLUSERS\t2\n"
202                                         "INSTALLLEVEL\t3\n"
203                                         "InstallMode\tTypical\n"
204                                         "Manufacturer\tWine\n"
205                                         "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
206                                         "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
207                                         "ProductID\tnone\n"
208                                         "ProductLanguage\t1033\n"
209                                         "ProductName\tMSITEST\n"
210                                         "ProductVersion\t1.1.1\n"
211                                         "PROMPTROLLBACKCOST\tP\n"
212                                         "Setup\tSetup\n"
213                                         "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
214                                         "AdminProperties\tPOSTADMIN\n"
215                                         "ROOTDRIVE\tC:\\\n"
216                                         "SERVNAME\tTestService\n"
217                                         "SERVDISP\tTestServiceDisp\n";
218
219 static const CHAR icon_property_dat[] = "Property\tValue\n"
220                                         "s72\tl0\n"
221                                         "Property\tProperty\n"
222                                         "DefaultUIFont\tDlgFont8\n"
223                                         "HASUIRUN\t0\n"
224                                         "INSTALLLEVEL\t3\n"
225                                         "InstallMode\tTypical\n"
226                                         "Manufacturer\tWine\n"
227                                         "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
228                                         "ProductCode\t{7DF88A49-996F-4EC8-A022-BF956F9B2CBB}\n"
229                                         "ProductID\tnone\n"
230                                         "ProductLanguage\t1033\n"
231                                         "ProductName\tMSITEST\n"
232                                         "ProductVersion\t1.1.1\n"
233                                         "PROMPTROLLBACKCOST\tP\n"
234                                         "Setup\tSetup\n"
235                                         "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
236                                         "AdminProperties\tPOSTADMIN\n"
237                                         "ROOTDRIVE\tC:\\\n"
238                                         "SERVNAME\tTestService\n"
239                                         "SERVDISP\tTestServiceDisp\n";
240
241 static const CHAR shortcut_dat[] = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n"
242                                    "s72\ts72\tl128\ts72\ts72\tS255\tL255\tI2\tS72\tI2\tI2\tS72\n"
243                                    "Shortcut\tShortcut\n"
244                                    "Shortcut\tMSITESTDIR\tShortcut\tcomponent\tShortcut\t\tShortcut\t\t\t\t\t\n";
245
246 static const CHAR environment_dat[] = "Environment\tName\tValue\tComponent_\n"
247                                       "s72\tl255\tL255\ts72\n"
248                                       "Environment\tEnvironment\n"
249                                       "Var1\t=-MSITESTVAR1\t1\tOne\n"
250                                       "Var2\tMSITESTVAR2\t1\tOne\n"
251                                       "Var3\t=-MSITESTVAR3\t1\tOne\n"
252                                       "Var4\tMSITESTVAR4\t1\tOne\n"
253                                       "Var5\t-MSITESTVAR5\t\tOne\n"
254                                       "Var6\tMSITESTVAR6\t\tOne\n"
255                                       "Var7\t!-MSITESTVAR7\t\tOne\n"
256                                       "Var8\t!-*MSITESTVAR8\t\tOne\n"
257                                       "Var9\t=-MSITESTVAR9\t\tOne\n"
258                                       "Var10\t=MSITESTVAR10\t\tOne\n"
259                                       "Var11\t+-MSITESTVAR11\t[~];1\tOne\n"
260                                       "Var12\t+-MSITESTVAR11\t[~];2\tOne\n"
261                                       "Var13\t+-MSITESTVAR12\t[~];1\tOne\n"
262                                       "Var14\t=MSITESTVAR13\t[~];1\tOne\n"
263                                       "Var15\t=MSITESTVAR13\t[~];2\tOne\n"
264                                       "Var16\t=MSITESTVAR14\t;1;\tOne\n"
265                                       "Var17\t=MSITESTVAR15\t;;1;;\tOne\n"
266                                       "Var18\t=MSITESTVAR16\t 1 \tOne\n"
267                                       "Var19\t+-MSITESTVAR17\t1\tOne\n"
268                                       "Var20\t+-MSITESTVAR17\t;;2;;[~]\tOne\n"
269                                       "Var21\t+-MSITESTVAR18\t1\tOne\n"
270                                       "Var22\t+-MSITESTVAR18\t[~];;2;;\tOne\n"
271                                       "Var23\t+-MSITESTVAR19\t1\tOne\n"
272                                       "Var24\t+-MSITESTVAR19\t[~]2\tOne\n"
273                                       "Var25\t+-MSITESTVAR20\t1\tOne\n"
274                                       "Var26\t+-MSITESTVAR20\t2[~]\tOne\n";
275
276 /* Expected results, starting from MSITESTVAR11 onwards */
277 static const CHAR *environment_dat_results[] = {"1;2",    /*MSITESTVAR11*/
278                                                 "1",      /*MSITESTVAR12*/
279                                                 "1;2",    /*MSITESTVAR13*/
280                                                 ";1;",    /*MSITESTVAR14*/
281                                                 ";;1;;",  /*MSITESTVAR15*/
282                                                 " 1 ",    /*MSITESTVAR16*/
283                                                 ";;2;;1", /*MSITESTVAR17*/
284                                                 "1;;2;;", /*MSITESTVAR18*/
285                                                 "1",      /*MSITESTVAR19*/
286                                                 "1",      /*MSITESTVAR20*/
287                                                 NULL};
288
289 static const CHAR condition_dat[] = "Feature_\tLevel\tCondition\n"
290                                     "s38\ti2\tS255\n"
291                                     "Condition\tFeature_\tLevel\n"
292                                     "One\t4\t1\n";
293
294 static const CHAR up_property_dat[] = "Property\tValue\n"
295                                       "s72\tl0\n"
296                                       "Property\tProperty\n"
297                                       "DefaultUIFont\tDlgFont8\n"
298                                       "HASUIRUN\t0\n"
299                                       "INSTALLLEVEL\t3\n"
300                                       "InstallMode\tTypical\n"
301                                       "Manufacturer\tWine\n"
302                                       "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
303                                       "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
304                                       "ProductID\tnone\n"
305                                       "ProductLanguage\t1033\n"
306                                       "ProductName\tMSITEST\n"
307                                       "ProductVersion\t1.1.1\n"
308                                       "PROMPTROLLBACKCOST\tP\n"
309                                       "Setup\tSetup\n"
310                                       "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
311                                       "AdminProperties\tPOSTADMIN\n"
312                                       "ROOTDRIVE\tC:\\\n"
313                                       "SERVNAME\tTestService\n"
314                                       "SERVDISP\tTestServiceDisp\n"
315                                       "RemovePreviousVersions\t1\n";
316
317 static const CHAR up2_property_dat[] = "Property\tValue\n"
318                                        "s72\tl0\n"
319                                        "Property\tProperty\n"
320                                        "DefaultUIFont\tDlgFont8\n"
321                                        "HASUIRUN\t0\n"
322                                        "INSTALLLEVEL\t3\n"
323                                        "InstallMode\tTypical\n"
324                                        "Manufacturer\tWine\n"
325                                        "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
326                                        "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
327                                        "ProductID\tnone\n"
328                                        "ProductLanguage\t1033\n"
329                                        "ProductName\tMSITEST\n"
330                                        "ProductVersion\t1.1.2\n"
331                                        "PROMPTROLLBACKCOST\tP\n"
332                                        "Setup\tSetup\n"
333                                        "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
334                                        "AdminProperties\tPOSTADMIN\n"
335                                        "ROOTDRIVE\tC:\\\n"
336                                        "SERVNAME\tTestService\n"
337                                        "SERVDISP\tTestServiceDisp\n";
338
339 static const CHAR up3_property_dat[] = "Property\tValue\n"
340                                        "s72\tl0\n"
341                                        "Property\tProperty\n"
342                                        "DefaultUIFont\tDlgFont8\n"
343                                        "HASUIRUN\t0\n"
344                                        "INSTALLLEVEL\t3\n"
345                                        "InstallMode\tTypical\n"
346                                        "Manufacturer\tWine\n"
347                                        "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
348                                        "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
349                                        "ProductID\tnone\n"
350                                        "ProductLanguage\t1033\n"
351                                        "ProductName\tMSITEST\n"
352                                        "ProductVersion\t1.1.2\n"
353                                        "PROMPTROLLBACKCOST\tP\n"
354                                        "Setup\tSetup\n"
355                                        "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
356                                        "AdminProperties\tPOSTADMIN\n"
357                                        "ROOTDRIVE\tC:\\\n"
358                                        "SERVNAME\tTestService\n"
359                                        "SERVDISP\tTestServiceDisp\n"
360                                        "RemovePreviousVersions\t1\n";
361
362 static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
363                                    "s72\ti2\tl255\tL255\tL0\ts72\n"
364                                    "Registry\tRegistry\n"
365                                    "Apples\t1\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
366                                    "Oranges\t1\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
367                                    "regdata\t1\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
368                                    "OrderTest\t1\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
369
370 static const CHAR service_install_dat[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
371                                           "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
372                                           "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
373                                           "ServiceInstall\tServiceInstall\n"
374                                           "TestService\t[SERVNAME]\t[SERVDISP]\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
375
376 static const CHAR service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
377                                           "s72\tl255\ti2\tL255\tI2\ts72\n"
378                                           "ServiceControl\tServiceControl\n"
379                                           "ServiceControl\tTestService\t8\t\t0\tservice_comp";
380
381 static const CHAR sss_service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
382                                               "s72\tl255\ti2\tL255\tI2\ts72\n"
383                                               "ServiceControl\tServiceControl\n"
384                                               "ServiceControl\tSpooler\t1\t\t0\tservice_comp";
385
386 static const CHAR sss_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
387                                                "s72\tS255\tI2\n"
388                                                "InstallExecuteSequence\tAction\n"
389                                                "LaunchConditions\t\t100\n"
390                                                "CostInitialize\t\t800\n"
391                                                "FileCost\t\t900\n"
392                                                "ResolveSource\t\t950\n"
393                                                "CostFinalize\t\t1000\n"
394                                                "InstallValidate\t\t1400\n"
395                                                "InstallInitialize\t\t1500\n"
396                                                "DeleteServices\t\t5000\n"
397                                                "MoveFiles\t\t5100\n"
398                                                "InstallFiles\t\t5200\n"
399                                                "DuplicateFiles\t\t5300\n"
400                                                "StartServices\t\t5400\n"
401                                                "InstallFinalize\t\t6000\n";
402
403 static const CHAR sds_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
404                                                "s72\tS255\tI2\n"
405                                                "InstallExecuteSequence\tAction\n"
406                                                "LaunchConditions\t\t100\n"
407                                                "CostInitialize\t\t800\n"
408                                                "FileCost\t\t900\n"
409                                                "ResolveSource\t\t950\n"
410                                                "CostFinalize\t\t1000\n"
411                                                "InstallValidate\t\t1400\n"
412                                                "InstallInitialize\t\t1500\n"
413                                                "DeleteServices\tInstalled\t5000\n"
414                                                "MoveFiles\t\t5100\n"
415                                                "InstallFiles\t\t5200\n"
416                                                "DuplicateFiles\t\t5300\n"
417                                                "InstallServices\tNOT Installed\t5400\n"
418                                                "RegisterProduct\t\t5500\n"
419                                                "PublishFeatures\t\t5600\n"
420                                                "PublishProduct\t\t5700\n"
421                                                "InstallFinalize\t\t6000\n";
422
423 /* tables for test_continuouscabs */
424 static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
425                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
426                                        "Component\tComponent\n"
427                                        "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
428                                        "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
429                                        "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
430
431 static const CHAR cc2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
432                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
433                                         "Component\tComponent\n"
434                                         "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
435                                         "augustus\t\tMSITESTDIR\t0\t0\taugustus\n"
436                                         "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
437
438 static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
439                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
440                                      "Feature\tFeature\n"
441                                      "feature\t\t\t\t2\t1\tTARGETDIR\t0";
442
443 static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
444                                           "s38\ts72\n"
445                                           "FeatureComponents\tFeature_\tComponent_\n"
446                                           "feature\tmaximus\n"
447                                           "feature\taugustus\n"
448                                           "feature\tcaesar";
449
450 static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
451                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
452                                   "File\tFile\n"
453                                   "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
454                                   "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
455                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
456
457 static const CHAR cc2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
458                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
459                                    "File\tFile\n"
460                                    "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
461                                    "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
462                                    "tiberius\tmaximus\ttiberius\t500\t\t\t16384\t3\n"
463                                    "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
464
465 static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
466                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
467                                    "Media\tDiskId\n"
468                                    "1\t10\t\ttest1.cab\tDISK1\t\n"
469                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
470                                    "3\t12\t\ttest3.cab\tDISK3\t\n";
471
472 static const CHAR co_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
473                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
474                                   "File\tFile\n"
475                                   "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
476                                   "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
477                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
478
479 static const CHAR co_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
480                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
481                                    "Media\tDiskId\n"
482                                    "1\t10\t\ttest1.cab\tDISK1\t\n"
483                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
484                                    "3\t3\t\ttest3.cab\tDISK3\t\n";
485
486 static const CHAR co2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
487                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
488                                     "Media\tDiskId\n"
489                                     "1\t10\t\ttest1.cab\tDISK1\t\n"
490                                     "2\t12\t\ttest3.cab\tDISK3\t\n"
491                                     "3\t2\t\ttest2.cab\tDISK2\t\n";
492
493 static const CHAR mm_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
494                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
495                                   "File\tFile\n"
496                                   "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
497                                   "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
498                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
499
500 static const CHAR mm_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
501                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
502                                    "Media\tDiskId\n"
503                                    "1\t3\t\ttest1.cab\tDISK1\t\n";
504
505 static const CHAR ss_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
506                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
507                                    "Media\tDiskId\n"
508                                    "1\t2\t\ttest1.cab\tDISK1\t\n"
509                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
510                                    "3\t12\t\ttest3.cab\tDISK3\t\n";
511
512 /* tables for test_uiLevelFlags */
513 static const CHAR ui_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
514                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
515                                        "Component\tComponent\n"
516                                        "maximus\t\tMSITESTDIR\t0\tHASUIRUN=1\tmaximus\n"
517                                        "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
518                                        "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
519
520 static const CHAR ui_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
521                                            "s72\tS255\tI2\n"
522                                            "InstallUISequence\tAction\n"
523                                            "SetUIProperty\t\t5\n"
524                                            "ExecuteAction\t\t1100\n";
525
526 static const CHAR ui_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
527                                            "s72\ti2\tS64\tS0\tS255\n"
528                                            "CustomAction\tAction\n"
529                                            "SetUIProperty\t51\tHASUIRUN\t1\t\n";
530
531 static const CHAR rof_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
532                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
533                                         "Component\tComponent\n"
534                                         "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";
535
536 static const CHAR rof_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
537                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
538                                       "Feature\tFeature\n"
539                                       "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
540                                       "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
541
542 static const CHAR rof_feature_comp_dat[] = "Feature_\tComponent_\n"
543                                            "s38\ts72\n"
544                                            "FeatureComponents\tFeature_\tComponent_\n"
545                                            "feature\tmaximus\n"
546                                            "montecristo\tmaximus";
547
548 static const CHAR rof_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
549                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
550                                    "File\tFile\n"
551                                    "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
552
553 static const CHAR rof_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
554                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
555                                     "Media\tDiskId\n"
556                                     "1\t1\t\t\tDISK1\t\n";
557
558 static const CHAR rofc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
559                                     "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
560                                     "File\tFile\n"
561                                     "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1";
562
563 static const CHAR rofc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
564                                      "i2\ti4\tL64\tS255\tS32\tS72\n"
565                                      "Media\tDiskId\n"
566                                      "1\t1\t\ttest1.cab\tDISK1\t\n";
567
568 static const CHAR lus2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
569                                      "i2\ti4\tL64\tS255\tS32\tS72\n"
570                                      "Media\tDiskId\n"
571                                      "1\t1\t\t#test1.cab\tDISK1\t\n";
572
573 static const CHAR sdp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
574                                                "s72\tS255\tI2\n"
575                                                "InstallExecuteSequence\tAction\n"
576                                                "AllocateRegistrySpace\tNOT Installed\t1550\n"
577                                                "CostFinalize\t\t1000\n"
578                                                "CostInitialize\t\t800\n"
579                                                "FileCost\t\t900\n"
580                                                "InstallFiles\t\t4000\n"
581                                                "InstallFinalize\t\t6600\n"
582                                                "InstallInitialize\t\t1500\n"
583                                                "InstallValidate\t\t1400\n"
584                                                "LaunchConditions\t\t100\n"
585                                                "SetDirProperty\t\t950";
586
587 static const CHAR sdp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
588                                             "s72\ti2\tS64\tS0\tS255\n"
589                                             "CustomAction\tAction\n"
590                                             "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";
591
592 static const CHAR cie_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
593                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
594                                         "Component\tComponent\n"
595                                         "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
596                                         "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
597                                         "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
598                                         "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";
599
600 static const CHAR cie_feature_comp_dat[] = "Feature_\tComponent_\n"
601                                            "s38\ts72\n"
602                                            "FeatureComponents\tFeature_\tComponent_\n"
603                                            "feature\tmaximus\n"
604                                            "feature\taugustus\n"
605                                            "feature\tcaesar\n"
606                                            "feature\tgaius";
607
608 static const CHAR cie_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
609                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
610                                    "File\tFile\n"
611                                    "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
612                                    "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
613                                    "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
614                                    "gaius\tgaius\tgaius\t500\t\t\t8192\t11";
615
616 static const CHAR cie_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
617                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
618                                     "Media\tDiskId\n"
619                                     "1\t1\t\ttest1.cab\tDISK1\t\n"
620                                     "2\t2\t\ttest2.cab\tDISK2\t\n"
621                                     "3\t12\t\ttest3.cab\tDISK3\t\n";
622
623 static const CHAR ci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
624                                               "s72\tS255\tI2\n"
625                                               "InstallExecuteSequence\tAction\n"
626                                               "CostFinalize\t\t1000\n"
627                                               "CostInitialize\t\t800\n"
628                                               "FileCost\t\t900\n"
629                                               "InstallFiles\t\t4000\n"
630                                               "InstallServices\t\t5000\n"
631                                               "InstallFinalize\t\t6600\n"
632                                               "InstallInitialize\t\t1500\n"
633                                               "RunInstall\t\t1600\n"
634                                               "InstallValidate\t\t1400\n"
635                                               "LaunchConditions\t\t100";
636
637 static const CHAR ci_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
638                                             "s72\ti2\tS64\tS0\tS255\n"
639                                             "CustomAction\tAction\n"
640                                             "RunInstall\t87\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
641
642 static const CHAR ci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
643                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
644                                        "Component\tComponent\n"
645                                        "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
646
647 static const CHAR ci2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
648                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
649                                         "Component\tComponent\n"
650                                         "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
651
652 static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
653                                            "s38\ts72\n"
654                                            "FeatureComponents\tFeature_\tComponent_\n"
655                                            "feature\taugustus";
656
657 static const CHAR ci2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
658                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
659                                    "File\tFile\n"
660                                    "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
661
662 static const CHAR spf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
663                                             "s72\ti2\tS64\tS0\tS255\n"
664                                             "CustomAction\tAction\n"
665                                             "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
666
667 static const CHAR spf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
668                                                "s72\tS255\tI2\n"
669                                                "InstallExecuteSequence\tAction\n"
670                                                "CostFinalize\t\t1000\n"
671                                                "CostInitialize\t\t800\n"
672                                                "FileCost\t\t900\n"
673                                                "SetFolderProp\t\t950\n"
674                                                "InstallFiles\t\t4000\n"
675                                                "InstallServices\t\t5000\n"
676                                                "InstallFinalize\t\t6600\n"
677                                                "InstallInitialize\t\t1500\n"
678                                                "InstallValidate\t\t1400\n"
679                                                "LaunchConditions\t\t100";
680
681 static const CHAR spf_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
682                                              "s72\tS255\tI2\n"
683                                              "InstallUISequence\tAction\n"
684                                              "CostInitialize\t\t800\n"
685                                              "FileCost\t\t900\n"
686                                              "CostFinalize\t\t1000\n"
687                                              "ExecuteAction\t\t1100\n";
688
689 static const CHAR pp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
690                                               "s72\tS255\tI2\n"
691                                               "InstallExecuteSequence\tAction\n"
692                                               "ValidateProductID\t\t700\n"
693                                               "CostInitialize\t\t800\n"
694                                               "FileCost\t\t900\n"
695                                               "CostFinalize\t\t1000\n"
696                                               "InstallValidate\t\t1400\n"
697                                               "InstallInitialize\t\t1500\n"
698                                               "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
699                                               "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
700                                               "RemoveFiles\t\t3500\n"
701                                               "InstallFiles\t\t4000\n"
702                                               "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
703                                               "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
704                                               "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
705                                               "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
706                                               "InstallFinalize\t\t6600";
707
708 static const CHAR ppc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
709                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
710                                         "Component\tComponent\n"
711                                         "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n"
712                                         "augustus\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\taugustus\n";
713
714 static const CHAR ppc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
715                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
716                                    "File\tFile\n"
717                                    "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1\n"
718                                    "augustus\taugustus\taugustus\t500\t\t\t8192\t2";
719
720 static const CHAR ppc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
721                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
722                                     "Media\tDiskId\n"
723                                     "1\t2\t\t\tDISK1\t\n";
724
725 static const CHAR ppc_feature_comp_dat[] = "Feature_\tComponent_\n"
726                                            "s38\ts72\n"
727                                            "FeatureComponents\tFeature_\tComponent_\n"
728                                            "feature\tmaximus\n"
729                                            "feature\taugustus\n"
730                                            "montecristo\tmaximus";
731
732 static const CHAR tp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
733                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
734                                        "Component\tComponent\n"
735                                        "augustus\t\tMSITESTDIR\t0\tprop=\"val\"\taugustus\n";
736
737 static const CHAR cwd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
738                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
739                                         "Component\tComponent\n"
740                                         "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
741
742 static const CHAR adm_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
743                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
744                                         "Component\tComponent\n"
745                                         "augustus\t\tMSITESTDIR\t0\tPOSTADMIN=1\taugustus";
746
747 static const CHAR adm_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
748                                             "s72\ti2\tS64\tS0\tS255\n"
749                                             "CustomAction\tAction\n"
750                                             "SetPOSTADMIN\t51\tPOSTADMIN\t1\t\n";
751
752 static const CHAR adm_admin_exec_seq_dat[] = "Action\tCondition\tSequence\n"
753                                              "s72\tS255\tI2\n"
754                                              "AdminExecuteSequence\tAction\n"
755                                              "CostFinalize\t\t1000\n"
756                                              "CostInitialize\t\t800\n"
757                                              "FileCost\t\t900\n"
758                                              "SetPOSTADMIN\t\t950\n"
759                                              "InstallFiles\t\t4000\n"
760                                              "InstallFinalize\t\t6600\n"
761                                              "InstallInitialize\t\t1500\n"
762                                              "InstallValidate\t\t1400\n"
763                                              "LaunchConditions\t\t100";
764
765 static const CHAR amp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
766                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
767                                         "Component\tComponent\n"
768                                         "augustus\t\tMSITESTDIR\t0\tMYPROP=2718 and MyProp=42\taugustus\n";
769
770 static const CHAR rem_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
771                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
772                                         "Component\tComponent\n"
773                                         "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t0\t\thydrogen\n"
774                                         "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\thelium\n"
775                                         "lithium\t\tMSITESTDIR\t2\t\tlithium\n";
776
777 static const CHAR rem_feature_comp_dat[] = "Feature_\tComponent_\n"
778                                            "s38\ts72\n"
779                                            "FeatureComponents\tFeature_\tComponent_\n"
780                                            "feature\thydrogen\n"
781                                            "feature\thelium\n"
782                                            "feature\tlithium";
783
784 static const CHAR rem_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
785                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
786                                    "File\tFile\n"
787                                    "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
788                                    "helium\thelium\thelium\t0\t\t\t8192\t1\n"
789                                    "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
790
791 static const CHAR rem_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
792                                                "s72\tS255\tI2\n"
793                                                "InstallExecuteSequence\tAction\n"
794                                                "ValidateProductID\t\t700\n"
795                                                "CostInitialize\t\t800\n"
796                                                "FileCost\t\t900\n"
797                                                "CostFinalize\t\t1000\n"
798                                                "InstallValidate\t\t1400\n"
799                                                "InstallInitialize\t\t1500\n"
800                                                "ProcessComponents\t\t1600\n"
801                                                "UnpublishFeatures\t\t1800\n"
802                                                "RemoveFiles\t\t3500\n"
803                                                "InstallFiles\t\t4000\n"
804                                                "RegisterProduct\t\t6100\n"
805                                                "PublishFeatures\t\t6300\n"
806                                                "PublishProduct\t\t6400\n"
807                                                "InstallFinalize\t\t6600";
808
809 static const CHAR rem_remove_files_dat[] = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n"
810                                            "s72\ts72\tS255\ts72\tI2\n"
811                                            "RemoveFile\tFileKey\n"
812                                            "furlong\thydrogen\tfurlong\tMSITESTDIR\t1\n"
813                                            "firkin\thelium\tfirkin\tMSITESTDIR\t1\n"
814                                            "fortnight\tlithium\tfortnight\tMSITESTDIR\t1\n"
815                                            "becquerel\thydrogen\tbecquerel\tMSITESTDIR\t2\n"
816                                            "dioptre\thelium\tdioptre\tMSITESTDIR\t2\n"
817                                            "attoparsec\tlithium\tattoparsec\tMSITESTDIR\t2\n"
818                                            "storeys\thydrogen\tstoreys\tMSITESTDIR\t3\n"
819                                            "block\thelium\tblock\tMSITESTDIR\t3\n"
820                                            "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n"
821                                            "nanoacre\thydrogen\t\tCABOUTDIR\t3\n";
822
823 static const CHAR mov_move_file_dat[] = "FileKey\tComponent_\tSourceName\tDestName\tSourceFolder\tDestFolder\tOptions\n"
824                                         "s72\ts72\tS255\tS255\tS72\ts72\ti2\n"
825                                         "MoveFile\tFileKey\n"
826                                         "abkhazia\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t0\n"
827                                         "bahamas\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t1\n"
828                                         "cambodia\taugustus\tcameroon\tcanada\tSourceDir\tMSITESTDIR\t0\n"
829                                         "denmark\taugustus\tdjibouti\tdominica\tSourceDir\tMSITESTDIR\t1\n"
830                                         "ecuador\taugustus\tegypt\telsalvador\tNotAProp\tMSITESTDIR\t1\n"
831                                         "fiji\taugustus\tfinland\tfrance\tSourceDir\tNotAProp\t1\n"
832                                         "gabon\taugustus\tgambia\tgeorgia\tSOURCEFULL\tMSITESTDIR\t1\n"
833                                         "haiti\taugustus\thonduras\thungary\tSourceDir\tDESTFULL\t1\n"
834                                         "iceland\taugustus\tindia\tindonesia\tMSITESTDIR\tMSITESTDIR\t1\n"
835                                         "jamaica\taugustus\tjapan\tjordan\tFILEPATHBAD\tMSITESTDIR\t1\n"
836                                         "kazakhstan\taugustus\t\tkiribati\tFILEPATHGOOD\tMSITESTDIR\t1\n"
837                                         "laos\taugustus\tlatvia\tlebanon\tSourceDir\tMSITESTDIR\t1\n"
838                                         "namibia\taugustus\tnauru\tkiribati\tSourceDir\tMSITESTDIR\t1\n"
839                                         "pakistan\taugustus\tperu\tsfn|poland\tSourceDir\tMSITESTDIR\t1\n"
840                                         "wildcard\taugustus\tapp*\twildcard\tSourceDir\tMSITESTDIR\t1\n"
841                                         "single\taugustus\tf?o\tsingle\tSourceDir\tMSITESTDIR\t1\n"
842                                         "wildcardnodest\taugustus\tbudd*\t\tSourceDir\tMSITESTDIR\t1\n"
843                                         "singlenodest\taugustus\tb?r\t\tSourceDir\tMSITESTDIR\t1\n";
844
845 static const CHAR mc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
846                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
847                                         "Component\tComponent\n"
848                                         "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
849                                         "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
850                                         "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
851                                         "gaius\t\tMSITESTDIR\t0\tGAIUS=1\tgaius\n";
852
853 static const CHAR mc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
854                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
855                                   "File\tFile\n"
856                                   "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
857                                   "augustus\taugustus\taugustus\t500\t\t\t0\t2\n"
858                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3\n"
859                                   "gaius\tgaius\tgaius\t500\t\t\t16384\t4";
860
861 static const CHAR mc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
862                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
863                                    "Media\tDiskId\n"
864                                    "1\t1\t\ttest1.cab\tDISK1\t\n"
865                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
866                                    "3\t3\t\ttest3.cab\tDISK3\t\n"
867                                    "4\t4\t\ttest3.cab\tDISK3\t\n";
868
869 static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n"
870                                        "s72\ti2\ti4\ti4\ti4\ti4\n"
871                                        "MsiFileHash\tFile_\n"
872                                        "caesar\t0\t850433704\t-241429251\t675791761\t-1221108824";
873
874 static const CHAR df_directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
875                                        "s72\tS72\tl255\n"
876                                        "Directory\tDirectory\n"
877                                        "THIS\tMSITESTDIR\tthis\n"
878                                        "DOESNOT\tTHIS\tdoesnot\n"
879                                        "NONEXISTENT\tDOESNOT\texist\n"
880                                        "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
881                                        "ProgramFilesFolder\tTARGETDIR\t.\n"
882                                        "TARGETDIR\t\tSourceDir";
883
884 static const CHAR df_duplicate_file_dat[] = "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
885                                             "s72\ts72\ts72\tS255\tS72\n"
886                                             "DuplicateFile\tFileKey\n"
887                                             "maximus\tmaximus\tmaximus\taugustus\t\n"
888                                             "caesar\tmaximus\tmaximus\t\tNONEXISTENT\n"
889                                             "augustus\tnosuchcomponent\tmaximus\t\tMSITESTDIR\n";
890
891 static const CHAR wrv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
892                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
893                                         "Component\tComponent\n"
894                                         "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
895
896 static const CHAR wrv_registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
897                                        "s72\ti2\tl255\tL255\tL0\ts72\n"
898                                        "Registry\tRegistry\n"
899                                        "regdata\t2\tSOFTWARE\\Wine\\msitest\tValue\t[~]one[~]two[~]three\taugustus";
900
901 static const CHAR ca51_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
902                                          "s72\tS38\ts72\ti2\tS255\tS72\n"
903                                          "Component\tComponent\n"
904                                          "augustus\t\tMSITESTDIR\t0\tMYPROP=42\taugustus\n";
905
906 static const CHAR ca51_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
907                                                 "s72\tS255\tI2\n"
908                                                 "InstallExecuteSequence\tAction\n"
909                                                 "ValidateProductID\t\t700\n"
910                                                 "GoodSetProperty\t\t725\n"
911                                                 "BadSetProperty\t\t750\n"
912                                                 "CostInitialize\t\t800\n"
913                                                 "ResolveSource\t\t810\n"
914                                                 "FileCost\t\t900\n"
915                                                 "SetSourceDir\tSRCDIR\t910\n"
916                                                 "CostFinalize\t\t1000\n"
917                                                 "InstallValidate\t\t1400\n"
918                                                 "InstallInitialize\t\t1500\n"
919                                                 "InstallFiles\t\t4000\n"
920                                                 "InstallFinalize\t\t6600";
921
922 static const CHAR ca51_custom_action_dat[] = "Action\tType\tSource\tTarget\n"
923                                              "s72\ti2\tS64\tS0\n"
924                                              "CustomAction\tAction\n"
925                                              "GoodSetProperty\t51\tMYPROP\t42\n"
926                                              "BadSetProperty\t51\t\tMYPROP\n"
927                                              "SetSourceDir\t51\tSourceDir\t[SRCDIR]\n";
928
929 static const CHAR is_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
930                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
931                                      "Feature\tFeature\n"
932                                      "one\t\t\t\t2\t1\t\t0\n" /* favorLocal */
933                                      "two\t\t\t\t2\t1\t\t1\n" /* favorSource */
934                                      "three\t\t\t\t2\t1\t\t4\n" /* favorAdvertise */
935                                      "four\t\t\t\t2\t0\t\t0"; /* disabled */
936
937 static const CHAR is_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
938                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
939                                        "Component\tComponent\n"
940                                        "alpha\t\tMSITESTDIR\t0\t\talpha_file\n" /* favorLocal:Local */
941                                        "beta\t\tMSITESTDIR\t1\t\tbeta_file\n" /* favorLocal:Source */
942                                        "gamma\t\tMSITESTDIR\t2\t\tgamma_file\n" /* favorLocal:Optional */
943                                        "theta\t\tMSITESTDIR\t0\t\ttheta_file\n" /* favorSource:Local */
944                                        "delta\t\tMSITESTDIR\t1\t\tdelta_file\n" /* favorSource:Source */
945                                        "epsilon\t\tMSITESTDIR\t2\t\tepsilon_file\n" /* favorSource:Optional */
946                                        "zeta\t\tMSITESTDIR\t0\t\tzeta_file\n" /* favorAdvertise:Local */
947                                        "iota\t\tMSITESTDIR\t1\t\tiota_file\n" /* favorAdvertise:Source */
948                                        "eta\t\tMSITESTDIR\t2\t\teta_file\n" /* favorAdvertise:Optional */
949                                        "kappa\t\tMSITESTDIR\t0\t\tkappa_file\n" /* disabled:Local */
950                                        "lambda\t\tMSITESTDIR\t1\t\tlambda_file\n" /* disabled:Source */
951                                        "mu\t\tMSITESTDIR\t2\t\tmu_file\n"; /* disabled:Optional */
952
953 static const CHAR is_feature_comp_dat[] = "Feature_\tComponent_\n"
954                                           "s38\ts72\n"
955                                           "FeatureComponents\tFeature_\tComponent_\n"
956                                           "one\talpha\n"
957                                           "one\tbeta\n"
958                                           "one\tgamma\n"
959                                           "two\ttheta\n"
960                                           "two\tdelta\n"
961                                           "two\tepsilon\n"
962                                           "three\tzeta\n"
963                                           "three\tiota\n"
964                                           "three\teta\n"
965                                           "four\tkappa\n"
966                                           "four\tlambda\n"
967                                           "four\tmu";
968
969 static const CHAR is_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
970                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
971                                   "File\tFile\n"
972                                   "alpha_file\talpha\talpha\t500\t\t\t8192\t1\n"
973                                   "beta_file\tbeta\tbeta\t500\t\t\t8291\t2\n"
974                                   "gamma_file\tgamma\tgamma\t500\t\t\t8192\t3\n"
975                                   "theta_file\ttheta\ttheta\t500\t\t\t8192\t4\n"
976                                   "delta_file\tdelta\tdelta\t500\t\t\t8192\t5\n"
977                                   "epsilon_file\tepsilon\tepsilon\t500\t\t\t8192\t6\n"
978                                   "zeta_file\tzeta\tzeta\t500\t\t\t8192\t7\n"
979                                   "iota_file\tiota\tiota\t500\t\t\t8192\t8\n"
980                                   "eta_file\teta\teta\t500\t\t\t8192\t9\n"
981                                   "kappa_file\tkappa\tkappa\t500\t\t\t8192\t10\n"
982                                   "lambda_file\tlambda\tlambda\t500\t\t\t8192\t11\n"
983                                   "mu_file\tmu\tmu\t500\t\t\t8192\t12";
984
985 static const CHAR is_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
986                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
987                                    "Media\tDiskId\n"
988                                    "1\t12\t\t\tDISK1\t\n";
989
990 static const CHAR sp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
991                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
992                                         "Component\tComponent\n"
993                                         "augustus\t\tTWODIR\t0\t\taugustus\n";
994
995 static const CHAR sp_directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
996                                        "s72\tS72\tl255\n"
997                                        "Directory\tDirectory\n"
998                                        "TARGETDIR\t\tSourceDir\n"
999                                        "ProgramFilesFolder\tTARGETDIR\t.\n"
1000                                        "MSITESTDIR\tProgramFilesFolder\tmsitest:.\n"
1001                                        "ONEDIR\tMSITESTDIR\t.:shortone|longone\n"
1002                                        "TWODIR\tONEDIR\t.:shorttwo|longtwo";
1003
1004 static const CHAR mcp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1005                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1006                                         "Component\tComponent\n"
1007                                         "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t2\t\thydrogen\n"
1008                                         "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t2\t\thelium\n"
1009                                         "lithium\t{4AF28FFC-71C7-4307-BDE4-B77C5338F56F}\tMSITESTDIR\t2\tPROPVAR=42\tlithium\n";
1010
1011 static const CHAR mcp_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1012                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1013                                       "Feature\tFeature\n"
1014                                       "hydroxyl\t\thydroxyl\thydroxyl\t2\t1\tTARGETDIR\t0\n"
1015                                       "heliox\t\theliox\theliox\t2\t5\tTARGETDIR\t0\n"
1016                                       "lithia\t\tlithia\tlithia\t2\t10\tTARGETDIR\t0";
1017
1018 static const CHAR mcp_feature_comp_dat[] = "Feature_\tComponent_\n"
1019                                            "s38\ts72\n"
1020                                            "FeatureComponents\tFeature_\tComponent_\n"
1021                                            "hydroxyl\thydrogen\n"
1022                                            "heliox\thelium\n"
1023                                            "lithia\tlithium";
1024
1025 static const CHAR mcomp_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1026                                      "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1027                                      "File\tFile\n"
1028                                      "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
1029                                      "helium\thelium\thelium\t0\t\t\t8192\t1\n"
1030                                      "lithium\tlithium\tlithium\t0\t\t\t8192\t1\n"
1031                                      "beryllium\tmissingcomp\tberyllium\t0\t\t\t8192\t1";
1032
1033 static const CHAR ai_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1034                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1035                                   "File\tFile\n"
1036                                   "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
1037                                   "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
1038                                   "one.txt\tOne\tone.txt\t1000\t\t\t16384\t1\n"
1039                                   "three.txt\tThree\tthree.txt\t1000\t\t\t16384\t3\n"
1040                                   "two.txt\tTwo\ttwo.txt\t1000\t\t\t16384\t2\n"
1041                                   "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
1042                                   "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
1043
1044 static const CHAR ip_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1045                                               "s72\tS255\tI2\n"
1046                                               "InstallExecuteSequence\tAction\n"
1047                                               "CostFinalize\t\t1000\n"
1048                                               "ValidateProductID\t\t700\n"
1049                                               "CostInitialize\t\t800\n"
1050                                               "FileCost\t\t900\n"
1051                                               "RemoveFiles\t\t3500\n"
1052                                               "InstallFiles\t\t4000\n"
1053                                               "RegisterUser\t\t6000\n"
1054                                               "RegisterProduct\t\t6100\n"
1055                                               "PublishFeatures\t\t6300\n"
1056                                               "PublishProduct\t\t6400\n"
1057                                               "InstallFinalize\t\t6600\n"
1058                                               "InstallInitialize\t\t1500\n"
1059                                               "ProcessComponents\t\t1600\n"
1060                                               "UnpublishFeatures\t\t1800\n"
1061                                               "InstallValidate\t\t1400\n"
1062                                               "LaunchConditions\t\t100\n"
1063                                               "TestInstalledProp\tInstalled AND NOT REMOVE\t950\n";
1064
1065 static const CHAR ip_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1066                                            "s72\ti2\tS64\tS0\tS255\n"
1067                                            "CustomAction\tAction\n"
1068                                            "TestInstalledProp\t19\t\tTest failed\t\n";
1069
1070 static const CHAR aup_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1071                                                "s72\tS255\tI2\n"
1072                                                "InstallExecuteSequence\tAction\n"
1073                                                "CostFinalize\t\t1000\n"
1074                                                "ValidateProductID\t\t700\n"
1075                                                "CostInitialize\t\t800\n"
1076                                                "FileCost\t\t900\n"
1077                                                "RemoveFiles\t\t3500\n"
1078                                                "InstallFiles\t\t4000\n"
1079                                                "RegisterUser\t\t6000\n"
1080                                                "RegisterProduct\t\t6100\n"
1081                                                "PublishFeatures\t\t6300\n"
1082                                                "PublishProduct\t\t6400\n"
1083                                                "InstallFinalize\t\t6600\n"
1084                                                "InstallInitialize\t\t1500\n"
1085                                                "ProcessComponents\t\t1600\n"
1086                                                "UnpublishFeatures\t\t1800\n"
1087                                                "InstallValidate\t\t1400\n"
1088                                                "LaunchConditions\t\t100\n"
1089                                                "TestAllUsersProp\tALLUSERS AND NOT REMOVE\t50\n";
1090
1091 static const CHAR aup2_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1092                                                 "s72\tS255\tI2\n"
1093                                                 "InstallExecuteSequence\tAction\n"
1094                                                 "CostFinalize\t\t1000\n"
1095                                                 "ValidateProductID\t\t700\n"
1096                                                 "CostInitialize\t\t800\n"
1097                                                 "FileCost\t\t900\n"
1098                                                 "RemoveFiles\t\t3500\n"
1099                                                 "InstallFiles\t\t4000\n"
1100                                                 "RegisterUser\t\t6000\n"
1101                                                 "RegisterProduct\t\t6100\n"
1102                                                 "PublishFeatures\t\t6300\n"
1103                                                 "PublishProduct\t\t6400\n"
1104                                                 "InstallFinalize\t\t6600\n"
1105                                                 "InstallInitialize\t\t1500\n"
1106                                                 "ProcessComponents\t\t1600\n"
1107                                                 "UnpublishFeatures\t\t1800\n"
1108                                                 "InstallValidate\t\t1400\n"
1109                                                 "LaunchConditions\t\t100\n"
1110                                                 "TestAllUsersProp\tALLUSERS=2 AND NOT REMOVE\t50\n";
1111
1112 static const CHAR aup3_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1113                                                 "s72\tS255\tI2\n"
1114                                                 "InstallExecuteSequence\tAction\n"
1115                                                 "CostFinalize\t\t1000\n"
1116                                                 "ValidateProductID\t\t700\n"
1117                                                 "CostInitialize\t\t800\n"
1118                                                 "FileCost\t\t900\n"
1119                                                 "RemoveFiles\t\t3500\n"
1120                                                 "InstallFiles\t\t4000\n"
1121                                                 "RegisterUser\t\t6000\n"
1122                                                 "RegisterProduct\t\t6100\n"
1123                                                 "PublishFeatures\t\t6300\n"
1124                                                 "PublishProduct\t\t6400\n"
1125                                                 "InstallFinalize\t\t6600\n"
1126                                                 "InstallInitialize\t\t1500\n"
1127                                                 "ProcessComponents\t\t1600\n"
1128                                                 "UnpublishFeatures\t\t1800\n"
1129                                                 "InstallValidate\t\t1400\n"
1130                                                 "LaunchConditions\t\t100\n"
1131                                                 "TestAllUsersProp\tALLUSERS=1 AND NOT REMOVE\t50\n";
1132
1133 static const CHAR aup_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1134                                             "s72\ti2\tS64\tS0\tS255\n"
1135                                             "CustomAction\tAction\n"
1136                                             "TestAllUsersProp\t19\t\tTest failed\t\n";
1137
1138 static const CHAR cf_create_folders_dat[] = "Directory_\tComponent_\n"
1139                                             "s72\ts72\n"
1140                                             "CreateFolder\tDirectory_\tComponent_\n"
1141                                             "FIRSTDIR\tOne\n";
1142
1143 static const CHAR cf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1144                                               "s72\tS255\tI2\n"
1145                                               "InstallExecuteSequence\tAction\n"
1146                                               "CostFinalize\t\t1000\n"
1147                                               "ValidateProductID\t\t700\n"
1148                                               "CostInitialize\t\t800\n"
1149                                               "FileCost\t\t900\n"
1150                                               "RemoveFiles\t\t3500\n"
1151                                               "CreateFolders\t\t3700\n"
1152                                               "InstallExecute\t\t3800\n"
1153                                               "TestCreateFolders\t\t3900\n"
1154                                               "InstallFiles\t\t4000\n"
1155                                               "RegisterUser\t\t6000\n"
1156                                               "RegisterProduct\t\t6100\n"
1157                                               "PublishFeatures\t\t6300\n"
1158                                               "PublishProduct\t\t6400\n"
1159                                               "InstallFinalize\t\t6600\n"
1160                                               "InstallInitialize\t\t1500\n"
1161                                               "ProcessComponents\t\t1600\n"
1162                                               "UnpublishFeatures\t\t1800\n"
1163                                               "InstallValidate\t\t1400\n"
1164                                               "LaunchConditions\t\t100\n";
1165
1166 static const CHAR cf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1167                                            "s72\ti2\tS64\tS0\tS255\n"
1168                                            "CustomAction\tAction\n"
1169                                            "TestCreateFolders\t19\t\tHalts installation\t\n";
1170
1171 static const CHAR rf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1172                                               "s72\tS255\tI2\n"
1173                                               "InstallExecuteSequence\tAction\n"
1174                                               "CostFinalize\t\t1000\n"
1175                                               "ValidateProductID\t\t700\n"
1176                                               "CostInitialize\t\t800\n"
1177                                               "FileCost\t\t900\n"
1178                                               "RemoveFiles\t\t3500\n"
1179                                               "CreateFolders\t\t3600\n"
1180                                               "RemoveFolders\t\t3700\n"
1181                                               "InstallExecute\t\t3800\n"
1182                                               "TestCreateFolders\t\t3900\n"
1183                                               "InstallFiles\t\t4000\n"
1184                                               "RegisterUser\t\t6000\n"
1185                                               "RegisterProduct\t\t6100\n"
1186                                               "PublishFeatures\t\t6300\n"
1187                                               "PublishProduct\t\t6400\n"
1188                                               "InstallFinalize\t\t6600\n"
1189                                               "InstallInitialize\t\t1500\n"
1190                                               "ProcessComponents\t\t1600\n"
1191                                               "UnpublishFeatures\t\t1800\n"
1192                                               "InstallValidate\t\t1400\n"
1193                                               "LaunchConditions\t\t100\n";
1194
1195
1196 static const CHAR sr_selfreg_dat[] = "File_\tCost\n"
1197                                      "s72\tI2\n"
1198                                      "SelfReg\tFile_\n"
1199                                      "one.txt\t1\n";
1200
1201 static const CHAR sr_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1202                                               "s72\tS255\tI2\n"
1203                                               "InstallExecuteSequence\tAction\n"
1204                                               "CostFinalize\t\t1000\n"
1205                                               "CostInitialize\t\t800\n"
1206                                               "FileCost\t\t900\n"
1207                                               "ResolveSource\t\t950\n"
1208                                               "MoveFiles\t\t1700\n"
1209                                               "SelfUnregModules\t\t3900\n"
1210                                               "InstallFiles\t\t4000\n"
1211                                               "DuplicateFiles\t\t4500\n"
1212                                               "WriteEnvironmentStrings\t\t4550\n"
1213                                               "CreateShortcuts\t\t4600\n"
1214                                               "InstallFinalize\t\t6600\n"
1215                                               "InstallInitialize\t\t1500\n"
1216                                               "InstallValidate\t\t1400\n"
1217                                               "LaunchConditions\t\t100\n";
1218
1219 static const CHAR font_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
1220                                      "i2\ti4\tL64\tS255\tS32\tS72\n"
1221                                      "Media\tDiskId\n"
1222                                      "1\t3\t\t\tDISK1\t\n";
1223
1224 static const CHAR font_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1225                                     "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1226                                     "File\tFile\n"
1227                                     "font.ttf\tfonts\tfont.ttf\t1000\t\t\t8192\t1\n";
1228
1229 static const CHAR font_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1230                                        "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1231                                        "Feature\tFeature\n"
1232                                        "fonts\t\t\tfont feature\t1\t2\tMSITESTDIR\t0\n";
1233
1234 static const CHAR font_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1235                                          "s72\tS38\ts72\ti2\tS255\tS72\n"
1236                                          "Component\tComponent\n"
1237                                          "fonts\t{F5920ED0-1183-4B8F-9330-86CE56557C05}\tMSITESTDIR\t0\t\tfont.ttf\n";
1238
1239 static const CHAR font_feature_comp_dat[] = "Feature_\tComponent_\n"
1240                                             "s38\ts72\n"
1241                                             "FeatureComponents\tFeature_\tComponent_\n"
1242                                             "fonts\tfonts\n";
1243
1244 static const CHAR font_dat[] = "File_\tFontTitle\n"
1245                                "s72\tS128\n"
1246                                "Font\tFile_\n"
1247                                "font.ttf\tmsi test font\n";
1248
1249 static const CHAR font_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1250                                                 "s72\tS255\tI2\n"
1251                                                 "InstallExecuteSequence\tAction\n"
1252                                                 "ValidateProductID\t\t700\n"
1253                                                 "CostInitialize\t\t800\n"
1254                                                 "FileCost\t\t900\n"
1255                                                 "CostFinalize\t\t1000\n"
1256                                                 "InstallValidate\t\t1400\n"
1257                                                 "InstallInitialize\t\t1500\n"
1258                                                 "ProcessComponents\t\t1600\n"
1259                                                 "UnpublishFeatures\t\t1800\n"
1260                                                 "RemoveFiles\t\t3500\n"
1261                                                 "InstallFiles\t\t4000\n"
1262                                                 "RegisterFonts\t\t4100\n"
1263                                                 "UnregisterFonts\t\t4200\n"
1264                                                 "RegisterUser\t\t6000\n"
1265                                                 "RegisterProduct\t\t6100\n"
1266                                                 "PublishFeatures\t\t6300\n"
1267                                                 "PublishProduct\t\t6400\n"
1268                                                 "InstallFinalize\t\t6600";
1269
1270 static const CHAR vp_property_dat[] = "Property\tValue\n"
1271                                       "s72\tl0\n"
1272                                       "Property\tProperty\n"
1273                                       "HASUIRUN\t0\n"
1274                                       "INSTALLLEVEL\t3\n"
1275                                       "InstallMode\tTypical\n"
1276                                       "Manufacturer\tWine\n"
1277                                       "PIDTemplate\t###-#######\n"
1278                                       "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
1279                                       "ProductLanguage\t1033\n"
1280                                       "ProductName\tMSITEST\n"
1281                                       "ProductVersion\t1.1.1\n"
1282                                       "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n";
1283
1284 static const CHAR vp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1285                                            "s72\ti2\tS64\tS0\tS255\n"
1286                                            "CustomAction\tAction\n"
1287                                            "SetProductID1\t51\tProductID\t1\t\n"
1288                                            "SetProductID2\t51\tProductID\t2\t\n"
1289                                            "TestProductID1\t19\t\t\tHalts installation\n"
1290                                            "TestProductID2\t19\t\t\tHalts installation\n";
1291
1292 static const CHAR vp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1293                                               "s72\tS255\tI2\n"
1294                                               "InstallExecuteSequence\tAction\n"
1295                                               "LaunchConditions\t\t100\n"
1296                                               "CostInitialize\t\t800\n"
1297                                               "FileCost\t\t900\n"
1298                                               "CostFinalize\t\t1000\n"
1299                                               "InstallValidate\t\t1400\n"
1300                                               "InstallInitialize\t\t1500\n"
1301                                               "SetProductID1\tSET_PRODUCT_ID=1\t3000\n"
1302                                               "SetProductID2\tSET_PRODUCT_ID=2\t3100\n"
1303                                               "ValidateProductID\t\t3200\n"
1304                                               "InstallExecute\t\t3300\n"
1305                                               "TestProductID1\tProductID=1\t3400\n"
1306                                               "TestProductID2\tProductID=\"123-1234567\"\t3500\n"
1307                                               "InstallFiles\t\t4000\n"
1308                                               "InstallFinalize\t\t6000\n";
1309
1310 static const CHAR odbc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1311                                     "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1312                                     "File\tFile\n"
1313                                     "ODBCdriver.dll\todbc\tODBCdriver.dll\t1000\t\t\t8192\t1\n"
1314                                     "ODBCdriver2.dll\todbc\tODBCdriver2.dll\t1000\t\t\t8192\t2\n"
1315                                     "ODBCtranslator.dll\todbc\tODBCtranslator.dll\t1000\t\t\t8192\t3\n"
1316                                     "ODBCtranslator2.dll\todbc\tODBCtranslator2.dll\t1000\t\t\t8192\t4\n"
1317                                     "ODBCsetup.dll\todbc\tODBCsetup.dll\t1000\t\t\t8192\t5\n";
1318
1319 static const CHAR odbc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1320                                        "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1321                                        "Feature\tFeature\n"
1322                                        "odbc\t\t\todbc feature\t1\t2\tMSITESTDIR\t0\n";
1323
1324 static const CHAR odbc_feature_comp_dat[] = "Feature_\tComponent_\n"
1325                                             "s38\ts72\n"
1326                                             "FeatureComponents\tFeature_\tComponent_\n"
1327                                             "odbc\todbc\n";
1328
1329 static const CHAR odbc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1330                                          "s72\tS38\ts72\ti2\tS255\tS72\n"
1331                                          "Component\tComponent\n"
1332                                          "odbc\t{B6F3E4AE-35D1-4B72-9044-989F03E20A43}\tMSITESTDIR\t0\t\tODBCdriver.dll\n";
1333
1334 static const CHAR odbc_driver_dat[] = "Driver\tComponent_\tDescription\tFile_\tFile_Setup\n"
1335                                       "s72\ts72\ts255\ts72\tS72\n"
1336                                       "ODBCDriver\tDriver\n"
1337                                       "ODBC test driver\todbc\tODBC test driver\tODBCdriver.dll\t\n"
1338                                       "ODBC test driver2\todbc\tODBC test driver2\tODBCdriver2.dll\tODBCsetup.dll\n";
1339
1340 static const CHAR odbc_translator_dat[] = "Translator\tComponent_\tDescription\tFile_\tFile_Setup\n"
1341                                           "s72\ts72\ts255\ts72\tS72\n"
1342                                           "ODBCTranslator\tTranslator\n"
1343                                           "ODBC test translator\todbc\tODBC test translator\tODBCtranslator.dll\t\n"
1344                                           "ODBC test translator2\todbc\tODBC test translator2\tODBCtranslator2.dll\tODBCsetup.dll\n";
1345
1346 static const CHAR odbc_datasource_dat[] = "DataSource\tComponent_\tDescription\tDriverDescription\tRegistration\n"
1347                                           "s72\ts72\ts255\ts255\ti2\n"
1348                                           "ODBCDataSource\tDataSource\n"
1349                                           "ODBC data source\todbc\tODBC data source\tODBC driver\t0\n";
1350
1351 static const CHAR odbc_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1352                                                 "s72\tS255\tI2\n"
1353                                                 "InstallExecuteSequence\tAction\n"
1354                                                 "LaunchConditions\t\t100\n"
1355                                                 "CostInitialize\t\t800\n"
1356                                                 "FileCost\t\t900\n"
1357                                                 "CostFinalize\t\t1000\n"
1358                                                 "InstallValidate\t\t1400\n"
1359                                                 "InstallInitialize\t\t1500\n"
1360                                                 "ProcessComponents\t\t1600\n"
1361                                                 "InstallODBC\t\t3000\n"
1362                                                 "RemoveODBC\t\t3100\n"
1363                                                 "RemoveFiles\t\t3900\n"
1364                                                 "InstallFiles\t\t4000\n"
1365                                                 "RegisterProduct\t\t5000\n"
1366                                                 "PublishFeatures\t\t5100\n"
1367                                                 "PublishProduct\t\t5200\n"
1368                                                 "InstallFinalize\t\t6000\n";
1369
1370 static const CHAR odbc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
1371                                      "i2\ti4\tL64\tS255\tS32\tS72\n"
1372                                      "Media\tDiskId\n"
1373                                      "1\t5\t\t\tDISK1\t\n";
1374
1375 static const CHAR tl_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1376                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1377                                   "File\tFile\n"
1378                                   "typelib.dll\ttypelib\ttypelib.dll\t1000\t\t\t8192\t1\n";
1379
1380 static const CHAR tl_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1381                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1382                                      "Feature\tFeature\n"
1383                                      "typelib\t\t\ttypelib feature\t1\t2\tMSITESTDIR\t0\n";
1384
1385 static const CHAR tl_feature_comp_dat[] = "Feature_\tComponent_\n"
1386                                           "s38\ts72\n"
1387                                           "FeatureComponents\tFeature_\tComponent_\n"
1388                                           "typelib\ttypelib\n";
1389
1390 static const CHAR tl_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1391                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
1392                                        "Component\tComponent\n"
1393                                        "typelib\t{BB4C26FD-89D8-4E49-AF1C-DB4DCB5BF1B0}\tMSITESTDIR\t0\t\ttypelib.dll\n";
1394
1395 static const CHAR tl_typelib_dat[] = "LibID\tLanguage\tComponent_\tVersion\tDescription\tDirectory_\tFeature_\tCost\n"
1396                                      "s38\ti2\ts72\tI4\tL128\tS72\ts38\tI4\n"
1397                                      "TypeLib\tLibID\tLanguage\tComponent_\n"
1398                                      "{EAC5166A-9734-4D91-878F-1DD02304C66C}\t0\ttypelib\t1793\t\tMSITESTDIR\ttypelib\t\n";
1399
1400 static const CHAR tl_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1401                                               "s72\tS255\tI2\n"
1402                                               "InstallExecuteSequence\tAction\n"
1403                                               "LaunchConditions\t\t100\n"
1404                                               "CostInitialize\t\t800\n"
1405                                               "FileCost\t\t900\n"
1406                                               "CostFinalize\t\t1000\n"
1407                                               "InstallValidate\t\t1400\n"
1408                                               "InstallInitialize\t\t1500\n"
1409                                               "ProcessComponents\t\t1600\n"
1410                                               "RemoveFiles\t\t1700\n"
1411                                               "InstallFiles\t\t2000\n"
1412                                               "RegisterTypeLibraries\tREGISTER_TYPELIB=1\t3000\n"
1413                                               "UnregisterTypeLibraries\t\t3100\n"
1414                                               "RegisterProduct\t\t5100\n"
1415                                               "PublishFeatures\t\t5200\n"
1416                                               "PublishProduct\t\t5300\n"
1417                                               "InstallFinalize\t\t6000\n";
1418
1419 static const CHAR crs_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1420                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1421                                    "File\tFile\n"
1422                                    "target.txt\tshortcut\ttarget.txt\t1000\t\t\t8192\t1\n";
1423
1424 static const CHAR crs_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1425                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1426                                       "Feature\tFeature\n"
1427                                       "shortcut\t\t\tshortcut feature\t1\t2\tMSITESTDIR\t0\n";
1428
1429 static const CHAR crs_feature_comp_dat[] = "Feature_\tComponent_\n"
1430                                            "s38\ts72\n"
1431                                            "FeatureComponents\tFeature_\tComponent_\n"
1432                                            "shortcut\tshortcut\n";
1433
1434 static const CHAR crs_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1435                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1436                                         "Component\tComponent\n"
1437                                         "shortcut\t{5D20E3C6-7206-498F-AC28-87AF2F9AD4CC}\tMSITESTDIR\t0\t\ttarget.txt\n";
1438
1439 static const CHAR crs_shortcut_dat[] = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n"
1440                                        "s72\ts72\tl128\ts72\ts72\tL255\tL255\tI2\tS72\tI2\tI2\tS72\n"
1441                                        "Shortcut\tShortcut\n"
1442                                        "shortcut\tMSITESTDIR\tshortcut\tshortcut\t[MSITESTDIR]target.txt\t\t\t\t\t\t\t\n";
1443
1444 static const CHAR crs_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1445                                                "s72\tS255\tI2\n"
1446                                                "InstallExecuteSequence\tAction\n"
1447                                                "LaunchConditions\t\t100\n"
1448                                                "CostInitialize\t\t800\n"
1449                                                "FileCost\t\t900\n"
1450                                                "CostFinalize\t\t1000\n"
1451                                                "InstallValidate\t\t1400\n"
1452                                                "InstallInitialize\t\t1500\n"
1453                                                "ProcessComponents\t\t1600\n"
1454                                                "RemoveFiles\t\t1700\n"
1455                                                "InstallFiles\t\t2000\n"
1456                                                "RemoveShortcuts\t\t3000\n"
1457                                                "CreateShortcuts\t\t3100\n"
1458                                                "RegisterProduct\t\t5000\n"
1459                                                "PublishFeatures\t\t5100\n"
1460                                                "PublishProduct\t\t5200\n"
1461                                                "InstallFinalize\t\t6000\n";
1462
1463 static const CHAR fo_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1464                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1465                                   "File\tFile\n"
1466                                   "override.txt\toverride\toverride.txt\t1000\t\t\t8192\t1\n"
1467                                   "preselected.txt\tpreselected\tpreselected.txt\t1000\t\t\t8192\t2\n"
1468                                   "notpreselected.txt\tnotpreselected\tnotpreselected.txt\t1000\t\t\t8192\t3\n";
1469
1470 static const CHAR fo_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1471                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1472                                      "Feature\tFeature\n"
1473                                      "override\t\t\toverride feature\t1\t1\tMSITESTDIR\t0\n"
1474                                      "preselected\t\t\tpreselected feature\t1\t1\tMSITESTDIR\t0\n"
1475                                      "notpreselected\t\t\tnotpreselected feature\t1\t1\tMSITESTDIR\t0\n";
1476
1477 static const CHAR fo_condition_dat[] = "Feature_\tLevel\tCondition\n"
1478                                        "s38\ti2\tS255\n"
1479                                        "Condition\tFeature_\tLevel\n"
1480                                        "preselected\t0\tPreselected\n"
1481                                        "notpreselected\t0\tNOT Preselected\n";
1482
1483 static const CHAR fo_feature_comp_dat[] = "Feature_\tComponent_\n"
1484                                           "s38\ts72\n"
1485                                           "FeatureComponents\tFeature_\tComponent_\n"
1486                                           "override\toverride\n"
1487                                           "preselected\tpreselected\n"
1488                                           "notpreselected\tnotpreselected\n";
1489
1490 static const CHAR fo_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1491                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
1492                                        "Component\tComponent\n"
1493                                        "override\t{0A00FB1D-97B0-4B42-ADF0-BB8913416623}\tMSITESTDIR\t0\t\toverride.txt\n"
1494                                        "preselected\t{44E1DB75-605A-43DD-8CF5-CAB17F1BBD60}\tMSITESTDIR\t0\t\tpreselected.txt\n"
1495                                        "notpreselected\t{E1647733-5E75-400A-A92E-5E60B4D4EF9F}\tMSITESTDIR\t0\t\tnotpreselected.txt\n";
1496
1497 static const CHAR fo_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1498                                            "s72\ti2\tS64\tS0\tS255\n"
1499                                            "CustomAction\tAction\n"
1500                                            "SetPreselected\t51\tPreselected\t1\t\n";
1501
1502 static const CHAR fo_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1503                                               "s72\tS255\tI2\n"
1504                                               "InstallExecuteSequence\tAction\n"
1505                                               "LaunchConditions\t\t100\n"
1506                                               "SetPreselected\tpreselect=1\t200\n"
1507                                               "CostInitialize\t\t800\n"
1508                                               "FileCost\t\t900\n"
1509                                               "CostFinalize\t\t1000\n"
1510                                               "InstallValidate\t\t1400\n"
1511                                               "InstallInitialize\t\t1500\n"
1512                                               "ProcessComponents\t\t1600\n"
1513                                               "RemoveFiles\t\t1700\n"
1514                                               "InstallFiles\t\t2000\n"
1515                                               "RegisterProduct\t\t5000\n"
1516                                               "PublishFeatures\t\t5100\n"
1517                                               "PublishProduct\t\t5200\n"
1518                                               "InstallFinalize\t\t6000\n";
1519
1520 static const CHAR pub_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1521                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1522                                    "File\tFile\n"
1523                                    "english.txt\tpublish\tenglish.txt\t1000\t\t\t8192\t1\n";
1524
1525 static const CHAR pub_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1526                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1527                                       "Feature\tFeature\n"
1528                                       "publish\t\t\tpublish feature\t1\t2\tMSITESTDIR\t0\n";
1529
1530 static const CHAR pub_feature_comp_dat[] = "Feature_\tComponent_\n"
1531                                            "s38\ts72\n"
1532                                            "FeatureComponents\tFeature_\tComponent_\n"
1533                                            "publish\tpublish\n";
1534
1535 static const CHAR pub_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1536                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1537                                         "Component\tComponent\n"
1538                                         "publish\t{B4EA0ACF-6238-426E-9C6D-7869F0F9C768}\tMSITESTDIR\t0\t\tenglish.txt\n";
1539
1540 static const CHAR pub_publish_component_dat[] = "ComponentId\tQualifier\tComponent_\tAppData\tFeature_\n"
1541                                                 "s38\ts255\ts72\tL255\ts38\n"
1542                                                 "PublishComponent\tComponentId\tQualifier\tComponent_\n"
1543                                                 "{92AFCBC0-9CA6-4270-8454-47C5EE2B8FAA}\tenglish.txt\tpublish\t\tpublish\n";
1544
1545 static const CHAR pub_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1546                                                "s72\tS255\tI2\n"
1547                                                "InstallExecuteSequence\tAction\n"
1548                                                "LaunchConditions\t\t100\n"
1549                                                "CostInitialize\t\t800\n"
1550                                                "FileCost\t\t900\n"
1551                                                "CostFinalize\t\t1000\n"
1552                                                "InstallValidate\t\t1400\n"
1553                                                "InstallInitialize\t\t1500\n"
1554                                                "ProcessComponents\t\t1600\n"
1555                                                "RemoveFiles\t\t1700\n"
1556                                                "InstallFiles\t\t2000\n"
1557                                                "PublishComponents\t\t3000\n"
1558                                                "UnpublishComponents\t\t3100\n"
1559                                                "RegisterProduct\t\t5000\n"
1560                                                "PublishFeatures\t\t5100\n"
1561                                                "PublishProduct\t\t5200\n"
1562                                                "InstallFinalize\t\t6000\n";
1563
1564 static const CHAR rd_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1565                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1566                                   "File\tFile\n"
1567                                   "original.txt\tduplicate\toriginal.txt\t1000\t\t\t8192\t1\n"
1568                                   "original2.txt\tduplicate\toriginal2.txt\t1000\t\t\t8192\t2\n"
1569                                   "original3.txt\tduplicate2\toriginal3.txt\t1000\t\t\t8192\t3\n";
1570
1571 static const CHAR rd_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1572                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1573                                      "Feature\tFeature\n"
1574                                      "duplicate\t\t\tduplicate feature\t1\t2\tMSITESTDIR\t0\n";
1575
1576 static const CHAR rd_feature_comp_dat[] = "Feature_\tComponent_\n"
1577                                           "s38\ts72\n"
1578                                           "FeatureComponents\tFeature_\tComponent_\n"
1579                                           "duplicate\tduplicate\n";
1580
1581 static const CHAR rd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1582                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
1583                                        "Component\tComponent\n"
1584                                        "duplicate\t{EB45D06A-ADFE-44E3-8D41-B7DE150E41AD}\tMSITESTDIR\t0\t\toriginal.txt\n"
1585                                        "duplicate2\t{B8BA60E0-B2E9-488E-9D0E-E60F25F04F97}\tMSITESTDIR\t0\tDUPLICATE2=1\toriginal3.txt\n";
1586
1587 static const CHAR rd_duplicate_file_dat[] = "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
1588                                             "s72\ts72\ts72\tS255\tS72\n"
1589                                             "DuplicateFile\tFileKey\n"
1590                                             "duplicate\tduplicate\toriginal.txt\tduplicate.txt\t\n"
1591                                             "duplicate2\tduplicate\toriginal2.txt\t\tMSITESTDIR\n"
1592                                             "duplicate3\tduplicate2\toriginal3.txt\tduplicate2.txt\t\n";
1593
1594 static const CHAR rd_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1595                                               "s72\tS255\tI2\n"
1596                                               "InstallExecuteSequence\tAction\n"
1597                                               "LaunchConditions\t\t100\n"
1598                                               "CostInitialize\t\t800\n"
1599                                               "FileCost\t\t900\n"
1600                                               "CostFinalize\t\t1000\n"
1601                                               "InstallValidate\t\t1400\n"
1602                                               "InstallInitialize\t\t1500\n"
1603                                               "ProcessComponents\t\t1600\n"
1604                                               "RemoveDuplicateFiles\t\t1900\n"
1605                                               "InstallFiles\t\t2000\n"
1606                                               "DuplicateFiles\t\t2100\n"
1607                                               "RegisterProduct\t\t5000\n"
1608                                               "PublishFeatures\t\t5100\n"
1609                                               "PublishProduct\t\t5200\n"
1610                                               "InstallFinalize\t\t6000\n";
1611
1612 static const CHAR rrv_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1613                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1614                                    "File\tFile\n"
1615                                    "registry.txt\tregistry\tregistry.txt\t1000\t\t\t8192\t1\n";
1616
1617 static const CHAR rrv_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1618                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1619                                       "Feature\tFeature\n"
1620                                       "registry\t\t\tregistry feature\t1\t2\tMSITESTDIR\t0\n";
1621
1622 static const CHAR rrv_feature_comp_dat[] = "Feature_\tComponent_\n"
1623                                            "s38\ts72\n"
1624                                            "FeatureComponents\tFeature_\tComponent_\n"
1625                                            "registry\tregistry\n";
1626
1627 static const CHAR rrv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1628                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1629                                         "Component\tComponent\n"
1630                                         "registry\t{DA97585B-962D-45EB-AD32-DA15E60CA9EE}\tMSITESTDIR\t0\t\tregistry.txt\n";
1631
1632 static const CHAR rrv_registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
1633                                        "s72\ti2\tl255\tL255\tL0\ts72\n"
1634                                        "Registry\tRegistry\n"
1635                                        "reg1\t2\tSOFTWARE\\Wine\\keyA\t\tA\tregistry\n"
1636                                        "reg2\t2\tSOFTWARE\\Wine\\keyA\tvalueA\tA\tregistry\n"
1637                                        "reg3\t2\tSOFTWARE\\Wine\\key1\t-\t\tregistry\n";
1638
1639 static const CHAR rrv_remove_registry_dat[] = "RemoveRegistry\tRoot\tKey\tName\tComponent_\n"
1640                                               "s72\ti2\tl255\tL255\ts72\n"
1641                                               "RemoveRegistry\tRemoveRegistry\n"
1642                                               "reg1\t2\tSOFTWARE\\Wine\\keyB\t\tregistry\n"
1643                                               "reg2\t2\tSOFTWARE\\Wine\\keyB\tValueB\tregistry\n"
1644                                               "reg3\t2\tSOFTWARE\\Wine\\key2\t-\tregistry\n";
1645
1646 static const CHAR rrv_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1647                                                "s72\tS255\tI2\n"
1648                                                "InstallExecuteSequence\tAction\n"
1649                                                "LaunchConditions\t\t100\n"
1650                                                "CostInitialize\t\t800\n"
1651                                                "FileCost\t\t900\n"
1652                                                "CostFinalize\t\t1000\n"
1653                                                "InstallValidate\t\t1400\n"
1654                                                "InstallInitialize\t\t1500\n"
1655                                                "ProcessComponents\t\t1600\n"
1656                                                "RemoveFiles\t\t1700\n"
1657                                                "InstallFiles\t\t2000\n"
1658                                                "RemoveRegistryValues\t\t3000\n"
1659                                                "RegisterProduct\t\t5000\n"
1660                                                "PublishFeatures\t\t5100\n"
1661                                                "PublishProduct\t\t5200\n"
1662                                                "InstallFinalize\t\t6000\n";
1663
1664 static const CHAR frp_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1665                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1666                                    "File\tFile\n"
1667                                    "product.txt\tproduct\tproduct.txt\t1000\t\t\t8192\t1\n";
1668
1669 static const CHAR frp_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1670                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1671                                       "Feature\tFeature\n"
1672                                       "product\t\t\tproduct feature\t1\t2\tMSITESTDIR\t0\n";
1673
1674 static const CHAR frp_feature_comp_dat[] = "Feature_\tComponent_\n"
1675                                            "s38\ts72\n"
1676                                            "FeatureComponents\tFeature_\tComponent_\n"
1677                                            "product\tproduct\n";
1678
1679 static const CHAR frp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1680                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1681                                         "Component\tComponent\n"
1682                                         "product\t{44725EE0-EEA8-40BD-8162-A48224A2FEA1}\tMSITESTDIR\t0\t\tproduct.txt\n";
1683
1684 static const CHAR frp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1685                                             "s72\ti2\tS64\tS0\tS255\n"
1686                                             "CustomAction\tAction\n"
1687                                             "TestProp\t19\t\t\tPROP set\n";
1688
1689 static const CHAR frp_upgrade_dat[] = "UpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\tRemove\tActionProperty\n"
1690                                       "s38\tS20\tS20\tS255\ti4\tS255\ts72\n"
1691                                       "Upgrade\tUpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\n"
1692                                       "{4C0EAA15-0264-4E5A-8758-609EF142B92D}\t1.1.1\t2.2.2\t\t768\t\tPROP\n";
1693
1694 static const CHAR frp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1695                                                "s72\tS255\tI2\n"
1696                                                "InstallExecuteSequence\tAction\n"
1697                                                "FindRelatedProducts\t\t50\n"
1698                                                "TestProp\tPROP AND NOT REMOVE\t51\n"
1699                                                "LaunchConditions\t\t100\n"
1700                                                "CostInitialize\t\t800\n"
1701                                                "FileCost\t\t900\n"
1702                                                "CostFinalize\t\t1000\n"
1703                                                "InstallValidate\t\t1400\n"
1704                                                "InstallInitialize\t\t1500\n"
1705                                                "ProcessComponents\t\t1600\n"
1706                                                "RemoveFiles\t\t1700\n"
1707                                                "InstallFiles\t\t2000\n"
1708                                                "RegisterProduct\t\t5000\n"
1709                                                "PublishFeatures\t\t5100\n"
1710                                                "PublishProduct\t\t5200\n"
1711                                                "InstallFinalize\t\t6000\n";
1712
1713 static const CHAR riv_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1714                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1715                                    "File\tFile\n"
1716                                    "inifile.txt\tinifile\tinifile.txt\t1000\t\t\t8192\t1\n";
1717
1718 static const CHAR riv_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1719                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1720                                       "Feature\tFeature\n"
1721                                       "inifile\t\t\tinifile feature\t1\t2\tMSITESTDIR\t0\n";
1722
1723 static const CHAR riv_feature_comp_dat[] = "Feature_\tComponent_\n"
1724                                            "s38\ts72\n"
1725                                            "FeatureComponents\tFeature_\tComponent_\n"
1726                                            "inifile\tinifile\n";
1727
1728 static const CHAR riv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1729                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1730                                         "Component\tComponent\n"
1731                                         "inifile\t{A0F15705-4F57-4437-88C4-6C8B37ACC6DE}\tMSITESTDIR\t0\t\tinifile.txt\n";
1732
1733 static const CHAR riv_ini_file_dat[] = "IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n"
1734                                        "s72\tl255\tS72\tl96\tl128\tl255\ti2\ts72\n"
1735                                        "IniFile\tIniFile\n"
1736                                        "inifile1\ttest.ini\tMSITESTDIR\tsection1\tkey1\tvalue1\t0\tinifile\n";
1737
1738 static const CHAR riv_remove_ini_file_dat[] = "RemoveIniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n"
1739                                               "s72\tl255\tS72\tl96\tl128\tL255\ti2\ts72\n"
1740                                               "RemoveIniFile\tRemoveIniFile\n"
1741                                               "inifile1\ttest.ini\tMSITESTDIR\tsectionA\tkeyA\tvalueA\t2\tinifile\n";
1742
1743 static const CHAR riv_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1744                                                "s72\tS255\tI2\n"
1745                                                "InstallExecuteSequence\tAction\n"
1746                                                "LaunchConditions\t\t100\n"
1747                                                "CostInitialize\t\t800\n"
1748                                                "FileCost\t\t900\n"
1749                                                "CostFinalize\t\t1000\n"
1750                                                "InstallValidate\t\t1400\n"
1751                                                "InstallInitialize\t\t1500\n"
1752                                                "ProcessComponents\t\t1600\n"
1753                                                "RemoveFiles\t\t1700\n"
1754                                                "InstallFiles\t\t2000\n"
1755                                                "RemoveIniValues\t\t3000\n"
1756                                                "RegisterProduct\t\t5000\n"
1757                                                "PublishFeatures\t\t5100\n"
1758                                                "PublishProduct\t\t5200\n"
1759                                                "InstallFinalize\t\t6000\n";
1760
1761 static const CHAR res_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1762                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1763                                    "File\tFile\n"
1764                                    "envvar.txt\tenvvar\tenvvar.txt\t1000\t\t\t8192\t1\n";
1765
1766 static const CHAR res_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1767                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1768                                       "Feature\tFeature\n"
1769                                       "envvar\t\t\tenvvar feature\t1\t2\tMSITESTDIR\t0\n";
1770
1771 static const CHAR res_feature_comp_dat[] = "Feature_\tComponent_\n"
1772                                            "s38\ts72\n"
1773                                            "FeatureComponents\tFeature_\tComponent_\n"
1774                                            "envvar\tenvvar\n";
1775
1776 static const CHAR res_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1777                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1778                                         "Component\tComponent\n"
1779                                         "envvar\t{45EE9AF4-E5D1-445F-8BB7-B22D4EEBD29E}\tMSITESTDIR\t0\t\tenvvar.txt\n";
1780
1781 static const CHAR res_environment_dat[] = "Environment\tName\tValue\tComponent_\n"
1782                                           "s72\tl255\tL255\ts72\n"
1783                                           "Environment\tEnvironment\n"
1784                                           "var1\t=-MSITESTVAR1\t1\tenvvar\n"
1785                                           "var2\t=+-MSITESTVAR2\t1\tenvvar\n"
1786                                           "var3\t=MSITESTVAR3\t1\tenvvar\n"
1787                                           "var4\t=-MSITESTVAR4\t\tenvvar\n"
1788                                           "var5\t=MSITESTVAR5\t\tenvvar\n";
1789
1790 static const CHAR res_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1791                                                "s72\tS255\tI2\n"
1792                                                "InstallExecuteSequence\tAction\n"
1793                                                "LaunchConditions\t\t100\n"
1794                                                "CostInitialize\t\t800\n"
1795                                                "FileCost\t\t900\n"
1796                                                "CostFinalize\t\t1000\n"
1797                                                "InstallValidate\t\t1400\n"
1798                                                "InstallInitialize\t\t1500\n"
1799                                                "ProcessComponents\t\t1600\n"
1800                                                "RemoveFiles\t\t1700\n"
1801                                                "InstallFiles\t\t2000\n"
1802                                                "RemoveEnvironmentStrings\t\t3000\n"
1803                                                "RegisterProduct\t\t5000\n"
1804                                                "PublishFeatures\t\t5100\n"
1805                                                "PublishProduct\t\t5200\n"
1806                                                "InstallFinalize\t\t6000\n";
1807
1808 static const CHAR rci_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1809                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1810                                    "File\tFile\n"
1811                                    "class.txt\tclass\tclass.txt\t1000\t\t\t8192\t1\n";
1812
1813 static const CHAR rci_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1814                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1815                                       "Feature\tFeature\n"
1816                                       "class\t\t\tclass feature\t1\t2\tMSITESTDIR\t0\n";
1817
1818 static const CHAR rci_feature_comp_dat[] = "Feature_\tComponent_\n"
1819                                            "s38\ts72\n"
1820                                            "FeatureComponents\tFeature_\tComponent_\n"
1821                                            "class\tclass\n";
1822
1823 static const CHAR rci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1824                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1825                                         "Component\tComponent\n"
1826                                         "class\t{89A98345-F8A1-422E-A48B-0250B5809F2D}\tMSITESTDIR\t0\t\tclass.txt\n";
1827
1828 static const CHAR rci_appid_dat[] = "AppId\tRemoteServerName\tLocalService\tServiceParameters\tDllSurrogate\tActivateAtStorage\tRunAsInteractiveUser\n"
1829                                     "s38\tS255\tS255\tS255\tS255\tI2\tI2\n"
1830                                     "AppId\tAppId\n"
1831                                     "{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\t\t\t\t\t\t\n";
1832
1833 static const CHAR rci_class_dat[] = "CLSID\tContext\tComponent_\tProgId_Default\tDescription\tAppId_\tFileTypeMask\tIcon_\tIconIndex\tDefInprocHandler\tArgument\tFeature_\tAttributes\n"
1834                                     "s38\ts32\ts72\tS255\tL255\tS38\tS255\tS72\tI2\tS32\tS255\ts38\tI2\n"
1835                                     "Class\tCLSID\tContext\tComponent_\n"
1836                                     "{110913E7-86D1-4BF3-9922-BA103FCDDDFA}\tLocalServer\tclass\t\tdescription\t{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\tmask1;mask2\t\t\t2\t\tclass\t\n";
1837
1838 static const CHAR rci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1839                                                "s72\tS255\tI2\n"
1840                                                "InstallExecuteSequence\tAction\n"
1841                                                "LaunchConditions\t\t100\n"
1842                                                "CostInitialize\t\t800\n"
1843                                                "FileCost\t\t900\n"
1844                                                "CostFinalize\t\t1000\n"
1845                                                "InstallValidate\t\t1400\n"
1846                                                "InstallInitialize\t\t1500\n"
1847                                                "ProcessComponents\t\t1600\n"
1848                                                "RemoveFiles\t\t1700\n"
1849                                                "InstallFiles\t\t2000\n"
1850                                                "UnregisterClassInfo\t\t3000\n"
1851                                                "RegisterClassInfo\t\t4000\n"
1852                                                "RegisterProduct\t\t5000\n"
1853                                                "PublishFeatures\t\t5100\n"
1854                                                "PublishProduct\t\t5200\n"
1855                                                "InstallFinalize\t\t6000\n";
1856
1857 static const CHAR rei_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1858                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1859                                    "File\tFile\n"
1860                                    "extension.txt\textension\textension.txt\t1000\t\t\t8192\t1\n";
1861
1862 static const CHAR rei_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1863                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1864                                       "Feature\tFeature\n"
1865                                       "extension\t\t\textension feature\t1\t2\tMSITESTDIR\t0\n";
1866
1867 static const CHAR rei_feature_comp_dat[] = "Feature_\tComponent_\n"
1868                                            "s38\ts72\n"
1869                                            "FeatureComponents\tFeature_\tComponent_\n"
1870                                            "extension\textension\n";
1871
1872 static const CHAR rei_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1873                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1874                                         "Component\tComponent\n"
1875                                         "extension\t{9A3060D4-60BA-4A82-AB55-9FB148AD013C}\tMSITESTDIR\t0\t\textension.txt\n";
1876
1877 static const CHAR rei_extension_dat[] = "Extension\tComponent_\tProgId_\tMIME_\tFeature_\n"
1878                                         "s255\ts72\tS255\tS64\ts38\n"
1879                                         "Extension\tExtension\tComponent_\n"
1880                                         "extension\textension\tProg.Id.1\t\textension\n";
1881
1882 static const CHAR rei_verb_dat[] = "Extension_\tVerb\tSequence\tCommand\tArgument\n"
1883                                    "s255\ts32\tI2\tL255\tL255\n"
1884                                    "Verb\tExtension_\tVerb\n"
1885                                    "extension\tOpen\t1\t&Open\t/argument\n";
1886
1887 static const CHAR rei_progid_dat[] = "ProgId\tProgId_Parent\tClass_\tDescription\tIcon_\tIconIndex\n"
1888                                      "s255\tS255\tS38\tL255\tS72\tI2\n"
1889                                      "ProgId\tProgId\n"
1890                                      "Prog.Id.1\t\t\tdescription\t\t\n";
1891
1892 static const CHAR rei_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1893                                                "s72\tS255\tI2\n"
1894                                                "InstallExecuteSequence\tAction\n"
1895                                                "LaunchConditions\t\t100\n"
1896                                                "CostInitialize\t\t800\n"
1897                                                "FileCost\t\t900\n"
1898                                                "CostFinalize\t\t1000\n"
1899                                                "InstallValidate\t\t1400\n"
1900                                                "InstallInitialize\t\t1500\n"
1901                                                "ProcessComponents\t\t1600\n"
1902                                                "RemoveFiles\t\t1700\n"
1903                                                "InstallFiles\t\t2000\n"
1904                                                "UnregisterExtensionInfo\t\t3000\n"
1905                                                "RegisterExtensionInfo\t\t4000\n"
1906                                                "RegisterProduct\t\t5000\n"
1907                                                "PublishFeatures\t\t5100\n"
1908                                                "PublishProduct\t\t5200\n"
1909                                                "InstallFinalize\t\t6000\n";
1910
1911 static const CHAR rmi_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1912                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1913                                    "File\tFile\n"
1914                                    "mime.txt\tmime\tmime.txt\t1000\t\t\t8192\t1\n";
1915
1916 static const CHAR rmi_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1917                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1918                                       "Feature\tFeature\n"
1919                                       "mime\t\t\tmime feature\t1\t2\tMSITESTDIR\t0\n";
1920
1921 static const CHAR rmi_feature_comp_dat[] = "Feature_\tComponent_\n"
1922                                            "s38\ts72\n"
1923                                            "FeatureComponents\tFeature_\tComponent_\n"
1924                                            "mime\tmime\n";
1925
1926 static const CHAR rmi_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1927                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1928                                         "Component\tComponent\n"
1929                                         "mime\t{A1D630CE-13A7-4882-AFDD-148E2BBAFC6D}\tMSITESTDIR\t0\t\tmime.txt\n";
1930
1931 static const CHAR rmi_extension_dat[] = "Extension\tComponent_\tProgId_\tMIME_\tFeature_\n"
1932                                         "s255\ts72\tS255\tS64\ts38\n"
1933                                         "Extension\tExtension\tComponent_\n"
1934                                         "mime\tmime\t\tmime/type\tmime\n";
1935
1936 static const CHAR rmi_verb_dat[] = "Extension_\tVerb\tSequence\tCommand\tArgument\n"
1937                                    "s255\ts32\tI2\tL255\tL255\n"
1938                                    "Verb\tExtension_\tVerb\n"
1939                                    "mime\tOpen\t1\t&Open\t/argument\n";
1940
1941 static const CHAR rmi_mime_dat[] = "ContentType\tExtension_\tCLSID\n"
1942                                    "s64\ts255\tS38\n"
1943                                    "MIME\tContentType\n"
1944                                    "mime/type\tmime\t\n";
1945
1946 static const CHAR rmi_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1947                                                "s72\tS255\tI2\n"
1948                                                "InstallExecuteSequence\tAction\n"
1949                                                "LaunchConditions\t\t100\n"
1950                                                "CostInitialize\t\t800\n"
1951                                                "FileCost\t\t900\n"
1952                                                "CostFinalize\t\t1000\n"
1953                                                "InstallValidate\t\t1400\n"
1954                                                "InstallInitialize\t\t1500\n"
1955                                                "ProcessComponents\t\t1600\n"
1956                                                "RemoveFiles\t\t1700\n"
1957                                                "InstallFiles\t\t2000\n"
1958                                                "UnregisterExtensionInfo\t\t3000\n"
1959                                                "UnregisterMIMEInfo\t\t3500\n"
1960                                                "RegisterExtensionInfo\t\t4000\n"
1961                                                "RegisterMIMEInfo\t\t4500\n"
1962                                                "RegisterProduct\t\t5000\n"
1963                                                "PublishFeatures\t\t5100\n"
1964                                                "PublishProduct\t\t5200\n"
1965                                                "InstallFinalize\t\t6000\n";
1966
1967 static const CHAR sd_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1968                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1969                                   "File\tFile\n"
1970                                   "sourcedir.txt\tsourcedir\tsourcedir.txt\t1000\t\t\t8192\t1\n";
1971
1972 static const CHAR sd_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1973                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1974                                      "Feature\tFeature\n"
1975                                      "sourcedir\t\t\tsourcedir feature\t1\t2\tMSITESTDIR\t0\n";
1976
1977 static const CHAR sd_feature_comp_dat[] = "Feature_\tComponent_\n"
1978                                           "s38\ts72\n"
1979                                           "FeatureComponents\tFeature_\tComponent_\n"
1980                                           "sourcedir\tsourcedir\n";
1981
1982 static const CHAR sd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1983                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
1984                                        "Component\tComponent\n"
1985                                        "sourcedir\t{DD422F92-3ED8-49B5-A0B7-F266F98357DF}\tMSITESTDIR\t0\t\tsourcedir.txt\n";
1986
1987 static const CHAR sd_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
1988                                             "s72\tS255\tI2\n"
1989                                             "InstallUISequence\tAction\n"
1990                                             "TestSourceDirProp1\tnot SourceDir and not SOURCEDIR and not Installed\t99\n"
1991                                             "AppSearch\t\t100\n"
1992                                             "TestSourceDirProp2\tnot SourceDir and not SOURCEDIR and not Installed\t101\n"
1993                                             "LaunchConditions\tnot Installed \t110\n"
1994                                             "TestSourceDirProp3\tnot SourceDir and not SOURCEDIR and not Installed\t111\n"
1995                                             "FindRelatedProducts\t\t120\n"
1996                                             "TestSourceDirProp4\tnot SourceDir and not SOURCEDIR and not Installed\t121\n"
1997                                             "CCPSearch\t\t130\n"
1998                                             "TestSourceDirProp5\tnot SourceDir and not SOURCEDIR and not Installed\t131\n"
1999                                             "RMCCPSearch\t\t140\n"
2000                                             "TestSourceDirProp6\tnot SourceDir and not SOURCEDIR and not Installed\t141\n"
2001                                             "ValidateProductID\t\t150\n"
2002                                             "TestSourceDirProp7\tnot SourceDir and not SOURCEDIR and not Installed\t151\n"
2003                                             "CostInitialize\t\t800\n"
2004                                             "TestSourceDirProp8\tnot SourceDir and not SOURCEDIR and not Installed\t801\n"
2005                                             "FileCost\t\t900\n"
2006                                             "TestSourceDirProp9\tnot SourceDir and not SOURCEDIR and not Installed\t901\n"
2007                                             "IsolateComponents\t\t1000\n"
2008                                             "TestSourceDirProp10\tnot SourceDir and not SOURCEDIR and not Installed\t1001\n"
2009                                             "CostFinalize\t\t1100\n"
2010                                             "TestSourceDirProp11\tnot SourceDir and not SOURCEDIR and not Installed\t1101\n"
2011                                             "MigrateFeatureStates\t\t1200\n"
2012                                             "TestSourceDirProp12\tnot SourceDir and not SOURCEDIR and not Installed\t1201\n"
2013                                             "ExecuteAction\t\t1300\n"
2014                                             "TestSourceDirProp13\tnot SourceDir and not SOURCEDIR and not Installed\t1301\n";
2015
2016 static const CHAR sd_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
2017                                               "s72\tS255\tI2\n"
2018                                               "InstallExecuteSequence\tAction\n"
2019                                               "TestSourceDirProp14\tSourceDir and SOURCEDIR and not Installed\t99\n"
2020                                               "LaunchConditions\t\t100\n"
2021                                               "TestSourceDirProp15\tSourceDir and SOURCEDIR and not Installed\t101\n"
2022                                               "ValidateProductID\t\t700\n"
2023                                               "TestSourceDirProp16\tSourceDir and SOURCEDIR and not Installed\t701\n"
2024                                               "CostInitialize\t\t800\n"
2025                                               "TestSourceDirProp17\tSourceDir and SOURCEDIR and not Installed\t801\n"
2026                                               "ResolveSource\tResolveSource and not Installed\t850\n"
2027                                               "TestSourceDirProp18\tResolveSource and not SourceDir and not SOURCEDIR and not Installed\t851\n"
2028                                               "TestSourceDirProp19\tnot ResolveSource and SourceDir and SOURCEDIR and not Installed\t852\n"
2029                                               "FileCost\t\t900\n"
2030                                               "TestSourceDirProp20\tSourceDir and SOURCEDIR and not Installed\t901\n"
2031                                               "IsolateComponents\t\t1000\n"
2032                                               "TestSourceDirProp21\tSourceDir and SOURCEDIR and not Installed\t1001\n"
2033                                               "CostFinalize\t\t1100\n"
2034                                               "TestSourceDirProp22\tSourceDir and SOURCEDIR and not Installed\t1101\n"
2035                                               "MigrateFeatureStates\t\t1200\n"
2036                                               "TestSourceDirProp23\tSourceDir and SOURCEDIR and not Installed\t1201\n"
2037                                               "InstallValidate\t\t1400\n"
2038                                               "TestSourceDirProp24\tSourceDir and SOURCEDIR and not Installed\t1401\n"
2039                                               "InstallInitialize\t\t1500\n"
2040                                               "TestSourceDirProp25\tSourceDir and SOURCEDIR and not Installed\t1501\n"
2041                                               "ProcessComponents\t\t1600\n"
2042                                               "TestSourceDirProp26\tnot SourceDir and not SOURCEDIR and not Installed\t1601\n"
2043                                               "UnpublishFeatures\t\t1800\n"
2044                                               "TestSourceDirProp27\tnot SourceDir and not SOURCEDIR and not Installed\t1801\n"
2045                                               "RemoveFiles\t\t3500\n"
2046                                               "TestSourceDirProp28\tnot SourceDir and not SOURCEDIR and not Installed\t3501\n"
2047                                               "InstallFiles\t\t4000\n"
2048                                               "TestSourceDirProp29\tnot SourceDir and not SOURCEDIR and not Installed\t4001\n"
2049                                               "RegisterUser\t\t6000\n"
2050                                               "TestSourceDirProp30\tnot SourceDir and not SOURCEDIR and not Installed\t6001\n"
2051                                               "RegisterProduct\t\t6100\n"
2052                                               "TestSourceDirProp31\tnot SourceDir and not SOURCEDIR and not Installed\t6101\n"
2053                                               "PublishFeatures\t\t6300\n"
2054                                               "TestSourceDirProp32\tnot SourceDir and not SOURCEDIR and not Installed\t6301\n"
2055                                               "PublishProduct\t\t6400\n"
2056                                               "TestSourceDirProp33\tnot SourceDir and not SOURCEDIR and not Installed\t6401\n"
2057                                               "InstallExecute\t\t6500\n"
2058                                               "TestSourceDirProp34\tnot SourceDir and not SOURCEDIR and not Installed\t6501\n"
2059                                               "InstallFinalize\t\t6600\n"
2060                                               "TestSourceDirProp35\tnot SourceDir and not SOURCEDIR and not Installed\t6601\n";
2061
2062 static const CHAR sd_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
2063                                            "s72\ti2\tS64\tS0\tS255\n"
2064                                            "CustomAction\tAction\n"
2065                                            "TestSourceDirProp1\t19\t\tTest 1 failed\t\n"
2066                                            "TestSourceDirProp2\t19\t\tTest 2 failed\t\n"
2067                                            "TestSourceDirProp3\t19\t\tTest 3 failed\t\n"
2068                                            "TestSourceDirProp4\t19\t\tTest 4 failed\t\n"
2069                                            "TestSourceDirProp5\t19\t\tTest 5 failed\t\n"
2070                                            "TestSourceDirProp6\t19\t\tTest 6 failed\t\n"
2071                                            "TestSourceDirProp7\t19\t\tTest 7 failed\t\n"
2072                                            "TestSourceDirProp8\t19\t\tTest 8 failed\t\n"
2073                                            "TestSourceDirProp9\t19\t\tTest 9 failed\t\n"
2074                                            "TestSourceDirProp10\t19\t\tTest 10 failed\t\n"
2075                                            "TestSourceDirProp11\t19\t\tTest 11 failed\t\n"
2076                                            "TestSourceDirProp12\t19\t\tTest 12 failed\t\n"
2077                                            "TestSourceDirProp13\t19\t\tTest 13 failed\t\n"
2078                                            "TestSourceDirProp14\t19\t\tTest 14 failed\t\n"
2079                                            "TestSourceDirProp15\t19\t\tTest 15 failed\t\n"
2080                                            "TestSourceDirProp16\t19\t\tTest 16 failed\t\n"
2081                                            "TestSourceDirProp17\t19\t\tTest 17 failed\t\n"
2082                                            "TestSourceDirProp18\t19\t\tTest 18 failed\t\n"
2083                                            "TestSourceDirProp19\t19\t\tTest 19 failed\t\n"
2084                                            "TestSourceDirProp20\t19\t\tTest 20 failed\t\n"
2085                                            "TestSourceDirProp21\t19\t\tTest 21 failed\t\n"
2086                                            "TestSourceDirProp22\t19\t\tTest 22 failed\t\n"
2087                                            "TestSourceDirProp23\t19\t\tTest 23 failed\t\n"
2088                                            "TestSourceDirProp24\t19\t\tTest 24 failed\t\n"
2089                                            "TestSourceDirProp25\t19\t\tTest 25 failed\t\n"
2090                                            "TestSourceDirProp26\t19\t\tTest 26 failed\t\n"
2091                                            "TestSourceDirProp27\t19\t\tTest 27 failed\t\n"
2092                                            "TestSourceDirProp28\t19\t\tTest 28 failed\t\n"
2093                                            "TestSourceDirProp29\t19\t\tTest 29 failed\t\n"
2094                                            "TestSourceDirProp30\t19\t\tTest 30 failed\t\n"
2095                                            "TestSourceDirProp31\t19\t\tTest 31 failed\t\n"
2096                                            "TestSourceDirProp32\t19\t\tTest 32 failed\t\n"
2097                                            "TestSourceDirProp33\t19\t\tTest 33 failed\t\n"
2098                                            "TestSourceDirProp34\t19\t\tTest 34 failed\t\n"
2099                                            "TestSourceDirProp35\t19\t\tTest 35 failed\t\n";
2100
2101 typedef struct _msi_table
2102 {
2103     const CHAR *filename;
2104     const CHAR *data;
2105     int size;
2106 } msi_table;
2107
2108 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
2109
2110 static const msi_table tables[] =
2111 {
2112     ADD_TABLE(component),
2113     ADD_TABLE(directory),
2114     ADD_TABLE(feature),
2115     ADD_TABLE(feature_comp),
2116     ADD_TABLE(file),
2117     ADD_TABLE(install_exec_seq),
2118     ADD_TABLE(media),
2119     ADD_TABLE(property),
2120     ADD_TABLE(registry),
2121     ADD_TABLE(service_install),
2122     ADD_TABLE(service_control)
2123 };
2124
2125 static const msi_table sc_tables[] =
2126 {
2127     ADD_TABLE(component),
2128     ADD_TABLE(directory),
2129     ADD_TABLE(feature),
2130     ADD_TABLE(feature_comp),
2131     ADD_TABLE(file),
2132     ADD_TABLE(install_exec_seq),
2133     ADD_TABLE(media),
2134     ADD_TABLE(property),
2135     ADD_TABLE(shortcut)
2136 };
2137
2138 static const msi_table ps_tables[] =
2139 {
2140     ADD_TABLE(component),
2141     ADD_TABLE(directory),
2142     ADD_TABLE(feature),
2143     ADD_TABLE(feature_comp),
2144     ADD_TABLE(file),
2145     ADD_TABLE(install_exec_seq),
2146     ADD_TABLE(media),
2147     ADD_TABLE(property),
2148     ADD_TABLE(condition)
2149 };
2150
2151 static const msi_table env_tables[] =
2152 {
2153     ADD_TABLE(component),
2154     ADD_TABLE(directory),
2155     ADD_TABLE(feature),
2156     ADD_TABLE(feature_comp),
2157     ADD_TABLE(file),
2158     ADD_TABLE(install_exec_seq),
2159     ADD_TABLE(media),
2160     ADD_TABLE(property),
2161     ADD_TABLE(environment)
2162 };
2163
2164 static const msi_table up_tables[] =
2165 {
2166     ADD_TABLE(component),
2167     ADD_TABLE(directory),
2168     ADD_TABLE(feature),
2169     ADD_TABLE(feature_comp),
2170     ADD_TABLE(file),
2171     ADD_TABLE(install_exec_seq),
2172     ADD_TABLE(media),
2173     ADD_TABLE(up_property),
2174     ADD_TABLE(registry),
2175     ADD_TABLE(service_install),
2176     ADD_TABLE(service_control)
2177 };
2178
2179 static const msi_table up2_tables[] =
2180 {
2181     ADD_TABLE(component),
2182     ADD_TABLE(directory),
2183     ADD_TABLE(feature),
2184     ADD_TABLE(feature_comp),
2185     ADD_TABLE(file),
2186     ADD_TABLE(install_exec_seq),
2187     ADD_TABLE(media),
2188     ADD_TABLE(up2_property),
2189     ADD_TABLE(registry),
2190     ADD_TABLE(service_install),
2191     ADD_TABLE(service_control)
2192 };
2193
2194 static const msi_table up3_tables[] =
2195 {
2196     ADD_TABLE(component),
2197     ADD_TABLE(directory),
2198     ADD_TABLE(feature),
2199     ADD_TABLE(feature_comp),
2200     ADD_TABLE(file),
2201     ADD_TABLE(install_exec_seq),
2202     ADD_TABLE(media),
2203     ADD_TABLE(up3_property),
2204     ADD_TABLE(registry),
2205     ADD_TABLE(service_install),
2206     ADD_TABLE(service_control)
2207 };
2208
2209 static const msi_table up4_tables[] =
2210 {
2211     ADD_TABLE(component),
2212     ADD_TABLE(directory),
2213     ADD_TABLE(feature),
2214     ADD_TABLE(feature_comp),
2215     ADD_TABLE(file),
2216     ADD_TABLE(pp_install_exec_seq),
2217     ADD_TABLE(media),
2218     ADD_TABLE(property),
2219     ADD_TABLE(registry),
2220     ADD_TABLE(service_install),
2221     ADD_TABLE(service_control)
2222 };
2223
2224 static const msi_table up5_tables[] =
2225 {
2226     ADD_TABLE(component),
2227     ADD_TABLE(directory),
2228     ADD_TABLE(feature),
2229     ADD_TABLE(feature_comp),
2230     ADD_TABLE(file),
2231     ADD_TABLE(pp_install_exec_seq),
2232     ADD_TABLE(media),
2233     ADD_TABLE(up_property),
2234     ADD_TABLE(registry),
2235     ADD_TABLE(service_install),
2236     ADD_TABLE(service_control)
2237 };
2238
2239 static const msi_table up6_tables[] =
2240 {
2241     ADD_TABLE(component),
2242     ADD_TABLE(directory),
2243     ADD_TABLE(feature),
2244     ADD_TABLE(feature_comp),
2245     ADD_TABLE(file),
2246     ADD_TABLE(pp_install_exec_seq),
2247     ADD_TABLE(media),
2248     ADD_TABLE(up2_property),
2249     ADD_TABLE(registry),
2250     ADD_TABLE(service_install),
2251     ADD_TABLE(service_control)
2252 };
2253
2254 static const msi_table up7_tables[] =
2255 {
2256     ADD_TABLE(component),
2257     ADD_TABLE(directory),
2258     ADD_TABLE(feature),
2259     ADD_TABLE(feature_comp),
2260     ADD_TABLE(file),
2261     ADD_TABLE(pp_install_exec_seq),
2262     ADD_TABLE(media),
2263     ADD_TABLE(up3_property),
2264     ADD_TABLE(registry),
2265     ADD_TABLE(service_install),
2266     ADD_TABLE(service_control)
2267 };
2268
2269 static const msi_table cc_tables[] =
2270 {
2271     ADD_TABLE(cc_component),
2272     ADD_TABLE(directory),
2273     ADD_TABLE(cc_feature),
2274     ADD_TABLE(cc_feature_comp),
2275     ADD_TABLE(cc_file),
2276     ADD_TABLE(install_exec_seq),
2277     ADD_TABLE(cc_media),
2278     ADD_TABLE(property),
2279 };
2280
2281 static const msi_table cc2_tables[] =
2282 {
2283     ADD_TABLE(cc2_component),
2284     ADD_TABLE(directory),
2285     ADD_TABLE(cc_feature),
2286     ADD_TABLE(cc_feature_comp),
2287     ADD_TABLE(cc2_file),
2288     ADD_TABLE(install_exec_seq),
2289     ADD_TABLE(cc_media),
2290     ADD_TABLE(property),
2291 };
2292
2293 static const msi_table co_tables[] =
2294 {
2295     ADD_TABLE(cc_component),
2296     ADD_TABLE(directory),
2297     ADD_TABLE(cc_feature),
2298     ADD_TABLE(cc_feature_comp),
2299     ADD_TABLE(co_file),
2300     ADD_TABLE(install_exec_seq),
2301     ADD_TABLE(co_media),
2302     ADD_TABLE(property),
2303 };
2304
2305 static const msi_table co2_tables[] =
2306 {
2307     ADD_TABLE(cc_component),
2308     ADD_TABLE(directory),
2309     ADD_TABLE(cc_feature),
2310     ADD_TABLE(cc_feature_comp),
2311     ADD_TABLE(cc_file),
2312     ADD_TABLE(install_exec_seq),
2313     ADD_TABLE(co2_media),
2314     ADD_TABLE(property),
2315 };
2316
2317 static const msi_table mm_tables[] =
2318 {
2319     ADD_TABLE(cc_component),
2320     ADD_TABLE(directory),
2321     ADD_TABLE(cc_feature),
2322     ADD_TABLE(cc_feature_comp),
2323     ADD_TABLE(mm_file),
2324     ADD_TABLE(install_exec_seq),
2325     ADD_TABLE(mm_media),
2326     ADD_TABLE(property),
2327 };
2328
2329 static const msi_table ss_tables[] =
2330 {
2331     ADD_TABLE(cc_component),
2332     ADD_TABLE(directory),
2333     ADD_TABLE(cc_feature),
2334     ADD_TABLE(cc_feature_comp),
2335     ADD_TABLE(cc_file),
2336     ADD_TABLE(install_exec_seq),
2337     ADD_TABLE(ss_media),
2338     ADD_TABLE(property),
2339 };
2340
2341 static const msi_table ui_tables[] =
2342 {
2343     ADD_TABLE(ui_component),
2344     ADD_TABLE(directory),
2345     ADD_TABLE(cc_feature),
2346     ADD_TABLE(cc_feature_comp),
2347     ADD_TABLE(cc_file),
2348     ADD_TABLE(install_exec_seq),
2349     ADD_TABLE(ui_install_ui_seq),
2350     ADD_TABLE(ui_custom_action),
2351     ADD_TABLE(cc_media),
2352     ADD_TABLE(property),
2353 };
2354
2355 static const msi_table rof_tables[] =
2356 {
2357     ADD_TABLE(rof_component),
2358     ADD_TABLE(directory),
2359     ADD_TABLE(rof_feature),
2360     ADD_TABLE(rof_feature_comp),
2361     ADD_TABLE(rof_file),
2362     ADD_TABLE(install_exec_seq),
2363     ADD_TABLE(rof_media),
2364     ADD_TABLE(property),
2365 };
2366
2367 static const msi_table rofc_tables[] =
2368 {
2369     ADD_TABLE(rof_component),
2370     ADD_TABLE(directory),
2371     ADD_TABLE(rof_feature),
2372     ADD_TABLE(rof_feature_comp),
2373     ADD_TABLE(rofc_file),
2374     ADD_TABLE(install_exec_seq),
2375     ADD_TABLE(rofc_media),
2376     ADD_TABLE(property),
2377 };
2378
2379 static const msi_table sdp_tables[] =
2380 {
2381     ADD_TABLE(rof_component),
2382     ADD_TABLE(directory),
2383     ADD_TABLE(rof_feature),
2384     ADD_TABLE(rof_feature_comp),
2385     ADD_TABLE(rof_file),
2386     ADD_TABLE(sdp_install_exec_seq),
2387     ADD_TABLE(sdp_custom_action),
2388     ADD_TABLE(rof_media),
2389     ADD_TABLE(property),
2390 };
2391
2392 static const msi_table cie_tables[] =
2393 {
2394     ADD_TABLE(cie_component),
2395     ADD_TABLE(directory),
2396     ADD_TABLE(cc_feature),
2397     ADD_TABLE(cie_feature_comp),
2398     ADD_TABLE(cie_file),
2399     ADD_TABLE(install_exec_seq),
2400     ADD_TABLE(cie_media),
2401     ADD_TABLE(property),
2402 };
2403
2404 static const msi_table ci_tables[] =
2405 {
2406     ADD_TABLE(ci_component),
2407     ADD_TABLE(directory),
2408     ADD_TABLE(rof_feature),
2409     ADD_TABLE(rof_feature_comp),
2410     ADD_TABLE(rof_file),
2411     ADD_TABLE(ci_install_exec_seq),
2412     ADD_TABLE(rof_media),
2413     ADD_TABLE(property),
2414     ADD_TABLE(ci_custom_action),
2415 };
2416
2417 static const msi_table ci2_tables[] =
2418 {
2419     ADD_TABLE(ci2_component),
2420     ADD_TABLE(directory),
2421     ADD_TABLE(rof_feature),
2422     ADD_TABLE(ci2_feature_comp),
2423     ADD_TABLE(ci2_file),
2424     ADD_TABLE(install_exec_seq),
2425     ADD_TABLE(rof_media),
2426     ADD_TABLE(property),
2427 };
2428
2429 static const msi_table spf_tables[] =
2430 {
2431     ADD_TABLE(ci_component),
2432     ADD_TABLE(directory),
2433     ADD_TABLE(rof_feature),
2434     ADD_TABLE(rof_feature_comp),
2435     ADD_TABLE(rof_file),
2436     ADD_TABLE(spf_install_exec_seq),
2437     ADD_TABLE(rof_media),
2438     ADD_TABLE(property),
2439     ADD_TABLE(spf_custom_action),
2440     ADD_TABLE(spf_install_ui_seq),
2441 };
2442
2443 static const msi_table pp_tables[] =
2444 {
2445     ADD_TABLE(ci_component),
2446     ADD_TABLE(directory),
2447     ADD_TABLE(rof_feature),
2448     ADD_TABLE(rof_feature_comp),
2449     ADD_TABLE(rof_file),
2450     ADD_TABLE(pp_install_exec_seq),
2451     ADD_TABLE(rof_media),
2452     ADD_TABLE(property),
2453 };
2454
2455 static const msi_table ppc_tables[] =
2456 {
2457     ADD_TABLE(ppc_component),
2458     ADD_TABLE(directory),
2459     ADD_TABLE(rof_feature),
2460     ADD_TABLE(ppc_feature_comp),
2461     ADD_TABLE(ppc_file),
2462     ADD_TABLE(pp_install_exec_seq),
2463     ADD_TABLE(ppc_media),
2464     ADD_TABLE(property),
2465 };
2466
2467 static const msi_table lus0_tables[] =
2468 {
2469     ADD_TABLE(ci_component),
2470     ADD_TABLE(directory),
2471     ADD_TABLE(rof_feature),
2472     ADD_TABLE(rof_feature_comp),
2473     ADD_TABLE(rof_file),
2474     ADD_TABLE(pp_install_exec_seq),
2475     ADD_TABLE(rof_media),
2476     ADD_TABLE(property),
2477 };
2478
2479 static const msi_table lus1_tables[] =
2480 {
2481     ADD_TABLE(ci_component),
2482     ADD_TABLE(directory),
2483     ADD_TABLE(rof_feature),
2484     ADD_TABLE(rof_feature_comp),
2485     ADD_TABLE(rof_file),
2486     ADD_TABLE(pp_install_exec_seq),
2487     ADD_TABLE(rofc_media),
2488     ADD_TABLE(property),
2489 };
2490
2491 static const msi_table lus2_tables[] =
2492 {
2493     ADD_TABLE(ci_component),
2494     ADD_TABLE(directory),
2495     ADD_TABLE(rof_feature),
2496     ADD_TABLE(rof_feature_comp),
2497     ADD_TABLE(rof_file),
2498     ADD_TABLE(pp_install_exec_seq),
2499     ADD_TABLE(lus2_media),
2500     ADD_TABLE(property),
2501 };
2502
2503 static const msi_table tp_tables[] =
2504 {
2505     ADD_TABLE(tp_component),
2506     ADD_TABLE(directory),
2507     ADD_TABLE(rof_feature),
2508     ADD_TABLE(ci2_feature_comp),
2509     ADD_TABLE(ci2_file),
2510     ADD_TABLE(install_exec_seq),
2511     ADD_TABLE(rof_media),
2512     ADD_TABLE(property),
2513 };
2514
2515 static const msi_table cwd_tables[] =
2516 {
2517     ADD_TABLE(cwd_component),
2518     ADD_TABLE(directory),
2519     ADD_TABLE(rof_feature),
2520     ADD_TABLE(ci2_feature_comp),
2521     ADD_TABLE(ci2_file),
2522     ADD_TABLE(install_exec_seq),
2523     ADD_TABLE(rof_media),
2524     ADD_TABLE(property),
2525 };
2526
2527 static const msi_table adm_tables[] =
2528 {
2529     ADD_TABLE(adm_component),
2530     ADD_TABLE(directory),
2531     ADD_TABLE(rof_feature),
2532     ADD_TABLE(ci2_feature_comp),
2533     ADD_TABLE(ci2_file),
2534     ADD_TABLE(install_exec_seq),
2535     ADD_TABLE(rof_media),
2536     ADD_TABLE(property),
2537     ADD_TABLE(adm_custom_action),
2538     ADD_TABLE(adm_admin_exec_seq),
2539 };
2540
2541 static const msi_table amp_tables[] =
2542 {
2543     ADD_TABLE(amp_component),
2544     ADD_TABLE(directory),
2545     ADD_TABLE(rof_feature),
2546     ADD_TABLE(ci2_feature_comp),
2547     ADD_TABLE(ci2_file),
2548     ADD_TABLE(install_exec_seq),
2549     ADD_TABLE(rof_media),
2550     ADD_TABLE(property),
2551 };
2552
2553 static const msi_table rem_tables[] =
2554 {
2555     ADD_TABLE(rem_component),
2556     ADD_TABLE(directory),
2557     ADD_TABLE(rof_feature),
2558     ADD_TABLE(rem_feature_comp),
2559     ADD_TABLE(rem_file),
2560     ADD_TABLE(rem_install_exec_seq),
2561     ADD_TABLE(rof_media),
2562     ADD_TABLE(property),
2563     ADD_TABLE(rem_remove_files),
2564 };
2565
2566 static const msi_table mov_tables[] =
2567 {
2568     ADD_TABLE(cwd_component),
2569     ADD_TABLE(directory),
2570     ADD_TABLE(rof_feature),
2571     ADD_TABLE(ci2_feature_comp),
2572     ADD_TABLE(ci2_file),
2573     ADD_TABLE(install_exec_seq),
2574     ADD_TABLE(rof_media),
2575     ADD_TABLE(property),
2576     ADD_TABLE(mov_move_file),
2577 };
2578
2579 static const msi_table mc_tables[] =
2580 {
2581     ADD_TABLE(mc_component),
2582     ADD_TABLE(directory),
2583     ADD_TABLE(cc_feature),
2584     ADD_TABLE(cie_feature_comp),
2585     ADD_TABLE(mc_file),
2586     ADD_TABLE(install_exec_seq),
2587     ADD_TABLE(mc_media),
2588     ADD_TABLE(property),
2589     ADD_TABLE(mc_file_hash),
2590 };
2591
2592 static const msi_table df_tables[] =
2593 {
2594     ADD_TABLE(rof_component),
2595     ADD_TABLE(df_directory),
2596     ADD_TABLE(rof_feature),
2597     ADD_TABLE(rof_feature_comp),
2598     ADD_TABLE(rof_file),
2599     ADD_TABLE(install_exec_seq),
2600     ADD_TABLE(rof_media),
2601     ADD_TABLE(property),
2602     ADD_TABLE(df_duplicate_file),
2603 };
2604
2605 static const msi_table wrv_tables[] =
2606 {
2607     ADD_TABLE(wrv_component),
2608     ADD_TABLE(directory),
2609     ADD_TABLE(rof_feature),
2610     ADD_TABLE(ci2_feature_comp),
2611     ADD_TABLE(ci2_file),
2612     ADD_TABLE(install_exec_seq),
2613     ADD_TABLE(rof_media),
2614     ADD_TABLE(property),
2615     ADD_TABLE(wrv_registry),
2616 };
2617
2618 static const msi_table sf_tables[] =
2619 {
2620     ADD_TABLE(wrv_component),
2621     ADD_TABLE(directory),
2622     ADD_TABLE(rof_feature),
2623     ADD_TABLE(ci2_feature_comp),
2624     ADD_TABLE(ci2_file),
2625     ADD_TABLE(install_exec_seq),
2626     ADD_TABLE(rof_media),
2627     ADD_TABLE(property),
2628 };
2629
2630 static const msi_table ca51_tables[] =
2631 {
2632     ADD_TABLE(ca51_component),
2633     ADD_TABLE(directory),
2634     ADD_TABLE(rof_feature),
2635     ADD_TABLE(ci2_feature_comp),
2636     ADD_TABLE(ci2_file),
2637     ADD_TABLE(ca51_install_exec_seq),
2638     ADD_TABLE(rof_media),
2639     ADD_TABLE(property),
2640     ADD_TABLE(ca51_custom_action),
2641 };
2642
2643 static const msi_table is_tables[] =
2644 {
2645     ADD_TABLE(is_component),
2646     ADD_TABLE(directory),
2647     ADD_TABLE(is_feature),
2648     ADD_TABLE(is_feature_comp),
2649     ADD_TABLE(is_file),
2650     ADD_TABLE(install_exec_seq),
2651     ADD_TABLE(is_media),
2652     ADD_TABLE(property),
2653 };
2654
2655 static const msi_table sp_tables[] =
2656 {
2657     ADD_TABLE(sp_component),
2658     ADD_TABLE(sp_directory),
2659     ADD_TABLE(rof_feature),
2660     ADD_TABLE(ci2_feature_comp),
2661     ADD_TABLE(ci2_file),
2662     ADD_TABLE(install_exec_seq),
2663     ADD_TABLE(rof_media),
2664     ADD_TABLE(property),
2665 };
2666
2667 static const msi_table mcp_tables[] =
2668 {
2669     ADD_TABLE(mcp_component),
2670     ADD_TABLE(directory),
2671     ADD_TABLE(mcp_feature),
2672     ADD_TABLE(mcp_feature_comp),
2673     ADD_TABLE(rem_file),
2674     ADD_TABLE(rem_install_exec_seq),
2675     ADD_TABLE(rof_media),
2676     ADD_TABLE(property),
2677 };
2678
2679 static const msi_table mcomp_tables[] =
2680 {
2681     ADD_TABLE(mcp_component),
2682     ADD_TABLE(directory),
2683     ADD_TABLE(mcp_feature),
2684     ADD_TABLE(mcp_feature_comp),
2685     ADD_TABLE(mcomp_file),
2686     ADD_TABLE(rem_install_exec_seq),
2687     ADD_TABLE(rof_media),
2688     ADD_TABLE(property),
2689 };
2690
2691 static const msi_table ai_tables[] =
2692 {
2693     ADD_TABLE(component),
2694     ADD_TABLE(directory),
2695     ADD_TABLE(feature),
2696     ADD_TABLE(feature_comp),
2697     ADD_TABLE(ai_file),
2698     ADD_TABLE(install_exec_seq),
2699     ADD_TABLE(media),
2700     ADD_TABLE(property)
2701 };
2702
2703 static const msi_table pc_tables[] =
2704 {
2705     ADD_TABLE(ca51_component),
2706     ADD_TABLE(directory),
2707     ADD_TABLE(rof_feature),
2708     ADD_TABLE(ci2_feature_comp),
2709     ADD_TABLE(ci2_file),
2710     ADD_TABLE(install_exec_seq),
2711     ADD_TABLE(rof_media),
2712     ADD_TABLE(property)
2713 };
2714
2715 static const msi_table ip_tables[] =
2716 {
2717     ADD_TABLE(component),
2718     ADD_TABLE(directory),
2719     ADD_TABLE(feature),
2720     ADD_TABLE(feature_comp),
2721     ADD_TABLE(file),
2722     ADD_TABLE(ip_install_exec_seq),
2723     ADD_TABLE(ip_custom_action),
2724     ADD_TABLE(media),
2725     ADD_TABLE(property)
2726 };
2727
2728 static const msi_table aup_tables[] =
2729 {
2730     ADD_TABLE(component),
2731     ADD_TABLE(directory),
2732     ADD_TABLE(feature),
2733     ADD_TABLE(feature_comp),
2734     ADD_TABLE(file),
2735     ADD_TABLE(aup_install_exec_seq),
2736     ADD_TABLE(aup_custom_action),
2737     ADD_TABLE(media),
2738     ADD_TABLE(property)
2739 };
2740
2741 static const msi_table aup2_tables[] =
2742 {
2743     ADD_TABLE(component),
2744     ADD_TABLE(directory),
2745     ADD_TABLE(feature),
2746     ADD_TABLE(feature_comp),
2747     ADD_TABLE(file),
2748     ADD_TABLE(aup2_install_exec_seq),
2749     ADD_TABLE(aup_custom_action),
2750     ADD_TABLE(media),
2751     ADD_TABLE(aup_property)
2752 };
2753
2754 static const msi_table aup3_tables[] =
2755 {
2756     ADD_TABLE(component),
2757     ADD_TABLE(directory),
2758     ADD_TABLE(feature),
2759     ADD_TABLE(feature_comp),
2760     ADD_TABLE(file),
2761     ADD_TABLE(aup2_install_exec_seq),
2762     ADD_TABLE(aup_custom_action),
2763     ADD_TABLE(media),
2764     ADD_TABLE(aup2_property)
2765 };
2766
2767 static const msi_table aup4_tables[] =
2768 {
2769     ADD_TABLE(component),
2770     ADD_TABLE(directory),
2771     ADD_TABLE(feature),
2772     ADD_TABLE(feature_comp),
2773     ADD_TABLE(file),
2774     ADD_TABLE(aup3_install_exec_seq),
2775     ADD_TABLE(aup_custom_action),
2776     ADD_TABLE(media),
2777     ADD_TABLE(aup2_property)
2778 };
2779
2780 static const msi_table fiu_tables[] =
2781 {
2782     ADD_TABLE(rof_component),
2783     ADD_TABLE(directory),
2784     ADD_TABLE(rof_feature),
2785     ADD_TABLE(rof_feature_comp),
2786     ADD_TABLE(rof_file),
2787     ADD_TABLE(pp_install_exec_seq),
2788     ADD_TABLE(rof_media),
2789     ADD_TABLE(property),
2790 };
2791
2792 static const msi_table fiuc_tables[] =
2793 {
2794     ADD_TABLE(rof_component),
2795     ADD_TABLE(directory),
2796     ADD_TABLE(rof_feature),
2797     ADD_TABLE(rof_feature_comp),
2798     ADD_TABLE(rofc_file),
2799     ADD_TABLE(pp_install_exec_seq),
2800     ADD_TABLE(rofc_media),
2801     ADD_TABLE(property),
2802 };
2803
2804 static const msi_table cf_tables[] =
2805 {
2806     ADD_TABLE(component),
2807     ADD_TABLE(directory),
2808     ADD_TABLE(feature),
2809     ADD_TABLE(feature_comp),
2810     ADD_TABLE(file),
2811     ADD_TABLE(cf_create_folders),
2812     ADD_TABLE(cf_install_exec_seq),
2813     ADD_TABLE(cf_custom_action),
2814     ADD_TABLE(media),
2815     ADD_TABLE(property)
2816 };
2817
2818 static const msi_table rf_tables[] =
2819 {
2820     ADD_TABLE(component),
2821     ADD_TABLE(directory),
2822     ADD_TABLE(feature),
2823     ADD_TABLE(feature_comp),
2824     ADD_TABLE(file),
2825     ADD_TABLE(cf_create_folders),
2826     ADD_TABLE(rf_install_exec_seq),
2827     ADD_TABLE(cf_custom_action),
2828     ADD_TABLE(media),
2829     ADD_TABLE(property)
2830 };
2831
2832 static const msi_table sss_tables[] =
2833 {
2834     ADD_TABLE(component),
2835     ADD_TABLE(directory),
2836     ADD_TABLE(feature),
2837     ADD_TABLE(feature_comp),
2838     ADD_TABLE(file),
2839     ADD_TABLE(sss_install_exec_seq),
2840     ADD_TABLE(sss_service_control),
2841     ADD_TABLE(media),
2842     ADD_TABLE(property)
2843 };
2844
2845 static const msi_table sds_tables[] =
2846 {
2847     ADD_TABLE(component),
2848     ADD_TABLE(directory),
2849     ADD_TABLE(feature),
2850     ADD_TABLE(feature_comp),
2851     ADD_TABLE(file),
2852     ADD_TABLE(sds_install_exec_seq),
2853     ADD_TABLE(service_control),
2854     ADD_TABLE(service_install),
2855     ADD_TABLE(media),
2856     ADD_TABLE(property)
2857 };
2858
2859 static const msi_table sr_tables[] =
2860 {
2861     ADD_TABLE(component),
2862     ADD_TABLE(directory),
2863     ADD_TABLE(feature),
2864     ADD_TABLE(feature_comp),
2865     ADD_TABLE(file),
2866     ADD_TABLE(sr_selfreg),
2867     ADD_TABLE(sr_install_exec_seq),
2868     ADD_TABLE(media),
2869     ADD_TABLE(property)
2870 };
2871
2872 static const msi_table font_tables[] =
2873 {
2874     ADD_TABLE(font_component),
2875     ADD_TABLE(directory),
2876     ADD_TABLE(font_feature),
2877     ADD_TABLE(font_feature_comp),
2878     ADD_TABLE(font_file),
2879     ADD_TABLE(font),
2880     ADD_TABLE(font_install_exec_seq),
2881     ADD_TABLE(font_media),
2882     ADD_TABLE(property)
2883 };
2884
2885 static const msi_table vp_tables[] =
2886 {
2887     ADD_TABLE(component),
2888     ADD_TABLE(directory),
2889     ADD_TABLE(feature),
2890     ADD_TABLE(feature_comp),
2891     ADD_TABLE(file),
2892     ADD_TABLE(vp_custom_action),
2893     ADD_TABLE(vp_install_exec_seq),
2894     ADD_TABLE(media),
2895     ADD_TABLE(vp_property)
2896 };
2897
2898 static const msi_table odbc_tables[] =
2899 {
2900     ADD_TABLE(odbc_component),
2901     ADD_TABLE(directory),
2902     ADD_TABLE(odbc_feature),
2903     ADD_TABLE(odbc_feature_comp),
2904     ADD_TABLE(odbc_file),
2905     ADD_TABLE(odbc_driver),
2906     ADD_TABLE(odbc_translator),
2907     ADD_TABLE(odbc_datasource),
2908     ADD_TABLE(odbc_install_exec_seq),
2909     ADD_TABLE(odbc_media),
2910     ADD_TABLE(property)
2911 };
2912
2913 static const msi_table tl_tables[] =
2914 {
2915     ADD_TABLE(tl_component),
2916     ADD_TABLE(directory),
2917     ADD_TABLE(tl_feature),
2918     ADD_TABLE(tl_feature_comp),
2919     ADD_TABLE(tl_file),
2920     ADD_TABLE(tl_typelib),
2921     ADD_TABLE(tl_install_exec_seq),
2922     ADD_TABLE(media),
2923     ADD_TABLE(property)
2924 };
2925
2926 static const msi_table crs_tables[] =
2927 {
2928     ADD_TABLE(crs_component),
2929     ADD_TABLE(directory),
2930     ADD_TABLE(crs_feature),
2931     ADD_TABLE(crs_feature_comp),
2932     ADD_TABLE(crs_file),
2933     ADD_TABLE(crs_shortcut),
2934     ADD_TABLE(crs_install_exec_seq),
2935     ADD_TABLE(media),
2936     ADD_TABLE(property)
2937 };
2938
2939 static const msi_table pub_tables[] =
2940 {
2941     ADD_TABLE(directory),
2942     ADD_TABLE(pub_component),
2943     ADD_TABLE(pub_feature),
2944     ADD_TABLE(pub_feature_comp),
2945     ADD_TABLE(pub_file),
2946     ADD_TABLE(pub_publish_component),
2947     ADD_TABLE(pub_install_exec_seq),
2948     ADD_TABLE(media),
2949     ADD_TABLE(property)
2950 };
2951
2952 static const msi_table rd_tables[] =
2953 {
2954     ADD_TABLE(directory),
2955     ADD_TABLE(rd_component),
2956     ADD_TABLE(rd_feature),
2957     ADD_TABLE(rd_feature_comp),
2958     ADD_TABLE(rd_file),
2959     ADD_TABLE(rd_duplicate_file),
2960     ADD_TABLE(rd_install_exec_seq),
2961     ADD_TABLE(media),
2962     ADD_TABLE(property)
2963 };
2964
2965 static const msi_table rrv_tables[] =
2966 {
2967     ADD_TABLE(directory),
2968     ADD_TABLE(rrv_component),
2969     ADD_TABLE(rrv_feature),
2970     ADD_TABLE(rrv_feature_comp),
2971     ADD_TABLE(rrv_file),
2972     ADD_TABLE(rrv_registry),
2973     ADD_TABLE(rrv_remove_registry),
2974     ADD_TABLE(rrv_install_exec_seq),
2975     ADD_TABLE(media),
2976     ADD_TABLE(property)
2977 };
2978
2979 static const msi_table frp_tables[] =
2980 {
2981     ADD_TABLE(directory),
2982     ADD_TABLE(frp_component),
2983     ADD_TABLE(frp_feature),
2984     ADD_TABLE(frp_feature_comp),
2985     ADD_TABLE(frp_file),
2986     ADD_TABLE(frp_upgrade),
2987     ADD_TABLE(frp_custom_action),
2988     ADD_TABLE(frp_install_exec_seq),
2989     ADD_TABLE(media),
2990     ADD_TABLE(property)
2991 };
2992
2993 static const msi_table riv_tables[] =
2994 {
2995     ADD_TABLE(directory),
2996     ADD_TABLE(riv_component),
2997     ADD_TABLE(riv_feature),
2998     ADD_TABLE(riv_feature_comp),
2999     ADD_TABLE(riv_file),
3000     ADD_TABLE(riv_ini_file),
3001     ADD_TABLE(riv_remove_ini_file),
3002     ADD_TABLE(riv_install_exec_seq),
3003     ADD_TABLE(media),
3004     ADD_TABLE(property)
3005 };
3006
3007 static const msi_table res_tables[] =
3008 {
3009     ADD_TABLE(directory),
3010     ADD_TABLE(res_component),
3011     ADD_TABLE(res_feature),
3012     ADD_TABLE(res_feature_comp),
3013     ADD_TABLE(res_file),
3014     ADD_TABLE(res_environment),
3015     ADD_TABLE(res_install_exec_seq),
3016     ADD_TABLE(media),
3017     ADD_TABLE(property)
3018 };
3019
3020 static const msi_table rci_tables[] =
3021 {
3022     ADD_TABLE(directory),
3023     ADD_TABLE(rci_component),
3024     ADD_TABLE(rci_feature),
3025     ADD_TABLE(rci_feature_comp),
3026     ADD_TABLE(rci_file),
3027     ADD_TABLE(rci_appid),
3028     ADD_TABLE(rci_class),
3029     ADD_TABLE(rci_install_exec_seq),
3030     ADD_TABLE(media),
3031     ADD_TABLE(property)
3032 };
3033
3034 static const msi_table rei_tables[] =
3035 {
3036     ADD_TABLE(directory),
3037     ADD_TABLE(rei_component),
3038     ADD_TABLE(rei_feature),
3039     ADD_TABLE(rei_feature_comp),
3040     ADD_TABLE(rei_file),
3041     ADD_TABLE(rei_extension),
3042     ADD_TABLE(rei_verb),
3043     ADD_TABLE(rei_progid),
3044     ADD_TABLE(rei_install_exec_seq),
3045     ADD_TABLE(media),
3046     ADD_TABLE(property)
3047 };
3048
3049 static const msi_table rmi_tables[] =
3050 {
3051     ADD_TABLE(directory),
3052     ADD_TABLE(rmi_component),
3053     ADD_TABLE(rmi_feature),
3054     ADD_TABLE(rmi_feature_comp),
3055     ADD_TABLE(rmi_file),
3056     ADD_TABLE(rmi_extension),
3057     ADD_TABLE(rmi_verb),
3058     ADD_TABLE(rmi_mime),
3059     ADD_TABLE(rmi_install_exec_seq),
3060     ADD_TABLE(media),
3061     ADD_TABLE(property)
3062 };
3063
3064 static const msi_table sd_tables[] =
3065 {
3066     ADD_TABLE(directory),
3067     ADD_TABLE(sd_component),
3068     ADD_TABLE(sd_feature),
3069     ADD_TABLE(sd_feature_comp),
3070     ADD_TABLE(sd_file),
3071     ADD_TABLE(sd_install_exec_seq),
3072     ADD_TABLE(sd_install_ui_seq),
3073     ADD_TABLE(sd_custom_action),
3074     ADD_TABLE(media),
3075     ADD_TABLE(property)
3076 };
3077
3078 static const msi_table fo_tables[] =
3079 {
3080     ADD_TABLE(directory),
3081     ADD_TABLE(fo_file),
3082     ADD_TABLE(fo_component),
3083     ADD_TABLE(fo_feature),
3084     ADD_TABLE(fo_condition),
3085     ADD_TABLE(fo_feature_comp),
3086     ADD_TABLE(fo_custom_action),
3087     ADD_TABLE(fo_install_exec_seq),
3088     ADD_TABLE(media),
3089     ADD_TABLE(property)
3090 };
3091
3092 static const msi_table icon_base_tables[] =
3093 {
3094     ADD_TABLE(ci_component),
3095     ADD_TABLE(directory),
3096     ADD_TABLE(rof_feature),
3097     ADD_TABLE(rof_feature_comp),
3098     ADD_TABLE(rof_file),
3099     ADD_TABLE(pp_install_exec_seq),
3100     ADD_TABLE(rof_media),
3101     ADD_TABLE(icon_property),
3102 };
3103
3104 /* cabinet definitions */
3105
3106 /* make the max size large so there is only one cab file */
3107 #define MEDIA_SIZE          0x7FFFFFFF
3108 #define FOLDER_THRESHOLD    900000
3109
3110 /* the FCI callbacks */
3111
3112 static void * CDECL mem_alloc(ULONG cb)
3113 {
3114     return HeapAlloc(GetProcessHeap(), 0, cb);
3115 }
3116
3117 static void CDECL mem_free(void *memory)
3118 {
3119     HeapFree(GetProcessHeap(), 0, memory);
3120 }
3121
3122 static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG  cbPrevCab, void *pv)
3123 {
3124     sprintf(pccab->szCab, pv, pccab->iCab);
3125     return TRUE;
3126 }
3127
3128 static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
3129 {
3130     return 0;
3131 }
3132
3133 static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile,
3134                              BOOL fContinuation, void *pv)
3135 {
3136     return 0;
3137 }
3138
3139 static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
3140 {
3141     HANDLE handle;
3142     DWORD dwAccess = 0;
3143     DWORD dwShareMode = 0;
3144     DWORD dwCreateDisposition = OPEN_EXISTING;
3145     
3146     dwAccess = GENERIC_READ | GENERIC_WRITE;
3147     /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
3148     dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
3149
3150     if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
3151         dwCreateDisposition = OPEN_EXISTING;
3152     else
3153         dwCreateDisposition = CREATE_NEW;
3154
3155     handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
3156                          dwCreateDisposition, 0, NULL);
3157
3158     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
3159
3160     return (INT_PTR)handle;
3161 }
3162
3163 static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
3164 {
3165     HANDLE handle = (HANDLE)hf;
3166     DWORD dwRead;
3167     BOOL res;
3168     
3169     res = ReadFile(handle, memory, cb, &dwRead, NULL);
3170     ok(res, "Failed to ReadFile\n");
3171
3172     return dwRead;
3173 }
3174
3175 static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
3176 {
3177     HANDLE handle = (HANDLE)hf;
3178     DWORD dwWritten;
3179     BOOL res;
3180
3181     res = WriteFile(handle, memory, cb, &dwWritten, NULL);
3182     ok(res, "Failed to WriteFile\n");
3183
3184     return dwWritten;
3185 }
3186
3187 static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
3188 {
3189     HANDLE handle = (HANDLE)hf;
3190     ok(CloseHandle(handle), "Failed to CloseHandle\n");
3191
3192     return 0;
3193 }
3194
3195 static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
3196 {
3197     HANDLE handle = (HANDLE)hf;
3198     DWORD ret;
3199     
3200     ret = SetFilePointer(handle, dist, NULL, seektype);
3201     ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
3202
3203     return ret;
3204 }
3205
3206 static int CDECL fci_delete(char *pszFile, int *err, void *pv)
3207 {
3208     BOOL ret = DeleteFileA(pszFile);
3209     ok(ret, "Failed to DeleteFile %s\n", pszFile);
3210
3211     return 0;
3212 }
3213
3214 static void init_functionpointers(void)
3215 {
3216     HMODULE hmsi = GetModuleHandleA("msi.dll");
3217     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
3218     HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
3219
3220 #define GET_PROC(mod, func) \
3221     p ## func = (void*)GetProcAddress(mod, #func); \
3222     if(!p ## func) \
3223       trace("GetProcAddress(%s) failed\n", #func);
3224
3225     GET_PROC(hmsi, MsiQueryComponentStateA);
3226     GET_PROC(hmsi, MsiSetExternalUIRecord);
3227     GET_PROC(hmsi, MsiSourceListEnumSourcesA);
3228     GET_PROC(hmsi, MsiSourceListGetInfoA);
3229
3230     GET_PROC(hadvapi32, ConvertSidToStringSidA);
3231     GET_PROC(hadvapi32, GetTokenInformation);
3232     GET_PROC(hadvapi32, OpenProcessToken);
3233     GET_PROC(hadvapi32, RegDeleteKeyExA)
3234     GET_PROC(hkernel32, IsWow64Process)
3235
3236     hsrclient = LoadLibraryA("srclient.dll");
3237     GET_PROC(hsrclient, SRRemoveRestorePoint);
3238     GET_PROC(hsrclient, SRSetRestorePointA);
3239
3240 #undef GET_PROC
3241 }
3242
3243 static BOOL is_process_limited(void)
3244 {
3245     HANDLE token;
3246
3247     if (!pOpenProcessToken || !pGetTokenInformation) return FALSE;
3248
3249     if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
3250     {
3251         BOOL ret;
3252         TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
3253         DWORD size;
3254
3255         ret = pGetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
3256         CloseHandle(token);
3257         return (ret && type == TokenElevationTypeLimited);
3258     }
3259     return FALSE;
3260 }
3261
3262 static BOOL check_win9x(void)
3263 {
3264     SC_HANDLE scm;
3265
3266     scm = OpenSCManager(NULL, NULL, GENERIC_ALL);
3267     if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
3268         return TRUE;
3269
3270     CloseServiceHandle(scm);
3271
3272     return FALSE;
3273 }
3274
3275 static LPSTR get_user_sid(LPSTR *usersid)
3276 {
3277     HANDLE token;
3278     BYTE buf[1024];
3279     DWORD size;
3280     PTOKEN_USER user;
3281
3282     if (!pConvertSidToStringSidA)
3283     {
3284         win_skip("ConvertSidToStringSidA is not available\n");
3285         return NULL;
3286     }
3287
3288     *usersid = NULL;
3289     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
3290     size = sizeof(buf);
3291     GetTokenInformation(token, TokenUser, buf, size, &size);
3292     user = (PTOKEN_USER)buf;
3293     pConvertSidToStringSidA(user->User.Sid, usersid);
3294     ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
3295     CloseHandle(token);
3296     return *usersid;
3297 }
3298
3299 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
3300 {
3301     CHAR buffer[0x20];
3302     UINT r;
3303     DWORD sz;
3304
3305     sz = sizeof buffer;
3306     r = MsiRecordGetString(rec, field, buffer, &sz);
3307     return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
3308 }
3309
3310 static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
3311 {
3312     LPSTR tempname;
3313
3314     tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
3315     GetTempFileNameA(".", "xx", 0, tempname);
3316
3317     if (tempname && (strlen(tempname) < (unsigned)cbTempName))
3318     {
3319         lstrcpyA(pszTempName, tempname);
3320         HeapFree(GetProcessHeap(), 0, tempname);
3321         return TRUE;
3322     }
3323
3324     HeapFree(GetProcessHeap(), 0, tempname);
3325
3326     return FALSE;
3327 }
3328
3329 static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
3330                                    USHORT *pattribs, int *err, void *pv)
3331 {
3332     BY_HANDLE_FILE_INFORMATION finfo;
3333     FILETIME filetime;
3334     HANDLE handle;
3335     DWORD attrs;
3336     BOOL res;
3337
3338     handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
3339                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
3340
3341     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
3342
3343     res = GetFileInformationByHandle(handle, &finfo);
3344     ok(res, "Expected GetFileInformationByHandle to succeed\n");
3345    
3346     FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
3347     FileTimeToDosDateTime(&filetime, pdate, ptime);
3348
3349     attrs = GetFileAttributes(pszName);
3350     ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
3351
3352     return (INT_PTR)handle;
3353 }
3354
3355 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
3356 {
3357     char path[MAX_PATH];
3358     char filename[MAX_PATH];
3359
3360     lstrcpyA(path, CURR_DIR);
3361     lstrcatA(path, "\\");
3362     lstrcatA(path, file);
3363
3364     lstrcpyA(filename, file);
3365
3366     return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
3367                       progress, get_open_info, compress);
3368 }
3369
3370 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
3371 {
3372     ZeroMemory(pCabParams, sizeof(CCAB));
3373
3374     pCabParams->cb = max_size;
3375     pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
3376     pCabParams->setID = 0xbeef;
3377     pCabParams->iCab = 1;
3378     lstrcpyA(pCabParams->szCabPath, CURR_DIR);
3379     lstrcatA(pCabParams->szCabPath, "\\");
3380     lstrcpyA(pCabParams->szCab, name);
3381 }
3382
3383 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
3384 {
3385     CCAB cabParams;
3386     LPCSTR ptr;
3387     HFCI hfci;
3388     ERF erf;
3389     BOOL res;
3390
3391     set_cab_parameters(&cabParams, name, max_size);
3392
3393     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
3394                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
3395                       get_temp_file, &cabParams, NULL);
3396
3397     ok(hfci != NULL, "Failed to create an FCI context\n");
3398
3399     ptr = files;
3400     while (*ptr)
3401     {
3402         res = add_file(hfci, ptr, tcompTYPE_MSZIP);
3403         ok(res, "Failed to add file: %s\n", ptr);
3404         ptr += lstrlen(ptr) + 1;
3405     }
3406
3407     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
3408     ok(res, "Failed to flush the cabinet\n");
3409
3410     res = FCIDestroy(hfci);
3411     ok(res, "Failed to destroy the cabinet\n");
3412 }
3413
3414 static BOOL get_user_dirs(void)
3415 {
3416     HKEY hkey;
3417     DWORD type, size;
3418
3419     if(RegOpenKey(HKEY_CURRENT_USER,
3420                    "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
3421                    &hkey))
3422         return FALSE;
3423
3424     size = MAX_PATH;
3425     if(RegQueryValueExA(hkey, "AppData", 0, &type, (LPBYTE)APP_DATA_DIR, &size)){
3426         RegCloseKey(hkey);
3427         return FALSE;
3428     }
3429
3430     RegCloseKey(hkey);
3431     return TRUE;
3432 }
3433
3434 static BOOL get_system_dirs(void)
3435 {
3436     HKEY hkey;
3437     DWORD type, size;
3438
3439     if (RegOpenKey(HKEY_LOCAL_MACHINE,
3440                    "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
3441         return FALSE;
3442
3443     size = MAX_PATH;
3444     if (RegQueryValueExA(hkey, "ProgramFilesDir (x86)", 0, &type, (LPBYTE)PROG_FILES_DIR, &size) &&
3445         RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)PROG_FILES_DIR, &size)) {
3446         RegCloseKey(hkey);
3447         return FALSE;
3448     }
3449
3450     size = MAX_PATH;
3451     if (RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size)) {
3452         RegCloseKey(hkey);
3453         return FALSE;
3454     }
3455
3456     RegCloseKey(hkey);
3457
3458     if(GetWindowsDirectoryA(WINDOWS_DIR, MAX_PATH) != ERROR_SUCCESS)
3459         return FALSE;
3460
3461     return TRUE;
3462 }
3463
3464 static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
3465 {
3466     HANDLE file;
3467     DWORD written;
3468
3469     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
3470     if (file == INVALID_HANDLE_VALUE)
3471         return;
3472
3473     WriteFile(file, data, strlen(data), &written, NULL);
3474
3475     if (size)
3476     {
3477         SetFilePointer(file, size, NULL, FILE_BEGIN);
3478         SetEndOfFile(file);
3479     }
3480
3481     CloseHandle(file);
3482 }
3483
3484 #define create_file(name, size) create_file_data(name, name, size)
3485
3486 static void create_test_files(void)
3487 {
3488     CreateDirectoryA("msitest", NULL);
3489     create_file("msitest\\one.txt", 100);
3490     CreateDirectoryA("msitest\\first", NULL);
3491     create_file("msitest\\first\\two.txt", 100);
3492     CreateDirectoryA("msitest\\second", NULL);
3493     create_file("msitest\\second\\three.txt", 100);
3494
3495     create_file("four.txt", 100);
3496     create_file("five.txt", 100);
3497     create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
3498
3499     create_file("msitest\\filename", 100);
3500     create_file("msitest\\service.exe", 100);
3501
3502     DeleteFileA("four.txt");
3503     DeleteFileA("five.txt");
3504 }
3505
3506 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
3507 {
3508     CHAR path[MAX_PATH];
3509
3510     lstrcpyA(path, PROG_FILES_DIR);
3511     lstrcatA(path, "\\");
3512     lstrcatA(path, rel_path);
3513
3514     if (is_file)
3515         return DeleteFileA(path);
3516     else
3517         return RemoveDirectoryA(path);
3518 }
3519
3520 static BOOL delete_cf(const CHAR *rel_path, BOOL is_file)
3521 {
3522     CHAR path[MAX_PATH];
3523
3524     lstrcpyA(path, COMMON_FILES_DIR);
3525     lstrcatA(path, "\\");
3526     lstrcatA(path, rel_path);
3527
3528     if (is_file)
3529         return DeleteFileA(path);
3530     else
3531         return RemoveDirectoryA(path);
3532 }
3533
3534 static void delete_test_files(void)
3535 {
3536     DeleteFileA("msitest.msi");
3537     DeleteFileA("msitest.cab");
3538     DeleteFileA("msitest\\second\\three.txt");
3539     DeleteFileA("msitest\\first\\two.txt");
3540     DeleteFileA("msitest\\one.txt");
3541     DeleteFileA("msitest\\service.exe");
3542     DeleteFileA("msitest\\filename");
3543     RemoveDirectoryA("msitest\\second");
3544     RemoveDirectoryA("msitest\\first");
3545     RemoveDirectoryA("msitest");
3546 }
3547
3548 static void write_file(const CHAR *filename, const char *data, int data_size)
3549 {
3550     DWORD size;
3551
3552     HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
3553                            CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
3554
3555     WriteFile(hf, data, data_size, &size, NULL);
3556     CloseHandle(hf);
3557 }
3558
3559 static void write_msi_summary_info(MSIHANDLE db, INT wordcount)
3560 {
3561     MSIHANDLE summary;
3562     UINT r;
3563
3564     r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
3565     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3566
3567     r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
3568     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3569
3570     r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
3571                                    "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
3572     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3573
3574     r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
3575     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3576
3577     r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, wordcount, NULL, NULL);
3578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3579
3580     r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
3581     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3582
3583     /* write the summary changes back to the stream */
3584     r = MsiSummaryInfoPersist(summary);
3585     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3586
3587     MsiCloseHandle(summary);
3588 }
3589
3590 #define create_database(name, tables, num_tables) \
3591     create_database_wordcount(name, tables, num_tables, 0);
3592
3593 static void create_database_wordcount(const CHAR *name, const msi_table *tables,
3594                                       int num_tables, INT wordcount)
3595 {
3596     MSIHANDLE db;
3597     UINT r;
3598     int j;
3599
3600     r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
3601     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3602
3603     /* import the tables into the database */
3604     for (j = 0; j < num_tables; j++)
3605     {
3606         const msi_table *table = &tables[j];
3607
3608         write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
3609
3610         r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
3611         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3612
3613         DeleteFileA(table->filename);
3614     }
3615
3616     write_msi_summary_info(db, wordcount);
3617
3618     r = MsiDatabaseCommit(db);
3619     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3620
3621     MsiCloseHandle(db);
3622 }
3623
3624 static void check_service_is_installed(void)
3625 {
3626     SC_HANDLE scm, service;
3627     BOOL res;
3628
3629     scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
3630     ok(scm != NULL, "Failed to open the SC Manager\n");
3631
3632     service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
3633     ok(service != NULL, "Failed to open TestService\n");
3634
3635     res = DeleteService(service);
3636     ok(res, "Failed to delete TestService\n");
3637
3638     CloseServiceHandle(service);
3639     CloseServiceHandle(scm);
3640 }
3641
3642 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
3643 {
3644     RESTOREPOINTINFOA spec;
3645
3646     spec.dwEventType = event_type;
3647     spec.dwRestorePtType = APPLICATION_INSTALL;
3648     spec.llSequenceNumber = status->llSequenceNumber;
3649     lstrcpyA(spec.szDescription, "msitest restore point");
3650
3651     return pSRSetRestorePointA(&spec, status);
3652 }
3653
3654 static void remove_restore_point(DWORD seq_number)
3655 {
3656     DWORD res;
3657
3658     res = pSRRemoveRestorePoint(seq_number);
3659     if (res != ERROR_SUCCESS)
3660         trace("Failed to remove the restore point : %08x\n", res);
3661 }
3662
3663 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
3664 {
3665     if (pRegDeleteKeyExA)
3666         return pRegDeleteKeyExA( key, subkey, access, 0 );
3667     return RegDeleteKeyA( key, subkey );
3668 }
3669
3670 static void test_MsiInstallProduct(void)
3671 {
3672     UINT r;
3673     CHAR path[MAX_PATH];
3674     LONG res;
3675     HKEY hkey;
3676     DWORD num, size, type;
3677     REGSAM access = KEY_ALL_ACCESS;
3678     BOOL wow64;
3679
3680     if (on_win9x)
3681     {
3682         win_skip("Services are not implemented on Win9x and WinMe\n");
3683         return;
3684     }
3685     if (is_process_limited())
3686     {
3687         skip("process is limited\n");
3688         return;
3689     }
3690
3691     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
3692         access |= KEY_WOW64_64KEY;
3693
3694     /* szPackagePath is NULL */
3695     r = MsiInstallProductA(NULL, "INSTALL=ALL");
3696     ok(r == ERROR_INVALID_PARAMETER,
3697        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3698
3699     /* both szPackagePath and szCommandLine are NULL */
3700     r = MsiInstallProductA(NULL, NULL);
3701     ok(r == ERROR_INVALID_PARAMETER,
3702        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3703
3704     /* szPackagePath is empty */
3705     r = MsiInstallProductA("", "INSTALL=ALL");
3706     ok(r == ERROR_PATH_NOT_FOUND,
3707        "Expected ERROR_PATH_NOT_FOUND, got %d\n", r);
3708
3709     create_test_files();
3710     create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
3711
3712     /* install, don't publish */
3713     r = MsiInstallProductA(msifile, NULL);
3714     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3715     {
3716         skip("Not enough rights to perform tests\n");
3717         goto error;
3718     }
3719     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3720
3721     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3722     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3723     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3724     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3725     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3726     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3727     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3728     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3729     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3730     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3731     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3732     ok(delete_pf("msitest", FALSE), "File not installed\n");
3733
3734     res = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", 0, access, &hkey);
3735     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3736
3737     size = MAX_PATH;
3738     type = REG_SZ;
3739     res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
3740     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3741     ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
3742
3743     size = MAX_PATH;
3744     type = REG_SZ;
3745     res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
3746     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3747
3748     size = sizeof(num);
3749     type = REG_DWORD;
3750     res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
3751     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3752     ok(num == 314, "Expected 314, got %d\n", num);
3753
3754     size = MAX_PATH;
3755     type = REG_SZ;
3756     res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
3757     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3758     ok(!lstrcmpA(path, "OrderTestValue"), "Expected OrderTestValue, got %s\n", path);
3759
3760     check_service_is_installed();
3761
3762     delete_key(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", access);
3763
3764     /* not published, reinstall */
3765     r = MsiInstallProductA(msifile, NULL);
3766     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3767
3768     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3769     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3770     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3771     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3772     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3773     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3774     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3775     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3776     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3777     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3778     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3779     ok(delete_pf("msitest", FALSE), "File not installed\n");
3780
3781     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3782     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3783     RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
3784
3785     create_database(msifile, up_tables, sizeof(up_tables) / sizeof(msi_table));
3786
3787     /* not published, RemovePreviousVersions set */
3788     r = MsiInstallProductA(msifile, NULL);
3789     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3790
3791     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3792     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3793     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3794     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3795     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3796     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3797     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3798     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3799     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3800     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3801     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3802     ok(delete_pf("msitest", FALSE), "File not installed\n");
3803
3804     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3805     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3806     RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
3807
3808     create_database(msifile, up2_tables, sizeof(up2_tables) / sizeof(msi_table));
3809
3810     /* not published, version number bumped */
3811     r = MsiInstallProductA(msifile, NULL);
3812     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3813
3814     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3815     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3816     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3817     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3818     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3819     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3820     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3821     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3822     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3823     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3824     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3825     ok(delete_pf("msitest", FALSE), "File not installed\n");
3826
3827     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3828     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3829     RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
3830
3831     create_database(msifile, up3_tables, sizeof(up3_tables) / sizeof(msi_table));
3832
3833     /* not published, RemovePreviousVersions set and version number bumped */
3834     r = MsiInstallProductA(msifile, NULL);
3835     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3836
3837     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3838     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3839     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3840     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3841     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3842     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3843     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3844     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3845     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3846     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3847     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3848     ok(delete_pf("msitest", FALSE), "File not installed\n");
3849
3850     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3851     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3852     RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
3853
3854     create_database(msifile, up4_tables, sizeof(up4_tables) / sizeof(msi_table));
3855
3856     /* install, publish product */
3857     r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
3858     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3859
3860     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3861     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3862     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3863     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3864     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3865     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3866     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3867     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3868     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3869     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3870     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3871     ok(delete_pf("msitest", FALSE), "File not installed\n");
3872
3873     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3874     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3875
3876     create_database(msifile, up4_tables, sizeof(up4_tables) / sizeof(msi_table));
3877
3878     /* published, reinstall */
3879     r = MsiInstallProductA(msifile, NULL);
3880     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3881
3882     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3883     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3884     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3885     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3886     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3887     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3888     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3889     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3890     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3891     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3892     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3893     ok(delete_pf("msitest", FALSE), "File not installed\n");
3894
3895     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3896     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3897
3898     create_database(msifile, up5_tables, sizeof(up5_tables) / sizeof(msi_table));
3899
3900     /* published product, RemovePreviousVersions set */
3901     r = MsiInstallProductA(msifile, NULL);
3902     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3903
3904     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3905     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3906     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3907     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3908     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3909     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3910     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3911     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3912     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3913     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3914     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3915     ok(delete_pf("msitest", FALSE), "File not installed\n");
3916
3917     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3918     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3919
3920     create_database(msifile, up6_tables, sizeof(up6_tables) / sizeof(msi_table));
3921
3922     /* published product, version number bumped */
3923     r = MsiInstallProductA(msifile, NULL);
3924     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3925
3926     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3927     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3928     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3929     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3930     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3931     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3932     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3933     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3934     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3935     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3936     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3937     ok(delete_pf("msitest", FALSE), "File not installed\n");
3938
3939     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3940     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3941
3942     create_database(msifile, up7_tables, sizeof(up7_tables) / sizeof(msi_table));
3943
3944     /* published product, RemovePreviousVersions set and version number bumped */
3945     r = MsiInstallProductA(msifile, NULL);
3946     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3947
3948     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3949     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3950     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3951     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3952     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3953     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3954     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3955     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3956     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3957     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3958     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3959     ok(delete_pf("msitest", FALSE), "File not installed\n");
3960
3961     res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
3962     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3963
3964     r = MsiInstallProductA(msifile, "REMOVE=ALL");
3965     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3966
3967 error:
3968     delete_test_files();
3969     DeleteFileA(msifile);
3970 }
3971
3972 static void test_MsiSetComponentState(void)
3973 {
3974     INSTALLSTATE installed, action;
3975     MSIHANDLE package;
3976     char path[MAX_PATH];
3977     UINT r;
3978
3979     create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
3980
3981     CoInitialize(NULL);
3982
3983     lstrcpy(path, CURR_DIR);
3984     lstrcat(path, "\\");
3985     lstrcat(path, msifile);
3986
3987     r = MsiOpenPackage(path, &package);
3988     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3989     {
3990         skip("Not enough rights to perform tests\n");
3991         goto error;
3992     }
3993     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3994
3995     r = MsiDoAction(package, "CostInitialize");
3996     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3997
3998     r = MsiDoAction(package, "FileCost");
3999     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4000
4001     r = MsiDoAction(package, "CostFinalize");
4002     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4003
4004     r = MsiGetComponentState(package, "dangler", &installed, &action);
4005     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4006     ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
4007     ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4008
4009     r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
4010     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4011
4012     MsiCloseHandle(package);
4013
4014 error:
4015     CoUninitialize();
4016     DeleteFileA(msifile);
4017 }
4018
4019 static void test_packagecoltypes(void)
4020 {
4021     MSIHANDLE hdb, view, rec;
4022     char path[MAX_PATH];
4023     LPCSTR query;
4024     UINT r, count;
4025
4026     create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
4027
4028     CoInitialize(NULL);
4029
4030     lstrcpy(path, CURR_DIR);
4031     lstrcat(path, "\\");
4032     lstrcat(path, msifile);
4033
4034     r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
4035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4036
4037     query = "SELECT * FROM `Media`";
4038     r = MsiDatabaseOpenView( hdb, query, &view );
4039     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
4040
4041     r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
4042     count = MsiRecordGetFieldCount( rec );
4043     ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
4044     ok(count == 6, "Expected 6, got %d\n", count);
4045     ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
4046     ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
4047     ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
4048     ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
4049     ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
4050     ok(check_record(rec, 6, "Source"), "wrong column label\n");
4051     MsiCloseHandle(rec);
4052
4053     r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
4054     count = MsiRecordGetFieldCount( rec );
4055     ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
4056     ok(count == 6, "Expected 6, got %d\n", count);
4057     ok(check_record(rec, 1, "i2"), "wrong column label\n");
4058     ok(check_record(rec, 2, "i4"), "wrong column label\n");
4059     ok(check_record(rec, 3, "L64"), "wrong column label\n");
4060     ok(check_record(rec, 4, "S255"), "wrong column label\n");
4061     ok(check_record(rec, 5, "S32"), "wrong column label\n");
4062     ok(check_record(rec, 6, "S72"), "wrong column label\n");
4063
4064     MsiCloseHandle(rec);
4065     MsiCloseHandle(view);
4066     MsiCloseHandle(hdb);
4067     CoUninitialize();
4068
4069     DeleteFile(msifile);
4070 }
4071
4072 static void create_cc_test_files(void)
4073 {
4074     CCAB cabParams;
4075     HFCI hfci;
4076     ERF erf;
4077     static CHAR cab_context[] = "test%d.cab";
4078     BOOL res;
4079
4080     create_file("maximus", 500);
4081     create_file("augustus", 50000);
4082     create_file("tiberius", 500);
4083     create_file("caesar", 500);
4084
4085     set_cab_parameters(&cabParams, "test1.cab", 40000);
4086
4087     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
4088                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
4089                       get_temp_file, &cabParams, cab_context);
4090     ok(hfci != NULL, "Failed to create an FCI context\n");
4091
4092     res = add_file(hfci, "maximus", tcompTYPE_NONE);
4093     ok(res, "Failed to add file maximus\n");
4094
4095     res = add_file(hfci, "augustus", tcompTYPE_NONE);
4096     ok(res, "Failed to add file augustus\n");
4097
4098     res = add_file(hfci, "tiberius", tcompTYPE_NONE);
4099     ok(res, "Failed to add file tiberius\n");
4100
4101     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
4102     ok(res, "Failed to flush the cabinet\n");
4103
4104     res = FCIDestroy(hfci);
4105     ok(res, "Failed to destroy the cabinet\n");
4106
4107     create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
4108
4109     DeleteFile("maximus");
4110     DeleteFile("augustus");
4111     DeleteFile("tiberius");
4112     DeleteFile("caesar");
4113 }
4114
4115 static void delete_cab_files(void)
4116 {
4117     SHFILEOPSTRUCT shfl;
4118     CHAR path[MAX_PATH+10];
4119
4120     lstrcpyA(path, CURR_DIR);
4121     lstrcatA(path, "\\*.cab");
4122     path[strlen(path) + 1] = '\0';
4123
4124     shfl.hwnd = NULL;
4125     shfl.wFunc = FO_DELETE;
4126     shfl.pFrom = path;
4127     shfl.pTo = NULL;
4128     shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
4129
4130     SHFileOperation(&shfl);
4131 }
4132
4133 static void test_continuouscabs(void)
4134 {
4135     UINT r;
4136
4137     if (is_process_limited())
4138     {
4139         skip("process is limited\n");
4140         return;
4141     }
4142
4143     create_cc_test_files();
4144     create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
4145
4146     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4147
4148     r = MsiInstallProductA(msifile, NULL);
4149     if (r == ERROR_SUCCESS) /* win9x has a problem with this */
4150     {
4151         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4152         ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4153         ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4154         ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4155         ok(delete_pf("msitest", FALSE), "File not installed\n");
4156     }
4157
4158     delete_cab_files();
4159     DeleteFile(msifile);
4160
4161     create_cc_test_files();
4162     create_database(msifile, cc2_tables, sizeof(cc2_tables) / sizeof(msi_table));
4163
4164     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4165
4166     r = MsiInstallProductA(msifile, NULL);
4167     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4168     {
4169         skip("Not enough rights to perform tests\n");
4170         goto error;
4171     }
4172     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4173     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4174     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
4175     ok(delete_pf("msitest\\tiberius", TRUE), "File not installed\n");
4176     ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4177     ok(delete_pf("msitest", FALSE), "File not installed\n");
4178
4179 error:
4180     delete_cab_files();
4181     DeleteFile(msifile);
4182 }
4183
4184 static void test_caborder(void)
4185 {
4186     UINT r;
4187
4188     create_file("imperator", 100);
4189     create_file("maximus", 500);
4190     create_file("augustus", 50000);
4191     create_file("caesar", 500);
4192
4193     create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
4194
4195     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4196
4197     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4198     create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
4199     create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
4200
4201     r = MsiInstallProductA(msifile, NULL);
4202     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4203     {
4204         skip("Not enough rights to perform tests\n");
4205         goto error;
4206     }
4207     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
4208     ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
4209     ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
4210     todo_wine
4211     {
4212         ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
4213         ok(!delete_pf("msitest", FALSE), "File is installed\n");
4214     }
4215
4216     delete_cab_files();
4217
4218     create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
4219     create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
4220     create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
4221
4222     r = MsiInstallProductA(msifile, NULL);
4223     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
4224     ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
4225     ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
4226     ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
4227     ok(!delete_pf("msitest", FALSE), "File is installed\n");
4228
4229     delete_cab_files();
4230     DeleteFile(msifile);
4231
4232     create_cc_test_files();
4233     create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
4234
4235     r = MsiInstallProductA(msifile, NULL);
4236     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
4237     ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
4238     ok(!delete_pf("msitest", FALSE), "File is installed\n");
4239     todo_wine
4240     {
4241         ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
4242         ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
4243     }
4244
4245     delete_cab_files();
4246     DeleteFile(msifile);
4247
4248     create_cc_test_files();
4249     create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
4250
4251     r = MsiInstallProductA(msifile, NULL);
4252     ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
4253     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
4254     todo_wine
4255     {
4256         ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
4257         ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
4258         ok(!delete_pf("msitest", FALSE), "File is installed\n");
4259     }
4260
4261 error:
4262     delete_cab_files();
4263     DeleteFile("imperator");
4264     DeleteFile("maximus");
4265     DeleteFile("augustus");
4266     DeleteFile("caesar");
4267     DeleteFile(msifile);
4268 }
4269
4270 static void test_mixedmedia(void)
4271 {
4272     UINT r;
4273
4274     if (is_process_limited())
4275     {
4276         skip("process is limited\n");
4277         return;
4278     }
4279
4280     CreateDirectoryA("msitest", NULL);
4281     create_file("msitest\\maximus", 500);
4282     create_file("msitest\\augustus", 500);
4283     create_file("caesar", 500);
4284
4285     create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
4286
4287     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4288
4289     create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
4290
4291     r = MsiInstallProductA(msifile, NULL);
4292     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4293     {
4294         skip("Not enough rights to perform tests\n");
4295         goto error;
4296     }
4297     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4298     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4299     ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4300     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4301     ok(delete_pf("msitest", FALSE), "File not installed\n");
4302
4303 error:
4304     /* Delete the files in the temp (current) folder */
4305     DeleteFile("msitest\\maximus");
4306     DeleteFile("msitest\\augustus");
4307     RemoveDirectory("msitest");
4308     DeleteFile("caesar");
4309     DeleteFile("test1.cab");
4310     DeleteFile(msifile);
4311 }
4312
4313 static void test_samesequence(void)
4314 {
4315     UINT r;
4316
4317     create_cc_test_files();
4318     create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
4319
4320     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4321
4322     r = MsiInstallProductA(msifile, NULL);
4323     if (r == ERROR_SUCCESS) /* win9x has a problem with this */
4324     {
4325         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4326         ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4327         ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4328         ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4329         ok(delete_pf("msitest", FALSE), "File not installed\n");
4330     }
4331
4332     delete_cab_files();
4333     DeleteFile(msifile);
4334 }
4335
4336 static void test_uiLevelFlags(void)
4337 {
4338     UINT r;
4339
4340     create_cc_test_files();
4341     create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
4342
4343     MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
4344
4345     r = MsiInstallProductA(msifile, NULL);
4346     if (r == ERROR_SUCCESS) /* win9x has a problem with this */
4347     {
4348         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4349         ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
4350         ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4351         ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4352         ok(delete_pf("msitest", FALSE), "File not installed\n");
4353     }
4354
4355     delete_cab_files();
4356     DeleteFile(msifile);
4357 }
4358
4359 static BOOL file_matches(LPSTR path)
4360 {
4361     CHAR buf[MAX_PATH];
4362     HANDLE file;
4363     DWORD size;
4364
4365     file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
4366                       NULL, OPEN_EXISTING, 0, NULL);
4367
4368     ZeroMemory(buf, MAX_PATH);
4369     ReadFile(file, buf, 15, &size, NULL);
4370     CloseHandle(file);
4371
4372     return !lstrcmp(buf, "msitest\\maximus");
4373 }
4374
4375 static void test_readonlyfile(void)
4376 {
4377     UINT r;
4378     DWORD size;
4379     HANDLE file;
4380     CHAR path[MAX_PATH];
4381
4382     if (is_process_limited())
4383     {
4384         skip("process is limited\n");
4385         return;
4386     }
4387
4388     CreateDirectoryA("msitest", NULL);
4389     create_file("msitest\\maximus", 500);
4390     create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
4391
4392     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4393
4394     lstrcpy(path, PROG_FILES_DIR);
4395     lstrcat(path, "\\msitest");
4396     CreateDirectory(path, NULL);
4397
4398     lstrcat(path, "\\maximus");
4399     file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
4400                       NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
4401
4402     WriteFile(file, "readonlyfile", strlen("readonlyfile"), &size, NULL);
4403     CloseHandle(file);
4404
4405     r = MsiInstallProductA(msifile, NULL);
4406     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4407     {
4408         skip("Not enough rights to perform tests\n");
4409         goto error;
4410     }
4411     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4412     ok(file_matches(path), "Expected file to be overwritten\n");
4413     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4414     ok(delete_pf("msitest", FALSE), "File not installed\n");
4415
4416 error:
4417     /* Delete the files in the temp (current) folder */
4418     DeleteFile("msitest\\maximus");
4419     RemoveDirectory("msitest");
4420     DeleteFile(msifile);
4421 }
4422
4423 static void test_readonlyfile_cab(void)
4424 {
4425     UINT r;
4426     DWORD size;
4427     HANDLE file;
4428     CHAR path[MAX_PATH];
4429     CHAR buf[16];
4430
4431     if (is_process_limited())
4432     {
4433         skip("process is limited\n");
4434         return;
4435     }
4436
4437     CreateDirectoryA("msitest", NULL);
4438     create_file("maximus", 500);
4439     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4440     DeleteFile("maximus");
4441
4442     create_database(msifile, rofc_tables, sizeof(rofc_tables) / sizeof(msi_table));
4443
4444     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4445
4446     lstrcpy(path, PROG_FILES_DIR);
4447     lstrcat(path, "\\msitest");
4448     CreateDirectory(path, NULL);
4449
4450     lstrcat(path, "\\maximus");
4451     file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
4452                       NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
4453
4454     WriteFile(file, "readonlyfile", strlen("readonlyfile"), &size, NULL);
4455     CloseHandle(file);
4456
4457     r = MsiInstallProductA(msifile, NULL);
4458     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4459     {
4460         skip("Not enough rights to perform tests\n");
4461         goto error;
4462     }
4463     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4464
4465     memset( buf, 0, sizeof(buf) );
4466     if ((file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
4467                            NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE)
4468     {
4469         ReadFile(file, buf, sizeof(buf) - 1, &size, NULL);
4470         CloseHandle(file);
4471     }
4472     ok(!memcmp( buf, "maximus", sizeof("maximus")-1 ), "Expected file to be overwritten, got '%s'\n", buf);
4473     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4474     ok(delete_pf("msitest", FALSE), "File not installed\n");
4475
4476 error:
4477     /* Delete the files in the temp (current) folder */
4478     delete_cab_files();
4479     DeleteFile("msitest\\maximus");
4480     RemoveDirectory("msitest");
4481     DeleteFile(msifile);
4482 }
4483
4484 static BOOL add_cabinet_storage(LPCSTR db, LPCSTR cabinet)
4485 {
4486     WCHAR dbW[MAX_PATH], cabinetW[MAX_PATH];
4487     IStorage *stg;
4488     IStream *stm;
4489     HRESULT hr;
4490     HANDLE handle;
4491
4492     MultiByteToWideChar(CP_ACP, 0, db, -1, dbW, MAX_PATH);
4493     hr = StgOpenStorage(dbW, NULL, STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
4494     if (FAILED(hr))
4495         return FALSE;
4496
4497     MultiByteToWideChar(CP_ACP, 0, cabinet, -1, cabinetW, MAX_PATH);
4498     hr = IStorage_CreateStream(stg, cabinetW, STGM_WRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
4499     if (FAILED(hr))
4500     {
4501         IStorage_Release(stg);
4502         return FALSE;
4503     }
4504
4505     handle = CreateFileW(cabinetW, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
4506     if (handle != INVALID_HANDLE_VALUE)
4507     {
4508         DWORD count;
4509         char buffer[1024];
4510         if (ReadFile(handle, buffer, sizeof(buffer), &count, NULL))
4511             IStream_Write(stm, buffer, count, &count);
4512         CloseHandle(handle);
4513     }
4514
4515     IStream_Release(stm);
4516     IStorage_Release(stg);
4517
4518     return TRUE;
4519 }
4520
4521 static void test_lastusedsource(void)
4522 {
4523     static char prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
4524
4525     UINT r;
4526     char value[MAX_PATH], path[MAX_PATH];
4527     DWORD size;
4528
4529     if (!pMsiSourceListGetInfoA)
4530     {
4531         win_skip("MsiSourceListGetInfoA is not available\n");
4532         return;
4533     }
4534
4535     CreateDirectoryA("msitest", NULL);
4536     create_file("maximus", 500);
4537     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4538     DeleteFile("maximus");
4539
4540     create_database("msifile0.msi", lus0_tables, sizeof(lus0_tables) / sizeof(msi_table));
4541     create_database("msifile1.msi", lus1_tables, sizeof(lus1_tables) / sizeof(msi_table));
4542     create_database("msifile2.msi", lus2_tables, sizeof(lus2_tables) / sizeof(msi_table));
4543
4544     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4545
4546     /* no cabinet file */
4547
4548     size = MAX_PATH;
4549     lstrcpyA(value, "aaa");
4550     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4551                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4552     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
4553     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
4554
4555     r = MsiInstallProductA("msifile0.msi", "PUBLISH_PRODUCT=1");
4556     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4557     {
4558         skip("Not enough rights to perform tests\n");
4559         goto error;
4560     }
4561     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4562
4563     lstrcpyA(path, CURR_DIR);
4564     lstrcatA(path, "\\");
4565
4566     size = MAX_PATH;
4567     lstrcpyA(value, "aaa");
4568     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4569                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4571     todo_wine
4572     {
4573     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
4574     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
4575     }
4576
4577     r = MsiInstallProductA("msifile0.msi", "REMOVE=ALL");
4578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4579
4580     /* separate cabinet file */
4581
4582     size = MAX_PATH;
4583     lstrcpyA(value, "aaa");
4584     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4585                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4586     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
4587     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
4588
4589     r = MsiInstallProductA("msifile1.msi", "PUBLISH_PRODUCT=1");
4590     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4591
4592     lstrcpyA(path, CURR_DIR);
4593     lstrcatA(path, "\\");
4594
4595     size = MAX_PATH;
4596     lstrcpyA(value, "aaa");
4597     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4598                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4599     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4600     todo_wine
4601     {
4602     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
4603     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
4604     }
4605
4606     r = MsiInstallProductA("msifile1.msi", "REMOVE=ALL");
4607     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4608
4609     size = MAX_PATH;
4610     lstrcpyA(value, "aaa");
4611     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4612                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4613     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
4614     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
4615
4616     /* embedded cabinet stream */
4617
4618     add_cabinet_storage("msifile2.msi", "test1.cab");
4619
4620     r = MsiInstallProductA("msifile2.msi", "PUBLISH_PRODUCT=1");
4621     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4622
4623     size = MAX_PATH;
4624     lstrcpyA(value, "aaa");
4625     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4626                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4627     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4628     todo_wine
4629     {
4630     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
4631     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
4632     }
4633
4634     r = MsiInstallProductA("msifile2.msi", "REMOVE=ALL");
4635     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4636
4637     size = MAX_PATH;
4638     lstrcpyA(value, "aaa");
4639     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4640                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4641     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
4642     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
4643
4644 error:
4645     /* Delete the files in the temp (current) folder */
4646     delete_cab_files();
4647     DeleteFile("msitest\\maximus");
4648     RemoveDirectory("msitest");
4649     DeleteFile("msifile0.msi");
4650     DeleteFile("msifile1.msi");
4651     DeleteFile("msifile2.msi");
4652 }
4653
4654 static void test_setdirproperty(void)
4655 {
4656     UINT r;
4657
4658     if (is_process_limited())
4659     {
4660         skip("process is limited\n");
4661         return;
4662     }
4663
4664     CreateDirectoryA("msitest", NULL);
4665     create_file("msitest\\maximus", 500);
4666     create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
4667
4668     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4669
4670     r = MsiInstallProductA(msifile, NULL);
4671     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4672     {
4673         skip("Not enough rights to perform tests\n");
4674         goto error;
4675     }
4676     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4677     ok(delete_cf("msitest\\maximus", TRUE), "File not installed\n");
4678     ok(delete_cf("msitest", FALSE), "File not installed\n");
4679
4680 error:
4681     /* Delete the files in the temp (current) folder */
4682     DeleteFile(msifile);
4683     DeleteFile("msitest\\maximus");
4684     RemoveDirectory("msitest");
4685 }
4686
4687 static void test_cabisextracted(void)
4688 {
4689     UINT r;
4690
4691     if (is_process_limited())
4692     {
4693         skip("process is limited\n");
4694         return;
4695     }
4696
4697     CreateDirectoryA("msitest", NULL);
4698     create_file("msitest\\gaius", 500);
4699     create_file("maximus", 500);
4700     create_file("augustus", 500);
4701     create_file("caesar", 500);
4702
4703     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4704     create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
4705     create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
4706
4707     create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
4708
4709     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4710
4711     r = MsiInstallProductA(msifile, NULL);
4712     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4713     {
4714         skip("Not enough rights to perform tests\n");
4715         goto error;
4716     }
4717     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4718     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4719     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4720     ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4721     ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
4722     ok(delete_pf("msitest", FALSE), "File not installed\n");
4723
4724 error:
4725     /* Delete the files in the temp (current) folder */
4726     delete_cab_files();
4727     DeleteFile(msifile);
4728     DeleteFile("maximus");
4729     DeleteFile("augustus");
4730     DeleteFile("caesar");
4731     DeleteFile("msitest\\gaius");
4732     RemoveDirectory("msitest");
4733 }
4734
4735 static void test_concurrentinstall(void)
4736 {
4737     UINT r;
4738     CHAR path[MAX_PATH];
4739
4740     if (is_process_limited())
4741     {
4742         skip("process is limited\n");
4743         return;
4744     }
4745
4746     CreateDirectoryA("msitest", NULL);
4747     CreateDirectoryA("msitest\\msitest", NULL);
4748     create_file("msitest\\maximus", 500);
4749     create_file("msitest\\msitest\\augustus", 500);
4750
4751     create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
4752
4753     lstrcpyA(path, CURR_DIR);
4754     lstrcatA(path, "\\msitest\\concurrent.msi");
4755     create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
4756
4757     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
4758
4759     r = MsiInstallProductA(msifile, NULL);
4760     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4761     {
4762         skip("Not enough rights to perform tests\n");
4763         DeleteFile(path);
4764         goto error;
4765     }
4766     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4767     if (!delete_pf("msitest\\augustus", TRUE))
4768         trace("concurrent installs not supported\n");
4769     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4770     ok(delete_pf("msitest", FALSE), "File not installed\n");
4771
4772     DeleteFile(path);
4773
4774     r = MsiInstallProductA(msifile, NULL);
4775     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4776     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4777     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
4778     ok(delete_pf("msitest", FALSE), "File not installed\n");
4779
4780 error:
4781     DeleteFile(msifile);
4782     DeleteFile("msitest\\msitest\\augustus");
4783     DeleteFile("msitest\\maximus");
4784     RemoveDirectory("msitest\\msitest");
4785     RemoveDirectory("msitest");
4786 }
4787
4788 static void test_setpropertyfolder(void)
4789 {
4790     UINT r;
4791     CHAR path[MAX_PATH];
4792     DWORD attr;
4793
4794     if (is_process_limited())
4795     {
4796         skip("process is limited\n");
4797         return;
4798     }
4799
4800     lstrcpyA(path, PROG_FILES_DIR);
4801     lstrcatA(path, "\\msitest\\added");
4802
4803     CreateDirectoryA("msitest", NULL);
4804     create_file("msitest\\maximus", 500);
4805
4806     create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
4807
4808     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
4809
4810     r = MsiInstallProductA(msifile, NULL);
4811     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4812     {
4813         skip("Not enough rights to perform tests\n");
4814         goto error;
4815     }
4816     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4817     attr = GetFileAttributesA(path);
4818     if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
4819     {
4820         ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
4821         ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
4822         ok(delete_pf("msitest", FALSE), "File not installed\n");
4823     }
4824     else
4825     {
4826         trace("changing folder property not supported\n");
4827         ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4828         ok(delete_pf("msitest", FALSE), "File not installed\n");
4829     }
4830
4831 error:
4832     /* Delete the files in the temp (current) folder */
4833     DeleteFile(msifile);
4834     DeleteFile("msitest\\maximus");
4835     RemoveDirectory("msitest");
4836 }
4837
4838 static BOOL file_exists(LPCSTR file)
4839 {
4840     return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
4841 }
4842
4843 static BOOL pf_exists(LPCSTR file)
4844 {
4845     CHAR path[MAX_PATH];
4846
4847     lstrcpyA(path, PROG_FILES_DIR);
4848     lstrcatA(path, "\\");
4849     lstrcatA(path, file);
4850
4851     return file_exists(path);
4852 }
4853
4854 static void delete_pfmsitest_files(void)
4855 {
4856     SHFILEOPSTRUCT shfl;
4857     CHAR path[MAX_PATH+11];
4858
4859     lstrcpyA(path, PROG_FILES_DIR);
4860     lstrcatA(path, "\\msitest\\*");
4861     path[strlen(path) + 1] = '\0';
4862
4863     shfl.hwnd = NULL;
4864     shfl.wFunc = FO_DELETE;
4865     shfl.pFrom = path;
4866     shfl.pTo = NULL;
4867     shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
4868
4869     SHFileOperation(&shfl);
4870
4871     lstrcpyA(path, PROG_FILES_DIR);
4872     lstrcatA(path, "\\msitest");
4873     RemoveDirectoryA(path);
4874 }
4875
4876 static void check_reg_str(HKEY prodkey, LPCSTR name, LPCSTR expected, BOOL bcase, DWORD line)
4877 {
4878     char val[MAX_PATH];
4879     DWORD size, type;
4880     LONG res;
4881
4882     size = MAX_PATH;
4883     val[0] = '\0';
4884     res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)val, &size);
4885
4886     if (res != ERROR_SUCCESS ||
4887         (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_MULTI_SZ))
4888     {
4889         ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
4890         return;
4891     }
4892
4893     if (!expected)
4894         ok_(__FILE__, line)(lstrlenA(val) == 0, "Expected empty string, got %s\n", val);
4895     else
4896     {
4897         if (bcase)
4898             ok_(__FILE__, line)(!lstrcmpA(val, expected), "Expected %s, got %s\n", expected, val);
4899         else
4900             ok_(__FILE__, line)(!lstrcmpiA(val, expected), "Expected %s, got %s\n", expected, val);
4901     }
4902 }
4903
4904 static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD expected, DWORD line)
4905 {
4906     DWORD val, size, type;
4907     LONG res;
4908
4909     size = sizeof(DWORD);
4910     res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
4911
4912     if (res != ERROR_SUCCESS || type != REG_DWORD)
4913     {
4914         ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
4915         return;
4916     }
4917
4918     ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected, val);
4919 }
4920
4921 static void check_reg_dword2(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD expected2, DWORD line)
4922 {
4923     DWORD val, size, type;
4924     LONG res;
4925
4926     size = sizeof(DWORD);
4927     res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
4928
4929     if (res != ERROR_SUCCESS || type != REG_DWORD)
4930     {
4931         ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
4932         return;
4933     }
4934
4935     ok_(__FILE__, line)(val == expected1 || val == expected2, "Expected %d or %d, got %d\n", expected1, expected2, val);
4936 }
4937
4938 static void check_reg_dword3(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD expected2, DWORD expected3, DWORD line)
4939 {
4940     DWORD val, size, type;
4941     LONG res;
4942
4943     size = sizeof(DWORD);
4944     res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
4945
4946     if (res != ERROR_SUCCESS || type != REG_DWORD)
4947     {
4948         ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
4949         return;
4950     }
4951
4952     ok_(__FILE__, line)(val == expected1 || val == expected2 || val == expected3,
4953                         "Expected %d, %d or %d, got %d\n", expected1, expected2, expected3, val);
4954 }
4955
4956 #define CHECK_REG_STR(prodkey, name, expected) \
4957     check_reg_str(prodkey, name, expected, TRUE, __LINE__);
4958
4959 #define CHECK_DEL_REG_STR(prodkey, name, expected) \
4960     check_reg_str(prodkey, name, expected, TRUE, __LINE__); \
4961     RegDeleteValueA(prodkey, name);
4962
4963 #define CHECK_REG_ISTR(prodkey, name, expected) \
4964     check_reg_str(prodkey, name, expected, FALSE, __LINE__);
4965
4966 #define CHECK_DEL_REG_ISTR(prodkey, name, expected) \
4967     check_reg_str(prodkey, name, expected, FALSE, __LINE__); \
4968     RegDeleteValueA(prodkey, name);
4969
4970 #define CHECK_REG_DWORD(prodkey, name, expected) \
4971     check_reg_dword(prodkey, name, expected, __LINE__);
4972
4973 #define CHECK_DEL_REG_DWORD(prodkey, name, expected) \
4974     check_reg_dword(prodkey, name, expected, __LINE__); \
4975     RegDeleteValueA(prodkey, name);
4976
4977 #define CHECK_REG_DWORD2(prodkey, name, expected1, expected2) \
4978     check_reg_dword2(prodkey, name, expected1, expected2, __LINE__);
4979
4980 #define CHECK_DEL_REG_DWORD2(prodkey, name, expected1, expected2) \
4981     check_reg_dword2(prodkey, name, expected1, expected2, __LINE__); \
4982     RegDeleteValueA(prodkey, name);
4983
4984 #define CHECK_REG_DWORD3(prodkey, name, expected1, expected2, expected3) \
4985     check_reg_dword3(prodkey, name, expected1, expected2, expected3, __LINE__);
4986
4987 #define CHECK_DEL_REG_DWORD3(prodkey, name, expected1, expected2, expected3) \
4988     check_reg_dword3(prodkey, name, expected1, expected2, expected3, __LINE__); \
4989     RegDeleteValueA(prodkey, name);
4990
4991 static void get_date_str(LPSTR date)
4992 {
4993     SYSTEMTIME systime;
4994
4995     static const char date_fmt[] = "%d%02d%02d";
4996     GetLocalTime(&systime);
4997     sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
4998 }
4999
5000 static void test_publish_registerproduct(void)
5001 {
5002     UINT r;
5003     LONG res;
5004     HKEY hkey;
5005     HKEY props, usage;
5006     LPSTR usersid;
5007     char date[MAX_PATH];
5008     char temp[MAX_PATH];
5009     char keypath[MAX_PATH];
5010     REGSAM access = KEY_ALL_ACCESS;
5011     BOOL wow64;
5012
5013     static const CHAR uninstall[] = "Software\\Microsoft\\Windows\\CurrentVersion"
5014                                     "\\Uninstall\\{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
5015     static const CHAR userdata[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Installer"
5016                                    "\\UserData\\%s\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5017     static const CHAR ugkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Installer"
5018                                 "\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2";
5019     static const CHAR userugkey[] = "Software\\Microsoft\\Installer\\UpgradeCodes"
5020                                     "\\51AAE0C44620A5E4788506E91F249BD2";
5021
5022     if (is_process_limited())
5023     {
5024         skip("process is limited\n");
5025         return;
5026     }
5027
5028     if (!get_user_sid(&usersid))
5029         return;
5030
5031     get_date_str(date);
5032     GetTempPath(MAX_PATH, temp);
5033
5034     CreateDirectoryA("msitest", NULL);
5035     create_file("msitest\\maximus", 500);
5036
5037     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5038
5039     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
5040         access |= KEY_WOW64_64KEY;
5041
5042     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5043
5044     /* RegisterProduct */
5045     r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
5046     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5047     {
5048         skip("Not enough rights to perform tests\n");
5049         goto error;
5050     }
5051     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5052     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5053     ok(delete_pf("msitest", FALSE), "File not installed\n");
5054
5055     res = RegOpenKeyA(HKEY_CURRENT_USER, userugkey, &hkey);
5056     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5057
5058     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, uninstall, 0, access, &hkey);
5059     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5060
5061     CHECK_DEL_REG_STR(hkey, "DisplayName", "MSITEST");
5062     CHECK_DEL_REG_STR(hkey, "DisplayVersion", "1.1.1");
5063     CHECK_DEL_REG_STR(hkey, "InstallDate", date);
5064     CHECK_DEL_REG_STR(hkey, "InstallSource", temp);
5065     CHECK_DEL_REG_ISTR(hkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5066     CHECK_DEL_REG_STR(hkey, "Publisher", "Wine");
5067     CHECK_DEL_REG_STR(hkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5068     CHECK_DEL_REG_STR(hkey, "AuthorizedCDFPrefix", NULL);
5069     CHECK_DEL_REG_STR(hkey, "Comments", NULL);
5070     CHECK_DEL_REG_STR(hkey, "Contact", NULL);
5071     CHECK_DEL_REG_STR(hkey, "HelpLink", NULL);
5072     CHECK_DEL_REG_STR(hkey, "HelpTelephone", NULL);
5073     CHECK_DEL_REG_STR(hkey, "InstallLocation", NULL);
5074     CHECK_DEL_REG_STR(hkey, "Readme", NULL);
5075     CHECK_DEL_REG_STR(hkey, "Size", NULL);
5076     CHECK_DEL_REG_STR(hkey, "URLInfoAbout", NULL);
5077     CHECK_DEL_REG_STR(hkey, "URLUpdateInfo", NULL);
5078     CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
5079     CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
5080     CHECK_DEL_REG_DWORD(hkey, "VersionMajor", 1);
5081     CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
5082     CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
5083     todo_wine
5084     {
5085         CHECK_DEL_REG_DWORD3(hkey, "EstimatedSize", 12, -12, 4);
5086     }
5087
5088     delete_key(hkey, "", access);
5089     RegCloseKey(hkey);
5090
5091     sprintf(keypath, userdata, usersid);
5092     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey);
5093     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5094
5095     res = RegOpenKeyExA(hkey, "InstallProperties", 0, access, &props);
5096     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5097
5098     RegDeleteValueA(props, "LocalPackage"); /* LocalPackage is nondeterministic */
5099     CHECK_DEL_REG_STR(props, "DisplayName", "MSITEST");
5100     CHECK_DEL_REG_STR(props, "DisplayVersion", "1.1.1");
5101     CHECK_DEL_REG_STR(props, "InstallDate", date);
5102     CHECK_DEL_REG_STR(props, "InstallSource", temp);
5103     CHECK_DEL_REG_ISTR(props, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5104     CHECK_DEL_REG_STR(props, "Publisher", "Wine");
5105     CHECK_DEL_REG_STR(props, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5106     CHECK_DEL_REG_STR(props, "AuthorizedCDFPrefix", NULL);
5107     CHECK_DEL_REG_STR(props, "Comments", NULL);
5108     CHECK_DEL_REG_STR(props, "Contact", NULL);
5109     CHECK_DEL_REG_STR(props, "HelpLink", NULL);
5110     CHECK_DEL_REG_STR(props, "HelpTelephone", NULL);
5111     CHECK_DEL_REG_STR(props, "InstallLocation", NULL);
5112     CHECK_DEL_REG_STR(props, "Readme", NULL);
5113     CHECK_DEL_REG_STR(props, "Size", NULL);
5114     CHECK_DEL_REG_STR(props, "URLInfoAbout", NULL);
5115     CHECK_DEL_REG_STR(props, "URLUpdateInfo", NULL);
5116     CHECK_DEL_REG_DWORD(props, "Language", 1033);
5117     CHECK_DEL_REG_DWORD(props, "Version", 0x1010001);
5118     CHECK_DEL_REG_DWORD(props, "VersionMajor", 1);
5119     CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
5120     CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
5121     todo_wine
5122     {
5123         CHECK_DEL_REG_DWORD3(props, "EstimatedSize", 12, -12, 4);
5124     }
5125
5126     delete_key(props, "", access);
5127     RegCloseKey(props);
5128
5129     res = RegOpenKeyExA(hkey, "Usage", 0, access, &usage);
5130     todo_wine
5131     {
5132         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5133     }
5134
5135     delete_key(usage, "", access);
5136     RegCloseKey(usage);
5137     delete_key(hkey, "", access);
5138     RegCloseKey(hkey);
5139
5140     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, ugkey, 0, access, &hkey);
5141     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5142
5143     CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
5144
5145     delete_key(hkey, "", access);
5146     RegCloseKey(hkey);
5147
5148     /* RegisterProduct, machine */
5149     r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 ALLUSERS=1");
5150     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5151     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5152     ok(delete_pf("msitest", FALSE), "File not installed\n");
5153
5154     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, userugkey, 0, access, &hkey);
5155     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5156
5157     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, uninstall, 0, access, &hkey);
5158     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5159
5160     CHECK_DEL_REG_STR(hkey, "DisplayName", "MSITEST");
5161     CHECK_DEL_REG_STR(hkey, "DisplayVersion", "1.1.1");
5162     CHECK_DEL_REG_STR(hkey, "InstallDate", date);
5163     CHECK_DEL_REG_STR(hkey, "InstallSource", temp);
5164     CHECK_DEL_REG_ISTR(hkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5165     CHECK_DEL_REG_STR(hkey, "Publisher", "Wine");
5166     CHECK_DEL_REG_STR(hkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5167     CHECK_DEL_REG_STR(hkey, "AuthorizedCDFPrefix", NULL);
5168     CHECK_DEL_REG_STR(hkey, "Comments", NULL);
5169     CHECK_DEL_REG_STR(hkey, "Contact", NULL);
5170     CHECK_DEL_REG_STR(hkey, "HelpLink", NULL);
5171     CHECK_DEL_REG_STR(hkey, "HelpTelephone", NULL);
5172     CHECK_DEL_REG_STR(hkey, "InstallLocation", NULL);
5173     CHECK_DEL_REG_STR(hkey, "Readme", NULL);
5174     CHECK_DEL_REG_STR(hkey, "Size", NULL);
5175     CHECK_DEL_REG_STR(hkey, "URLInfoAbout", NULL);
5176     CHECK_DEL_REG_STR(hkey, "URLUpdateInfo", NULL);
5177     CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
5178     CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
5179     CHECK_DEL_REG_DWORD(hkey, "VersionMajor", 1);
5180     CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
5181     CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
5182     todo_wine
5183     {
5184         CHECK_DEL_REG_DWORD3(hkey, "EstimatedSize", 12, -12, 4);
5185     }
5186
5187     delete_key(hkey, "", access);
5188     RegCloseKey(hkey);
5189
5190     sprintf(keypath, userdata, "S-1-5-18");
5191     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey);
5192     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5193
5194     res = RegOpenKeyExA(hkey, "InstallProperties", 0, access, &props);
5195     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5196
5197     RegDeleteValueA(props, "LocalPackage"); /* LocalPackage is nondeterministic */
5198     CHECK_DEL_REG_STR(props, "DisplayName", "MSITEST");
5199     CHECK_DEL_REG_STR(props, "DisplayVersion", "1.1.1");
5200     CHECK_DEL_REG_STR(props, "InstallDate", date);
5201     CHECK_DEL_REG_STR(props, "InstallSource", temp);
5202     CHECK_DEL_REG_ISTR(props, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5203     CHECK_DEL_REG_STR(props, "Publisher", "Wine");
5204     CHECK_DEL_REG_STR(props, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5205     CHECK_DEL_REG_STR(props, "AuthorizedCDFPrefix", NULL);
5206     CHECK_DEL_REG_STR(props, "Comments", NULL);
5207     CHECK_DEL_REG_STR(props, "Contact", NULL);
5208     CHECK_DEL_REG_STR(props, "HelpLink", NULL);
5209     CHECK_DEL_REG_STR(props, "HelpTelephone", NULL);
5210     CHECK_DEL_REG_STR(props, "InstallLocation", NULL);
5211     CHECK_DEL_REG_STR(props, "Readme", NULL);
5212     CHECK_DEL_REG_STR(props, "Size", NULL);
5213     CHECK_DEL_REG_STR(props, "URLInfoAbout", NULL);
5214     CHECK_DEL_REG_STR(props, "URLUpdateInfo", NULL);
5215     CHECK_DEL_REG_DWORD(props, "Language", 1033);
5216     CHECK_DEL_REG_DWORD(props, "Version", 0x1010001);
5217     CHECK_DEL_REG_DWORD(props, "VersionMajor", 1);
5218     CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
5219     CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
5220     todo_wine
5221     {
5222         CHECK_DEL_REG_DWORD3(props, "EstimatedSize", 12, -12, 4);
5223     }
5224
5225     delete_key(props, "", access);
5226     RegCloseKey(props);
5227
5228     res = RegOpenKeyExA(hkey, "Usage", 0, access, &usage);
5229     todo_wine
5230     {
5231         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5232     }
5233
5234     delete_key(usage, "", access);
5235     RegCloseKey(usage);
5236     delete_key(hkey, "", access);
5237     RegCloseKey(hkey);
5238
5239     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, ugkey, 0, access, &hkey);
5240     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5241
5242     CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
5243
5244     delete_key(hkey, "", access);
5245     RegCloseKey(hkey);
5246
5247 error:
5248     DeleteFile(msifile);
5249     DeleteFile("msitest\\maximus");
5250     RemoveDirectory("msitest");
5251     HeapFree(GetProcessHeap(), 0, usersid);
5252 }
5253
5254 static void test_publish_publishproduct(void)
5255 {
5256     UINT r;
5257     LONG res;
5258     LPSTR usersid;
5259     HKEY sourcelist, net, props;
5260     HKEY hkey, patches, media;
5261     CHAR keypath[MAX_PATH];
5262     CHAR temp[MAX_PATH];
5263     CHAR path[MAX_PATH];
5264     BOOL wow64, old_installer = FALSE;
5265     REGSAM access = KEY_ALL_ACCESS;
5266
5267     static const CHAR prodpath[] = "Software\\Microsoft\\Windows\\CurrentVersion"
5268                                    "\\Installer\\UserData\\%s\\Products"
5269                                    "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5270     static const CHAR cuprodpath[] = "Software\\Microsoft\\Installer\\Products"
5271                                      "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5272     static const CHAR cuupgrades[] = "Software\\Microsoft\\Installer\\UpgradeCodes"
5273                                      "\\51AAE0C44620A5E4788506E91F249BD2";
5274     static const CHAR badprod[] = "Software\\Microsoft\\Windows\\CurrentVersion"
5275                                   "\\Installer\\Products"
5276                                   "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5277     static const CHAR machprod[] = "Installer\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5278     static const CHAR machup[] = "Installer\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2";
5279
5280     if (is_process_limited())
5281     {
5282         skip("process is limited\n");
5283         return;
5284     }
5285
5286     if (!get_user_sid(&usersid))
5287         return;
5288
5289     GetTempPath(MAX_PATH, temp);
5290
5291     CreateDirectoryA("msitest", NULL);
5292     create_file("msitest\\maximus", 500);
5293
5294     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5295
5296     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
5297         access |= KEY_WOW64_64KEY;
5298
5299     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5300
5301     /* PublishProduct, current user */
5302     r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
5303     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5304     {
5305         skip("Not enough rights to perform tests\n");
5306         goto error;
5307     }
5308     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5309     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5310     ok(delete_pf("msitest", FALSE), "File not installed\n");
5311
5312     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, badprod, 0, access, &hkey);
5313     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5314
5315     sprintf(keypath, prodpath, usersid);
5316     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey);
5317     if (res == ERROR_FILE_NOT_FOUND)
5318     {
5319         res = RegOpenKeyA(HKEY_CURRENT_USER, cuprodpath, &hkey);
5320         if (res == ERROR_SUCCESS)
5321         {
5322             win_skip("Windows Installer < 3.0 detected\n");
5323             RegCloseKey(hkey);
5324             old_installer = TRUE;
5325             goto currentuser;
5326         }
5327         else
5328         {
5329             win_skip("Install failed, no need to continue\n");
5330             return;
5331         }
5332     }
5333     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5334
5335     res = RegOpenKeyExA(hkey, "InstallProperties", 0, access, &props);
5336     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5337
5338     res = RegOpenKeyExA(hkey, "Patches", 0, access, &patches);
5339     todo_wine
5340     {
5341         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5342         CHECK_DEL_REG_STR(patches, "AllPatches", NULL);
5343     }
5344
5345     delete_key(patches, "", access);
5346     RegCloseKey(patches);
5347     delete_key(hkey, "", access);
5348     RegCloseKey(hkey);
5349
5350 currentuser:
5351     res = RegOpenKeyA(HKEY_CURRENT_USER, cuprodpath, &hkey);
5352     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5353
5354     CHECK_DEL_REG_STR(hkey, "ProductName", "MSITEST");
5355     CHECK_DEL_REG_STR(hkey, "PackageCode", "AC75740029052c94DA02821EECD05F2F");
5356     CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
5357     CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
5358     if (!old_installer)
5359         CHECK_DEL_REG_DWORD(hkey, "AuthorizedLUAApp", 0);
5360     CHECK_DEL_REG_DWORD(hkey, "Assignment", 0);
5361     CHECK_DEL_REG_DWORD(hkey, "AdvertiseFlags", 0x184);
5362     CHECK_DEL_REG_DWORD(hkey, "InstanceType", 0);
5363     CHECK_DEL_REG_STR(hkey, "Clients", ":");
5364
5365     res = RegOpenKeyA(hkey, "SourceList", &sourcelist);
5366     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5367
5368     lstrcpyA(path, "n;1;");
5369     lstrcatA(path, temp);
5370     CHECK_DEL_REG_STR(sourcelist, "LastUsedSource", path);
5371     CHECK_DEL_REG_STR(sourcelist, "PackageName", "msitest.msi");
5372
5373     res = RegOpenKeyA(sourcelist, "Net", &net);
5374     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5375
5376     CHECK_DEL_REG_STR(net, "1", temp);
5377
5378     RegDeleteKeyA(net, "");
5379     RegCloseKey(net);
5380
5381     res = RegOpenKeyA(sourcelist, "Media", &media);
5382     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5383
5384     CHECK_DEL_REG_STR(media, "1", "DISK1;");
5385
5386     RegDeleteKeyA(media, "");
5387     RegCloseKey(media);
5388     RegDeleteKeyA(sourcelist, "");
5389     RegCloseKey(sourcelist);
5390     RegDeleteKeyA(hkey, "");
5391     RegCloseKey(hkey);
5392
5393     res = RegOpenKeyA(HKEY_CURRENT_USER, cuupgrades, &hkey);
5394     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5395
5396     CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
5397
5398     RegDeleteKeyA(hkey, "");
5399     RegCloseKey(hkey);
5400
5401     /* PublishProduct, machine */
5402     r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1 ALLUSERS=1");
5403     if (old_installer)
5404         goto machprod;
5405     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5406     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5407     ok(delete_pf("msitest", FALSE), "File not installed\n");
5408
5409     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, badprod, 0, access, &hkey);
5410     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5411
5412     sprintf(keypath, prodpath, "S-1-5-18");
5413     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey);
5414     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5415
5416     res = RegOpenKeyExA(hkey, "InstallProperties", 0, access, &props);
5417     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5418
5419     res = RegOpenKeyExA(hkey, "Patches", 0, access, &patches);
5420     todo_wine
5421     {
5422         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5423         CHECK_DEL_REG_STR(patches, "AllPatches", NULL);
5424     }
5425
5426     delete_key(patches, "", access);
5427     RegCloseKey(patches);
5428     delete_key(hkey, "", access);
5429     RegCloseKey(hkey);
5430
5431 machprod:
5432     res = RegOpenKeyA(HKEY_CLASSES_ROOT, machprod, &hkey);
5433     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5434
5435     CHECK_DEL_REG_STR(hkey, "ProductName", "MSITEST");
5436     CHECK_DEL_REG_STR(hkey, "PackageCode", "AC75740029052c94DA02821EECD05F2F");
5437     CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
5438     CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
5439     if (!old_installer)
5440         CHECK_DEL_REG_DWORD(hkey, "AuthorizedLUAApp", 0);
5441     todo_wine CHECK_DEL_REG_DWORD(hkey, "Assignment", 1);
5442     CHECK_DEL_REG_DWORD(hkey, "AdvertiseFlags", 0x184);
5443     CHECK_DEL_REG_DWORD(hkey, "InstanceType", 0);
5444     CHECK_DEL_REG_STR(hkey, "Clients", ":");
5445
5446     res = RegOpenKeyA(hkey, "SourceList", &sourcelist);
5447     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5448
5449     lstrcpyA(path, "n;1;");
5450     lstrcatA(path, temp);
5451     CHECK_DEL_REG_STR(sourcelist, "LastUsedSource", path);
5452     CHECK_DEL_REG_STR(sourcelist, "PackageName", "msitest.msi");
5453
5454     res = RegOpenKeyA(sourcelist, "Net", &net);
5455     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5456
5457     CHECK_DEL_REG_STR(net, "1", temp);
5458
5459     RegDeleteKeyA(net, "");
5460     RegCloseKey(net);
5461
5462     res = RegOpenKeyA(sourcelist, "Media", &media);
5463     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5464
5465     CHECK_DEL_REG_STR(media, "1", "DISK1;");
5466
5467     RegDeleteKeyA(media, "");
5468     RegCloseKey(media);
5469     RegDeleteKeyA(sourcelist, "");
5470     RegCloseKey(sourcelist);
5471     RegDeleteKeyA(hkey, "");
5472     RegCloseKey(hkey);
5473
5474     res = RegOpenKeyA(HKEY_CLASSES_ROOT, machup, &hkey);
5475     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5476
5477     CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
5478
5479     RegDeleteKeyA(hkey, "");
5480     RegCloseKey(hkey);
5481
5482 error:
5483     DeleteFile(msifile);
5484     DeleteFile("msitest\\maximus");
5485     RemoveDirectory("msitest");
5486     HeapFree(GetProcessHeap(), 0, usersid);
5487 }
5488
5489 static void test_publish_publishfeatures(void)
5490 {
5491     UINT r;
5492     LONG res;
5493     HKEY hkey;
5494     LPSTR usersid;
5495     CHAR keypath[MAX_PATH];
5496     REGSAM access = KEY_ALL_ACCESS;
5497     BOOL wow64;
5498
5499     static const CHAR cupath[] = "Software\\Microsoft\\Installer\\Features"
5500                                  "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5501     static const CHAR udpath[] = "Software\\Microsoft\\Windows\\CurrentVersion"
5502                                  "\\Installer\\UserData\\%s\\Products"
5503                                  "\\84A88FD7F6998CE40A22FB59F6B9C2BB\\Features";
5504     static const CHAR featkey[] = "Software\\Microsoft\\Windows\\CurrentVersion"
5505                                   "\\Installer\\Features";
5506     static const CHAR classfeat[] = "Software\\Classes\\Installer\\Features"
5507                                     "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5508
5509     if (is_process_limited())
5510     {
5511         skip("process is limited\n");
5512         return;
5513     }
5514
5515     if (!get_user_sid(&usersid))
5516         return;
5517
5518     CreateDirectoryA("msitest", NULL);
5519     create_file("msitest\\maximus", 500);
5520
5521     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5522
5523     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
5524         access |= KEY_WOW64_64KEY;
5525
5526     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5527
5528     /* PublishFeatures, current user */
5529     r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
5530     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5531     {
5532         skip("Not enough rights to perform tests\n");
5533         goto error;
5534     }
5535     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5536     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5537     ok(delete_pf("msitest", FALSE), "File not installed\n");
5538
5539     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, featkey, 0, access, &hkey);
5540     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5541
5542     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, classfeat, 0, access, &hkey);
5543     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5544
5545     res = RegOpenKeyA(HKEY_CURRENT_USER, cupath, &hkey);
5546     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5547
5548     CHECK_REG_STR(hkey, "feature", "");
5549     CHECK_REG_STR(hkey, "montecristo", "");
5550
5551     RegDeleteValueA(hkey, "feature");
5552     RegDeleteValueA(hkey, "montecristo");
5553     RegDeleteKeyA(hkey, "");
5554     RegCloseKey(hkey);
5555
5556     sprintf(keypath, udpath, usersid);
5557     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
5558     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5559
5560     CHECK_REG_STR(hkey, "feature", "VGtfp^p+,?82@JU1j_KE");
5561     CHECK_REG_STR(hkey, "montecristo", "VGtfp^p+,?82@JU1j_KE");
5562
5563     RegDeleteValueA(hkey, "feature");
5564     RegDeleteValueA(hkey, "montecristo");
5565     RegDeleteKeyA(hkey, "");
5566     RegCloseKey(hkey);
5567
5568     /* PublishFeatures, machine */
5569     r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1 ALLUSERS=1");
5570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5571     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5572     ok(delete_pf("msitest", FALSE), "File not installed\n");
5573
5574     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, featkey, 0, access, &hkey);
5575     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5576
5577     res = RegOpenKeyA(HKEY_CURRENT_USER, cupath, &hkey);
5578     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5579
5580     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, classfeat, &hkey);
5581     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5582
5583     CHECK_REG_STR(hkey, "feature", "");
5584     CHECK_REG_STR(hkey, "montecristo", "");
5585
5586     RegDeleteValueA(hkey, "feature");
5587     RegDeleteValueA(hkey, "montecristo");
5588     RegDeleteKeyA(hkey, "");
5589     RegCloseKey(hkey);
5590
5591     sprintf(keypath, udpath, "S-1-5-18");
5592     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
5593     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5594
5595     CHECK_REG_STR(hkey, "feature", "VGtfp^p+,?82@JU1j_KE");
5596     CHECK_REG_STR(hkey, "montecristo", "VGtfp^p+,?82@JU1j_KE");
5597
5598     RegDeleteValueA(hkey, "feature");
5599     RegDeleteValueA(hkey, "montecristo");
5600     RegDeleteKeyA(hkey, "");
5601     RegCloseKey(hkey);
5602
5603 error:
5604     DeleteFile(msifile);
5605     DeleteFile("msitest\\maximus");
5606     RemoveDirectory("msitest");
5607     HeapFree(GetProcessHeap(), 0, usersid);
5608 }
5609
5610 static LPSTR reg_get_val_str(HKEY hkey, LPCSTR name)
5611 {
5612     DWORD len = 0;
5613     LPSTR val;
5614     LONG r;
5615
5616     r = RegQueryValueExA(hkey, name, NULL, NULL, NULL, &len);
5617     if (r != ERROR_SUCCESS)
5618         return NULL;
5619
5620     len += sizeof (WCHAR);
5621     val = HeapAlloc(GetProcessHeap(), 0, len);
5622     if (!val) return NULL;
5623     val[0] = 0;
5624     RegQueryValueExA(hkey, name, NULL, NULL, (LPBYTE)val, &len);
5625     return val;
5626 }
5627
5628 static void get_owner_company(LPSTR *owner, LPSTR *company)
5629 {
5630     LONG res;
5631     HKEY hkey;
5632     REGSAM access = KEY_ALL_ACCESS;
5633     BOOL wow64;
5634
5635     *owner = *company = NULL;
5636
5637     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
5638         access |= KEY_WOW64_64KEY;
5639
5640     res = RegOpenKeyA(HKEY_CURRENT_USER,
5641                       "Software\\Microsoft\\MS Setup (ACME)\\User Info", &hkey);
5642     if (res == ERROR_SUCCESS)
5643     {
5644         *owner = reg_get_val_str(hkey, "DefName");
5645         *company = reg_get_val_str(hkey, "DefCompany");
5646         RegCloseKey(hkey);
5647     }
5648
5649     if (!*owner || !*company)
5650     {
5651         res = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
5652                             "Software\\Microsoft\\Windows\\CurrentVersion", 0, access, &hkey);
5653         if (res == ERROR_SUCCESS)
5654         {
5655             *owner = reg_get_val_str(hkey, "RegisteredOwner");
5656             *company = reg_get_val_str(hkey, "RegisteredOrganization");
5657             RegCloseKey(hkey);
5658         }
5659     }
5660
5661     if (!*owner || !*company)
5662     {
5663         res = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
5664                             "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey);
5665         if (res == ERROR_SUCCESS)
5666         {
5667             *owner = reg_get_val_str(hkey, "RegisteredOwner");
5668             *company = reg_get_val_str(hkey, "RegisteredOrganization");
5669             RegCloseKey(hkey);
5670         }
5671     }
5672 }
5673
5674 static void test_publish_registeruser(void)
5675 {
5676     UINT r;
5677     LONG res;
5678     HKEY props;
5679     LPSTR usersid;
5680     LPSTR owner, company;
5681     CHAR keypath[MAX_PATH];
5682     REGSAM access = KEY_ALL_ACCESS;
5683     BOOL wow64;
5684
5685     static const CHAR keyfmt[] =
5686         "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\"
5687         "UserData\\%s\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB\\InstallProperties";
5688
5689     if (is_process_limited())
5690     {
5691         skip("process is limited\n");
5692         return;
5693     }
5694
5695     if (!get_user_sid(&usersid))
5696         return;
5697
5698     get_owner_company(&owner, &company);
5699
5700     CreateDirectoryA("msitest", NULL);
5701     create_file("msitest\\maximus", 500);
5702
5703     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5704
5705     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
5706         access |= KEY_WOW64_64KEY;
5707
5708     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5709
5710     /* RegisterUser, per-user */
5711     r = MsiInstallProductA(msifile, "REGISTER_USER=1");
5712     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5713     {
5714         skip("Not enough rights to perform tests\n");
5715         goto error;
5716     }
5717     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5718     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5719     ok(delete_pf("msitest", FALSE), "File not installed\n");
5720
5721     sprintf(keypath, keyfmt, usersid);
5722     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
5723     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5724
5725     CHECK_REG_STR(props, "ProductID", "none");
5726     CHECK_REG_STR(props, "RegCompany", company);
5727     CHECK_REG_STR(props, "RegOwner", owner);
5728
5729     RegDeleteValueA(props, "ProductID");
5730     RegDeleteValueA(props, "RegCompany");
5731     RegDeleteValueA(props, "RegOwner");
5732     delete_key(props, "", access);
5733     RegCloseKey(props);
5734
5735     /* RegisterUser, machine */
5736     r = MsiInstallProductA(msifile, "REGISTER_USER=1 ALLUSERS=1");
5737     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5738     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5739     ok(delete_pf("msitest", FALSE), "File not installed\n");
5740
5741     sprintf(keypath, keyfmt, "S-1-5-18");
5742     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
5743     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5744
5745     CHECK_REG_STR(props, "ProductID", "none");
5746     CHECK_REG_STR(props, "RegCompany", company);
5747     CHECK_REG_STR(props, "RegOwner", owner);
5748
5749     RegDeleteValueA(props, "ProductID");
5750     RegDeleteValueA(props, "RegCompany");
5751     RegDeleteValueA(props, "RegOwner");
5752     delete_key(props, "", access);
5753     RegCloseKey(props);
5754
5755 error:
5756     HeapFree(GetProcessHeap(), 0, company);
5757     HeapFree(GetProcessHeap(), 0, owner);
5758
5759     DeleteFile(msifile);
5760     DeleteFile("msitest\\maximus");
5761     RemoveDirectory("msitest");
5762     LocalFree(usersid);
5763 }
5764
5765 static void test_publish_processcomponents(void)
5766 {
5767     UINT r;
5768     LONG res;
5769     DWORD size;
5770     HKEY comp, hkey;
5771     LPSTR usersid;
5772     CHAR val[MAX_PATH];
5773     CHAR keypath[MAX_PATH];
5774     CHAR program_files_maximus[MAX_PATH];
5775     REGSAM access = KEY_ALL_ACCESS;
5776     BOOL wow64;
5777
5778     static const CHAR keyfmt[] =
5779         "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\"
5780         "UserData\\%s\\Components\\%s";
5781     static const CHAR compkey[] =
5782         "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Components";
5783
5784     if (is_process_limited())
5785     {
5786         skip("process is limited\n");
5787         return;
5788     }
5789
5790     if (!get_user_sid(&usersid))
5791         return;
5792
5793     CreateDirectoryA("msitest", NULL);
5794     create_file("msitest\\maximus", 500);
5795
5796     create_database(msifile, ppc_tables, sizeof(ppc_tables) / sizeof(msi_table));
5797
5798     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
5799         access |= KEY_WOW64_64KEY;
5800
5801     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5802
5803     /* ProcessComponents, per-user */
5804     r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
5805     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5806     {
5807         skip("Not enough rights to perform tests\n");
5808         goto error;
5809     }
5810     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5811     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5812     ok(delete_pf("msitest", FALSE), "File not installed\n");
5813
5814     sprintf(keypath, keyfmt, usersid, "CBABC2FDCCB35E749A8944D8C1C098B5");
5815     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &comp);
5816     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5817
5818     size = MAX_PATH;
5819     res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
5820                            NULL, NULL, (LPBYTE)val, &size);
5821     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5822
5823     lstrcpyA(program_files_maximus,PROG_FILES_DIR);
5824     lstrcatA(program_files_maximus,"\\msitest\\maximus");
5825
5826     ok(!lstrcmpiA(val, program_files_maximus),
5827        "Expected \"%s\", got \"%s\"\n", program_files_maximus, val);
5828
5829     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, compkey, 0, access, &hkey);
5830     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5831
5832     RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
5833     delete_key(comp, "", access);
5834     RegCloseKey(comp);
5835
5836     sprintf(keypath, keyfmt, usersid, "241C3DA58FECD0945B9687D408766058");
5837     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &comp);
5838     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5839
5840     size = MAX_PATH;
5841     res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
5842                            NULL, NULL, (LPBYTE)val, &size);
5843     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5844     ok(!lstrcmpA(val, "01\\msitest\\augustus"),
5845        "Expected \"01\\msitest\\augustus\", got \"%s\"\n", val);
5846
5847     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, compkey, 0, access, &hkey);
5848     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5849
5850     RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
5851     delete_key(comp, "", access);
5852     RegCloseKey(comp);
5853
5854     /* ProcessComponents, machine */
5855     r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1 ALLUSERS=1");
5856     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5857     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5858     ok(delete_pf("msitest", FALSE), "File not installed\n");
5859
5860     sprintf(keypath, keyfmt, "S-1-5-18", "CBABC2FDCCB35E749A8944D8C1C098B5");
5861     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &comp);
5862     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5863
5864     size = MAX_PATH;
5865     res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
5866                            NULL, NULL, (LPBYTE)val, &size);
5867     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5868     ok(!lstrcmpiA(val, program_files_maximus),
5869        "Expected \"%s\", got \"%s\"\n", program_files_maximus, val);
5870
5871     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, compkey, 0, access, &hkey);
5872     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5873
5874     RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
5875     delete_key(comp, "", access);
5876     RegCloseKey(comp);
5877
5878     sprintf(keypath, keyfmt, "S-1-5-18", "241C3DA58FECD0945B9687D408766058");
5879     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &comp);
5880     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5881
5882     size = MAX_PATH;
5883     res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
5884                            NULL, NULL, (LPBYTE)val, &size);
5885     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5886     ok(!lstrcmpA(val, "01\\msitest\\augustus"),
5887        "Expected \"01\\msitest\\augustus\", got \"%s\"\n", val);
5888
5889     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, compkey, 0, access, &hkey);
5890     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5891
5892     RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
5893     delete_key(comp, "", access);
5894     RegCloseKey(comp);
5895
5896 error:
5897     DeleteFile(msifile);
5898     DeleteFile("msitest\\maximus");
5899     RemoveDirectory("msitest");
5900     LocalFree(usersid);
5901 }
5902
5903 static void test_publish(void)
5904 {
5905     UINT r;
5906     LONG res;
5907     HKEY uninstall, prodkey;
5908     INSTALLSTATE state;
5909     CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
5910     char date[MAX_PATH], temp[MAX_PATH];
5911     REGSAM access = KEY_ALL_ACCESS;
5912     BOOL wow64;
5913
5914     static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
5915
5916     if (!pMsiQueryComponentStateA)
5917     {
5918         win_skip("MsiQueryComponentStateA is not available\n");
5919         return;
5920     }
5921     if (is_process_limited())
5922     {
5923         skip("process is limited\n");
5924         return;
5925     }
5926
5927     get_date_str(date);
5928     GetTempPath(MAX_PATH, temp);
5929
5930     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
5931         access |= KEY_WOW64_64KEY;
5932
5933     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, subkey, 0, access, &uninstall);
5934     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5935
5936     CreateDirectoryA("msitest", NULL);
5937     create_file("msitest\\maximus", 500);
5938
5939     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5940
5941     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5942
5943     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5944     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5945
5946     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5947     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5948
5949     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5950     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5951
5952     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5953                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5954     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5955     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5956
5957     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
5958     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5959
5960     /* nothing published */
5961     r = MsiInstallProductA(msifile, NULL);
5962     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5963     {
5964         skip("Not enough rights to perform tests\n");
5965         goto error;
5966     }
5967     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5968     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5969     ok(pf_exists("msitest"), "File not installed\n");
5970
5971     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5972     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5973
5974     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5975     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5976
5977     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5978     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5979
5980     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5981                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5982     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5983     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5984
5985     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
5986     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5987
5988     /* PublishProduct and RegisterProduct */
5989     r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
5990     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5991     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5992     ok(pf_exists("msitest"), "File not installed\n");
5993
5994     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5995     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
5996
5997     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5998     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5999
6000     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6001     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6002
6003     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6004                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6005     ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
6006     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6007
6008     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6009     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6010
6011     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
6012     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
6013     CHECK_REG_STR(prodkey, "InstallDate", date);
6014     CHECK_REG_STR(prodkey, "InstallSource", temp);
6015     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6016     CHECK_REG_STR(prodkey, "Publisher", "Wine");
6017     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6018     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
6019     CHECK_REG_STR(prodkey, "Comments", NULL);
6020     CHECK_REG_STR(prodkey, "Contact", NULL);
6021     CHECK_REG_STR(prodkey, "HelpLink", NULL);
6022     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
6023     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
6024     CHECK_REG_STR(prodkey, "Readme", NULL);
6025     CHECK_REG_STR(prodkey, "Size", NULL);
6026     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
6027     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
6028     CHECK_REG_DWORD(prodkey, "Language", 1033);
6029     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
6030     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
6031     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
6032     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
6033     todo_wine
6034     {
6035         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
6036     }
6037
6038     RegCloseKey(prodkey);
6039
6040     r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
6041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6042     ok(pf_exists("msitest\\maximus"), "File deleted\n");
6043     ok(pf_exists("msitest"), "File deleted\n");
6044
6045     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6046     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6047
6048     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6049     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6050
6051     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6052     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6053
6054     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6055                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6056     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6057     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6058
6059     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6060     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
6061
6062     /* complete install */
6063     r = MsiInstallProductA(msifile, "FULL=1");
6064     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6065     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6066     ok(pf_exists("msitest"), "File not installed\n");
6067
6068     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6069     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
6070
6071     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6072     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6073
6074     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6075     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6076
6077     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6078                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6079     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6080     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6081
6082     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6083     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6084
6085     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
6086     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
6087     CHECK_REG_STR(prodkey, "InstallDate", date);
6088     CHECK_REG_STR(prodkey, "InstallSource", temp);
6089     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6090     CHECK_REG_STR(prodkey, "Publisher", "Wine");
6091     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6092     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
6093     CHECK_REG_STR(prodkey, "Comments", NULL);
6094     CHECK_REG_STR(prodkey, "Contact", NULL);
6095     CHECK_REG_STR(prodkey, "HelpLink", NULL);
6096     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
6097     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
6098     CHECK_REG_STR(prodkey, "Readme", NULL);
6099     CHECK_REG_STR(prodkey, "Size", NULL);
6100     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
6101     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
6102     CHECK_REG_DWORD(prodkey, "Language", 1033);
6103     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
6104     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
6105     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
6106     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
6107     todo_wine
6108     {
6109         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
6110     }
6111
6112     RegCloseKey(prodkey);
6113
6114     /* no UnpublishFeatures */
6115     r = MsiInstallProductA(msifile, "REMOVE=ALL");
6116     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6117     ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
6118     ok(!pf_exists("msitest"), "Directory not deleted\n");
6119
6120     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6121     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6122
6123     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6124     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6125
6126     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6127     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6128
6129     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6130                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6131     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6132     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6133
6134     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6135     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
6136
6137     /* complete install */
6138     r = MsiInstallProductA(msifile, "FULL=1");
6139     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6140     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6141     ok(pf_exists("msitest"), "File not installed\n");
6142
6143     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6144     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
6145
6146     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6147     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6148
6149     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6150     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6151
6152     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6153                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6154     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6155     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6156
6157     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6158     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6159
6160     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
6161     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
6162     CHECK_REG_STR(prodkey, "InstallDate", date);
6163     CHECK_REG_STR(prodkey, "InstallSource", temp);
6164     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6165     CHECK_REG_STR(prodkey, "Publisher", "Wine");
6166     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6167     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
6168     CHECK_REG_STR(prodkey, "Comments", NULL);
6169     CHECK_REG_STR(prodkey, "Contact", NULL);
6170     CHECK_REG_STR(prodkey, "HelpLink", NULL);
6171     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
6172     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
6173     CHECK_REG_STR(prodkey, "Readme", NULL);
6174     CHECK_REG_STR(prodkey, "Size", NULL);
6175     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
6176     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
6177     CHECK_REG_DWORD(prodkey, "Language", 1033);
6178     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
6179     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
6180     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
6181     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
6182     todo_wine
6183     {
6184         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
6185     }
6186
6187     RegCloseKey(prodkey);
6188
6189     /* UnpublishFeatures, only feature removed.  Only works when entire product is removed */
6190     r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
6191     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6192     ok(pf_exists("msitest\\maximus"), "File deleted\n");
6193     ok(pf_exists("msitest"), "Directory deleted\n");
6194
6195     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6196     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
6197
6198     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6199     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6200
6201     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6202     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6203
6204     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6205                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6206     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6207     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6208
6209     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6210     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6211
6212     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
6213     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
6214     CHECK_REG_STR(prodkey, "InstallDate", date);
6215     CHECK_REG_STR(prodkey, "InstallSource", temp);
6216     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6217     CHECK_REG_STR(prodkey, "Publisher", "Wine");
6218     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6219     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
6220     CHECK_REG_STR(prodkey, "Comments", NULL);
6221     CHECK_REG_STR(prodkey, "Contact", NULL);
6222     CHECK_REG_STR(prodkey, "HelpLink", NULL);
6223     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
6224     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
6225     CHECK_REG_STR(prodkey, "Readme", NULL);
6226     CHECK_REG_STR(prodkey, "Size", NULL);
6227     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
6228     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
6229     CHECK_REG_DWORD(prodkey, "Language", 1033);
6230     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
6231     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
6232     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
6233     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
6234     todo_wine
6235     {
6236         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
6237     }
6238
6239     RegCloseKey(prodkey);
6240
6241     /* complete install */
6242     r = MsiInstallProductA(msifile, "FULL=1");
6243     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6244     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6245     ok(pf_exists("msitest"), "File not installed\n");
6246
6247     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6248     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
6249
6250     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6251     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6252
6253     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6254     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6255
6256     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6257                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6258     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6259     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6260
6261     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6262     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6263
6264     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
6265     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
6266     CHECK_REG_STR(prodkey, "InstallDate", date);
6267     CHECK_REG_STR(prodkey, "InstallSource", temp);
6268     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6269     CHECK_REG_STR(prodkey, "Publisher", "Wine");
6270     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6271     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
6272     CHECK_REG_STR(prodkey, "Comments", NULL);
6273     CHECK_REG_STR(prodkey, "Contact", NULL);
6274     CHECK_REG_STR(prodkey, "HelpLink", NULL);
6275     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
6276     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
6277     CHECK_REG_STR(prodkey, "Readme", NULL);
6278     CHECK_REG_STR(prodkey, "Size", NULL);
6279     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
6280     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
6281     CHECK_REG_DWORD(prodkey, "Language", 1033);
6282     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
6283     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
6284     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
6285     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
6286     todo_wine
6287     {
6288         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -20);
6289     }
6290
6291     RegCloseKey(prodkey);
6292
6293     /* UnpublishFeatures, both features removed */
6294     r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
6295     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6296     ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
6297     ok(!pf_exists("msitest"), "Directory not deleted\n");
6298
6299     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6300     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6301
6302     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6303     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6304
6305     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6306     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6307
6308     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6309                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6310     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6311     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6312
6313     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6314     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
6315
6316     /* complete install */
6317     r = MsiInstallProductA(msifile, "FULL=1");
6318     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6319     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6320     ok(pf_exists("msitest"), "File not installed\n");
6321
6322     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6323     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
6324
6325     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6326     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6327
6328     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6329     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6330
6331     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6332                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6333     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6334     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6335
6336     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6337     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6338
6339     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
6340     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
6341     CHECK_REG_STR(prodkey, "InstallDate", date);
6342     CHECK_REG_STR(prodkey, "InstallSource", temp);
6343     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6344     CHECK_REG_STR(prodkey, "Publisher", "Wine");
6345     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6346     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
6347     CHECK_REG_STR(prodkey, "Comments", NULL);
6348     CHECK_REG_STR(prodkey, "Contact", NULL);
6349     CHECK_REG_STR(prodkey, "HelpLink", NULL);
6350     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
6351     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
6352     CHECK_REG_STR(prodkey, "Readme", NULL);
6353     CHECK_REG_STR(prodkey, "Size", NULL);
6354     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
6355     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
6356     CHECK_REG_DWORD(prodkey, "Language", 1033);
6357     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
6358     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
6359     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
6360     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
6361     todo_wine
6362     {
6363         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
6364     }
6365
6366     RegCloseKey(prodkey);
6367
6368     /* complete uninstall */
6369     r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
6370     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6371     ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
6372     ok(!pf_exists("msitest"), "Directory not deleted\n");
6373
6374     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
6375     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6376
6377     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
6378     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6379
6380     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
6381     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6382
6383     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6384                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
6385     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6386     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6387
6388     res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
6389     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
6390
6391     /* make sure 'Program Files\msitest' is removed */
6392     delete_pfmsitest_files();
6393
6394 error:
6395     RegCloseKey(uninstall);
6396     DeleteFile(msifile);
6397     DeleteFile("msitest\\maximus");
6398     RemoveDirectory("msitest");
6399 }
6400
6401 static void test_publishsourcelist(void)
6402 {
6403     UINT r;
6404     DWORD size;
6405     CHAR value[MAX_PATH];
6406     CHAR path[MAX_PATH];
6407     CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
6408
6409     if (!pMsiSourceListEnumSourcesA || !pMsiSourceListGetInfoA)
6410     {
6411         win_skip("MsiSourceListEnumSourcesA and/or MsiSourceListGetInfoA are not available\n");
6412         return;
6413     }
6414     if (is_process_limited())
6415     {
6416         skip("process is limited\n");
6417         return;
6418     }
6419
6420     CreateDirectoryA("msitest", NULL);
6421     create_file("msitest\\maximus", 500);
6422
6423     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
6424
6425     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
6426
6427     r = MsiInstallProductA(msifile, NULL);
6428     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6429     {
6430         skip("Not enough rights to perform tests\n");
6431         goto error;
6432     }
6433     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6434     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6435     ok(pf_exists("msitest"), "File not installed\n");
6436
6437     /* nothing published */
6438     size = MAX_PATH;
6439     lstrcpyA(value, "aaa");
6440     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6441                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
6442     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6443     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
6444     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
6445
6446     size = MAX_PATH;
6447     lstrcpyA(value, "aaa");
6448     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6449                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
6450     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6451     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
6452     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
6453
6454     r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
6455     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6456     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6457     ok(pf_exists("msitest"), "File not installed\n");
6458
6459     /* after RegisterProduct */
6460     size = MAX_PATH;
6461     lstrcpyA(value, "aaa");
6462     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6463                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
6464     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6465     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
6466     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
6467
6468     size = MAX_PATH;
6469     lstrcpyA(value, "aaa");
6470     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6471                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
6472     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6473     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
6474     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
6475
6476     r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
6477     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6478     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6479     ok(pf_exists("msitest"), "File not installed\n");
6480
6481     /* after ProcessComponents */
6482     size = MAX_PATH;
6483     lstrcpyA(value, "aaa");
6484     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6485                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
6486     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6487     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
6488     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
6489
6490     size = MAX_PATH;
6491     lstrcpyA(value, "aaa");
6492     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6493                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
6494     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6495     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
6496     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
6497
6498     r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
6499     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6500     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6501     ok(pf_exists("msitest"), "File not installed\n");
6502
6503     /* after PublishFeatures */
6504     size = MAX_PATH;
6505     lstrcpyA(value, "aaa");
6506     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6507                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
6508     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6509     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
6510     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
6511
6512     size = MAX_PATH;
6513     lstrcpyA(value, "aaa");
6514     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6515                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
6516     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6517     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
6518     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
6519
6520     r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
6521     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6522     ok(pf_exists("msitest\\maximus"), "File not installed\n");
6523     ok(pf_exists("msitest"), "File not installed\n");
6524
6525     /* after PublishProduct */
6526     size = MAX_PATH;
6527     lstrcpyA(value, "aaa");
6528     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6529                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
6530     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6531     ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
6532     ok(size == 11, "Expected 11, got %d\n", size);
6533
6534     size = MAX_PATH;
6535     lstrcpyA(value, "aaa");
6536     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6537                                MSICODE_PRODUCT, INSTALLPROPERTY_MEDIAPACKAGEPATH, value, &size);
6538     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6539     ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
6540     ok(size == 0, "Expected 0, got %d\n", size);
6541
6542     size = MAX_PATH;
6543     lstrcpyA(value, "aaa");
6544     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6545                                MSICODE_PRODUCT, INSTALLPROPERTY_DISKPROMPT, value, &size);
6546     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6547     ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
6548     ok(size == 0, "Expected 0, got %d\n", size);
6549
6550     lstrcpyA(path, CURR_DIR);
6551     lstrcatA(path, "\\");
6552
6553     size = MAX_PATH;
6554     lstrcpyA(value, "aaa");
6555     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6556                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
6557     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6558     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
6559     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
6560
6561     size = MAX_PATH;
6562     lstrcpyA(value, "aaa");
6563     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6564                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDTYPE, value, &size);
6565     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6566     ok(!lstrcmpA(value, "n"), "Expected \"n\", got \"%s\"\n", value);
6567     ok(size == 1, "Expected 1, got %d\n", size);
6568
6569     size = MAX_PATH;
6570     lstrcpyA(value, "aaa");
6571     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6572                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
6573     ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
6574     ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
6575     ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
6576
6577     size = MAX_PATH;
6578     lstrcpyA(value, "aaa");
6579     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6580                                    MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 0, value, &size);
6581     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6582     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
6583     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
6584
6585     size = MAX_PATH;
6586     lstrcpyA(value, "aaa");
6587     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6588                                    MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 1, value, &size);
6589     ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
6590     ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
6591     ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
6592
6593     /* complete uninstall */
6594     r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
6595     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6596     ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
6597     ok(!pf_exists("msitest"), "Directory not deleted\n");
6598
6599     /* make sure 'Program Files\msitest' is removed */
6600     delete_pfmsitest_files();
6601
6602 error:
6603     DeleteFile(msifile);
6604     DeleteFile("msitest\\maximus");
6605     RemoveDirectory("msitest");
6606 }
6607
6608 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
6609 {
6610     MSIHANDLE hview = 0;
6611     UINT r;
6612
6613     r = MsiDatabaseOpenView(hdb, query, &hview);
6614     if(r != ERROR_SUCCESS)
6615         return r;
6616
6617     r = MsiViewExecute(hview, hrec);
6618     if(r == ERROR_SUCCESS)
6619         r = MsiViewClose(hview);
6620     MsiCloseHandle(hview);
6621     return r;
6622 }
6623
6624 static void set_transform_summary_info(void)
6625 {
6626     UINT r;
6627     MSIHANDLE suminfo = 0;
6628
6629     /* build summary info */
6630     r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
6631     ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
6632
6633     r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
6634     ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
6635
6636     r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
6637                         "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
6638                         "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
6639                         "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
6640     ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
6641
6642     r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
6643     ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
6644
6645     r = MsiSummaryInfoPersist(suminfo);
6646     ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
6647
6648     r = MsiCloseHandle(suminfo);
6649     ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
6650 }
6651
6652 static void generate_transform(void)
6653 {
6654     MSIHANDLE hdb1, hdb2;
6655     LPCSTR query;
6656     UINT r;
6657
6658     /* start with two identical databases */
6659     CopyFile(msifile, msifile2, FALSE);
6660
6661     r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
6662     ok(r == ERROR_SUCCESS , "Failed to create database\n");
6663
6664     r = MsiDatabaseCommit(hdb1);
6665     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
6666
6667     r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
6668     ok(r == ERROR_SUCCESS , "Failed to create database\n");
6669
6670     query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
6671     r = run_query(hdb1, 0, query);
6672     ok(r == ERROR_SUCCESS, "failed to add property\n");
6673
6674     /* database needs to be committed */
6675     MsiDatabaseCommit(hdb1);
6676
6677     r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
6678     ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
6679
6680 #if 0  /* not implemented in wine yet */
6681     r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
6682     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6683 #endif
6684
6685     MsiCloseHandle(hdb1);
6686     MsiCloseHandle(hdb2);
6687 }
6688
6689 /* data for generating a transform */
6690
6691 /* tables transform names - encoded as they would be in an msi database file */
6692 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
6693 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
6694 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
6695
6696 /* data in each table */
6697 static const char data1[] = /* _StringData */
6698     "propval";  /* all the strings squashed together */
6699
6700 static const WCHAR data2[] = { /* _StringPool */
6701 /*  len, refs */
6702     0,   0,    /* string 0 ''     */
6703     4,   1,    /* string 1 'prop' */
6704     3,   1,    /* string 2 'val'  */
6705 };
6706
6707 static const WCHAR data3[] = { /* Property */
6708     0x0201, 0x0001, 0x0002,
6709 };
6710
6711 static const struct {
6712     LPCWSTR name;
6713     const void *data;
6714     DWORD size;
6715 } table_transform_data[] =
6716 {
6717     { name1, data1, sizeof data1 - 1 },
6718     { name2, data2, sizeof data2 },
6719     { name3, data3, sizeof data3 },
6720 };
6721
6722 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
6723
6724 static void generate_transform_manual(void)
6725 {
6726     IStorage *stg = NULL;
6727     IStream *stm;
6728     WCHAR name[0x20];
6729     HRESULT r;
6730     DWORD i, count;
6731     const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
6732
6733     const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
6734
6735     MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
6736
6737     r = StgCreateDocfile(name, mode, 0, &stg);
6738     ok(r == S_OK, "failed to create storage\n");
6739     if (!stg)
6740         return;
6741
6742     r = IStorage_SetClass(stg, &CLSID_MsiTransform);
6743     ok(r == S_OK, "failed to set storage type\n");
6744
6745     for (i=0; i<NUM_TRANSFORM_TABLES; i++)
6746     {
6747         r = IStorage_CreateStream(stg, table_transform_data[i].name,
6748                             STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
6749         if (FAILED(r))
6750         {
6751             ok(0, "failed to create stream %08x\n", r);
6752             continue;
6753         }
6754
6755         r = IStream_Write(stm, table_transform_data[i].data,
6756                           table_transform_data[i].size, &count);
6757         if (FAILED(r) || count != table_transform_data[i].size)
6758             ok(0, "failed to write stream\n");
6759         IStream_Release(stm);
6760     }
6761
6762     IStorage_Release(stg);
6763
6764     set_transform_summary_info();
6765 }
6766
6767 static void test_transformprop(void)
6768 {
6769     UINT r;
6770
6771     if (is_process_limited())
6772     {
6773         skip("process is limited\n");
6774         return;
6775     }
6776
6777     CreateDirectoryA("msitest", NULL);
6778     create_file("msitest\\augustus", 500);
6779
6780     create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
6781
6782     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6783
6784     r = MsiInstallProductA(msifile, NULL);
6785     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6786     {
6787         skip("Not enough rights to perform tests\n");
6788         goto error;
6789     }
6790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6791     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6792     ok(!delete_pf("msitest", FALSE), "File installed\n");
6793
6794     if (0)
6795         generate_transform();
6796     else
6797         generate_transform_manual();
6798
6799     r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
6800     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6801     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
6802     ok(delete_pf("msitest", FALSE), "File not installed\n");
6803
6804 error:
6805     /* Delete the files in the temp (current) folder */
6806     DeleteFile(msifile);
6807     DeleteFile(msifile2);
6808     DeleteFile(mstfile);
6809     DeleteFile("msitest\\augustus");
6810     RemoveDirectory("msitest");
6811 }
6812
6813 static void test_currentworkingdir(void)
6814 {
6815     UINT r;
6816     CHAR drive[MAX_PATH], path[MAX_PATH];
6817     LPSTR ptr;
6818
6819     if (is_process_limited())
6820     {
6821         skip("process is limited\n");
6822         return;
6823     }
6824
6825     CreateDirectoryA("msitest", NULL);
6826     create_file("msitest\\augustus", 500);
6827
6828     create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
6829
6830     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6831
6832     CreateDirectoryA("diffdir", NULL);
6833     SetCurrentDirectoryA("diffdir");
6834
6835     sprintf(path, "..\\%s", msifile);
6836     r = MsiInstallProductA(path, NULL);
6837     todo_wine
6838     {
6839         ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
6840         ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6841         ok(!delete_pf("msitest", FALSE), "File installed\n");
6842     }
6843
6844     sprintf(path, "%s\\%s", CURR_DIR, msifile);
6845     r = MsiInstallProductA(path, NULL);
6846     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6847     {
6848         skip("Not enough rights to perform tests\n");
6849         goto error;
6850     }
6851     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6852     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
6853     ok(delete_pf("msitest", FALSE), "File not installed\n");
6854
6855     lstrcpyA(drive, CURR_DIR);
6856     drive[2] = '\\';
6857     drive[3] = '\0';
6858     SetCurrentDirectoryA(drive);
6859
6860     lstrcpy(path, CURR_DIR);
6861     if (path[lstrlenA(path) - 1] != '\\')
6862         lstrcatA(path, "\\");
6863     lstrcatA(path, msifile);
6864     ptr = strchr(path, ':');
6865     ptr +=2;
6866
6867     r = MsiInstallProductA(ptr, NULL);
6868     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6869     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
6870     ok(delete_pf("msitest", FALSE), "File not installed\n");
6871
6872 error:
6873     SetCurrentDirectoryA(CURR_DIR);
6874     DeleteFile(msifile);
6875     DeleteFile("msitest\\augustus");
6876     RemoveDirectory("msitest");
6877     RemoveDirectory("diffdir");
6878 }
6879
6880 static void set_admin_summary_info(const CHAR *name)
6881 {
6882     MSIHANDLE db, summary;
6883     UINT r;
6884
6885     r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
6886     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6887
6888     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
6889     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6890
6891     r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
6892     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6893
6894     /* write the summary changes back to the stream */
6895     r = MsiSummaryInfoPersist(summary);
6896     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6897
6898     MsiCloseHandle(summary);
6899
6900     r = MsiDatabaseCommit(db);
6901     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6902
6903     MsiCloseHandle(db);
6904 }
6905
6906 static void test_admin(void)
6907 {
6908     UINT r;
6909
6910     CreateDirectoryA("msitest", NULL);
6911     create_file("msitest\\augustus", 500);
6912
6913     create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
6914     set_admin_summary_info(msifile);
6915
6916     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6917
6918     r = MsiInstallProductA(msifile, NULL);
6919     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6920     {
6921         skip("Not enough rights to perform tests\n");
6922         goto error;
6923     }
6924     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6925     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6926     ok(!delete_pf("msitest", FALSE), "File installed\n");
6927     ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
6928     ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
6929
6930     r = MsiInstallProductA(msifile, "ACTION=ADMIN");
6931     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6932     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6933     ok(!delete_pf("msitest", FALSE), "File installed\n");
6934     todo_wine
6935     {
6936         ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
6937         ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
6938     }
6939
6940 error:
6941     DeleteFile(msifile);
6942     DeleteFile("msitest\\augustus");
6943     RemoveDirectory("msitest");
6944 }
6945
6946 static void set_admin_property_stream(LPCSTR file)
6947 {
6948     IStorage *stg;
6949     IStream *stm;
6950     WCHAR fileW[MAX_PATH];
6951     HRESULT hr;
6952     DWORD count;
6953     const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
6954
6955     /* AdminProperties */
6956     static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
6957     static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',' ',
6958         'M','y','P','r','o','p','=','4','2',0};
6959
6960     MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
6961
6962     hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
6963     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
6964     if (!stg)
6965         return;
6966
6967     hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
6968     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
6969
6970     hr = IStream_Write(stm, data, sizeof(data), &count);
6971     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
6972
6973     IStream_Release(stm);
6974     IStorage_Release(stg);
6975 }
6976
6977 static void test_adminprops(void)
6978 {
6979     UINT r;
6980
6981     if (is_process_limited())
6982     {
6983         skip("process is limited\n");
6984         return;
6985     }
6986
6987     CreateDirectoryA("msitest", NULL);
6988     create_file("msitest\\augustus", 500);
6989
6990     create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
6991     set_admin_summary_info(msifile);
6992     set_admin_property_stream(msifile);
6993
6994     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6995
6996     r = MsiInstallProductA(msifile, NULL);
6997     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6998     {
6999         skip("Not enough rights to perform tests\n");
7000         goto error;
7001     }
7002     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7003     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
7004     ok(delete_pf("msitest", FALSE), "File installed\n");
7005
7006 error:
7007     DeleteFile(msifile);
7008     DeleteFile("msitest\\augustus");
7009     RemoveDirectory("msitest");
7010 }
7011
7012 static void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file)
7013 {
7014     CHAR path[MAX_PATH];
7015
7016     lstrcpyA(path, PROG_FILES_DIR);
7017     lstrcatA(path, "\\");
7018     lstrcatA(path, file);
7019
7020     if (is_file)
7021         create_file_data(path, data, 500);
7022     else
7023         CreateDirectoryA(path, NULL);
7024 }
7025
7026 #define create_pf(file, is_file) create_pf_data(file, file, is_file)
7027
7028 static void test_removefiles(void)
7029 {
7030     UINT r;
7031
7032     if (is_process_limited())
7033     {
7034         skip("process is limited\n");
7035         return;
7036     }
7037
7038     CreateDirectoryA("msitest", NULL);
7039     create_file("msitest\\hydrogen", 500);
7040     create_file("msitest\\helium", 500);
7041     create_file("msitest\\lithium", 500);
7042
7043     create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
7044
7045     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
7046
7047     r = MsiInstallProductA(msifile, NULL);
7048     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7049     {
7050         skip("Not enough rights to perform tests\n");
7051         goto error;
7052     }
7053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7054     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7055     ok(!pf_exists("msitest\\helium"), "File installed\n");
7056     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7057     ok(pf_exists("msitest"), "File not installed\n");
7058
7059     r = MsiInstallProductA(msifile, "REMOVE=ALL");
7060     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7061     ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
7062     ok(!pf_exists("msitest\\helium"), "File not deleted\n");
7063     ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
7064     ok(delete_pf("msitest", FALSE), "File deleted\n");
7065
7066     create_pf("msitest", FALSE);
7067     create_pf("msitest\\hydrogen", TRUE);
7068     create_pf("msitest\\helium", TRUE);
7069     create_pf("msitest\\lithium", TRUE);
7070
7071     r = MsiInstallProductA(msifile, NULL);
7072     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7073     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7074     ok(pf_exists("msitest\\helium"), "File not installed\n");
7075     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7076     ok(pf_exists("msitest"), "File not installed\n");
7077
7078     r = MsiInstallProductA(msifile, "REMOVE=ALL");
7079     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7080     ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
7081     ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
7082     ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
7083     ok(delete_pf("msitest", FALSE), "File deleted\n");
7084
7085     create_pf("msitest", FALSE);
7086     create_pf("msitest\\furlong", TRUE);
7087     create_pf("msitest\\firkin", TRUE);
7088     create_pf("msitest\\fortnight", TRUE);
7089     create_pf("msitest\\becquerel", TRUE);
7090     create_pf("msitest\\dioptre", TRUE);
7091     create_pf("msitest\\attoparsec", TRUE);
7092     create_pf("msitest\\storeys", TRUE);
7093     create_pf("msitest\\block", TRUE);
7094     create_pf("msitest\\siriometer", TRUE);
7095     create_pf("msitest\\cabout", FALSE);
7096     create_pf("msitest\\cabout\\blocker", TRUE);
7097
7098     r = MsiInstallProductA(msifile, NULL);
7099     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7100     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7101     ok(!pf_exists("msitest\\helium"), "File installed\n");
7102     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7103     ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
7104     ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
7105     ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
7106     ok(pf_exists("msitest\\becquerel"), "File not installed\n");
7107     ok(pf_exists("msitest\\dioptre"), "File not installed\n");
7108     ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
7109     ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
7110     ok(!pf_exists("msitest\\block"), "File not deleted\n");
7111     ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
7112     ok(pf_exists("msitest\\cabout"), "Directory removed\n");
7113     ok(pf_exists("msitest"), "File not installed\n");
7114
7115     create_pf("msitest\\furlong", TRUE);
7116     create_pf("msitest\\firkin", TRUE);
7117     create_pf("msitest\\fortnight", TRUE);
7118     create_pf("msitest\\storeys", TRUE);
7119     create_pf("msitest\\block", TRUE);
7120     create_pf("msitest\\siriometer", TRUE);
7121
7122     r = MsiInstallProductA(msifile, "REMOVE=ALL");
7123     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7124     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
7125     ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
7126     ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
7127     ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
7128     ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
7129     ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
7130     ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
7131     ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
7132     ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
7133     ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
7134     ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
7135     ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
7136     ok(pf_exists("msitest\\cabout"), "Directory deleted\n");
7137     ok(pf_exists("msitest"), "Directory deleted\n");
7138
7139     r = MsiInstallProductA(msifile, NULL);
7140     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7141     ok(delete_pf("msitest\\hydrogen", TRUE), "File not installed\n");
7142     ok(!delete_pf("msitest\\helium", TRUE), "File installed\n");
7143     ok(delete_pf("msitest\\lithium", TRUE), "File not installed\n");
7144     ok(pf_exists("msitest\\cabout"), "Directory deleted\n");
7145     ok(pf_exists("msitest"), "Directory deleted\n");
7146
7147     delete_pf("msitest\\cabout\\blocker", TRUE);
7148
7149     r = MsiInstallProductA(msifile, "REMOVE=ALL");
7150     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7151     ok(!delete_pf("msitest\\cabout", FALSE), "Directory not deleted\n");
7152     ok(delete_pf("msitest", FALSE), "Directory deleted\n");
7153
7154 error:
7155     DeleteFile(msifile);
7156     DeleteFile("msitest\\hydrogen");
7157     DeleteFile("msitest\\helium");
7158     DeleteFile("msitest\\lithium");
7159     RemoveDirectory("msitest");
7160 }
7161
7162 static void test_movefiles(void)
7163 {
7164     UINT r;
7165     char props[MAX_PATH];
7166
7167     if (is_process_limited())
7168     {
7169         skip("process is limited\n");
7170         return;
7171     }
7172
7173     CreateDirectoryA("msitest", NULL);
7174     create_file("msitest\\augustus", 100);
7175     create_file("cameroon", 100);
7176     create_file("djibouti", 100);
7177     create_file("egypt", 100);
7178     create_file("finland", 100);
7179     create_file("gambai", 100);
7180     create_file("honduras", 100);
7181     create_file("msitest\\india", 100);
7182     create_file("japan", 100);
7183     create_file("kenya", 100);
7184     CreateDirectoryA("latvia", NULL);
7185     create_file("nauru", 100);
7186     create_file("peru", 100);
7187     create_file("apple", 100);
7188     create_file("application", 100);
7189     create_file("ape", 100);
7190     create_file("foo", 100);
7191     create_file("fao", 100);
7192     create_file("fbod", 100);
7193     create_file("budding", 100);
7194     create_file("buddy", 100);
7195     create_file("bud", 100);
7196     create_file("bar", 100);
7197     create_file("bur", 100);
7198     create_file("bird", 100);
7199
7200     create_database(msifile, mov_tables, sizeof(mov_tables) / sizeof(msi_table));
7201
7202     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
7203
7204     /* if the source or dest property is not a full path,
7205      * windows tries to access it as a network resource
7206      */
7207
7208     sprintf(props, "SOURCEFULL=\"%s\\\" DESTFULL=\"%s\\msitest\" "
7209             "FILEPATHBAD=\"%s\\japan\" FILEPATHGOOD=\"%s\\kenya\"",
7210             CURR_DIR, PROG_FILES_DIR, CURR_DIR, CURR_DIR);
7211
7212     r = MsiInstallProductA(msifile, props);
7213     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7214     {
7215         skip("Not enough rights to perform tests\n");
7216         goto error;
7217     }
7218     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7219     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
7220     ok(!delete_pf("msitest\\dest", TRUE), "File copied\n");
7221     ok(delete_pf("msitest\\canada", TRUE), "File not copied\n");
7222     ok(delete_pf("msitest\\dominica", TRUE), "File not moved\n");
7223     ok(!delete_pf("msitest\\elsalvador", TRUE), "File moved\n");
7224     ok(!delete_pf("msitest\\france", TRUE), "File moved\n");
7225     ok(!delete_pf("msitest\\georgia", TRUE), "File moved\n");
7226     ok(delete_pf("msitest\\hungary", TRUE), "File not moved\n");
7227     ok(!delete_pf("msitest\\indonesia", TRUE), "File moved\n");
7228     ok(!delete_pf("msitest\\jordan", TRUE), "File moved\n");
7229     ok(delete_pf("msitest\\kiribati", TRUE), "File not moved\n");
7230     ok(!delete_pf("msitest\\lebanon", TRUE), "File moved\n");
7231     ok(!delete_pf("msitest\\lebanon", FALSE), "Directory moved\n");
7232     ok(delete_pf("msitest\\poland", TRUE), "File not moved\n");
7233     /* either apple or application will be moved depending on directory order */
7234     if (!delete_pf("msitest\\apple", TRUE))
7235         ok(delete_pf("msitest\\application", TRUE), "File not moved\n");
7236     else
7237         ok(!delete_pf("msitest\\application", TRUE), "File should not exist\n");
7238     ok(delete_pf("msitest\\wildcard", TRUE), "File not moved\n");
7239     ok(!delete_pf("msitest\\ape", TRUE), "File moved\n");
7240     /* either fao or foo will be moved depending on directory order */
7241     if (delete_pf("msitest\\foo", TRUE))
7242         ok(!delete_pf("msitest\\fao", TRUE), "File should not exist\n");
7243     else
7244         ok(delete_pf("msitest\\fao", TRUE), "File not moved\n");
7245     ok(delete_pf("msitest\\single", TRUE), "File not moved\n");
7246     ok(!delete_pf("msitest\\fbod", TRUE), "File moved\n");
7247     ok(delete_pf("msitest\\budding", TRUE), "File not moved\n");
7248     ok(delete_pf("msitest\\buddy", TRUE), "File not moved\n");
7249     ok(!delete_pf("msitest\\bud", TRUE), "File moved\n");
7250     ok(delete_pf("msitest\\bar", TRUE), "File not moved\n");
7251     ok(delete_pf("msitest\\bur", TRUE), "File not moved\n");
7252     ok(!delete_pf("msitest\\bird", TRUE), "File moved\n");
7253     ok(delete_pf("msitest", FALSE), "File not installed\n");
7254     ok(DeleteFileA("cameroon"), "File moved\n");
7255     ok(!DeleteFileA("djibouti"), "File not moved\n");
7256     ok(DeleteFileA("egypt"), "File moved\n");
7257     ok(DeleteFileA("finland"), "File moved\n");
7258     ok(DeleteFileA("gambai"), "File moved\n");
7259     ok(!DeleteFileA("honduras"), "File not moved\n");
7260     ok(DeleteFileA("msitest\\india"), "File moved\n");
7261     ok(DeleteFileA("japan"), "File moved\n");
7262     ok(!DeleteFileA("kenya"), "File not moved\n");
7263     ok(RemoveDirectoryA("latvia"), "Directory moved\n");
7264     ok(!DeleteFileA("nauru"), "File not moved\n");
7265     ok(!DeleteFileA("peru"), "File not moved\n");
7266     ok(!DeleteFileA("apple"), "File not moved\n");
7267     ok(!DeleteFileA("application"), "File not moved\n");
7268     ok(DeleteFileA("ape"), "File moved\n");
7269     ok(!DeleteFileA("foo"), "File not moved\n");
7270     ok(!DeleteFileA("fao"), "File not moved\n");
7271     ok(DeleteFileA("fbod"), "File moved\n");
7272     ok(!DeleteFileA("budding"), "File not moved\n");
7273     ok(!DeleteFileA("buddy"), "File not moved\n");
7274     ok(DeleteFileA("bud"), "File moved\n");
7275     ok(!DeleteFileA("bar"), "File not moved\n");
7276     ok(!DeleteFileA("bur"), "File not moved\n");
7277     ok(DeleteFileA("bird"), "File moved\n");
7278
7279 error:
7280     DeleteFile("cameroon");
7281     DeleteFile("djibouti");
7282     DeleteFile("egypt");
7283     DeleteFile("finland");
7284     DeleteFile("gambai");
7285     DeleteFile("honduras");
7286     DeleteFile("japan");
7287     DeleteFile("kenya");
7288     DeleteFile("nauru");
7289     DeleteFile("peru");
7290     DeleteFile("apple");
7291     DeleteFile("application");
7292     DeleteFile("ape");
7293     DeleteFile("foo");
7294     DeleteFile("fao");
7295     DeleteFile("fbod");
7296     DeleteFile("budding");
7297     DeleteFile("buddy");
7298     DeleteFile("bud");
7299     DeleteFile("bar");
7300     DeleteFile("bur");
7301     DeleteFile("bird");
7302     DeleteFile("msitest\\india");
7303     DeleteFile("msitest\\augustus");
7304     RemoveDirectory("latvia");
7305     RemoveDirectory("msitest");
7306     DeleteFile(msifile);
7307 }
7308
7309 static void test_missingcab(void)
7310 {
7311     UINT r;
7312
7313     if (is_process_limited())
7314     {
7315         skip("process is limited\n");
7316         return;
7317     }
7318
7319     CreateDirectoryA("msitest", NULL);
7320     create_file("msitest\\augustus", 500);
7321     create_file("maximus", 500);
7322
7323     create_database(msifile, mc_tables, sizeof(mc_tables) / sizeof(msi_table));
7324
7325     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7326
7327     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
7328
7329     create_pf("msitest", FALSE);
7330     create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
7331
7332     r = MsiInstallProductA(msifile, NULL);
7333     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7334     {
7335         skip("Not enough rights to perform tests\n");
7336         goto error;
7337     }
7338     ok(r == ERROR_SUCCESS ||
7339        broken(r == ERROR_INSTALL_FAILURE), /* win9x */
7340        "Expected ERROR_SUCCESS, got %u\n", r);
7341     if (r == ERROR_SUCCESS)
7342     {
7343       ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
7344       ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
7345     }
7346     ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
7347     ok(!delete_pf("msitest\\gaius", TRUE), "File installed\n");
7348     ok(delete_pf("msitest", FALSE), "File not installed\n");
7349
7350     create_pf("msitest", FALSE);
7351     create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
7352     create_pf("msitest\\gaius", TRUE);
7353
7354     r = MsiInstallProductA(msifile, "GAIUS=1");
7355     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
7356     todo_wine
7357     {
7358         ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
7359         ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
7360     }
7361     ok(delete_pf("msitest\\caesar", TRUE), "File removed\n");
7362     ok(delete_pf("msitest\\gaius", TRUE), "File removed\n");
7363     ok(delete_pf("msitest", FALSE), "File not installed\n");
7364
7365 error:
7366     delete_pf("msitest\\caesar", TRUE);
7367     delete_pf("msitest", FALSE);
7368     DeleteFile("msitest\\augustus");
7369     RemoveDirectory("msitest");
7370     DeleteFile("maximus");
7371     DeleteFile("test1.cab");
7372     DeleteFile(msifile);
7373 }
7374
7375 static void test_duplicatefiles(void)
7376 {
7377     UINT r;
7378
7379     if (is_process_limited())
7380     {
7381         skip("process is limited\n");
7382         return;
7383     }
7384
7385     CreateDirectoryA("msitest", NULL);
7386     create_file("msitest\\maximus", 500);
7387     create_database(msifile, df_tables, sizeof(df_tables) / sizeof(msi_table));
7388
7389     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7390
7391     /* fails if the destination folder is not a valid property */
7392
7393     r = MsiInstallProductA(msifile, NULL);
7394     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7395     {
7396         skip("Not enough rights to perform tests\n");
7397         goto error;
7398     }
7399     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7400     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
7401     ok(delete_pf("msitest\\augustus", TRUE), "File not duplicated\n");
7402     ok(delete_pf("msitest\\this\\doesnot\\exist\\maximus", TRUE), "File not duplicated\n");
7403     ok(delete_pf("msitest\\this\\doesnot\\exist", FALSE), "File not duplicated\n");
7404     ok(delete_pf("msitest\\this\\doesnot", FALSE), "File not duplicated\n");
7405     ok(delete_pf("msitest\\this", FALSE), "File not duplicated\n");
7406     ok(delete_pf("msitest", FALSE), "File not installed\n");
7407
7408 error:
7409     DeleteFile("msitest\\maximus");
7410     RemoveDirectory("msitest");
7411     DeleteFile(msifile);
7412 }
7413
7414 static void test_writeregistryvalues(void)
7415 {
7416     UINT r;
7417     LONG res;
7418     HKEY hkey;
7419     DWORD type, size;
7420     CHAR path[MAX_PATH];
7421     REGSAM access = KEY_ALL_ACCESS;
7422     BOOL wow64;
7423
7424     if (is_process_limited())
7425     {
7426         skip("process is limited\n");
7427         return;
7428     }
7429
7430     CreateDirectoryA("msitest", NULL);
7431     create_file("msitest\\augustus", 500);
7432
7433     create_database(msifile, wrv_tables, sizeof(wrv_tables) / sizeof(msi_table));
7434
7435     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
7436         access |= KEY_WOW64_64KEY;
7437
7438     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7439
7440     r = MsiInstallProductA(msifile, NULL);
7441     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7442     {
7443         skip("Not enough rights to perform tests\n");
7444         goto error;
7445     }
7446     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7447     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
7448     ok(delete_pf("msitest", FALSE), "File installed\n");
7449
7450     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
7451     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7452
7453     size = MAX_PATH;
7454     type = REG_MULTI_SZ;
7455     memset(path, 'a', MAX_PATH);
7456     res = RegQueryValueExA(hkey, "Value", NULL, &type, (LPBYTE)path, &size);
7457     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7458     ok(!memcmp(path, "one\0two\0three\0\0", size), "Wrong multi-sz data\n");
7459     ok(size == 15, "Expected 15, got %d\n", size);
7460     ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type);
7461
7462     RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
7463
7464 error:
7465     DeleteFile(msifile);
7466     DeleteFile("msitest\\augustus");
7467     RemoveDirectory("msitest");
7468 }
7469
7470 static void test_sourcefolder(void)
7471 {
7472     UINT r;
7473
7474     if (is_process_limited())
7475     {
7476         skip("process is limited\n");
7477         return;
7478     }
7479
7480     CreateDirectoryA("msitest", NULL);
7481     create_file("augustus", 500);
7482
7483     create_database(msifile, sf_tables, sizeof(sf_tables) / sizeof(msi_table));
7484
7485     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7486
7487     r = MsiInstallProductA(msifile, NULL);
7488     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7489     {
7490         skip("Not enough rights to perform tests\n");
7491         goto error;
7492     }
7493     ok(r == ERROR_INSTALL_FAILURE,
7494        "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
7495     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
7496     todo_wine
7497     {
7498         ok(!delete_pf("msitest", FALSE), "File installed\n");
7499     }
7500
7501     RemoveDirectoryA("msitest");
7502
7503     r = MsiInstallProductA(msifile, NULL);
7504     ok(r == ERROR_INSTALL_FAILURE,
7505        "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
7506     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
7507     todo_wine
7508     {
7509         ok(!delete_pf("msitest", FALSE), "File installed\n");
7510     }
7511
7512 error:
7513     DeleteFile(msifile);
7514     DeleteFile("augustus");
7515 }
7516
7517 static void test_customaction51(void)
7518 {
7519     UINT r;
7520
7521     if (is_process_limited())
7522     {
7523         skip("process is limited\n");
7524         return;
7525     }
7526
7527     CreateDirectoryA("msitest", NULL);
7528     create_file("msitest\\augustus", 500);
7529
7530     create_database(msifile, ca51_tables, sizeof(ca51_tables) / sizeof(msi_table));
7531
7532     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7533
7534     r = MsiInstallProductA(msifile, NULL);
7535     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7536     {
7537         skip("Not enough rights to perform tests\n");
7538         goto error;
7539     }
7540     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7541     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
7542     ok(delete_pf("msitest", FALSE), "File installed\n");
7543
7544 error:
7545     DeleteFile(msifile);
7546     DeleteFile("msitest\\augustus");
7547     RemoveDirectory("msitest");
7548 }
7549
7550 static void test_installstate(void)
7551 {
7552     UINT r;
7553
7554     if (is_process_limited())
7555     {
7556         skip("process is limited\n");
7557         return;
7558     }
7559
7560     CreateDirectoryA("msitest", NULL);
7561     create_file("msitest\\alpha", 500);
7562     create_file("msitest\\beta", 500);
7563     create_file("msitest\\gamma", 500);
7564     create_file("msitest\\theta", 500);
7565     create_file("msitest\\delta", 500);
7566     create_file("msitest\\epsilon", 500);
7567     create_file("msitest\\zeta", 500);
7568     create_file("msitest\\iota", 500);
7569     create_file("msitest\\eta", 500);
7570     create_file("msitest\\kappa", 500);
7571     create_file("msitest\\lambda", 500);
7572     create_file("msitest\\mu", 500);
7573
7574     create_database(msifile, is_tables, sizeof(is_tables) / sizeof(msi_table));
7575
7576     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7577
7578     r = MsiInstallProductA(msifile, NULL);
7579     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7580     {
7581         skip("Not enough rights to perform tests\n");
7582         goto error;
7583     }
7584     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7585     ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
7586     ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
7587     ok(delete_pf("msitest\\gamma", TRUE), "File not installed\n");
7588     ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
7589     ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
7590     ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
7591     ok(!delete_pf("msitest\\zeta", TRUE), "File installed\n");
7592     ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
7593     ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
7594     ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
7595     ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
7596     ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
7597     ok(delete_pf("msitest", FALSE), "File not installed\n");
7598
7599     r = MsiInstallProductA(msifile, "ADDLOCAL=\"one,two,three,four\"");
7600     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7601     ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
7602     ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
7603     ok(delete_pf("msitest\\gamma", TRUE), "File not installed\n");
7604     ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
7605     ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
7606     ok(delete_pf("msitest\\epsilon", TRUE), "File not installed\n");
7607     ok(delete_pf("msitest\\zeta", TRUE), "File not installed\n");
7608     ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
7609     ok(delete_pf("msitest\\eta", TRUE), "File not installed\n");
7610     ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
7611     ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
7612     ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
7613     ok(delete_pf("msitest", FALSE), "File not installed\n");
7614
7615     r = MsiInstallProductA(msifile, "ADDSOURCE=\"one,two,three,four\"");
7616     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7617     ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
7618     ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
7619     ok(!delete_pf("msitest\\gamma", TRUE), "File installed\n");
7620     ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
7621     ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
7622     ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
7623     ok(delete_pf("msitest\\zeta", TRUE), "File not installed\n");
7624     ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
7625     ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
7626     ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
7627     ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
7628     ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
7629     ok(delete_pf("msitest", FALSE), "File not installed\n");
7630
7631     r = MsiInstallProductA(msifile, "REMOVE=\"one,two,three,four\"");
7632     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7633     ok(!delete_pf("msitest\\alpha", TRUE), "File installed\n");
7634     ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
7635     ok(!delete_pf("msitest\\gamma", TRUE), "File installed\n");
7636     ok(!delete_pf("msitest\\theta", TRUE), "File installed\n");
7637     ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
7638     ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
7639     ok(!delete_pf("msitest\\zeta", TRUE), "File installed\n");
7640     ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
7641     ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
7642     ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
7643     ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
7644     ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
7645     ok(!delete_pf("msitest", FALSE), "File installed\n");
7646
7647 error:
7648     DeleteFile(msifile);
7649     DeleteFile("msitest\\alpha");
7650     DeleteFile("msitest\\beta");
7651     DeleteFile("msitest\\gamma");
7652     DeleteFile("msitest\\theta");
7653     DeleteFile("msitest\\delta");
7654     DeleteFile("msitest\\epsilon");
7655     DeleteFile("msitest\\zeta");
7656     DeleteFile("msitest\\iota");
7657     DeleteFile("msitest\\eta");
7658     DeleteFile("msitest\\kappa");
7659     DeleteFile("msitest\\lambda");
7660     DeleteFile("msitest\\mu");
7661     RemoveDirectory("msitest");
7662 }
7663
7664 struct sourcepathmap
7665 {
7666     BOOL sost; /* shortone\shorttwo */
7667     BOOL solt; /* shortone\longtwo */
7668     BOOL lost; /* longone\shorttwo */
7669     BOOL lolt; /* longone\longtwo */
7670     BOOL soste; /* shortone\shorttwo source exists */
7671     BOOL solte; /* shortone\longtwo source exists */
7672     BOOL loste; /* longone\shorttwo source exists */
7673     BOOL lolte; /* longone\longtwo source exists */
7674     UINT err;
7675     DWORD size;
7676 } spmap[256] =
7677 {
7678     {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7679     {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7680     {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7681     {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7682     {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7683     {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7684     {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7685     {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7686     {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7687     {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7688     {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7689     {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7690     {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7691     {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7692     {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7693     {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7694     {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7695     {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7696     {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7697     {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7698     {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7699     {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7700     {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7701     {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7702     {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7703     {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7704     {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7705     {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7706     {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7707     {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7708     {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7709     {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7710     {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7711     {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7712     {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7713     {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7714     {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7715     {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7716     {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7717     {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7718     {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7719     {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7720     {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7721     {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7722     {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7723     {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7724     {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7725     {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7726     {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7727     {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7728     {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7729     {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7730     {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7731     {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7732     {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7733     {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7734     {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7735     {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7736     {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7737     {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7738     {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7739     {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7740     {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7741     {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7742     {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7743     {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7744     {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7745     {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7746     {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7747     {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7748     {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7749     {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7750     {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7751     {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7752     {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7753     {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7754     {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7755     {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7756     {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7757     {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7758     {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7759     {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7760     {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7761     {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7762     {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7763     {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7764     {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7765     {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7766     {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7767     {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7768     {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7769     {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7770     {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7771     {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7772     {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7773     {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7774     {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7775     {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7776     {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7777     {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7778     {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7779     {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7780     {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7781     {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7782     {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7783     {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7784     {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7785     {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7786     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7787     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7788     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7789     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7790     {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7791     {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7792     {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7793     {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7794     {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7795     {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7796     {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7797     {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7798     {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7799     {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7800     {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7801     {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7802     {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7803     {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7804     {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7805     {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7806     {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7807     {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7808     {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7809     {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7810     {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7811     {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7812     {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7813     {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7814     {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7815     {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7816     {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7817     {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7818     {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7819     {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7820     {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7821     {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7822     {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7823     {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7824     {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7825     {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7826     {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7827     {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7828     {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7829     {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7830     {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7831     {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7832     {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7833     {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7834     {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7835     {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7836     {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7837     {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7838     {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7839     {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7840     {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7841     {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7842     {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7843     {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7844     {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7845     {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7846     {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7847     {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7848     {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7849     {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7850     {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7851     {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7852     {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7853     {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7854     {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7855     {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7856     {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7857     {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7858     {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7859     {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7860     {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7861     {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7862     {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7863     {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7864     {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7865     {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7866     {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7867     {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7868     {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7869     {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7870     {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7871     {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7872     {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7873     {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7874     {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7875     {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7876     {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7877     {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7878     {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7879     {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7880     {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7881     {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7882     {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7883     {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7884     {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7885     {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7886     {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7887     {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7888     {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7889     {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7890     {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7891     {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7892     {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7893     {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7894     {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7895     {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7896     {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7897     {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7898     {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7899     {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7900     {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7901     {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7902     {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7903     {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7904     {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7905     {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7906     {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7907     {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7908     {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7909     {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7910     {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7911     {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7912     {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7913     {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7914     {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7915     {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7916     {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7917     {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7918     {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7919     {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7920     {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7921     {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7922     {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7923     {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7924     {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7925     {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7926     {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7927     {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7928     {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7929     {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7930     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7931     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7932     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7933     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7934 };
7935
7936 static DWORD get_pf_file_size(LPCSTR file)
7937 {
7938     CHAR path[MAX_PATH];
7939     HANDLE hfile;
7940     DWORD size;
7941
7942     lstrcpyA(path, PROG_FILES_DIR);
7943     lstrcatA(path, "\\");
7944     lstrcatA(path, file);
7945
7946     hfile = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
7947     if (hfile == INVALID_HANDLE_VALUE)
7948         return INVALID_FILE_SIZE;
7949
7950     size = GetFileSize(hfile, NULL);
7951     CloseHandle(hfile);
7952     return size;
7953 }
7954
7955 static void test_sourcepath(void)
7956 {
7957     UINT r, i;
7958
7959     if (!winetest_interactive)
7960     {
7961         skip("Run in interactive mode to run source path tests.\n");
7962         return;
7963     }
7964
7965     create_database(msifile, sp_tables, sizeof(sp_tables) / sizeof(msi_table));
7966
7967     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7968
7969     for (i = 0; i < sizeof(spmap) / sizeof(spmap[0]); i++)
7970     {
7971         if (spmap[i].sost)
7972         {
7973             CreateDirectoryA("shortone", NULL);
7974             CreateDirectoryA("shortone\\shorttwo", NULL);
7975         }
7976
7977         if (spmap[i].solt)
7978         {
7979             CreateDirectoryA("shortone", NULL);
7980             CreateDirectoryA("shortone\\longtwo", NULL);
7981         }
7982
7983         if (spmap[i].lost)
7984         {
7985             CreateDirectoryA("longone", NULL);
7986             CreateDirectoryA("longone\\shorttwo", NULL);
7987         }
7988
7989         if (spmap[i].lolt)
7990         {
7991             CreateDirectoryA("longone", NULL);
7992             CreateDirectoryA("longone\\longtwo", NULL);
7993         }
7994
7995         if (spmap[i].soste)
7996             create_file("shortone\\shorttwo\\augustus", 50);
7997         if (spmap[i].solte)
7998             create_file("shortone\\longtwo\\augustus", 100);
7999         if (spmap[i].loste)
8000             create_file("longone\\shorttwo\\augustus", 150);
8001         if (spmap[i].lolte)
8002             create_file("longone\\longtwo\\augustus", 200);
8003
8004         r = MsiInstallProductA(msifile, NULL);
8005         ok(r == spmap[i].err, "%d: Expected %d, got %d\n", i, spmap[i].err, r);
8006         ok(get_pf_file_size("msitest\\augustus") == spmap[i].size,
8007            "%d: Expected %d, got %d\n", i, spmap[i].size,
8008            get_pf_file_size("msitest\\augustus"));
8009
8010         if (r == ERROR_SUCCESS)
8011         {
8012             ok(delete_pf("msitest\\augustus", TRUE), "%d: File not installed\n", i);
8013             ok(delete_pf("msitest", FALSE), "%d: File not installed\n", i);
8014         }
8015         else
8016         {
8017             ok(!delete_pf("msitest\\augustus", TRUE), "%d: File installed\n", i);
8018             todo_wine ok(!delete_pf("msitest", FALSE), "%d: File installed\n", i);
8019         }
8020
8021         DeleteFileA("shortone\\shorttwo\\augustus");
8022         DeleteFileA("shortone\\longtwo\\augustus");
8023         DeleteFileA("longone\\shorttwo\\augustus");
8024         DeleteFileA("longone\\longtwo\\augustus");
8025         RemoveDirectoryA("shortone\\shorttwo");
8026         RemoveDirectoryA("shortone\\longtwo");
8027         RemoveDirectoryA("longone\\shorttwo");
8028         RemoveDirectoryA("longone\\longtwo");
8029         RemoveDirectoryA("shortone");
8030         RemoveDirectoryA("longone");
8031     }
8032
8033     DeleteFileA(msifile);
8034 }
8035
8036 static void test_MsiConfigureProductEx(void)
8037 {
8038     UINT r;
8039     LONG res;
8040     DWORD type, size;
8041     HKEY props, source;
8042     CHAR keypath[MAX_PATH * 2], localpack[MAX_PATH];
8043     REGSAM access = KEY_ALL_ACCESS;
8044     BOOL wow64;
8045
8046     if (on_win9x)
8047     {
8048         win_skip("Different registry keys on Win9x and WinMe\n");
8049         return;
8050     }
8051     if (is_process_limited())
8052     {
8053         skip("process is limited\n");
8054         return;
8055     }
8056
8057     CreateDirectoryA("msitest", NULL);
8058     create_file("msitest\\hydrogen", 500);
8059     create_file("msitest\\helium", 500);
8060     create_file("msitest\\lithium", 500);
8061
8062     create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
8063
8064     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
8065         access |= KEY_WOW64_64KEY;
8066
8067     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8068
8069     /* NULL szProduct */
8070     r = MsiConfigureProductExA(NULL, INSTALLLEVEL_DEFAULT,
8071                                INSTALLSTATE_DEFAULT, "PROPVAR=42");
8072     ok(r == ERROR_INVALID_PARAMETER,
8073        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8074
8075     /* empty szProduct */
8076     r = MsiConfigureProductExA("", INSTALLLEVEL_DEFAULT,
8077                                INSTALLSTATE_DEFAULT, "PROPVAR=42");
8078     ok(r == ERROR_INVALID_PARAMETER,
8079        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8080
8081     /* garbage szProduct */
8082     r = MsiConfigureProductExA("garbage", INSTALLLEVEL_DEFAULT,
8083                                INSTALLSTATE_DEFAULT, "PROPVAR=42");
8084     ok(r == ERROR_INVALID_PARAMETER,
8085        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8086
8087     /* guid without brackets */
8088     r = MsiConfigureProductExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
8089                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
8090                                "PROPVAR=42");
8091     ok(r == ERROR_INVALID_PARAMETER,
8092        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8093
8094     /* guid with brackets */
8095     r = MsiConfigureProductExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
8096                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
8097                                "PROPVAR=42");
8098     ok(r == ERROR_UNKNOWN_PRODUCT,
8099        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
8100
8101     /* same length as guid, but random */
8102     r = MsiConfigureProductExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
8103                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
8104                                "PROPVAR=42");
8105     ok(r == ERROR_UNKNOWN_PRODUCT,
8106        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
8107
8108     /* product not installed yet */
8109     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8110                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
8111                                "PROPVAR=42");
8112     ok(r == ERROR_UNKNOWN_PRODUCT,
8113        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
8114
8115     /* install the product, per-user unmanaged */
8116     r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42");
8117     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8118     {
8119         skip("Not enough rights to perform tests\n");
8120         goto error;
8121     }
8122     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8123     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
8124     ok(pf_exists("msitest\\helium"), "File not installed\n");
8125     ok(pf_exists("msitest\\lithium"), "File not installed\n");
8126     ok(pf_exists("msitest"), "File not installed\n");
8127
8128     /* product is installed per-user managed, remove it */
8129     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8130                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
8131                                "PROPVAR=42");
8132     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8133     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
8134     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
8135     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
8136     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
8137
8138     /* product has been removed */
8139     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8140                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
8141                                "PROPVAR=42");
8142     ok(r == ERROR_UNKNOWN_PRODUCT,
8143        "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
8144
8145     /* install the product, machine */
8146     r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
8147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8148     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
8149     ok(pf_exists("msitest\\helium"), "File not installed\n");
8150     ok(pf_exists("msitest\\lithium"), "File not installed\n");
8151     ok(pf_exists("msitest"), "File not installed\n");
8152
8153     /* product is installed machine, remove it */
8154     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8155                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
8156                                "PROPVAR=42");
8157     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8158     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
8159     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
8160     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
8161     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
8162
8163     /* product has been removed */
8164     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8165                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
8166                                "PROPVAR=42");
8167     ok(r == ERROR_UNKNOWN_PRODUCT,
8168        "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
8169
8170     /* install the product, machine */
8171     r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
8172     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8173     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
8174     ok(pf_exists("msitest\\helium"), "File not installed\n");
8175     ok(pf_exists("msitest\\lithium"), "File not installed\n");
8176     ok(pf_exists("msitest"), "File not installed\n");
8177
8178     DeleteFileA(msifile);
8179
8180     /* local msifile is removed */
8181     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8182                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
8183                                "PROPVAR=42");
8184     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8185     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
8186     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
8187     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
8188     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
8189
8190     create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
8191
8192     /* install the product, machine */
8193     r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
8194     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8195     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
8196     ok(pf_exists("msitest\\helium"), "File not installed\n");
8197     ok(pf_exists("msitest\\lithium"), "File not installed\n");
8198     ok(pf_exists("msitest"), "File not installed\n");
8199
8200     DeleteFileA(msifile);
8201
8202     lstrcpyA(keypath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
8203     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
8204     lstrcatA(keypath, "84A88FD7F6998CE40A22FB59F6B9C2BB\\InstallProperties");
8205
8206     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
8207     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8208
8209     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
8210                          (const BYTE *)"C:\\idontexist.msi", 18);
8211     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8212
8213     /* LocalPackage is used to find the cached msi package */
8214     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8215                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
8216                                "PROPVAR=42");
8217     ok(r == ERROR_INSTALL_SOURCE_ABSENT,
8218        "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r);
8219     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
8220     ok(pf_exists("msitest\\helium"), "File not installed\n");
8221     ok(pf_exists("msitest\\lithium"), "File not installed\n");
8222     ok(pf_exists("msitest"), "File not installed\n");
8223
8224     RegCloseKey(props);
8225     create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
8226
8227     /* LastUsedSource (local msi package) can be used as a last resort */
8228     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8229                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
8230                                "PROPVAR=42");
8231     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8232     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
8233     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
8234     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
8235     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
8236
8237     /* install the product, machine */
8238     r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
8239     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8240     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
8241     ok(pf_exists("msitest\\helium"), "File not installed\n");
8242     ok(pf_exists("msitest\\lithium"), "File not installed\n");
8243     ok(pf_exists("msitest"), "File not installed\n");
8244
8245     lstrcpyA(keypath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
8246     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
8247     lstrcatA(keypath, "84A88FD7F6998CE40A22FB59F6B9C2BB\\InstallProperties");
8248
8249     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
8250     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8251
8252     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
8253                          (const BYTE *)"C:\\idontexist.msi", 18);
8254     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8255
8256     lstrcpyA(keypath, "SOFTWARE\\Classes\\Installer\\Products\\");
8257     lstrcatA(keypath, "84A88FD7F6998CE40A22FB59F6B9C2BB\\SourceList");
8258
8259     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &source);
8260     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8261
8262     type = REG_SZ;
8263     size = MAX_PATH;
8264     res = RegQueryValueExA(source, "PackageName", NULL, &type,
8265                            (LPBYTE)localpack, &size);
8266     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8267
8268     res = RegSetValueExA(source, "PackageName", 0, REG_SZ,
8269                          (const BYTE *)"idontexist.msi", 15);
8270     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8271
8272     /* SourceList is altered */
8273     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8274                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
8275                                "PROPVAR=42");
8276     ok(r == ERROR_INSTALL_SOURCE_ABSENT,
8277        "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r);
8278     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
8279     ok(pf_exists("msitest\\helium"), "File not installed\n");
8280     ok(pf_exists("msitest\\lithium"), "File not installed\n");
8281     ok(pf_exists("msitest"), "File not installed\n");
8282
8283     /* restore the SourceList */
8284     res = RegSetValueExA(source, "PackageName", 0, REG_SZ,
8285                          (const BYTE *)localpack, lstrlenA(localpack) + 1);
8286     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8287
8288     /* finally remove the product */
8289     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
8290                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
8291                                "PROPVAR=42");
8292     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8293     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
8294     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
8295     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
8296     ok(!delete_pf("msitest", FALSE), "File not removed\n");
8297
8298     RegCloseKey(source);
8299     RegCloseKey(props);
8300
8301 error:
8302     DeleteFileA("msitest\\hydrogen");
8303     DeleteFileA("msitest\\helium");
8304     DeleteFileA("msitest\\lithium");
8305     RemoveDirectoryA("msitest");
8306     DeleteFileA(msifile);
8307 }
8308
8309 static void test_missingcomponent(void)
8310 {
8311     UINT r;
8312
8313     if (is_process_limited())
8314     {
8315         skip("process is limited\n");
8316         return;
8317     }
8318
8319     CreateDirectoryA("msitest", NULL);
8320     create_file("msitest\\hydrogen", 500);
8321     create_file("msitest\\helium", 500);
8322     create_file("msitest\\lithium", 500);
8323     create_file("beryllium", 500);
8324
8325     create_database(msifile, mcomp_tables, sizeof(mcomp_tables) / sizeof(msi_table));
8326
8327     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8328
8329     r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42");
8330     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8331     {
8332         skip("Not enough rights to perform tests\n");
8333         goto error;
8334     }
8335     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8336     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
8337     ok(pf_exists("msitest\\helium"), "File not installed\n");
8338     ok(pf_exists("msitest\\lithium"), "File not installed\n");
8339     ok(!pf_exists("msitest\\beryllium"), "File installed\n");
8340     ok(pf_exists("msitest"), "File not installed\n");
8341
8342     r = MsiInstallProductA(msifile, "REMOVE=ALL INSTALLLEVEL=10 PROPVAR=42");
8343     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8344     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
8345     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
8346     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
8347     ok(!pf_exists("msitest\\beryllium"), "File installed\n");
8348     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
8349
8350 error:
8351     DeleteFileA(msifile);
8352     DeleteFileA("msitest\\hydrogen");
8353     DeleteFileA("msitest\\helium");
8354     DeleteFileA("msitest\\lithium");
8355     DeleteFileA("beryllium");
8356     RemoveDirectoryA("msitest");
8357 }
8358
8359 static void test_sourcedirprop(void)
8360 {
8361     UINT r;
8362     CHAR props[MAX_PATH];
8363
8364     if (is_process_limited())
8365     {
8366         skip("process is limited\n");
8367         return;
8368     }
8369
8370     CreateDirectoryA("msitest", NULL);
8371     create_file("msitest\\augustus", 500);
8372
8373     create_database(msifile, ca51_tables, sizeof(ca51_tables) / sizeof(msi_table));
8374
8375     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8376
8377     r = MsiInstallProductA(msifile, NULL);
8378     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8379     {
8380         skip("Not enough rights to perform tests\n");
8381         goto error;
8382     }
8383     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8384     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
8385     ok(delete_pf("msitest", FALSE), "File installed\n");
8386
8387     DeleteFile("msitest\\augustus");
8388     RemoveDirectory("msitest");
8389
8390     CreateDirectoryA("altsource", NULL);
8391     CreateDirectoryA("altsource\\msitest", NULL);
8392     create_file("altsource\\msitest\\augustus", 500);
8393
8394     sprintf(props, "SRCDIR=%s\\altsource\\", CURR_DIR);
8395
8396     r = MsiInstallProductA(msifile, props);
8397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8398     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
8399     ok(delete_pf("msitest", FALSE), "File installed\n");
8400
8401     DeleteFile("altsource\\msitest\\augustus");
8402     RemoveDirectory("altsource\\msitest");
8403     RemoveDirectory("altsource");
8404
8405 error:
8406     DeleteFile("msitest\\augustus");
8407     RemoveDirectory("msitest");
8408     DeleteFile(msifile);
8409 }
8410
8411 static void test_adminimage(void)
8412 {
8413     UINT r;
8414
8415     if (is_process_limited())
8416     {
8417         skip("process is limited\n");
8418         return;
8419     }
8420
8421     CreateDirectoryA("msitest", NULL);
8422     CreateDirectoryA("msitest\\first", NULL);
8423     CreateDirectoryA("msitest\\second", NULL);
8424     CreateDirectoryA("msitest\\cabout", NULL);
8425     CreateDirectoryA("msitest\\cabout\\new", NULL);
8426     create_file("msitest\\one.txt", 100);
8427     create_file("msitest\\first\\two.txt", 100);
8428     create_file("msitest\\second\\three.txt", 100);
8429     create_file("msitest\\cabout\\four.txt", 100);
8430     create_file("msitest\\cabout\\new\\five.txt", 100);
8431     create_file("msitest\\filename", 100);
8432     create_file("msitest\\service.exe", 100);
8433
8434     create_database_wordcount(msifile, ai_tables,
8435                               sizeof(ai_tables) / sizeof(msi_table),
8436                               msidbSumInfoSourceTypeAdminImage);
8437
8438     r = MsiInstallProductA(msifile, NULL);
8439     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8440     {
8441         skip("Not enough rights to perform tests\n");
8442         goto error;
8443     }
8444     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8445
8446     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8447     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8448     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8449     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8450     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8451     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8452     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8453     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8454     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
8455     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8456     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8457     ok(delete_pf("msitest", FALSE), "File not installed\n");
8458
8459 error:
8460     DeleteFileA("msifile");
8461     DeleteFileA("msitest\\cabout\\new\\five.txt");
8462     DeleteFileA("msitest\\cabout\\four.txt");
8463     DeleteFileA("msitest\\second\\three.txt");
8464     DeleteFileA("msitest\\first\\two.txt");
8465     DeleteFileA("msitest\\one.txt");
8466     DeleteFileA("msitest\\service.exe");
8467     DeleteFileA("msitest\\filename");
8468     RemoveDirectoryA("msitest\\cabout\\new");
8469     RemoveDirectoryA("msitest\\cabout");
8470     RemoveDirectoryA("msitest\\second");
8471     RemoveDirectoryA("msitest\\first");
8472     RemoveDirectoryA("msitest");
8473 }
8474
8475 static void test_propcase(void)
8476 {
8477     UINT r;
8478
8479     if (is_process_limited())
8480     {
8481         skip("process is limited\n");
8482         return;
8483     }
8484
8485     CreateDirectoryA("msitest", NULL);
8486     create_file("msitest\\augustus", 500);
8487
8488     create_database(msifile, pc_tables, sizeof(pc_tables) / sizeof(msi_table));
8489
8490     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8491
8492     r = MsiInstallProductA(msifile, "MyProp=42");
8493     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8494     {
8495         skip("Not enough rights to perform tests\n");
8496         goto error;
8497     }
8498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8499     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
8500     ok(delete_pf("msitest", FALSE), "File not installed\n");
8501
8502 error:
8503     DeleteFile(msifile);
8504     DeleteFile("msitest\\augustus");
8505     RemoveDirectory("msitest");
8506 }
8507
8508 static void test_int_widths( void )
8509 {
8510     static const char int0[] = "int0\ni0\nint0\tint0\n1";
8511     static const char int1[] = "int1\ni1\nint1\tint1\n1";
8512     static const char int2[] = "int2\ni2\nint2\tint2\n1";
8513     static const char int3[] = "int3\ni3\nint3\tint3\n1";
8514     static const char int4[] = "int4\ni4\nint4\tint4\n1";
8515     static const char int5[] = "int5\ni5\nint5\tint5\n1";
8516     static const char int8[] = "int8\ni8\nint8\tint8\n1";
8517
8518     static const struct
8519     {
8520         const char  *data;
8521         unsigned int size;
8522         UINT         ret;
8523     }
8524     tests[] =
8525     {
8526         { int0, sizeof(int0) - 1, ERROR_SUCCESS },
8527         { int1, sizeof(int1) - 1, ERROR_SUCCESS },
8528         { int2, sizeof(int2) - 1, ERROR_SUCCESS },
8529         { int3, sizeof(int3) - 1, ERROR_FUNCTION_FAILED },
8530         { int4, sizeof(int4) - 1, ERROR_SUCCESS },
8531         { int5, sizeof(int5) - 1, ERROR_FUNCTION_FAILED },
8532         { int8, sizeof(int8) - 1, ERROR_FUNCTION_FAILED }
8533     };
8534
8535     char tmpdir[MAX_PATH], msitable[MAX_PATH], msidb[MAX_PATH];
8536     MSIHANDLE db;
8537     UINT r, i;
8538
8539     GetTempPathA(MAX_PATH, tmpdir);
8540     CreateDirectoryA(tmpdir, NULL);
8541
8542     strcpy(msitable, tmpdir);
8543     strcat(msitable, "\\msitable.idt");
8544
8545     strcpy(msidb, tmpdir);
8546     strcat(msidb, "\\msitest.msi");
8547
8548     r = MsiOpenDatabaseA(msidb, MSIDBOPEN_CREATE, &db);
8549     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8550
8551     for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
8552     {
8553         write_file(msitable, tests[i].data, tests[i].size);
8554
8555         r = MsiDatabaseImportA(db, tmpdir, "msitable.idt");
8556         ok(r == tests[i].ret, " %u expected %u, got %u\n", i, tests[i].ret, r);
8557
8558         r = MsiDatabaseCommit(db);
8559         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8560         DeleteFileA(msitable);
8561     }
8562
8563     MsiCloseHandle(db);
8564     DeleteFileA(msidb);
8565     RemoveDirectoryA(tmpdir);
8566 }
8567
8568 static void test_shortcut(void)
8569 {
8570     UINT r;
8571     HRESULT hr;
8572
8573     if (is_process_limited())
8574     {
8575         skip("process is limited\n");
8576         return;
8577     }
8578
8579     create_test_files();
8580     create_database(msifile, sc_tables, sizeof(sc_tables) / sizeof(msi_table));
8581
8582     r = MsiInstallProductA(msifile, NULL);
8583     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8584     {
8585         skip("Not enough rights to perform tests\n");
8586         goto error;
8587     }
8588     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8589
8590     hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
8591     ok(SUCCEEDED(hr), "CoInitialize failed 0x%08x\n", hr);
8592
8593     r = MsiInstallProductA(msifile, NULL);
8594     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8595
8596     CoUninitialize();
8597
8598     hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
8599     ok(SUCCEEDED(hr), "CoInitialize failed 0x%08x\n", hr);
8600
8601     r = MsiInstallProductA(msifile, NULL);
8602     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8603
8604     CoUninitialize();
8605
8606     delete_pf("msitest\\cabout\\new\\five.txt", TRUE);
8607     delete_pf("msitest\\cabout\\new", FALSE);
8608     delete_pf("msitest\\cabout\\four.txt", TRUE);
8609     delete_pf("msitest\\cabout", FALSE);
8610     delete_pf("msitest\\changed\\three.txt", TRUE);
8611     delete_pf("msitest\\changed", FALSE);
8612     delete_pf("msitest\\first\\two.txt", TRUE);
8613     delete_pf("msitest\\first", FALSE);
8614     delete_pf("msitest\\filename", TRUE);
8615     delete_pf("msitest\\one.txt", TRUE);
8616     delete_pf("msitest\\service.exe", TRUE);
8617     delete_pf("msitest\\Shortcut.lnk", TRUE);
8618     delete_pf("msitest", FALSE);
8619
8620 error:
8621     delete_test_files();
8622     DeleteFile(msifile);
8623 }
8624
8625 static void test_envvar(void)
8626 {
8627     UINT r;
8628     HKEY env;
8629     LONG res;
8630     DWORD type, size;
8631     char buffer[16];
8632     UINT i;
8633
8634     if (on_win9x)
8635     {
8636         win_skip("Environment variables are handled differently on Win9x and WinMe\n");
8637         return;
8638     }
8639     if (is_process_limited())
8640     {
8641         skip("process is limited\n");
8642         return;
8643     }
8644
8645     create_test_files();
8646     create_database(msifile, env_tables, sizeof(env_tables) / sizeof(msi_table));
8647
8648     res = RegCreateKeyExA(HKEY_CURRENT_USER, "Environment", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &env, NULL);
8649     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8650
8651     res = RegSetValueExA(env, "MSITESTVAR1", 0, REG_SZ, (const BYTE *)"0", 2);
8652     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8653
8654     res = RegSetValueExA(env, "MSITESTVAR2", 0, REG_SZ, (const BYTE *)"0", 2);
8655     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8656
8657     r = MsiInstallProductA(msifile, NULL);
8658     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8659     {
8660         skip("Not enough rights to perform tests\n");
8661         goto error;
8662     }
8663     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8664
8665     type = REG_NONE;
8666     size = sizeof(buffer);
8667     buffer[0] = 0;
8668     res = RegQueryValueExA(env, "MSITESTVAR1", NULL, &type, (LPBYTE)buffer, &size);
8669     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8670     ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
8671     ok(!lstrcmp(buffer, "1"), "Expected \"1\", got %s\n", buffer);
8672
8673     res = RegDeleteValueA(env, "MSITESTVAR1");
8674     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8675
8676     type = REG_NONE;
8677     size = sizeof(buffer);
8678     buffer[0] = 0;
8679     res = RegQueryValueExA(env, "MSITESTVAR2", NULL, &type, (LPBYTE)buffer, &size);
8680     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8681     ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
8682     ok(!lstrcmp(buffer, "1"), "Expected \"1\", got %s\n", buffer);
8683
8684     res = RegDeleteValueA(env, "MSITESTVAR2");
8685     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8686
8687     res = RegDeleteValueA(env, "MSITESTVAR3");
8688     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8689
8690     res = RegDeleteValueA(env, "MSITESTVAR4");
8691     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8692
8693     res = RegDeleteValueA(env, "MSITESTVAR5");
8694     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
8695
8696     res = RegDeleteValueA(env, "MSITESTVAR6");
8697     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
8698
8699     res = RegDeleteValueA(env, "MSITESTVAR7");
8700     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
8701
8702     res = RegDeleteValueA(env, "MSITESTVAR8");
8703     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
8704
8705     res = RegDeleteValueA(env, "MSITESTVAR9");
8706     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
8707
8708     res = RegDeleteValueA(env, "MSITESTVAR10");
8709     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
8710
8711     i = 11;
8712     while (environment_dat_results[(i-11)]) {
8713         char name[20];
8714         sprintf(name, "MSITESTVAR%d", i);
8715
8716         type = REG_NONE;
8717         size = sizeof(buffer);
8718         buffer[0] = 0;
8719         res = RegQueryValueExA(env, name, NULL, &type, (LPBYTE)buffer, &size);
8720         ok(res == ERROR_SUCCESS, "%d: Expected ERROR_SUCCESS, got %d\n", i, res);
8721         ok(type == REG_SZ, "%d: Expected REG_SZ, got %u\n", i, type);
8722         ok(!lstrcmp(buffer, environment_dat_results[(i-11)]), "%d: Expected %s, got %s\n",
8723            i, environment_dat_results[(i-11)], buffer);
8724
8725         res = RegDeleteValueA(env, name);
8726         ok(res == ERROR_SUCCESS, "%d: Expected ERROR_SUCCESS, got %d\n", i, res);
8727         i++;
8728     }
8729
8730     delete_pf("msitest\\cabout\\new\\five.txt", TRUE);
8731     delete_pf("msitest\\cabout\\new", FALSE);
8732     delete_pf("msitest\\cabout\\four.txt", TRUE);
8733     delete_pf("msitest\\cabout", FALSE);
8734     delete_pf("msitest\\changed\\three.txt", TRUE);
8735     delete_pf("msitest\\changed", FALSE);
8736     delete_pf("msitest\\first\\two.txt", TRUE);
8737     delete_pf("msitest\\first", FALSE);
8738     delete_pf("msitest\\filename", TRUE);
8739     delete_pf("msitest\\one.txt", TRUE);
8740     delete_pf("msitest\\service.exe", TRUE);
8741     delete_pf("msitest", FALSE);
8742
8743 error:
8744     RegDeleteValueA(env, "MSITESTVAR1");
8745     RegDeleteValueA(env, "MSITESTVAR2");
8746     RegCloseKey(env);
8747
8748     delete_test_files();
8749     DeleteFile(msifile);
8750 }
8751
8752 static void test_preselected(void)
8753 {
8754     UINT r;
8755
8756     if (is_process_limited())
8757     {
8758         skip("process is limited\n");
8759         return;
8760     }
8761
8762     create_test_files();
8763     create_database(msifile, ps_tables, sizeof(ps_tables) / sizeof(msi_table));
8764
8765     r = MsiInstallProductA(msifile, "ADDLOCAL=One");
8766     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8767     {
8768         skip("Not enough rights to perform tests\n");
8769         goto error;
8770     }
8771     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8772
8773     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
8774     ok(!delete_pf("msitest\\cabout\\new", FALSE), "File installed\n");
8775     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
8776     ok(!delete_pf("msitest\\cabout", FALSE), "File installed\n");
8777     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
8778     ok(!delete_pf("msitest\\changed", FALSE), "File installed\n");
8779     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
8780     ok(!delete_pf("msitest\\first", FALSE), "File installed\n");
8781     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
8782     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
8783     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
8784     ok(delete_pf("msitest", FALSE), "File not installed\n");
8785
8786     r = MsiInstallProductA(msifile, NULL);
8787     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8788
8789     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8790     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8791     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8792     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8793     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8794     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8795     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8796     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8797     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8798     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8799     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8800     ok(delete_pf("msitest", FALSE), "File not installed\n");
8801
8802 error:
8803     delete_test_files();
8804     DeleteFile(msifile);
8805 }
8806
8807 static void test_installed_prop(void)
8808 {
8809     static char prodcode[] = "{7df88a48-996f-4ec8-a022-bf956f9b2cbb}";
8810     UINT r;
8811
8812     if (is_process_limited())
8813     {
8814         skip("process is limited\n");
8815         return;
8816     }
8817
8818     create_test_files();
8819     create_database(msifile, ip_tables, sizeof(ip_tables) / sizeof(msi_table));
8820
8821     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8822
8823     r = MsiInstallProductA(msifile, "FULL=1");
8824     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8825     {
8826         skip("Not enough rights to perform tests\n");
8827         goto error;
8828     }
8829     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8830
8831     r = MsiInstallProductA(msifile, "FULL=1");
8832     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8833
8834     r = MsiConfigureProductExA(prodcode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, "FULL=1");
8835     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8836
8837     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8838     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8839     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8840     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8841     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8842     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8843     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8844     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8845     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8846     ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8847     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8848     ok(delete_pf("msitest", FALSE), "File not installed\n");
8849
8850     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8851     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8852
8853 error:
8854     delete_test_files();
8855     DeleteFile(msifile);
8856 }
8857
8858 static void test_allusers_prop(void)
8859 {
8860     UINT r;
8861
8862     if (is_process_limited())
8863     {
8864         skip("process is limited\n");
8865         return;
8866     }
8867
8868     create_test_files();
8869     create_database(msifile, aup_tables, sizeof(aup_tables) / sizeof(msi_table));
8870
8871     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8872
8873     /* ALLUSERS property unset */
8874     r = MsiInstallProductA(msifile, "FULL=1");
8875     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8876     {
8877         skip("Not enough rights to perform tests\n");
8878         goto error;
8879     }
8880     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8881
8882     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8883     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8884     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8885     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8886     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8887     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8888     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8889     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8890     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8891     ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8892     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8893     ok(delete_pf("msitest", FALSE), "File not installed\n");
8894
8895     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8896     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8897
8898     delete_test_files();
8899
8900     create_test_files();
8901     create_database(msifile, aup2_tables, sizeof(aup2_tables) / sizeof(msi_table));
8902
8903     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8904
8905     /* ALLUSERS property set to 1 */
8906     r = MsiInstallProductA(msifile, "FULL=1");
8907     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8908
8909     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8910     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8911     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8912     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8913     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8914     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8915     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8916     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8917     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8918     ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8919     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8920     ok(delete_pf("msitest", FALSE), "File not installed\n");
8921
8922     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8923     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8924
8925     delete_test_files();
8926
8927     create_test_files();
8928     create_database(msifile, aup3_tables, sizeof(aup3_tables) / sizeof(msi_table));
8929
8930     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8931
8932     /* ALLUSERS property set to 2 */
8933     r = MsiInstallProductA(msifile, "FULL=1");
8934     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8935
8936     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8937     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8938     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8939     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8940     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8941     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8942     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8943     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8944     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8945     ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8946     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8947     ok(delete_pf("msitest", FALSE), "File not installed\n");
8948
8949     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8950     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8951
8952     delete_test_files();
8953
8954     create_test_files();
8955     create_database(msifile, aup4_tables, sizeof(aup4_tables) / sizeof(msi_table));
8956
8957     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8958
8959     /* ALLUSERS property set to 2, conditioned on ALLUSERS = 1 */
8960     r = MsiInstallProductA(msifile, "FULL=1");
8961     if (r == ERROR_SUCCESS)
8962     {
8963         /* Win9x/WinMe */
8964         win_skip("Win9x and WinMe act differently with respect to ALLUSERS\n");
8965
8966         ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8967         ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8968         ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8969         ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8970         ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8971         ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8972         ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8973         ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8974         ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8975         ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8976         ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8977         ok(delete_pf("msitest", FALSE), "File not installed\n");
8978
8979         r = MsiInstallProductA(msifile, "REMOVE=ALL");
8980         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8981
8982         delete_test_files();
8983     }
8984     else
8985         ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8986
8987 error:
8988     delete_test_files();
8989     DeleteFile(msifile);
8990 }
8991
8992 static char session_manager[] = "System\\CurrentControlSet\\Control\\Session Manager";
8993 static char rename_ops[]      = "PendingFileRenameOperations";
8994
8995 static void process_pending_renames(HKEY hkey)
8996 {
8997     char *buf, *src, *dst, *buf2, *buf2ptr;
8998     DWORD size, buf2len = 0;
8999     LONG ret;
9000     BOOL found = FALSE;
9001
9002     ret = RegQueryValueExA(hkey, rename_ops, NULL, NULL, NULL, &size);
9003     buf = HeapAlloc(GetProcessHeap(), 0, size);
9004     buf2ptr = buf2 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
9005     buf[0] = 0;
9006
9007     ret = RegQueryValueExA(hkey, rename_ops, NULL, NULL, (LPBYTE)buf, &size);
9008     ok(!ret, "RegQueryValueExA failed %d (%u)\n", ret, GetLastError());
9009
9010     for (src = buf; *src; src = dst + strlen(dst) + 1)
9011     {
9012         DWORD flags = MOVEFILE_COPY_ALLOWED;
9013
9014         dst = src + strlen(src) + 1;
9015
9016         if (!strstr(src, "msitest"))
9017         {
9018             lstrcpyA(buf2ptr, src);
9019             buf2len += strlen(src) + 1;
9020             buf2ptr += strlen(src) + 1;
9021             if (*dst)
9022             {
9023                 lstrcpyA(buf2ptr, dst);
9024                 buf2ptr += strlen(dst) + 1;
9025                 buf2len += strlen(dst) + 1;
9026             }
9027             buf2ptr++;
9028             buf2len++;
9029             continue;
9030         }
9031
9032         found = TRUE;
9033
9034         if (*dst == '!')
9035         {
9036             flags |= MOVEFILE_REPLACE_EXISTING;
9037             dst++;
9038         }
9039         if (src[0] == '\\' && src[1] == '?' && src[2] == '?' && src[3] == '\\') src += 4;
9040         if (*dst)
9041         {
9042             if (dst[0] == '\\' && dst[1] == '?' && dst[2] == '?' && dst[3] == '\\') dst += 4;
9043             ok(MoveFileExA(src, dst, flags), "Failed to move file %s -> %s (%u)\n", src, dst, GetLastError());
9044         }
9045         else
9046             ok(DeleteFileA(src), "Failed to delete file %s (%u)\n", src, GetLastError());
9047     }
9048
9049     ok(found, "Expected a 'msitest' entry\n");
9050
9051     if (*buf2)
9052     {
9053         buf2len++;
9054         RegSetValueExA(hkey, rename_ops, 0, REG_MULTI_SZ, (LPBYTE)buf2, buf2len);
9055     }
9056     else
9057         RegDeleteValueA(hkey, rename_ops);
9058
9059     HeapFree(GetProcessHeap(), 0, buf);
9060     HeapFree(GetProcessHeap(), 0, buf2);
9061 }
9062
9063 static BOOL file_matches_data(LPCSTR file, LPCSTR data)
9064 {
9065     DWORD len, data_len = strlen(data);
9066     HANDLE handle;
9067     char buf[128];
9068
9069     handle = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
9070     ok(handle != INVALID_HANDLE_VALUE, "failed to open %s (%u)\n", file, GetLastError());
9071
9072     if (ReadFile(handle, buf, sizeof(buf), &len, NULL) && len >= data_len)
9073     {
9074         CloseHandle(handle);
9075         return !memcmp(buf, data, data_len);
9076     }
9077     CloseHandle(handle);
9078     return FALSE;
9079 }
9080
9081 static void test_file_in_use(void)
9082 {
9083     UINT r;
9084     HANDLE file;
9085     HKEY hkey;
9086     char path[MAX_PATH];
9087
9088     if (on_win9x)
9089     {
9090         win_skip("Pending file renaming is implemented differently on Win9x and WinMe\n");
9091         return;
9092     }
9093     if (is_process_limited())
9094     {
9095         skip("process is limited\n");
9096         return;
9097     }
9098
9099     RegOpenKeyExA(HKEY_LOCAL_MACHINE, session_manager, 0, KEY_ALL_ACCESS, &hkey);
9100
9101     CreateDirectoryA("msitest", NULL);
9102     create_file("msitest\\maximus", 500);
9103     create_database(msifile, fiu_tables, sizeof(fiu_tables) / sizeof(msi_table));
9104
9105     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9106
9107     lstrcpy(path, PROG_FILES_DIR);
9108     lstrcat(path, "\\msitest");
9109     CreateDirectoryA(path, NULL);
9110
9111     lstrcat(path, "\\maximus");
9112     file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
9113
9114     r = MsiInstallProductA(msifile, "REBOOT=ReallySuppress FULL=1");
9115     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9116     {
9117         skip("Not enough rights to perform tests\n");
9118         goto error;
9119     }
9120     ok(r == ERROR_SUCCESS_REBOOT_REQUIRED, "Expected ERROR_SUCCESS_REBOOT_REQUIRED got %u\n", r);
9121     ok(!file_matches_data(path, "msitest\\maximus"), "Expected file not to match\n");
9122     CloseHandle(file);
9123     ok(!file_matches_data(path, "msitest\\maximus"), "Expected file not to match\n");
9124
9125     process_pending_renames(hkey);
9126     RegCloseKey(hkey);
9127
9128     ok(file_matches_data(path, "msitest\\maximus"), "Expected file to match\n");
9129     ok(delete_pf("msitest\\maximus", TRUE), "File not present\n");
9130     ok(delete_pf("msitest", FALSE), "Directory not present or not empty\n");
9131
9132     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9133     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9134
9135 error:
9136     RegCloseKey(hkey);
9137
9138     delete_pf("msitest\\maximus", TRUE);
9139     delete_pf("msitest", FALSE);
9140     DeleteFileA("msitest\\maximus");
9141     delete_test_files();
9142     DeleteFile(msifile);
9143 }
9144
9145 static void test_file_in_use_cab(void)
9146 {
9147     UINT r;
9148     HANDLE file;
9149     HKEY hkey;
9150     char path[MAX_PATH];
9151
9152     if (on_win9x)
9153     {
9154         win_skip("Pending file renaming is implemented differently on Win9x and WinMe\n");
9155         return;
9156     }
9157     if (is_process_limited())
9158     {
9159         skip("process is limited\n");
9160         return;
9161     }
9162
9163     RegOpenKeyExA(HKEY_LOCAL_MACHINE, session_manager, 0, KEY_ALL_ACCESS, &hkey);
9164
9165     CreateDirectoryA("msitest", NULL);
9166     create_file("maximus", 500);
9167     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
9168     DeleteFile("maximus");
9169
9170     create_database(msifile, fiuc_tables, sizeof(fiuc_tables) / sizeof(msi_table));
9171
9172     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9173
9174     lstrcpy(path, PROG_FILES_DIR);
9175     lstrcat(path, "\\msitest");
9176     CreateDirectoryA(path, NULL);
9177
9178     lstrcat(path, "\\maximus");
9179     file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
9180
9181     r = MsiInstallProductA(msifile, "REBOOT=ReallySuppress FULL=1");
9182     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9183     {
9184         skip("Not enough rights to perform tests\n");
9185         goto error;
9186     }
9187     ok(r == ERROR_SUCCESS_REBOOT_REQUIRED, "Expected ERROR_SUCCESS_REBOOT_REQUIRED got %u\n", r);
9188     ok(!file_matches_data(path, "maximus"), "Expected file not to match\n");
9189     CloseHandle(file);
9190     ok(!file_matches_data(path, "maximus"), "Expected file not to match\n");
9191
9192     process_pending_renames(hkey);
9193     RegCloseKey(hkey);
9194
9195     ok(file_matches_data(path, "maximus"), "Expected file to match\n");
9196     ok(delete_pf("msitest\\maximus", TRUE), "File not present\n");
9197     ok(delete_pf("msitest", FALSE), "Directory not present or not empty\n");
9198
9199     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9200     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9201
9202 error:
9203     RegCloseKey(hkey);
9204
9205     delete_pf("msitest\\maximus", TRUE);
9206     delete_pf("msitest", FALSE);
9207     DeleteFileA("msitest\\maximus");
9208     delete_cab_files();
9209     delete_test_files();
9210     DeleteFile(msifile);
9211 }
9212
9213 static INT CALLBACK handler_a(LPVOID context, UINT type, LPCSTR msg)
9214 {
9215     return IDOK;
9216 }
9217
9218 static INT CALLBACK handler_w(LPVOID context, UINT type, LPCWSTR msg)
9219 {
9220     return IDOK;
9221 }
9222
9223 static INT CALLBACK handler_record(LPVOID context, UINT type, MSIHANDLE record)
9224 {
9225     return IDOK;
9226 }
9227
9228 static void test_MsiSetExternalUI(void)
9229 {
9230     INSTALLUI_HANDLERA ret_a;
9231     INSTALLUI_HANDLERW ret_w;
9232     INSTALLUI_HANDLER_RECORD prev;
9233     UINT error;
9234
9235     ret_a = MsiSetExternalUIA(handler_a, INSTALLLOGMODE_ERROR, NULL);
9236     ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
9237
9238     ret_a = MsiSetExternalUIA(NULL, 0, NULL);
9239     ok(ret_a == handler_a, "expected %p, got %p\n", handler_a, ret_a);
9240
9241     /* Not present before Installer 3.1 */
9242     if (!pMsiSetExternalUIRecord) {
9243         win_skip("MsiSetExternalUIRecord is not available\n");
9244         return;
9245     }
9246
9247     error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, &prev);
9248     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
9249     ok(prev == NULL, "expected NULL, got %p\n", prev);
9250
9251     prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
9252     error = pMsiSetExternalUIRecord(NULL, INSTALLLOGMODE_ERROR, NULL, &prev);
9253     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
9254     ok(prev == handler_record, "expected %p, got %p\n", handler_record, prev);
9255
9256     ret_w = MsiSetExternalUIW(handler_w, INSTALLLOGMODE_ERROR, NULL);
9257     ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
9258
9259     ret_w = MsiSetExternalUIW(NULL, 0, NULL);
9260     ok(ret_w == handler_w, "expected %p, got %p\n", handler_w, ret_w);
9261
9262     ret_a = MsiSetExternalUIA(handler_a, INSTALLLOGMODE_ERROR, NULL);
9263     ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
9264
9265     ret_w = MsiSetExternalUIW(handler_w, INSTALLLOGMODE_ERROR, NULL);
9266     ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
9267
9268     prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
9269     error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, &prev);
9270     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
9271     ok(prev == NULL, "expected NULL, got %p\n", prev);
9272
9273     ret_a = MsiSetExternalUIA(NULL, 0, NULL);
9274     ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
9275
9276     ret_w = MsiSetExternalUIW(NULL, 0, NULL);
9277     ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
9278
9279     prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
9280     error = pMsiSetExternalUIRecord(NULL, 0, NULL, &prev);
9281     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
9282     ok(prev == handler_record, "expected %p, got %p\n", handler_record, prev);
9283
9284     error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, NULL);
9285     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
9286
9287     error = pMsiSetExternalUIRecord(NULL, 0, NULL, NULL);
9288     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
9289 }
9290
9291 static void test_feature_override(void)
9292 {
9293     UINT r;
9294     REGSAM access = KEY_ALL_ACCESS;
9295     BOOL wow64;
9296
9297     if (is_process_limited())
9298     {
9299         skip("process is limited\n");
9300         return;
9301     }
9302
9303     create_test_files();
9304     create_file("msitest\\override.txt", 1000);
9305     create_file("msitest\\preselected.txt", 1000);
9306     create_file("msitest\\notpreselected.txt", 1000);
9307     create_database(msifile, fo_tables, sizeof(fo_tables) / sizeof(msi_table));
9308
9309     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
9310         access |= KEY_WOW64_64KEY;
9311
9312     r = MsiInstallProductA(msifile, "ADDLOCAL=override");
9313     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9314     {
9315         skip("Not enough rights to perform tests\n");
9316         goto error;
9317     }
9318     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9319
9320     ok(pf_exists("msitest\\override.txt"), "file not installed\n");
9321     ok(!pf_exists("msitest\\preselected.txt"), "file installed\n");
9322     ok(!pf_exists("msitest\\notpreselected.txt"), "file installed\n");
9323
9324     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9325     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9326
9327     ok(!delete_pf("msitest\\override.txt", TRUE), "file not removed\n");
9328
9329     r = MsiInstallProductA(msifile, "preselect=1");
9330     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9331
9332     ok(pf_exists("msitest\\override.txt"), "file not installed\n");
9333     ok(pf_exists("msitest\\preselected.txt"), "file not installed\n");
9334     ok(!pf_exists("msitest\\notpreselected.txt"), "file installed\n");
9335
9336     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9337     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9338
9339     ok(!delete_pf("msitest\\override.txt", TRUE), "file not removed\n");
9340     todo_wine {
9341     ok(delete_pf("msitest\\preselected.txt", TRUE), "file removed\n");
9342     ok(delete_pf("msitest", FALSE), "directory removed\n");
9343     }
9344
9345     r = MsiInstallProductA(msifile, NULL);
9346     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9347
9348     ok(pf_exists("msitest\\override.txt"), "file not installed\n");
9349     ok(pf_exists("msitest\\preselected.txt"), "file not installed\n");
9350     ok(!pf_exists("msitest\\notpreselected.txt"), "file installed\n");
9351
9352     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9353     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9354
9355     ok(!delete_pf("msitest\\override.txt", TRUE), "file not removed\n");
9356     todo_wine {
9357     ok(delete_pf("msitest\\preselected.txt", TRUE), "file removed\n");
9358     ok(delete_pf("msitest", FALSE), "directory removed\n");
9359     }
9360
9361     delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", access);
9362
9363 error:
9364     DeleteFileA("msitest\\override.txt");
9365     DeleteFileA("msitest\\preselected.txt");
9366     DeleteFileA("msitest\\notpreselected.txt");
9367     delete_test_files();
9368     DeleteFile(msifile);
9369 }
9370
9371 static void test_create_folder(void)
9372 {
9373     UINT r;
9374
9375     create_test_files();
9376     create_database(msifile, cf_tables, sizeof(cf_tables) / sizeof(msi_table));
9377
9378     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9379
9380     r = MsiInstallProductA(msifile, NULL);
9381     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9382     {
9383         skip("Not enough rights to perform tests\n");
9384         goto error;
9385     }
9386     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
9387
9388     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
9389     ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
9390     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
9391     ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
9392     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
9393     ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
9394     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
9395     ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
9396     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
9397     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
9398     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
9399     ok(!delete_pf("msitest", FALSE), "Directory created\n");
9400
9401     r = MsiInstallProductA(msifile, "LOCAL=Two");
9402     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
9403
9404     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
9405     ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
9406     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
9407     ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
9408     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
9409     ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
9410     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
9411     ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
9412     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
9413     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
9414     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
9415     ok(!delete_pf("msitest", FALSE), "Directory created\n");
9416
9417 error:
9418     delete_test_files();
9419     DeleteFile(msifile);
9420 }
9421
9422 static void test_remove_folder(void)
9423 {
9424     UINT r;
9425
9426     create_test_files();
9427     create_database(msifile, rf_tables, sizeof(rf_tables) / sizeof(msi_table));
9428
9429     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9430
9431     r = MsiInstallProductA(msifile, NULL);
9432     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9433     {
9434         skip("Not enough rights to perform tests\n");
9435         goto error;
9436     }
9437     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
9438
9439     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
9440     ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
9441     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
9442     ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
9443     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
9444     ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
9445     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
9446     ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
9447     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
9448     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
9449     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
9450     ok(!delete_pf("msitest", FALSE), "Directory created\n");
9451
9452     r = MsiInstallProductA(msifile, "LOCAL=Two");
9453     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
9454
9455     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
9456     ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
9457     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
9458     ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
9459     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
9460     ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
9461     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
9462     ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
9463     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
9464     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
9465     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
9466     ok(!delete_pf("msitest", FALSE), "Directory created\n");
9467
9468 error:
9469     delete_test_files();
9470     DeleteFile(msifile);
9471 }
9472
9473 static void test_start_services(void)
9474 {
9475     UINT r;
9476     SC_HANDLE scm, service;
9477     BOOL ret;
9478     DWORD error = ERROR_SUCCESS;
9479
9480     if (on_win9x)
9481     {
9482         win_skip("Services are not implemented on Win9x and WinMe\n");
9483         return;
9484     }
9485     scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
9486     if (!scm && GetLastError() == ERROR_ACCESS_DENIED)
9487     {
9488         skip("Not enough rights to perform tests\n");
9489         return;
9490     }
9491     ok(scm != NULL, "Failed to open the SC Manager\n");
9492     if (!scm) return;
9493
9494     service = OpenService(scm, "Spooler", SC_MANAGER_ALL_ACCESS);
9495     if (!service && GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST)
9496     {
9497         win_skip("The 'Spooler' service does not exist\n");
9498         CloseServiceHandle(scm);
9499         return;
9500     }
9501     ok(service != NULL, "Failed to open Spooler, error %d\n", GetLastError());
9502     if (!service) {
9503         CloseServiceHandle(scm);
9504         return;
9505     }
9506
9507     ret = StartService(service, 0, NULL);
9508     if (!ret && (error = GetLastError()) != ERROR_SERVICE_ALREADY_RUNNING)
9509     {
9510         skip("Terminal service not available, skipping test\n");
9511         CloseServiceHandle(service);
9512         CloseServiceHandle(scm);
9513         return;
9514     }
9515
9516     CloseServiceHandle(service);
9517     CloseServiceHandle(scm);
9518
9519     create_test_files();
9520     create_database(msifile, sss_tables, sizeof(sss_tables) / sizeof(msi_table));
9521
9522     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9523
9524     r = MsiInstallProductA(msifile, NULL);
9525     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9526
9527     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
9528     ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
9529     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
9530     ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
9531     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
9532     ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
9533     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
9534     ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
9535     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
9536     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
9537     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
9538     ok(delete_pf("msitest", FALSE), "Directory not created\n");
9539
9540     delete_test_files();
9541     DeleteFile(msifile);
9542
9543     if (error == ERROR_SUCCESS)
9544     {
9545         SERVICE_STATUS status;
9546
9547         scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
9548         service = OpenService(scm, "Spooler", SC_MANAGER_ALL_ACCESS);
9549
9550         ret = ControlService(service, SERVICE_CONTROL_STOP, &status);
9551         ok(ret, "ControlService failed %u\n", GetLastError());
9552
9553         CloseServiceHandle(service);
9554         CloseServiceHandle(scm);
9555     }
9556 }
9557
9558 static void test_delete_services(void)
9559 {
9560     UINT r;
9561
9562     if (on_win9x)
9563     {
9564         win_skip("Services are not implemented on Win9x and WinMe\n");
9565         return;
9566     }
9567     if (is_process_limited())
9568     {
9569         skip("process is limited\n");
9570         return;
9571     }
9572
9573     create_test_files();
9574     create_database(msifile, sds_tables, sizeof(sds_tables) / sizeof(msi_table));
9575
9576     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9577
9578     r = MsiInstallProductA(msifile, NULL);
9579     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9580     {
9581         skip("Not enough rights to perform tests\n");
9582         goto error;
9583     }
9584     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9585
9586     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9587     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9588
9589     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
9590     ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
9591     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
9592     ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
9593     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
9594     ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
9595     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
9596     ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
9597     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
9598     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
9599     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
9600     ok(delete_pf("msitest", FALSE), "Directory not created\n");
9601
9602 error:
9603     delete_test_files();
9604     DeleteFile(msifile);
9605 }
9606
9607 static void test_self_registration(void)
9608 {
9609     UINT r;
9610
9611     if (is_process_limited())
9612     {
9613         skip("process is limited\n");
9614         return;
9615     }
9616
9617     create_test_files();
9618     create_database(msifile, sr_tables, sizeof(sr_tables) / sizeof(msi_table));
9619
9620     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9621
9622     r = MsiInstallProductA(msifile, NULL);
9623     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9624     {
9625         skip("Not enough rights to perform tests\n");
9626         goto error;
9627     }
9628     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9629
9630     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
9631     ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
9632     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
9633     ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
9634     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
9635     ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
9636     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
9637     ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
9638     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
9639     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
9640     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
9641     ok(delete_pf("msitest", FALSE), "Directory not created\n");
9642
9643 error:
9644     delete_test_files();
9645     DeleteFile(msifile);
9646 }
9647
9648 static void test_register_font(void)
9649 {
9650     static const char regfont1[] = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
9651     static const char regfont2[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Fonts";
9652     LONG ret;
9653     HKEY key;
9654     UINT r;
9655     REGSAM access = KEY_ALL_ACCESS;
9656     BOOL wow64;
9657
9658     if (is_process_limited())
9659     {
9660         skip("process is limited\n");
9661         return;
9662     }
9663
9664     create_test_files();
9665     create_file("msitest\\font.ttf", 1000);
9666     create_database(msifile, font_tables, sizeof(font_tables) / sizeof(msi_table));
9667
9668     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
9669         access |= KEY_WOW64_64KEY;
9670
9671     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9672
9673     r = MsiInstallProductA(msifile, NULL);
9674     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9675     {
9676         skip("Not enough rights to perform tests\n");
9677         goto error;
9678     }
9679     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9680
9681     ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, regfont1, 0, access, &key);
9682     if (ret)
9683         RegOpenKeyExA(HKEY_LOCAL_MACHINE, regfont2, 0, access, &key);
9684
9685     ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL);
9686     ok(ret != ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret);
9687
9688     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9689     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9690
9691     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9692
9693     ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL);
9694     ok(ret == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret);
9695
9696     RegDeleteValueA(key, "msi test font");
9697     RegCloseKey(key);
9698
9699 error:
9700     DeleteFileA("msitest\\font.ttf");
9701     delete_test_files();
9702     DeleteFile(msifile);
9703 }
9704
9705 static void test_validate_product_id(void)
9706 {
9707     UINT r;
9708
9709     if (is_process_limited())
9710     {
9711         skip("process is limited\n");
9712         return;
9713     }
9714
9715     create_test_files();
9716     create_database(msifile, vp_tables, sizeof(vp_tables) / sizeof(msi_table));
9717
9718     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9719
9720     r = MsiInstallProductA(msifile, NULL);
9721     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9722     {
9723         skip("Not enough rights to perform tests\n");
9724         goto error;
9725     }
9726     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9727
9728     r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=1");
9729     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
9730
9731     r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=2");
9732     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9733
9734     r = MsiInstallProductA(msifile, "PIDKEY=123-1234567");
9735     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
9736
9737     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
9738     ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
9739     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
9740     ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
9741     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
9742     ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
9743     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
9744     ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
9745     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
9746     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
9747     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
9748     ok(delete_pf("msitest", FALSE), "Directory not created\n");
9749
9750 error:
9751     delete_test_files();
9752     DeleteFile(msifile);
9753 }
9754
9755 static void test_install_remove_odbc(void)
9756 {
9757     UINT r;
9758
9759     if (is_process_limited())
9760     {
9761         skip("process is limited\n");
9762         return;
9763     }
9764
9765     create_test_files();
9766     create_file("msitest\\ODBCdriver.dll", 1000);
9767     create_file("msitest\\ODBCdriver2.dll", 1000);
9768     create_file("msitest\\ODBCtranslator.dll", 1000);
9769     create_file("msitest\\ODBCtranslator2.dll", 1000);
9770     create_file("msitest\\ODBCsetup.dll", 1000);
9771     create_database(msifile, odbc_tables, sizeof(odbc_tables) / sizeof(msi_table));
9772
9773     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9774
9775     r = MsiInstallProductA(msifile, NULL);
9776     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9777     {
9778         skip("Not enough rights to perform tests\n");
9779         goto error;
9780     }
9781     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9782
9783     ok(pf_exists("msitest\\ODBCdriver.dll"), "file not created\n");
9784     ok(pf_exists("msitest\\ODBCdriver2.dll"), "file not created\n");
9785     ok(pf_exists("msitest\\ODBCtranslator.dll"), "file not created\n");
9786     ok(pf_exists("msitest\\ODBCtranslator2.dll"), "file not created\n");
9787     ok(pf_exists("msitest\\ODBCsetup.dll"), "file not created\n");
9788
9789     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9791
9792     ok(!delete_pf("msitest\\ODBCdriver.dll", TRUE), "file not removed\n");
9793     ok(!delete_pf("msitest\\ODBCdriver2.dll", TRUE), "file not removed\n");
9794     ok(!delete_pf("msitest\\ODBCtranslator.dll", TRUE), "file not removed\n");
9795     ok(!delete_pf("msitest\\ODBCtranslator2.dll", TRUE), "file not removed\n");
9796     ok(!delete_pf("msitest\\ODBCsetup.dll", TRUE), "file not removed\n");
9797     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9798
9799 error:
9800     DeleteFileA("msitest\\ODBCdriver.dll");
9801     DeleteFileA("msitest\\ODBCdriver2.dll");
9802     DeleteFileA("msitest\\ODBCtranslator.dll");
9803     DeleteFileA("msitest\\ODBCtranslator2.dll");
9804     DeleteFileA("msitest\\ODBCsetup.dll");
9805     delete_test_files();
9806     DeleteFile(msifile);
9807 }
9808
9809 static void test_register_typelib(void)
9810 {
9811     UINT r;
9812
9813     if (is_process_limited())
9814     {
9815         skip("process is limited\n");
9816         return;
9817     }
9818
9819     create_test_files();
9820     create_file("msitest\\typelib.dll", 1000);
9821     create_database(msifile, tl_tables, sizeof(tl_tables) / sizeof(msi_table));
9822
9823     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9824
9825     r = MsiInstallProductA(msifile, "REGISTER_TYPELIB=1");
9826     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9827     {
9828         skip("Not enough rights to perform tests\n");
9829         goto error;
9830     }
9831     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
9832
9833     r = MsiInstallProductA(msifile, NULL);
9834     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9835
9836     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9838
9839     ok(!delete_pf("msitest\\typelib.dll", TRUE), "file not removed\n");
9840     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9841
9842 error:
9843     DeleteFileA("msitest\\typelib.dll");
9844     delete_test_files();
9845     DeleteFile(msifile);
9846 }
9847
9848 static void test_create_remove_shortcut(void)
9849 {
9850     UINT r;
9851
9852     if (is_process_limited())
9853     {
9854         skip("process is limited\n");
9855         return;
9856     }
9857
9858     create_test_files();
9859     create_file("msitest\\target.txt", 1000);
9860     create_database(msifile, crs_tables, sizeof(crs_tables) / sizeof(msi_table));
9861
9862     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9863
9864     r = MsiInstallProductA(msifile, NULL);
9865     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9866     {
9867         skip("Not enough rights to perform tests\n");
9868         goto error;
9869     }
9870     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9871
9872     ok(pf_exists("msitest\\target.txt"), "file not created\n");
9873     ok(pf_exists("msitest\\shortcut.lnk"), "file not created\n");
9874
9875     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9876     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9877
9878     ok(!delete_pf("msitest\\shortcut.lnk", TRUE), "file not removed\n");
9879     ok(!delete_pf("msitest\\target.txt", TRUE), "file not removed\n");
9880     todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9881
9882 error:
9883     DeleteFileA("msitest\\target.txt");
9884     delete_test_files();
9885     DeleteFile(msifile);
9886 }
9887
9888 static void test_publish_components(void)
9889 {
9890     static char keypath[] =
9891         "Software\\Microsoft\\Installer\\Components\\0CBCFA296AC907244845745CEEB2F8AA";
9892
9893     UINT r;
9894     LONG res;
9895     HKEY key;
9896
9897     if (is_process_limited())
9898     {
9899         skip("process is limited\n");
9900         return;
9901     }
9902
9903     create_test_files();
9904     create_file("msitest\\english.txt", 1000);
9905     create_database(msifile, pub_tables, sizeof(pub_tables) / sizeof(msi_table));
9906
9907     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9908
9909     r = MsiInstallProductA(msifile, NULL);
9910     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9911     {
9912         skip("Not enough rights to perform tests\n");
9913         goto error;
9914     }
9915     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9916
9917     res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key);
9918     ok(res == ERROR_SUCCESS, "components key not created %d\n", res);
9919
9920     res = RegQueryValueExA(key, "english.txt", NULL, NULL, NULL, NULL);
9921     ok(res == ERROR_SUCCESS, "value not found %d\n", res);
9922     RegCloseKey(key);
9923
9924     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9925     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9926
9927     res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key);
9928     ok(res == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", res);
9929
9930     ok(!delete_pf("msitest\\english.txt", TRUE), "file not removed\n");
9931     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9932
9933 error:
9934     DeleteFileA("msitest\\english.txt");
9935     delete_test_files();
9936     DeleteFile(msifile);
9937 }
9938
9939 static void test_remove_duplicate_files(void)
9940 {
9941     UINT r;
9942
9943     if (is_process_limited())
9944     {
9945         skip("process is limited\n");
9946         return;
9947     }
9948
9949     create_test_files();
9950     create_file("msitest\\original.txt", 1000);
9951     create_file("msitest\\original2.txt", 1000);
9952     create_file("msitest\\original3.txt", 1000);
9953     create_database(msifile, rd_tables, sizeof(rd_tables) / sizeof(msi_table));
9954
9955     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9956
9957     r = MsiInstallProductA(msifile, NULL);
9958     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9959     {
9960         skip("Not enough rights to perform tests\n");
9961         goto error;
9962     }
9963     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9964
9965     ok(pf_exists("msitest\\original.txt"), "file not created\n");
9966     ok(pf_exists("msitest\\original2.txt"), "file not created\n");
9967     ok(!pf_exists("msitest\\original3.txt"), "file created\n");
9968     ok(pf_exists("msitest\\duplicate.txt"), "file not created\n");
9969     ok(!pf_exists("msitest\\duplicate2.txt"), "file created\n");
9970
9971     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9972     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9973
9974     ok(delete_pf("msitest\\original.txt", TRUE), "file removed\n");
9975     ok(!delete_pf("msitest\\original2.txt", TRUE), "file not removed\n");
9976     ok(!delete_pf("msitest\\original3.txt", TRUE), "file not removed\n");
9977     ok(!delete_pf("msitest\\duplicate.txt", TRUE), "file not removed\n");
9978     ok(!delete_pf("msitest\\duplicate2.txt", TRUE), "file not removed\n");
9979     ok(delete_pf("msitest", FALSE), "directory removed\n");
9980
9981 error:
9982     DeleteFileA("msitest\\original.txt");
9983     DeleteFileA("msitest\\original2.txt");
9984     DeleteFileA("msitest\\original3.txt");
9985     delete_test_files();
9986     DeleteFile(msifile);
9987 }
9988
9989 static void test_remove_registry_values(void)
9990 {
9991     UINT r;
9992     LONG res;
9993     HKEY key;
9994     REGSAM access = KEY_ALL_ACCESS;
9995     BOOL wow64;
9996
9997     if (is_process_limited())
9998     {
9999         skip("process is limited\n");
10000         return;
10001     }
10002
10003     create_test_files();
10004     create_file("msitest\\registry.txt", 1000);
10005     create_database(msifile, rrv_tables, sizeof(rrv_tables) / sizeof(msi_table));
10006
10007     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
10008         access |= KEY_WOW64_64KEY;
10009
10010     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10011
10012     RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1", 0, NULL, 0, access, NULL, &key, NULL);
10013     RegSetValueExA(key, "value1", 0, REG_SZ, (const BYTE *)"1", 2);
10014     RegCloseKey(key);
10015
10016     RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", 0, NULL, 0, access, NULL, &key, NULL);
10017     RegSetValueExA(key, "value2", 0, REG_SZ, (const BYTE *)"2", 2);
10018     RegCloseKey(key);
10019
10020     RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyA", 0, NULL, 0, access, NULL, &key, NULL);
10021     RegSetValueExA(key, "", 0, REG_SZ, (const BYTE *)"default", 8);
10022     RegSetValueExA(key, "valueA", 0, REG_SZ, (const BYTE *)"A", 2);
10023     RegSetValueExA(key, "valueB", 0, REG_SZ, (const BYTE *)"B", 2);
10024     RegCloseKey(key);
10025
10026     RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyB", 0, NULL, 0, access, NULL, &key, NULL);
10027     RegSetValueExA(key, "", 0, REG_SZ, (const BYTE *)"default", 8);
10028     RegSetValueExA(key, "valueB", 0, REG_SZ, (const BYTE *)"B", 2);
10029     RegCloseKey(key);
10030
10031     r = MsiInstallProductA(msifile, NULL);
10032     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10033     {
10034         skip("Not enough rights to perform tests\n");
10035         goto error;
10036     }
10037     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10038
10039     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1", 0, access, &key);
10040     ok(res == ERROR_SUCCESS, "key removed\n");
10041     RegCloseKey(key);
10042
10043     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", 0, access, &key);
10044     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10045
10046     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", 0, NULL, 0, access, NULL, &key, NULL);
10047     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10048     RegCloseKey(key);
10049
10050     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10051     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10052
10053     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1", 0, access, &key);
10054     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10055
10056     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", 0, access, &key);
10057     ok(res == ERROR_SUCCESS, "key removed\n");
10058     RegCloseKey(key);
10059
10060     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyA", 0, access, &key);
10061     ok(res == ERROR_SUCCESS, "key removed\n");
10062     RegCloseKey(key);
10063
10064     res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyB", 0, access, &key);
10065     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10066
10067     delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyA", access);
10068     delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", access);
10069     delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine", access);
10070
10071     ok(!delete_pf("msitest\\registry.txt", TRUE), "file not removed\n");
10072     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10073
10074 error:
10075     delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1", access);
10076     delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", access);
10077     delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyA", access);
10078     delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyB", access);
10079
10080     DeleteFileA("msitest\\registry.txt");
10081     delete_test_files();
10082     DeleteFile(msifile);
10083 }
10084
10085 static void test_find_related_products(void)
10086 {
10087     UINT r;
10088
10089     if (is_process_limited())
10090     {
10091         skip("process is limited\n");
10092         return;
10093     }
10094
10095     create_test_files();
10096     create_file("msitest\\product.txt", 1000);
10097     create_database(msifile, frp_tables, sizeof(frp_tables) / sizeof(msi_table));
10098
10099     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10100
10101     r = MsiInstallProductA(msifile, NULL);
10102     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10103     {
10104         skip("Not enough rights to perform tests\n");
10105         goto error;
10106     }
10107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10108
10109     /* install again, so it finds the upgrade code */
10110     r = MsiInstallProductA(msifile, NULL);
10111     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10112
10113     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10114     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10115
10116     ok(!delete_pf("msitest\\product.txt", TRUE), "file not removed\n");
10117     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10118
10119 error:
10120     DeleteFileA("msitest\\product.txt");
10121     delete_test_files();
10122     DeleteFile(msifile);
10123 }
10124
10125 static void test_remove_ini_values(void)
10126 {
10127     UINT r;
10128     DWORD len;
10129     char inifile[MAX_PATH], buf[0x10];
10130     HANDLE file;
10131     BOOL ret;
10132
10133     if (is_process_limited())
10134     {
10135         skip("process is limited\n");
10136         return;
10137     }
10138
10139     create_test_files();
10140     create_file("msitest\\inifile.txt", 1000);
10141     create_database(msifile, riv_tables, sizeof(riv_tables) / sizeof(msi_table));
10142
10143     lstrcpyA(inifile, PROG_FILES_DIR);
10144     lstrcatA(inifile, "\\msitest");
10145     ret = CreateDirectoryA(inifile, NULL);
10146     if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
10147     {
10148         skip("Not enough rights to perform tests\n");
10149         goto error;
10150     }
10151     lstrcatA(inifile, "\\test.ini");
10152     file = CreateFileA(inifile, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, 0, NULL);
10153     CloseHandle(file);
10154
10155     ret = WritePrivateProfileStringA("section1", "key1", "value1", inifile);
10156     ok(ret, "failed to write profile string %u\n", GetLastError());
10157
10158     ret = WritePrivateProfileStringA("sectionA", "keyA", "valueA", inifile);
10159     ok(ret, "failed to write profile string %u\n", GetLastError());
10160
10161     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10162
10163     r = MsiInstallProductA(msifile, NULL);
10164     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10165
10166     len = GetPrivateProfileStringA("section1", "key1", NULL, buf, sizeof(buf), inifile);
10167     ok(len == 6, "got %u expected 6\n", len);
10168
10169     len = GetPrivateProfileStringA("sectionA", "keyA", NULL, buf, sizeof(buf), inifile);
10170     ok(!len, "got %u expected 0\n", len);
10171
10172     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10173     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10174
10175     len = GetPrivateProfileStringA("section1", "key1", NULL, buf, sizeof(buf), inifile);
10176     ok(!len, "got %u expected 0\n", len);
10177
10178     len = GetPrivateProfileStringA("sectionA", "keyA", NULL, buf, sizeof(buf), inifile);
10179     ok(!len, "got %u expected 0\n", len);
10180
10181     todo_wine ok(!delete_pf("msitest\\test.ini", TRUE), "file removed\n");
10182     ok(!delete_pf("msitest\\inifile.txt", TRUE), "file not removed\n");
10183     ok(delete_pf("msitest", FALSE), "directory removed\n");
10184
10185 error:
10186     DeleteFileA("msitest\\inifile.txt");
10187     delete_test_files();
10188     DeleteFile(msifile);
10189 }
10190
10191 static void test_remove_env_strings(void)
10192 {
10193     UINT r;
10194     LONG res;
10195     HKEY key;
10196     DWORD type, size;
10197     char buffer[0x10];
10198
10199     if (on_win9x)
10200     {
10201         win_skip("Environment variables are handled differently on win9x and winme\n");
10202         return;
10203     }
10204     if (is_process_limited())
10205     {
10206         skip("process is limited\n");
10207         return;
10208     }
10209
10210     create_test_files();
10211     create_file("msitest\\envvar.txt", 1000);
10212     create_database(msifile, res_tables, sizeof(res_tables) / sizeof(msi_table));
10213
10214     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10215
10216     res = RegOpenKeyA(HKEY_CURRENT_USER, "Environment", &key);
10217     ok(!res, "failed to open environment key %d\n", res);
10218
10219     RegSetValueExA(key, "MSITESTVAR1", 0, REG_SZ, (const BYTE *)"1", 2);
10220     RegSetValueExA(key, "MSITESTVAR2", 0, REG_SZ, (const BYTE *)"1", 2);
10221     RegSetValueExA(key, "MSITESTVAR3", 0, REG_SZ, (const BYTE *)"1", 2);
10222     RegSetValueExA(key, "MSITESTVAR4", 0, REG_SZ, (const BYTE *)"1", 2);
10223     RegSetValueExA(key, "MSITESTVAR5", 0, REG_SZ, (const BYTE *)"1", 2);
10224
10225     RegCloseKey(key);
10226
10227     r = MsiInstallProductA(msifile, NULL);
10228     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10229     {
10230         skip("Not enough rights to perform tests\n");
10231         goto error;
10232     }
10233     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10234
10235     res = RegOpenKeyA(HKEY_CURRENT_USER, "Environment", &key);
10236     ok(!res, "failed to open environment key %d\n", res);
10237
10238     type = REG_NONE;
10239     buffer[0] = 0;
10240     size = sizeof(buffer);
10241     res = RegQueryValueExA(key, "MSITESTVAR1", NULL, &type, (LPBYTE)buffer, &size);
10242     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10243     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
10244     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
10245
10246     type = REG_NONE;
10247     buffer[0] = 0;
10248     size = sizeof(buffer);
10249     res = RegQueryValueExA(key, "MSITESTVAR2", NULL, &type, (LPBYTE)buffer, &size);
10250     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10251     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
10252     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
10253
10254     type = REG_NONE;
10255     buffer[0] = 0;
10256     size = sizeof(buffer);
10257     res = RegQueryValueExA(key, "MSITESTVAR3", NULL, &type, (LPBYTE)buffer, &size);
10258     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10259     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
10260     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
10261
10262     type = REG_NONE;
10263     buffer[0] = 0;
10264     size = sizeof(buffer);
10265     res = RegQueryValueExA(key, "MSITESTVAR4", NULL, &type, (LPBYTE)buffer, &size);
10266     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10267     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
10268     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
10269
10270     type = REG_NONE;
10271     buffer[0] = 0;
10272     size = sizeof(buffer);
10273     res = RegQueryValueExA(key, "MSITESTVAR5", NULL, &type, (LPBYTE)buffer, &size);
10274     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10275     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
10276     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
10277
10278     RegCloseKey(key);
10279
10280     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10281     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10282
10283     res = RegOpenKeyA(HKEY_CURRENT_USER, "Environment", &key);
10284     ok(!res, "failed to open environment key %d\n", res);
10285
10286     res = RegQueryValueExA(key, "MSITESTVAR1", NULL, NULL, NULL, NULL);
10287     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
10288
10289     res = RegQueryValueExA(key, "MSITESTVAR2", NULL, NULL, NULL, NULL);
10290     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
10291
10292     type = REG_NONE;
10293     buffer[0] = 0;
10294     size = sizeof(buffer);
10295     res = RegQueryValueExA(key, "MSITESTVAR3", NULL, &type, (LPBYTE)buffer, &size);
10296     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10297     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
10298     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
10299     RegDeleteValueA(key, "MSITESTVAR3");
10300
10301     res = RegQueryValueExA(key, "MSITESTVAR4", NULL, NULL, NULL, NULL);
10302     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
10303
10304     type = REG_NONE;
10305     buffer[0] = 0;
10306     size = sizeof(buffer);
10307     res = RegQueryValueExA(key, "MSITESTVAR5", NULL, &type, (LPBYTE)buffer, &size);
10308     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10309     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
10310     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
10311     RegDeleteValueA(key, "MSITESTVAR5");
10312
10313     ok(!delete_pf("msitest\\envvar.txt", TRUE), "file not removed\n");
10314     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10315
10316 error:
10317     RegDeleteValueA(key, "MSITESTVAR1");
10318     RegDeleteValueA(key, "MSITESTVAR2");
10319     RegDeleteValueA(key, "MSITESTVAR3");
10320     RegDeleteValueA(key, "MSITESTVAR4");
10321     RegDeleteValueA(key, "MSITESTVAR5");
10322     RegCloseKey(key);
10323
10324     DeleteFileA("msitest\\envvar.txt");
10325     delete_test_files();
10326     DeleteFile(msifile);
10327 }
10328
10329 static void test_register_class_info(void)
10330 {
10331     UINT r;
10332     LONG res;
10333     HKEY hkey;
10334
10335     if (is_process_limited())
10336     {
10337         skip("process is limited\n");
10338         return;
10339     }
10340
10341     create_test_files();
10342     create_file("msitest\\class.txt", 1000);
10343     create_database(msifile, rci_tables, sizeof(rci_tables) / sizeof(msi_table));
10344
10345     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10346
10347     r = MsiInstallProductA(msifile, NULL);
10348     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10349     {
10350         skip("Not enough rights to perform tests\n");
10351         goto error;
10352     }
10353     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10354
10355     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
10356     ok(res == ERROR_SUCCESS, "key not created\n");
10357     RegCloseKey(hkey);
10358
10359     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "FileType\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
10360     ok(res == ERROR_SUCCESS, "key not created\n");
10361     RegCloseKey(hkey);
10362
10363     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "AppID\\{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}", &hkey);
10364     ok(res == ERROR_SUCCESS, "key not created\n");
10365     RegCloseKey(hkey);
10366
10367     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10368     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10369
10370     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
10371     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10372
10373     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "FileType\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
10374     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10375
10376     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "AppID\\{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}", &hkey);
10377     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10378
10379     ok(!delete_pf("msitest\\class.txt", TRUE), "file not removed\n");
10380     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10381
10382 error:
10383     DeleteFileA("msitest\\class.txt");
10384     delete_test_files();
10385     DeleteFile(msifile);
10386 }
10387
10388 static void test_register_extension_info(void)
10389 {
10390     UINT r;
10391     LONG res;
10392     HKEY hkey;
10393
10394     if (is_process_limited())
10395     {
10396         skip("process is limited\n");
10397         return;
10398     }
10399
10400     create_test_files();
10401     create_file("msitest\\extension.txt", 1000);
10402     create_database(msifile, rei_tables, sizeof(rei_tables) / sizeof(msi_table));
10403
10404     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10405
10406     r = MsiInstallProductA(msifile, NULL);
10407     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10408     {
10409         skip("Not enough rights to perform tests\n");
10410         goto error;
10411     }
10412     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10413
10414     res = RegOpenKeyA(HKEY_CLASSES_ROOT, ".extension", &hkey);
10415     ok(res == ERROR_SUCCESS, "key not created\n");
10416     RegCloseKey(hkey);
10417
10418     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Prog.Id.1\\shell\\Open\\command", &hkey);
10419     ok(res == ERROR_SUCCESS, "key not created\n");
10420     RegCloseKey(hkey);
10421
10422     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10423     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10424
10425     res = RegOpenKeyA(HKEY_CLASSES_ROOT, ".extension", &hkey);
10426     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10427
10428     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Prog.Id.1", &hkey);
10429     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10430
10431     ok(!delete_pf("msitest\\extension.txt", TRUE), "file not removed\n");
10432     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10433
10434 error:
10435     DeleteFileA("msitest\\extension.txt");
10436     delete_test_files();
10437     DeleteFile(msifile);
10438 }
10439
10440 static void test_register_mime_info(void)
10441 {
10442     UINT r;
10443     LONG res;
10444     HKEY hkey;
10445
10446     if (is_process_limited())
10447     {
10448         skip("process is limited\n");
10449         return;
10450     }
10451
10452     create_test_files();
10453     create_file("msitest\\mime.txt", 1000);
10454     create_database(msifile, rmi_tables, sizeof(rmi_tables) / sizeof(msi_table));
10455
10456     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10457
10458     r = MsiInstallProductA(msifile, NULL);
10459     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10460     {
10461         skip("Not enough rights to perform tests\n");
10462         goto error;
10463     }
10464     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10465
10466     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "MIME\\Database\\Content Type\\mime/type", &hkey);
10467     ok(res == ERROR_SUCCESS, "key not created\n");
10468     RegCloseKey(hkey);
10469
10470     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10471     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10472
10473     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "MIME\\Database\\Content Type\\mime/type", &hkey);
10474     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
10475
10476     ok(!delete_pf("msitest\\mime.txt", TRUE), "file not removed\n");
10477     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10478
10479 error:
10480     DeleteFileA("msitest\\mime.txt");
10481     delete_test_files();
10482     DeleteFile(msifile);
10483 }
10484
10485 static void test_icon_table(void)
10486 {
10487     MSIHANDLE hdb = 0, record;
10488     LPCSTR query;
10489     UINT res;
10490     CHAR path[MAX_PATH], win9xpath[MAX_PATH];
10491     static const char prodcode[] = "{7DF88A49-996F-4EC8-A022-BF956F9B2CBB}";
10492
10493     if (is_process_limited())
10494     {
10495         skip("process is limited\n");
10496         return;
10497     }
10498
10499     create_database(msifile, icon_base_tables, sizeof(icon_base_tables) / sizeof(msi_table));
10500
10501     res = MsiOpenDatabase(msifile, MSIDBOPEN_TRANSACT, &hdb);
10502     ok(res == ERROR_SUCCESS, "failed to open db: %d\n", res);
10503
10504     query = "CREATE TABLE `Icon` (`Name` CHAR(72) NOT NULL, `Data` OBJECT NOT NULL  PRIMARY KEY `Name`)";
10505     res = run_query( hdb, 0, query );
10506     ok(res == ERROR_SUCCESS, "Can't create Icon table: %d\n", res);
10507
10508     create_file("icon.ico", 100);
10509     record = MsiCreateRecord(1);
10510     res = MsiRecordSetStream(record, 1, "icon.ico");
10511     ok(res == ERROR_SUCCESS, "Failed to add stream data to record: %d\n", res);
10512     DeleteFile("icon.ico");
10513
10514     query = "INSERT INTO `Icon` (`Name`, `Data`) VALUES ('testicon', ?)";
10515     res = run_query(hdb, record, query);
10516     ok(res == ERROR_SUCCESS, "Insert into Icon table failed: %d\n", res);
10517
10518     res = MsiCloseHandle(record);
10519     ok(res == ERROR_SUCCESS, "Failed to close record handle: %d\n", res);
10520     res = MsiDatabaseCommit(hdb);
10521     ok(res == ERROR_SUCCESS, "Failed to commit database: %d\n", res);
10522     res = MsiCloseHandle(hdb);
10523     ok(res == ERROR_SUCCESS, "Failed to close database: %d\n", res);
10524
10525     /* per-user */
10526     res = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
10527     if (res == ERROR_INSTALL_PACKAGE_REJECTED)
10528     {
10529         skip("Not enough rights to perform tests\n");
10530         DeleteFile(msifile);
10531         return;
10532     }
10533     ok(res == ERROR_SUCCESS, "Failed to do per-user install: %d\n", res);
10534
10535     lstrcpyA(path, APP_DATA_DIR);
10536     lstrcatA(path, "\\");
10537     lstrcatA(path, "Microsoft\\Installer\\");
10538     lstrcatA(path, prodcode);
10539     lstrcatA(path, "\\testicon");
10540     ok(file_exists(path), "Per-user icon file isn't where it's expected (%s)\n", path);
10541
10542     res = MsiInstallProductA(msifile, "REMOVE=ALL");
10543     ok(res == ERROR_SUCCESS, "Failed to uninstall per-user\n");
10544
10545     /* system-wide */
10546     res = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1 ALLUSERS=1");
10547     ok(res == ERROR_SUCCESS, "Failed to system-wide install: %d\n", res);
10548
10549     /* win9x with MSI 2.0 installs the icon to a different folder, same as above */
10550     lstrcpyA(win9xpath, APP_DATA_DIR);
10551     lstrcatA(win9xpath, "\\");
10552     lstrcatA(win9xpath, "Microsoft\\Installer\\");
10553     lstrcatA(win9xpath, prodcode);
10554     lstrcatA(win9xpath, "\\testicon");
10555
10556     lstrcpyA(path, WINDOWS_DIR);
10557     lstrcatA(path, "\\");
10558     lstrcatA(path, "Installer\\");
10559     lstrcatA(path, prodcode);
10560     lstrcatA(path, "\\testicon");
10561     ok(file_exists(path) || file_exists(win9xpath),
10562             "System-wide icon file isn't where it's expected (%s)\n", path);
10563
10564     res = MsiInstallProductA(msifile, "REMOVE=ALL");
10565     ok(res == ERROR_SUCCESS, "Failed to uninstall system-wide\n");
10566
10567     delete_pfmsitest_files();
10568     DeleteFile(msifile);
10569 }
10570
10571 static void test_sourcedir_props(void)
10572 {
10573     UINT r;
10574
10575     if (on_win9x)
10576     {
10577         win_skip("skipping sourcedir tests on win9x\n");
10578         return;
10579     }
10580     if (is_process_limited())
10581     {
10582         skip("process is limited\n");
10583         return;
10584     }
10585
10586     create_test_files();
10587     create_file("msitest\\sourcedir.txt", 1000);
10588     create_database(msifile, sd_tables, sizeof(sd_tables) / sizeof(msi_table));
10589
10590     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
10591
10592     /* full UI, no ResolveSource action */
10593     r = MsiInstallProductA(msifile, NULL);
10594     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10595
10596     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10597     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10598
10599     ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
10600     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10601
10602     /* full UI, ResolveSource action */
10603     r = MsiInstallProductA(msifile, "ResolveSource=1");
10604     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10605
10606     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10607     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10608
10609     ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
10610     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10611
10612     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10613
10614     /* no UI, no ResolveSource action */
10615     r = MsiInstallProductA(msifile, NULL);
10616     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10617
10618     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10619     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10620
10621     ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
10622     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10623
10624     /* no UI, ResolveSource action */
10625     r = MsiInstallProductA(msifile, "ResolveSource=1");
10626     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10627
10628     r = MsiInstallProductA(msifile, "REMOVE=ALL");
10629     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10630
10631     ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
10632     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
10633
10634     DeleteFileA("msitest\\sourcedir.txt");
10635     DeleteFile(msifile);
10636 }
10637
10638 START_TEST(install)
10639 {
10640     DWORD len;
10641     char temp_path[MAX_PATH], prev_path[MAX_PATH], log_file[MAX_PATH];
10642     STATEMGRSTATUS status;
10643     BOOL ret = FALSE;
10644
10645     init_functionpointers();
10646
10647     on_win9x = check_win9x();
10648
10649     GetCurrentDirectoryA(MAX_PATH, prev_path);
10650     GetTempPath(MAX_PATH, temp_path);
10651     SetCurrentDirectoryA(temp_path);
10652
10653     lstrcpyA(CURR_DIR, temp_path);
10654     len = lstrlenA(CURR_DIR);
10655
10656     if(len && (CURR_DIR[len - 1] == '\\'))
10657         CURR_DIR[len - 1] = 0;
10658
10659     get_system_dirs();
10660     get_user_dirs();
10661
10662     /* Create a restore point ourselves so we circumvent the multitude of restore points
10663      * that would have been created by all the installation and removal tests.
10664      */
10665     if (pSRSetRestorePointA)
10666     {
10667         memset(&status, 0, sizeof(status));
10668         ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
10669     }
10670
10671     /* Create only one log file and don't append. We have to pass something
10672      * for the log mode for this to work. The logfile needs to have an absolute
10673      * path otherwise we still end up with some extra logfiles as some tests
10674      * change the current directory.
10675      */
10676     lstrcpyA(log_file, temp_path);
10677     lstrcatA(log_file, "\\msitest.log");
10678     MsiEnableLogA(INSTALLLOGMODE_FATALEXIT, log_file, 0);
10679
10680     test_MsiInstallProduct();
10681     test_MsiSetComponentState();
10682     test_packagecoltypes();
10683     test_continuouscabs();
10684     test_caborder();
10685     test_mixedmedia();
10686     test_samesequence();
10687     test_uiLevelFlags();
10688     test_readonlyfile();
10689     test_readonlyfile_cab();
10690     test_setdirproperty();
10691     test_cabisextracted();
10692     test_concurrentinstall();
10693     test_setpropertyfolder();
10694     test_publish_registerproduct();
10695     test_publish_publishproduct();
10696     test_publish_publishfeatures();
10697     test_publish_registeruser();
10698     test_publish_processcomponents();
10699     test_publish();
10700     test_publishsourcelist();
10701     test_transformprop();
10702     test_currentworkingdir();
10703     test_admin();
10704     test_adminprops();
10705     test_removefiles();
10706     test_movefiles();
10707     test_missingcab();
10708     test_duplicatefiles();
10709     test_writeregistryvalues();
10710     test_sourcefolder();
10711     test_customaction51();
10712     test_installstate();
10713     test_sourcepath();
10714     test_MsiConfigureProductEx();
10715     test_missingcomponent();
10716     test_sourcedirprop();
10717     test_adminimage();
10718     test_propcase();
10719     test_int_widths();
10720     test_shortcut();
10721     test_envvar();
10722     test_lastusedsource();
10723     test_preselected();
10724     test_installed_prop();
10725     test_file_in_use();
10726     test_file_in_use_cab();
10727     test_MsiSetExternalUI();
10728     test_allusers_prop();
10729     test_feature_override();
10730     test_create_folder();
10731     test_remove_folder();
10732     test_start_services();
10733     test_delete_services();
10734     test_self_registration();
10735     test_register_font();
10736     test_validate_product_id();
10737     test_install_remove_odbc();
10738     test_register_typelib();
10739     test_create_remove_shortcut();
10740     test_publish_components();
10741     test_remove_duplicate_files();
10742     test_remove_registry_values();
10743     test_find_related_products();
10744     test_remove_ini_values();
10745     test_remove_env_strings();
10746     test_register_class_info();
10747     test_register_extension_info();
10748     test_register_mime_info();
10749     test_icon_table();
10750     test_sourcedir_props();
10751
10752     DeleteFileA(log_file);
10753
10754     if (pSRSetRestorePointA && ret)
10755     {
10756         ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
10757         if (ret)
10758             remove_restore_point(status.llSequenceNumber);
10759     }
10760     FreeLibrary(hsrclient);
10761
10762     SetCurrentDirectoryA(prev_path);
10763 }