install.c 244 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Copyright (C) 2006 James Hawkins
 *
 * A test program for installing MSI products.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

21
#define _WIN32_MSI 300
22
#define COBJMACROS
23

24 25 26 27 28 29 30
#include <stdio.h>

#include <windows.h>
#include <msiquery.h>
#include <msidefs.h>
#include <msi.h>
#include <fci.h>
31
#include <objidl.h>
32
#include <srrestoreptapi.h>
33
#include <shlobj.h>
34 35
#include <winsvc.h>
#include <shellapi.h>
36 37

#include "wine/test.h"
38
#include "utils.h"
39

40 41
static UINT (WINAPI *pMsiQueryComponentStateA)
    (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
42 43
static UINT (WINAPI *pMsiSourceListEnumSourcesA)
    (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, DWORD, LPSTR, LPDWORD);
44 45
static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)
    (LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
46

47 48
static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
49 50
static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(void **);
static BOOL (WINAPI *pWow64RevertWow64FsRedirection)(void *);
51

52 53 54
static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);

55
static BOOL is_wow64;
56
static const BOOL is_64bit = sizeof(void *) > sizeof(int);
57

58
static const char *msifile = "msitest.msi";
59 60
static const char *msifile2 = "winetest2.msi";
static const char *mstfile = "winetest.mst";
61

62 63
static const WCHAR msifileW[] = L"msitest.msi";
static const WCHAR msifile2W[] = L"msitest2.msi";
64

65 66 67 68 69 70
char CURR_DIR[MAX_PATH];
char PROG_FILES_DIR[MAX_PATH];
char PROG_FILES_DIR_NATIVE[MAX_PATH];
char COMMON_FILES_DIR[MAX_PATH];
char APP_DATA_DIR[MAX_PATH];
char WINDOWS_DIR[MAX_PATH];
71

72 73
static const char *customdll;

74 75 76 77 78 79 80
/* msi database data */

static const CHAR component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                    "s72\tS38\ts72\ti2\tS255\tS72\n"
                                    "Component\tComponent\n"
                                    "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
                                    "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
81
                                    "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\tNOT REINSTALL\tone.txt\n"
82
                                    "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
83
                                    "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
84
                                    "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
85
                                    "component\t\tMSITESTDIR\t0\t1\tfile\n";
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104

static const CHAR directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
                                    "s72\tS72\tl255\n"
                                    "Directory\tDirectory\n"
                                    "CABOUTDIR\tMSITESTDIR\tcabout\n"
                                    "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
                                    "FIRSTDIR\tMSITESTDIR\tfirst\n"
                                    "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
                                    "NEWDIR\tCABOUTDIR\tnew\n"
                                    "ProgramFilesFolder\tTARGETDIR\t.\n"
                                    "TARGETDIR\t\tSourceDir";

static const CHAR feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
                                  "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
                                  "Feature\tFeature\n"
                                  "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
                                  "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
                                  "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
                                  "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
105
                                  "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
106
                                  "feature\t\t\t\t2\t1\tTARGETDIR\t0\n";
107 108 109 110 111 112 113 114

static const CHAR feature_comp_dat[] = "Feature_\tComponent_\n"
                                       "s38\ts72\n"
                                       "FeatureComponents\tFeature_\tComponent_\n"
                                       "Five\tFive\n"
                                       "Four\tFour\n"
                                       "One\tOne\n"
                                       "Three\tThree\n"
115
                                       "Two\tTwo\n"
116
                                       "feature\tcomponent\n";
117 118 119 120 121 122 123 124

static const CHAR file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                               "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                               "File\tFile\n"
                               "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
                               "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
                               "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
                               "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
125
                               "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
126
                               "file\tcomponent\tfilename\t100\t\t\t8192\t1\n";
127 128 129 130 131 132 133 134

static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                           "s72\tS255\tI2\n"
                                           "InstallExecuteSequence\tAction\n"
                                           "AllocateRegistrySpace\tNOT Installed\t1550\n"
                                           "CostFinalize\t\t1000\n"
                                           "CostInitialize\t\t800\n"
                                           "FileCost\t\t900\n"
135 136
                                           "ResolveSource\t\t950\n"
                                           "MoveFiles\t\t1700\n"
137
                                           "InstallFiles\t\t4000\n"
138
                                           "BindImage\t\t4100\n"
139
                                           "DuplicateFiles\t\t4500\n"
140
                                           "WriteEnvironmentStrings\t\t4550\n"
141
                                           "CreateShortcuts\t\t4600\n"
142 143 144 145
                                           "InstallFinalize\t\t6600\n"
                                           "InstallInitialize\t\t1500\n"
                                           "InstallValidate\t\t1400\n"
                                           "LaunchConditions\t\t100\n"
146
                                           "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
147 148

static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
149
                                "i2\ti4\tL64\tS255\tS32\tS72\n"
150 151 152 153 154 155 156 157
                                "Media\tDiskId\n"
                                "1\t3\t\t\tDISK1\t\n"
                                "2\t5\t\tmsitest.cab\tDISK2\t\n";

static const CHAR property_dat[] = "Property\tValue\n"
                                   "s72\tl0\n"
                                   "Property\tProperty\n"
                                   "DefaultUIFont\tDlgFont8\n"
158
                                   "HASUIRUN\t0\n"
159 160 161 162
                                   "INSTALLLEVEL\t3\n"
                                   "InstallMode\tTypical\n"
                                   "Manufacturer\tWine\n"
                                   "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
163
                                   "PRIMARYFOLDER\tTARGETDIR\n"
164
                                   "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
165 166 167 168 169 170
                                   "ProductID\tnone\n"
                                   "ProductLanguage\t1033\n"
                                   "ProductName\tMSITEST\n"
                                   "ProductVersion\t1.1.1\n"
                                   "PROMPTROLLBACKCOST\tP\n"
                                   "Setup\tSetup\n"
171
                                   "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
172
                                   "AdminProperties\tPOSTADMIN\n"
173
                                   "ROOTDRIVE\tC:\\\n"
174
                                   "MSIFASTINSTALL\t1\n";
175

176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
static const CHAR aup_property_dat[] = "Property\tValue\n"
                                       "s72\tl0\n"
                                       "Property\tProperty\n"
                                       "DefaultUIFont\tDlgFont8\n"
                                       "HASUIRUN\t0\n"
                                       "ALLUSERS\t1\n"
                                       "INSTALLLEVEL\t3\n"
                                       "InstallMode\tTypical\n"
                                       "Manufacturer\tWine\n"
                                       "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
                                       "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
                                       "ProductID\tnone\n"
                                       "ProductLanguage\t1033\n"
                                       "ProductName\tMSITEST\n"
                                       "ProductVersion\t1.1.1\n"
                                       "PROMPTROLLBACKCOST\tP\n"
                                       "Setup\tSetup\n"
                                       "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
                                       "AdminProperties\tPOSTADMIN\n"
                                       "ROOTDRIVE\tC:\\\n"
196
                                       "MSIFASTINSTALL\t1\n";
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217

static const CHAR aup2_property_dat[] = "Property\tValue\n"
                                        "s72\tl0\n"
                                        "Property\tProperty\n"
                                        "DefaultUIFont\tDlgFont8\n"
                                        "HASUIRUN\t0\n"
                                        "ALLUSERS\t2\n"
                                        "INSTALLLEVEL\t3\n"
                                        "InstallMode\tTypical\n"
                                        "Manufacturer\tWine\n"
                                        "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
                                        "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
                                        "ProductID\tnone\n"
                                        "ProductLanguage\t1033\n"
                                        "ProductName\tMSITEST\n"
                                        "ProductVersion\t1.1.1\n"
                                        "PROMPTROLLBACKCOST\tP\n"
                                        "Setup\tSetup\n"
                                        "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
                                        "AdminProperties\tPOSTADMIN\n"
                                        "ROOTDRIVE\tC:\\\n"
218
                                        "MSIFASTINSTALL\t1\n";
219

220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
static const CHAR icon_property_dat[] = "Property\tValue\n"
                                        "s72\tl0\n"
                                        "Property\tProperty\n"
                                        "DefaultUIFont\tDlgFont8\n"
                                        "HASUIRUN\t0\n"
                                        "INSTALLLEVEL\t3\n"
                                        "InstallMode\tTypical\n"
                                        "Manufacturer\tWine\n"
                                        "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
                                        "ProductCode\t{7DF88A49-996F-4EC8-A022-BF956F9B2CBB}\n"
                                        "ProductID\tnone\n"
                                        "ProductLanguage\t1033\n"
                                        "ProductName\tMSITEST\n"
                                        "ProductVersion\t1.1.1\n"
                                        "PROMPTROLLBACKCOST\tP\n"
                                        "Setup\tSetup\n"
                                        "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
                                        "AdminProperties\tPOSTADMIN\n"
                                        "ROOTDRIVE\tC:\\\n"
239
                                        "MSIFASTINSTALL\t1\n";
240

241 242 243 244 245
static const CHAR shortcut_dat[] = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n"
                                   "s72\ts72\tl128\ts72\ts72\tS255\tL255\tI2\tS72\tI2\tI2\tS72\n"
                                   "Shortcut\tShortcut\n"
                                   "Shortcut\tMSITESTDIR\tShortcut\tcomponent\tShortcut\t\tShortcut\t\t\t\t\t\n";

246 247 248 249
static const CHAR condition_dat[] = "Feature_\tLevel\tCondition\n"
                                    "s38\ti2\tS255\n"
                                    "Condition\tFeature_\tLevel\n"
                                    "One\t4\t1\n";
250

251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
static const CHAR up_property_dat[] = "Property\tValue\n"
                                      "s72\tl0\n"
                                      "Property\tProperty\n"
                                      "DefaultUIFont\tDlgFont8\n"
                                      "HASUIRUN\t0\n"
                                      "INSTALLLEVEL\t3\n"
                                      "InstallMode\tTypical\n"
                                      "Manufacturer\tWine\n"
                                      "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
                                      "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
                                      "ProductID\tnone\n"
                                      "ProductLanguage\t1033\n"
                                      "ProductName\tMSITEST\n"
                                      "ProductVersion\t1.1.1\n"
                                      "PROMPTROLLBACKCOST\tP\n"
                                      "Setup\tSetup\n"
                                      "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
                                      "AdminProperties\tPOSTADMIN\n"
                                      "ROOTDRIVE\tC:\\\n"
270 271
                                      "RemovePreviousVersions\t1\n"
                                      "MSIFASTINSTALL\t1\n";
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291

static const CHAR up2_property_dat[] = "Property\tValue\n"
                                       "s72\tl0\n"
                                       "Property\tProperty\n"
                                       "DefaultUIFont\tDlgFont8\n"
                                       "HASUIRUN\t0\n"
                                       "INSTALLLEVEL\t3\n"
                                       "InstallMode\tTypical\n"
                                       "Manufacturer\tWine\n"
                                       "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
                                       "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
                                       "ProductID\tnone\n"
                                       "ProductLanguage\t1033\n"
                                       "ProductName\tMSITEST\n"
                                       "ProductVersion\t1.1.2\n"
                                       "PROMPTROLLBACKCOST\tP\n"
                                       "Setup\tSetup\n"
                                       "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
                                       "AdminProperties\tPOSTADMIN\n"
                                       "ROOTDRIVE\tC:\\\n"
292
                                       "MSIFASTINSTALL\t1\n";
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312

static const CHAR up3_property_dat[] = "Property\tValue\n"
                                       "s72\tl0\n"
                                       "Property\tProperty\n"
                                       "DefaultUIFont\tDlgFont8\n"
                                       "HASUIRUN\t0\n"
                                       "INSTALLLEVEL\t3\n"
                                       "InstallMode\tTypical\n"
                                       "Manufacturer\tWine\n"
                                       "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
                                       "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
                                       "ProductID\tnone\n"
                                       "ProductLanguage\t1033\n"
                                       "ProductName\tMSITEST\n"
                                       "ProductVersion\t1.1.2\n"
                                       "PROMPTROLLBACKCOST\tP\n"
                                       "Setup\tSetup\n"
                                       "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
                                       "AdminProperties\tPOSTADMIN\n"
                                       "ROOTDRIVE\tC:\\\n"
313 314
                                       "RemovePreviousVersions\t1\n"
                                       "MSIFASTINSTALL\t1\n";
315

316 317 318
static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
                                   "s72\ti2\tl255\tL255\tL0\ts72\n"
                                   "Registry\tRegistry\n"
319 320 321 322
                                   "Apples\t1\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
                                   "Oranges\t1\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
                                   "regdata\t1\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
                                   "OrderTest\t1\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
323

324 325 326 327 328
/* tables for test_continuouscabs */
static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                       "s72\tS38\ts72\ti2\tS255\tS72\n"
                                       "Component\tComponent\n"
                                       "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
329 330
                                       "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
                                       "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
331

332 333 334 335 336 337 338
static const CHAR cc2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
                                        "augustus\t\tMSITESTDIR\t0\t0\taugustus\n"
                                        "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";

339 340 341 342 343 344 345 346 347
static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
                                     "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
                                     "Feature\tFeature\n"
                                     "feature\t\t\t\t2\t1\tTARGETDIR\t0";

static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
                                          "s38\ts72\n"
                                          "FeatureComponents\tFeature_\tComponent_\n"
                                          "feature\tmaximus\n"
348 349
                                          "feature\taugustus\n"
                                          "feature\tcaesar";
350 351 352 353 354

static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                  "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                  "File\tFile\n"
                                  "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
355 356
                                  "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
                                  "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
357

358 359 360 361 362 363 364 365
static const CHAR cc2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                   "File\tFile\n"
                                   "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
                                   "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
                                   "tiberius\tmaximus\ttiberius\t500\t\t\t16384\t3\n"
                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";

366 367 368 369
static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                   "i2\ti4\tL64\tS255\tS32\tS72\n"
                                   "Media\tDiskId\n"
                                   "1\t10\t\ttest1.cab\tDISK1\t\n"
370 371 372
                                   "2\t2\t\ttest2.cab\tDISK2\t\n"
                                   "3\t12\t\ttest3.cab\tDISK3\t\n";

373 374 375 376 377 378 379
static const CHAR cc3_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
                                    "Media\tDiskId\n"
                                    "1\t10\t\ttest1.cab\tDISK1\t\n"
                                    "2\t2\t\ttest2_.cab\tDISK2\t\n"
                                    "3\t12\t\ttest3.cab\tDISK3\t\n";

380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
static const CHAR co_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                  "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                  "File\tFile\n"
                                  "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
                                  "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
                                  "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";

static const CHAR co_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                   "i2\ti4\tL64\tS255\tS32\tS72\n"
                                   "Media\tDiskId\n"
                                   "1\t10\t\ttest1.cab\tDISK1\t\n"
                                   "2\t2\t\ttest2.cab\tDISK2\t\n"
                                   "3\t3\t\ttest3.cab\tDISK3\t\n";

static const CHAR co2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
                                    "Media\tDiskId\n"
                                    "1\t10\t\ttest1.cab\tDISK1\t\n"
                                    "2\t12\t\ttest3.cab\tDISK3\t\n"
                                    "3\t2\t\ttest2.cab\tDISK2\t\n";
400

401 402 403 404 405 406 407 408 409 410 411 412
static const CHAR mm_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                  "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                  "File\tFile\n"
                                  "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
                                  "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
                                  "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";

static const CHAR mm_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                   "i2\ti4\tL64\tS255\tS32\tS72\n"
                                   "Media\tDiskId\n"
                                   "1\t3\t\ttest1.cab\tDISK1\t\n";

413 414 415 416 417 418 419
static const CHAR ss_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                   "i2\ti4\tL64\tS255\tS32\tS72\n"
                                   "Media\tDiskId\n"
                                   "1\t2\t\ttest1.cab\tDISK1\t\n"
                                   "2\t2\t\ttest2.cab\tDISK2\t\n"
                                   "3\t12\t\ttest3.cab\tDISK3\t\n";

420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
/* tables for test_uiLevelFlags */
static const CHAR ui_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                       "s72\tS38\ts72\ti2\tS255\tS72\n"
                                       "Component\tComponent\n"
                                       "maximus\t\tMSITESTDIR\t0\tHASUIRUN=1\tmaximus\n"
                                       "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
                                       "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";

static const CHAR ui_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
                                           "s72\tS255\tI2\n"
                                           "InstallUISequence\tAction\n"
                                           "SetUIProperty\t\t5\n"
                                           "ExecuteAction\t\t1100\n";

static const CHAR ui_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
                                           "s72\ti2\tS64\tS0\tS255\n"
                                           "CustomAction\tAction\n"
                                           "SetUIProperty\t51\tHASUIRUN\t1\t\n";

439 440 441 442 443 444 445 446
static const CHAR rof_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";

static const CHAR rof_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
                                      "Feature\tFeature\n"
447 448
                                      "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
                                      "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
449 450 451 452

static const CHAR rof_feature_comp_dat[] = "Feature_\tComponent_\n"
                                           "s38\ts72\n"
                                           "FeatureComponents\tFeature_\tComponent_\n"
453 454
                                           "feature\tmaximus\n"
                                           "montecristo\tmaximus";
455 456 457 458 459 460 461 462 463 464 465

static const CHAR rof_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                   "File\tFile\n"
                                   "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";

static const CHAR rof_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
                                    "Media\tDiskId\n"
                                    "1\t1\t\t\tDISK1\t\n";

466 467 468 469 470 471 472 473 474 475
static const CHAR rofc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                    "File\tFile\n"
                                    "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1";

static const CHAR rofc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
                                     "Media\tDiskId\n"
                                     "1\t1\t\ttest1.cab\tDISK1\t\n";

476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
static const CHAR sdp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                               "s72\tS255\tI2\n"
                                               "InstallExecuteSequence\tAction\n"
                                               "AllocateRegistrySpace\tNOT Installed\t1550\n"
                                               "CostFinalize\t\t1000\n"
                                               "CostInitialize\t\t800\n"
                                               "FileCost\t\t900\n"
                                               "InstallFiles\t\t4000\n"
                                               "InstallFinalize\t\t6600\n"
                                               "InstallInitialize\t\t1500\n"
                                               "InstallValidate\t\t1400\n"
                                               "LaunchConditions\t\t100\n"
                                               "SetDirProperty\t\t950";

static const CHAR sdp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
                                            "s72\ti2\tS64\tS0\tS255\n"
                                            "CustomAction\tAction\n"
                                            "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";

495 496 497 498 499 500 501 502 503 504 505 506
static const CHAR pv_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                              "s72\tS255\tI2\n"
                                              "InstallExecuteSequence\tAction\n"
                                              "LaunchConditions\t\t100\n"
                                              "CostInitialize\t\t800\n"
                                              "FileCost\t\t900\n"
                                              "CostFinalize\t\t1000\n"
                                              "InstallValidate\t\t1400\n"
                                              "InstallInitialize\t\t1500\n"
                                              "InstallFiles\t\t4000\n"
                                              "InstallFinalize\t\t6600\n";

507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
static const CHAR cie_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
                                        "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
                                        "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
                                        "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";

static const CHAR cie_feature_comp_dat[] = "Feature_\tComponent_\n"
                                           "s38\ts72\n"
                                           "FeatureComponents\tFeature_\tComponent_\n"
                                           "feature\tmaximus\n"
                                           "feature\taugustus\n"
                                           "feature\tcaesar\n"
                                           "feature\tgaius";

static const CHAR cie_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                   "File\tFile\n"
                                   "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
                                   "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
                                   "gaius\tgaius\tgaius\t500\t\t\t8192\t11";

static const CHAR cie_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
                                    "Media\tDiskId\n"
                                    "1\t1\t\ttest1.cab\tDISK1\t\n"
                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
                                    "3\t12\t\ttest3.cab\tDISK3\t\n";

538 539 540
static const CHAR ci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                       "s72\tS38\ts72\ti2\tS255\tS72\n"
                                       "Component\tComponent\n"
541
                                       "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
542 543 544 545 546 547 548 549 550 551 552

static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
                                           "s38\ts72\n"
                                           "FeatureComponents\tFeature_\tComponent_\n"
                                           "feature\taugustus";

static const CHAR ci2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                   "File\tFile\n"
                                   "augustus\taugustus\taugustus\t500\t\t\t8192\t1";

553 554 555 556 557 558 559 560 561 562 563 564 565
static const CHAR pp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                              "s72\tS255\tI2\n"
                                              "InstallExecuteSequence\tAction\n"
                                              "ValidateProductID\t\t700\n"
                                              "CostInitialize\t\t800\n"
                                              "FileCost\t\t900\n"
                                              "CostFinalize\t\t1000\n"
                                              "InstallValidate\t\t1400\n"
                                              "InstallInitialize\t\t1500\n"
                                              "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
                                              "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
                                              "RemoveFiles\t\t3500\n"
                                              "InstallFiles\t\t4000\n"
566
                                              "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
567 568 569 570 571
                                              "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
                                              "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
                                              "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
                                              "InstallFinalize\t\t6600";

572 573 574 575 576
static const CHAR tp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                       "s72\tS38\ts72\ti2\tS255\tS72\n"
                                       "Component\tComponent\n"
                                       "augustus\t\tMSITESTDIR\t0\tprop=\"val\"\taugustus\n";

577 578 579 580 581
static const CHAR cwd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "augustus\t\tMSITESTDIR\t0\t\taugustus\n";

582 583 584 585 586 587 588 589
static const CHAR adm_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "augustus\t\tMSITESTDIR\t0\tPOSTADMIN=1\taugustus";

static const CHAR adm_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
                                            "s72\ti2\tS64\tS0\tS255\n"
                                            "CustomAction\tAction\n"
590
                                            "SetPOSTADMIN\t51\tPOSTADMIN\t1\t\n";
591 592 593 594 595 596 597 598 599 600 601 602 603 604

static const CHAR adm_admin_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                             "s72\tS255\tI2\n"
                                             "AdminExecuteSequence\tAction\n"
                                             "CostFinalize\t\t1000\n"
                                             "CostInitialize\t\t800\n"
                                             "FileCost\t\t900\n"
                                             "SetPOSTADMIN\t\t950\n"
                                             "InstallFiles\t\t4000\n"
                                             "InstallFinalize\t\t6600\n"
                                             "InstallInitialize\t\t1500\n"
                                             "InstallValidate\t\t1400\n"
                                             "LaunchConditions\t\t100";

605 606 607
static const CHAR amp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
608
                                        "augustus\t\tMSITESTDIR\t0\tMYPROP=2718 and MyProp=42\taugustus\n";
609

610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
static const CHAR rem_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                               "s72\tS255\tI2\n"
                                               "InstallExecuteSequence\tAction\n"
                                               "ValidateProductID\t\t700\n"
                                               "CostInitialize\t\t800\n"
                                               "FileCost\t\t900\n"
                                               "CostFinalize\t\t1000\n"
                                               "InstallValidate\t\t1400\n"
                                               "InstallInitialize\t\t1500\n"
                                               "ProcessComponents\t\t1600\n"
                                               "UnpublishFeatures\t\t1800\n"
                                               "RemoveFiles\t\t3500\n"
                                               "InstallFiles\t\t4000\n"
                                               "RegisterProduct\t\t6100\n"
                                               "PublishFeatures\t\t6300\n"
                                               "PublishProduct\t\t6400\n"
                                               "InstallFinalize\t\t6600";

628 629 630 631 632 633
static const CHAR mc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
                                        "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
                                        "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
634 635
                                        "gaius\t\tMSITESTDIR\t0\tGAIUS=1\tgaius\n"
                                        "tiberius\t\tMSITESTDIR\t0\t\ttiberius\n";
636 637 638 639 640 641 642

static const CHAR mc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                  "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                  "File\tFile\n"
                                  "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
                                  "augustus\taugustus\taugustus\t500\t\t\t0\t2\n"
                                  "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3\n"
643 644
                                  "gaius\tgaius\tgaius\t500\t\t\t16384\t4\n"
                                  "tiberius\ttiberius\ttiberius\t500\t\t\t0\t5\n";
645 646 647 648 649 650 651

static const CHAR mc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                   "i2\ti4\tL64\tS255\tS32\tS72\n"
                                   "Media\tDiskId\n"
                                   "1\t1\t\ttest1.cab\tDISK1\t\n"
                                   "2\t2\t\ttest2.cab\tDISK2\t\n"
                                   "3\t3\t\ttest3.cab\tDISK3\t\n"
652 653
                                   "4\t4\t\ttest3.cab\tDISK3\t\n"
                                   "5\t5\t\ttest4.cab\tDISK4\t\n";
654 655 656 657

static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n"
                                       "s72\ti2\ti4\ti4\ti4\ti4\n"
                                       "MsiFileHash\tFile_\n"
658
                                       "caesar\t0\t850433704\t-241429251\t675791761\t-1221108824";
659

660 661 662 663 664
static const CHAR wrv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "augustus\t\tMSITESTDIR\t0\t\taugustus\n";

665 666 667
static const CHAR ca1_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                               "s72\tS255\tI2\n"
                                               "InstallExecuteSequence\tAction\n"
668 669 670
                                               "CostInitialize\t\t100\n"
                                               "FileCost\t\t200\n"
                                               "CostFinalize\t\t300\n"
671
                                               "InstallValidate\t\t400\n"
672
                                               "InstallInitialize\t\t500\n"
673
                                               "embednull\t\t600\n"
674
                                               "maintest\tMAIN_TEST\t700\n"
675 676 677 678
                                               "testretval\tTEST_RETVAL\t710\n"
                                               "process1\tTEST_PROCESS\t720\n"
                                               "process2\tTEST_PROCESS\t721\n"
                                               "process_deferred\tTEST_PROCESS\t722\n"
679 680
                                               "async1\tTEST_ASYNC\t730\n"
                                               "async2\tTEST_ASYNC\t731\n"
681
                                               "InstallFinalize\t\t800\n";
682 683 684 685

static const CHAR ca1_custom_action_dat[] = "Action\tType\tSource\tTarget\n"
                                             "s72\ti2\tS64\tS0\n"
                                             "CustomAction\tAction\n"
686
                                             "embednull\t51\tembednullprop\ta[~]b\n"
687 688
                                             "nested51\t51\tnested\t1\n"
                                             "nested1\t1\tcustom.dll\tnested\n"
689
                                             "maintest\t1\tcustom.dll\tmain_test\n"
690 691 692
                                             "process1\t1\tcustom.dll\tprocess1\n"
                                             "process2\t1\tcustom.dll\tprocess2\n"
                                             "process_deferred\t1025\tcustom.dll\tprocess2\n"
693 694
                                             "async1\t129\tcustom.dll\tasync1\n"
                                             "async2\t1\tcustom.dll\tasync2\n"
695 696
                                             "testretval\t1\tcustom.dll\ttest_retval\n";

697 698 699 700 701 702
static const CHAR ca1_test_seq_dat[] = "Action\tCondition\tSequence\n"
                                       "s72\tS255\tI2\n"
                                       "TestSequence\tAction\n"
                                       "nested1\t\t1\n"
                                       "nested51\t\t2\n";

703 704 705 706 707 708 709 710 711 712 713 714 715
static const CHAR ca1_test2_dat[] =
    "A\tB\n"
    "i2\ti2\n"
    "test2\tA\n"
    "1\t2\n";

static const CHAR ca1__validation_dat[] =
    "Table\tColumn\tNullable\tMinValue\tMaxValue\tKeyTable\tKeyColumn\tCategory\tSet\tDescription\n"
    "s32\ts32\ts4\tI4\tI4\tS255\tI2\tS32\tS255\tS255\n"
    "_Validation\tTable\tColumn\n"
    "test2\tA\tN\t\t\t\t\t\t\t\n"
    "test2\tB\tN\t\t\t\t\t\t\t\n";

716 717 718 719 720 721 722 723 724 725 726 727
static const CHAR ca51_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
                                         "Component\tComponent\n"
                                         "augustus\t\tMSITESTDIR\t0\tMYPROP=42\taugustus\n";

static const CHAR ca51_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                                "s72\tS255\tI2\n"
                                                "InstallExecuteSequence\tAction\n"
                                                "ValidateProductID\t\t700\n"
                                                "GoodSetProperty\t\t725\n"
                                                "BadSetProperty\t\t750\n"
                                                "CostInitialize\t\t800\n"
728
                                                "ResolveSource\t\t810\n"
729
                                                "FileCost\t\t900\n"
730
                                                "SetSourceDir\tSRCDIR\t910\n"
731 732 733 734 735 736 737 738 739 740
                                                "CostFinalize\t\t1000\n"
                                                "InstallValidate\t\t1400\n"
                                                "InstallInitialize\t\t1500\n"
                                                "InstallFiles\t\t4000\n"
                                                "InstallFinalize\t\t6600";

static const CHAR ca51_custom_action_dat[] = "Action\tType\tSource\tTarget\n"
                                             "s72\ti2\tS64\tS0\n"
                                             "CustomAction\tAction\n"
                                             "GoodSetProperty\t51\tMYPROP\t42\n"
741 742
                                             "BadSetProperty\t51\t\tMYPROP\n"
                                             "SetSourceDir\t51\tSourceDir\t[SRCDIR]\n";
743

744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804
static const CHAR is_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
                                     "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
                                     "Feature\tFeature\n"
                                     "one\t\t\t\t2\t1\t\t0\n" /* favorLocal */
                                     "two\t\t\t\t2\t1\t\t1\n" /* favorSource */
                                     "three\t\t\t\t2\t1\t\t4\n" /* favorAdvertise */
                                     "four\t\t\t\t2\t0\t\t0"; /* disabled */

static const CHAR is_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                       "s72\tS38\ts72\ti2\tS255\tS72\n"
                                       "Component\tComponent\n"
                                       "alpha\t\tMSITESTDIR\t0\t\talpha_file\n" /* favorLocal:Local */
                                       "beta\t\tMSITESTDIR\t1\t\tbeta_file\n" /* favorLocal:Source */
                                       "gamma\t\tMSITESTDIR\t2\t\tgamma_file\n" /* favorLocal:Optional */
                                       "theta\t\tMSITESTDIR\t0\t\ttheta_file\n" /* favorSource:Local */
                                       "delta\t\tMSITESTDIR\t1\t\tdelta_file\n" /* favorSource:Source */
                                       "epsilon\t\tMSITESTDIR\t2\t\tepsilon_file\n" /* favorSource:Optional */
                                       "zeta\t\tMSITESTDIR\t0\t\tzeta_file\n" /* favorAdvertise:Local */
                                       "iota\t\tMSITESTDIR\t1\t\tiota_file\n" /* favorAdvertise:Source */
                                       "eta\t\tMSITESTDIR\t2\t\teta_file\n" /* favorAdvertise:Optional */
                                       "kappa\t\tMSITESTDIR\t0\t\tkappa_file\n" /* disabled:Local */
                                       "lambda\t\tMSITESTDIR\t1\t\tlambda_file\n" /* disabled:Source */
                                       "mu\t\tMSITESTDIR\t2\t\tmu_file\n"; /* disabled:Optional */

static const CHAR is_feature_comp_dat[] = "Feature_\tComponent_\n"
                                          "s38\ts72\n"
                                          "FeatureComponents\tFeature_\tComponent_\n"
                                          "one\talpha\n"
                                          "one\tbeta\n"
                                          "one\tgamma\n"
                                          "two\ttheta\n"
                                          "two\tdelta\n"
                                          "two\tepsilon\n"
                                          "three\tzeta\n"
                                          "three\tiota\n"
                                          "three\teta\n"
                                          "four\tkappa\n"
                                          "four\tlambda\n"
                                          "four\tmu";

static const CHAR is_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                  "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                  "File\tFile\n"
                                  "alpha_file\talpha\talpha\t500\t\t\t8192\t1\n"
                                  "beta_file\tbeta\tbeta\t500\t\t\t8291\t2\n"
                                  "gamma_file\tgamma\tgamma\t500\t\t\t8192\t3\n"
                                  "theta_file\ttheta\ttheta\t500\t\t\t8192\t4\n"
                                  "delta_file\tdelta\tdelta\t500\t\t\t8192\t5\n"
                                  "epsilon_file\tepsilon\tepsilon\t500\t\t\t8192\t6\n"
                                  "zeta_file\tzeta\tzeta\t500\t\t\t8192\t7\n"
                                  "iota_file\tiota\tiota\t500\t\t\t8192\t8\n"
                                  "eta_file\teta\teta\t500\t\t\t8192\t9\n"
                                  "kappa_file\tkappa\tkappa\t500\t\t\t8192\t10\n"
                                  "lambda_file\tlambda\tlambda\t500\t\t\t8192\t11\n"
                                  "mu_file\tmu\tmu\t500\t\t\t8192\t12";

static const CHAR is_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
                                   "i2\ti4\tL64\tS255\tS32\tS72\n"
                                   "Media\tDiskId\n"
                                   "1\t12\t\t\tDISK1\t\n";

805 806 807 808 809 810 811 812 813 814 815 816 817 818
static const CHAR sp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "augustus\t\tTWODIR\t0\t\taugustus\n";

static const CHAR sp_directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
                                       "s72\tS72\tl255\n"
                                       "Directory\tDirectory\n"
                                       "TARGETDIR\t\tSourceDir\n"
                                       "ProgramFilesFolder\tTARGETDIR\t.\n"
                                       "MSITESTDIR\tProgramFilesFolder\tmsitest:.\n"
                                       "ONEDIR\tMSITESTDIR\t.:shortone|longone\n"
                                       "TWODIR\tONEDIR\t.:shorttwo|longtwo";

819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839
static const CHAR mcp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
                                        "Component\tComponent\n"
                                        "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t2\t\thydrogen\n"
                                        "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t2\t\thelium\n"
                                        "lithium\t{4AF28FFC-71C7-4307-BDE4-B77C5338F56F}\tMSITESTDIR\t2\tPROPVAR=42\tlithium\n";

static const CHAR mcp_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
                                      "Feature\tFeature\n"
                                      "hydroxyl\t\thydroxyl\thydroxyl\t2\t1\tTARGETDIR\t0\n"
                                      "heliox\t\theliox\theliox\t2\t5\tTARGETDIR\t0\n"
                                      "lithia\t\tlithia\tlithia\t2\t10\tTARGETDIR\t0";

static const CHAR mcp_feature_comp_dat[] = "Feature_\tComponent_\n"
                                           "s38\ts72\n"
                                           "FeatureComponents\tFeature_\tComponent_\n"
                                           "hydroxyl\thydrogen\n"
                                           "heliox\thelium\n"
                                           "lithia\tlithium";

840 841 842 843 844 845 846
static const CHAR mcp_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                   "File\tFile\n"
                                   "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
                                   "helium\thelium\thelium\t0\t\t\t8192\t1\n"
                                   "lithium\tlithium\tlithium\t0\t\t\t8192\t1\n"
                                   "beryllium\tmissingcomp\tberyllium\t0\t\t\t8192\t1";
847

848 849 850 851 852 853 854 855
static const CHAR ai_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                  "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                  "File\tFile\n"
                                  "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
                                  "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
                                  "one.txt\tOne\tone.txt\t1000\t\t\t16384\t1\n"
                                  "three.txt\tThree\tthree.txt\t1000\t\t\t16384\t3\n"
                                  "two.txt\tTwo\ttwo.txt\t1000\t\t\t16384\t2\n"
856
                                  "file\tcomponent\tfilename\t100\t\t\t8192\t1\n";
857

858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883
static const CHAR ip_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                              "s72\tS255\tI2\n"
                                              "InstallExecuteSequence\tAction\n"
                                              "CostFinalize\t\t1000\n"
                                              "ValidateProductID\t\t700\n"
                                              "CostInitialize\t\t800\n"
                                              "FileCost\t\t900\n"
                                              "RemoveFiles\t\t3500\n"
                                              "InstallFiles\t\t4000\n"
                                              "RegisterUser\t\t6000\n"
                                              "RegisterProduct\t\t6100\n"
                                              "PublishFeatures\t\t6300\n"
                                              "PublishProduct\t\t6400\n"
                                              "InstallFinalize\t\t6600\n"
                                              "InstallInitialize\t\t1500\n"
                                              "ProcessComponents\t\t1600\n"
                                              "UnpublishFeatures\t\t1800\n"
                                              "InstallValidate\t\t1400\n"
                                              "LaunchConditions\t\t100\n"
                                              "TestInstalledProp\tInstalled AND NOT REMOVE\t950\n";

static const CHAR ip_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
                                           "s72\ti2\tS64\tS0\tS255\n"
                                           "CustomAction\tAction\n"
                                           "TestInstalledProp\t19\t\tTest failed\t\n";

884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904
static const CHAR aup_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                               "s72\tS255\tI2\n"
                                               "InstallExecuteSequence\tAction\n"
                                               "CostFinalize\t\t1000\n"
                                               "ValidateProductID\t\t700\n"
                                               "CostInitialize\t\t800\n"
                                               "FileCost\t\t900\n"
                                               "RemoveFiles\t\t3500\n"
                                               "InstallFiles\t\t4000\n"
                                               "RegisterUser\t\t6000\n"
                                               "RegisterProduct\t\t6100\n"
                                               "PublishFeatures\t\t6300\n"
                                               "PublishProduct\t\t6400\n"
                                               "InstallFinalize\t\t6600\n"
                                               "InstallInitialize\t\t1500\n"
                                               "ProcessComponents\t\t1600\n"
                                               "UnpublishFeatures\t\t1800\n"
                                               "InstallValidate\t\t1400\n"
                                               "LaunchConditions\t\t100\n"
                                               "TestAllUsersProp\tALLUSERS AND NOT REMOVE\t50\n";

905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946
static const CHAR aup2_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                                "s72\tS255\tI2\n"
                                                "InstallExecuteSequence\tAction\n"
                                                "CostFinalize\t\t1000\n"
                                                "ValidateProductID\t\t700\n"
                                                "CostInitialize\t\t800\n"
                                                "FileCost\t\t900\n"
                                                "RemoveFiles\t\t3500\n"
                                                "InstallFiles\t\t4000\n"
                                                "RegisterUser\t\t6000\n"
                                                "RegisterProduct\t\t6100\n"
                                                "PublishFeatures\t\t6300\n"
                                                "PublishProduct\t\t6400\n"
                                                "InstallFinalize\t\t6600\n"
                                                "InstallInitialize\t\t1500\n"
                                                "ProcessComponents\t\t1600\n"
                                                "UnpublishFeatures\t\t1800\n"
                                                "InstallValidate\t\t1400\n"
                                                "LaunchConditions\t\t100\n"
                                                "TestAllUsersProp\tALLUSERS=2 AND NOT REMOVE\t50\n";

static const CHAR aup3_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                                "s72\tS255\tI2\n"
                                                "InstallExecuteSequence\tAction\n"
                                                "CostFinalize\t\t1000\n"
                                                "ValidateProductID\t\t700\n"
                                                "CostInitialize\t\t800\n"
                                                "FileCost\t\t900\n"
                                                "RemoveFiles\t\t3500\n"
                                                "InstallFiles\t\t4000\n"
                                                "RegisterUser\t\t6000\n"
                                                "RegisterProduct\t\t6100\n"
                                                "PublishFeatures\t\t6300\n"
                                                "PublishProduct\t\t6400\n"
                                                "InstallFinalize\t\t6600\n"
                                                "InstallInitialize\t\t1500\n"
                                                "ProcessComponents\t\t1600\n"
                                                "UnpublishFeatures\t\t1800\n"
                                                "InstallValidate\t\t1400\n"
                                                "LaunchConditions\t\t100\n"
                                                "TestAllUsersProp\tALLUSERS=1 AND NOT REMOVE\t50\n";

947 948 949 950 951
static const CHAR aup_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
                                            "s72\ti2\tS64\tS0\tS255\n"
                                            "CustomAction\tAction\n"
                                            "TestAllUsersProp\t19\t\tTest failed\t\n";

952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
static const CHAR fo_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                  "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                  "File\tFile\n"
                                  "override.txt\toverride\toverride.txt\t1000\t\t\t8192\t1\n"
                                  "preselected.txt\tpreselected\tpreselected.txt\t1000\t\t\t8192\t2\n"
                                  "notpreselected.txt\tnotpreselected\tnotpreselected.txt\t1000\t\t\t8192\t3\n";

static const CHAR fo_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
                                     "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
                                     "Feature\tFeature\n"
                                     "override\t\t\toverride feature\t1\t1\tMSITESTDIR\t0\n"
                                     "preselected\t\t\tpreselected feature\t1\t1\tMSITESTDIR\t0\n"
                                     "notpreselected\t\t\tnotpreselected feature\t1\t1\tMSITESTDIR\t0\n";

static const CHAR fo_condition_dat[] = "Feature_\tLevel\tCondition\n"
                                       "s38\ti2\tS255\n"
                                       "Condition\tFeature_\tLevel\n"
969 970
                                       "preselected\t0\tPreselected AND NOT REMOVE\n"
                                       "notpreselected\t0\tNOT Preselected AND NOT REMOVE\n";
971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006

static const CHAR fo_feature_comp_dat[] = "Feature_\tComponent_\n"
                                          "s38\ts72\n"
                                          "FeatureComponents\tFeature_\tComponent_\n"
                                          "override\toverride\n"
                                          "preselected\tpreselected\n"
                                          "notpreselected\tnotpreselected\n";

static const CHAR fo_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                       "s72\tS38\ts72\ti2\tS255\tS72\n"
                                       "Component\tComponent\n"
                                       "override\t{0A00FB1D-97B0-4B42-ADF0-BB8913416623}\tMSITESTDIR\t0\t\toverride.txt\n"
                                       "preselected\t{44E1DB75-605A-43DD-8CF5-CAB17F1BBD60}\tMSITESTDIR\t0\t\tpreselected.txt\n"
                                       "notpreselected\t{E1647733-5E75-400A-A92E-5E60B4D4EF9F}\tMSITESTDIR\t0\t\tnotpreselected.txt\n";

static const CHAR fo_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
                                           "s72\ti2\tS64\tS0\tS255\n"
                                           "CustomAction\tAction\n"
                                           "SetPreselected\t51\tPreselected\t1\t\n";

static const CHAR fo_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                              "s72\tS255\tI2\n"
                                              "InstallExecuteSequence\tAction\n"
                                              "LaunchConditions\t\t100\n"
                                              "SetPreselected\tpreselect=1\t200\n"
                                              "CostInitialize\t\t800\n"
                                              "FileCost\t\t900\n"
                                              "CostFinalize\t\t1000\n"
                                              "InstallValidate\t\t1400\n"
                                              "InstallInitialize\t\t1500\n"
                                              "ProcessComponents\t\t1600\n"
                                              "RemoveFiles\t\t1700\n"
                                              "InstallFiles\t\t2000\n"
                                              "RegisterProduct\t\t5000\n"
                                              "PublishFeatures\t\t5100\n"
                                              "PublishProduct\t\t5200\n"
1007
                                              "UnpublishFeatures\t\t5300\n"
1008 1009
                                              "InstallFinalize\t\t6000\n";

1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
static const CHAR uc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
                                  "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
                                  "File\tFile\n"
                                  "upgradecode.txt\tupgradecode\tupgradecode.txt\t1000\t\t\t8192\t1\n";

static const CHAR uc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
                                     "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
                                     "Feature\tFeature\n"
                                     "upgradecode\t\t\tupgradecode feature\t1\t2\tMSITESTDIR\t0\n";

static const CHAR uc_feature_comp_dat[] = "Feature_\tComponent_\n"
                                          "s38\ts72\n"
                                          "FeatureComponents\tFeature_\tComponent_\n"
                                          "upgradecode\tupgradecode\n";

static const CHAR uc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
                                       "s72\tS38\ts72\ti2\tS255\tS72\n"
                                       "Component\tComponent\n"
                                       "upgradecode\t{6952B732-2FCB-4E47-976F-989FCBD7EDFB}\tMSITESTDIR\t0\t\tupgradecode.txt\n";

static const CHAR uc_property_dat[] = "Property\tValue\n"
                                      "s72\tl0\n"
                                      "Property\tProperty\n"
                                      "INSTALLLEVEL\t3\n"
                                      "ProductCode\t{E5FB1241-F547-4BA7-A60E-8E75797268D4}\n"
                                      "ProductName\tMSITEST\n"
                                      "ProductVersion\t1.1.1\n"
                                      "UpgradeCode\t#UPGEADECODE#\n"
                                      "MSIFASTINSTALL\t1\n";

static const CHAR uc_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                              "s72\tS255\tI2\n"
                                              "InstallExecuteSequence\tAction\n"
                                              "LaunchConditions\t\t100\n"
                                              "CostInitialize\t\t200\n"
                                              "FileCost\t\t300\n"
                                              "CostFinalize\t\t400\n"
                                              "InstallInitialize\t\t500\n"
                                              "ProcessComponents\t\t600\n"
                                              "InstallValidate\t\t700\n"
                                              "RemoveFiles\t\t800\n"
                                              "InstallFiles\t\t900\n"
                                              "RegisterProduct\t\t1000\n"
                                              "PublishFeatures\t\t1100\n"
                                              "PublishProduct\t\t1200\n"
1055
                                              "UnpublishFeatures\t\t1250\n"
1056 1057
                                              "InstallFinalize\t\t1300\n";

1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
static const char mixed_feature_dat[] =
    "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
    "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
    "Feature\tFeature\n"
    "feature1\t\t\t\t1\t2\tMSITESTDIR\t0\n"
    "feature2\t\t\t\t1\t2\tMSITESTDIR\t0\n";

static const char mixed_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "feature1\tcomp1\n"
    "feature2\tcomp2\n";

static const char mixed_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "comp1\t{DE9F0EF4-0ED3-495A-8105-060C0EA457B8}\tTARGETDIR\t4\t\tregdata1\n"
    "comp2\t{4912DBE7-FC3A-4F91-BB5C-88F5C15C19A5}\tTARGETDIR\t260\t\tregdata2\n";

static const char mixed_registry_dat[] =
    "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
    "s72\ti2\tl255\tL255\tL0\ts72\n"
    "Registry\tRegistry\n"
    "regdata1\t2\tSOFTWARE\\Wine\\msitest\ttest1\t\tcomp1\n"
1084 1085 1086 1087 1088
    "regdata2\t2\tSOFTWARE\\Wine\\msitest\ttest2\t\tcomp2\n"
    "regdata3\t0\tCLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\t\tCLSID_Winetest32\tcomp1\n"
    "regdata4\t0\tCLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32\t\twinetest32.dll\tcomp1\n"
    "regdata5\t0\tCLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\t\tCLSID_Winetest64\tcomp2\n"
    "regdata6\t0\tCLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32\t\twinetest64.dll\tcomp2\n";
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108

static const char mixed_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "LaunchConditions\t\t100\n"
    "CostInitialize\t\t200\n"
    "FileCost\t\t300\n"
    "CostFinalize\t\t400\n"
    "InstallValidate\t\t500\n"
    "InstallInitialize\t\t600\n"
    "ProcessComponents\t\t700\n"
    "UnpublishFeatures\t\t800\n"
    "RemoveRegistryValues\t\t900\n"
    "WriteRegistryValues\t\t1000\n"
    "RegisterProduct\t\t1100\n"
    "PublishFeatures\t\t1200\n"
    "PublishProduct\t\t1300\n"
    "InstallFinalize\t\t1400\n";

1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138
static const char vp_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "volumeprop\tcomp\tvolumeprop.txt\t1000\t\t\t8192\t1\n";

static const char vp_feature_dat[] =
    "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
    "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
    "Feature\tFeature\n"
    "feature\t\t\t\t1\t2\tMSITESTDIR\t0\n";

static const char vp_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "feature\tcomp\n";

static const char vp_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "comp\t{24364AE7-5B7F-496C-AF5A-54893639C567}\tMSITESTDIR\t0\t\tvolumeprop\n";

static const char vp_custom_action_dat[] =
    "Action\tType\tSource\tTarget\tISComments\n"
    "s72\ti2\tS64\tS0\tS255\n"
    "CustomAction\tAction\n"
    "TestPrimaryVolumePath0\t19\t\tPrimaryVolumePath set before CostFinalize\t\n"
    "TestPrimaryVolumeSpaceAvailable0\t19\t\tPrimaryVolumeSpaceAvailable set before CostFinalize\t\n"
1139 1140
    "TestPrimaryVolumeSpaceRequired0\t19\t\tPrimaryVolumeSpaceRequired set before CostFinalize\t\n"
    "TestPrimaryVolumeSpaceRemaining0\t19\t\tPrimaryVolumeSpaceRemaining set before CostFinalize\t\n"
1141 1142
    "TestPrimaryVolumePath1\t19\t\tPrimaryVolumePath set before InstallValidate\t\n"
    "TestPrimaryVolumeSpaceAvailable1\t19\t\tPrimaryVolumeSpaceAvailable not set before InstallValidate\t\n"
1143 1144
    "TestPrimaryVolumeSpaceRequired1\t19\t\tPrimaryVolumeSpaceRequired not set before InstallValidate\t\n"
    "TestPrimaryVolumeSpaceRemaining1\t19\t\tPrimaryVolumeSpaceRemaining not set before InstallValidate\t\n"
1145
    "TestPrimaryVolumePath2\t19\t\tPrimaryVolumePath not set after InstallValidate\t\n"
1146 1147 1148
    "TestPrimaryVolumeSpaceAvailable2\t19\t\tPrimaryVolumeSpaceAvailable not set after InstallValidate\t\n"
    "TestPrimaryVolumeSpaceRequired2\t19\t\tPrimaryVolumeSpaceRequired not set after InstallValidate\t\n"
    "TestPrimaryVolumeSpaceRemaining2\t19\t\tPrimaryVolumeSpaceRemaining not set after InstallValidate\t\n";
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158

static const char vp_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "LaunchConditions\t\t100\n"
    "CostInitialize\t\t200\n"
    "FileCost\t\t300\n"
    "TestPrimaryVolumePath0\tPrimaryVolumePath AND NOT REMOVE\t400\n"
    "TestPrimaryVolumeSpaceAvailable0\tPrimaryVolumeSpaceAvailable AND NOT REMOVE\t500\n"
1159 1160
    "TestPrimaryVolumeSpaceRequired0\tPrimaryVolumeSpaceRequired AND NOT REMOVE\t510\n"
    "TestPrimaryVolumeSpaceRemaining0\tPrimaryVolumeSpaceRemaining AND NOT REMOVE\t520\n"
1161 1162 1163
    "CostFinalize\t\t600\n"
    "TestPrimaryVolumePath1\tPrimaryVolumePath AND NOT REMOVE\t600\n"
    "TestPrimaryVolumeSpaceAvailable1\tNOT PrimaryVolumeSpaceAvailable AND NOT REMOVE\t800\n"
1164 1165
    "TestPrimaryVolumeSpaceRequired1\tNOT PrimaryVolumeSpaceRequired AND NOT REMOVE\t810\n"
    "TestPrimaryVolumeSpaceRemaining1\tNOT PrimaryVolumeSpaceRemaining AND NOT REMOVE\t820\n"
1166 1167 1168
    "InstallValidate\t\t900\n"
    "TestPrimaryVolumePath2\tNOT PrimaryVolumePath AND NOT REMOVE\t1000\n"
    "TestPrimaryVolumeSpaceAvailable2\tNOT PrimaryVolumeSpaceAvailable AND NOT REMOVE\t1100\n"
1169 1170
    "TestPrimaryVolumeSpaceRequired2\tNOT PrimaryVolumeSpaceRequired AND NOT REMOVE\t1110\n"
    "TestPrimaryVolumeSpaceRemaining2\tNOT PrimaryVolumeSpaceRemaining AND NOT REMOVE\t1120\n"
1171 1172 1173 1174 1175 1176 1177
    "InstallInitialize\t\t1200\n"
    "ProcessComponents\t\t1300\n"
    "RemoveFiles\t\t1400\n"
    "InstallFiles\t\t1500\n"
    "RegisterProduct\t\t1600\n"
    "PublishFeatures\t\t1700\n"
    "PublishProduct\t\t1800\n"
1178
    "UnpublishFeatures\t\t1850\n"
1179 1180
    "InstallFinalize\t\t1900\n";

1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228
static const char shc_property_dat[] =
    "Property\tValue\n"
    "s72\tl0\n"
    "Property\tProperty\n"
    "INSTALLLEVEL\t3\n"
    "ProductCode\t{5CD99CD0-69C7-409B-9905-82DD743CC840}\n"
    "ProductName\tMSITEST\n"
    "ProductVersion\t1.1.1\n"
    "MSIFASTINSTALL\t1\n";

static const char shc2_property_dat[] =
    "Property\tValue\n"
    "s72\tl0\n"
    "Property\tProperty\n"
    "INSTALLLEVEL\t3\n"
    "ProductCode\t{4CEFADE5-DAFB-4C21-8EF2-4ED4F139F340}\n"
    "ProductName\tMSITEST2\n"
    "ProductVersion\t1.1.1\n"
    "MSIFASTINSTALL\t1\n";

static const char shc_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "sharedcomponent\tsharedcomponent\tsharedcomponent.txt\t1000\t\t\t8192\t1\n";

static const char shc_feature_dat[] =
    "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
    "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
    "Feature\tFeature\n"
    "feature\t\t\t\t1\t2\tMSITESTDIR\t0\n";

static const char shc_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "feature\tsharedcomponent\n";

static const char shc_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "sharedcomponent\t{900A4ACB-DC6F-4795-A04B-81B530183D41}\tMSITESTDIR\t0\t\tsharedcomponent\n";

static const char shc_custom_action_dat[] =
    "Action\tType\tSource\tTarget\tISComments\n"
    "s72\ti2\tS64\tS0\tS255\n"
    "CustomAction\tAction\n"
1229 1230 1231
    "TestComponentAction\t19\t\twrong component action on install\t\n"
    "TestDisallowedAction\t19\t\twrong component action on disallowed remove\t\n"
    "TestRemoveAction\t19\t\twrong component action on remove\t\n";
1232 1233 1234 1235 1236 1237 1238 1239 1240

static const char shc_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "LaunchConditions\t\t100\n"
    "CostInitialize\t\t200\n"
    "FileCost\t\t300\n"
    "CostFinalize\t\t600\n"
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250
    "TestDisallowedAction\tREMOVE AND ($sharedcomponent <> -1)\t700\n"
    "InstallValidate\t\t900\n"
    "InstallInitialize\t\t1200\n"
    "ProcessComponents\t\t1300\n"
    "RemoveFiles\t\t1400\n"
    "InstallFiles\t\t1500\n"
    "TestComponentAction\tNOT REMOVE AND ($sharedcomponent <> 3)\t1600\n"
    "RegisterProduct\t\t1700\n"
    "PublishFeatures\t\t1800\n"
    "PublishProduct\t\t1900\n"
1251
    "UnpublishFeatures\t\t1950\n"
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
    "InstallFinalize\t\t2000\n";

static const char shc2_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "LaunchConditions\t\t100\n"
    "CostInitialize\t\t200\n"
    "FileCost\t\t300\n"
    "CostFinalize\t\t600\n"
    "TestRemoveAction\tREMOVE AND ($sharedcomponent <> 2)\t700\n"
1263 1264 1265 1266 1267 1268 1269 1270 1271
    "InstallValidate\t\t900\n"
    "InstallInitialize\t\t1200\n"
    "ProcessComponents\t\t1300\n"
    "RemoveFiles\t\t1400\n"
    "InstallFiles\t\t1500\n"
    "TestComponentAction\tNOT REMOVE AND ($sharedcomponent <> 3)\t1600\n"
    "RegisterProduct\t\t1700\n"
    "PublishFeatures\t\t1800\n"
    "PublishProduct\t\t1900\n"
1272
    "UnpublishFeatures\t\t1950\n"
1273 1274
    "InstallFinalize\t\t2000\n";

1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335
static const char ft_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "featuretree\tcomp\tfeaturetree.txt\t1000\t\t\t8192\t1\n";

static const char ft_comp_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "comp\t{12345678-1234-1234-1234-222222222222}\tTARGETDIR\t0\t\t\n"
    "comp2\t{12345678-1234-1234-1234-333333333333}\tTARGETDIR\t0\t\tfeaturetree\n";

static const char ft_feature_dat[] =
    "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
    "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
    "Feature\tFeature\n"
    "A\t\t\t\t2\t1\t\t0\n"
    "C\tB\t\t\t2\t1\t\t0\n"
    "B\tA\t\t\t4\t1\t\t0\n"
    "D\t\t\t\t2\t1\t\t0\n";

static const char ft_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "C\tcomp\n"
    "D\tcomp2\n";

static const char ft_condition_dat[] =
    "Feature_\tLevel\tCondition\n"
    "s38\ti2\tS255\n"
    "Condition\tFeature_\tLevel\n"
    "A\t0\t\"0\"<>INSTALLTYPE\n";

static const char ft_custom_action_dat[] =
    "Action\tType\tSource\tTarget\tISComments\n"
    "s72\ti2\tS64\tS0\tS255\n"
    "CustomAction\tAction\n"
    "Run A\t19\t\tA\t\n"
    "Run B\t19\t\tB\t\n"
    "Run C\t19\t\tC\t\n";

static const char ft_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "CostInitialize\t\t100\n"
    "FileCost\t\t200\n"
    "CostFinalize\t\t300\n"
    "InstallValidate\t\t400\n"
    "InstallInitialize\t\t500\n"
    "Run C\t3 = &C AND NOT Installed\t600\n"
    "Run B\t3 = &B AND NOT Installed\t700\n"
    "Run A\t3 = &A AND NOT Installed\t800\n"
    "ProcessComponents\t\t900\n"
    "RemoveFiles\t\t1000\n"
    "InstallFiles\t\t1100\n"
    "RegisterProduct\t\t1200\n"
    "PublishFeatures\t\t1300\n"
    "PublishProduct\t\t1400\n"
1336
    "UnpublishFeatures\t\t1450\n"
1337 1338
    "InstallFinalize\t\t1500\n";

1339
static const char da_custom_action_dat[] =
1340 1341
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
1342
    "CustomAction\tAction\n"
1343 1344 1345
    "setprop\t51\tdeferred\t[TESTPATH]\n"
    "immediate\t1\tcustom.dll\tda_immediate\n"
    "deferred\t1025\tcustom.dll\tda_deferred\n";
1346 1347 1348 1349 1350 1351 1352 1353 1354

static const char da_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "CostInitialize\t\t200\n"
    "FileCost\t\t300\n"
    "CostFinalize\t\t400\n"
    "InstallInitialize\t\t500\n"
1355 1356 1357 1358
    "setprop\t\t600\n"
    "deferred\t\t700\n"
    "immediate\t\t800\n"
    "InstallFinalize\t\t1100\n";
1359

1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371
static const CHAR x64_directory_dat[] =
    "Directory\tDirectory_Parent\tDefaultDir\n"
    "s72\tS72\tl255\n"
    "Directory\tDirectory\n"
    "CABOUTDIR\tMSITESTDIR\tcabout\n"
    "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
    "FIRSTDIR\tMSITESTDIR\tfirst\n"
    "MSITESTDIR\tProgramFiles64Folder\tmsitest\n"
    "NEWDIR\tCABOUTDIR\tnew\n"
    "ProgramFiles64Folder\tTARGETDIR\t.\n"
    "TARGETDIR\t\tSourceDir";

1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383
static const CHAR sr_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "CostInitialize\t\t200\n"
    "FileCost\t\t300\n"
    "CostFinalize\t\t400\n"
    "InstallValidate\t\t500\n"
    "InstallInitialize\t\t600\n"
    "sourcedir_unset\tSourceDir\t700\n"
    "ResolveSource\tRESOLVE_SOURCE\t800\n"
    "ProcessComponents\tPROCESS_COMPONENTS\t800\n"
1384
    "InstallFiles\tINSTALL_FILES\t800\n"
1385 1386 1387 1388 1389 1390 1391 1392 1393 1394
    "sourcedir_set\tNOT SourceDir\t900\n"
    "InstallFinalize\t\t1000\n";

static const CHAR sr_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "sourcedir_unset\t19\t\tSourceDir should not be set\n"
    "sourcedir_set\t19\t\tSourceDir should be set\n";

1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422
static const CHAR ai2_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "five.txt\tFive\tfive.txt\t1000\t\t\t0\t5\n"
    "four.txt\tFour\tfour.txt\t1000\t\t\t0\t4\n";

static const CHAR ai2_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
    "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n";

static const CHAR ai2_feature_dat[] =
    "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
    "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
    "Feature\tFeature\n"
    "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
    "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n";

static const CHAR ai2_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "Five\tFive\n"
    "Four\tFour\n";

1423 1424 1425 1426 1427 1428 1429 1430 1431 1432
static const msi_table tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property),
1433
    ADD_TABLE(registry),
1434 1435
};

1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
static const msi_table sc_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property),
    ADD_TABLE(shortcut)
};

1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461
static const msi_table ps_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property),
    ADD_TABLE(condition)
};

1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552
static const msi_table up_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(up_property),
    ADD_TABLE(registry),
};

static const msi_table up2_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(up2_property),
    ADD_TABLE(registry),
};

static const msi_table up3_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(up3_property),
    ADD_TABLE(registry),
};

static const msi_table up4_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(pp_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property),
    ADD_TABLE(registry),
};

static const msi_table up5_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(pp_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(up_property),
    ADD_TABLE(registry),
};

static const msi_table up6_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(pp_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(up2_property),
    ADD_TABLE(registry),
};

static const msi_table up7_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(pp_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(up3_property),
    ADD_TABLE(registry),
};

1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564
static const msi_table cc_tables[] =
{
    ADD_TABLE(cc_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cc_feature_comp),
    ADD_TABLE(cc_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(cc_media),
    ADD_TABLE(property),
};

1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576
static const msi_table cc2_tables[] =
{
    ADD_TABLE(cc2_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cc_feature_comp),
    ADD_TABLE(cc2_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(cc_media),
    ADD_TABLE(property),
};

1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588
static const msi_table cc3_tables[] =
{
    ADD_TABLE(cc_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cc_feature_comp),
    ADD_TABLE(cc_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(cc3_media),
    ADD_TABLE(property),
};

1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
static const msi_table co_tables[] =
{
    ADD_TABLE(cc_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cc_feature_comp),
    ADD_TABLE(co_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(co_media),
    ADD_TABLE(property),
};

static const msi_table co2_tables[] =
{
    ADD_TABLE(cc_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cc_feature_comp),
    ADD_TABLE(cc_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(co2_media),
    ADD_TABLE(property),
};

1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624
static const msi_table mm_tables[] =
{
    ADD_TABLE(cc_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cc_feature_comp),
    ADD_TABLE(mm_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(mm_media),
    ADD_TABLE(property),
};

1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636
static const msi_table ss_tables[] =
{
    ADD_TABLE(cc_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cc_feature_comp),
    ADD_TABLE(cc_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(ss_media),
    ADD_TABLE(property),
};

1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650
static const msi_table ui_tables[] =
{
    ADD_TABLE(ui_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cc_feature_comp),
    ADD_TABLE(cc_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(ui_install_ui_seq),
    ADD_TABLE(ui_custom_action),
    ADD_TABLE(cc_media),
    ADD_TABLE(property),
};

1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662
static const msi_table rof_tables[] =
{
    ADD_TABLE(rof_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rof_feature_comp),
    ADD_TABLE(rof_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674
static const msi_table rofc_tables[] =
{
    ADD_TABLE(rof_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rof_feature_comp),
    ADD_TABLE(rofc_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rofc_media),
    ADD_TABLE(property),
};

1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687
static const msi_table sdp_tables[] =
{
    ADD_TABLE(rof_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rof_feature_comp),
    ADD_TABLE(rof_file),
    ADD_TABLE(sdp_install_exec_seq),
    ADD_TABLE(sdp_custom_action),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699
static const msi_table cie_tables[] =
{
    ADD_TABLE(cie_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cie_feature_comp),
    ADD_TABLE(cie_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(cie_media),
    ADD_TABLE(property),
};

1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711
static const msi_table tp_tables[] =
{
    ADD_TABLE(tp_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723
static const msi_table cwd_tables[] =
{
    ADD_TABLE(cwd_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737
static const msi_table adm_tables[] =
{
    ADD_TABLE(adm_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
    ADD_TABLE(adm_custom_action),
    ADD_TABLE(adm_admin_exec_seq),
};

1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749
static const msi_table amp_tables[] =
{
    ADD_TABLE(amp_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762
static const msi_table mc_tables[] =
{
    ADD_TABLE(mc_component),
    ADD_TABLE(directory),
    ADD_TABLE(cc_feature),
    ADD_TABLE(cie_feature_comp),
    ADD_TABLE(mc_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(mc_media),
    ADD_TABLE(property),
    ADD_TABLE(mc_file_hash),
};

1763
static const msi_table sf_tables[] =
1764
{
1765 1766
    ADD_TABLE(wrv_component),
    ADD_TABLE(directory),
1767
    ADD_TABLE(rof_feature),
1768 1769
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
1770 1771 1772 1773 1774
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1775 1776
static const msi_table ca1_tables[] =
{
1777 1778 1779 1780 1781
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
1782
    ADD_TABLE(property),
1783
    ADD_TABLE(directory),
1784 1785
    ADD_TABLE(ca1_install_exec_seq),
    ADD_TABLE(ca1_custom_action),
1786
    ADD_TABLE(ca1_test_seq),
1787 1788
    ADD_TABLE(ca1_test2),
    ADD_TABLE(ca1__validation),
1789 1790
};

1791
static const msi_table ca51_tables[] =
1792
{
1793
    ADD_TABLE(ca51_component),
1794 1795 1796 1797 1798 1799 1800 1801 1802 1803
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
    ADD_TABLE(ca51_install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
    ADD_TABLE(ca51_custom_action),
};

1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815
static const msi_table is_tables[] =
{
    ADD_TABLE(is_component),
    ADD_TABLE(directory),
    ADD_TABLE(is_feature),
    ADD_TABLE(is_feature_comp),
    ADD_TABLE(is_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(is_media),
    ADD_TABLE(property),
};

1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827
static const msi_table sp_tables[] =
{
    ADD_TABLE(sp_component),
    ADD_TABLE(sp_directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1828 1829 1830 1831 1832 1833
static const msi_table mcp_tables[] =
{
    ADD_TABLE(mcp_component),
    ADD_TABLE(directory),
    ADD_TABLE(mcp_feature),
    ADD_TABLE(mcp_feature_comp),
1834
    ADD_TABLE(mcp_file),
1835 1836 1837 1838 1839
    ADD_TABLE(rem_install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851
static const msi_table ai_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(ai_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863
static const msi_table ai2_tables[] =
{
    ADD_TABLE(ai2_component),
    ADD_TABLE(directory),
    ADD_TABLE(ai2_feature),
    ADD_TABLE(ai2_feature_comp),
    ADD_TABLE(ai2_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875
static const msi_table pc_tables[] =
{
    ADD_TABLE(ca51_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
    ADD_TABLE(install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property)
};

1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888
static const msi_table ip_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(ip_install_exec_seq),
    ADD_TABLE(ip_custom_action),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901
static const msi_table aup_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(aup_install_exec_seq),
    ADD_TABLE(aup_custom_action),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940
static const msi_table aup2_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(aup2_install_exec_seq),
    ADD_TABLE(aup_custom_action),
    ADD_TABLE(media),
    ADD_TABLE(aup_property)
};

static const msi_table aup3_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(aup2_install_exec_seq),
    ADD_TABLE(aup_custom_action),
    ADD_TABLE(media),
    ADD_TABLE(aup2_property)
};

static const msi_table aup4_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(aup3_install_exec_seq),
    ADD_TABLE(aup_custom_action),
    ADD_TABLE(media),
    ADD_TABLE(aup2_property)
};

1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952
static const msi_table fiu_tables[] =
{
    ADD_TABLE(rof_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rof_feature_comp),
    ADD_TABLE(rof_file),
    ADD_TABLE(pp_install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964
static const msi_table fiuc_tables[] =
{
    ADD_TABLE(rof_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rof_feature_comp),
    ADD_TABLE(rofc_file),
    ADD_TABLE(pp_install_exec_seq),
    ADD_TABLE(rofc_media),
    ADD_TABLE(property),
};

1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978
static const msi_table fo_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(fo_file),
    ADD_TABLE(fo_component),
    ADD_TABLE(fo_feature),
    ADD_TABLE(fo_condition),
    ADD_TABLE(fo_feature_comp),
    ADD_TABLE(fo_custom_action),
    ADD_TABLE(fo_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
static const msi_table icon_base_tables[] =
{
    ADD_TABLE(ci_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rof_feature_comp),
    ADD_TABLE(rof_file),
    ADD_TABLE(pp_install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(icon_property),
};

1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002
static const msi_table pv_tables[] =
{
    ADD_TABLE(rof_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rof_feature_comp),
    ADD_TABLE(rof_file),
    ADD_TABLE(pv_install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property)
};

2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
static const msi_table uc_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(uc_component),
    ADD_TABLE(uc_feature),
    ADD_TABLE(uc_feature_comp),
    ADD_TABLE(uc_file),
    ADD_TABLE(uc_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(uc_property)
};

2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026
static const msi_table mixed_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(mixed_component),
    ADD_TABLE(mixed_feature),
    ADD_TABLE(mixed_feature_comp),
    ADD_TABLE(mixed_install_exec_seq),
    ADD_TABLE(mixed_registry),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039
static const msi_table vp_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(vp_file),
    ADD_TABLE(vp_component),
    ADD_TABLE(vp_feature),
    ADD_TABLE(vp_feature_comp),
    ADD_TABLE(vp_custom_action),
    ADD_TABLE(vp_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061
static const msi_table shc_tables[] =
{
    ADD_TABLE(media),
    ADD_TABLE(directory),
    ADD_TABLE(shc_file),
    ADD_TABLE(shc_component),
    ADD_TABLE(shc_feature),
    ADD_TABLE(shc_feature_comp),
    ADD_TABLE(shc_custom_action),
    ADD_TABLE(shc_install_exec_seq),
    ADD_TABLE(shc_property)
};

static const msi_table shc2_tables[] =
{
    ADD_TABLE(media),
    ADD_TABLE(directory),
    ADD_TABLE(shc_file),
    ADD_TABLE(shc_component),
    ADD_TABLE(shc_feature),
    ADD_TABLE(shc_feature_comp),
    ADD_TABLE(shc_custom_action),
2062
    ADD_TABLE(shc2_install_exec_seq),
2063 2064 2065
    ADD_TABLE(shc2_property)
};

2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079
static const msi_table ft_tables[] =
{
    ADD_TABLE(media),
    ADD_TABLE(directory),
    ADD_TABLE(ft_file),
    ADD_TABLE(ft_comp),
    ADD_TABLE(ft_feature),
    ADD_TABLE(ft_feature_comp),
    ADD_TABLE(ft_condition),
    ADD_TABLE(ft_custom_action),
    ADD_TABLE(ft_install_exec_seq),
    ADD_TABLE(property)
};

2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092
static const msi_table da_tables[] =
{
    ADD_TABLE(media),
    ADD_TABLE(directory),
    ADD_TABLE(file),
    ADD_TABLE(component),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(property),
    ADD_TABLE(da_install_exec_seq),
    ADD_TABLE(da_custom_action),
};

2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104
static const msi_table x64_tables[] =
{
    ADD_TABLE(media),
    ADD_TABLE(x64_directory),
    ADD_TABLE(file),
    ADD_TABLE(component),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(property),
    ADD_TABLE(install_exec_seq),
};

2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117
static const msi_table sr_tables[] =
{
    ADD_TABLE(media),
    ADD_TABLE(directory),
    ADD_TABLE(file),
    ADD_TABLE(component),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(property),
    ADD_TABLE(sr_install_exec_seq),
    ADD_TABLE(sr_custom_action),
};

2118 2119 2120
/* cabinet definitions */

/* make the max size large so there is only one cab file */
2121
#define MEDIA_SIZE          0x7FFFFFFF
2122 2123 2124 2125
#define FOLDER_THRESHOLD    900000

/* the FCI callbacks */

2126
static void * CDECL mem_alloc(ULONG cb)
2127
{
2128
    return malloc(cb);
2129 2130
}

2131
static void CDECL mem_free(void *memory)
2132
{
2133
    free(memory);
2134 2135
}

2136
static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG  cbPrevCab, void *pv)
2137
{
2138
    sprintf(pccab->szCab, pv, pccab->iCab);
2139 2140 2141
    return TRUE;
}

2142
static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
2143 2144 2145 2146
{
    return 0;
}

2147
static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile,
2148
                             BOOL fContinuation, void *pv)
2149 2150 2151 2152
{
    return 0;
}

2153
static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
2154 2155 2156 2157 2158
{
    HANDLE handle;
    DWORD dwAccess = 0;
    DWORD dwShareMode = 0;
    DWORD dwCreateDisposition = OPEN_EXISTING;
2159

2160
    dwAccess = GENERIC_READ | GENERIC_WRITE;
2161
    dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175

    if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
        dwCreateDisposition = OPEN_EXISTING;
    else
        dwCreateDisposition = CREATE_NEW;

    handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
                         dwCreateDisposition, 0, NULL);

    ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);

    return (INT_PTR)handle;
}

2176
static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
2177 2178 2179 2180
{
    HANDLE handle = (HANDLE)hf;
    DWORD dwRead;
    BOOL res;
2181

2182 2183 2184 2185 2186 2187
    res = ReadFile(handle, memory, cb, &dwRead, NULL);
    ok(res, "Failed to ReadFile\n");

    return dwRead;
}

2188
static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199
{
    HANDLE handle = (HANDLE)hf;
    DWORD dwWritten;
    BOOL res;

    res = WriteFile(handle, memory, cb, &dwWritten, NULL);
    ok(res, "Failed to WriteFile\n");

    return dwWritten;
}

2200
static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
2201 2202 2203 2204 2205 2206 2207
{
    HANDLE handle = (HANDLE)hf;
    ok(CloseHandle(handle), "Failed to CloseHandle\n");

    return 0;
}

2208
static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
2209 2210 2211
{
    HANDLE handle = (HANDLE)hf;
    DWORD ret;
2212

2213 2214 2215 2216 2217 2218
    ret = SetFilePointer(handle, dist, NULL, seektype);
    ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");

    return ret;
}

2219
static int CDECL fci_delete(char *pszFile, int *err, void *pv)
2220 2221 2222 2223 2224 2225 2226
{
    BOOL ret = DeleteFileA(pszFile);
    ok(ret, "Failed to DeleteFile %s\n", pszFile);

    return 0;
}

2227 2228 2229
static void init_functionpointers(void)
{
    HMODULE hmsi = GetModuleHandleA("msi.dll");
2230
    HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
2231
    HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
2232
    HMODULE hsrclient = LoadLibraryA("srclient.dll");
2233

2234 2235
#define GET_PROC(mod, func) \
    p ## func = (void*)GetProcAddress(mod, #func); \
2236 2237 2238
    if(!p ## func) \
      trace("GetProcAddress(%s) failed\n", #func);

2239 2240
    GET_PROC(hmsi, MsiQueryComponentStateA);
    GET_PROC(hmsi, MsiSourceListEnumSourcesA);
2241
    GET_PROC(hmsi, MsiGetComponentPathExA);
2242

2243 2244
    GET_PROC(hadvapi32, RegDeleteKeyExA)
    GET_PROC(hkernel32, IsWow64Process)
2245 2246
    GET_PROC(hkernel32, Wow64DisableWow64FsRedirection);
    GET_PROC(hkernel32, Wow64RevertWow64FsRedirection);
2247

2248 2249
    GET_PROC(hsrclient, SRRemoveRestorePoint);
    GET_PROC(hsrclient, SRSetRestorePointA);
2250 2251

#undef GET_PROC
2252 2253
}

2254
BOOL is_process_limited(void)
2255
{
2256
    SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
2257
    PSID Group = NULL;
2258
    BOOL IsInGroup;
2259 2260
    HANDLE token;

2261
    if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
2262
                                  DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) ||
2263
        !CheckTokenMembership(NULL, Group, &IsInGroup))
2264 2265
    {
        trace("Could not check if the current user is an administrator\n");
2266
        FreeSid(Group);
2267 2268
        return FALSE;
    }
2269 2270
    FreeSid(Group);

2271 2272 2273 2274 2275
    if (!IsInGroup)
    {
        /* Only administrators have enough privileges for these tests */
        return TRUE;
    }
2276

2277
    if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
2278 2279 2280 2281 2282
    {
        BOOL ret;
        TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
        DWORD size;

2283
        ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
2284 2285 2286 2287 2288 2289
        CloseHandle(token);
        return (ret && type == TokenElevationTypeLimited);
    }
    return FALSE;
}

2290
static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
2291 2292 2293 2294 2295 2296
{
    CHAR buffer[0x20];
    UINT r;
    DWORD sz;

    sz = sizeof buffer;
2297
    r = MsiRecordGetStringA(rec, field, buffer, &sz);
2298 2299 2300
    return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
}

2301
static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
2302 2303 2304
{
    LPSTR tempname;

2305
    tempname = malloc(MAX_PATH);
2306 2307 2308 2309 2310
    GetTempFileNameA(".", "xx", 0, tempname);

    if (tempname && (strlen(tempname) < (unsigned)cbTempName))
    {
        lstrcpyA(pszTempName, tempname);
2311
        free(tempname);
2312 2313 2314
        return TRUE;
    }

2315
    free(tempname);
2316 2317 2318
    return FALSE;
}

2319 2320
static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
                                   USHORT *pattribs, int *err, void *pv)
2321 2322 2323 2324 2325 2326 2327
{
    BY_HANDLE_FILE_INFORMATION finfo;
    FILETIME filetime;
    HANDLE handle;
    DWORD attrs;
    BOOL res;

2328 2329
    handle = CreateFileA(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
2330 2331 2332 2333 2334

    ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);

    res = GetFileInformationByHandle(handle, &finfo);
    ok(res, "Expected GetFileInformationByHandle to succeed\n");
2335

2336 2337 2338
    FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
    FileTimeToDosDateTime(&filetime, pdate, ptime);

2339
    attrs = GetFileAttributesA(pszName);
2340 2341 2342 2343 2344
    ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");

    return (INT_PTR)handle;
}

2345
static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
2346 2347
{
    char path[MAX_PATH];
2348
    char filename[MAX_PATH];
2349 2350 2351 2352 2353

    lstrcpyA(path, CURR_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, file);

2354 2355
    lstrcpyA(filename, file);

2356 2357
    return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
                      progress, get_open_info, compress);
2358 2359
}

2360
static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
2361 2362 2363
{
    ZeroMemory(pCabParams, sizeof(CCAB));

2364
    pCabParams->cb = max_size;
2365 2366
    pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
    pCabParams->setID = 0xbeef;
2367
    pCabParams->iCab = 1;
2368 2369 2370 2371 2372
    lstrcpyA(pCabParams->szCabPath, CURR_DIR);
    lstrcatA(pCabParams->szCabPath, "\\");
    lstrcpyA(pCabParams->szCab, name);
}

2373
void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
2374 2375
{
    CCAB cabParams;
2376
    LPCSTR ptr;
2377 2378 2379 2380
    HFCI hfci;
    ERF erf;
    BOOL res;

2381
    set_cab_parameters(&cabParams, name, max_size);
2382 2383 2384 2385 2386 2387 2388

    hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
                      fci_read, fci_write, fci_close, fci_seek, fci_delete,
                      get_temp_file, &cabParams, NULL);

    ok(hfci != NULL, "Failed to create an FCI context\n");

2389 2390 2391
    ptr = files;
    while (*ptr)
    {
2392 2393
        res = add_file(hfci, ptr, tcompTYPE_MSZIP);
        ok(res, "Failed to add file: %s\n", ptr);
2394
        ptr += lstrlenA(ptr) + 1;
2395
    }
2396 2397 2398 2399 2400 2401 2402 2403

    res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
    ok(res, "Failed to flush the cabinet\n");

    res = FCIDestroy(hfci);
    ok(res, "Failed to destroy the cabinet\n");
}

2404
BOOL get_user_dirs(void)
2405
{
2406 2407
    HKEY hkey;
    DWORD type, size;
2408

2409 2410
    if (RegOpenKeyA(HKEY_CURRENT_USER,
                    "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey))
2411 2412
        return FALSE;

2413 2414 2415 2416 2417 2418 2419
    size = MAX_PATH;
    if(RegQueryValueExA(hkey, "AppData", 0, &type, (LPBYTE)APP_DATA_DIR, &size)){
        RegCloseKey(hkey);
        return FALSE;
    }

    RegCloseKey(hkey);
2420 2421 2422
    return TRUE;
}

2423
BOOL get_system_dirs(void)
2424 2425
{
    HKEY hkey;
2426
    DWORD type, size;
2427

2428 2429
    if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
        0, KEY_QUERY_VALUE | KEY_WOW64_64KEY, &hkey))
2430 2431 2432
        return FALSE;

    size = MAX_PATH;
2433 2434
    if (RegQueryValueExA(hkey, "ProgramFilesDir (x86)", 0, &type, (LPBYTE)PROG_FILES_DIR, &size) &&
        RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)PROG_FILES_DIR, &size)) {
2435
        RegCloseKey(hkey);
2436
        return FALSE;
2437
    }
2438

2439
    size = MAX_PATH;
2440 2441
    if (RegQueryValueExA(hkey, "CommonFilesDir (x86)", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size) &&
        RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size)) {
2442
        RegCloseKey(hkey);
2443
        return FALSE;
2444
    }
2445

2446 2447 2448 2449 2450 2451
    size = MAX_PATH;
    if (RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)PROG_FILES_DIR_NATIVE, &size)) {
        RegCloseKey(hkey);
        return FALSE;
    }

2452
    RegCloseKey(hkey);
2453

2454
    if(!GetWindowsDirectoryA(WINDOWS_DIR, MAX_PATH))
2455 2456
        return FALSE;

2457 2458 2459
    return TRUE;
}

2460
void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
2461 2462
{
    HANDLE file;
2463
    DWORD written;
2464 2465

    file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
2466 2467 2468
    if (file == INVALID_HANDLE_VALUE)
        return;

2469
    WriteFile(file, data, strlen(data), &written, NULL);
2470

2471 2472 2473 2474 2475
    if (size)
    {
        SetFilePointer(file, size, NULL, FILE_BEGIN);
        SetEndOfFile(file);
    }
2476

2477 2478 2479 2480 2481 2482
    CloseHandle(file);
}

static void create_test_files(void)
{
    CreateDirectoryA("msitest", NULL);
2483
    create_file("msitest\\one.txt", 100);
2484
    CreateDirectoryA("msitest\\first", NULL);
2485
    create_file("msitest\\first\\two.txt", 100);
2486
    CreateDirectoryA("msitest\\second", NULL);
2487
    create_file("msitest\\second\\three.txt", 100);
2488

2489 2490 2491
    create_file("four.txt", 100);
    create_file("five.txt", 100);
    create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
2492

2493
    create_file("msitest\\filename", 100);
2494

2495 2496 2497 2498
    DeleteFileA("four.txt");
    DeleteFileA("five.txt");
}

2499
BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512
{
    CHAR path[MAX_PATH];

    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, rel_path);

    if (is_file)
        return DeleteFileA(path);
    else
        return RemoveDirectoryA(path);
}

2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526
static BOOL delete_pf_native(const CHAR *rel_path, BOOL is_file)
{
    CHAR path[MAX_PATH];

    lstrcpyA(path, PROG_FILES_DIR_NATIVE);
    lstrcatA(path, "\\");
    lstrcatA(path, rel_path);

    if (is_file)
        return DeleteFileA(path);
    else
        return RemoveDirectoryA(path);
}

2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540
static BOOL delete_cf(const CHAR *rel_path, BOOL is_file)
{
    CHAR path[MAX_PATH];

    lstrcpyA(path, COMMON_FILES_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, rel_path);

    if (is_file)
        return DeleteFileA(path);
    else
        return RemoveDirectoryA(path);
}

2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552
static BOOL compare_pf_data(const char *filename, const char *data, DWORD size)
{
    DWORD read;
    HANDLE handle;
    BOOL ret = FALSE;
    char *buffer, path[MAX_PATH];

    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, filename);

    handle = CreateFileA(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
2553
    if ((buffer = malloc(size)))
2554 2555 2556
    {
        ReadFile(handle, buffer, size, &read, NULL);
        if (read == size && !memcmp(data, buffer, size)) ret = TRUE;
2557
        free(buffer);
2558 2559 2560 2561 2562
    }
    CloseHandle(handle);
    return ret;
}

2563 2564 2565 2566 2567 2568 2569
static void delete_test_files(void)
{
    DeleteFileA("msitest.msi");
    DeleteFileA("msitest.cab");
    DeleteFileA("msitest\\second\\three.txt");
    DeleteFileA("msitest\\first\\two.txt");
    DeleteFileA("msitest\\one.txt");
2570
    DeleteFileA("msitest\\filename");
2571 2572 2573 2574 2575
    RemoveDirectoryA("msitest\\second");
    RemoveDirectoryA("msitest\\first");
    RemoveDirectoryA("msitest");
}

2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590
static void delete_pf_files(void)
{
    ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
    ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
    ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
    ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
    ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
}

2591 2592 2593 2594
static void write_file(const CHAR *filename, const char *data, int data_size)
{
    DWORD size;

2595 2596
    HANDLE hf = CreateFileA(filename, GENERIC_WRITE, 0, NULL,
                            CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
2597 2598 2599 2600
    WriteFile(hf, data, data_size, &size, NULL);
    CloseHandle(hf);
}

2601 2602
static void write_msi_summary_info(MSIHANDLE db, INT version, INT wordcount,
                                   const char *template, const char *packagecode)
2603 2604 2605 2606
{
    MSIHANDLE summary;
    UINT r;

2607
    r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
2608 2609
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2610
    r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, template);
2611 2612
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2613
    r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL, packagecode);
2614 2615
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2616
    r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, version, NULL, NULL);
2617 2618
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2619
    r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, wordcount, NULL, NULL);
2620 2621
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2622 2623 2624
    r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2625 2626 2627 2628 2629 2630 2631
    /* write the summary changes back to the stream */
    r = MsiSummaryInfoPersist(summary);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    MsiCloseHandle(summary);
}

2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642
static char *load_resource(const char *name)
{
    static char path[MAX_PATH];
    DWORD written;
    HANDLE file;
    HRSRC res;
    void *ptr;

    GetTempFileNameA(".", name, 0, path);

    file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
2643
    ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %lu\n", path, GetLastError());
2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698

    res = FindResourceA(NULL, name, "TESTDLL");
    ok( res != 0, "couldn't find resource\n" );
    ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res ));
    WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL );
    ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
    CloseHandle( file );

    return path;
}

static INT CALLBACK ok_callback(void *context, UINT message_type, MSIHANDLE record)
{
    if (message_type == INSTALLMESSAGE_USER)
    {
        char file[200];
        char msg[2000];
        DWORD len;

        len = sizeof(file);
        MsiRecordGetStringA(record, 2, file, &len);
        len = sizeof(msg);
        MsiRecordGetStringA(record, 5, msg, &len);

        todo_wine_if(MsiRecordGetInteger(record, 1))
        ok_(file, MsiRecordGetInteger(record, 3)) (MsiRecordGetInteger(record, 4), "%s", msg);

        return 1;
    }
    return 0;
}

static void add_custom_dll(MSIHANDLE hdb)
{
    MSIHANDLE record;
    UINT res;

    if (!customdll)
        customdll = load_resource("custom.dll");

    MsiSetExternalUIRecord(ok_callback, INSTALLLOGMODE_USER, NULL, NULL);

    res = run_query(hdb, 0, "CREATE TABLE `Binary` (`Name` CHAR(72) NOT NULL, `Data` OBJECT NOT NULL PRIMARY KEY `Name`)");
    ok(res == ERROR_SUCCESS, "failed to create Binary table: %u\n", res);

    record = MsiCreateRecord(1);
    res = MsiRecordSetStreamA(record, 1, customdll);
    ok(res == ERROR_SUCCESS, "failed to add %s to stream: %u\n", customdll, res);

    res = run_query(hdb, record, "INSERT INTO `Binary` (`Name`, `Data`) VALUES ('custom.dll', ?)");
    ok(res == ERROR_SUCCESS, "failed to insert into Binary table: %u\n", res);

    MsiCloseHandle(record);
}

2699 2700
void create_database_wordcount(const CHAR *name, const msi_table *tables, int num_tables,
    INT version, INT wordcount, const char *template, const char *packagecode)
2701 2702 2703
{
    MSIHANDLE db;
    UINT r;
2704 2705
    WCHAR *nameW;
    int j, len;
2706

2707
    len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
2708
    if (!(nameW = malloc( len * sizeof(WCHAR) ))) return;
2709 2710 2711
    MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, len );

    r = MsiOpenDatabaseW(nameW, MSIDBOPEN_CREATE, &db);
2712 2713 2714 2715 2716 2717 2718 2719 2720 2721
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    /* import the tables into the database */
    for (j = 0; j < num_tables; j++)
    {
        const msi_table *table = &tables[j];

        write_file(table->filename, table->data, (table->size - 1) * sizeof(char));

        r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
2722
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2723 2724 2725 2726

        DeleteFileA(table->filename);
    }

2727
    write_msi_summary_info(db, version, wordcount, template, packagecode);
2728
    add_custom_dll(db);
2729 2730 2731 2732 2733

    r = MsiDatabaseCommit(db);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    MsiCloseHandle(db);
2734
    free( nameW );
2735 2736
}

2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754
static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
{
    RESTOREPOINTINFOA spec;

    spec.dwEventType = event_type;
    spec.dwRestorePtType = APPLICATION_INSTALL;
    spec.llSequenceNumber = status->llSequenceNumber;
    lstrcpyA(spec.szDescription, "msitest restore point");

    return pSRSetRestorePointA(&spec, status);
}

static void remove_restore_point(DWORD seq_number)
{
    DWORD res;

    res = pSRRemoveRestorePoint(seq_number);
    if (res != ERROR_SUCCESS)
2755
        trace("Failed to remove the restore point: %#lx\n", res);
2756 2757
}

2758 2759 2760 2761 2762 2763 2764
static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
{
    if (pRegDeleteKeyExA)
        return pRegDeleteKeyExA( key, subkey, access, 0 );
    return RegDeleteKeyA( key, subkey );
}

2765 2766 2767 2768 2769 2770 2771
static void test_MsiInstallProduct(void)
{
    UINT r;
    CHAR path[MAX_PATH];
    LONG res;
    HKEY hkey;
    DWORD num, size, type;
2772
    REGSAM access = KEY_ALL_ACCESS;
2773

2774 2775 2776 2777 2778
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }
2779

2780
    if (is_wow64)
2781 2782
        access |= KEY_WOW64_64KEY;

2783 2784
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

2785 2786 2787 2788 2789 2790 2791 2792
    if (0) /* crashes on Win10 1709 */
    {
        r = MsiInstallProductA(NULL, "INSTALL=ALL");
        ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);

        r = MsiInstallProductA(NULL, NULL);
        ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);
    }
2793 2794 2795 2796 2797 2798

    /* szPackagePath is empty */
    r = MsiInstallProductA("", "INSTALL=ALL");
    ok(r == ERROR_PATH_NOT_FOUND,
       "Expected ERROR_PATH_NOT_FOUND, got %d\n", r);

2799
    create_test_files();
2800
    create_database(msifile, tables, ARRAY_SIZE(tables));
2801

2802
    /* install, don't publish */
2803
    r = MsiInstallProductA(msifile, NULL);
2804 2805 2806 2807 2808
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
2809
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2810

2811
    delete_pf_files();
2812

2813
    res = RegOpenKeyExA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", 0, access, &hkey);
2814
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res);
2815 2816 2817 2818

    size = MAX_PATH;
    type = REG_SZ;
    res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
2819
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res);
2820
    ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
2821

2822 2823 2824
    size = MAX_PATH;
    type = REG_SZ;
    res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
2825
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", res);
2826

2827 2828 2829
    size = sizeof(num);
    type = REG_DWORD;
    res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
2830 2831
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res);
    ok(num == 314, "Expected 314, got %lu\n", num);
2832

2833 2834 2835
    size = MAX_PATH;
    type = REG_SZ;
    res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
2836
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res);
2837
    ok(!lstrcmpA(path, "OrderTestValue"), "Expected OrderTestValue, got %s\n", path);
2838

2839
    delete_key(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", access);
2840

2841 2842 2843 2844
    /* not published, reinstall */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2845
    delete_pf_files();
2846

2847
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2848
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res);
2849
    RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
2850

2851
    create_database(msifile, up_tables, ARRAY_SIZE(up_tables));
2852 2853 2854 2855 2856

    /* not published, RemovePreviousVersions set */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2857
    delete_pf_files();
2858

2859
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2860
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res);
2861
    RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
2862

2863
    create_database(msifile, up2_tables, ARRAY_SIZE(up2_tables));
2864 2865 2866 2867 2868

    /* not published, version number bumped */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2869
    delete_pf_files();
2870

2871
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2872
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res);
2873
    RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
2874

2875
    create_database(msifile, up3_tables, ARRAY_SIZE(up3_tables));
2876 2877 2878 2879 2880

    /* not published, RemovePreviousVersions set and version number bumped */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2881
    delete_pf_files();
2882

2883
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2884
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res);
2885
    RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest");
2886

2887
    create_database(msifile, up4_tables, ARRAY_SIZE(up4_tables));
2888 2889 2890 2891 2892

    /* install, publish product */
    r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2893
    delete_pf_files();
2894

2895
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2896
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", res);
2897

2898
    create_database(msifile, up4_tables, ARRAY_SIZE(up4_tables));
2899 2900 2901 2902 2903

    /* published, reinstall */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2904
    delete_pf_files();
2905

2906
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2907
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", res);
2908

2909
    create_database(msifile, up5_tables, ARRAY_SIZE(up5_tables));
2910 2911 2912 2913 2914

    /* published product, RemovePreviousVersions set */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2915
    delete_pf_files();
2916

2917
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2918
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", res);
2919

2920
    create_database(msifile, up6_tables, ARRAY_SIZE(up6_tables));
2921 2922 2923 2924 2925

    /* published product, version number bumped */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2926
    delete_pf_files();
2927

2928
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2929
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", res);
2930

2931
    create_database(msifile, up7_tables, ARRAY_SIZE(up7_tables));
2932 2933 2934 2935 2936

    /* published product, RemovePreviousVersions set and version number bumped */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2937
    delete_pf_files();
2938

2939
    res = RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest", &hkey);
2940
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", res);
2941

2942
    r = MsiInstallProductA(msifile, "REMOVE=ALL FULL=1");
2943 2944
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2945
error:
2946
    delete_test_files();
2947
    DeleteFileA(msifile);
2948 2949
}

2950 2951
static void test_MsiSetComponentState(void)
{
2952
    INSTALLSTATE installed, action;
2953 2954 2955 2956
    MSIHANDLE package;
    char path[MAX_PATH];
    UINT r;

2957
    create_database(msifile, tables, ARRAY_SIZE(tables));
2958

2959 2960
    CoInitialize(NULL);

2961 2962 2963
    lstrcpyA(path, CURR_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, msifile);
2964

2965 2966
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

2967
    r = MsiOpenPackageA(path, &package);
2968 2969 2970 2971 2972
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
2973 2974
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2975
    r = MsiDoActionA(package, "CostInitialize");
2976
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2977

2978
    r = MsiDoActionA(package, "FileCost");
2979 2980
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2981
    r = MsiDoActionA(package, "CostFinalize");
2982 2983
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

2984
    r = MsiGetComponentStateA(package, "dangler", &installed, &action);
2985 2986 2987 2988
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
    ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);

2989
    r = MsiSetComponentStateA(package, "dangler", INSTALLSTATE_SOURCE);
2990
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2991 2992

    MsiCloseHandle(package);
2993

2994 2995
error:
    CoUninitialize();
2996
    DeleteFileA(msifile);
2997 2998
}

2999 3000 3001 3002
static void test_packagecoltypes(void)
{
    MSIHANDLE hdb, view, rec;
    char path[MAX_PATH];
3003
    WCHAR pathW[MAX_PATH];
3004
    LPCSTR query;
3005 3006
    UINT r, count;

3007
    create_database(msifile, tables, ARRAY_SIZE(tables));
3008

3009 3010
    CoInitialize(NULL);

3011 3012 3013
    lstrcpyA(path, CURR_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, msifile);
3014
    MultiByteToWideChar( CP_ACP, 0, path, -1, pathW, MAX_PATH );
3015

3016
    r = MsiOpenDatabaseW(pathW, MSIDBOPEN_READONLY, &hdb);
3017 3018 3019
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    query = "SELECT * FROM `Media`";
3020
    r = MsiDatabaseOpenViewA( hdb, query, &view );
3021
    ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
3022 3023 3024

    r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
    count = MsiRecordGetFieldCount( rec );
3025 3026 3027 3028 3029 3030 3031 3032
    ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
    ok(count == 6, "Expected 6, got %d\n", count);
    ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
    ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
    ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
    ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
    ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
    ok(check_record(rec, 6, "Source"), "wrong column label\n");
3033
    MsiCloseHandle(rec);
3034 3035 3036

    r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
    count = MsiRecordGetFieldCount( rec );
3037 3038
    ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
    ok(count == 6, "Expected 6, got %d\n", count);
3039 3040
    ok(check_record(rec, 1, "i2"), "wrong column label\n");
    ok(check_record(rec, 2, "i4"), "wrong column label\n");
3041
    ok(check_record(rec, 3, "L64"), "wrong column label\n");
3042 3043 3044
    ok(check_record(rec, 4, "S255"), "wrong column label\n");
    ok(check_record(rec, 5, "S32"), "wrong column label\n");
    ok(check_record(rec, 6, "S72"), "wrong column label\n");
3045

3046 3047
    MsiCloseHandle(rec);
    MsiCloseHandle(view);
3048
    MsiCloseHandle(hdb);
3049 3050
    CoUninitialize();

3051
    DeleteFileA(msifile);
3052 3053
}

3054 3055 3056 3057 3058
static void create_cc_test_files(void)
{
    CCAB cabParams;
    HFCI hfci;
    ERF erf;
3059
    static CHAR cab_context[] = "test%d.cab";
3060 3061
    BOOL res;

3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090
    create_file("maximus", 500);
    create_file("augustus", 50000);
    create_file("tiberius", 500);
    create_file("caesar", 500);

    set_cab_parameters(&cabParams, "test1.cab", 40000);

    hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
                      fci_read, fci_write, fci_close, fci_seek, fci_delete,
                      get_temp_file, &cabParams, cab_context);
    ok(hfci != NULL, "Failed to create an FCI context\n");

    res = add_file(hfci, "maximus", tcompTYPE_NONE);
    ok(res, "Failed to add file maximus\n");

    res = add_file(hfci, "augustus", tcompTYPE_NONE);
    ok(res, "Failed to add file augustus\n");

    res = add_file(hfci, "tiberius", tcompTYPE_NONE);
    ok(res, "Failed to add file tiberius\n");

    res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
    ok(res, "Failed to flush the cabinet\n");

    res = FCIDestroy(hfci);
    ok(res, "Failed to destroy the cabinet\n");

    create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");

3091 3092 3093 3094
    DeleteFileA("maximus");
    DeleteFileA("augustus");
    DeleteFileA("tiberius");
    DeleteFileA("caesar");
3095 3096
}

3097
void delete_cab_files(void)
3098
{
3099
    SHFILEOPSTRUCTA shfl;
3100
    CHAR path[MAX_PATH+10];
3101 3102

    lstrcpyA(path, CURR_DIR);
3103 3104
    lstrcatA(path, "\\*.cab");
    path[strlen(path) + 1] = '\0';
3105 3106 3107

    shfl.hwnd = NULL;
    shfl.wFunc = FO_DELETE;
3108
    shfl.pFrom = path;
3109 3110 3111
    shfl.pTo = NULL;
    shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;

3112
    SHFileOperationA(&shfl);
3113 3114
}

3115 3116 3117 3118
static void test_continuouscabs(void)
{
    UINT r;

3119 3120 3121 3122 3123 3124
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

3125
    create_cc_test_files();
3126
    create_database(msifile, cc_tables, ARRAY_SIZE(cc_tables));
3127

3128 3129
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

3130
    r = MsiInstallProductA(msifile, NULL);
3131 3132 3133
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
3134 3135
        goto error;
    }
3136 3137 3138 3139 3140 3141 3142 3143
    else
    {
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
        ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
        ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
        ok(delete_pf("msitest", FALSE), "Directory not created\n");
    }
3144

3145
    delete_cab_files();
3146
    DeleteFileA(msifile);
3147

3148
    create_cc_test_files();
3149
    create_database(msifile, cc2_tables, ARRAY_SIZE(cc2_tables));
3150 3151 3152 3153

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
3154 3155 3156 3157
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
    }
3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168
    else
    {
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
        ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
        ok(delete_pf("msitest\\tiberius", TRUE), "File not installed\n");
        ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
        ok(delete_pf("msitest", FALSE), "Directory not created\n");
    }

    delete_cab_files();
3169
    DeleteFileA(msifile);
3170 3171 3172 3173 3174

    /* Tests to show that only msi cab filename is taken in case of mismatch with the one given by previous cab */

    /* Filename from cab is right and the one from msi is wrong */
    create_cc_test_files();
3175
    create_database(msifile, cc3_tables, ARRAY_SIZE(cc3_tables));
3176 3177 3178 3179 3180 3181 3182 3183 3184 3185

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
    }
    else
    {
3186
        ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3187 3188 3189 3190 3191 3192 3193
        todo_wine ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
        ok(!delete_pf("msitest\\caesar", TRUE), "File installed\n");
        todo_wine ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
        todo_wine ok(!delete_pf("msitest", FALSE), "Directory created\n");
    }

    delete_cab_files();
3194
    DeleteFileA(msifile);
3195 3196 3197

    /* Filename from msi is right and the one from cab is wrong */
    create_cc_test_files();
3198
    ok(MoveFileA("test2.cab", "test2_.cab"), "Cannot rename test2.cab to test2_.cab\n");
3199
    create_database(msifile, cc3_tables, ARRAY_SIZE(cc3_tables));
3200 3201 3202 3203 3204 3205 3206 3207 3208 3209

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
    }
    else
    {
3210
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3211
        ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3212
        ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3213 3214 3215
        ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
        ok(delete_pf("msitest", FALSE), "Directory not created\n");
    }
3216

3217
error:
3218
    delete_cab_files();
3219
    DeleteFileA(msifile);
3220 3221
}

3222 3223 3224 3225 3226 3227 3228
static void test_caborder(void)
{
    UINT r;

    create_file("imperator", 100);
    create_file("maximus", 500);
    create_file("augustus", 50000);
3229
    create_file("caesar", 500);
3230

3231
    create_database(msifile, cc_tables, ARRAY_SIZE(cc_tables));
3232 3233 3234 3235 3236

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
    create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
3237
    create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
3238 3239

    r = MsiInstallProductA(msifile, NULL);
3240 3241 3242 3243 3244
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
3245 3246
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
    ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
3247
    ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
3248 3249
    todo_wine
    {
3250
        ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
3251
        ok(!delete_pf("msitest", FALSE), "Directory is created\n");
3252 3253
    }

3254
    delete_cab_files();
3255 3256 3257

    create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
    create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
3258
    create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
3259 3260

    r = MsiInstallProductA(msifile, NULL);
3261 3262 3263
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
    ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
    ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
3264
    ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
3265
    ok(!delete_pf("msitest", FALSE), "Directory is created\n");
3266

3267
    delete_cab_files();
3268
    DeleteFileA(msifile);
3269 3270

    create_cc_test_files();
3271
    create_database(msifile, co_tables, ARRAY_SIZE(co_tables));
3272 3273

    r = MsiInstallProductA(msifile, NULL);
3274
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3275
    ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
3276
    ok(!delete_pf("msitest", FALSE), "Directory is created\n");
3277 3278
    todo_wine
    {
3279
        ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
3280
        ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
3281
    }
3282

3283
    delete_cab_files();
3284
    DeleteFileA(msifile);
3285 3286

    create_cc_test_files();
3287
    create_database(msifile, co2_tables, ARRAY_SIZE(co2_tables));
3288 3289 3290

    r = MsiInstallProductA(msifile, NULL);
    ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
3291
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3292 3293
    todo_wine
    {
3294
        ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
3295
        ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
3296
        ok(!delete_pf("msitest", FALSE), "Directory is created\n");
3297 3298
    }

3299
error:
3300
    delete_cab_files();
3301 3302 3303 3304 3305
    DeleteFileA("imperator");
    DeleteFileA("maximus");
    DeleteFileA("augustus");
    DeleteFileA("caesar");
    DeleteFileA(msifile);
3306 3307
}

3308 3309 3310 3311
static void test_mixedmedia(void)
{
    UINT r;

3312 3313 3314 3315 3316 3317
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

3318 3319 3320 3321 3322
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);
    create_file("msitest\\augustus", 500);
    create_file("caesar", 500);

3323
    create_database(msifile, mm_tables, ARRAY_SIZE(mm_tables));
3324 3325 3326 3327 3328 3329

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");

    r = MsiInstallProductA(msifile, NULL);
3330 3331 3332 3333 3334
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
3335 3336 3337 3338
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3339
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3340

3341
error:
3342
    /* Delete the files in the temp (current) folder */
3343 3344 3345 3346 3347 3348
    DeleteFileA("msitest\\maximus");
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
    DeleteFileA("caesar");
    DeleteFileA("test1.cab");
    DeleteFileA(msifile);
3349 3350
}

3351 3352 3353 3354 3355
static void test_samesequence(void)
{
    UINT r;

    create_cc_test_files();
3356
    create_database(msifile, ss_tables, ARRAY_SIZE(ss_tables));
3357 3358 3359 3360

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
3361 3362 3363 3364 3365
    if (r == ERROR_INSTALL_FAILURE)
    {
        win_skip("unprivileged user?\n");
        goto error;
    }
3366
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3367 3368 3369 3370 3371 3372 3373
    if (r == ERROR_SUCCESS)
    {
        ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
        ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
        ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
        ok(delete_pf("msitest", FALSE), "Directory not created\n");
    }
3374 3375

error:
3376
    delete_cab_files();
3377
    DeleteFileA(msifile);
3378 3379
}

3380 3381 3382 3383 3384
static void test_uiLevelFlags(void)
{
    UINT r;

    create_cc_test_files();
3385
    create_database(msifile, ui_tables, ARRAY_SIZE(ui_tables));
3386 3387 3388 3389

    MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);

    r = MsiInstallProductA(msifile, NULL);
3390 3391 3392 3393 3394 3395
    if (r == ERROR_INSTALL_FAILURE)
    {
        win_skip("unprivileged user?\n");
        goto error;
    }

3396
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3397 3398 3399 3400 3401 3402 3403
    if (r == ERROR_SUCCESS)
    {
        ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
        ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
        ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
        ok(delete_pf("msitest", FALSE), "Directory not created\n");
    }
3404 3405

error:
3406
    delete_cab_files();
3407
    DeleteFileA(msifile);
3408 3409
}

3410 3411 3412 3413 3414 3415
static BOOL file_matches(LPSTR path)
{
    CHAR buf[MAX_PATH];
    HANDLE file;
    DWORD size;

3416 3417
    file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
                       NULL, OPEN_EXISTING, 0, NULL);
3418 3419 3420 3421
    ZeroMemory(buf, MAX_PATH);
    ReadFile(file, buf, 15, &size, NULL);
    CloseHandle(file);

3422
    return !lstrcmpA(buf, "msitest\\maximus");
3423 3424 3425 3426 3427 3428 3429 3430 3431
}

static void test_readonlyfile(void)
{
    UINT r;
    DWORD size;
    HANDLE file;
    CHAR path[MAX_PATH];

3432 3433 3434 3435 3436 3437
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

3438 3439
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);
3440
    create_database(msifile, rof_tables, ARRAY_SIZE(rof_tables));
3441 3442 3443

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

3444 3445 3446
    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\msitest");
    CreateDirectoryA(path, NULL);
3447

3448 3449 3450
    lstrcatA(path, "\\maximus");
    file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
                       NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
3451

3452
    WriteFile(file, "readonlyfile", strlen("readonlyfile"), &size, NULL);
3453 3454 3455
    CloseHandle(file);

    r = MsiInstallProductA(msifile, NULL);
3456 3457 3458 3459 3460
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
3461 3462 3463
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(file_matches(path), "Expected file to be overwritten\n");
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3464
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3465

3466
error:
3467
    /* Delete the files in the temp (current) folder */
3468 3469 3470
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
    DeleteFileA(msifile);
3471 3472
}

3473 3474 3475 3476 3477 3478 3479 3480
static void test_readonlyfile_cab(void)
{
    UINT r;
    DWORD size;
    HANDLE file;
    CHAR path[MAX_PATH];
    CHAR buf[16];

3481 3482 3483 3484 3485 3486
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

3487 3488 3489
    CreateDirectoryA("msitest", NULL);
    create_file("maximus", 500);
    create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
3490
    DeleteFileA("maximus");
3491

3492
    create_database(msifile, rofc_tables, ARRAY_SIZE(rofc_tables));
3493 3494 3495

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

3496 3497 3498
    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\msitest");
    CreateDirectoryA(path, NULL);
3499

3500 3501 3502
    lstrcatA(path, "\\maximus");
    file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
                       NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
3503 3504 3505 3506 3507

    WriteFile(file, "readonlyfile", strlen("readonlyfile"), &size, NULL);
    CloseHandle(file);

    r = MsiInstallProductA(msifile, NULL);
3508 3509 3510 3511 3512
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
3513 3514 3515
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    memset( buf, 0, sizeof(buf) );
3516 3517
    if ((file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
                            NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE)
3518 3519 3520 3521
    {
        ReadFile(file, buf, sizeof(buf) - 1, &size, NULL);
        CloseHandle(file);
    }
3522
    ok(!memcmp( buf, "maximus", sizeof("maximus")-1 ), "Expected file to be overwritten, got '%s'\n", buf);
3523
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3524
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3525

3526
error:
3527 3528
    /* Delete the files in the temp (current) folder */
    delete_cab_files();
3529 3530 3531
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
    DeleteFileA(msifile);
3532 3533
}

3534 3535 3536 3537
static void test_setdirproperty(void)
{
    UINT r;

3538 3539 3540 3541 3542 3543
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

3544 3545
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);
3546
    create_database(msifile, sdp_tables, ARRAY_SIZE(sdp_tables));
3547 3548 3549 3550

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
3551 3552 3553 3554 3555
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
3556
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3557
    ok(delete_cf("msitest\\maximus", TRUE), "File not installed\n");
3558
    ok(delete_cf("msitest", FALSE), "Directory not created\n");
3559

3560
error:
3561
    /* Delete the files in the temp (current) folder */
3562 3563 3564
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
3565 3566
}

3567 3568 3569 3570
static void test_cabisextracted(void)
{
    UINT r;

3571 3572 3573 3574 3575 3576
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

3577 3578 3579 3580 3581 3582 3583 3584 3585 3586
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\gaius", 500);
    create_file("maximus", 500);
    create_file("augustus", 500);
    create_file("caesar", 500);

    create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
    create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
    create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");

3587
    create_database(msifile, cie_tables, ARRAY_SIZE(cie_tables));
3588 3589 3590 3591

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
3592 3593 3594 3595 3596
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
3597 3598 3599 3600 3601
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
3602
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3603

3604
error:
3605
    /* Delete the files in the temp (current) folder */
3606
    delete_cab_files();
3607 3608 3609 3610 3611 3612
    DeleteFileA(msifile);
    DeleteFileA("maximus");
    DeleteFileA("augustus");
    DeleteFileA("caesar");
    DeleteFileA("msitest\\gaius");
    RemoveDirectoryA("msitest");
3613 3614
}

3615
BOOL file_exists(const char *file)
3616
{
3617
    return GetFileAttributesA(file) != INVALID_FILE_ATTRIBUTES;
3618 3619
}

3620
BOOL pf_exists(const char *file)
3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632
{
    CHAR path[MAX_PATH];

    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, file);

    return file_exists(path);
}

static void delete_pfmsitest_files(void)
{
3633
    SHFILEOPSTRUCTA shfl;
3634
    CHAR path[MAX_PATH+11];
3635 3636 3637 3638 3639 3640 3641 3642 3643

    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\msitest\\*");
    path[strlen(path) + 1] = '\0';

    shfl.hwnd = NULL;
    shfl.wFunc = FO_DELETE;
    shfl.pFrom = path;
    shfl.pTo = NULL;
3644
    shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT | FOF_NOERRORUI;
3645

3646
    SHFileOperationA(&shfl);
3647 3648 3649 3650 3651 3652

    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\msitest");
    RemoveDirectoryA(path);
}

3653
UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
3654
{
3655 3656
    MSIHANDLE hview = 0;
    UINT r;
3657

3658
    r = MsiDatabaseOpenViewA(hdb, query, &hview);
3659 3660
    if(r != ERROR_SUCCESS)
        return r;
3661

3662 3663 3664 3665 3666
    r = MsiViewExecute(hview, hrec);
    if(r == ERROR_SUCCESS)
        r = MsiViewClose(hview);
    MsiCloseHandle(hview);
    return r;
3667 3668
}

3669
static void set_transform_summary_info(void)
3670
{
3671 3672
    UINT r;
    MSIHANDLE suminfo = 0;
3673

3674
    /* build summary info */
3675
    r = MsiGetSummaryInformationA(0, mstfile, 3, &suminfo);
3676
    ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
3677

3678
    r = MsiSummaryInfoSetPropertyA(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
3679
    ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
3680

3681 3682 3683 3684
    r = MsiSummaryInfoSetPropertyA(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
                                   "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
                                   "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
                                   "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
3685
    ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
3686

3687
    r = MsiSummaryInfoSetPropertyA(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
3688
    ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
3689

3690 3691
    r = MsiSummaryInfoPersist(suminfo);
    ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
3692

3693 3694
    r = MsiCloseHandle(suminfo);
    ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
3695 3696
}

3697
static void generate_transform(void)
3698
{
3699 3700 3701
    MSIHANDLE hdb1, hdb2;
    LPCSTR query;
    UINT r;
3702

3703
    /* start with two identical databases */
3704
    CopyFileA(msifile, msifile2, FALSE);
3705

3706
    r = MsiOpenDatabaseW(msifile2W, MSIDBOPEN_TRANSACT, &hdb1);
3707
    ok(r == ERROR_SUCCESS , "Failed to create database\n");
3708

3709 3710
    r = MsiDatabaseCommit(hdb1);
    ok(r == ERROR_SUCCESS , "Failed to commit database\n");
3711

3712
    r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_READONLY, &hdb2);
3713
    ok(r == ERROR_SUCCESS , "Failed to create database\n");
3714

3715 3716 3717
    query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
    r = run_query(hdb1, 0, query);
    ok(r == ERROR_SUCCESS, "failed to add property\n");
3718

3719 3720
    /* database needs to be committed */
    MsiDatabaseCommit(hdb1);
3721

3722
    r = MsiDatabaseGenerateTransformA(hdb1, hdb2, mstfile, 0, 0);
3723
    ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
3724

3725
    r = MsiCreateTransformSummaryInfoA(hdb2, hdb2, mstfile, 0, 0);
3726
    todo_wine ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3727

3728 3729 3730
    MsiCloseHandle(hdb1);
    MsiCloseHandle(hdb2);
}
3731

3732
/* data for generating a transform */
3733

3734 3735 3736 3737
/* tables transform names - encoded as they would be in an msi database file */
static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
3738

3739 3740 3741
/* data in each table */
static const char data1[] = /* _StringData */
    "propval";  /* all the strings squashed together */
3742

3743 3744 3745 3746 3747 3748
static const WCHAR data2[] = { /* _StringPool */
/*  len, refs */
    0,   0,    /* string 0 ''     */
    4,   1,    /* string 1 'prop' */
    3,   1,    /* string 2 'val'  */
};
3749

3750 3751 3752
static const WCHAR data3[] = { /* Property */
    0x0201, 0x0001, 0x0002,
};
3753

3754 3755 3756 3757 3758
static const struct {
    LPCWSTR name;
    const void *data;
    DWORD size;
} table_transform_data[] =
3759
{
3760 3761 3762 3763
    { name1, data1, sizeof data1 - 1 },
    { name2, data2, sizeof data2 },
    { name3, data3, sizeof data3 },
};
3764

3765 3766 3767 3768 3769 3770 3771 3772
static void generate_transform_manual(void)
{
    IStorage *stg = NULL;
    IStream *stm;
    WCHAR name[0x20];
    HRESULT r;
    DWORD i, count;
    const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
3773

3774
    const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
3775

3776
    MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
3777

3778 3779 3780 3781
    r = StgCreateDocfile(name, mode, 0, &stg);
    ok(r == S_OK, "failed to create storage\n");
    if (!stg)
        return;
3782

3783 3784
    r = IStorage_SetClass(stg, &CLSID_MsiTransform);
    ok(r == S_OK, "failed to set storage type\n");
3785

3786
    for (i=0; i<ARRAY_SIZE(table_transform_data); i++)
3787
    {
3788 3789 3790 3791
        r = IStorage_CreateStream(stg, table_transform_data[i].name,
                            STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
        if (FAILED(r))
        {
3792
            ok(0, "failed to create stream %#lx\n", r);
3793 3794
            continue;
        }
3795

3796 3797 3798 3799 3800
        r = IStream_Write(stm, table_transform_data[i].data,
                          table_transform_data[i].size, &count);
        if (FAILED(r) || count != table_transform_data[i].size)
            ok(0, "failed to write stream\n");
        IStream_Release(stm);
3801 3802
    }

3803
    IStorage_Release(stg);
3804

3805 3806
    set_transform_summary_info();
}
3807

3808 3809 3810
static void test_transformprop(void)
{
    UINT r;
3811

3812
    if (is_process_limited())
3813
    {
3814 3815
        skip("process is limited\n");
        return;
3816 3817
    }

3818 3819
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\augustus", 500);
3820

3821
    create_database(msifile, tp_tables, ARRAY_SIZE(tp_tables));
3822

3823
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3824

3825 3826 3827 3828 3829 3830 3831 3832
    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3833
    ok(!delete_pf("msitest", FALSE), "Directory created\n");
3834

3835 3836 3837 3838
    if (0)
        generate_transform();
    else
        generate_transform_manual();
3839

3840 3841 3842
    r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3843
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3844

3845 3846
error:
    /* Delete the files in the temp (current) folder */
3847 3848 3849 3850 3851
    DeleteFileA(msifile);
    DeleteFileA(msifile2);
    DeleteFileA(mstfile);
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
3852
}
3853

3854 3855 3856
static void test_currentworkingdir(void)
{
    UINT r;
3857
    CHAR drive[MAX_PATH], path[MAX_PATH + 12];
3858
    LPSTR ptr;
3859

3860
    if (is_process_limited())
3861
    {
3862 3863
        skip("process is limited\n");
        return;
3864 3865
    }

3866 3867
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\augustus", 500);
3868

3869
    create_database(msifile, cwd_tables, ARRAY_SIZE(cwd_tables));
3870

3871 3872 3873 3874
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    CreateDirectoryA("diffdir", NULL);
    SetCurrentDirectoryA("diffdir");
3875

3876 3877
    sprintf(path, "..\\%s", msifile);
    r = MsiInstallProductA(path, NULL);
3878 3879
    todo_wine
    {
3880 3881
        ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
        ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3882
        ok(!delete_pf("msitest", FALSE), "Directory created\n");
3883 3884
    }

3885 3886 3887
    sprintf(path, "%s\\%s", CURR_DIR, msifile);
    r = MsiInstallProductA(path, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3888
    {
3889 3890
        skip("Not enough rights to perform tests\n");
        goto error;
3891
    }
3892 3893
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3894
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3895

3896 3897 3898 3899
    lstrcpyA(drive, CURR_DIR);
    drive[2] = '\\';
    drive[3] = '\0';
    SetCurrentDirectoryA(drive);
3900

3901 3902
    lstrcpyA(path, CURR_DIR);
    if (path[lstrlenA(path) - 1] != '\\') lstrcatA(path, "\\");
3903 3904 3905
    lstrcatA(path, msifile);
    ptr = strchr(path, ':');
    ptr +=2;
3906

3907 3908 3909
    r = MsiInstallProductA(ptr, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3910
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3911

3912
error:
3913
    SetCurrentDirectoryA(CURR_DIR);
3914 3915 3916 3917
    DeleteFileA(msifile);
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
    RemoveDirectoryA("diffdir");
3918 3919
}

3920
static void set_admin_summary_info(const WCHAR *name)
3921
{
3922
    MSIHANDLE db, summary;
3923 3924
    UINT r;

3925
    r = MsiOpenDatabaseW(name, MSIDBOPEN_DIRECT, &db);
3926
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3927

3928 3929
    r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3930

3931 3932
    r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3933

3934 3935 3936
    /* write the summary changes back to the stream */
    r = MsiSummaryInfoPersist(summary);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3937

3938
    MsiCloseHandle(summary);
3939

3940 3941
    r = MsiDatabaseCommit(db);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3942

3943 3944
    MsiCloseHandle(db);
}
3945

3946 3947 3948
static void test_admin(void)
{
    UINT r;
3949

3950 3951 3952
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\augustus", 500);

3953
    create_database(msifile, adm_tables, ARRAY_SIZE(adm_tables));
3954
    set_admin_summary_info(msifileW);
3955 3956 3957 3958

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
3959 3960 3961 3962 3963
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
3964 3965
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3966
    ok(!delete_pf("msitest", FALSE), "Directory created\n");
3967 3968
    ok(!DeleteFileA("c:\\msitest\\augustus"), "File installed\n");
    ok(!RemoveDirectoryA("c:\\msitest"), "File installed\n");
3969

3970
    r = MsiInstallProductA(msifile, "ACTION=ADMIN");
3971
    todo_wine
3972 3973
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3974
    ok(!delete_pf("msitest", FALSE), "Directory created\n");
3975 3976
    todo_wine
    {
3977 3978
        ok(DeleteFileA("c:\\msitest\\augustus"), "File not installed\n");
        ok(RemoveDirectoryA("c:\\msitest"), "File not installed\n");
3979
    }
3980

3981
error:
3982 3983 3984
    DeleteFileA(msifile);
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
3985
}
3986

3987 3988 3989 3990 3991 3992 3993 3994
static void set_admin_property_stream(LPCSTR file)
{
    IStorage *stg;
    IStream *stm;
    WCHAR fileW[MAX_PATH];
    HRESULT hr;
    DWORD count;
    const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
3995

3996
    MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
3997

3998
    hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
3999
    ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
4000 4001
    if (!stg)
        return;
4002

4003 4004
    hr = IStorage_CreateStream(stg, L"\x41ca\x4330\x3e71\x44b5\x4233\x45f5\x422c\x4836",
                               STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
4005
    ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
4006

4007
    hr = IStream_Write(stm, L"MYPROP=2718 MyProp=42", sizeof(L"MYPROP=2718 MyProp=42"), &count);
4008
    ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
4009

4010 4011 4012
    IStream_Release(stm);
    IStorage_Release(stg);
}
4013

4014 4015 4016
static void test_adminprops(void)
{
    UINT r;
4017

4018
    if (is_process_limited())
4019
    {
4020 4021
        skip("process is limited\n");
        return;
4022 4023
    }

4024 4025
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\augustus", 500);
4026

4027
    create_database(msifile, amp_tables, ARRAY_SIZE(amp_tables));
4028
    set_admin_summary_info(msifileW);
4029
    set_admin_property_stream(msifile);
4030

4031
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4032

4033 4034 4035 4036 4037 4038 4039 4040
    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
4041
    ok(delete_pf("msitest", FALSE), "Directory created\n");
4042

4043
error:
4044 4045 4046
    DeleteFileA(msifile);
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
4047
}
4048

4049
void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file)
4050
{
4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063
    CHAR path[MAX_PATH];

    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, file);

    if (is_file)
        create_file_data(path, data, 500);
    else
        CreateDirectoryA(path, NULL);
}

#define create_pf(file, is_file) create_pf_data(file, file, is_file)
4064

4065 4066 4067
static void test_missingcab(void)
{
    UINT r;
4068

4069 4070 4071 4072 4073 4074
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

4075
    CreateDirectoryA("msitest", NULL);
4076 4077
    create_file("msitest\\augustus", 500);
    create_file("maximus", 500);
4078
    create_file("tiberius", 500);
4079

4080
    create_database(msifile, mc_tables, ARRAY_SIZE(mc_tables));
4081

4082
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4083

4084
    create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4085
    create_cab_file("test4.cab", MEDIA_SIZE, "tiberius\0");
4086

4087 4088
    create_pf("msitest", FALSE);
    create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
4089
    create_pf_data("msitest\\tiberius", "abcdefgh", TRUE);
4090

4091
    r = MsiInstallProductA(msifile, NULL);
4092 4093 4094 4095 4096
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
4097 4098 4099
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4100
    ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4101 4102
    ok(compare_pf_data("msitest\\tiberius", "abcdefgh", sizeof("abcdefgh")), "Wrong file contents\n");
    ok(delete_pf("msitest\\tiberius", TRUE), "File not installed\n");
4103
    ok(!delete_pf("msitest\\gaius", TRUE), "File installed\n");
4104
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
4105

4106 4107
    create_pf("msitest", FALSE);
    create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
4108
    create_pf_data("msitest\\tiberius", "abcdefgh", TRUE);
4109
    create_pf("msitest\\gaius", TRUE);
4110

4111 4112 4113 4114 4115 4116 4117 4118
    r = MsiInstallProductA(msifile, "GAIUS=1");
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
    todo_wine
    {
        ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
        ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
    }
    ok(delete_pf("msitest\\caesar", TRUE), "File removed\n");
4119 4120
    ok(compare_pf_data("msitest\\tiberius", "abcdefgh", sizeof("abcdefgh")), "Wrong file contents\n");
    ok(delete_pf("msitest\\tiberius", TRUE), "File removed\n");
4121
    ok(delete_pf("msitest\\gaius", TRUE), "File removed\n");
4122
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
4123

4124
error:
4125
    delete_pf("msitest", FALSE);
4126 4127 4128 4129 4130 4131 4132
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
    DeleteFileA("maximus");
    DeleteFileA("tiberius");
    DeleteFileA("test1.cab");
    DeleteFileA("test4.cab");
    DeleteFileA(msifile);
4133 4134
}

4135
static void test_sourcefolder(void)
4136
{
4137
    UINT r;
4138

4139 4140 4141 4142 4143
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }
4144

4145 4146
    CreateDirectoryA("msitest", NULL);
    create_file("augustus", 500);
4147

4148
    create_database(msifile, sf_tables, ARRAY_SIZE(sf_tables));
4149

4150
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4151

4152 4153
    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4154
    {
4155 4156
        skip("Not enough rights to perform tests\n");
        goto error;
4157
    }
4158 4159 4160 4161
    ok(r == ERROR_INSTALL_FAILURE,
       "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
    ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
    todo_wine
4162
    {
4163
        ok(!delete_pf("msitest", FALSE), "Directory created\n");
4164
    }
4165 4166 4167 4168 4169 4170 4171
    RemoveDirectoryA("msitest");

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_INSTALL_FAILURE,
       "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
    ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
    todo_wine
4172
    {
4173
        ok(!delete_pf("msitest", FALSE), "Directory created\n");
4174
    }
4175 4176

error:
4177 4178
    DeleteFileA(msifile);
    DeleteFileA("augustus");
4179 4180
}

4181 4182
static void test_customaction1(void)
{
4183
    MSIHANDLE hdb, record;
4184 4185
    UINT r;

4186
    create_test_files();
4187
    create_database(msifile, ca1_tables, ARRAY_SIZE(ca1_tables));
4188

4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201
    /* create a test table */
    MsiOpenDatabaseW(msifileW, MSIDBOPEN_TRANSACT, &hdb);
    run_query(hdb, 0, "CREATE TABLE `Test` (`Name` CHAR(10), `Number` INTEGER, `Data` OBJECT PRIMARY KEY `Name`)");
    create_file("unus", 10);
    create_file("duo", 10);
    record = MsiCreateRecord(1);
    MsiRecordSetStreamA(record, 1, "unus");
    run_query(hdb, record, "INSERT INTO `Test` (`Name`, `Number`, `Data`) VALUES ('one', 1, ?)");
    MsiRecordSetStreamA(record, 1, "duo");
    run_query(hdb, record, "INSERT INTO `Test` (`Name`, `Number`, `Data`) VALUES ('two', 2, ?)");
    MsiDatabaseCommit(hdb);
    MsiCloseHandle(hdb);

4202 4203
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

4204 4205 4206 4207
    r = MsiInstallProductA(msifile, "MAIN_TEST=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    /* Test return values */
4208 4209 4210
    r = MsiInstallProductA(msifile, "TEST_RETVAL=0");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

4211
    r = MsiInstallProductA(msifile, "TEST_RETVAL=1626"); /* ERROR_FUNCTION_NOT_CALLED */
4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    r = MsiInstallProductA(msifile, "TEST_RETVAL=1602");
    ok(r == ERROR_INSTALL_USEREXIT, "Expected ERROR_INSTALL_USEREXIT, got %u\n", r);

    r = MsiInstallProductA(msifile, "TEST_RETVAL=259"); /* ERROR_NO_MORE_ITEMS */
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    /* any other error maps to ERROR_INSTALL_FAILURE */
    r = MsiInstallProductA(msifile, "TEST_RETVAL=1");
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);

4224 4225 4226 4227
    /* Custom actions execute in the same process, but they don't retain state */
    r = MsiInstallProductA(msifile, "TEST_PROCESS=1");
    ok(!r, "got %u\n", r);

4228 4229 4230 4231
    /* test asynchronous actions (msidbCustomActionTypeAsync) */
    r = MsiInstallProductA(msifile, "TEST_ASYNC=1");
    ok(!r, "got %u\n", r);

4232
    delete_test_files();
4233
    DeleteFileA(msifile);
4234 4235
    DeleteFileA("unus");
    DeleteFileA("duo");
4236 4237
}

4238
static void test_customaction51(void)
4239 4240 4241
{
    UINT r;

4242 4243 4244 4245 4246 4247
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

4248
    CreateDirectoryA("msitest", NULL);
4249
    create_file("msitest\\augustus", 500);
4250

4251
    create_database(msifile, ca51_tables, ARRAY_SIZE(ca51_tables));
4252

4253
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4254

4255
    r = MsiInstallProductA(msifile, NULL);
4256 4257 4258 4259 4260
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
4261 4262
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
4263
    ok(delete_pf("msitest", FALSE), "Directory created\n");
4264

4265
error:
4266 4267 4268
    DeleteFileA(msifile);
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
4269 4270
}

4271
static void test_installstate(void)
4272 4273 4274
{
    UINT r;

4275 4276 4277 4278 4279 4280
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

4281
    CreateDirectoryA("msitest", NULL);
4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293
    create_file("msitest\\alpha", 500);
    create_file("msitest\\beta", 500);
    create_file("msitest\\gamma", 500);
    create_file("msitest\\theta", 500);
    create_file("msitest\\delta", 500);
    create_file("msitest\\epsilon", 500);
    create_file("msitest\\zeta", 500);
    create_file("msitest\\iota", 500);
    create_file("msitest\\eta", 500);
    create_file("msitest\\kappa", 500);
    create_file("msitest\\lambda", 500);
    create_file("msitest\\mu", 500);
4294

4295
    create_database(msifile, is_tables, ARRAY_SIZE(is_tables));
4296

4297
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4298

4299
    r = MsiInstallProductA(msifile, NULL);
4300 4301 4302 4303 4304
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
    ok(delete_pf("msitest\\gamma", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\zeta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
4318
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
4319

4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333
    r = MsiInstallProductA(msifile, "ADDLOCAL=\"one,two,three,four\"");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
    ok(delete_pf("msitest\\gamma", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
    ok(delete_pf("msitest\\epsilon", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\zeta", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
    ok(delete_pf("msitest\\eta", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
4334
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
4335

4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349
    r = MsiInstallProductA(msifile, "ADDSOURCE=\"one,two,three,four\"");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\gamma", TRUE), "File installed\n");
    ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
    ok(delete_pf("msitest\\zeta", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
4350
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
4351

4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365
    r = MsiInstallProductA(msifile, "REMOVE=\"one,two,three,four\"");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!delete_pf("msitest\\alpha", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\gamma", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\theta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\zeta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
4366
    ok(!delete_pf("msitest", FALSE), "Directory created\n");
4367

4368
error:
4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382
    DeleteFileA(msifile);
    DeleteFileA("msitest\\alpha");
    DeleteFileA("msitest\\beta");
    DeleteFileA("msitest\\gamma");
    DeleteFileA("msitest\\theta");
    DeleteFileA("msitest\\delta");
    DeleteFileA("msitest\\epsilon");
    DeleteFileA("msitest\\zeta");
    DeleteFileA("msitest\\iota");
    DeleteFileA("msitest\\eta");
    DeleteFileA("msitest\\kappa");
    DeleteFileA("msitest\\lambda");
    DeleteFileA("msitest\\mu");
    RemoveDirectoryA("msitest");
4383 4384
}

4385
static const struct sourcepathmap
4386
{
4387 4388 4389 4390 4391 4392 4393 4394 4395
    BOOL sost; /* shortone\shorttwo */
    BOOL solt; /* shortone\longtwo */
    BOOL lost; /* longone\shorttwo */
    BOOL lolt; /* longone\longtwo */
    BOOL soste; /* shortone\shorttwo source exists */
    BOOL solte; /* shortone\longtwo source exists */
    BOOL loste; /* longone\shorttwo source exists */
    BOOL lolte; /* longone\longtwo source exists */
    UINT err;
4396
    DWORD size;
4397
} spmap[256] =
4398
{
4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655
    {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
    {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
    {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
};
4656

4657
static DWORD get_pf_file_size(LPCSTR file)
4658
{
4659 4660
    CHAR path[MAX_PATH];
    HANDLE hfile;
4661
    DWORD size;
4662

4663 4664 4665
    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, file);
4666

4667 4668 4669
    hfile = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    if (hfile == INVALID_HANDLE_VALUE)
        return INVALID_FILE_SIZE;
4670

4671 4672 4673
    size = GetFileSize(hfile, NULL);
    CloseHandle(hfile);
    return size;
4674
}
4675

4676
static void test_sourcepath(void)
4677
{
4678
    UINT r, i;
4679

4680 4681 4682
    if (!winetest_interactive)
    {
        skip("Run in interactive mode to run source path tests.\n");
4683 4684 4685
        return;
    }

4686
    create_database(msifile, sp_tables, ARRAY_SIZE(sp_tables));
4687

4688
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4689

4690
    for (i = 0; i < ARRAY_SIZE(spmap); i++)
4691 4692 4693 4694 4695 4696
    {
        if (spmap[i].sost)
        {
            CreateDirectoryA("shortone", NULL);
            CreateDirectoryA("shortone\\shorttwo", NULL);
        }
4697

4698 4699 4700 4701 4702
        if (spmap[i].solt)
        {
            CreateDirectoryA("shortone", NULL);
            CreateDirectoryA("shortone\\longtwo", NULL);
        }
4703

4704 4705 4706 4707 4708
        if (spmap[i].lost)
        {
            CreateDirectoryA("longone", NULL);
            CreateDirectoryA("longone\\shorttwo", NULL);
        }
4709

4710 4711 4712 4713 4714
        if (spmap[i].lolt)
        {
            CreateDirectoryA("longone", NULL);
            CreateDirectoryA("longone\\longtwo", NULL);
        }
4715

4716 4717 4718 4719 4720 4721 4722 4723
        if (spmap[i].soste)
            create_file("shortone\\shorttwo\\augustus", 50);
        if (spmap[i].solte)
            create_file("shortone\\longtwo\\augustus", 100);
        if (spmap[i].loste)
            create_file("longone\\shorttwo\\augustus", 150);
        if (spmap[i].lolte)
            create_file("longone\\longtwo\\augustus", 200);
4724

4725 4726 4727
        r = MsiInstallProductA(msifile, NULL);
        ok(r == spmap[i].err, "%d: Expected %d, got %d\n", i, spmap[i].err, r);
        ok(get_pf_file_size("msitest\\augustus") == spmap[i].size,
4728
           "%u: Expected %lu, got %lu\n", i, spmap[i].size,
4729
           get_pf_file_size("msitest\\augustus"));
4730

4731 4732 4733
        if (r == ERROR_SUCCESS)
        {
            ok(delete_pf("msitest\\augustus", TRUE), "%d: File not installed\n", i);
4734
            ok(delete_pf("msitest", FALSE), "%d: Directory not created\n", i);
4735 4736 4737 4738
        }
        else
        {
            ok(!delete_pf("msitest\\augustus", TRUE), "%d: File installed\n", i);
4739
            todo_wine ok(!delete_pf("msitest", FALSE), "%d: Directory installed\n", i);
4740
        }
4741

4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752
        DeleteFileA("shortone\\shorttwo\\augustus");
        DeleteFileA("shortone\\longtwo\\augustus");
        DeleteFileA("longone\\shorttwo\\augustus");
        DeleteFileA("longone\\longtwo\\augustus");
        RemoveDirectoryA("shortone\\shorttwo");
        RemoveDirectoryA("shortone\\longtwo");
        RemoveDirectoryA("longone\\shorttwo");
        RemoveDirectoryA("longone\\longtwo");
        RemoveDirectoryA("shortone");
        RemoveDirectoryA("longone");
    }
4753

4754
    DeleteFileA(msifile);
4755 4756
}

4757
static void test_missingcomponent(void)
4758 4759 4760
{
    UINT r;

4761 4762 4763 4764 4765 4766
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

4767 4768 4769 4770 4771 4772
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\hydrogen", 500);
    create_file("msitest\\helium", 500);
    create_file("msitest\\lithium", 500);
    create_file("beryllium", 500);

4773
    create_database(msifile, mcp_tables, ARRAY_SIZE(mcp_tables));
4774 4775 4776

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

4777
    r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42");
4778 4779 4780 4781 4782
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
4783 4784 4785 4786 4787
    else if (r == ERROR_INSTALL_FAILURE)
    {
        win_skip("broken result\n");
        goto error;
    }
4788
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4789 4790 4791 4792 4793
    ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
    ok(pf_exists("msitest\\helium"), "File not installed\n");
    ok(pf_exists("msitest\\lithium"), "File not installed\n");
    ok(!pf_exists("msitest\\beryllium"), "File installed\n");
    ok(pf_exists("msitest"), "File not installed\n");
4794

4795 4796 4797 4798 4799 4800 4801
    r = MsiInstallProductA(msifile, "REMOVE=ALL INSTALLLEVEL=10 PROPVAR=42");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
    ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
    ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
    ok(!pf_exists("msitest\\beryllium"), "File installed\n");
    ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
4802

4803
error:
4804 4805 4806 4807 4808 4809
    DeleteFileA(msifile);
    DeleteFileA("msitest\\hydrogen");
    DeleteFileA("msitest\\helium");
    DeleteFileA("msitest\\lithium");
    DeleteFileA("beryllium");
    RemoveDirectoryA("msitest");
4810 4811
}

4812
static void test_sourcedirprop(void)
4813 4814
{
    UINT r;
4815
    CHAR props[MAX_PATH + 18];
4816

4817 4818 4819 4820 4821 4822
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

4823 4824
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\augustus", 500);
4825

4826
    create_database(msifile, ca51_tables, ARRAY_SIZE(ca51_tables));
4827

4828 4829 4830
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
4831 4832 4833 4834 4835
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
4836
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4837
    ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
4838
    ok(delete_pf("msitest", FALSE), "Directory created\n");
4839

4840 4841
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
4842

4843 4844 4845
    CreateDirectoryA("altsource", NULL);
    CreateDirectoryA("altsource\\msitest", NULL);
    create_file("altsource\\msitest\\augustus", 500);
4846

4847
    sprintf(props, "SRCDIR=%s\\altsource\\", CURR_DIR);
4848

4849 4850 4851
    r = MsiInstallProductA(msifile, props);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
4852
    ok(delete_pf("msitest", FALSE), "Directory created\n");
4853

4854 4855 4856
    DeleteFileA("altsource\\msitest\\augustus");
    RemoveDirectoryA("altsource\\msitest");
    RemoveDirectoryA("altsource");
4857 4858

error:
4859 4860 4861
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
    DeleteFileA(msifile);
4862 4863
}

4864
static void test_adminimage(void)
4865 4866 4867
{
    UINT r;

4868 4869 4870 4871 4872 4873
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885
    CreateDirectoryA("msitest", NULL);
    CreateDirectoryA("msitest\\first", NULL);
    CreateDirectoryA("msitest\\second", NULL);
    CreateDirectoryA("msitest\\cabout", NULL);
    CreateDirectoryA("msitest\\cabout\\new", NULL);
    create_file("msitest\\one.txt", 100);
    create_file("msitest\\first\\two.txt", 100);
    create_file("msitest\\second\\three.txt", 100);
    create_file("msitest\\cabout\\four.txt", 100);
    create_file("msitest\\cabout\\new\\five.txt", 100);
    create_file("msitest\\filename", 100);

4886
    create_database_wordcount(msifile, ai_tables, ARRAY_SIZE(ai_tables),
4887 4888
                              100, msidbSumInfoSourceTypeAdminImage, ";1033",
                              "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}");
4889 4890 4891 4892

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
4893 4894 4895 4896 4897
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
4898 4899
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

4900
    delete_pf_files();
4901

4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919
    create_file("four.txt", 100);
    create_file("five.txt", 100);
    create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
    create_database_wordcount(msifile, ai2_tables, ARRAY_SIZE(ai2_tables),
                              100, msidbSumInfoSourceTypeAdminImage|msidbSumInfoSourceTypeCompressed,
                              ";1033", "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}");

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
    ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
    ok(delete_pf("msitest", FALSE), "Directory not created\n");

4920
error:
4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932
    DeleteFileA("msifile");
    DeleteFileA("msitest\\cabout\\new\\five.txt");
    DeleteFileA("msitest\\cabout\\four.txt");
    DeleteFileA("msitest\\second\\three.txt");
    DeleteFileA("msitest\\first\\two.txt");
    DeleteFileA("msitest\\one.txt");
    DeleteFileA("msitest\\filename");
    RemoveDirectoryA("msitest\\cabout\\new");
    RemoveDirectoryA("msitest\\cabout");
    RemoveDirectoryA("msitest\\second");
    RemoveDirectoryA("msitest\\first");
    RemoveDirectoryA("msitest");
4933 4934
}

4935
static void test_propcase(void)
4936 4937 4938
{
    UINT r;

4939 4940 4941 4942 4943 4944
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

4945 4946 4947
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\augustus", 500);

4948
    create_database(msifile, pc_tables, ARRAY_SIZE(pc_tables));
4949 4950 4951

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

4952
    r = MsiInstallProductA(msifile, "MyProp=42");
4953 4954 4955 4956 4957
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
4958
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4959
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4960
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
4961

4962 4963 4964 4965 4966 4967
    r = MsiInstallProductA(msifile, "Prop1=\"Copyright \"\"My Company\"\" 2015\" MyProp=42");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
    ok(delete_pf("msitest", FALSE), "Directory not created\n");

    r = MsiInstallProductA(msifile, "Prop1=\"\"\"install.exe\"\" /Install\" MyProp=\"42\"");
4968 4969 4970 4971
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
    ok(delete_pf("msitest", FALSE), "Directory not created\n");

4972
error:
4973 4974 4975
    DeleteFileA(msifile);
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("msitest");
4976 4977
}

4978
static void test_int_widths( void )
4979
{
4980 4981 4982 4983 4984 4985 4986 4987
    static const char int0[] = "int0\ni0\nint0\tint0\n1";
    static const char int1[] = "int1\ni1\nint1\tint1\n1";
    static const char int2[] = "int2\ni2\nint2\tint2\n1";
    static const char int3[] = "int3\ni3\nint3\tint3\n1";
    static const char int4[] = "int4\ni4\nint4\tint4\n1";
    static const char int5[] = "int5\ni5\nint5\tint5\n1";
    static const char int8[] = "int8\ni8\nint8\tint8\n1";
    static const struct
4988
    {
4989 4990 4991
        const char  *data;
        unsigned int size;
        UINT         ret;
4992
    }
4993 4994 4995 4996 4997 4998 4999 5000 5001 5002
    tests[] =
    {
        { int0, sizeof(int0) - 1, ERROR_SUCCESS },
        { int1, sizeof(int1) - 1, ERROR_SUCCESS },
        { int2, sizeof(int2) - 1, ERROR_SUCCESS },
        { int3, sizeof(int3) - 1, ERROR_FUNCTION_FAILED },
        { int4, sizeof(int4) - 1, ERROR_SUCCESS },
        { int5, sizeof(int5) - 1, ERROR_FUNCTION_FAILED },
        { int8, sizeof(int8) - 1, ERROR_FUNCTION_FAILED }
    };
5003
    WCHAR tmpdir[MAX_PATH], msitable[MAX_PATH], msidb[MAX_PATH];
5004 5005
    MSIHANDLE db;
    UINT r, i;
5006

5007 5008
    GetTempPathW(MAX_PATH, tmpdir);
    CreateDirectoryW(tmpdir, NULL);
5009

5010
    lstrcpyW(msitable, tmpdir);
5011
    lstrcatW(msitable, L"\\msitable.idt");
5012

5013
    lstrcpyW(msidb, tmpdir);
5014
    lstrcatW(msidb, L"\\msitest.msi");
5015

5016
    r = MsiOpenDatabaseW(msidb, MSIDBOPEN_CREATE, &db);
5017 5018
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5019
    for (i = 0; i < ARRAY_SIZE(tests); i++)
5020
    {
5021
        DWORD count;
5022
        HANDLE handle = CreateFileW(msitable, GENERIC_WRITE, 0, NULL,
5023 5024 5025
                                    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
        WriteFile(handle, tests[i].data, tests[i].size, &count, NULL);
        CloseHandle(handle);
5026

5027
        r = MsiDatabaseImportW(db, tmpdir, L"msitable.idt");
5028 5029 5030 5031
        ok(r == tests[i].ret, " %u expected %u, got %u\n", i, tests[i].ret, r);

        r = MsiDatabaseCommit(db);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5032
        DeleteFileW(msitable);
5033 5034 5035
    }

    MsiCloseHandle(db);
5036 5037
    DeleteFileW(msidb);
    RemoveDirectoryW(tmpdir);
5038 5039
}

5040
static void test_shortcut(void)
5041 5042
{
    UINT r;
5043
    HRESULT hr;
5044

5045 5046 5047 5048 5049 5050
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

5051
    create_test_files();
5052
    create_database(msifile, sc_tables, ARRAY_SIZE(sc_tables));
5053 5054 5055 5056

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
5057 5058 5059 5060 5061
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5062 5063
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5064
    hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
5065
    ok(SUCCEEDED(hr), "CoInitialize failed %#lx\n", hr);
5066

5067 5068 5069 5070 5071 5072
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    CoUninitialize();

    hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
5073
    ok(SUCCEEDED(hr), "CoInitialize failed %#lx\n", hr);
5074 5075

    r = MsiInstallProductA(msifile, NULL);
5076 5077
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5078 5079
    CoUninitialize();

5080
    while (!delete_pf("msitest\\Shortcut.lnk", TRUE) && GetLastError() == ERROR_SHARING_VIOLATION) Sleep(1000);
5081
    delete_pf_files();
5082

5083
error:
5084
    delete_test_files();
5085
    DeleteFileA(msifile);
5086 5087
}

5088
static void test_preselected(void)
5089 5090 5091
{
    UINT r;

5092 5093 5094 5095 5096 5097
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

5098
    create_test_files();
5099
    create_database(msifile, ps_tables, ARRAY_SIZE(ps_tables));
5100 5101 5102

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

5103
    r = MsiInstallProductA(msifile, "ADDLOCAL=One");
5104 5105 5106 5107 5108
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5109 5110
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5111
    ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
5112
    ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
5113
    ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
5114
    ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
5115
    ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
5116
    ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
5117
    ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
5118
    ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
5119 5120
    ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
    ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
5121
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
5122

5123
    r = MsiInstallProductA(msifile, NULL);
5124 5125
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5126
    ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
5127
    ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
5128
    ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
5129
    ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
5130
    ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
5131
    ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
5132
    ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
5133
    ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
5134 5135
    ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
5136
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
5137

5138
error:
5139
    delete_test_files();
5140
    DeleteFileA(msifile);
5141 5142
}

5143
static void test_installed_prop(void)
5144
{
5145
    static const char prodcode[] = "{7df88a48-996f-4ec8-a022-bf956f9b2cbb}";
5146 5147
    UINT r;

5148 5149 5150 5151 5152 5153
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

5154
    create_test_files();
5155
    create_database(msifile, ip_tables, ARRAY_SIZE(ip_tables));
5156 5157 5158

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

5159
    r = MsiInstallProductA(msifile, "FULL=1");
5160 5161 5162 5163 5164
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5165 5166
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5167 5168 5169 5170 5171 5172
    r = MsiInstallProductA(msifile, "FULL=1");
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);

    r = MsiConfigureProductExA(prodcode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, "FULL=1");
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);

5173
    delete_pf_files();
5174 5175 5176 5177

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5178
error:
5179
    delete_test_files();
5180
    DeleteFileA(msifile);
5181 5182
}

5183
static void test_allusers_prop(void)
5184 5185 5186
{
    UINT r;

5187 5188 5189 5190 5191 5192
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

5193
    create_test_files();
5194
    create_database(msifile, aup_tables, ARRAY_SIZE(aup_tables));
5195

5196 5197
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

5198 5199
    /* ALLUSERS property unset */
    r = MsiInstallProductA(msifile, "FULL=1");
5200 5201 5202 5203 5204
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5205 5206
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5207
    delete_pf_files();
5208 5209 5210 5211 5212

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    delete_test_files();
5213

5214
    create_test_files();
5215
    create_database(msifile, aup2_tables, ARRAY_SIZE(aup2_tables));
5216

5217 5218 5219 5220
    /* ALLUSERS property set to 1 */
    r = MsiInstallProductA(msifile, "FULL=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5221
    delete_pf_files();
5222 5223 5224 5225

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5226
    delete_test_files();
5227

5228
    create_test_files();
5229
    create_database(msifile, aup3_tables, ARRAY_SIZE(aup3_tables));
5230

5231 5232 5233
    /* ALLUSERS property set to 2 */
    r = MsiInstallProductA(msifile, "FULL=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5234

5235
    delete_pf_files();
5236 5237 5238 5239 5240 5241 5242

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    delete_test_files();

    create_test_files();
5243
    create_database(msifile, aup4_tables, ARRAY_SIZE(aup4_tables));
5244 5245 5246

    /* ALLUSERS property set to 2, conditioned on ALLUSERS = 1 */
    r = MsiInstallProductA(msifile, "FULL=1");
5247
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
5248

5249
error:
5250
    delete_test_files();
5251
    DeleteFileA(msifile);
5252 5253
}

5254 5255
static const char session_manager[] = "System\\CurrentControlSet\\Control\\Session Manager";
static const char rename_ops[]      = "PendingFileRenameOperations";
5256 5257

static void process_pending_renames(HKEY hkey)
5258
{
5259 5260 5261 5262
    char *buf, *src, *dst, *buf2, *buf2ptr;
    DWORD size;
    LONG ret;
    BOOL found = FALSE;
5263

5264
    ret = RegQueryValueExA(hkey, rename_ops, NULL, NULL, NULL, &size);
5265
    ok(!ret, "RegQueryValueExA failed %ld\n", ret);
5266

5267 5268
    buf = malloc(size + 1);
    buf2ptr = buf2 = calloc(1, size + 1);
5269 5270 5271

    ret = RegQueryValueExA(hkey, rename_ops, NULL, NULL, (LPBYTE)buf, &size);
    buf[size] = 0;
5272
    ok(!ret, "RegQueryValueExA failed %ld\n", ret);
5273 5274 5275
    if (ret) return;

    for (src = buf; *src; src = dst + strlen(dst) + 1)
5276
    {
5277
        DWORD flags = MOVEFILE_COPY_ALLOWED;
5278
        BOOL fileret;
5279

5280
        dst = src + strlen(src) + 1;
5281

5282 5283 5284 5285
        if (!strstr(src, "msitest"))
        {
            lstrcpyA(buf2ptr, src);
            buf2ptr += strlen(src) + 1;
5286 5287
            lstrcpyA(buf2ptr, dst);
            buf2ptr += strlen(dst) + 1;
5288 5289
            continue;
        }
5290

5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301
        found = TRUE;

        if (*dst == '!')
        {
            flags |= MOVEFILE_REPLACE_EXISTING;
            dst++;
        }
        if (src[0] == '\\' && src[1] == '?' && src[2] == '?' && src[3] == '\\') src += 4;
        if (*dst)
        {
            if (dst[0] == '\\' && dst[1] == '?' && dst[2] == '?' && dst[3] == '\\') dst += 4;
5302
            fileret = MoveFileExA(src, dst, flags);
5303
            ok(fileret, "Failed to move file %s -> %s (%lu)\n", src, dst, GetLastError());
5304 5305
        }
        else
5306 5307
        {
            fileret = DeleteFileA(src);
5308
            ok(fileret || broken(!fileret) /* win2k3 */, "Failed to delete file %s (%lu)\n", src, GetLastError());
5309
        }
5310
    }
5311

5312
    ok(found, "Expected a 'msitest' entry\n");
5313

5314 5315 5316 5317
    if (*buf2)
        RegSetValueExA(hkey, rename_ops, 0, REG_MULTI_SZ, (LPBYTE)buf2, buf2ptr + 1 - buf2);
    else
        RegDeleteValueA(hkey, rename_ops);
5318

5319 5320
    free(buf);
    free(buf2);
5321
}
5322

5323 5324 5325 5326 5327 5328
static BOOL file_matches_data(LPCSTR file, LPCSTR data)
{
    DWORD len, data_len = strlen(data);
    HANDLE handle;
    char buf[128];

5329
    handle = CreateFileA(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
5330
    ok(handle != INVALID_HANDLE_VALUE, "failed to open %s (%lu)\n", file, GetLastError());
5331 5332 5333 5334 5335 5336 5337 5338

    if (ReadFile(handle, buf, sizeof(buf), &len, NULL) && len >= data_len)
    {
        CloseHandle(handle);
        return !memcmp(buf, data, data_len);
    }
    CloseHandle(handle);
    return FALSE;
5339 5340
}

5341
static void test_file_in_use(void)
5342 5343 5344
{
    UINT r;
    HANDLE file;
5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357
    HKEY hkey;
    char path[MAX_PATH];

    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

    RegOpenKeyExA(HKEY_LOCAL_MACHINE, session_manager, 0, KEY_ALL_ACCESS, &hkey);

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);
5358
    create_database(msifile, fiu_tables, ARRAY_SIZE(fiu_tables));
5359

5360
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5361

5362 5363
    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\msitest");
5364 5365
    CreateDirectoryA(path, NULL);

5366
    lstrcatA(path, "\\maximus");
5367
    file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
5368

5369 5370
    r = MsiInstallProductA(msifile, "REBOOT=ReallySuppress FULL=1");
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5371 5372 5373 5374
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5375 5376
    ok(r == ERROR_SUCCESS_REBOOT_REQUIRED, "Expected ERROR_SUCCESS_REBOOT_REQUIRED got %u\n", r);
    ok(!file_matches_data(path, "msitest\\maximus"), "Expected file not to match\n");
5377
    CloseHandle(file);
5378
    ok(!file_matches_data(path, "msitest\\maximus"), "Expected file not to match\n");
5379

5380 5381
    process_pending_renames(hkey);
    RegCloseKey(hkey);
5382

5383 5384 5385
    ok(file_matches_data(path, "msitest\\maximus"), "Expected file to match\n");
    ok(delete_pf("msitest\\maximus", TRUE), "File not present\n");
    ok(delete_pf("msitest", FALSE), "Directory not present or not empty\n");
5386

5387
    r = MsiInstallProductA(msifile, "REMOVE=ALL FULL=1");
5388 5389
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5390
error:
5391 5392 5393 5394 5395
    RegCloseKey(hkey);

    delete_pf("msitest\\maximus", TRUE);
    delete_pf("msitest", FALSE);
    DeleteFileA("msitest\\maximus");
5396
    delete_test_files();
5397
    DeleteFileA(msifile);
5398 5399
}

5400
static void test_file_in_use_cab(void)
5401 5402
{
    UINT r;
5403 5404 5405
    HANDLE file;
    HKEY hkey;
    char path[MAX_PATH];
5406

5407 5408 5409 5410 5411
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }
5412

5413
    RegOpenKeyExA(HKEY_LOCAL_MACHINE, session_manager, 0, KEY_ALL_ACCESS, &hkey);
5414

5415 5416 5417
    CreateDirectoryA("msitest", NULL);
    create_file("maximus", 500);
    create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
5418
    DeleteFileA("maximus");
5419

5420
    create_database(msifile, fiuc_tables, ARRAY_SIZE(fiuc_tables));
5421

5422
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5423

5424 5425
    lstrcpyA(path, PROG_FILES_DIR);
    lstrcatA(path, "\\msitest");
5426
    CreateDirectoryA(path, NULL);
5427

5428
    lstrcatA(path, "\\maximus");
5429
    file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
5430

5431
    r = MsiInstallProductA(msifile, "REBOOT=ReallySuppress FULL=1");
5432 5433 5434 5435 5436
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5437 5438 5439 5440
    ok(r == ERROR_SUCCESS_REBOOT_REQUIRED, "Expected ERROR_SUCCESS_REBOOT_REQUIRED got %u\n", r);
    ok(!file_matches_data(path, "maximus"), "Expected file not to match\n");
    CloseHandle(file);
    ok(!file_matches_data(path, "maximus"), "Expected file not to match\n");
5441

5442 5443
    process_pending_renames(hkey);
    RegCloseKey(hkey);
5444

5445 5446 5447
    ok(file_matches_data(path, "maximus"), "Expected file to match\n");
    ok(delete_pf("msitest\\maximus", TRUE), "File not present\n");
    ok(delete_pf("msitest", FALSE), "Directory not present or not empty\n");
5448

5449
    r = MsiInstallProductA(msifile, "REMOVE=ALL FULL=1");
5450 5451
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5452 5453
error:
    RegCloseKey(hkey);
5454

5455 5456 5457 5458 5459
    delete_pf("msitest\\maximus", TRUE);
    delete_pf("msitest", FALSE);
    DeleteFileA("msitest\\maximus");
    delete_cab_files();
    delete_test_files();
5460
    DeleteFileA(msifile);
5461
}
5462

5463
static void test_feature_override(void)
5464 5465
{
    UINT r;
5466
    REGSAM access = KEY_ALL_ACCESS;
5467

5468 5469 5470 5471 5472 5473
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

5474
    create_test_files();
5475 5476 5477
    create_file("msitest\\override.txt", 1000);
    create_file("msitest\\preselected.txt", 1000);
    create_file("msitest\\notpreselected.txt", 1000);
5478
    create_database(msifile, fo_tables, ARRAY_SIZE(fo_tables));
5479 5480 5481

    if (is_wow64)
        access |= KEY_WOW64_64KEY;
5482 5483 5484

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

5485
    r = MsiInstallProductA(msifile, "ADDLOCAL=override");
5486 5487 5488 5489 5490
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5491 5492
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5493 5494 5495
    ok(pf_exists("msitest\\override.txt"), "file not installed\n");
    ok(!pf_exists("msitest\\preselected.txt"), "file installed\n");
    ok(!pf_exists("msitest\\notpreselected.txt"), "file installed\n");
5496 5497 5498 5499

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5500
    ok(!delete_pf("msitest\\override.txt", TRUE), "file not removed\n");
5501

5502 5503
    r = MsiInstallProductA(msifile, "preselect=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5504

5505 5506 5507
    ok(pf_exists("msitest\\override.txt"), "file not installed\n");
    ok(pf_exists("msitest\\preselected.txt"), "file not installed\n");
    ok(!pf_exists("msitest\\notpreselected.txt"), "file installed\n");
5508

5509 5510
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5511

5512
    ok(!delete_pf("msitest\\override.txt", TRUE), "file not removed\n");
5513 5514
    ok(!delete_pf("msitest\\preselected.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");
5515

5516 5517 5518
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5519 5520 5521
    ok(pf_exists("msitest\\override.txt"), "file not installed\n");
    ok(pf_exists("msitest\\preselected.txt"), "file not installed\n");
    ok(!pf_exists("msitest\\notpreselected.txt"), "file installed\n");
5522 5523 5524 5525

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

5526
    ok(!delete_pf("msitest\\override.txt", TRUE), "file not removed\n");
5527 5528
    ok(!delete_pf("msitest\\preselected.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");
5529

5530
    delete_key(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", access);
5531

5532
error:
5533 5534 5535
    DeleteFileA("msitest\\override.txt");
    DeleteFileA("msitest\\preselected.txt");
    DeleteFileA("msitest\\notpreselected.txt");
5536
    delete_test_files();
5537
    DeleteFileA(msifile);
5538 5539
}

5540 5541 5542 5543 5544
static void test_icon_table(void)
{
    MSIHANDLE hdb = 0, record;
    LPCSTR query;
    UINT res;
5545
    CHAR path[MAX_PATH];
5546 5547
    static const char prodcode[] = "{7DF88A49-996F-4EC8-A022-BF956F9B2CBB}";

5548 5549 5550 5551 5552 5553
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

5554
    create_database(msifile, icon_base_tables, ARRAY_SIZE(icon_base_tables));
5555

5556 5557
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

5558
    res = MsiOpenDatabaseW(msifileW, MSIDBOPEN_TRANSACT, &hdb);
5559 5560 5561 5562 5563 5564 5565 5566
    ok(res == ERROR_SUCCESS, "failed to open db: %d\n", res);

    query = "CREATE TABLE `Icon` (`Name` CHAR(72) NOT NULL, `Data` OBJECT NOT NULL  PRIMARY KEY `Name`)";
    res = run_query( hdb, 0, query );
    ok(res == ERROR_SUCCESS, "Can't create Icon table: %d\n", res);

    create_file("icon.ico", 100);
    record = MsiCreateRecord(1);
5567
    res = MsiRecordSetStreamA(record, 1, "icon.ico");
5568 5569 5570 5571 5572 5573 5574 5575
    ok(res == ERROR_SUCCESS, "Failed to add stream data to record: %d\n", res);

    query = "INSERT INTO `Icon` (`Name`, `Data`) VALUES ('testicon', ?)";
    res = run_query(hdb, record, query);
    ok(res == ERROR_SUCCESS, "Insert into Icon table failed: %d\n", res);

    res = MsiCloseHandle(record);
    ok(res == ERROR_SUCCESS, "Failed to close record handle: %d\n", res);
5576
    DeleteFileA("icon.ico");
5577 5578 5579 5580 5581 5582 5583
    res = MsiDatabaseCommit(hdb);
    ok(res == ERROR_SUCCESS, "Failed to commit database: %d\n", res);
    res = MsiCloseHandle(hdb);
    ok(res == ERROR_SUCCESS, "Failed to close database: %d\n", res);

    /* per-user */
    res = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
5584 5585 5586
    if (res == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
5587
        DeleteFileA(msifile);
5588 5589
        return;
    }
5590 5591 5592 5593 5594 5595 5596 5597 5598
    ok(res == ERROR_SUCCESS, "Failed to do per-user install: %d\n", res);

    lstrcpyA(path, APP_DATA_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, "Microsoft\\Installer\\");
    lstrcatA(path, prodcode);
    lstrcatA(path, "\\testicon");
    ok(file_exists(path), "Per-user icon file isn't where it's expected (%s)\n", path);

5599
    res = MsiInstallProductA(msifile, "REMOVE=ALL FULL=1");
5600
    ok(res == ERROR_SUCCESS, "Failed to uninstall per-user\n");
5601
    ok(!file_exists(path), "Per-user icon file not removed (%s)\n", path);
5602 5603 5604 5605 5606 5607 5608 5609 5610 5611

    /* system-wide */
    res = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1 ALLUSERS=1");
    ok(res == ERROR_SUCCESS, "Failed to system-wide install: %d\n", res);

    lstrcpyA(path, WINDOWS_DIR);
    lstrcatA(path, "\\");
    lstrcatA(path, "Installer\\");
    lstrcatA(path, prodcode);
    lstrcatA(path, "\\testicon");
5612
    ok(file_exists(path), "System-wide icon file isn't where it's expected (%s)\n", path);
5613

5614
    res = MsiInstallProductA(msifile, "REMOVE=ALL FULL=1");
5615
    ok(res == ERROR_SUCCESS, "Failed to uninstall system-wide\n");
5616
    ok(!file_exists(path), "System-wide icon file not removed (%s)\n", path);
5617 5618

    delete_pfmsitest_files();
5619
    DeleteFileA(msifile);
5620 5621
}

5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633
static void test_package_validation(void)
{
    UINT r;

    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);
5634
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Intel;1033");
5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
    ok(delete_pf("msitest", FALSE), "directory does not exist\n");

5648
    DeleteFileA(msifile);
5649
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "Intel,9999;9999");
5650 5651 5652 5653

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_INSTALL_LANGUAGE_UNSUPPORTED, "Expected ERROR_INSTALL_LANGUAGE_UNSUPPORTED, got %u\n", r);

5654
    DeleteFileA(msifile);
5655
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "Intel,1033;9999");
5656 5657 5658 5659

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_INSTALL_LANGUAGE_UNSUPPORTED, "Expected ERROR_INSTALL_LANGUAGE_UNSUPPORTED, got %u\n", r);

5660
    DeleteFileA(msifile);
5661
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "Intel,9999;1033");
5662 5663 5664 5665 5666 5667

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
    ok(delete_pf("msitest", FALSE), "directory does not exist\n");

5668
    DeleteFileA(msifile);
5669
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "Intel64,9999;1033");
5670 5671 5672 5673

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_INSTALL_PLATFORM_UNSUPPORTED, "Expected ERROR_INSTALL_PLATFORM_UNSUPPORTED, got %u\n", r);

5674
    DeleteFileA(msifile);
5675
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "Intel32,1033;1033");
5676 5677 5678 5679

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_INSTALL_PLATFORM_UNSUPPORTED, "Expected ERROR_INSTALL_PLATFORM_UNSUPPORTED, got %u\n", r);

5680
    DeleteFileA(msifile);
5681
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "Intel32,9999;1033");
5682 5683 5684 5685

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_INSTALL_PLATFORM_UNSUPPORTED, "Expected ERROR_INSTALL_PLATFORM_UNSUPPORTED, got %u\n", r);

5686
    DeleteFileA(msifile);
5687
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Intel;9999");
5688 5689 5690 5691 5692 5693

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_INSTALL_LANGUAGE_UNSUPPORTED, "Expected ERROR_INSTALL_LANGUAGE_UNSUPPORTED, got %u\n", r);
    ok(!delete_pf("msitest\\maximus", TRUE), "file exists\n");
    ok(!delete_pf("msitest", FALSE), "directory exists\n");

5694 5695
    if (GetSystemDefaultLangID() == MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ))
    {
5696
        DeleteFileA(msifile);
5697
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Intel;9");
5698 5699 5700 5701 5702
        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
        ok(delete_pf("msitest", FALSE), "directory does not exist\n");

5703
        DeleteFileA(msifile);
5704
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Intel;1024");
5705 5706 5707 5708 5709 5710
        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
        ok(delete_pf("msitest", FALSE), "directory does not exist\n");
    }

5711
    DeleteFileA(msifile);
5712
    create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Intel32;0");
5713 5714 5715 5716 5717 5718

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_INSTALL_PLATFORM_UNSUPPORTED, "Expected ERROR_INSTALL_PLATFORM_UNSUPPORTED, got %u\n", r);
    ok(!delete_pf("msitest\\maximus", TRUE), "file exists\n");
    ok(!delete_pf("msitest", FALSE), "directory exists\n");

5719
    if (is_64bit && !is_wow64)
5720
    {
5721
        DeleteFileA(msifile);
5722
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Intel;0");
5723 5724 5725 5726 5727 5728

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
        ok(delete_pf("msitest", FALSE), "directory does not exist\n");

5729
        DeleteFileA(msifile);
5730
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "x64;0");
5731 5732 5733 5734 5735 5736

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_INSTALL_PACKAGE_INVALID, "Expected ERROR_INSTALL_PACKAGE_INVALID, got %u\n", r);
        ok(!delete_pf("msitest\\maximus", TRUE), "file exists\n");
        ok(!delete_pf("msitest", FALSE), "directory exists\n");

5737
        DeleteFileA(msifile);
5738
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "x64;0");
5739 5740 5741 5742 5743 5744

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
        ok(delete_pf("msitest", FALSE), "directory does not exist\n");
    }
5745
    else if (is_wow64)
5746
    {
5747
        DeleteFileA(msifile);
5748
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Intel;0");
5749 5750 5751 5752 5753 5754

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
        ok(delete_pf("msitest", FALSE), "directory does not exist\n");

5755
        DeleteFileA(msifile);
5756
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "x64;0");
5757 5758

        r = MsiInstallProductA(msifile, NULL);
5759
        ok(r == ERROR_INSTALL_PACKAGE_INVALID, "Expected ERROR_INSTALL_PACKAGE_INVALID, got %u\n", r);
5760 5761
        ok(!delete_pf("msitest\\maximus", TRUE), "file exists\n");
        ok(!delete_pf("msitest", FALSE), "directory exists\n");
5762

5763
        DeleteFileA(msifile);
5764
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "x64;0");
5765 5766 5767

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5768 5769
        ok(delete_pf("msitest\\maximus", TRUE), "file exists\n");
        ok(delete_pf("msitest", FALSE), "directory exists\n");
5770 5771 5772
    }
    else
    {
5773
        DeleteFileA(msifile);
5774
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Intel;0");
5775 5776 5777 5778 5779

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
        ok(delete_pf("msitest", FALSE), "directory does not exist\n");
5780

5781
        DeleteFileA(msifile);
5782
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "Alpha,Beta,Intel;0");
5783 5784 5785 5786 5787

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "file does not exist\n");
        ok(delete_pf("msitest", FALSE), "directory does not exist\n");
5788

5789
        DeleteFileA(msifile);
5790
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 100, "x64;0");
5791 5792 5793 5794 5795 5796

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_INSTALL_PLATFORM_UNSUPPORTED, "Expected ERROR_INSTALL_PLATFORM_UNSUPPORTED, got %u\n", r);
        ok(!delete_pf("msitest\\maximus", TRUE), "file exists\n");
        ok(!delete_pf("msitest", FALSE), "directory exists\n");

5797
        DeleteFileA(msifile);
5798
        create_database_template(msifile, pv_tables, ARRAY_SIZE(pv_tables), 200, "x64;0");
5799 5800 5801 5802 5803 5804 5805 5806 5807

        r = MsiInstallProductA(msifile, NULL);
        ok(r == ERROR_INSTALL_PLATFORM_UNSUPPORTED, "Expected ERROR_INSTALL_PLATFORM_UNSUPPORTED, got %u\n", r);
        ok(!delete_pf("msitest\\maximus", TRUE), "file exists\n");
        ok(!delete_pf("msitest", FALSE), "directory exists\n");
    }

error:
    /* Delete the files in the temp (current) folder */
5808 5809 5810
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
5811 5812
}

5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824
static void test_upgrade_code(void)
{
    UINT r;

    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\upgradecode.txt", 1000);
5825
    create_database(msifile, uc_tables, ARRAY_SIZE(uc_tables));
5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    ok(pf_exists("msitest\\upgradecode.txt"), "file not installed\n");

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    ok(!delete_pf("msitest\\upgradecode.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

    DeleteFileA("msitest\\upgradecode.txt");
    RemoveDirectoryA("msitest");
5842
    DeleteFileA(msifile);
5843 5844
}

5845 5846 5847 5848 5849
static void test_mixed_package(void)
{
    UINT r;
    LONG res;
    HKEY hkey;
5850 5851
    char value[MAX_PATH];
    DWORD size;
5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863

    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }
    if (!is_wow64 && !is_64bit)
    {
        skip("this test must be run on 64-bit\n");
        return;
    }
    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5864
    create_database_template(msifile, mixed_tables, ARRAY_SIZE(mixed_tables), 200, "x64;1033");
5865 5866 5867 5868 5869 5870 5871 5872 5873 5874

    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", 0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
5875
    ok(!res, "can't open 32-bit component key, got %ld\n", res);
5876
    res = RegQueryValueExA(hkey, "test1", NULL, NULL, NULL, NULL);
5877
    ok(!res, "expected RegQueryValueEx to succeed, got %ld\n", res);
5878
    res = RegQueryValueExA(hkey, "test2", NULL, NULL, NULL, NULL);
5879
    ok(res, "expected RegQueryValueEx to fail, got %ld\n", res);
5880 5881 5882
    RegCloseKey(hkey);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", 0, KEY_ALL_ACCESS|KEY_WOW64_64KEY, &hkey);
5883
    ok(!res, "can't open 64-bit component key, got %ld\n", res);
5884
    res = RegQueryValueExA(hkey, "test1", NULL, NULL, NULL, NULL);
5885
    ok(res, "expected RegQueryValueEx to fail, got %ld\n", res);
5886
    res = RegQueryValueExA(hkey, "test2", NULL, NULL, NULL, NULL);
5887
    ok(!res, "expected RegQueryValueEx to succeed, got %ld\n", res);
5888 5889
    RegCloseKey(hkey);

5890 5891 5892
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                        "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32",
                        0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
5893
    ok(res == ERROR_SUCCESS, "can't open 32-bit CLSID key, got %ld\n", res);
5894 5895 5896 5897 5898 5899 5900 5901 5902 5903
    if (res == ERROR_SUCCESS) {
        size = sizeof(value);
        res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size);
        ok(!strcmp(value, "winetest32.dll"), "got %s\n", value);
        RegCloseKey(hkey);
    }

    res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                        "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32",
                        0, KEY_ALL_ACCESS|KEY_WOW64_64KEY, &hkey);
5904
    ok(res == ERROR_SUCCESS, "can't open 64-bit CLSID key, got %ld\n", res);
5905 5906 5907 5908 5909 5910 5911
    if (res == ERROR_SUCCESS) {
        size = sizeof(value);
        res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size);
        ok(!strcmp(value, "winetest64.dll"), "got %s\n", value);
        RegCloseKey(hkey);
    }

5912 5913 5914 5915
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", 0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
5916
    ok(res == ERROR_FILE_NOT_FOUND || broken(!res), "32-bit component key not removed\n");
5917 5918 5919 5920

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", 0, KEY_ALL_ACCESS|KEY_WOW64_64KEY, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "64-bit component key not removed\n");

5921 5922 5923 5924 5925 5926 5927 5928 5929 5930
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                        "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}",
                        0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "32-bit CLSID key not removed\n");

    res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                        "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}",
                        0, KEY_ALL_ACCESS|KEY_WOW64_64KEY, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "64-bit CLSID key not removed\n");

5931
    DeleteFileA( msifile );
5932
    create_database_template(msifile, mixed_tables, ARRAY_SIZE(mixed_tables), 200, "Intel;1033");
5933 5934 5935 5936 5937

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", 0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
5938
    ok(!res, "can't open 32-bit component key, got %ld\n", res);
5939
    res = RegQueryValueExA(hkey, "test1", NULL, NULL, NULL, NULL);
5940
    ok(!res, "expected RegQueryValueEx to succeed, got %ld\n", res);
5941
    res = RegQueryValueExA(hkey, "test2", NULL, NULL, NULL, NULL);
5942
    ok(res, "expected RegQueryValueEx to fail, got %ld\n", res);
5943 5944 5945
    RegCloseKey(hkey);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", 0, KEY_ALL_ACCESS|KEY_WOW64_64KEY, &hkey);
5946
    ok(!res, "can't open 64-bit component key, got %ld\n", res);
5947
    res = RegQueryValueExA(hkey, "test1", NULL, NULL, NULL, NULL);
5948
    ok(res, "expected RegQueryValueEx to fail, got %ld\n", res);
5949
    res = RegQueryValueExA(hkey, "test2", NULL, NULL, NULL, NULL);
5950
    ok(!res, "expected RegQueryValueEx to succeed, got %ld\n", res);
5951 5952
    RegCloseKey(hkey);

5953 5954 5955
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                        "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32",
                        0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
5956
    ok(res == ERROR_SUCCESS, "can't open 32-bit CLSID key, got %ld\n", res);
5957 5958 5959 5960 5961 5962 5963 5964 5965 5966
    if (res == ERROR_SUCCESS) {
        size = sizeof(value);
        res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size);
        ok(!strcmp(value, "winetest32.dll"), "got %s\n", value);
        RegCloseKey(hkey);
    }

    res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                        "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32",
                        0, KEY_ALL_ACCESS|KEY_WOW64_64KEY, &hkey);
5967
    ok(res == ERROR_SUCCESS, "can't open 64-bit CLSID key, got %ld\n", res);
5968 5969 5970 5971 5972 5973 5974
    if (res == ERROR_SUCCESS) {
        size = sizeof(value);
        res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size);
        ok(!strcmp(value, "winetest64.dll"), "got %s\n", value);
        RegCloseKey(hkey);
    }

5975 5976 5977 5978
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", 0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
5979
    ok(res == ERROR_FILE_NOT_FOUND || broken(!res), "32-bit component key not removed\n");
5980 5981 5982 5983

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest", 0, KEY_ALL_ACCESS|KEY_WOW64_64KEY, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "64-bit component key not removed\n");

5984 5985 5986 5987 5988 5989 5990 5991 5992 5993
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                        "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}",
                        0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "32-bit CLSID key not removed\n");

    res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                        "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}",
                        0, KEY_ALL_ACCESS|KEY_WOW64_64KEY, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "64-bit CLSID key not removed\n");

5994 5995
error:
    DeleteFileA( msifile );
5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008
}

static void test_volume_props(void)
{
    UINT r;

    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\volumeprop.txt", 1000);
6009
    create_database(msifile, vp_tables, ARRAY_SIZE(vp_tables));
6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    DeleteFileA("msitest\\volumeprop.txt");
    RemoveDirectoryA("msitest");
6021
    DeleteFileA(msifile);
6022 6023
}

6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034
static void test_shared_component(void)
{
    UINT r;

    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\sharedcomponent.txt", 1000);
6035
    create_database_wordcount(msifile, shc_tables, ARRAY_SIZE(shc_tables),
6036
                              100, 0, ";", "{A8826420-FD72-4E61-9E15-C1944CF4CBE1}");
6037
    create_database_wordcount(msifile2, shc2_tables, ARRAY_SIZE(shc2_tables),
6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067
                              100, 0, ";", "{A8B50B30-0E8A-4ACD-B3CF-1A5DC58B2739}");

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    ok(pf_exists("msitest\\sharedcomponent.txt"), "file not installed\n");

    r = MsiInstallProductA(msifile2, NULL);
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    ok(pf_exists("msitest\\sharedcomponent.txt"), "file not installed\n");

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    ok(pf_exists("msitest\\sharedcomponent.txt"), "file removed\n");

    r = MsiInstallProductA(msifile2, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    ok(!pf_exists("msitest\\sharedcomponent.txt"), "file not removed\n");

    DeleteFileA("msitest\\sharedcomponent.txt");
    RemoveDirectoryA("msitest");
    DeleteFileA(msifile);
    DeleteFileA(msifile2);
}

6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084
static void test_remove_upgrade_code(void)
{
    UINT r;
    LONG res;
    HKEY hkey;
    REGSAM access = KEY_ALL_ACCESS;
    DWORD type, size;
    char buf[1];

    if (is_process_limited())
    {
        skip( "process is limited\n" );
        return;
    }
    if (is_wow64) access |= KEY_WOW64_64KEY;

    create_test_files();
6085
    create_database( msifile, icon_base_tables, ARRAY_SIZE( icon_base_tables ));
6086 6087 6088 6089 6090 6091 6092 6093 6094

    MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );

    r = MsiInstallProductA( msifile, "FULL=1" );
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    res = RegOpenKeyExA( HKEY_LOCAL_MACHINE,
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2",
        0, access, &hkey );
6095
    ok( res == ERROR_SUCCESS, "got %ld\n", res );
6096 6097 6098 6099 6100

    type = 0xdeadbeef;
    buf[0] = 0x55;
    size = sizeof(buf);
    res = RegQueryValueExA( hkey, "94A88FD7F6998CE40A22FB59F6B9C2BB", NULL, &type, (BYTE *)buf, &size );
6101 6102 6103
    ok( res == ERROR_SUCCESS, "got %ld\n", res );
    ok( type == REG_SZ, "got %lu\n", type );
    ok( size == 1, "got %lu\n", size );
6104 6105 6106 6107 6108 6109 6110 6111 6112
    ok( !buf[0], "wrong data\n" );
    RegCloseKey( hkey );

    r = MsiInstallProductA( msifile, "REMOVE=ALL" );
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    res = RegOpenKeyExA( HKEY_LOCAL_MACHINE,
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2",
        0, access, &hkey );
6113
    ok( res == ERROR_FILE_NOT_FOUND, "got %ld\n", res );
6114 6115 6116 6117 6118

    RemoveDirectoryA( "msitest" );
    DeleteFileA( msifile );
}

6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129
static void test_feature_tree(void)
{
    UINT r;

    if (is_process_limited())
    {
        skip( "process is limited\n" );
        return;
    }

    create_file( "msitest\\featuretree.txt", 1000 );
6130
    create_database( msifile, ft_tables, ARRAY_SIZE( ft_tables ));
6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147

    MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );

    r = MsiInstallProductA( msifile, "INSTALLTYPE=\"0\"" );
    ok( r == ERROR_INSTALL_FAILURE, "got %u\n", r );

    r = MsiInstallProductA( msifile, "INSTALLTYPE=\"1\"" );
    ok( r == ERROR_SUCCESS, "got %u\n", r );

    r = MsiInstallProductA( msifile, "REMOVE=ALL" );
    ok( r == ERROR_SUCCESS, "got %u\n", r );

    DeleteFileA( "msitest\\featuretree.txt" );
    RemoveDirectoryA( "msitest" );
    DeleteFileA( msifile );
}

6148 6149 6150 6151 6152 6153 6154 6155
static void check_file_matches(const char *filename, const char *text)
{
    char buffer[200];
    HANDLE file;
    DWORD size;

    file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
    ReadFile(file, buffer, sizeof(buffer), &size, NULL);
6156
    ok(size == strlen(text) && !memcmp(buffer, text, size), "got %.*s\n", (int)size, buffer);
6157 6158 6159
    CloseHandle(file);
}

6160 6161
static void test_deferred_action(void)
{
6162
    char path[200], file[200], buffer[211];
6163 6164
    UINT r;

6165 6166 6167 6168
    GetTempPathA(sizeof(path), path);
    GetTempFileNameA(path, "da", 0, file);
    sprintf(buffer, "TESTPATH=\"%s\"", file);

6169
    create_database(msifile, da_tables, ARRAY_SIZE(da_tables));
6170 6171 6172

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

6173
    r = MsiInstallProductA(msifile, buffer);
6174 6175 6176 6177 6178 6179 6180
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

6181 6182 6183 6184
    check_file_matches(file, "onetwo");

    ok(DeleteFileA(file), "Directory not created\n");

6185 6186 6187 6188
error:
    DeleteFileA(msifile);
}

6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206
static void test_wow64(void)
{
    void *cookie;
    UINT r;

    if (!is_wow64)
    {
        skip("test must be run on WoW64\n");
        return;
    }

    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

    create_test_files();
6207
    create_database_template(msifile, x64_tables, ARRAY_SIZE(x64_tables), 200, "x64;0");
6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247
    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }

    pWow64DisableWow64FsRedirection(&cookie);

    ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
    ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
    ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
    ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
    ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
    ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
    ok(!delete_pf("msitest", FALSE), "Directory created\n");

    ok(delete_pf_native("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
    ok(delete_pf_native("msitest\\cabout\\new", FALSE), "Directory not created\n");
    ok(delete_pf_native("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
    ok(delete_pf_native("msitest\\cabout", FALSE), "Directory not created\n");
    ok(delete_pf_native("msitest\\changed\\three.txt", TRUE), "File not installed\n");
    ok(delete_pf_native("msitest\\changed", FALSE), "Directory not created\n");
    ok(delete_pf_native("msitest\\first\\two.txt", TRUE), "File not installed\n");
    ok(delete_pf_native("msitest\\first", FALSE), "Directory not created\n");
    ok(delete_pf_native("msitest\\one.txt", TRUE), "File not installed\n");
    ok(delete_pf_native("msitest\\filename", TRUE), "File not installed\n");
    ok(delete_pf_native("msitest", FALSE), "Directory not created\n");

    pWow64RevertWow64FsRedirection(cookie);

error:
    delete_test_files();
    DeleteFileA(msifile);
}

6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259
/* Test what actions cause resolution of SourceDir when executed. */
static void test_source_resolution(void)
{
    UINT r;

    if (is_process_limited())
    {
        skip( "process is limited\n" );
        return;
    }

    create_test_files();
6260
    create_database(msifile, sr_tables, ARRAY_SIZE(sr_tables));
6261 6262 6263 6264 6265 6266 6267 6268 6269

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, "RESOLVE_SOURCE=1");
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
    ok(r == ERROR_SUCCESS, "got %u\n", r);

6270 6271 6272 6273
    r = MsiInstallProductA(msifile, "INSTALL_FILES=1");
    ok(r == ERROR_SUCCESS, "got %u\n", r);

    delete_pf_files();
6274 6275 6276 6277
    delete_test_files();
    DeleteFileA(msifile);
}

6278 6279
START_TEST(install)
{
6280
    DWORD len;
6281
    char temp_path[MAX_PATH], prev_path[MAX_PATH], log_file[MAX_PATH];
6282 6283
    STATEMGRSTATUS status;
    BOOL ret = FALSE;
6284

6285
    init_functionpointers();
6286
    subtest("custom");
6287

6288 6289 6290
    if (pIsWow64Process)
        pIsWow64Process(GetCurrentProcess(), &is_wow64);

6291
    GetCurrentDirectoryA(MAX_PATH, prev_path);
6292
    GetTempPathA(MAX_PATH, temp_path);
6293
    SetCurrentDirectoryA(temp_path);
6294

6295
    lstrcpyA(CURR_DIR, temp_path);
6296 6297
    len = lstrlenA(CURR_DIR);

6298
    if(len && (CURR_DIR[len - 1] == '\\'))
6299
        CURR_DIR[len - 1] = 0;
6300

6301 6302
    ok(get_system_dirs(), "failed to retrieve system dirs\n");
    ok(get_user_dirs(), "failed to retrieve user dirs\n");
6303

6304 6305
    /* Create a restore point ourselves so we circumvent the multitude of restore points
     * that would have been created by all the installation and removal tests.
6306 6307 6308
     *
     * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
     * creation of restore points.
6309
     */
6310
    if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
6311 6312 6313 6314 6315
    {
        memset(&status, 0, sizeof(status));
        ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
    }

6316
    /* Create only one log file and don't append. We have to pass something
6317 6318 6319
     * for the log mode for this to work. The logfile needs to have an absolute
     * path otherwise we still end up with some extra logfiles as some tests
     * change the current directory.
6320
     */
6321 6322 6323
    lstrcpyA(log_file, temp_path);
    lstrcatA(log_file, "\\msitest.log");
    MsiEnableLogA(INSTALLLOGMODE_FATALEXIT, log_file, 0);
6324

6325 6326
    if (pSRSetRestorePointA) /* test has side-effects on win2k3 that cause failures in following tests */
        test_MsiInstallProduct();
6327
    test_MsiSetComponentState();
6328
    test_packagecoltypes();
6329
    test_continuouscabs();
6330
    test_caborder();
6331
    test_mixedmedia();
6332
    test_samesequence();
6333
    test_uiLevelFlags();
6334
    test_readonlyfile();
6335
    test_readonlyfile_cab();
6336
    test_setdirproperty();
6337
    test_cabisextracted();
6338
    test_transformprop();
6339
    test_currentworkingdir();
6340
    test_admin();
6341
    test_adminprops();
6342
    test_missingcab();
6343
    test_sourcefolder();
6344
    test_customaction1();
6345
    test_customaction51();
6346
    test_installstate();
6347
    test_sourcepath();
6348
    test_missingcomponent();
6349
    test_sourcedirprop();
6350
    test_adminimage();
6351
    test_propcase();
6352
    test_int_widths();
6353
    test_shortcut();
6354
    test_preselected();
6355
    test_installed_prop();
6356
    test_file_in_use();
6357
    test_file_in_use_cab();
6358
    test_allusers_prop();
6359
    test_feature_override();
6360
    test_icon_table();
6361
    test_package_validation();
6362
    test_upgrade_code();
6363
    test_mixed_package();
6364
    test_volume_props();
6365
    test_shared_component();
6366
    test_remove_upgrade_code();
6367
    test_feature_tree();
6368
    test_deferred_action();
6369
    test_wow64();
6370
    test_source_resolution();
6371

6372 6373
    DeleteFileA(customdll);

6374
    DeleteFileA(log_file);
6375

6376
    if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
6377 6378 6379 6380 6381 6382
    {
        ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
        if (ret)
            remove_restore_point(status.llSequenceNumber);
    }

6383
    SetCurrentDirectoryA(prev_path);
6384
}