action.c 243 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * Copyright (C) 2006 James Hawkins
 * Copyright 2010 Hans Leidekker for CodeWeavers
 *
 * Tests concentrating on standard actions
 *
 * 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
 */

#define _WIN32_MSI 300
#include <stdio.h>
24
#include <stdlib.h>
25

26
#define COBJMACROS
27 28 29 30 31 32
#include <windows.h>
#include <msiquery.h>
#include <msidefs.h>
#include <msi.h>
#include <fci.h>
#include <srrestoreptapi.h>
33 34 35
#include <wtypes.h>
#include <shellapi.h>
#include <winsvc.h>
36
#include <odbcinst.h>
37
#include <sddl.h>
38 39

#include "wine/test.h"
40
#include "utils.h"
41
#include "typelib.h"
42 43 44 45 46 47 48 49 50

static UINT (WINAPI *pMsiQueryComponentStateA)
    (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE *);
static UINT (WINAPI *pMsiSourceListEnumSourcesA)
    (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, DWORD, LPSTR, LPDWORD);
static UINT (WINAPI *pMsiSourceListGetInfoA)
    (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)
    (LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
51 52
static UINT (WINAPI *pMsiQueryFeatureStateExA)
    (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE *);
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);

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

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

static const char *msifile = "msitest.msi";

/* 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"
    "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\tNOT REINSTALL\tone.txt\n"
    "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
    "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
    "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
    "component\t\tMSITESTDIR\t0\t1\tfile\n"
78
    "service_comp\t{935A0A91-22A3-4F87-BCA8-928FFDFE2353}\tMSITESTDIR\t0\t\tservice_file\n"
79 80
    "service_comp2\t{3F7B04A4-9521-4649-BDC9-0C8722740A49}\tMSITESTDIR\t0\t\tservice_file2\n"
    "service_comp3\t{DBCD1502-20E3-423F-B53E-F37E263CDC7E}\tMSITESTDIR\t0\t\t\n";
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

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"
    "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
    "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
    "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";

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"
    "Two\tTwo\n"
    "feature\tcomponent\n"
116
    "service_feature\tservice_comp\n"
117 118
    "service_feature\tservice_comp2\n"
    "service_feature\tservice_comp3";
119 120 121 122 123 124 125 126 127 128 129

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"
    "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
    "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
130 131
    "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t6\n"
    "service_file2\tservice_comp2\tservice2.exe\t100\t\t\t8192\t7";
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

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"
    "ResolveSource\t\t950\n"
    "MoveFiles\t\t1700\n"
    "InstallFiles\t\t4000\n"
    "DuplicateFiles\t\t4500\n"
    "CreateShortcuts\t\t4600\n"
    "InstallServices\t\t5000\n"
    "InstallFinalize\t\t6600\n"
    "InstallInitialize\t\t1500\n"
    "InstallValidate\t\t1400\n"
    "LaunchConditions\t\t100\n"
    "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";

static const char media_dat[] =
    "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
    "i2\ti4\tL64\tS255\tS32\tS72\n"
    "Media\tDiskId\n"
    "1\t3\t\t\tDISK1\t\n"
158
    "2\t7\t\tmsitest.cab\tDISK2\t\n";
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180

static const char 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"
    "SERVNAME\tTestService\n"
181
    "SERVNAME2\tTestService2\n"
182
    "SERVDISP\tTestServiceDisp\n"
183
    "SERVDISP2\tTestServiceDisp2\n"
184
    "MSIFASTINSTALL\t1\n"
185
    "ARPNOMODIFY\t1\n"
186
    "regdata17\t#1\n";
187

188 189 190 191 192 193 194 195 196 197 198
static const char env_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"
    "ProcessComponents\t\t600\n"
    "WriteEnvironmentStrings\t\t700\n"
199 200
    "wes_immediate\tNOT REMOVE\t701\n"
    "wes_deferred\tNOT REMOVE\t702\n"
201
    "RemoveEnvironmentStrings\t\t800\n"
202 203
    "res_immediate\tREMOVE\t801\n"
    "res_deferred\tREMOVE\t802\n"
204 205 206
    "RegisterProduct\t\t900\n"
    "PublishFeatures\t\t1000\n"
    "PublishProduct\t\t1100\n"
207
    "UnpublishFeatures\t\t1150\n"
208 209
    "InstallFinalize\t\t1200\n";

210 211 212 213 214 215 216 217 218
static const char env_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "wes_immediate\t1\tcustom.dll\tenv_absent\n"
    "wes_deferred\t1025\tcustom.dll\tenv_present\n"
    "res_immediate\t1\tcustom.dll\tenv_present\n"
    "res_deferred\t1025\tcustom.dll\tenv_absent\n";

219
static const char env_environment_dat[] =
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
    "Environment\tName\tValue\tComponent_\n"
    "s72\tl255\tL255\ts72\n"
    "Environment\tEnvironment\n"
    "Var1\t=-MSITESTVAR1\t1\tOne\n"
    "Var2\tMSITESTVAR2\t1\tOne\n"
    "Var3\t=-MSITESTVAR3\t1\tOne\n"
    "Var4\tMSITESTVAR4\t1\tOne\n"
    "Var5\t-MSITESTVAR5\t\tOne\n"
    "Var6\tMSITESTVAR6\t\tOne\n"
    "Var7\t!-MSITESTVAR7\t\tOne\n"
    "Var8\t!-*MSITESTVAR8\t\tOne\n"
    "Var9\t=-MSITESTVAR9\t\tOne\n"
    "Var10\t=MSITESTVAR10\t\tOne\n"
    "Var11\t+-MSITESTVAR11\t[~];1\tOne\n"
    "Var12\t+-MSITESTVAR11\t[~];2\tOne\n"
    "Var13\t+-MSITESTVAR12\t[~];1\tOne\n"
    "Var14\t=MSITESTVAR13\t[~];1\tOne\n"
    "Var15\t=MSITESTVAR13\t[~];2\tOne\n"
    "Var16\t=MSITESTVAR14\t;1;\tOne\n"
    "Var17\t=MSITESTVAR15\t;;1;;\tOne\n"
    "Var18\t=MSITESTVAR16\t 1 \tOne\n"
    "Var19\t+-MSITESTVAR17\t1\tOne\n"
    "Var20\t+-MSITESTVAR17\t;;2;;[~]\tOne\n"
    "Var21\t+-MSITESTVAR18\t1\tOne\n"
    "Var22\t+-MSITESTVAR18\t[~];;2;;\tOne\n"
    "Var23\t+-MSITESTVAR19\t1\tOne\n"
    "Var24\t+-MSITESTVAR19\t[~]2\tOne\n"
    "Var25\t+-MSITESTVAR20\t1\tOne\n"
248
    "Var26\t+-MSITESTVAR20\t2[~]\tOne\n"
249 250
    "Var27\t+-MSITESTVAR21\t[~];1\tOne\n"
    "Var28\t-MSITESTVAR22\t1\tOne\n"
251
    "Var29\t-MSITESTVAR23\t2\tOne\n"
252 253 254
    "Var30\t*MSITESTVAR100\t1\tOne\n"
    "Var31\t-=MSITESTVAR24\t[SERVNAME]\tOne\n"
    "Var32\t-=MSITESTVAR25\t[bogus_prop]\tOne\n";
255 256 257 258 259 260

static const char service_install_dat[] =
    "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
    "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
    "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
    "ServiceInstall\tServiceInstall\n"
261
    "TestService\t[SERVNAME]\t[SERVDISP]\t2\t3\t0\t\tservice1[~]+group1[~]service2[~]+group2[~][~]\tTestService\t\t-a arg\tservice_comp\tdescription\n"
262
    "TestService2\t[SERVNAME2]\t[SERVDISP2]\t2\t3\t0\t\tservice1[~]+group1[~]service2[~]+group2[~][~]\tTestService2\t\t-a arg\tservice_comp2\tdescription\n";
263

264 265 266 267 268
static const char service_install2_dat[] =
    "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
    "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
    "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
    "ServiceInstall\tServiceInstall\n"
269
    "TestService\tTestService\tTestService\t2\t3\t32768\t\t\tTestService\t\t\tservice_comp\t\n"
270 271
    "TestService4\tTestService4\tTestService4\t2\t3\t0\t\t\tTestService4\t\t\tservice_comp3\t\n";

272 273 274 275
static const char service_control_dat[] =
    "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
    "s72\tl255\ti2\tL255\tI2\ts72\n"
    "ServiceControl\tServiceControl\n"
276 277
    "ServiceControl\tTestService3\t8\t\t0\tservice_comp\n"
    "ServiceControl2\tTestService3\t128\t\t0\tservice_comp2";
278 279 280 281 282

static const char sss_service_control_dat[] =
    "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
    "s72\tl255\ti2\tL255\tI2\ts72\n"
    "ServiceControl\tServiceControl\n"
283 284 285 286
    "ServiceControl\tSpooler\t1\t\t1\tservice_comp\n"
    "ServiceControl2\tSpooler\t2\t\t1\tservice_comp\n"
    "ServiceControl3\tSpooler\t16\t\t1\tservice_comp\n"
    "ServiceControl4\tSpooler\t32\t\t1\tservice_comp\n";
287 288 289 290 291 292 293 294 295 296 297 298

static const char sss_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"
    "ResolveSource\t\t950\n"
    "CostFinalize\t\t1000\n"
    "InstallValidate\t\t1400\n"
    "InstallInitialize\t\t1500\n"
299
    "StopServices\t\t4000\n"
300 301
    "stop_immediate\tNOT REMOVE\t4001\n"
    "stop_deferred\tNOT REMOVE\t4002\n"
302 303 304 305 306
    "DeleteServices\t\t5000\n"
    "MoveFiles\t\t5100\n"
    "InstallFiles\t\t5200\n"
    "DuplicateFiles\t\t5300\n"
    "StartServices\t\t5400\n"
307
    "start_deferred\tNOT REMOVE\t5401\n"
308 309 310
    "RegisterProduct\t\t5500\n"
    "PublishFeatures\t\t5600\n"
    "PublishProduct\t\t5700\n"
311
    "UnpublishFeatures\t\t5800\n"
312 313
    "InstallFinalize\t\t6000\n";

314 315 316 317 318 319 320 321
static const char sss_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "stop_immediate\t1\tcustom.dll\tsss_started\n"
    "stop_deferred\t1025\tcustom.dll\tsss_stopped\n"
    "start_deferred\t1025\tcustom.dll\tsss_started\n";

322 323 324 325 326 327 328 329 330 331 332
static const char sds_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"
    "ResolveSource\t\t950\n"
    "CostFinalize\t\t1000\n"
    "InstallValidate\t\t1400\n"
    "InstallInitialize\t\t1500\n"
333 334
    "StopServices\t\t5000\n"
    "DeleteServices\t\t5050\n"
335 336
    "sds_immediate\tNOT REMOVE\t5051\n"
    "sds_deferred\tNOT REMOVE\t5052\n"
337 338 339
    "MoveFiles\t\t5100\n"
    "InstallFiles\t\t5200\n"
    "DuplicateFiles\t\t5300\n"
340 341
    "InstallServices\t\t5400\n"
    "StartServices\t\t5450\n"
342 343 344
    "RegisterProduct\t\t5500\n"
    "PublishFeatures\t\t5600\n"
    "PublishProduct\t\t5700\n"
345
    "UnpublishFeatures\t\t5800\n"
346 347
    "InstallFinalize\t\t6000\n";

348 349 350 351 352 353 354
static const char sds_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "sds_immediate\t1\tcustom.dll\tsds_present\n"
    "sds_deferred\t1025\tcustom.dll\tsds_absent\n";

355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
static const char sis_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "CostInitialize\t\t800\n"
    "FileCost\t\t900\n"
    "CostFinalize\t\t1000\n"
    "InstallValidate\t\t1400\n"
    "InstallInitialize\t\t1500\n"
    "StopServices\t\t5000\n"
    "DeleteServices\t\t5050\n"
    "InstallFiles\t\t5200\n"
    "InstallServices\t\t5400\n"
    "sis_immediate\tNOT REMOVE\t5401\n"
    "sis_deferred\tNOT REMOVE\t5402\n"
    "StartServices\t\t5450\n"
    "RegisterProduct\t\t5500\n"
    "PublishFeatures\t\t5600\n"
    "PublishProduct\t\t5700\n"
374
    "UnpublishFeatures\t\t5800\n"
375 376 377 378 379 380 381 382 383
    "InstallFinalize\t\t6000\n";

static const char sis_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "sis_immediate\t1\tcustom.dll\tsis_absent\n"
    "sis_deferred\t1025\tcustom.dll\tsis_present\n";

384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
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"
    "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
    "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";

static const char rof_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "feature\tmaximus\n"
    "montecristo\tmaximus";

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";

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";

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"
439 440
    "ppc_immediate\tPROCESS_COMPONENTS AND ALLUSERS\t1601\n"
    "ppc_deferred\tPROCESS_COMPONENTS AND ALLUSERS\t1602\n"
441
    "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
442 443
    "uf_immediate\tUNPUBLISH_FEATURES AND ALLUSERS\t1801\n"
    "uf_deferred\tUNPUBLISH_FEATURES AND ALLUSERS\t1802\n"
444 445 446
    "RemoveFiles\t\t3500\n"
    "InstallFiles\t\t4000\n"
    "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
447 448
    "ru_immediate\tREGISTER_USER AND ALLUSERS\t6001\n"
    "ru_deferred\tREGISTER_USER AND ALLUSERS\t6002\n"
449
    "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
450 451
    "rp_immediate\tREGISTER_PRODUCT AND ALLUSERS AND NOT RP_TEST64\t6101\n"
    "rp_deferred\tREGISTER_PRODUCT AND ALLUSERS AND NOT RP_TEST64\t6102\n"
452
    "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
453 454
    "pf_immediate\tPUBLISH_FEATURES AND ALLUSERS\t6301\n"
    "pf_deferred\tPUBLISH_FEATURES AND ALLUSERS\t6302\n"
455
    "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
456 457
    "pp_immediate\tPUBLISH_PRODUCT AND ALLUSERS\t6401\n"
    "pp_deferred\tPUBLISH_PRODUCT AND ALLUSERS\t6402\n"
458 459
    "InstallFinalize\t\t6600";

460 461 462 463
static const char pp_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
464 465 466 467
    "pf_immediate\t1\tcustom.dll\tpf_absent\n"
    "pf_deferred\t1025\tcustom.dll\tpf_present\n"
    "uf_immediate\t1\tcustom.dll\tpf_present\n"
    "uf_deferred\t1025\tcustom.dll\tpf_absent\n"
468 469
    "pp_immediate\t1\tcustom.dll\tpp_absent\n"
    "pp_deferred\t1025\tcustom.dll\tpp_present\n"
470 471
    "rp_immediate\t1\tcustom.dll\trp_absent\n"
    "rp_deferred\t1025\tcustom.dll\trp_present\n"
472 473
    "ru_immediate\t1\tcustom.dll\tru_absent\n"
    "ru_deferred\t1025\tcustom.dll\tru_present\n"
474 475 476
    "ppc_immediate\t1\tcustom.dll\tppc_absent\n"
    "ppc_deferred\t1025\tcustom.dll\tppc_present\n";

477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 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 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
static const char pp_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\t\tmaximus\n";

static const char ppc_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\t\tmaximus\n"
    "augustus\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\taugustus\n";

static const char ppc_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\n"
    "augustus\taugustus\taugustus\t500\t\t\t8192\t2";

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

static const char ppc_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "feature\tmaximus\n"
    "feature\taugustus\n"
    "montecristo\tmaximus";

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";

static const char rem_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\t0\t\thydrogen\n"
    "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\thelium\n"
    "lithium\t\tMSITESTDIR\t2\t\tlithium\n";

static const char rem_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "feature\thydrogen\n"
    "feature\thelium\n"
    "feature\tlithium";

static const char rem_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";

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"
    "RemoveFiles\t\t3500\n"
    "InstallFiles\t\t4000\n"
    "RegisterProduct\t\t6100\n"
    "PublishFeatures\t\t6300\n"
    "PublishProduct\t\t6400\n"
557
    "UnpublishFeatures\t\t6500\n"
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
    "InstallFinalize\t\t6600";

static const char rem_remove_files_dat[] =
    "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n"
    "s72\ts72\tS255\ts72\tI2\n"
    "RemoveFile\tFileKey\n"
    "furlong\thydrogen\tfurlong\tMSITESTDIR\t1\n"
    "firkin\thelium\tfirkin\tMSITESTDIR\t1\n"
    "fortnight\tlithium\tfortnight\tMSITESTDIR\t1\n"
    "becquerel\thydrogen\tbecquerel\tMSITESTDIR\t2\n"
    "dioptre\thelium\tdioptre\tMSITESTDIR\t2\n"
    "attoparsec\tlithium\tattoparsec\tMSITESTDIR\t2\n"
    "storeys\thydrogen\tstoreys\tMSITESTDIR\t3\n"
    "block\thelium\tblock\tMSITESTDIR\t3\n"
    "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n"
    "nanoacre\thydrogen\t\tCABOUTDIR\t3\n";

static const char mov_move_file_dat[] =
    "FileKey\tComponent_\tSourceName\tDestName\tSourceFolder\tDestFolder\tOptions\n"
    "s72\ts72\tS255\tS255\tS72\ts72\ti2\n"
    "MoveFile\tFileKey\n"
    "abkhazia\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t0\n"
    "bahamas\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t1\n"
    "cambodia\taugustus\tcameroon\tcanada\tSourceDir\tMSITESTDIR\t0\n"
    "denmark\taugustus\tdjibouti\tdominica\tSourceDir\tMSITESTDIR\t1\n"
    "ecuador\taugustus\tegypt\telsalvador\tNotAProp\tMSITESTDIR\t1\n"
    "fiji\taugustus\tfinland\tfrance\tSourceDir\tNotAProp\t1\n"
    "gabon\taugustus\tgambia\tgeorgia\tSOURCEFULL\tMSITESTDIR\t1\n"
    "haiti\taugustus\thonduras\thungary\tSourceDir\tDESTFULL\t1\n"
    "iceland\taugustus\tindia\tindonesia\tMSITESTDIR\tMSITESTDIR\t1\n"
    "jamaica\taugustus\tjapan\tjordan\tFILEPATHBAD\tMSITESTDIR\t1\n"
    "kazakhstan\taugustus\t\tkiribati\tFILEPATHGOOD\tMSITESTDIR\t1\n"
    "laos\taugustus\tlatvia\tlebanon\tSourceDir\tMSITESTDIR\t1\n"
    "namibia\taugustus\tnauru\tkiribati\tSourceDir\tMSITESTDIR\t1\n"
    "pakistan\taugustus\tperu\tsfn|poland\tSourceDir\tMSITESTDIR\t1\n"
    "wildcard\taugustus\tapp*\twildcard\tSourceDir\tMSITESTDIR\t1\n"
    "single\taugustus\tf?o\tsingle\tSourceDir\tMSITESTDIR\t1\n"
    "wildcardnodest\taugustus\tbudd*\t\tSourceDir\tMSITESTDIR\t1\n"
    "singlenodest\taugustus\tb?r\t\tSourceDir\tMSITESTDIR\t1\n";

598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
static const char mov_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "CostInitialize\t\t100\n"
    "FileCost\t\t200\n"
    "ResolveSource\t\t300\n"
    "CostFinalize\t\t400\n"
    "InstallValidate\t\t500\n"
    "InstallInitialize\t\t600\n"
    "MoveFiles\t\t700\n"
    "mov_immediate\t\t701\n"
    "mov_deferred\t\t702\n"
    "InstallFiles\t\t800\n"
    "InstallFinalize\t\t900\n";

static const char mov_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "mov_immediate\t1\tcustom.dll\tmov_absent\n"
    "mov_deferred\t1025\tcustom.dll\tmov_present\n";

621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
static const char df_directory_dat[] =
    "Directory\tDirectory_Parent\tDefaultDir\n"
    "s72\tS72\tl255\n"
    "Directory\tDirectory\n"
    "THIS\tMSITESTDIR\tthis\n"
    "DOESNOT\tTHIS\tdoesnot\n"
    "NONEXISTENT\tDOESNOT\texist\n"
    "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
    "ProgramFilesFolder\tTARGETDIR\t.\n"
    "TARGETDIR\t\tSourceDir";

static const char df_duplicate_file_dat[] =
    "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
    "s72\ts72\ts72\tS255\tS72\n"
    "DuplicateFile\tFileKey\n"
    "maximus\tmaximus\tmaximus\taugustus\t\n"
    "caesar\tmaximus\tmaximus\t\tNONEXISTENT\n"
    "augustus\tnosuchcomponent\tmaximus\t\tMSITESTDIR\n";

static const char wrv_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
644 645
    "augustus\t{bafe0297-cbcc-4e08-8a78-7e9b83456eef}\tMSITESTDIR\t0\t\t\n"
    "caesar\t{bafe0298-cbcc-4e08-8a78-7e9b83456eef}\tMSITESTDIR\t1\t\t\n";
646 647 648 649 650 651 652 653 654 655 656 657 658 659

static const char wrv_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\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
    "feature2\t\tFeature2\tFeature2\t2\t1\tTARGETDIR\t1";

static const char wrv_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "feature\taugustus\n"
    "feature2\tcaesar";
660 661 662 663 664

static const char wrv_registry_dat[] =
    "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
    "s72\ti2\tl255\tL255\tL0\ts72\n"
    "Registry\tRegistry\n"
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
    "regdata0\t1\tmsitest\tsz\tstring\taugustus\n"
    "regdata1\t1\tmsitest\tmultisz\tone[~]two[~]three\taugustus\n"
    "regdata2\t1\tmsitest\texpandsz\t#%string\taugustus\n"
    "regdata3\t1\tmsitest\tdword\t#123\taugustus\n"
    "regdata4\t1\tmsitest\tbinary\t#x01234567\taugustus\n"
    "regdata5\t1\tmsitest\t\tdefault\taugustus\n"
    "regdata6\t1\tmsitest\\subkey\t*\t\taugustus\n"
    "regdata7\t1\tmsitest\\subkey\t*\t#%\taugustus\n"
    "regdata8\t1\tmsitest\\subkey\t*\t#x\taugustus\n"
    "regdata9\t1\tmsitest\\VisualStudio\\10.0\\AD7Metrics\\Exception\\{049EC4CC-30D2-4032-9256-EE18EB41B62B}\\Common Language Runtime Exceptions\\System.Workflow.ComponentModel.Serialization\\System.Workflow.ComponentModel.Serialization.WorkflowMarkupSerializationException\tlong\tkey\taugustus\n"
    "regdata10\t1\tmsitest\tValue1\t[~]one[~]\taugustus\n"
    "regdata11\t1\tmsitest\tValue2\t[~]two\taugustus\n"
    "regdata12\t1\tmsitest\tValue3\tone[~]\taugustus\n"
    "regdata13\t1\tmsitest\tValue4\tone[~]two\taugustus\n"
    "regdata14\t1\tmsitest\tValue5\t[~]one[~]two[~]three\taugustus\n"
    "regdata15\t1\tmsitest\tValue6\t[~]\taugustus\n"
    "regdata16\t1\tmsitest\tValue7\t[~]two\taugustus\n"
    "regdata17\t1\tmsitest\tformat\t[regdata17]\taugustus\n"
    "regdata18\t1\tmsitest\tsource\t#1\tcaesar\n"
    "regdata19\t1\tmsitest\\create\t+\t\taugustus\n"
    "regdata20\t1\tmsitest\\delete\t-\t\taugustus\n";

static const char wrv_remove_registry_dat[] =
    "RemoveRegistry\tRoot\tKey\tName\tComponent_\n"
    "s72\ti2\tl255\tL255\ts72\n"
    "RemoveRegistry\tRemoveRegistry\n"
    "regdata0\t1\tmsitest\tinstremove\taugustus\n"
    "regdata1\t1\tmsitest\\instremove\t-\taugustus\n";

static const char wrv_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\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"
    "RemoveRegistryValues\t\t4900\n"
705 706
    "rrv_immediate\tREMOVE\t4901\n"
    "rrv_deferred\tREMOVE\t4902\n"
707
    "WriteRegistryValues\t\t5000\n"
708 709
    "wrv_immediate\tNOT REMOVE\t5001\n"
    "wrv_deferred\tNOT REMOVE\t5002\n"
710 711 712
    "RegisterProduct\t\t6100\n"
    "PublishFeatures\t\t6200\n"
    "PublishProduct\t\t6300\n"
713
    "UnpublishFeatures\t\t6400\n"
714
    "InstallFinalize\t\t6600\n";
715

716 717 718 719 720 721 722 723 724
static const char wrv_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "wrv_immediate\t1\tcustom.dll\twrv_absent\n"
    "wrv_deferred\t1025\tcustom.dll\twrv_present\n"
    "rrv_immediate\t1\tcustom.dll\twrv_present\n"
    "rrv_deferred\t1025\tcustom.dll\twrv_absent\n";

725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
static const char cf_directory_dat[] =
    "Directory\tDirectory_Parent\tDefaultDir\n"
    "s72\tS72\tl255\n"
    "Directory\tDirectory\n"
    "FIRSTDIR\tMSITESTDIR\tfirst\n"
    "SECONDDIR\tMSITESTDIR\tsecond\n"
    "THIRDDIR\tMSITESTDIR\tthird\n"
    "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
    "ProgramFilesFolder\tTARGETDIR\t.\n"
    "TARGETDIR\t\tSourceDir";

static const char cf_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "One\t{F8CD42AC-9C38-48FE-8664-B35FD121012A}\tFIRSTDIR\t0\t\tone.txt\n"
    "Two\t{DE2DB02E-2DDF-4E34-8CF6-DCA13E29DF52}\tSECONDDIR\t0\t\ttwo.txt\n";

static const char cf_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\tOne\tThe One Feature\t1\t3\tFIRSTDIR\t0\n"
    "Two\t\tTwo\tThe Two Feature\t1\t3\tSECONDDIR\t0\n";

static const char cf_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "One\tOne\n"
    "Two\tTwo\n";

static const char cf_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "one.txt\tOne\tone.txt\t0\t\t\t0\t1\n"
    "two.txt\tTwo\ttwo.txt\t0\t\t\t0\t2\n";

764 765 766 767
static const char cf_create_folders_dat[] =
    "Directory_\tComponent_\n"
    "s72\ts72\n"
    "CreateFolder\tDirectory_\tComponent_\n"
768 769 770
    "FIRSTDIR\tOne\n"
    "SECONDDIR\tTwo\n"
    "THIRDDIR\tTwo\n";
771 772 773 774 775 776 777 778 779 780

static const char cf_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"
781 782
    "rfi_immediate\tREMOVE\t3501\n"
    "rfi_deferred\tREMOVE\t3502\n"
783
    "CreateFolders\t\t3700\n"
784 785
    "cf_immediate\tNOT REMOVE\t3701\n"
    "cf_deferred\tNOT REMOVE\t3702\n"
786
    "RemoveFolders\t\t3800\n"
787 788
    "rf_immediate\tREMOVE\t3801\n"
    "rf_deferred\tREMOVE\t3802\n"
789
    "InstallFiles\t\t4000\n"
790 791
    "ifi_immediate\tNOT REMOVE\t4001\n"
    "ifi_deferred\tNOT REMOVE\t4002\n"
792 793 794 795 796 797 798 799 800 801 802
    "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";

803 804 805 806
static const char cf_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
807 808 809 810
    "ifi_immediate\t1\tcustom.dll\tfile_absent\n"
    "ifi_deferred\t1025\tcustom.dll\tfile_present\n"
    "rfi_immediate\t1\tcustom.dll\tfile_present\n"
    "rfi_deferred\t1025\tcustom.dll\tfile_absent\n"
811 812 813 814 815
    "cf_immediate\t1\tcustom.dll\tcf_absent\n"
    "cf_deferred\t1025\tcustom.dll\tcf_present\n"
    "rf_immediate\t1\tcustom.dll\tcf_present\n"
    "rf_deferred\t1025\tcustom.dll\tcf_absent\n";

816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839
static const char sr_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "selfreg.dll\tselfreg\tselfreg.dll\t1000\t\t\t8192\t1\n";

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

static const char sr_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "selfreg\tselfreg\n";

static const char sr_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "selfreg\t{BB4C26FD-89D8-4E49-AF1C-DB4DCB5BF1B0}\tMSITESTDIR\t0\t\tselfreg.dll\n";

840 841 842 843
static const char sr_selfreg_dat[] =
    "File_\tCost\n"
    "s72\tI2\n"
    "SelfReg\tFile_\n"
844
    "selfreg.dll\t\n";
845 846 847 848 849 850 851

static const char sr_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "CostInitialize\t\t800\n"
    "FileCost\t\t900\n"
852 853 854 855 856
    "CostFinalize\t\t1000\n"
    "InstallValidate\t\t1400\n"
    "InstallInitialize\t\t1500\n"
    "ProcessComponents\t\t1600\n"
    "SelfUnregModules\t\t3800\n"
857 858
    "su_immediate\tREMOVE\t3801\n"
    "su_deferred\tREMOVE\t3802\n"
859
    "RemoveFiles\t\t3900\n"
860
    "InstallFiles\t\t4000\n"
861
    "SelfRegModules\t\t4100\n"
862 863
    "sr_immediate\tNOT REMOVE\t4101\n"
    "sr_deferred\tNOT REMOVE\t4102\n"
864
    "CreateShortcuts\t\t4600\n"
865 866 867
    "RegisterProduct\t\t5100\n"
    "PublishFeatures\t\t5200\n"
    "PublishProduct\t\t5300\n"
868
    "UnpublishFeatures\t\t5400\n"
869
    "InstallFinalize\t\t6600\n";
870

871 872 873 874 875 876 877 878 879
static const char sr_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "sr_immediate\t1\tcustom.dll\tsr_absent\n"
    "sr_deferred\t1025\tcustom.dll\tsr_present\n"
    "su_immediate\t1\tcustom.dll\tsr_present\n"
    "su_deferred\t1025\tcustom.dll\tsr_absent\n";

880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 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
static const char font_media_dat[] =
    "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
    "i2\ti4\tL64\tS255\tS32\tS72\n"
    "Media\tDiskId\n"
    "1\t3\t\t\tDISK1\t\n";

static const char font_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "font.ttf\tfonts\tfont.ttf\t1000\t\t\t8192\t1\n";

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

static const char font_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "fonts\t{F5920ED0-1183-4B8F-9330-86CE56557C05}\tMSITESTDIR\t0\t\tfont.ttf\n";

static const char font_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "fonts\tfonts\n";

static const char font_dat[] =
    "File_\tFontTitle\n"
    "s72\tS128\n"
    "Font\tFile_\n"
    "font.ttf\tmsi test font\n";

static const char font_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"
    "RemoveFiles\t\t3500\n"
    "InstallFiles\t\t4000\n"
    "RegisterFonts\t\t4100\n"
930 931
    "rf_immediate\tNOT REMOVE\t4101\n"
    "rf_deferred\tNOT REMOVE\t4102\n"
932
    "UnregisterFonts\t\t4200\n"
933 934
    "uf_immediate\tREMOVE\t4201\n"
    "uf_deferred\tREMOVE\t4202\n"
935 936 937 938
    "RegisterUser\t\t6000\n"
    "RegisterProduct\t\t6100\n"
    "PublishFeatures\t\t6300\n"
    "PublishProduct\t\t6400\n"
939
    "UnpublishFeatures\t\t6500\n"
940 941
    "InstallFinalize\t\t6600";

942 943 944 945 946 947 948 949 950
static const char font_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "rf_immediate\t1\tcustom.dll\tfont_absent\n"
    "rf_deferred\t1025\tcustom.dll\tfont_present\n"
    "uf_immediate\t1\tcustom.dll\tfont_present\n"
    "uf_deferred\t1025\tcustom.dll\tfont_absent\n";

951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 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 1007 1008 1009 1010 1011 1012 1013 1014
static const char vp_property_dat[] =
    "Property\tValue\n"
    "s72\tl0\n"
    "Property\tProperty\n"
    "HASUIRUN\t0\n"
    "INSTALLLEVEL\t3\n"
    "InstallMode\tTypical\n"
    "Manufacturer\tWine\n"
    "PIDTemplate\t###-#######\n"
    "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
    "ProductLanguage\t1033\n"
    "ProductName\tMSITEST\n"
    "ProductVersion\t1.1.1\n"
    "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
    "MSIFASTINSTALL\t1\n";

static const char vp_custom_action_dat[] =
    "Action\tType\tSource\tTarget\tISComments\n"
    "s72\ti2\tS64\tS0\tS255\n"
    "CustomAction\tAction\n"
    "SetProductID1\t51\tProductID\t1\t\n"
    "SetProductID2\t51\tProductID\t2\t\n"
    "TestProductID1\t19\t\t\tHalts installation\n"
    "TestProductID2\t19\t\t\tHalts installation\n";

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\t800\n"
    "FileCost\t\t900\n"
    "CostFinalize\t\t1000\n"
    "InstallValidate\t\t1400\n"
    "InstallInitialize\t\t1500\n"
    "SetProductID1\tSET_PRODUCT_ID=1\t3000\n"
    "SetProductID2\tSET_PRODUCT_ID=2\t3100\n"
    "ValidateProductID\t\t3200\n"
    "InstallExecute\t\t3300\n"
    "TestProductID1\tProductID=1\t3400\n"
    "TestProductID2\tProductID=\"123-1234567\"\t3500\n"
    "InstallFiles\t\t4000\n"
    "InstallFinalize\t\t6000\n";

static const char odbc_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "ODBCdriver.dll\todbc\tODBCdriver.dll\t1000\t\t\t8192\t1\n"
    "ODBCdriver2.dll\todbc\tODBCdriver2.dll\t1000\t\t\t8192\t2\n"
    "ODBCtranslator.dll\todbc\tODBCtranslator.dll\t1000\t\t\t8192\t3\n"
    "ODBCtranslator2.dll\todbc\tODBCtranslator2.dll\t1000\t\t\t8192\t4\n"
    "ODBCsetup.dll\todbc\tODBCsetup.dll\t1000\t\t\t8192\t5\n";

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

static const char odbc_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
1015
    "odbc\todbc64\n"
1016 1017 1018 1019 1020 1021
    "odbc\todbc\n";

static const char odbc_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
1022
    "odbc64\t{B6F3E4AF-35D1-4B72-9044-989F03E20A43}\tMSITESTDIR\t256\tMsix64\tODBCdriver.dll\n"
1023 1024 1025 1026 1027 1028
    "odbc\t{B6F3E4AE-35D1-4B72-9044-989F03E20A43}\tMSITESTDIR\t0\t\tODBCdriver.dll\n";

static const char odbc_driver_dat[] =
    "Driver\tComponent_\tDescription\tFile_\tFile_Setup\n"
    "s72\ts72\ts255\ts72\tS72\n"
    "ODBCDriver\tDriver\n"
1029 1030
    "64-bit driver\todbc64\tODBC test driver\tODBCdriver.dll\t\n"
    "64-bit driver2\todbc64\tODBC test driver2\tODBCdriver2.dll\tODBCsetup.dll\n"
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
    "ODBC test driver\todbc\tODBC test driver\tODBCdriver.dll\t\n"
    "ODBC test driver2\todbc\tODBC test driver2\tODBCdriver2.dll\tODBCsetup.dll\n";

static const char odbc_translator_dat[] =
    "Translator\tComponent_\tDescription\tFile_\tFile_Setup\n"
    "s72\ts72\ts255\ts72\tS72\n"
    "ODBCTranslator\tTranslator\n"
    "ODBC test translator\todbc\tODBC test translator\tODBCtranslator.dll\t\n"
    "ODBC test translator2\todbc\tODBC test translator2\tODBCtranslator2.dll\tODBCsetup.dll\n";

static const char odbc_datasource_dat[] =
    "DataSource\tComponent_\tDescription\tDriverDescription\tRegistration\n"
    "s72\ts72\ts255\ts255\ti2\n"
    "ODBCDataSource\tDataSource\n"
    "ODBC data source\todbc\tODBC data source\tODBC driver\t0\n";

static const char odbc_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"
    "ProcessComponents\t\t1600\n"
    "InstallODBC\t\t3000\n"
1059 1060
    "io_immediate\tNOT REMOVE\t3001\n"
    "io_deferred\tNOT REMOVE\t3002\n"
1061
    "RemoveODBC\t\t3100\n"
1062 1063
    "ro_immediate\tREMOVE\t3101\n"
    "ro_deferred\tREMOVE\t3102\n"
1064 1065 1066 1067 1068
    "RemoveFiles\t\t3900\n"
    "InstallFiles\t\t4000\n"
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1069
    "UnpublishFeatures\t\t5300\n"
1070 1071
    "InstallFinalize\t\t6000\n";

1072 1073 1074 1075 1076 1077 1078 1079 1080
static const char odbc_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "io_immediate\t1\tcustom.dll\todbc_absent\n"
    "io_deferred\t1025\tcustom.dll\todbc_present\n"
    "ro_immediate\t1\tcustom.dll\todbc_present\n"
    "ro_deferred\t1025\tcustom.dll\todbc_absent\n";

1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128
static const char odbc_media_dat[] =
    "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
    "i2\ti4\tL64\tS255\tS32\tS72\n"
    "Media\tDiskId\n"
    "1\t5\t\t\tDISK1\t\n";

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

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

static const char tl_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "typelib\ttypelib\n";

static const char tl_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "typelib\t{BB4C26FD-89D8-4E49-AF1C-DB4DCB5BF1B0}\tMSITESTDIR\t0\t\ttypelib.dll\n";

static const char tl_typelib_dat[] =
    "LibID\tLanguage\tComponent_\tVersion\tDescription\tDirectory_\tFeature_\tCost\n"
    "s38\ti2\ts72\tI4\tL128\tS72\ts38\tI4\n"
    "TypeLib\tLibID\tLanguage\tComponent_\n"
    "{EAC5166A-9734-4D91-878F-1DD02304C66C}\t0\ttypelib\t1793\t\tMSITESTDIR\ttypelib\t\n";

static const char tl_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"
    "ProcessComponents\t\t1600\n"
    "UnregisterTypeLibraries\t\t3100\n"
1129 1130
    "ut_immediate\tREMOVE\t3101\n"
    "ut_deferred\tREMOVE\t3102\n"
1131 1132 1133
    "RemoveFiles\t\t3200\n"
    "InstallFiles\t\t3300\n"
    "RegisterTypeLibraries\t\t3400\n"
1134 1135
    "rt_immediate\tNOT REMOVE\t3401\n"
    "rt_deferred\tNOT REMOVE\t3402\n"
1136 1137 1138
    "RegisterProduct\t\t5100\n"
    "PublishFeatures\t\t5200\n"
    "PublishProduct\t\t5300\n"
1139
    "UnpublishFeatures\t\t5400\n"
1140 1141
    "InstallFinalize\t\t6000\n";

1142 1143 1144 1145 1146 1147 1148 1149 1150
static const char tl_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "rt_immediate\t1\tcustom.dll\ttl_absent\n"
    "rt_deferred\t1025\tcustom.dll\ttl_present\n"
    "ut_immediate\t1\tcustom.dll\ttl_present\n"
    "ut_deferred\t1025\tcustom.dll\ttl_absent\n";

1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194
static const char crs_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "target.txt\tshortcut\ttarget.txt\t1000\t\t\t8192\t1\n";

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

static const char crs_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "shortcut\tshortcut\n";

static const char crs_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "shortcut\t{5D20E3C6-7206-498F-AC28-87AF2F9AD4CC}\tMSITESTDIR\t0\t\ttarget.txt\n";

static const char crs_shortcut_dat[] =
    "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n"
    "s72\ts72\tl128\ts72\ts72\tL255\tL255\tI2\tS72\tI2\tI2\tS72\n"
    "Shortcut\tShortcut\n"
    "shortcut\tMSITESTDIR\tshortcut\tshortcut\t[MSITESTDIR]target.txt\t\t\t\t\t\t\t\n";

static const char crs_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"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "InstallFiles\t\t2000\n"
    "RemoveShortcuts\t\t3000\n"
1195 1196
    "rs_immediate\tREMOVE\t3001\n"
    "rs_deferred\tREMOVE\t3002\n"
1197
    "CreateShortcuts\t\t3100\n"
1198 1199
    "cs_immediate\tNOT REMOVE\t3101\n"
    "cs_deferred\tNOT REMOVE\t3102\n"
1200 1201 1202
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1203
    "UnpublishFeatures\t\t5300\n"
1204 1205
    "InstallFinalize\t\t6000\n";

1206 1207 1208 1209 1210 1211 1212 1213 1214
static const char crs_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "cs_immediate\t1\tcustom.dll\tcrs_absent\n"
    "cs_deferred\t1025\tcustom.dll\tcrs_present\n"
    "rs_immediate\t1\tcustom.dll\tcrs_present\n"
    "rs_deferred\t1025\tcustom.dll\tcrs_absent\n";

1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258
static const char pub_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "english.txt\tpublish\tenglish.txt\t1000\t\t\t8192\t1\n";

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

static const char pub_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "publish\tpublish\n";

static const char pub_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "publish\t{B4EA0ACF-6238-426E-9C6D-7869F0F9C768}\tMSITESTDIR\t0\t\tenglish.txt\n";

static const char pub_publish_component_dat[] =
    "ComponentId\tQualifier\tComponent_\tAppData\tFeature_\n"
    "s38\ts255\ts72\tL255\ts38\n"
    "PublishComponent\tComponentId\tQualifier\tComponent_\n"
    "{92AFCBC0-9CA6-4270-8454-47C5EE2B8FAA}\tenglish.txt\tpublish\t\tpublish\n";

static const char pub_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"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "InstallFiles\t\t2000\n"
    "PublishComponents\t\t3000\n"
1259 1260
    "pub_immediate\tNOT REMOVE\t3001\n"
    "pub_deferred\tNOT REMOVE\t3002\n"
1261
    "UnpublishComponents\t\t3100\n"
1262 1263
    "unp_immediate\tREMOVE\t3101\n"
    "unp_deferred\tREMOVE\t3102\n"
1264 1265 1266
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1267
    "UnpublishFeatures\t\t5300\n"
1268 1269
    "InstallFinalize\t\t6000\n";

1270 1271 1272 1273 1274 1275 1276 1277 1278
static const char pub_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "pub_immediate\t1\tcustom.dll\tpub_absent\n"
    "pub_deferred\t1025\tcustom.dll\tpub_present\n"
    "unp_immediate\t1\tcustom.dll\tpub_present\n"
    "unp_deferred\t1025\tcustom.dll\tpub_absent\n";

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
static const char rd_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "original.txt\tduplicate\toriginal.txt\t1000\t\t\t8192\t1\n"
    "original2.txt\tduplicate\toriginal2.txt\t1000\t\t\t8192\t2\n"
    "original3.txt\tduplicate2\toriginal3.txt\t1000\t\t\t8192\t3\n";

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

static const char rd_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "duplicate\tduplicate\n";

static const char rd_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "duplicate\t{EB45D06A-ADFE-44E3-8D41-B7DE150E41AD}\tMSITESTDIR\t0\t\toriginal.txt\n"
    "duplicate2\t{B8BA60E0-B2E9-488E-9D0E-E60F25F04F97}\tMSITESTDIR\t0\tDUPLICATE2=1\toriginal3.txt\n";

static const char rd_duplicate_file_dat[] =
    "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
    "s72\ts72\ts72\tS255\tS72\n"
    "DuplicateFile\tFileKey\n"
    "duplicate\tduplicate\toriginal.txt\tduplicate.txt\t\n"
    "duplicate2\tduplicate\toriginal2.txt\t\tMSITESTDIR\n"
    "duplicate3\tduplicate2\toriginal3.txt\tduplicate2.txt\t\n";

static const char rd_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"
    "ProcessComponents\t\t1600\n"
    "RemoveDuplicateFiles\t\t1900\n"
1326 1327
    "rd_immediate\tREMOVE\t1901\n"
    "rd_deferred\tREMOVE\t1902\n"
1328 1329
    "InstallFiles\t\t2000\n"
    "DuplicateFiles\t\t2100\n"
1330 1331
    "df_immediate\tNOT REMOVE\t2101\n"
    "df_deferred\tNOT REMOVE\t2102\n"
1332 1333 1334
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1335
    "UnpublishFeatures\t\t5300\n"
1336 1337
    "InstallFinalize\t\t6000\n";

1338 1339 1340 1341 1342 1343 1344 1345 1346
static const char rd_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "df_immediate\t1\tcustom.dll\trd_absent\n"
    "df_deferred\t1025\tcustom.dll\trd_present\n"
    "rd_immediate\t1\tcustom.dll\trd_present\n"
    "rd_deferred\t1025\tcustom.dll\trd_absent\n";

1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400
static const char frp_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "product.txt\tproduct\tproduct.txt\t1000\t\t\t8192\t1\n";

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

static const char frp_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "product\tproduct\n";

static const char frp_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "product\t{44725EE0-EEA8-40BD-8162-A48224A2FEA1}\tMSITESTDIR\t0\t\tproduct.txt\n";

static const char frp_custom_action_dat[] =
    "Action\tType\tSource\tTarget\tISComments\n"
    "s72\ti2\tS64\tS0\tS255\n"
    "CustomAction\tAction\n"
    "TestProp\t19\t\t\tPROP set\n";

static const char frp_upgrade_dat[] =
    "UpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\tRemove\tActionProperty\n"
    "s38\tS20\tS20\tS255\ti4\tS255\ts72\n"
    "Upgrade\tUpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\n"
    "{4C0EAA15-0264-4E5A-8758-609EF142B92D}\t1.1.1\t2.2.2\t\t768\t\tPROP\n";

static const char frp_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "FindRelatedProducts\t\t50\n"
    "TestProp\tPROP AND NOT REMOVE\t51\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"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "InstallFiles\t\t2000\n"
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1401
    "UnpublishFeatures\t\t5300\n"
1402 1403
    "InstallFinalize\t\t6000\n";

1404
static const char ini_file_dat[] =
1405 1406 1407 1408 1409
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "inifile.txt\tinifile\tinifile.txt\t1000\t\t\t8192\t1\n";

1410
static const char ini_feature_dat[] =
1411 1412 1413 1414 1415
    "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
    "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
    "Feature\tFeature\n"
    "inifile\t\t\tinifile feature\t1\t2\tMSITESTDIR\t0\n";

1416
static const char ini_feature_comp_dat[] =
1417 1418 1419 1420 1421
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "inifile\tinifile\n";

1422
static const char ini_component_dat[] =
1423 1424 1425 1426 1427
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "inifile\t{A0F15705-4F57-4437-88C4-6C8B37ACC6DE}\tMSITESTDIR\t0\t\tinifile.txt\n";

1428
static const char ini_ini_file_dat[] =
1429 1430 1431 1432 1433
    "IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n"
    "s72\tl255\tS72\tl96\tl128\tl255\ti2\ts72\n"
    "IniFile\tIniFile\n"
    "inifile1\ttest.ini\tMSITESTDIR\tsection1\tkey1\tvalue1\t0\tinifile\n";

1434
static const char ini_remove_ini_file_dat[] =
1435 1436 1437 1438 1439
    "RemoveIniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n"
    "s72\tl255\tS72\tl96\tl128\tL255\ti2\ts72\n"
    "RemoveIniFile\tRemoveIniFile\n"
    "inifile1\ttest.ini\tMSITESTDIR\tsectionA\tkeyA\tvalueA\t2\tinifile\n";

1440
static const char ini_install_exec_seq_dat[] =
1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453
    "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"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "InstallFiles\t\t2000\n"
    "RemoveIniValues\t\t3000\n"
1454 1455
    "riv_immediate\tREMOVE\t3001\n"
    "riv_deferred\tREMOVE\t3002\n"
1456
    "WriteIniValues\t\t3100\n"
1457 1458
    "wiv_immediate\tNOT REMOVE\t3101\n"
    "wiv_deferred\tNOT REMOVE\t3102\n"
1459 1460 1461
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1462
    "UnpublishFeatures\t\t5300\n"
1463 1464
    "InstallFinalize\t\t6000\n";

1465 1466 1467 1468 1469 1470 1471 1472 1473
static const char ini_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "wiv_immediate\t1\tcustom.dll\tini_absent\n"
    "wiv_deferred\t1025\tcustom.dll\tini_present\n"
    "riv_immediate\t1\tcustom.dll\tini_present\n"
    "riv_deferred\t1025\tcustom.dll\tini_absent\n";

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
static const char rci_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "class.txt\tclass\tclass.txt\t1000\t\t\t8192\t1\n";

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

static const char rci_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "class\tclass\n";

static const char rci_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "class\t{89A98345-F8A1-422E-A48B-0250B5809F2D}\tMSITESTDIR\t0\t\tclass.txt\n";

static const char rci_appid_dat[] =
    "AppId\tRemoteServerName\tLocalService\tServiceParameters\tDllSurrogate\tActivateAtStorage\tRunAsInteractiveUser\n"
    "s38\tS255\tS255\tS255\tS255\tI2\tI2\n"
    "AppId\tAppId\n"
    "{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\t\t\t\t\t\t\n";

static const char rci_class_dat[] =
    "CLSID\tContext\tComponent_\tProgId_Default\tDescription\tAppId_\tFileTypeMask\tIcon_\tIconIndex\tDefInprocHandler\tArgument\tFeature_\tAttributes\n"
    "s38\ts32\ts72\tS255\tL255\tS38\tS255\tS72\tI2\tS32\tS255\ts38\tI2\n"
    "Class\tCLSID\tContext\tComponent_\n"
    "{110913E7-86D1-4BF3-9922-BA103FCDDDFA}\tLocalServer\tclass\t\tdescription\t{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\tmask1;mask2\t\t\t2\t\tclass\t\n";

static const char rci_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"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "InstallFiles\t\t2000\n"
    "UnregisterClassInfo\t\t3000\n"
1524 1525
    "uci_immediate\tREMOVE\t3001\n"
    "uci_deferred\tREMOVE\t3002\n"
1526
    "RegisterClassInfo\t\t4000\n"
1527 1528
    "rci_immediate\tNOT REMOVE\t4001\n"
    "rci_deferred\tNOT REMOVE\t4002\n"
1529 1530 1531
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1532
    "UnpublishFeatures\t\t5300\n"
1533 1534
    "InstallFinalize\t\t6000\n";

1535 1536 1537 1538 1539 1540 1541 1542 1543
static const char rci_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "rci_immediate\t1\tcustom.dll\trci_absent\n"
    "rci_deferred\t1025\tcustom.dll\trci_present\n"
    "uci_immediate\t1\tcustom.dll\trci_present\n"
    "uci_deferred\t1025\tcustom.dll\trci_absent\n";

1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
static const char rei_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "extension.txt\textension\textension.txt\t1000\t\t\t8192\t1\n";

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

static const char rei_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "extension\textension\n";

static const char rei_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "extension\t{9A3060D4-60BA-4A82-AB55-9FB148AD013C}\tMSITESTDIR\t0\t\textension.txt\n";

static const char rei_extension_dat[] =
    "Extension\tComponent_\tProgId_\tMIME_\tFeature_\n"
    "s255\ts72\tS255\tS64\ts38\n"
    "Extension\tExtension\tComponent_\n"
    "extension\textension\tProg.Id.1\t\textension\n";

static const char rei_verb_dat[] =
    "Extension_\tVerb\tSequence\tCommand\tArgument\n"
    "s255\ts32\tI2\tL255\tL255\n"
    "Verb\tExtension_\tVerb\n"
    "extension\tOpen\t1\t&Open\t/argument\n";

static const char rei_progid_dat[] =
    "ProgId\tProgId_Parent\tClass_\tDescription\tIcon_\tIconIndex\n"
    "s255\tS255\tS38\tL255\tS72\tI2\n"
    "ProgId\tProgId\n"
    "Prog.Id.1\t\t\tdescription\t\t\n";

static const char rei_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"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "InstallFiles\t\t2000\n"
    "UnregisterExtensionInfo\t\t3000\n"
1600 1601
    "uei_immediate\tREMOVE\t3001\n"
    "uei_deferred\tREMOVE\t3002\n"
1602
    "RegisterExtensionInfo\t\t4000\n"
1603 1604
    "rei_immediate\tNOT REMOVE\t4001\n"
    "rei_deferred\tNOT REMOVE\t4002\n"
1605 1606 1607
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1608
    "UnpublishFeatures\t\t5300\n"
1609 1610
    "InstallFinalize\t\t6000\n";

1611 1612 1613 1614 1615 1616 1617 1618 1619
static const char rei_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "rei_immediate\t1\tcustom.dll\trei_absent\n"
    "rei_deferred\t1025\tcustom.dll\trei_present\n"
    "uei_immediate\t1\tcustom.dll\trei_present\n"
    "uei_deferred\t1025\tcustom.dll\trei_absent\n";

1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660
static const char rpi_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "progid.txt\tprogid\tprogid.txt\t1000\t\t\t8192\t1\n";

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

static const char rpi_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "progid\tprogid\n";

static const char rpi_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "progid\t{89A98345-F8A1-422E-A48B-0250B5809F2D}\tMSITESTDIR\t0\t\tprogid.txt\n";

static const char rpi_appid_dat[] =
    "AppId\tRemoteServerName\tLocalService\tServiceParameters\tDllSurrogate\tActivateAtStorage\tRunAsInteractiveUser\n"
    "s38\tS255\tS255\tS255\tS255\tI2\tI2\n"
    "AppId\tAppId\n"
    "{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\t\t\t\t\t\t\n";

static const char rpi_class_dat[] =
    "CLSID\tContext\tComponent_\tProgId_Default\tDescription\tAppId_\tFileTypeMask\tIcon_\tIconIndex\tDefInprocHandler\tArgument\tFeature_\tAttributes\n"
    "s38\ts32\ts72\tS255\tL255\tS38\tS255\tS72\tI2\tS32\tS255\ts38\tI2\n"
    "Class\tCLSID\tContext\tComponent_\n"
    "{110913E7-86D1-4BF3-9922-BA103FCDDDFA}\tLocalServer\tprogid\tWinetest.Class.1\tdescription\t{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\tmask1;mask2\t\t\t2\t\tprogid\t\n"
    "{904E6BC9-F57F-4412-B460-D40DE2F256E2}\tLocalServer\tprogid\tWinetest.VerClass\tdescription\t{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\tmask1;mask2\t\t\t2\t\tprogid\t\n"
    "{57C413FB-CA02-498A-81F6-7E769BDB7C97}\tLocalServer\tprogid\t\tdescription\t{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\tmask1;mask2\t\t\t2\t\tprogid\t\n";

static const char rpi_extension_dat[] =
    "Extension\tComponent_\tProgId_\tMIME_\tFeature_\n"
    "s255\ts72\tS255\tS64\ts38\n"
1661 1662 1663 1664 1665 1666 1667 1668
    "Extension\tExtension\tComponent_\n"
    "winetest\tprogid\tWinetest.Extension\t\tprogid\n";

static const char rpi_verb_dat[] =
    "Extension_\tVerb\tSequence\tCommand\tArgument\n"
    "s255\ts32\tI2\tL255\tL255\n"
    "Verb\tExtension_\tVerb\n"
    "winetest\tOpen\t1\t&Open\t/argument\n";
1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681

static const char rpi_progid_dat[] =
    "ProgId\tProgId_Parent\tClass_\tDescription\tIcon_\tIconIndex\n"
    "s255\tS255\tS38\tL255\tS72\tI2\n"
    "ProgId\tProgId\n"
    "Winetest.Class.1\t\t{110913E7-86D1-4BF3-9922-BA103FCDDDFA}\tdescription\t\t\n"
    "Winetest.Class\tWinetest.Class.1\t\tdescription\t\t\n"
    "Winetest.Class.2\t\t{110913E7-86D1-4BF3-9922-BA103FCDDDFA}\tdescription\t\t\n"
    "Winetest.VerClass.1\t\t{904E6BC9-F57F-4412-B460-D40DE2F256E2}\tdescription\t\t\n"
    "Winetest.VerClass\tWinetest.VerClass.1\t\tdescription\t\t\n"
    "Winetest.NoProgIdClass.1\t\t{57C413FB-CA02-498A-81F6-7E769BDB7C97}\tdescription\t\t\n"
    "Winetest.NoProgIdClass\tWinetest.NoProgIdClass.1\t\tdescription\t\t\n"
    "Winetest.Orphaned\t\t\tdescription\t\t\n"
1682 1683
    "Winetest.Orphaned2\t\t\tdescription\t\t\n"
    "Winetest.Extension\t\t\tdescription\t\t\n";
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697

static const char rpi_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"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "UnregisterClassInfo\t\t3000\n"
1698
    "UnregisterExtensionInfo\t\t3200\n"
1699
    "UnregisterProgIdInfo\t\t3400\n"
1700 1701
    "upi_immediate\tREMOVE\t3401\n"
    "upi_deferred\tREMOVE\t3402\n"
1702
    "InstallFiles\t\t3600\n"
1703
    "RegisterClassInfo\t\t4000\n"
1704
    "RegisterExtensionInfo\t\t4200\n"
1705
    "RegisterProgIdInfo\t\t4400\n"
1706 1707
    "rpi_immediate\tNOT REMOVE\t4401\n"
    "rpi_deferred\tNOT REMOVE\t4402\n"
1708 1709 1710
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1711
    "UnpublishFeatures\t\t5300\n"
1712 1713
    "InstallFinalize\t\t6000\n";

1714 1715 1716 1717 1718 1719 1720 1721 1722
static const char rpi_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "rpi_immediate\t1\tcustom.dll\trpi_absent\n"
    "rpi_deferred\t1025\tcustom.dll\trpi_present\n"
    "upi_immediate\t1\tcustom.dll\trpi_present\n"
    "upi_deferred\t1025\tcustom.dll\trpi_absent\n";

1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779
static const char rmi_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "mime.txt\tmime\tmime.txt\t1000\t\t\t8192\t1\n";

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

static const char rmi_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "mime\tmime\n";

static const char rmi_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "mime\t{A1D630CE-13A7-4882-AFDD-148E2BBAFC6D}\tMSITESTDIR\t0\t\tmime.txt\n";

static const char rmi_extension_dat[] =
    "Extension\tComponent_\tProgId_\tMIME_\tFeature_\n"
    "s255\ts72\tS255\tS64\ts38\n"
    "Extension\tExtension\tComponent_\n"
    "mime\tmime\t\tmime/type\tmime\n";

static const char rmi_verb_dat[] =
    "Extension_\tVerb\tSequence\tCommand\tArgument\n"
    "s255\ts32\tI2\tL255\tL255\n"
    "Verb\tExtension_\tVerb\n"
    "mime\tOpen\t1\t&Open\t/argument\n";

static const char rmi_mime_dat[] =
    "ContentType\tExtension_\tCLSID\n"
    "s64\ts255\tS38\n"
    "MIME\tContentType\n"
    "mime/type\tmime\t\n";

static const char rmi_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"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "InstallFiles\t\t2000\n"
    "UnregisterExtensionInfo\t\t3000\n"
    "UnregisterMIMEInfo\t\t3500\n"
1780 1781
    "umi_immediate\tREMOVE\t3501\n"
    "umi_deferred\tREMOVE\t3502\n"
1782 1783
    "RegisterExtensionInfo\t\t4000\n"
    "RegisterMIMEInfo\t\t4500\n"
1784 1785
    "rmi_immediate\tNOT REMOVE\t4501\n"
    "rmi_deferred\tNOT REMOVE\t4502\n"
1786 1787 1788
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1789
    "UnpublishFeatures\t\t5300\n"
1790 1791
    "InstallFinalize\t\t6000\n";

1792 1793 1794 1795 1796 1797 1798 1799 1800
static const char rmi_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "rmi_immediate\t1\tcustom.dll\trmi_absent\n"
    "rmi_deferred\t1025\tcustom.dll\trmi_present\n"
    "umi_immediate\t1\tcustom.dll\trmi_present\n"
    "umi_deferred\t1025\tcustom.dll\trmi_absent\n";

1801 1802 1803 1804
static const char pa_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
1805
    "fake_local.txt\tfake_local\tfake_local.txt\t1000\t\t\t8192\t1\n"
1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824
    "win32.txt\twin32\twin32.txt\t1000\t\t\t8192\t1\n"
    "manifest.txt\twin32\tmanifest.txt\t1000\t\t\t8192\t1\n"
    "win32_local.txt\twin32_local\twin32_local.txt\t1000\t\t\t8192\t1\n"
    "manifest_local.txt\twin32_local\tmanifest_local.txt\t1000\t\t\t8192\t1\n"
    "dotnet.txt\tdotnet\tdotnet.txt\t1000\t\t\t8192\t1\n"
    "dotnet_local.txt\tdotnet_local\tdotnet_local.txt\t1000\t\t\t8192\t1\n"
    "application_win32.txt\twin32_local\tapplication_win32.txt\t1000\t\t\t8192\t1\n"
    "application_dotnet.txt\tdotnet_local\tapplication_dotnet.txt\t1000\t\t\t8192\t1\n";

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

static const char pa_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
1825
    "assembly\tfake_local\n"
1826 1827 1828 1829 1830 1831 1832 1833 1834
    "assembly\twin32\n"
    "assembly\twin32_local\n"
    "assembly\tdotnet\n"
    "assembly\tdotnet_local\n";

static const char pa_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
1835
    "fake_local\t{F515549D-7E61-425D-AAC1-9BEF2E066D06}\tMSITESTDIR\t0\t\tfake_local.txt\n"
1836 1837 1838 1839 1840 1841 1842 1843 1844
    "win32\t{F515549E-7E61-425D-AAC1-9BEF2E066D06}\tMSITESTDIR\t0\t\twin32.txt\n"
    "win32_local\t{D34D3FBA-6789-4E57-AD1A-1281297DC201}\tMSITESTDIR\t0\t\twin32_local.txt\n"
    "dotnet\t{8943164F-2B31-4C09-A894-493A8CBDE0A4}\tMSITESTDIR\t0\t\tdotnet.txt\n"
    "dotnet_local\t{4E8567E8-8EAE-4E36-90F1-B99D33C663F8}\tMSITESTDIR\t0\t\tdotnet_local.txt\n";

static const char pa_msi_assembly_dat[] =
    "Component_\tFeature_\tFile_Manifest\tFile_Application\tAttributes\n"
    "s72\ts38\tS72\tS72\tI2\n"
    "MsiAssembly\tComponent_\n"
1845
    "fake_local\tassembly\t\tnonexistent.txt\t0\n"
1846 1847 1848 1849 1850 1851 1852 1853 1854
    "win32\tassembly\tmanifest.txt\t\t1\n"
    "win32_local\tassembly\tmanifest_local.txt\tapplication_win32.txt\t1\n"
    "dotnet\tassembly\t\t\t0\n"
    "dotnet_local\tassembly\t\tapplication_dotnet.txt\t0\n";

static const char pa_msi_assembly_name_dat[] =
    "Component_\tName\tValue\n"
    "s72\ts255\ts255\n"
    "MsiAssemblyName\tComponent_\tName\n"
1855 1856 1857 1858 1859
    "fake_local\tName\tWine.Fake.Application.Assembly\n"
    "fake_local\tprocessorArchitecture\tx86\n"
    "fake_local\tpublicKeyToken\tabcdef0123456789\n"
    "fake_local\ttype\twin32\n"
    "fake_local\tversion\t1.0.0.0\n"
1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892
    "win32\tName\tWine.Win32.Assembly\n"
    "win32\tprocessorArchitecture\tx86\n"
    "win32\tpublicKeyToken\tabcdef0123456789\n"
    "win32\ttype\twin32\n"
    "win32\tversion\t1.0.0.0\n"
    "win32_local\tName\tWine.Win32.Local.Assembly\n"
    "win32_local\tprocessorArchitecture\tx86\n"
    "win32_local\tpublicKeyToken\tabcdef0123456789\n"
    "win32_local\ttype\twin32\n"
    "win32_local\tversion\t1.0.0.0\n"
    "dotnet\tName\tWine.Dotnet.Assembly\n"
    "dotnet\tprocessorArchitecture\tMSIL\n"
    "dotnet\tpublicKeyToken\tabcdef0123456789\n"
    "dotnet\tculture\tneutral\n"
    "dotnet\tversion\t1.0.0.0\n"
    "dotnet_local\tName\tWine.Dotnet.Local.Assembly\n"
    "dotnet_local\tprocessorArchitecture\tMSIL\n"
    "dotnet_local\tpublicKeyToken\tabcdef0123456789\n"
    "dotnet_local\tculture\tneutral\n"
    "dotnet_local\tversion\t1.0.0.0\n";

static const char pa_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"
    "ProcessComponents\t\t1600\n"
    "MsiPublishAssemblies\t\t3000\n"
1893 1894
    "pa_immediate\tNOT REMOVE AND NOT ALLUSERS\t3001\n"
    "pa_deferred\tNOT REMOVE AND NOT ALLUSERS\t3002\n"
1895
    "MsiUnpublishAssemblies\t\t4000\n"
1896 1897
    "ua_immediate\tREMOVE AND NOT ALLUSERS\t4001\n"
    "ua_deferred\tREMOVE AND NOT ALLUSERS\t4002\n"
1898 1899 1900
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1901
    "UnpublishFeatures\t\t5300\n"
1902 1903
    "InstallFinalize\t\t6000\n";

1904 1905 1906 1907 1908 1909 1910 1911 1912
static const char pa_custom_action_dat[] =
    "Action\tType\tSource\tTarget\n"
    "s72\ti2\tS64\tS0\n"
    "CustomAction\tAction\n"
    "pa_immediate\t1\tcustom.dll\tpa_absent\n"
    "pa_deferred\t1025\tcustom.dll\tpa_present\n"
    "ua_immediate\t1\tcustom.dll\tpa_present\n"
    "ua_deferred\t1025\tcustom.dll\tpa_absent\n";

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 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
static const char rep_file_dat[] =
    "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
    "File\tFile\n"
    "rep.txt\trep\trep.txt\t1000\t\t\t8192\t1\n";

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

static const char rep_feature_comp_dat[] =
    "Feature_\tComponent_\n"
    "s38\ts72\n"
    "FeatureComponents\tFeature_\tComponent_\n"
    "rep\trep\n";

static const char rep_component_dat[] =
    "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
    "s72\tS38\ts72\ti2\tS255\tS72\n"
    "Component\tComponent\n"
    "rep\t{A24FAF2A-3B2E-41EF-AA78-331542E1A29D}\tMSITESTDIR\t0\t\trep.txt\n";

static const char rep_upgrade_dat[] =
    "UpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\tRemove\tActionProperty\n"
    "s38\tS20\tS20\tS255\ti4\tS255\ts72\n"
    "Upgrade\tUpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\n"
    "{2967C1CC-34D4-42EE-8D96-CD6836F192BF}\t\t\t\t256\t\tPRODUCT\n";

static const char rep_property_dat[] =
    "Property\tValue\n"
    "s72\tl0\n"
    "Property\tProperty\n"
    "HASUIRUN\t0\n"
    "INSTALLLEVEL\t3\n"
    "InstallMode\tTypical\n"
    "Manufacturer\tWine\n"
    "PIDTemplate\t###-#######\n"
    "ProductCode\t{1699F0BB-0B61-4A89-AFE4-CFD60DFD76F3}\n"
    "ProductLanguage\t1033\n"
    "ProductName\tMSITEST\n"
    "ProductVersion\t1.1.1\n"
    "UpgradeCode\t{2967C1CC-34D4-42EE-8D96-CD6836F192BF}\n"
    "PRODUCT\t2F41860D-7B4C-4DA7-BED9-B64F26594C56\n"
    "MSIFASTINSTALL\t1\n";

static const char rep_install_exec_seq_dat[] =
    "Action\tCondition\tSequence\n"
    "s72\tS255\tI2\n"
    "InstallExecuteSequence\tAction\n"
    "FindRelatedProducts\t\t100\n"
    "CostInitialize\t\t800\n"
    "FileCost\t\t900\n"
    "CostFinalize\t\t1000\n"
    "InstallValidate\t\t1400\n"
    "RemoveExistingProducts\t\t1499\n"
    "InstallInitialize\t\t1500\n"
    "ProcessComponents\t\t1600\n"
    "RemoveFiles\t\t1700\n"
    "InstallFiles\t\t2000\n"
    "UnregisterExtensionInfo\t\t3000\n"
    "UnregisterMIMEInfo\t\t3500\n"
    "RegisterExtensionInfo\t\t4000\n"
    "RegisterMIMEInfo\t\t4500\n"
    "RegisterProduct\t\t5000\n"
    "PublishFeatures\t\t5100\n"
    "PublishProduct\t\t5200\n"
1981
    "UnpublishFeatures\t\t5300\n"
1982 1983
    "InstallFinalize\t\t6000\n";

1984 1985 1986 1987 1988 1989 1990
static const msi_table env_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
1991
    ADD_TABLE(env_install_exec_seq),
1992
    ADD_TABLE(env_custom_action),
1993 1994
    ADD_TABLE(media),
    ADD_TABLE(property),
1995
    ADD_TABLE(env_environment)
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
};

static const msi_table pp_tables[] =
{
    ADD_TABLE(pp_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rof_feature_comp),
    ADD_TABLE(rof_file),
    ADD_TABLE(pp_install_exec_seq),
2006
    ADD_TABLE(pp_custom_action),
2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
};

static const msi_table ppc_tables[] =
{
    ADD_TABLE(ppc_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ppc_feature_comp),
    ADD_TABLE(ppc_file),
    ADD_TABLE(pp_install_exec_seq),
2019
    ADD_TABLE(pp_custom_action),
2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043
    ADD_TABLE(ppc_media),
    ADD_TABLE(property),
};

static const msi_table rem_tables[] =
{
    ADD_TABLE(rem_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(rem_feature_comp),
    ADD_TABLE(rem_file),
    ADD_TABLE(rem_install_exec_seq),
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
    ADD_TABLE(rem_remove_files),
};

static const msi_table mov_tables[] =
{
    ADD_TABLE(cwd_component),
    ADD_TABLE(directory),
    ADD_TABLE(rof_feature),
    ADD_TABLE(ci2_feature_comp),
    ADD_TABLE(ci2_file),
2044 2045
    ADD_TABLE(mov_install_exec_seq),
    ADD_TABLE(mov_custom_action),
2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067
    ADD_TABLE(rof_media),
    ADD_TABLE(property),
    ADD_TABLE(mov_move_file),
};

static const msi_table df_tables[] =
{
    ADD_TABLE(rof_component),
    ADD_TABLE(df_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),
    ADD_TABLE(df_duplicate_file),
};

static const msi_table wrv_tables[] =
{
    ADD_TABLE(wrv_component),
    ADD_TABLE(directory),
2068 2069
    ADD_TABLE(wrv_feature),
    ADD_TABLE(wrv_feature_comp),
2070
    ADD_TABLE(wrv_install_exec_seq),
2071
    ADD_TABLE(wrv_custom_action),
2072
    ADD_TABLE(property),
2073
    ADD_TABLE(media),
2074
    ADD_TABLE(wrv_registry),
2075
    ADD_TABLE(wrv_remove_registry),
2076 2077 2078 2079
};

static const msi_table cf_tables[] =
{
2080 2081 2082 2083 2084
    ADD_TABLE(cf_component),
    ADD_TABLE(cf_directory),
    ADD_TABLE(cf_feature),
    ADD_TABLE(cf_feature_comp),
    ADD_TABLE(cf_file),
2085 2086
    ADD_TABLE(cf_create_folders),
    ADD_TABLE(cf_install_exec_seq),
2087
    ADD_TABLE(cf_custom_action),
2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table sss_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(sss_install_exec_seq),
    ADD_TABLE(sss_service_control),
2101
    ADD_TABLE(sss_custom_action),
2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table sds_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(sds_install_exec_seq),
2114
    ADD_TABLE(sds_custom_action),
2115 2116 2117 2118 2119 2120
    ADD_TABLE(service_control),
    ADD_TABLE(service_install),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2121 2122 2123 2124 2125 2126 2127
static const msi_table sis_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
2128 2129
    ADD_TABLE(sis_install_exec_seq),
    ADD_TABLE(sis_custom_action),
2130 2131 2132 2133 2134
    ADD_TABLE(service_install2),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2135 2136
static const msi_table sr_tables[] =
{
2137
    ADD_TABLE(sr_component),
2138
    ADD_TABLE(directory),
2139 2140 2141
    ADD_TABLE(sr_feature),
    ADD_TABLE(sr_feature_comp),
    ADD_TABLE(sr_file),
2142 2143
    ADD_TABLE(sr_selfreg),
    ADD_TABLE(sr_install_exec_seq),
2144
    ADD_TABLE(sr_custom_action),
2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table font_tables[] =
{
    ADD_TABLE(font_component),
    ADD_TABLE(directory),
    ADD_TABLE(font_feature),
    ADD_TABLE(font_feature_comp),
    ADD_TABLE(font_file),
    ADD_TABLE(font),
    ADD_TABLE(font_install_exec_seq),
2158
    ADD_TABLE(font_custom_action),
2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186
    ADD_TABLE(font_media),
    ADD_TABLE(property)
};

static const msi_table vp_tables[] =
{
    ADD_TABLE(component),
    ADD_TABLE(directory),
    ADD_TABLE(feature),
    ADD_TABLE(feature_comp),
    ADD_TABLE(file),
    ADD_TABLE(vp_custom_action),
    ADD_TABLE(vp_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(vp_property)
};

static const msi_table odbc_tables[] =
{
    ADD_TABLE(odbc_component),
    ADD_TABLE(directory),
    ADD_TABLE(odbc_feature),
    ADD_TABLE(odbc_feature_comp),
    ADD_TABLE(odbc_file),
    ADD_TABLE(odbc_driver),
    ADD_TABLE(odbc_translator),
    ADD_TABLE(odbc_datasource),
    ADD_TABLE(odbc_install_exec_seq),
2187
    ADD_TABLE(odbc_custom_action),
2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200
    ADD_TABLE(odbc_media),
    ADD_TABLE(property)
};

static const msi_table tl_tables[] =
{
    ADD_TABLE(tl_component),
    ADD_TABLE(directory),
    ADD_TABLE(tl_feature),
    ADD_TABLE(tl_feature_comp),
    ADD_TABLE(tl_file),
    ADD_TABLE(tl_typelib),
    ADD_TABLE(tl_install_exec_seq),
2201
    ADD_TABLE(tl_custom_action),
2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table crs_tables[] =
{
    ADD_TABLE(crs_component),
    ADD_TABLE(directory),
    ADD_TABLE(crs_feature),
    ADD_TABLE(crs_feature_comp),
    ADD_TABLE(crs_file),
    ADD_TABLE(crs_shortcut),
    ADD_TABLE(crs_install_exec_seq),
2215
    ADD_TABLE(crs_custom_action),
2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table pub_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(pub_component),
    ADD_TABLE(pub_feature),
    ADD_TABLE(pub_feature_comp),
    ADD_TABLE(pub_file),
    ADD_TABLE(pub_publish_component),
    ADD_TABLE(pub_install_exec_seq),
2229
    ADD_TABLE(pub_custom_action),
2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table rd_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(rd_component),
    ADD_TABLE(rd_feature),
    ADD_TABLE(rd_feature_comp),
    ADD_TABLE(rd_file),
    ADD_TABLE(rd_duplicate_file),
    ADD_TABLE(rd_install_exec_seq),
2243
    ADD_TABLE(rd_custom_action),
2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table frp_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(frp_component),
    ADD_TABLE(frp_feature),
    ADD_TABLE(frp_feature_comp),
    ADD_TABLE(frp_file),
    ADD_TABLE(frp_upgrade),
    ADD_TABLE(frp_custom_action),
    ADD_TABLE(frp_install_exec_seq),
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2262
static const msi_table ini_tables[] =
2263 2264
{
    ADD_TABLE(directory),
2265 2266 2267 2268 2269 2270 2271
    ADD_TABLE(ini_component),
    ADD_TABLE(ini_feature),
    ADD_TABLE(ini_feature_comp),
    ADD_TABLE(ini_file),
    ADD_TABLE(ini_ini_file),
    ADD_TABLE(ini_remove_ini_file),
    ADD_TABLE(ini_install_exec_seq),
2272
    ADD_TABLE(ini_custom_action),
2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table rci_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(rci_component),
    ADD_TABLE(rci_feature),
    ADD_TABLE(rci_feature_comp),
    ADD_TABLE(rci_file),
    ADD_TABLE(rci_appid),
    ADD_TABLE(rci_class),
    ADD_TABLE(rci_install_exec_seq),
2287
    ADD_TABLE(rci_custom_action),
2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302
    ADD_TABLE(media),
    ADD_TABLE(property)
};

static const msi_table rei_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(rei_component),
    ADD_TABLE(rei_feature),
    ADD_TABLE(rei_feature_comp),
    ADD_TABLE(rei_file),
    ADD_TABLE(rei_extension),
    ADD_TABLE(rei_verb),
    ADD_TABLE(rei_progid),
    ADD_TABLE(rei_install_exec_seq),
2303
    ADD_TABLE(rei_custom_action),
2304 2305 2306 2307
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2308 2309 2310 2311 2312 2313 2314 2315 2316 2317
static const msi_table rpi_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(rpi_component),
    ADD_TABLE(rpi_feature),
    ADD_TABLE(rpi_feature_comp),
    ADD_TABLE(rpi_file),
    ADD_TABLE(rpi_appid),
    ADD_TABLE(rpi_class),
    ADD_TABLE(rpi_extension),
2318
    ADD_TABLE(rpi_verb),
2319 2320
    ADD_TABLE(rpi_progid),
    ADD_TABLE(rpi_install_exec_seq),
2321
    ADD_TABLE(rpi_custom_action),
2322 2323 2324 2325
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336
static const msi_table rmi_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(rmi_component),
    ADD_TABLE(rmi_feature),
    ADD_TABLE(rmi_feature_comp),
    ADD_TABLE(rmi_file),
    ADD_TABLE(rmi_extension),
    ADD_TABLE(rmi_verb),
    ADD_TABLE(rmi_mime),
    ADD_TABLE(rmi_install_exec_seq),
2337
    ADD_TABLE(rmi_custom_action),
2338 2339 2340 2341
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2342 2343 2344 2345 2346 2347 2348 2349 2350 2351
static const msi_table pa_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(pa_component),
    ADD_TABLE(pa_feature),
    ADD_TABLE(pa_feature_comp),
    ADD_TABLE(pa_file),
    ADD_TABLE(pa_msi_assembly),
    ADD_TABLE(pa_msi_assembly_name),
    ADD_TABLE(pa_install_exec_seq),
2352
    ADD_TABLE(pa_custom_action),
2353 2354 2355 2356
    ADD_TABLE(media),
    ADD_TABLE(property)
};

2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369
static const msi_table rep_tables[] =
{
    ADD_TABLE(directory),
    ADD_TABLE(rep_component),
    ADD_TABLE(rep_feature),
    ADD_TABLE(rep_feature_comp),
    ADD_TABLE(rep_file),
    ADD_TABLE(rep_upgrade),
    ADD_TABLE(rep_property),
    ADD_TABLE(rep_install_exec_seq),
    ADD_TABLE(media)
};

2370 2371 2372 2373 2374 2375 2376 2377 2378 2379
/* cabinet definitions */

/* make the max size large so there is only one cab file */
#define MEDIA_SIZE          0x7FFFFFFF

static void init_functionpointers(void)
{
    HMODULE hmsi = GetModuleHandleA("msi.dll");
    HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
    HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
2380
    HMODULE hsrclient = LoadLibraryA("srclient.dll");
2381 2382 2383 2384 2385 2386 2387 2388 2389 2390

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

    GET_PROC(hmsi, MsiQueryComponentStateA);
    GET_PROC(hmsi, MsiSourceListEnumSourcesA);
    GET_PROC(hmsi, MsiSourceListGetInfoA);
    GET_PROC(hmsi, MsiGetComponentPathExA);
2391
    GET_PROC(hmsi, MsiQueryFeatureStateExA);
2392 2393 2394 2395 2396 2397 2398 2399 2400 2401

    GET_PROC(hadvapi32, RegDeleteKeyExA)
    GET_PROC(hkernel32, IsWow64Process)

    GET_PROC(hsrclient, SRRemoveRestorePoint);
    GET_PROC(hsrclient, SRSetRestorePointA);

#undef GET_PROC
}

2402
static char *get_user_sid(void)
2403 2404
{
    HANDLE token;
2405 2406 2407
    DWORD size = 0;
    TOKEN_USER *user;
    char *usersid = NULL;
2408

2409 2410 2411 2412 2413
    OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
    GetTokenInformation(token, TokenUser, NULL, size, &size);

    user = HeapAlloc(GetProcessHeap(), 0, size);
    GetTokenInformation(token, TokenUser, user, size, &size);
2414
    ConvertSidToStringSidA(user->User.Sid, &usersid);
2415
    HeapFree(GetProcessHeap(), 0, user);
2416 2417

    CloseHandle(token);
2418
    return usersid;
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435
}

static void create_test_files(void)
{
    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\one.txt", 100);
    CreateDirectoryA("msitest\\first", NULL);
    create_file("msitest\\first\\two.txt", 100);
    CreateDirectoryA("msitest\\second", NULL);
    create_file("msitest\\second\\three.txt", 100);

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

    create_file("msitest\\filename", 100);
    create_file("msitest\\service.exe", 100);
2436
    create_file("msitest\\service2.exe", 100);
2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449

    DeleteFileA("four.txt");
    DeleteFileA("five.txt");
}

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");
    DeleteFileA("msitest\\service.exe");
2450
    DeleteFileA("msitest\\service2.exe");
2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486
    DeleteFileA("msitest\\filename");
    RemoveDirectoryA("msitest\\second");
    RemoveDirectoryA("msitest\\first");
    RemoveDirectoryA("msitest");
}

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)
        trace("Failed to remove the restore point : %08x\n", res);
}

static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
{
    if (pRegDeleteKeyExA)
        return pRegDeleteKeyExA( key, subkey, access, 0 );
    return RegDeleteKeyA( key, subkey );
}

static void delete_pfmsitest_files(void)
{
2487
    SHFILEOPSTRUCTA shfl;
2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499
    CHAR path[MAX_PATH+11];

    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;
    shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT | FOF_NOERRORUI;

2500
    SHFileOperationA(&shfl);
2501 2502 2503 2504 2505 2506

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

2507
static void check_reg_str(HKEY prodkey, LPCSTR name, LPCSTR expected, BOOL bcase, BOOL todo, DWORD line)
2508 2509 2510 2511 2512 2513 2514
{
    char val[MAX_PATH];
    DWORD size, type;
    LONG res;

    size = MAX_PATH;
    val[0] = '\0';
2515 2516 2517 2518
    res = RegQueryValueExA(prodkey, name, NULL, &type, (BYTE *)val, &size);
    ok_(__FILE__, line)(!res, "Failed to query value, error %u\n", res);
    ok_(__FILE__, line)(type == REG_SZ || type == REG_EXPAND_SZ, "Got wrong type %u\n", type);
    todo_wine_if (todo)
2519
    {
2520 2521 2522 2523
        if (bcase)
            ok_(__FILE__, line)(!strcmp(val, expected), "got %s\n", debugstr_a(val));
        else
            ok_(__FILE__, line)(!strcasecmp(val, expected), "got %s\n", debugstr_a(val));
2524 2525 2526
    }
}

2527 2528 2529
static void check_reg_multi(HKEY prodkey, const char *name, const char *expect, DWORD line)
{
    char val[MAX_PATH];
2530 2531
    DWORD expect_size = 0, size, type;
    const char *p;
2532 2533
    LONG res;

2534 2535 2536 2537
    for (p = expect; *p; p += strlen(p) + 1)
        ;
    expect_size = (p + 1) - expect;

2538 2539 2540
    size = MAX_PATH;
    val[0] = '\0';
    res = RegQueryValueExA(prodkey, name, NULL, &type, (BYTE *)val, &size);
2541 2542
    ok_(__FILE__, line)(!res, "Failed to query value, error %u\n", res);
    ok_(__FILE__, line)(type == REG_MULTI_SZ, "Got wrong type %u\n", type);
2543 2544
    ok_(__FILE__, line)(size == expect_size, "expected size %u, got %u\n", expect_size, size);
    ok_(__FILE__, line)(!memcmp(val, expect, size), "got %s\n", debugstr_an(val, size));
2545 2546
}

2547
static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD expected, BOOL todo, DWORD line)
2548 2549 2550 2551 2552
{
    DWORD val, size, type;
    LONG res;

    size = sizeof(DWORD);
2553 2554 2555 2556 2557
    res = RegQueryValueExA(prodkey, name, NULL, &type, (BYTE *)&val, &size);
    ok_(__FILE__, line)(!res, "Failed to query value, error %u\n", res);
    ok_(__FILE__, line)(type == REG_DWORD, "Got wrong type %u\n", type);
    todo_wine_if (todo)
        ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected, val);
2558 2559 2560
}

#define CHECK_REG_STR(prodkey, name, expected) \
2561
    check_reg_str(prodkey, name, expected, TRUE, FALSE, __LINE__);
2562 2563

#define CHECK_DEL_REG_STR(prodkey, name, expected) \
2564
    do { \
2565 2566 2567 2568 2569 2570 2571
        check_reg_str(prodkey, name, expected, TRUE, FALSE, __LINE__); \
        RegDeleteValueA(prodkey, name); \
    } while(0)

#define CHECK_DEL_REG_STR_TODO(prodkey, name, expected) \
    do { \
        check_reg_str(prodkey, name, expected, TRUE, TRUE, __LINE__); \
2572 2573
        RegDeleteValueA(prodkey, name); \
    } while(0)
2574 2575

#define CHECK_REG_ISTR(prodkey, name, expected) \
2576
    check_reg_str(prodkey, name, expected, FALSE, FALSE, __LINE__);
2577 2578

#define CHECK_DEL_REG_ISTR(prodkey, name, expected) \
2579
    do { \
2580
        check_reg_str(prodkey, name, expected, FALSE, FALSE, __LINE__); \
2581 2582
        RegDeleteValueA(prodkey, name); \
    } while(0)
2583

2584 2585 2586
#define CHECK_REG_MULTI(key, name, expect) \
    check_reg_multi(key, name, expect, __LINE__);

2587 2588 2589 2590 2591 2592
#define CHECK_DEL_REG_MULTI(key, name, expect) \
    do { \
        check_reg_multi(key, name, expect, __LINE__); \
        RegDeleteValueA(key, name); \
    } while(0)

2593
#define CHECK_REG_DWORD(prodkey, name, expected) \
2594 2595 2596 2597
    check_reg_dword(prodkey, name, expected, FALSE, __LINE__);

#define CHECK_REG_DWORD_TODO(prodkey, name, expected) \
    check_reg_dword(prodkey, name, expected, TRUE, __LINE__);
2598 2599

#define CHECK_DEL_REG_DWORD(prodkey, name, expected) \
2600
    do { \
2601 2602 2603 2604 2605 2606 2607
        check_reg_dword(prodkey, name, expected, FALSE, __LINE__); \
        RegDeleteValueA(prodkey, name); \
    } while(0)

#define CHECK_DEL_REG_DWORD_TODO(prodkey, name, expected) \
    do { \
        check_reg_dword(prodkey, name, expected, TRUE, __LINE__); \
2608 2609
        RegDeleteValueA(prodkey, name); \
    } while(0)
2610 2611 2612 2613 2614 2615 2616 2617 2618 2619

static void get_date_str(LPSTR date)
{
    SYSTEMTIME systime;

    static const char date_fmt[] = "%d%02d%02d";
    GetLocalTime(&systime);
    sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
}

2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635
/* EstimatedSize is the size in KiB of .msi + installed files, rounded up to page size. */
static DWORD get_estimated_size(void)
{
    SYSTEM_INFO si;
    HANDLE file;
    DWORD size;

    GetSystemInfo(&si);

    file = CreateFileA(msifile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
    size = ((GetFileSize(file, NULL) + si.dwPageSize - 1) / si.dwPageSize + 1);
    size = size * si.dwPageSize / 1024;
    CloseHandle(file);
    return size;
}

2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653
static void extract_resource(const char *name, const char *type, const char *path)
{
    DWORD written;
    HANDLE file;
    HRSRC res;
    void *ptr;

    file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
    ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", path, GetLastError());

    res = FindResourceA(NULL, name, type);
    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 );
}

2654 2655 2656 2657
static void test_register_product(void)
{
    UINT r;
    LONG res;
2658
    HKEY hkey, props, usage;
2659
    LPSTR usersid;
2660 2661
    char date[MAX_PATH], temp[MAX_PATH], keypath[MAX_PATH], path[MAX_PATH];
    DWORD size, type;
2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677

    static const CHAR uninstall[] = "Software\\Microsoft\\Windows\\CurrentVersion"
                                    "\\Uninstall\\{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
    static const CHAR userdata[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Installer"
                                   "\\UserData\\%s\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB";
    static const CHAR ugkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Installer"
                                "\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2";
    static const CHAR userugkey[] = "Software\\Microsoft\\Installer\\UpgradeCodes"
                                    "\\51AAE0C44620A5E4788506E91F249BD2";

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

2678
    if (!(usersid = get_user_sid()))
2679 2680 2681
        return;

    get_date_str(date);
2682
    GetTempPathA(MAX_PATH, temp);
2683 2684 2685 2686

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);

2687
    create_database(msifile, pp_tables, ARRAY_SIZE(pp_tables));
2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699

    MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);

    /* RegisterProduct */
    r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
2700
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
2701 2702 2703 2704

    res = RegOpenKeyA(HKEY_CURRENT_USER, userugkey, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

2705 2706
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, uninstall, 0, KEY_READ | KEY_WOW64_32KEY, &hkey);
    ok(!res, "got %d\n", res);
2707 2708 2709 2710 2711

    CHECK_DEL_REG_STR(hkey, "DisplayName", "MSITEST");
    CHECK_DEL_REG_STR(hkey, "DisplayVersion", "1.1.1");
    CHECK_DEL_REG_STR(hkey, "InstallDate", date);
    CHECK_DEL_REG_STR(hkey, "InstallSource", temp);
2712
    CHECK_DEL_REG_ISTR(hkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2713
    CHECK_DEL_REG_STR(hkey, "Publisher", "Wine");
2714
    CHECK_DEL_REG_STR(hkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2715 2716 2717 2718 2719 2720
    CHECK_DEL_REG_STR(hkey, "AuthorizedCDFPrefix", "");
    CHECK_DEL_REG_STR(hkey, "Comments", "");
    CHECK_DEL_REG_STR(hkey, "Contact", "");
    CHECK_DEL_REG_STR(hkey, "HelpLink", "");
    CHECK_DEL_REG_STR(hkey, "HelpTelephone", "");
    CHECK_DEL_REG_STR(hkey, "InstallLocation", "");
2721
    CHECK_DEL_REG_DWORD(hkey, "NoModify", 1);
2722 2723 2724 2725
    CHECK_DEL_REG_STR(hkey, "Readme", "");
    CHECK_DEL_REG_STR(hkey, "Size", "");
    CHECK_DEL_REG_STR(hkey, "URLInfoAbout", "");
    CHECK_DEL_REG_STR(hkey, "URLUpdateInfo", "");
2726 2727 2728 2729 2730
    CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
    CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
    CHECK_DEL_REG_DWORD(hkey, "VersionMajor", 1);
    CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
    CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
2731
    CHECK_DEL_REG_DWORD_TODO(hkey, "EstimatedSize", get_estimated_size());
2732

2733 2734
    res = RegDeleteKeyA(hkey, "");
    ok(!res, "got %d\n", res);
2735 2736 2737
    RegCloseKey(hkey);

    sprintf(keypath, userdata, usersid);
2738
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &hkey);
2739 2740
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

2741
    res = RegOpenKeyExA(hkey, "InstallProperties", 0, KEY_READ, &props);
2742 2743
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

2744 2745 2746
    size = sizeof(path);
    RegQueryValueExA(props, "LocalPackage", NULL, &type, (LPBYTE)path, &size);
    DeleteFileA(path);
2747
    RegDeleteValueA(props, "LocalPackage"); /* LocalPackage is nondeterministic */
2748

2749 2750 2751 2752
    CHECK_DEL_REG_STR(props, "DisplayName", "MSITEST");
    CHECK_DEL_REG_STR(props, "DisplayVersion", "1.1.1");
    CHECK_DEL_REG_STR(props, "InstallDate", date);
    CHECK_DEL_REG_STR(props, "InstallSource", temp);
2753
    CHECK_DEL_REG_ISTR(props, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2754
    CHECK_DEL_REG_STR(props, "Publisher", "Wine");
2755
    CHECK_DEL_REG_STR(props, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2756 2757 2758 2759 2760 2761
    CHECK_DEL_REG_STR(props, "AuthorizedCDFPrefix", "");
    CHECK_DEL_REG_STR(props, "Comments", "");
    CHECK_DEL_REG_STR(props, "Contact", "");
    CHECK_DEL_REG_STR(props, "HelpLink", "");
    CHECK_DEL_REG_STR(props, "HelpTelephone", "");
    CHECK_DEL_REG_STR(props, "InstallLocation", "");
2762
    CHECK_DEL_REG_DWORD(props, "NoModify", 1);
2763 2764 2765 2766
    CHECK_DEL_REG_STR(props, "Readme", "");
    CHECK_DEL_REG_STR(props, "Size", "");
    CHECK_DEL_REG_STR(props, "URLInfoAbout", "");
    CHECK_DEL_REG_STR(props, "URLUpdateInfo", "");
2767 2768 2769 2770 2771
    CHECK_DEL_REG_DWORD(props, "Language", 1033);
    CHECK_DEL_REG_DWORD(props, "Version", 0x1010001);
    CHECK_DEL_REG_DWORD(props, "VersionMajor", 1);
    CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
    CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
2772
    CHECK_DEL_REG_DWORD_TODO(props, "EstimatedSize", get_estimated_size());
2773

2774 2775
    res = RegDeleteKeyA(props, "");
    ok(!res, "got %d\n", res);
2776 2777
    RegCloseKey(props);

2778
    res = RegOpenKeyExA(hkey, "Usage", 0, KEY_READ, &usage);
2779 2780 2781 2782 2783
    todo_wine
    {
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

2784 2785 2786
    res = RegDeleteKeyA(usage, "");
todo_wine
    ok(!res, "got %d\n", res);
2787
    RegCloseKey(usage);
2788 2789
    res = RegDeleteKeyA(hkey, "");
    ok(!res, "got %d\n", res);
2790 2791
    RegCloseKey(hkey);

2792
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, ugkey, 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
2793 2794
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

2795
    CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", "");
2796

2797 2798
    res = RegDeleteKeyA(hkey, "");
    ok(!res, "got %d\n", res);
2799 2800 2801 2802 2803 2804
    RegCloseKey(hkey);

    /* RegisterProduct, machine */
    r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 ALLUSERS=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
2805
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
2806

2807
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, userugkey, 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
2808 2809
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

2810 2811
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, uninstall, 0, KEY_READ | KEY_WOW64_32KEY, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2812 2813 2814 2815 2816

    CHECK_DEL_REG_STR(hkey, "DisplayName", "MSITEST");
    CHECK_DEL_REG_STR(hkey, "DisplayVersion", "1.1.1");
    CHECK_DEL_REG_STR(hkey, "InstallDate", date);
    CHECK_DEL_REG_STR(hkey, "InstallSource", temp);
2817
    CHECK_DEL_REG_ISTR(hkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2818
    CHECK_DEL_REG_STR(hkey, "Publisher", "Wine");
2819
    CHECK_DEL_REG_STR(hkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2820 2821 2822 2823 2824 2825
    CHECK_DEL_REG_STR(hkey, "AuthorizedCDFPrefix", "");
    CHECK_DEL_REG_STR(hkey, "Comments", "");
    CHECK_DEL_REG_STR(hkey, "Contact", "");
    CHECK_DEL_REG_STR(hkey, "HelpLink", "");
    CHECK_DEL_REG_STR(hkey, "HelpTelephone", "");
    CHECK_DEL_REG_STR(hkey, "InstallLocation", "");
2826
    CHECK_DEL_REG_DWORD(hkey, "NoModify", 1);
2827 2828 2829 2830
    CHECK_DEL_REG_STR(hkey, "Readme", "");
    CHECK_DEL_REG_STR(hkey, "Size", "");
    CHECK_DEL_REG_STR(hkey, "URLInfoAbout", "");
    CHECK_DEL_REG_STR(hkey, "URLUpdateInfo", "");
2831 2832 2833 2834 2835
    CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
    CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
    CHECK_DEL_REG_DWORD(hkey, "VersionMajor", 1);
    CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
    CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
2836
    CHECK_DEL_REG_DWORD_TODO(hkey, "EstimatedSize", get_estimated_size());
2837

2838 2839
    res = RegDeleteKeyA(hkey, "");
    ok(!res, "got %d\n", res);
2840 2841 2842
    RegCloseKey(hkey);

    sprintf(keypath, userdata, "S-1-5-18");
2843
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
2844 2845
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

2846
    res = RegOpenKeyExA(hkey, "InstallProperties", 0, KEY_READ, &props);
2847 2848
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

2849 2850 2851
    size = sizeof(path);
    RegQueryValueExA(props, "LocalPackage", NULL, &type, (LPBYTE)path, &size);
    DeleteFileA(path);
2852
    RegDeleteValueA(props, "LocalPackage"); /* LocalPackage is nondeterministic */
2853

2854 2855 2856 2857
    CHECK_DEL_REG_STR(props, "DisplayName", "MSITEST");
    CHECK_DEL_REG_STR(props, "DisplayVersion", "1.1.1");
    CHECK_DEL_REG_STR(props, "InstallDate", date);
    CHECK_DEL_REG_STR(props, "InstallSource", temp);
2858
    CHECK_DEL_REG_ISTR(props, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2859
    CHECK_DEL_REG_STR(props, "Publisher", "Wine");
2860
    CHECK_DEL_REG_STR(props, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2861 2862 2863 2864 2865 2866
    CHECK_DEL_REG_STR(props, "AuthorizedCDFPrefix", "");
    CHECK_DEL_REG_STR(props, "Comments", "");
    CHECK_DEL_REG_STR(props, "Contact", "");
    CHECK_DEL_REG_STR(props, "HelpLink", "");
    CHECK_DEL_REG_STR(props, "HelpTelephone", "");
    CHECK_DEL_REG_STR(props, "InstallLocation", "");
2867
    CHECK_DEL_REG_DWORD(props, "NoModify", 1);
2868 2869 2870 2871
    CHECK_DEL_REG_STR(props, "Readme", "");
    CHECK_DEL_REG_STR(props, "Size", "");
    CHECK_DEL_REG_STR(props, "URLInfoAbout", "");
    CHECK_DEL_REG_STR(props, "URLUpdateInfo", "");
2872 2873 2874 2875 2876
    CHECK_DEL_REG_DWORD(props, "Language", 1033);
    CHECK_DEL_REG_DWORD(props, "Version", 0x1010001);
    CHECK_DEL_REG_DWORD(props, "VersionMajor", 1);
    CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
    CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
2877
    CHECK_DEL_REG_DWORD_TODO(props, "EstimatedSize", get_estimated_size());
2878

2879 2880
    res = RegDeleteKeyA(props, "");
    ok(!res, "got %d\n", res);
2881 2882
    RegCloseKey(props);

2883
    res = RegOpenKeyExA(hkey, "Usage", 0, KEY_READ, &usage);
2884 2885 2886 2887 2888
    todo_wine
    {
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

2889 2890 2891
    res = RegDeleteKeyA(usage, "");
todo_wine
    ok(!res, "got %d\n", res);
2892
    RegCloseKey(usage);
2893 2894
    res = RegDeleteKeyA(hkey, "");
    ok(!res, "got %d\n", res);
2895 2896
    RegCloseKey(hkey);

2897
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, ugkey, 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
2898 2899
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

2900
    CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", "");
2901

2902 2903
    res = RegDeleteKeyA(hkey, "");
    ok(!res, "got %d\n", res);
2904 2905
    RegCloseKey(hkey);

2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931
    if (is_wow64 || is_64bit)
    {
        DeleteFileA(msifile);
        create_database_template(msifile, pp_tables, ARRAY_SIZE(pp_tables), 200, "x64;1033");

        r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 ALLUSERS=1 RP_TEST64=1");
        ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
        ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
        ok(delete_pf("msitest", FALSE), "Directory not created\n");

        res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, userugkey, 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
        ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

        res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, uninstall, 0, KEY_READ | KEY_WOW64_32KEY, &hkey);
        ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_SUCCESS, got %d\n", res);

        res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, uninstall, 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

        CHECK_DEL_REG_STR(hkey, "DisplayName", "MSITEST");
        CHECK_DEL_REG_STR(hkey, "DisplayVersion", "1.1.1");
        CHECK_DEL_REG_STR(hkey, "InstallDate", date);
        CHECK_DEL_REG_STR(hkey, "InstallSource", temp);
        CHECK_DEL_REG_ISTR(hkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
        CHECK_DEL_REG_STR(hkey, "Publisher", "Wine");
        CHECK_DEL_REG_STR(hkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2932 2933 2934 2935 2936 2937
        CHECK_DEL_REG_STR(hkey, "AuthorizedCDFPrefix", "");
        CHECK_DEL_REG_STR(hkey, "Comments", "");
        CHECK_DEL_REG_STR(hkey, "Contact", "");
        CHECK_DEL_REG_STR(hkey, "HelpLink", "");
        CHECK_DEL_REG_STR(hkey, "HelpTelephone", "");
        CHECK_DEL_REG_STR(hkey, "InstallLocation", "");
2938
        CHECK_DEL_REG_DWORD(hkey, "NoModify", 1);
2939 2940 2941 2942
        CHECK_DEL_REG_STR(hkey, "Readme", "");
        CHECK_DEL_REG_STR(hkey, "Size", "");
        CHECK_DEL_REG_STR(hkey, "URLInfoAbout", "");
        CHECK_DEL_REG_STR(hkey, "URLUpdateInfo", "");
2943 2944 2945 2946 2947
        CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
        CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
        CHECK_DEL_REG_DWORD(hkey, "VersionMajor", 1);
        CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
        CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
2948
        CHECK_DEL_REG_DWORD_TODO(hkey, "EstimatedSize", get_estimated_size());
2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972

        res = RegDeleteKeyA(hkey, "");
        ok(!res, "got %d\n", res);
        RegCloseKey(hkey);

        sprintf(keypath, userdata, "S-1-5-18");
        res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

        res = RegOpenKeyExA(hkey, "InstallProperties", 0, KEY_READ, &props);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

        size = sizeof(path);
        RegQueryValueExA(props, "LocalPackage", NULL, &type, (LPBYTE)path, &size);
        DeleteFileA(path);
        RegDeleteValueA(props, "LocalPackage"); /* LocalPackage is nondeterministic */

        CHECK_DEL_REG_STR(props, "DisplayName", "MSITEST");
        CHECK_DEL_REG_STR(props, "DisplayVersion", "1.1.1");
        CHECK_DEL_REG_STR(props, "InstallDate", date);
        CHECK_DEL_REG_STR(props, "InstallSource", temp);
        CHECK_DEL_REG_ISTR(props, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
        CHECK_DEL_REG_STR(props, "Publisher", "Wine");
        CHECK_DEL_REG_STR(props, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2973 2974 2975 2976 2977 2978
        CHECK_DEL_REG_STR(props, "AuthorizedCDFPrefix", "");
        CHECK_DEL_REG_STR(props, "Comments", "");
        CHECK_DEL_REG_STR(props, "Contact", "");
        CHECK_DEL_REG_STR(props, "HelpLink", "");
        CHECK_DEL_REG_STR(props, "HelpTelephone", "");
        CHECK_DEL_REG_STR(props, "InstallLocation", "");
2979
        CHECK_DEL_REG_DWORD(props, "NoModify", 1);
2980 2981 2982 2983
        CHECK_DEL_REG_STR(props, "Readme", "");
        CHECK_DEL_REG_STR(props, "Size", "");
        CHECK_DEL_REG_STR(props, "URLInfoAbout", "");
        CHECK_DEL_REG_STR(props, "URLUpdateInfo", "");
2984 2985 2986 2987 2988
        CHECK_DEL_REG_DWORD(props, "Language", 1033);
        CHECK_DEL_REG_DWORD(props, "Version", 0x1010001);
        CHECK_DEL_REG_DWORD(props, "VersionMajor", 1);
        CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
        CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
2989
        CHECK_DEL_REG_DWORD_TODO(props, "EstimatedSize", get_estimated_size());
2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011

        res = RegDeleteKeyA(props, "");
        ok(!res, "got %d\n", res);
        RegCloseKey(props);

        res = RegOpenKeyExA(hkey, "Usage", 0, KEY_READ, &usage);
        todo_wine
        {
            ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
        }

        res = RegDeleteKeyA(usage, "");
    todo_wine
        ok(!res, "got %d\n", res);
        RegCloseKey(usage);
        res = RegDeleteKeyA(hkey, "");
        ok(!res, "got %d\n", res);
        RegCloseKey(hkey);

        res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, ugkey, 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

3012
        CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", "");
3013 3014 3015 3016 3017 3018 3019 3020

        res = RegDeleteKeyA(hkey, "");
        ok(!res, "got %d\n", res);
        RegCloseKey(hkey);
    }
    else
        skip("64-bit RegisterProduct tests\n");

3021
error:
3022 3023 3024
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
3025 3026 3027 3028 3029
    HeapFree(GetProcessHeap(), 0, usersid);
}

static void test_publish_product(void)
{
3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043
    static const char prodpath[] =
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Products"
        "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
    static const char cuprodpath[] =
        "Software\\Microsoft\\Installer\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB";
    static const char cuupgrades[] =
        "Software\\Microsoft\\Installer\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2";
    static const char badprod[] =
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products"
        "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
    static const char machprod[] =
        "Software\\Classes\\Installer\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB";
    static const char machup[] =
        "Software\\Classes\\Installer\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2";
3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060
    UINT r;
    LONG res;
    LPSTR usersid;
    HKEY sourcelist, net, props;
    HKEY hkey, patches, media;
    CHAR keypath[MAX_PATH];
    CHAR temp[MAX_PATH];
    CHAR path[MAX_PATH];
    BOOL old_installer = FALSE;
    REGSAM access = KEY_ALL_ACCESS;

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

3061
    if (!(usersid = get_user_sid()))
3062 3063
        return;

3064
    GetTempPathA(MAX_PATH, temp);
3065 3066 3067 3068

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);

3069
    create_database(msifile, pp_tables, ARRAY_SIZE(pp_tables));
3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084

    if (is_wow64)
        access |= KEY_WOW64_64KEY;

    MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);

    /* PublishProduct, current user */
    r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3085
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, badprod, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    sprintf(keypath, prodpath, usersid);
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey);
    if (res == ERROR_FILE_NOT_FOUND)
    {
        res = RegOpenKeyA(HKEY_CURRENT_USER, cuprodpath, &hkey);
        if (res == ERROR_SUCCESS)
        {
            win_skip("Windows Installer < 3.0 detected\n");
            RegCloseKey(hkey);
            old_installer = TRUE;
            goto currentuser;
        }
        else
        {
            win_skip("Install failed, no need to continue\n");
            return;
        }
    }
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    res = RegOpenKeyExA(hkey, "InstallProperties", 0, access, &props);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegOpenKeyExA(hkey, "Patches", 0, access, &patches);
3114 3115
    todo_wine ok(!res, "Expected ERROR_SUCCESS, got %d\n", res);
    if (!res)
3116
        CHECK_DEL_REG_STR(patches, "AllPatches", "");
3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127

    delete_key(patches, "", access);
    RegCloseKey(patches);
    delete_key(hkey, "", access);
    RegCloseKey(hkey);

currentuser:
    res = RegOpenKeyA(HKEY_CURRENT_USER, cuprodpath, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_DEL_REG_STR(hkey, "ProductName", "MSITEST");
3128
    CHECK_DEL_REG_STR(hkey, "PackageCode", "AC75740029052C94DA02821EECD05F2F");
3129 3130 3131 3132 3133 3134 3135
    CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
    CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
    if (!old_installer)
        CHECK_DEL_REG_DWORD(hkey, "AuthorizedLUAApp", 0);
    CHECK_DEL_REG_DWORD(hkey, "Assignment", 0);
    CHECK_DEL_REG_DWORD(hkey, "AdvertiseFlags", 0x184);
    CHECK_DEL_REG_DWORD(hkey, "InstanceType", 0);
3136
    CHECK_DEL_REG_MULTI(hkey, "Clients", ":\0");
3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168

    res = RegOpenKeyA(hkey, "SourceList", &sourcelist);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    lstrcpyA(path, "n;1;");
    lstrcatA(path, temp);
    CHECK_DEL_REG_STR(sourcelist, "LastUsedSource", path);
    CHECK_DEL_REG_STR(sourcelist, "PackageName", "msitest.msi");

    res = RegOpenKeyA(sourcelist, "Net", &net);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_DEL_REG_STR(net, "1", temp);

    RegDeleteKeyA(net, "");
    RegCloseKey(net);

    res = RegOpenKeyA(sourcelist, "Media", &media);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_DEL_REG_STR(media, "1", "DISK1;");

    RegDeleteKeyA(media, "");
    RegCloseKey(media);
    RegDeleteKeyA(sourcelist, "");
    RegCloseKey(sourcelist);
    RegDeleteKeyA(hkey, "");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CURRENT_USER, cuupgrades, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

3169
    CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", "");
3170 3171 3172 3173 3174 3175 3176 3177 3178 3179

    RegDeleteKeyA(hkey, "");
    RegCloseKey(hkey);

    /* PublishProduct, machine */
    r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1 ALLUSERS=1");
    if (old_installer)
        goto machprod;
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3180
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, badprod, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    sprintf(keypath, prodpath, "S-1-5-18");
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    res = RegOpenKeyExA(hkey, "InstallProperties", 0, access, &props);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegOpenKeyExA(hkey, "Patches", 0, access, &patches);
3193 3194
    todo_wine ok(!res, "Expected ERROR_SUCCESS, got %d\n", res);
    if (!res)
3195
        CHECK_DEL_REG_STR(patches, "AllPatches", "");
3196 3197 3198 3199 3200 3201 3202

    delete_key(patches, "", access);
    RegCloseKey(patches);
    delete_key(hkey, "", access);
    RegCloseKey(hkey);

machprod:
Hans Leidekker's avatar
Hans Leidekker committed
3203
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, machprod, 0, access, &hkey);
3204 3205 3206
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_DEL_REG_STR(hkey, "ProductName", "MSITEST");
3207
    CHECK_DEL_REG_STR(hkey, "PackageCode", "AC75740029052C94DA02821EECD05F2F");
3208 3209 3210 3211
    CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
    CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
    if (!old_installer)
        CHECK_DEL_REG_DWORD(hkey, "AuthorizedLUAApp", 0);
3212
    CHECK_DEL_REG_DWORD_TODO(hkey, "Assignment", 1);
3213 3214
    CHECK_DEL_REG_DWORD(hkey, "AdvertiseFlags", 0x184);
    CHECK_DEL_REG_DWORD(hkey, "InstanceType", 0);
3215
    CHECK_DEL_REG_MULTI(hkey, "Clients", ":\0");
3216

3217
    res = RegOpenKeyExA(hkey, "SourceList", 0, access, &sourcelist);
3218 3219 3220 3221 3222 3223 3224
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    lstrcpyA(path, "n;1;");
    lstrcatA(path, temp);
    CHECK_DEL_REG_STR(sourcelist, "LastUsedSource", path);
    CHECK_DEL_REG_STR(sourcelist, "PackageName", "msitest.msi");

3225
    res = RegOpenKeyExA(sourcelist, "Net", 0, access, &net);
3226 3227 3228 3229
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_DEL_REG_STR(net, "1", temp);

3230 3231
    res = delete_key(net, "", access);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3232 3233
    RegCloseKey(net);

3234
    res = RegOpenKeyExA(sourcelist, "Media", 0, access, &media);
3235 3236 3237 3238
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_DEL_REG_STR(media, "1", "DISK1;");

3239 3240
    res = delete_key(media, "", access);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3241
    RegCloseKey(media);
3242 3243
    res = delete_key(sourcelist, "", access);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3244
    RegCloseKey(sourcelist);
3245 3246
    res = delete_key(hkey, "", access);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3247 3248
    RegCloseKey(hkey);

Hans Leidekker's avatar
Hans Leidekker committed
3249
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, machup, 0, access, &hkey);
3250 3251
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

3252
    CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", "");
3253

3254 3255
    res = delete_key(hkey, "", access);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3256 3257 3258
    RegCloseKey(hkey);

error:
3259 3260 3261
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
3262 3263 3264 3265 3266
    HeapFree(GetProcessHeap(), 0, usersid);
}

static void test_publish_features(void)
{
3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278
    static const char cupath[] =
        "Software\\Microsoft\\Installer\\Features\\84A88FD7F6998CE40A22FB59F6B9C2BB";
    static const char udfeatpath[] =
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Products"
        "\\84A88FD7F6998CE40A22FB59F6B9C2BB\\Features";
    static const char udpridpath[] =
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Products"
        "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
    static const char featkey[] =
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Features";
    static const char classfeat[] =
        "Software\\Classes\\Installer\\Features\\84A88FD7F6998CE40A22FB59F6B9C2BB";
3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291
    UINT r;
    LONG res;
    HKEY hkey;
    LPSTR usersid;
    CHAR keypath[MAX_PATH];
    REGSAM access = KEY_ALL_ACCESS;

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

3292
    if (!(usersid = get_user_sid()))
3293 3294 3295 3296 3297
        return;

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);

3298
    create_database(msifile, pp_tables, ARRAY_SIZE(pp_tables));
3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313

    if (is_wow64)
        access |= KEY_WOW64_64KEY;

    MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);

    /* PublishFeatures, current user */
    r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3314
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, featkey, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, classfeat, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegOpenKeyA(HKEY_CURRENT_USER, cupath, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_REG_STR(hkey, "feature", "");
    CHECK_REG_STR(hkey, "montecristo", "");

    RegDeleteValueA(hkey, "feature");
    RegDeleteValueA(hkey, "montecristo");
3330
    delete_key(hkey, "", access);
3331 3332
    RegCloseKey(hkey);

3333
    sprintf(keypath, udfeatpath, usersid);
3334 3335 3336 3337 3338 3339 3340 3341
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_REG_STR(hkey, "feature", "VGtfp^p+,?82@JU1j_KE");
    CHECK_REG_STR(hkey, "montecristo", "VGtfp^p+,?82@JU1j_KE");

    RegDeleteValueA(hkey, "feature");
    RegDeleteValueA(hkey, "montecristo");
3342
    delete_key(hkey, "", access);
3343
    RegCloseKey(hkey);
3344 3345
    sprintf(keypath, udpridpath, usersid);
    delete_key(HKEY_LOCAL_MACHINE, keypath, access);
3346 3347 3348 3349 3350

    /* PublishFeatures, machine */
    r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1 ALLUSERS=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3351
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3352 3353 3354 3355 3356 3357

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, featkey, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegOpenKeyA(HKEY_CURRENT_USER, cupath, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3358
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, classfeat, 0, access, &hkey);
3359 3360 3361 3362 3363 3364 3365
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_REG_STR(hkey, "feature", "");
    CHECK_REG_STR(hkey, "montecristo", "");

    RegDeleteValueA(hkey, "feature");
    RegDeleteValueA(hkey, "montecristo");
3366
    delete_key(hkey, "", access);
3367 3368
    RegCloseKey(hkey);

3369
    sprintf(keypath, udfeatpath, "S-1-5-18");
3370 3371 3372 3373 3374 3375 3376 3377
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_REG_STR(hkey, "feature", "VGtfp^p+,?82@JU1j_KE");
    CHECK_REG_STR(hkey, "montecristo", "VGtfp^p+,?82@JU1j_KE");

    RegDeleteValueA(hkey, "feature");
    RegDeleteValueA(hkey, "montecristo");
3378
    delete_key(hkey, "", access);
3379
    RegCloseKey(hkey);
3380 3381
    sprintf(keypath, udpridpath, "S-1-5-18");
    delete_key(HKEY_LOCAL_MACHINE, keypath, access);
3382 3383

error:
3384 3385 3386
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430
    HeapFree(GetProcessHeap(), 0, usersid);
}

static LPSTR reg_get_val_str(HKEY hkey, LPCSTR name)
{
    DWORD len = 0;
    LPSTR val;
    LONG r;

    r = RegQueryValueExA(hkey, name, NULL, NULL, NULL, &len);
    if (r != ERROR_SUCCESS)
        return NULL;

    len += sizeof (WCHAR);
    val = HeapAlloc(GetProcessHeap(), 0, len);
    if (!val) return NULL;
    val[0] = 0;
    RegQueryValueExA(hkey, name, NULL, NULL, (LPBYTE)val, &len);
    return val;
}

static void get_owner_company(LPSTR *owner, LPSTR *company)
{
    LONG res;
    HKEY hkey;
    REGSAM access = KEY_ALL_ACCESS;

    *owner = *company = NULL;

    if (is_wow64)
        access |= KEY_WOW64_64KEY;

    res = RegOpenKeyA(HKEY_CURRENT_USER,
                      "Software\\Microsoft\\MS Setup (ACME)\\User Info", &hkey);
    if (res == ERROR_SUCCESS)
    {
        *owner = reg_get_val_str(hkey, "DefName");
        *company = reg_get_val_str(hkey, "DefCompany");
        RegCloseKey(hkey);
    }

    if (!*owner || !*company)
    {
        res = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
3431
                            "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey);
3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442
        if (res == ERROR_SUCCESS)
        {
            *owner = reg_get_val_str(hkey, "RegisteredOwner");
            *company = reg_get_val_str(hkey, "RegisteredOrganization");
            RegCloseKey(hkey);
        }
    }

    if (!*owner || !*company)
    {
        res = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
3443
                            "Software\\Microsoft\\Windows\\CurrentVersion", 0, access, &hkey);
3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462
        if (res == ERROR_SUCCESS)
        {
            *owner = reg_get_val_str(hkey, "RegisteredOwner");
            *company = reg_get_val_str(hkey, "RegisteredOrganization");
            RegCloseKey(hkey);
        }
    }
}

static void test_register_user(void)
{
    UINT r;
    LONG res;
    HKEY props;
    LPSTR usersid;
    LPSTR owner, company;
    CHAR keypath[MAX_PATH];
    REGSAM access = KEY_ALL_ACCESS;

3463
    static const CHAR keypropsfmt[] =
3464 3465
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\"
        "UserData\\%s\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB\\InstallProperties";
3466 3467 3468
    static const CHAR keypridfmt[] =
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\"
        "UserData\\%s\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB";
3469 3470 3471 3472 3473 3474 3475

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

3476
    if (!(usersid = get_user_sid()))
3477 3478 3479 3480 3481 3482 3483
        return;

    get_owner_company(&owner, &company);

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);

3484
    create_database(msifile, pp_tables, ARRAY_SIZE(pp_tables));
3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499

    if (is_wow64)
        access |= KEY_WOW64_64KEY;

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    /* RegisterUser, per-user */
    r = MsiInstallProductA(msifile, "REGISTER_USER=1");
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3500
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3501

3502
    sprintf(keypath, keypropsfmt, usersid);
3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_REG_STR(props, "ProductID", "none");
    CHECK_REG_STR(props, "RegCompany", company);
    CHECK_REG_STR(props, "RegOwner", owner);

    RegDeleteValueA(props, "ProductID");
    RegDeleteValueA(props, "RegCompany");
    RegDeleteValueA(props, "RegOwner");
    delete_key(props, "", access);
    RegCloseKey(props);
3515 3516
    sprintf(keypath, keypridfmt, usersid);
    delete_key(HKEY_LOCAL_MACHINE, keypath, access);
3517 3518 3519 3520 3521

    /* RegisterUser, machine */
    r = MsiInstallProductA(msifile, "REGISTER_USER=1 ALLUSERS=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3522
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3523

3524
    sprintf(keypath, keypropsfmt, "S-1-5-18");
3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    CHECK_REG_STR(props, "ProductID", "none");
    CHECK_REG_STR(props, "RegCompany", company);
    CHECK_REG_STR(props, "RegOwner", owner);

    RegDeleteValueA(props, "ProductID");
    RegDeleteValueA(props, "RegCompany");
    RegDeleteValueA(props, "RegOwner");
    delete_key(props, "", access);
    RegCloseKey(props);
3537 3538
    sprintf(keypath, keypridfmt, "S-1-5-18");
    delete_key(HKEY_LOCAL_MACHINE, keypath, access);
3539 3540 3541 3542 3543

error:
    HeapFree(GetProcessHeap(), 0, company);
    HeapFree(GetProcessHeap(), 0, owner);

3544 3545 3546
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
3547 3548 3549 3550 3551
    LocalFree(usersid);
}

static void test_process_components(void)
{
3552 3553 3554 3555
    static const char keyfmt[] =
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Components\\%s";
    static const char compkey[] =
        "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Components";
3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571
    UINT r;
    LONG res;
    DWORD size;
    HKEY comp, hkey;
    LPSTR usersid;
    CHAR val[MAX_PATH];
    CHAR keypath[MAX_PATH];
    CHAR program_files_maximus[MAX_PATH];
    REGSAM access = KEY_ALL_ACCESS;

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

3572
    if (!(usersid = get_user_sid()))
3573 3574 3575 3576 3577
        return;

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);

3578
    create_database(msifile, ppc_tables, ARRAY_SIZE(ppc_tables));
3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593

    if (is_wow64)
        access |= KEY_WOW64_64KEY;

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    /* ProcessComponents, per-user */
    r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3594
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639

    sprintf(keypath, keyfmt, usersid, "CBABC2FDCCB35E749A8944D8C1C098B5");
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &comp);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    size = MAX_PATH;
    res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
                           NULL, NULL, (LPBYTE)val, &size);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    lstrcpyA(program_files_maximus,PROG_FILES_DIR);
    lstrcatA(program_files_maximus,"\\msitest\\maximus");

    ok(!lstrcmpiA(val, program_files_maximus),
       "Expected \"%s\", got \"%s\"\n", program_files_maximus, val);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, compkey, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
    delete_key(comp, "", access);
    RegCloseKey(comp);

    sprintf(keypath, keyfmt, usersid, "241C3DA58FECD0945B9687D408766058");
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &comp);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    size = MAX_PATH;
    res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
                           NULL, NULL, (LPBYTE)val, &size);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    ok(!lstrcmpA(val, "01\\msitest\\augustus"),
       "Expected \"01\\msitest\\augustus\", got \"%s\"\n", val);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, compkey, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
    delete_key(comp, "", access);
    RegCloseKey(comp);

    /* ProcessComponents, machine */
    r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1 ALLUSERS=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3640
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678

    sprintf(keypath, keyfmt, "S-1-5-18", "CBABC2FDCCB35E749A8944D8C1C098B5");
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &comp);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    size = MAX_PATH;
    res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
                           NULL, NULL, (LPBYTE)val, &size);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    ok(!lstrcmpiA(val, program_files_maximus),
       "Expected \"%s\", got \"%s\"\n", program_files_maximus, val);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, compkey, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
    delete_key(comp, "", access);
    RegCloseKey(comp);

    sprintf(keypath, keyfmt, "S-1-5-18", "241C3DA58FECD0945B9687D408766058");
    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &comp);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    size = MAX_PATH;
    res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
                           NULL, NULL, (LPBYTE)val, &size);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    ok(!lstrcmpA(val, "01\\msitest\\augustus"),
       "Expected \"01\\msitest\\augustus\", got \"%s\"\n", val);

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, compkey, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
    delete_key(comp, "", access);
    RegCloseKey(comp);

error:
3679 3680 3681
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
3682 3683 3684 3685 3686
    LocalFree(usersid);
}

static void test_publish(void)
{
3687 3688
    static const char subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
    static const char subkey_32node[] = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
3689 3690 3691 3692
    UINT r;
    LONG res;
    HKEY uninstall, prodkey, uninstall_32node = NULL;
    INSTALLSTATE state;
3693
    char date[MAX_PATH], temp[MAX_PATH], prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
3694
    REGSAM access = KEY_ALL_ACCESS;
3695
    DWORD error;
3696

3697
    if (!pMsiQueryFeatureStateExA)
3698
    {
3699
        win_skip("MsiQueryFeatureStateExA is not available\n");
3700 3701 3702 3703 3704 3705 3706 3707 3708
        return;
    }
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

    get_date_str(date);
3709
    GetTempPathA(MAX_PATH, temp);
3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725

    if (is_wow64)
        access |= KEY_WOW64_64KEY;

    res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, subkey, 0, KEY_ALL_ACCESS, &uninstall);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    if (is_64bit)
    {
        res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, subkey_32node, 0, KEY_ALL_ACCESS, &uninstall_32node);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);

3726
    create_database(msifile, pp_tables, ARRAY_SIZE(pp_tables));
3727 3728 3729

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

3730
    state = MsiQueryProductStateA(prodcode);
3731 3732
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3733
    state = MsiQueryFeatureStateA(prodcode, "feature");
3734 3735
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759
    state = 0xdead;
    SetLastError(0xdeadbeef);
    r = pMsiQueryFeatureStateExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, "feature", &state);
    error = GetLastError();
    ok(r == ERROR_UNKNOWN_PRODUCT, "got %u\n", r);
    ok(state == 0xdead, "got %d\n", state);
    ok(error == 0xdeadbeef, "got %u\n", error);

    state = 0xdead;
    SetLastError(0xdeadbeef);
    r = pMsiQueryFeatureStateExA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, "feature", &state);
    error = GetLastError();
    ok(r == ERROR_UNKNOWN_PRODUCT, "got %u\n", r);
    ok(state == 0xdead, "got %d\n", state);
    ok(error == ERROR_SUCCESS, "got %u\n", error);

    state = 0xdead;
    SetLastError(0xdeadbeef);
    r = pMsiQueryFeatureStateExA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, "feature", &state);
    error = GetLastError();
    ok(r == ERROR_UNKNOWN_PRODUCT, "got %u\n", r);
    ok(state == 0xdead, "got %d\n", state);
    ok(error == ERROR_SUCCESS, "got %u\n", error);

3760
    state = MsiQueryFeatureStateA(prodcode, "feature");
3761 3762
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3763
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    /* nothing published */
    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(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

3785
    state = MsiQueryProductStateA(prodcode);
3786 3787
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3788
    state = MsiQueryFeatureStateA(prodcode, "feature");
3789 3790
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3791
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    /* PublishProduct and RegisterProduct */
    r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

3808
    state = MsiQueryProductStateA(prodcode);
3809 3810
    ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);

3811
    state = MsiQueryFeatureStateA(prodcode, "feature");
3812 3813
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3814
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
3815 3816 3817 3818 3819 3820 3821
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3822
    if (is_64bit)
3823 3824 3825 3826 3827 3828 3829
    {
        res = RegOpenKeyExA(uninstall_32node, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }
    else
    {
        res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
3830 3831
        if (is_wow64 && res == ERROR_FILE_NOT_FOUND) /* XP - Vista, Wow64 */
            res = RegOpenKeyExA(uninstall, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
3832 3833 3834 3835 3836 3837 3838
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

    CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
    CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
    CHECK_REG_STR(prodkey, "InstallDate", date);
    CHECK_REG_STR(prodkey, "InstallSource", temp);
3839
    CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3840
    CHECK_REG_STR(prodkey, "Publisher", "Wine");
3841
    CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3842 3843 3844 3845 3846 3847
    CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", "");
    CHECK_REG_STR(prodkey, "Comments", "");
    CHECK_REG_STR(prodkey, "Contact", "");
    CHECK_REG_STR(prodkey, "HelpLink", "");
    CHECK_REG_STR(prodkey, "HelpTelephone", "");
    CHECK_REG_STR(prodkey, "InstallLocation", "");
3848
    CHECK_REG_DWORD(prodkey, "NoModify", 1);
3849 3850 3851 3852
    CHECK_REG_STR(prodkey, "Readme", "");
    CHECK_REG_STR(prodkey, "Size", "");
    CHECK_REG_STR(prodkey, "URLInfoAbout", "");
    CHECK_REG_STR(prodkey, "URLUpdateInfo", "");
3853 3854 3855 3856 3857
    CHECK_REG_DWORD(prodkey, "Language", 1033);
    CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
    CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
    CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
    CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
3858
    CHECK_REG_DWORD_TODO(prodkey, "EstimatedSize", get_estimated_size());
3859 3860 3861 3862 3863 3864 3865 3866

    RegCloseKey(prodkey);

    r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(pf_exists("msitest\\maximus"), "File deleted\n");
    ok(pf_exists("msitest"), "File deleted\n");

3867
    state = MsiQueryProductStateA(prodcode);
3868 3869
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3870
    state = MsiQueryFeatureStateA(prodcode, "feature");
3871 3872
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3873
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    /* complete install */
    r = MsiInstallProductA(msifile, "FULL=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

3890
    state = MsiQueryProductStateA(prodcode);
3891 3892
    ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);

3893
    state = MsiQueryFeatureStateA(prodcode, "feature");
3894 3895
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919
    state = 0xdead;
    SetLastError(0xdeadbeef);
    r = pMsiQueryFeatureStateExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, "feature", &state);
    error = GetLastError();
    ok(r == ERROR_UNKNOWN_PRODUCT, "got %u\n", r);
    ok(state == 0xdead, "got %d\n", state);
    ok(error == 0xdeadbeef, "got %u\n", error);

    state = 0xdead;
    SetLastError(0xdeadbeef);
    r = pMsiQueryFeatureStateExA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, "feature", &state);
    error = GetLastError();
    ok(r == ERROR_UNKNOWN_PRODUCT, "got %u\n", r);
    ok(state == 0xdead, "got %d\n", state);
    ok(error == ERROR_SUCCESS, "got %u\n", error);

    state = 0xdead;
    SetLastError(0xdeadbeef);
    r = pMsiQueryFeatureStateExA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, "feature", &state);
    error = GetLastError();
    ok(r == ERROR_SUCCESS, "got %u\n", r);
    ok(state == INSTALLSTATE_LOCAL, "got %d\n", state);
    ok(error == ERROR_SUCCESS, "got %u\n", error);

3920
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
3921 3922 3923 3924 3925 3926 3927
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

3928
    if (is_64bit)
3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942
    {
        res = RegOpenKeyExA(uninstall_32node, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }
    else
    {
        res = RegOpenKeyExA(uninstall, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

    CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
    CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
    CHECK_REG_STR(prodkey, "InstallDate", date);
    CHECK_REG_STR(prodkey, "InstallSource", temp);
3943
    CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3944
    CHECK_REG_STR(prodkey, "Publisher", "Wine");
3945
    CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3946 3947 3948 3949 3950 3951
    CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", "");
    CHECK_REG_STR(prodkey, "Comments", "");
    CHECK_REG_STR(prodkey, "Contact", "");
    CHECK_REG_STR(prodkey, "HelpLink", "");
    CHECK_REG_STR(prodkey, "HelpTelephone", "");
    CHECK_REG_STR(prodkey, "InstallLocation", "");
3952
    CHECK_REG_DWORD(prodkey, "NoModify", 1);
3953 3954 3955 3956
    CHECK_REG_STR(prodkey, "Readme", "");
    CHECK_REG_STR(prodkey, "Size", "");
    CHECK_REG_STR(prodkey, "URLInfoAbout", "");
    CHECK_REG_STR(prodkey, "URLUpdateInfo", "");
3957 3958 3959 3960 3961
    CHECK_REG_DWORD(prodkey, "Language", 1033);
    CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
    CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
    CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
    CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
3962
    CHECK_REG_DWORD_TODO(prodkey, "EstimatedSize", get_estimated_size());
3963 3964 3965 3966 3967 3968 3969 3970 3971

    RegCloseKey(prodkey);

    /* no UnpublishFeatures */
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
    ok(!pf_exists("msitest"), "Directory not deleted\n");

3972
    state = MsiQueryProductStateA(prodcode);
3973 3974
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3975
    state = MsiQueryFeatureStateA(prodcode, "feature");
3976 3977
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

3978
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    /* complete install */
    r = MsiInstallProductA(msifile, "FULL=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

3995
    state = MsiQueryProductStateA(prodcode);
3996 3997
    ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);

3998
    state = MsiQueryFeatureStateA(prodcode, "feature");
3999 4000
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

4001
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
4002 4003 4004 4005 4006 4007 4008
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

4009
    if (is_64bit)
4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023
    {
        res = RegOpenKeyExA(uninstall_32node, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }
    else
    {
        res = RegOpenKeyExA(uninstall, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

    CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
    CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
    CHECK_REG_STR(prodkey, "InstallDate", date);
    CHECK_REG_STR(prodkey, "InstallSource", temp);
4024
    CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4025
    CHECK_REG_STR(prodkey, "Publisher", "Wine");
4026
    CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4027 4028 4029 4030 4031 4032
    CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", "");
    CHECK_REG_STR(prodkey, "Comments", "");
    CHECK_REG_STR(prodkey, "Contact", "");
    CHECK_REG_STR(prodkey, "HelpLink", "");
    CHECK_REG_STR(prodkey, "HelpTelephone", "");
    CHECK_REG_STR(prodkey, "InstallLocation", "");
4033
    CHECK_REG_DWORD(prodkey, "NoModify", 1);
4034 4035 4036 4037
    CHECK_REG_STR(prodkey, "Readme", "");
    CHECK_REG_STR(prodkey, "Size", "");
    CHECK_REG_STR(prodkey, "URLInfoAbout", "");
    CHECK_REG_STR(prodkey, "URLUpdateInfo", "");
4038 4039 4040 4041 4042
    CHECK_REG_DWORD(prodkey, "Language", 1033);
    CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
    CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
    CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
    CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
4043
    CHECK_REG_DWORD_TODO(prodkey, "EstimatedSize", get_estimated_size());
4044 4045 4046 4047 4048 4049 4050 4051 4052

    RegCloseKey(prodkey);

    /* UnpublishFeatures, only feature removed.  Only works when entire product is removed */
    r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(pf_exists("msitest\\maximus"), "File deleted\n");
    ok(pf_exists("msitest"), "Directory deleted\n");

4053
    state = MsiQueryProductStateA(prodcode);
4054 4055
    ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);

4056
    state = MsiQueryFeatureStateA(prodcode, "feature");
4057 4058
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

4059
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
4060 4061 4062 4063 4064 4065 4066
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

4067
    if (is_64bit)
4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081
    {
        res = RegOpenKeyExA(uninstall_32node, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }
    else
    {
        res = RegOpenKeyExA(uninstall, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

    CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
    CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
    CHECK_REG_STR(prodkey, "InstallDate", date);
    CHECK_REG_STR(prodkey, "InstallSource", temp);
4082
    CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4083
    CHECK_REG_STR(prodkey, "Publisher", "Wine");
4084
    CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4085 4086 4087 4088 4089 4090
    CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", "");
    CHECK_REG_STR(prodkey, "Comments", "");
    CHECK_REG_STR(prodkey, "Contact", "");
    CHECK_REG_STR(prodkey, "HelpLink", "");
    CHECK_REG_STR(prodkey, "HelpTelephone", "");
    CHECK_REG_STR(prodkey, "InstallLocation", "");
4091
    CHECK_REG_DWORD(prodkey, "NoModify", 1);
4092 4093 4094 4095
    CHECK_REG_STR(prodkey, "Readme", "");
    CHECK_REG_STR(prodkey, "Size", "");
    CHECK_REG_STR(prodkey, "URLInfoAbout", "");
    CHECK_REG_STR(prodkey, "URLUpdateInfo", "");
4096 4097 4098 4099 4100
    CHECK_REG_DWORD(prodkey, "Language", 1033);
    CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
    CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
    CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
    CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
4101
    CHECK_REG_DWORD_TODO(prodkey, "EstimatedSize", get_estimated_size());
4102 4103 4104 4105 4106 4107 4108 4109 4110

    RegCloseKey(prodkey);

    /* complete install */
    r = MsiInstallProductA(msifile, "FULL=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

4111
    state = MsiQueryProductStateA(prodcode);
4112 4113
    ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);

4114
    state = MsiQueryFeatureStateA(prodcode, "feature");
4115 4116
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

4117
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
4118 4119 4120 4121 4122 4123 4124
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

4125
    if (is_64bit)
4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139
    {
        res = RegOpenKeyExA(uninstall_32node, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }
    else
    {
        res = RegOpenKeyExA(uninstall, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

    CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
    CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
    CHECK_REG_STR(prodkey, "InstallDate", date);
    CHECK_REG_STR(prodkey, "InstallSource", temp);
4140
    CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4141
    CHECK_REG_STR(prodkey, "Publisher", "Wine");
4142
    CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4143 4144 4145 4146 4147 4148
    CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", "");
    CHECK_REG_STR(prodkey, "Comments", "");
    CHECK_REG_STR(prodkey, "Contact", "");
    CHECK_REG_STR(prodkey, "HelpLink", "");
    CHECK_REG_STR(prodkey, "HelpTelephone", "");
    CHECK_REG_STR(prodkey, "InstallLocation", "");
4149
    CHECK_REG_DWORD(prodkey, "NoModify", 1);
4150 4151 4152 4153
    CHECK_REG_STR(prodkey, "Readme", "");
    CHECK_REG_STR(prodkey, "Size", "");
    CHECK_REG_STR(prodkey, "URLInfoAbout", "");
    CHECK_REG_STR(prodkey, "URLUpdateInfo", "");
4154 4155 4156 4157 4158
    CHECK_REG_DWORD(prodkey, "Language", 1033);
    CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
    CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
    CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
    CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
4159
    CHECK_REG_DWORD_TODO(prodkey, "EstimatedSize", get_estimated_size());
4160 4161 4162 4163 4164 4165 4166 4167 4168

    RegCloseKey(prodkey);

    /* UnpublishFeatures, both features removed */
    r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
    ok(!pf_exists("msitest"), "Directory not deleted\n");

4169
    state = MsiQueryProductStateA(prodcode);
4170 4171
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

4172
    state = MsiQueryFeatureStateA(prodcode, "feature");
4173 4174
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

4175
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    /* complete install */
    r = MsiInstallProductA(msifile, "FULL=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

4192
    state = MsiQueryProductStateA(prodcode);
4193 4194
    ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);

4195
    state = MsiQueryFeatureStateA(prodcode, "feature");
4196 4197
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

4198
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
4199 4200 4201 4202 4203 4204 4205
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);

4206
    if (is_64bit)
4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220
    {
        res = RegOpenKeyExA(uninstall_32node, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }
    else
    {
        res = RegOpenKeyExA(uninstall, prodcode, 0, KEY_ALL_ACCESS, &prodkey);
        ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    }

    CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
    CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
    CHECK_REG_STR(prodkey, "InstallDate", date);
    CHECK_REG_STR(prodkey, "InstallSource", temp);
4221
    CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4222
    CHECK_REG_STR(prodkey, "Publisher", "Wine");
4223
    CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /X{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4224 4225 4226 4227 4228 4229
    CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", "");
    CHECK_REG_STR(prodkey, "Comments", "");
    CHECK_REG_STR(prodkey, "Contact", "");
    CHECK_REG_STR(prodkey, "HelpLink", "");
    CHECK_REG_STR(prodkey, "HelpTelephone", "");
    CHECK_REG_STR(prodkey, "InstallLocation", "");
4230
    CHECK_REG_DWORD(prodkey, "NoModify", 1);
4231 4232 4233 4234
    CHECK_REG_STR(prodkey, "Readme", "");
    CHECK_REG_STR(prodkey, "Size", "");
    CHECK_REG_STR(prodkey, "URLInfoAbout", "");
    CHECK_REG_STR(prodkey, "URLUpdateInfo", "");
4235 4236 4237 4238 4239
    CHECK_REG_DWORD(prodkey, "Language", 1033);
    CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
    CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
    CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
    CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
4240
    CHECK_REG_DWORD_TODO(prodkey, "EstimatedSize", get_estimated_size());
4241 4242 4243 4244 4245 4246 4247 4248 4249

    RegCloseKey(prodkey);

    /* complete uninstall */
    r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
    ok(!pf_exists("msitest"), "Directory not deleted\n");

4250
    state = MsiQueryProductStateA(prodcode);
4251 4252
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

4253
    state = MsiQueryFeatureStateA(prodcode, "feature");
4254 4255
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

4256
    state = MsiQueryFeatureStateA(prodcode, "montecristo");
4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);

    res = RegOpenKeyExA(uninstall, prodcode, 0, access, &prodkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    /* make sure 'Program Files\msitest' is removed */
    delete_pfmsitest_files();

error:
    RegCloseKey(uninstall);
    RegCloseKey(uninstall_32node);
4273 4274 4275
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299
}

static void test_publish_sourcelist(void)
{
    UINT r;
    DWORD size;
    CHAR value[MAX_PATH];
    CHAR path[MAX_PATH];
    CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";

    if (!pMsiSourceListEnumSourcesA || !pMsiSourceListGetInfoA)
    {
        win_skip("MsiSourceListEnumSourcesA and/or MsiSourceListGetInfoA are not available\n");
        return;
    }
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);

4300
    create_database(msifile, pp_tables, ARRAY_SIZE(pp_tables));
4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317

    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(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

    /* nothing published */
    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4318
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEA, value, &size);
4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
    ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                   MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
    ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);

    r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

    /* after RegisterProduct */
    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4340
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEA, value, &size);
4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
    ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                   MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
    ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);

    r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

    /* after ProcessComponents */
    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4362
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEA, value, &size);
4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
    ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                   MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
    ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);

    r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

    /* after PublishFeatures */
    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4384
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEA, value, &size);
4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
    ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                   MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
    ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
    ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
    ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);

    r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(pf_exists("msitest\\maximus"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

    /* after PublishProduct */
    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4406
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEA, value, &size);
4407 4408 4409 4410 4411 4412 4413
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
    ok(size == 11, "Expected 11, got %d\n", size);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4414
                               MSICODE_PRODUCT, INSTALLPROPERTY_MEDIAPACKAGEPATHA, value, &size);
4415 4416 4417 4418 4419 4420 4421
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
    ok(size == 0, "Expected 0, got %d\n", size);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4422
                               MSICODE_PRODUCT, INSTALLPROPERTY_DISKPROMPTA, value, &size);
4423 4424 4425 4426 4427 4428 4429 4430 4431 4432
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
    ok(size == 0, "Expected 0, got %d\n", size);

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

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4433
                               MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
4434 4435 4436 4437 4438 4439 4440
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
    ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4441
                               MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDTYPEA, value, &size);
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
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(value, "n"), "Expected \"n\", got \"%s\"\n", value);
    ok(size == 1, "Expected 1, got %d\n", size);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                   MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
    ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
    ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
    ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                   MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 0, value, &size);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
    ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);

    size = MAX_PATH;
    lstrcpyA(value, "aaa");
    r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
                                   MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 1, value, &size);
    ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
    ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
    ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);

    /* complete uninstall */
    r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
    ok(!pf_exists("msitest"), "Directory not deleted\n");

    /* make sure 'Program Files\msitest' is removed */
    delete_pfmsitest_files();

error:
4480 4481 4482
    DeleteFileA(msifile);
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499
}

static void test_remove_files(void)
{
    UINT r;

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

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\hydrogen", 500);
    create_file("msitest\\helium", 500);
    create_file("msitest\\lithium", 500);

4500
    create_database(msifile, rem_tables, ARRAY_SIZE(rem_tables));
4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520

    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(pf_exists("msitest\\hydrogen"), "File not installed\n");
    ok(!pf_exists("msitest\\helium"), "File installed\n");
    ok(pf_exists("msitest\\lithium"), "File not installed\n");
    ok(pf_exists("msitest"), "File not installed\n");

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
    ok(!pf_exists("msitest\\helium"), "File not deleted\n");
    ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
4521
    ok(delete_pf("msitest", FALSE), "Directory deleted\n");
4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539

    create_pf("msitest", FALSE);
    create_pf("msitest\\hydrogen", TRUE);
    create_pf("msitest\\helium", TRUE);
    create_pf("msitest\\lithium", TRUE);

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    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"), "File not installed\n");

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
    ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
    ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
4540
    ok(delete_pf("msitest", FALSE), "Directory deleted\n");
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

    create_pf("msitest", FALSE);
    create_pf("msitest\\furlong", TRUE);
    create_pf("msitest\\firkin", TRUE);
    create_pf("msitest\\fortnight", TRUE);
    create_pf("msitest\\becquerel", TRUE);
    create_pf("msitest\\dioptre", TRUE);
    create_pf("msitest\\attoparsec", TRUE);
    create_pf("msitest\\storeys", TRUE);
    create_pf("msitest\\block", TRUE);
    create_pf("msitest\\siriometer", TRUE);
    create_pf("msitest\\cabout", FALSE);
    create_pf("msitest\\cabout\\blocker", TRUE);

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
    ok(!pf_exists("msitest\\helium"), "File installed\n");
    ok(pf_exists("msitest\\lithium"), "File not installed\n");
    ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
    ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
    ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
    ok(pf_exists("msitest\\becquerel"), "File not installed\n");
    ok(pf_exists("msitest\\dioptre"), "File not installed\n");
    ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
    ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
    ok(!pf_exists("msitest\\block"), "File not deleted\n");
    ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
    ok(pf_exists("msitest\\cabout"), "Directory removed\n");
    ok(pf_exists("msitest"), "File not installed\n");

    create_pf("msitest\\furlong", TRUE);
    create_pf("msitest\\firkin", TRUE);
    create_pf("msitest\\fortnight", TRUE);
    create_pf("msitest\\storeys", TRUE);
    create_pf("msitest\\block", TRUE);
    create_pf("msitest\\siriometer", TRUE);

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
    ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
    ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
    ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
    ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
    ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
    ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
    ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
    ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
    ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
    ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
    ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
    ok(pf_exists("msitest\\cabout"), "Directory deleted\n");
    ok(pf_exists("msitest"), "Directory deleted\n");

    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(delete_pf("msitest\\hydrogen", TRUE), "File not installed\n");
    ok(!delete_pf("msitest\\helium", TRUE), "File installed\n");
    ok(delete_pf("msitest\\lithium", TRUE), "File not installed\n");
    ok(pf_exists("msitest\\cabout"), "Directory deleted\n");
    ok(pf_exists("msitest"), "Directory deleted\n");

    delete_pf("msitest\\cabout\\blocker", TRUE);

    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
    ok(!delete_pf("msitest\\cabout", FALSE), "Directory not deleted\n");
4609
    delete_pf("msitest", FALSE);
4610 4611

error:
4612 4613 4614 4615 4616
    DeleteFileA(msifile);
    DeleteFileA("msitest\\hydrogen");
    DeleteFileA("msitest\\helium");
    DeleteFileA("msitest\\lithium");
    RemoveDirectoryA("msitest");
4617 4618 4619 4620 4621
}

static void test_move_files(void)
{
    UINT r;
4622
    char props[4 * MAX_PATH + 74];
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 4656

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

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\augustus", 100);
    create_file("cameroon", 100);
    create_file("djibouti", 100);
    create_file("egypt", 100);
    create_file("finland", 100);
    create_file("gambai", 100);
    create_file("honduras", 100);
    create_file("msitest\\india", 100);
    create_file("japan", 100);
    create_file("kenya", 100);
    CreateDirectoryA("latvia", NULL);
    create_file("nauru", 100);
    create_file("peru", 100);
    create_file("apple", 100);
    create_file("application", 100);
    create_file("ape", 100);
    create_file("foo", 100);
    create_file("fao", 100);
    create_file("fbod", 100);
    create_file("budding", 100);
    create_file("buddy", 100);
    create_file("bud", 100);
    create_file("bar", 100);
    create_file("bur", 100);
    create_file("bird", 100);

4657
    create_database(msifile, mov_tables, ARRAY_SIZE(mov_tables));
4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    /* if the source or dest property is not a full path,
     * windows tries to access it as a network resource
     */

    sprintf(props, "SOURCEFULL=\"%s\\\" DESTFULL=\"%s\\msitest\" "
            "FILEPATHBAD=\"%s\\japan\" FILEPATHGOOD=\"%s\\kenya\"",
            CURR_DIR, PROG_FILES_DIR, CURR_DIR, CURR_DIR);

    r = MsiInstallProductA(msifile, props);
    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 not installed\n");
    ok(!delete_pf("msitest\\dest", TRUE), "File copied\n");
    ok(delete_pf("msitest\\canada", TRUE), "File not copied\n");
    ok(delete_pf("msitest\\dominica", TRUE), "File not moved\n");
    ok(!delete_pf("msitest\\elsalvador", TRUE), "File moved\n");
    ok(!delete_pf("msitest\\france", TRUE), "File moved\n");
    ok(!delete_pf("msitest\\georgia", TRUE), "File moved\n");
    ok(delete_pf("msitest\\hungary", TRUE), "File not moved\n");
    ok(!delete_pf("msitest\\indonesia", TRUE), "File moved\n");
    ok(!delete_pf("msitest\\jordan", TRUE), "File moved\n");
    ok(delete_pf("msitest\\kiribati", TRUE), "File not moved\n");
    ok(!delete_pf("msitest\\lebanon", TRUE), "File moved\n");
    ok(!delete_pf("msitest\\lebanon", FALSE), "Directory moved\n");
    ok(delete_pf("msitest\\poland", TRUE), "File not moved\n");
    /* either apple or application will be moved depending on directory order */
    if (!delete_pf("msitest\\apple", TRUE))
        ok(delete_pf("msitest\\application", TRUE), "File not moved\n");
    else
        ok(!delete_pf("msitest\\application", TRUE), "File should not exist\n");
    ok(delete_pf("msitest\\wildcard", TRUE), "File not moved\n");
    ok(!delete_pf("msitest\\ape", TRUE), "File moved\n");
    /* either fao or foo will be moved depending on directory order */
    if (delete_pf("msitest\\foo", TRUE))
        ok(!delete_pf("msitest\\fao", TRUE), "File should not exist\n");
    else
        ok(delete_pf("msitest\\fao", TRUE), "File not moved\n");
    ok(delete_pf("msitest\\single", TRUE), "File not moved\n");
    ok(!delete_pf("msitest\\fbod", TRUE), "File moved\n");
    ok(delete_pf("msitest\\budding", TRUE), "File not moved\n");
    ok(delete_pf("msitest\\buddy", TRUE), "File not moved\n");
    ok(!delete_pf("msitest\\bud", TRUE), "File moved\n");
    ok(delete_pf("msitest\\bar", TRUE), "File not moved\n");
    ok(delete_pf("msitest\\bur", TRUE), "File not moved\n");
    ok(!delete_pf("msitest\\bird", TRUE), "File moved\n");
4710
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736
    ok(DeleteFileA("cameroon"), "File moved\n");
    ok(!DeleteFileA("djibouti"), "File not moved\n");
    ok(DeleteFileA("egypt"), "File moved\n");
    ok(DeleteFileA("finland"), "File moved\n");
    ok(DeleteFileA("gambai"), "File moved\n");
    ok(!DeleteFileA("honduras"), "File not moved\n");
    ok(DeleteFileA("msitest\\india"), "File moved\n");
    ok(DeleteFileA("japan"), "File moved\n");
    ok(!DeleteFileA("kenya"), "File not moved\n");
    ok(RemoveDirectoryA("latvia"), "Directory moved\n");
    ok(!DeleteFileA("nauru"), "File not moved\n");
    ok(!DeleteFileA("peru"), "File not moved\n");
    ok(!DeleteFileA("apple"), "File not moved\n");
    ok(!DeleteFileA("application"), "File not moved\n");
    ok(DeleteFileA("ape"), "File moved\n");
    ok(!DeleteFileA("foo"), "File not moved\n");
    ok(!DeleteFileA("fao"), "File not moved\n");
    ok(DeleteFileA("fbod"), "File moved\n");
    ok(!DeleteFileA("budding"), "File not moved\n");
    ok(!DeleteFileA("buddy"), "File not moved\n");
    ok(DeleteFileA("bud"), "File moved\n");
    ok(!DeleteFileA("bar"), "File not moved\n");
    ok(!DeleteFileA("bur"), "File not moved\n");
    ok(DeleteFileA("bird"), "File moved\n");

error:
4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763
    DeleteFileA("cameroon");
    DeleteFileA("djibouti");
    DeleteFileA("egypt");
    DeleteFileA("finland");
    DeleteFileA("gambai");
    DeleteFileA("honduras");
    DeleteFileA("japan");
    DeleteFileA("kenya");
    DeleteFileA("nauru");
    DeleteFileA("peru");
    DeleteFileA("apple");
    DeleteFileA("application");
    DeleteFileA("ape");
    DeleteFileA("foo");
    DeleteFileA("fao");
    DeleteFileA("fbod");
    DeleteFileA("budding");
    DeleteFileA("buddy");
    DeleteFileA("bud");
    DeleteFileA("bar");
    DeleteFileA("bur");
    DeleteFileA("bird");
    DeleteFileA("msitest\\india");
    DeleteFileA("msitest\\augustus");
    RemoveDirectoryA("latvia");
    RemoveDirectoryA("msitest");
    DeleteFileA(msifile);
4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777
}

static void test_duplicate_files(void)
{
    UINT r;

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

    CreateDirectoryA("msitest", NULL);
    create_file("msitest\\maximus", 500);
4778
    create_database(msifile, df_tables, ARRAY_SIZE(df_tables));
4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    /* fails if the destination folder is not a valid property */

    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 not installed\n");
    ok(delete_pf("msitest\\augustus", TRUE), "File not duplicated\n");
    ok(delete_pf("msitest\\this\\doesnot\\exist\\maximus", TRUE), "File not duplicated\n");
4794 4795 4796 4797
    ok(delete_pf("msitest\\this\\doesnot\\exist", FALSE), "Directory not created\n");
    ok(delete_pf("msitest\\this\\doesnot", FALSE), "Directory not created\n");
    ok(delete_pf("msitest\\this", FALSE), "Directory not created\n");
    ok(delete_pf("msitest", FALSE), "Directory not created\n");
4798 4799

error:
4800 4801 4802
    DeleteFileA("msitest\\maximus");
    RemoveDirectoryA("msitest");
    DeleteFileA(msifile);
4803 4804 4805 4806
}

static void test_write_registry_values(void)
{
4807
    HKEY hkey, subkey;
4808
    DWORD type, size;
4809 4810 4811
    char buf[20];
    LONG res;
    UINT r;
4812 4813 4814 4815 4816 4817 4818 4819 4820

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

    CreateDirectoryA("msitest", NULL);

4821
    create_database(msifile, wrv_tables, ARRAY_SIZE(wrv_tables));
4822 4823 4824

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

4825
    res = RegCreateKeyA(HKEY_CURRENT_USER, "msitest", &hkey);
4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    res = RegSetValueExA(hkey, "Value1", 0, REG_MULTI_SZ, (const BYTE *)"two\0", 5);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    res = RegSetValueExA(hkey, "Value2", 0, REG_MULTI_SZ, (const BYTE *)"one\0", 5);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    res = RegSetValueExA(hkey, "Value3", 0, REG_MULTI_SZ, (const BYTE *)"two\0", 5);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    res = RegSetValueExA(hkey, "Value4", 0, REG_MULTI_SZ, (const BYTE *)"one\0", 5);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    res = RegSetValueExA(hkey, "Value5", 0, REG_MULTI_SZ, (const BYTE *)"one\0two\0", 9);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    res = RegSetValueExA(hkey, "Value6", 0, REG_MULTI_SZ, (const BYTE *)"one\0", 5);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
    res = RegSetValueExA(hkey, "Value7", 0, REG_SZ, (const BYTE *)"one", 4);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4842 4843 4844 4845 4846 4847 4848

    res = RegSetValueExA(hkey, "instremove", 0, REG_SZ, (const BYTE *)"val", 3);
    ok(!res, "got %u\n", res);

    res = RegCreateKeyA(hkey, "instremove", &subkey);
    ok(!res, "got %u\n", res);
    RegCloseKey(subkey);
4849

4850 4851 4852 4853 4854 4855 4856 4857
    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);

4858 4859 4860
    CHECK_REG_STR(hkey, "sz", "string");
    CHECK_REG_MULTI(hkey, "multisz", "one\0two\0three\0");
    CHECK_REG_DWORD(hkey, "dword", 123);
4861

4862 4863 4864 4865 4866
    size = sizeof(buf);
    res = RegQueryValueExA(hkey, "expandsz", NULL, &type, (BYTE *)buf, &size);
    ok(!res, "got %u\n", res);
    ok(type == REG_EXPAND_SZ, "got %d\n", type);
    ok(!strcmp(buf, "string"), "got %s\n", buf);
4867

4868 4869 4870 4871 4872 4873
    size = sizeof(buf);
    res = RegQueryValueExA(hkey, "binary", NULL, &type, (BYTE *)buf, &size);
    ok(!res, "got %u\n", res);
    ok(type == REG_BINARY, "got %d\n", type);
    ok(size == 4, "got size %u\n", size);
    ok(!memcmp(buf, "\x01\x23\x45\x67", 4), "wrong data\n");
4874

4875
    CHECK_REG_STR(hkey, "", "default");
4876

4877
    res = RegOpenKeyA(hkey, "VisualStudio", &subkey);
4878
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911
    RegCloseKey(subkey);

    CHECK_REG_MULTI(hkey, "Value1", "one\0");
    CHECK_REG_MULTI(hkey, "Value2", "one\0two\0");
    CHECK_REG_MULTI(hkey, "Value3", "one\0two\0");
    CHECK_REG_MULTI(hkey, "Value4", "one\0two\0");
    CHECK_REG_MULTI(hkey, "Value5", "one\0two\0three\0");
    CHECK_REG_MULTI(hkey, "Value6", "");
    CHECK_REG_MULTI(hkey, "Value7", "two\0");

    CHECK_REG_DWORD(hkey, "format", 1);
    CHECK_REG_DWORD(hkey, "source", 1);

    res = RegOpenKeyA(hkey, "subkey", &subkey);
    ok(!res, "got %u\n", res);
    res = RegQueryValueExA(subkey, "", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    RegCloseKey(subkey);

    res = RegOpenKeyA(hkey, "create", &subkey);
    ok(!res, "got %u\n", res);
    RegCloseKey(subkey);

    res = RegOpenKeyA(hkey, "delete", &subkey);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegCreateKeyA(hkey, "delete", &subkey);
    ok(!res, "got %u\n", res);
    RegCloseKey(subkey);

    res = RegQueryValueExA(hkey, "instremove", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegOpenKeyA(hkey, "instremove", &subkey);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
4912

4913 4914
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(!r, "got %u\n", r);
4915

4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941
    res = RegQueryValueExA(hkey, "sz", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "multisz", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "dword", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "expandsz", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "binary", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);

    res = RegOpenKeyA(hkey, "VisualStudio", &subkey);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);

    res = RegQueryValueExA(hkey, "Value1", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "Value4", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "Value5", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "Value6", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "Value7", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
4942

4943 4944 4945 4946
todo_wine {
    CHECK_REG_MULTI(hkey, "Value2", "one\0");
    CHECK_REG_MULTI(hkey, "Value3", "two\0");
}
4947

4948 4949 4950 4951
    res = RegQueryValueExA(hkey, "format", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
    res = RegQueryValueExA(hkey, "source", NULL, NULL, NULL, NULL);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
4952

4953 4954
    res = RegOpenKeyA(hkey, "subkey", &subkey);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
4955

4956 4957 4958 4959 4960
    res = RegOpenKeyA(hkey, "create", &subkey);
    ok(!res, "got %u\n", res);
    RegCloseKey(subkey);
    res = RegDeleteKeyA(hkey, "create");
    ok(!res, "got %u\n", res);
4961

4962 4963
    res = RegOpenKeyA(hkey, "delete", &subkey);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);
4964

4965
    RegCloseKey(hkey);
4966 4967
    res = RegDeleteKeyA(HKEY_CURRENT_USER, "msitest");
    ok(!res, "got %u\n", res);
4968 4969

error:
4970 4971
    DeleteFileA(msifile);
    RemoveDirectoryA("msitest");
4972 4973 4974 4975
}

static void test_envvar(void)
{
4976 4977
    char buffer[16];
    UINT r, i;
4978
    HKEY env, env2;
4979 4980 4981 4982 4983 4984 4985 4986
    LONG res;

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

4987
    create_database(msifile, env_tables, ARRAY_SIZE(env_tables));
4988 4989 4990 4991

    res = RegCreateKeyExA(HKEY_CURRENT_USER, "Environment", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &env, NULL);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

4992 4993 4994 4995
    res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Session Manager\\Environment",
                          0, NULL, 0, KEY_ALL_ACCESS, NULL, &env2, NULL);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

4996 4997 4998 4999 5000 5001
    res = RegSetValueExA(env, "MSITESTVAR1", 0, REG_SZ, (const BYTE *)"0", 2);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    res = RegSetValueExA(env, "MSITESTVAR2", 0, REG_SZ, (const BYTE *)"0", 2);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

5002 5003 5004
    res = RegSetValueExA(env, "MSITESTVAR21", 0, REG_SZ, (const BYTE *)"1", 2);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

5005 5006 5007 5008 5009 5010 5011 5012 5013 5014
    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);

5015 5016 5017 5018
    CHECK_REG_STR(env, "MSITESTVAR1", "1");
    CHECK_REG_STR(env, "MSITESTVAR2", "1");
    CHECK_REG_STR(env, "MSITESTVAR3", "1");
    CHECK_REG_STR(env, "MSITESTVAR4", "1");
5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037

    res = RegDeleteValueA(env, "MSITESTVAR5");
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegDeleteValueA(env, "MSITESTVAR6");
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegDeleteValueA(env, "MSITESTVAR7");
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegDeleteValueA(env, "MSITESTVAR8");
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegDeleteValueA(env, "MSITESTVAR9");
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegDeleteValueA(env, "MSITESTVAR10");
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048
    CHECK_REG_STR(env, "MSITESTVAR11", "1;2");
    CHECK_REG_STR(env, "MSITESTVAR12", "1");
    CHECK_REG_STR(env, "MSITESTVAR13", "1;2");
    CHECK_REG_STR(env, "MSITESTVAR14", ";1;");
    CHECK_REG_STR(env, "MSITESTVAR15", ";;1;;");
    CHECK_REG_STR(env, "MSITESTVAR16", " 1 ");
    CHECK_REG_STR(env, "MSITESTVAR17", ";;2;;1");
    CHECK_REG_STR(env, "MSITESTVAR18", "1;;2;;");
    CHECK_REG_STR(env, "MSITESTVAR19", "1");
    CHECK_REG_STR(env, "MSITESTVAR20", "1");
    CHECK_REG_STR(env, "MSITESTVAR21", "1");
5049
    CHECK_REG_STR(env, "MSITESTVAR24", "TestService");
5050
    CHECK_REG_STR(env2, "MSITESTVAR100", "1");
5051 5052 5053 5054 5055 5056 5057

    res = RegSetValueExA(env, "MSITESTVAR22", 0, REG_SZ, (const BYTE *)"1", 2);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    res = RegSetValueExA(env, "MSITESTVAR23", 0, REG_SZ, (const BYTE *)"1", 2);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

5058 5059 5060
    res = RegDeleteValueA(env, "MSITESTVAR25");
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

5061 5062 5063 5064 5065 5066 5067
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(!r, "got %u\n", r);

    CHECK_DEL_REG_STR(env, "MSITESTVAR13", "1;2");
    CHECK_DEL_REG_STR(env, "MSITESTVAR14", ";1;");
    CHECK_DEL_REG_STR(env, "MSITESTVAR15", ";;1;;");
    CHECK_DEL_REG_STR(env, "MSITESTVAR16", " 1 ");
5068 5069
    CHECK_DEL_REG_STR_TODO(env, "MSITESTVAR17", "1");
    CHECK_DEL_REG_STR_TODO(env, "MSITESTVAR18", "1");
5070 5071 5072
    CHECK_DEL_REG_STR(env, "MSITESTVAR23", "1");

    for (i = 1; i <= 23; i++)
5073
    {
5074 5075 5076
        sprintf(buffer, "MSITESTVAR%i", i);
        res = RegDeleteValueA(env, buffer);
        ok(res == ERROR_FILE_NOT_FOUND, "[%d] got %u\n", i, res);
5077 5078
    }

5079 5080 5081
    res = RegDeleteValueA(env2, "MSITESTVAR100");
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

5082 5083 5084
error:
    RegDeleteValueA(env, "MSITESTVAR1");
    RegDeleteValueA(env, "MSITESTVAR2");
5085
    RegDeleteValueA(env, "MSITESTVAR21");
5086
    RegCloseKey(env);
5087
    RegCloseKey(env2);
5088

5089
    DeleteFileA(msifile);
5090 5091
}

5092
static void test_create_remove_folder(void)
5093 5094 5095
{
    UINT r;

5096 5097 5098 5099 5100 5101
    if (is_process_limited())
    {
        skip("process is limited\n");
        return;
    }

5102 5103 5104 5105 5106
    CreateDirectoryA("msitest", NULL);
    CreateDirectoryA("msitest\\first", NULL);
    CreateDirectoryA("msitest\\second", NULL);
    create_file("msitest\\first\\one.txt", 1000);
    create_file("msitest\\second\\two.txt", 1000);
5107
    create_database(msifile, cf_tables, ARRAY_SIZE(cf_tables));
5108 5109 5110 5111 5112 5113 5114 5115 5116

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5117
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5118

5119 5120 5121 5122 5123 5124
    ok(pf_exists("msitest\\first\\one.txt"), "file not installed\n");
    ok(pf_exists("msitest\\first"), "directory not created\n");
    ok(pf_exists("msitest\\second\\two.txt"), "file not installed\n");
    ok(pf_exists("msitest\\second"), "directory not created\n");
    ok(pf_exists("msitest\\third"), "directory not created\n");
    ok(pf_exists("msitest"), "directory not created\n");
5125

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

5129 5130 5131 5132 5133 5134
    ok(!pf_exists("msitest\\first\\one.txt"), "file not removed\n");
    ok(!pf_exists("msitest\\first"), "directory not removed\n");
    ok(!pf_exists("msitest\\second\\two.txt"), "file not removed\n");
    ok(!pf_exists("msitest\\second"), "directory not removed\n");
    ok(!pf_exists("msitest\\third"), "directory not removed\n");
    todo_wine ok(!pf_exists("msitest"), "directory not removed\n");
5135 5136

error:
5137 5138 5139 5140 5141
    DeleteFileA("msitest\\first\\one.txt");
    DeleteFileA("msitest\\second\\two.txt");
    RemoveDirectoryA("msitest\\first");
    RemoveDirectoryA("msitest\\second");
    RemoveDirectoryA("msitest");
5142
    DeleteFileA(msifile);
5143 5144
}

5145
static void test_start_stop_services(void)
5146 5147 5148 5149 5150 5151
{
    UINT r;
    SC_HANDLE scm, service;
    BOOL ret;
    DWORD error = ERROR_SUCCESS;

5152
    scm = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
5153 5154 5155 5156 5157 5158 5159 5160
    if (!scm && GetLastError() == ERROR_ACCESS_DENIED)
    {
        skip("Not enough rights to perform tests\n");
        return;
    }
    ok(scm != NULL, "Failed to open the SC Manager\n");
    if (!scm) return;

5161
    service = OpenServiceA(scm, "Spooler", SC_MANAGER_ALL_ACCESS);
5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173
    if (!service && GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST)
    {
        win_skip("The 'Spooler' service does not exist\n");
        CloseServiceHandle(scm);
        return;
    }
    ok(service != NULL, "Failed to open Spooler, error %d\n", GetLastError());
    if (!service) {
        CloseServiceHandle(scm);
        return;
    }

5174
    ret = StartServiceA(service, 0, NULL);
5175 5176
    if (!ret && (error = GetLastError()) != ERROR_SERVICE_ALREADY_RUNNING)
    {
5177
        skip("Spooler service not available, skipping test\n");
5178 5179 5180 5181 5182 5183 5184 5185 5186
        CloseServiceHandle(service);
        CloseServiceHandle(scm);
        return;
    }

    CloseServiceHandle(service);
    CloseServiceHandle(scm);

    create_test_files();
5187
    create_database(msifile, sss_tables, ARRAY_SIZE(sss_tables));
5188 5189 5190 5191 5192 5193

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

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

5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210
    if (error == ERROR_SUCCESS)
    {
        SERVICE_STATUS status;

        scm = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
        service = OpenServiceA(scm, "Spooler", SC_MANAGER_ALL_ACCESS);

        ret = ControlService(service, SERVICE_CONTROL_STOP, &status);
        ok(ret, "ControlService failed %u\n", GetLastError());

        CloseServiceHandle(service);
        CloseServiceHandle(scm);
    }

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

5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221
    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\\filename", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
5222
    ok(delete_pf("msitest\\service2.exe", TRUE), "File not installed\n");
5223 5224 5225 5226 5227 5228
    ok(delete_pf("msitest", FALSE), "Directory not created\n");

    if (error == ERROR_SUCCESS)
    {
        SERVICE_STATUS status;

5229 5230
        scm = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
        service = OpenServiceA(scm, "Spooler", SC_MANAGER_ALL_ACCESS);
5231 5232 5233 5234 5235 5236 5237

        ret = ControlService(service, SERVICE_CONTROL_STOP, &status);
        ok(ret, "ControlService failed %u\n", GetLastError());

        CloseServiceHandle(service);
        CloseServiceHandle(scm);
    }
5238 5239 5240

    delete_test_files();
    DeleteFileA(msifile);
5241 5242
}

5243
static void delete_test_service(const char *name)
5244 5245 5246 5247 5248 5249
{
    BOOL ret;
    SC_HANDLE manager, service;

    manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    ok(manager != NULL, "can't open service manager\n");
5250
    if (!manager) return;
5251

5252
    service = OpenServiceA(manager, name, GENERIC_ALL);
5253 5254 5255 5256 5257 5258 5259 5260 5261
    if (service)
    {
        ret = DeleteService( service );
        ok( ret, "failed to delete service %u\n", GetLastError() );
        CloseServiceHandle(service);
    }
    CloseServiceHandle(manager);
}

5262 5263 5264
static void test_delete_services(void)
{
    UINT r;
5265 5266
    SC_HANDLE manager, service;
    DWORD error;
5267 5268 5269 5270 5271 5272 5273

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

5274
    manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
5275 5276 5277 5278 5279 5280 5281 5282 5283
    ok(manager != NULL, "can't open service manager %u\n", GetLastError());
    if (!manager) return;

    service = CreateServiceA(manager, "TestService3", "TestService3",
        SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START,
        SERVICE_ERROR_NORMAL, "C:\\doesnt_exist.exe", NULL, NULL, NULL, NULL, NULL);
    ok(service != NULL, "can't create service %u\n", GetLastError());
    CloseServiceHandle(service);
    CloseServiceHandle(manager);
5284
    if (!service) return;
5285

5286
    create_test_files();
5287
    create_database(msifile, sds_tables, ARRAY_SIZE(sds_tables));
5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298

    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);

5299
    manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
5300 5301 5302 5303 5304 5305 5306 5307 5308
    ok(manager != NULL, "can't open service manager\n");
    if (!manager) goto error;

    service = OpenServiceA(manager, "TestService3", GENERIC_ALL);
    error = GetLastError();
    ok(service == NULL, "TestService3 not deleted\n");
    ok(error == ERROR_SERVICE_DOES_NOT_EXIST, "wrong error %u\n", error);
    CloseServiceHandle(manager);

5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    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\\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\\filename", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
5323
    ok(delete_pf("msitest\\service2.exe", TRUE), "File not installed\n");
5324 5325 5326
    ok(delete_pf("msitest", FALSE), "Directory not created\n");

error:
5327 5328 5329
    delete_test_service("TestService");
    delete_test_service("TestService2");
    delete_test_service("TestService3");
5330
    delete_test_files();
5331
    DeleteFileA(msifile);
5332 5333
}

5334 5335 5336 5337
static void test_install_services(void)
{
    UINT r;
    SC_HANDLE manager, service;
5338 5339 5340
    LONG res;
    HKEY hKey;
    DWORD err_control, err_controlsize, err_controltype;
5341 5342 5343 5344 5345 5346 5347 5348

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

    create_test_files();
5349
    create_database(msifile, sis_tables, ARRAY_SIZE(sis_tables));
5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371

    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);

    manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    ok(manager != NULL, "can't open service manager\n");
    if (!manager) goto error;

    service = OpenServiceA(manager, "TestService", GENERIC_ALL);
    ok(service != NULL, "TestService not installed\n");
    CloseServiceHandle(service);

    service = OpenServiceA(manager, "TestService4", GENERIC_ALL);
    ok(service == NULL, "TestService4 installed\n");

5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384
    res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\TestService", &hKey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);

    if (res == ERROR_SUCCESS)
    {
        err_control = 0xBEEF;
        err_controltype = REG_DWORD;
        err_controlsize = sizeof(err_control);
        res = RegQueryValueExA(hKey, "ErrorControl", NULL, &err_controltype, (LPBYTE)&err_control, &err_controlsize);
        ok(err_control == 0, "TestService.ErrorControl wrong, expected 0, got %u\n", err_control);
        RegCloseKey(hKey);
    }

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

5388 5389 5390 5391 5392
    service = OpenServiceA(manager, "TestService", GENERIC_ALL);
    ok(service != NULL, "TestService deleted\n");
    CloseServiceHandle(service);
    CloseServiceHandle(manager);

5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407
    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\\filename", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\service2.exe", TRUE), "File not installed\n");
    ok(delete_pf("msitest", FALSE), "Directory not created\n");

error:
5408
    delete_test_service("TestService");
5409 5410 5411 5412
    delete_test_files();
    DeleteFileA(msifile);
}

5413 5414
static void test_self_registration(void)
{
5415
    HKEY key;
5416 5417 5418 5419 5420 5421 5422 5423 5424
    UINT r;

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

    create_test_files();
5425
    extract_resource("selfreg.dll", "TESTDLL", "msitest\\selfreg.dll");
5426
    create_database(msifile, sr_tables, ARRAY_SIZE(sr_tables));
5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437

    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);

5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449
    r = RegOpenKeyA(HKEY_CLASSES_ROOT, "selfreg_test", &key);
    ok(!r, "got %u\n", r);
    RegCloseKey(key);

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

    r = RegOpenKeyA(HKEY_CLASSES_ROOT, "selfreg_test", &key);
    ok(r == ERROR_FILE_NOT_FOUND, "got %u\n", r);

    ok(!delete_pf("msitest\\selfreg.dll", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");
5450 5451

error:
5452
    DeleteFileA("msitest\\selfreg.dll");
5453
    delete_test_files();
5454
    DeleteFileA(msifile);
5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473
}

static void test_register_font(void)
{
    static const char regfont1[] = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
    static const char regfont2[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Fonts";
    LONG ret;
    HKEY key;
    UINT r;
    REGSAM access = KEY_ALL_ACCESS;

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

    create_test_files();
    create_file("msitest\\font.ttf", 1000);
5474
    create_database(msifile, font_tables, ARRAY_SIZE(font_tables));
5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509

    if (is_wow64)
        access |= KEY_WOW64_64KEY;

    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);

    ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, regfont1, 0, access, &key);
    if (ret)
        RegOpenKeyExA(HKEY_LOCAL_MACHINE, regfont2, 0, access, &key);

    ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL);
    ok(ret != ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret);

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

    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

    ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL);
    ok(ret == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret);

    RegDeleteValueA(key, "msi test font");
    RegCloseKey(key);

error:
    DeleteFileA("msitest\\font.ttf");
    delete_test_files();
5510
    DeleteFileA(msifile);
5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523
}

static void test_validate_product_id(void)
{
    UINT r;

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

    create_test_files();
5524
    create_database(msifile, vp_tables, ARRAY_SIZE(vp_tables));
5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555

    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);

    r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=1");
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);

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

    r = MsiInstallProductA(msifile, "PIDKEY=123-1234567");
    ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, 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\\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\\filename", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
    ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
5556
    ok(delete_pf("msitest\\service2.exe", TRUE), "File not installed\n");
5557 5558 5559 5560
    ok(delete_pf("msitest", FALSE), "Directory not created\n");

error:
    delete_test_files();
5561
    DeleteFileA(msifile);
5562 5563 5564 5565
}

static void test_install_remove_odbc(void)
{
5566 5567 5568
    int gotdriver = 0, gotdriver2 = 0;
    char buffer[1000], *p;
    WORD len;
5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582
    UINT r;

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

    create_test_files();
    create_file("msitest\\ODBCdriver.dll", 1000);
    create_file("msitest\\ODBCdriver2.dll", 1000);
    create_file("msitest\\ODBCtranslator.dll", 1000);
    create_file("msitest\\ODBCtranslator2.dll", 1000);
    create_file("msitest\\ODBCsetup.dll", 1000);
5583
    create_database(msifile, odbc_tables, ARRAY_SIZE(odbc_tables));
5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600

    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(pf_exists("msitest\\ODBCdriver.dll"), "file not created\n");
    ok(pf_exists("msitest\\ODBCdriver2.dll"), "file not created\n");
    ok(pf_exists("msitest\\ODBCtranslator.dll"), "file not created\n");
    ok(pf_exists("msitest\\ODBCtranslator2.dll"), "file not created\n");
    ok(pf_exists("msitest\\ODBCsetup.dll"), "file not created\n");

5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613
    r = SQLGetInstalledDrivers(buffer, sizeof(buffer), &len);
    ok(len < sizeof(buffer), "buffer too small\n");
    ok(r, "SQLGetInstalledDrivers failed\n");
    for (p = buffer; *p; p += strlen(p) + 1)
    {
        if (!strcmp(p, "ODBC test driver"))
            gotdriver = 1;
        if (!strcmp(p, "ODBC test driver2"))
            gotdriver2 = 1;
    }
    ok(gotdriver, "driver not installed\n");
    ok(gotdriver2, "driver 2 not installed\n");

5614 5615 5616 5617 5618 5619 5620 5621 5622 5623
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    ok(!delete_pf("msitest\\ODBCdriver.dll", TRUE), "file not removed\n");
    ok(!delete_pf("msitest\\ODBCdriver2.dll", TRUE), "file not removed\n");
    ok(!delete_pf("msitest\\ODBCtranslator.dll", TRUE), "file not removed\n");
    ok(!delete_pf("msitest\\ODBCtranslator2.dll", TRUE), "file not removed\n");
    ok(!delete_pf("msitest\\ODBCsetup.dll", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637
    gotdriver = gotdriver2 = 0;
    r = SQLGetInstalledDrivers(buffer, sizeof(buffer), &len);
    ok(len < sizeof(buffer), "buffer too small\n");
    ok(r, "SQLGetInstalledDrivers failed\n");
    for (p = buffer; *p; p += strlen(p) + 1)
    {
        if (!strcmp(p, "ODBC test driver"))
            gotdriver = 1;
        if (!strcmp(p, "ODBC test driver2"))
            gotdriver2 = 1;
    }
    ok(!gotdriver, "driver not installed\n");
    ok(!gotdriver2, "driver 2 not installed\n");

5638 5639 5640 5641 5642 5643 5644
error:
    DeleteFileA("msitest\\ODBCdriver.dll");
    DeleteFileA("msitest\\ODBCdriver2.dll");
    DeleteFileA("msitest\\ODBCtranslator.dll");
    DeleteFileA("msitest\\ODBCtranslator2.dll");
    DeleteFileA("msitest\\ODBCsetup.dll");
    delete_test_files();
5645
    DeleteFileA(msifile);
5646 5647 5648 5649
}

static void test_register_typelib(void)
{
5650 5651
    ITypeLib *tlb;
    HRESULT hr;
5652 5653 5654 5655 5656 5657 5658 5659
    UINT r;

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

5660
    /* UnregisterTypeLibraries action fails in 64-bit Windows <= 7 */
5661
    if (sizeof(void *) == 8 && strcmp( winetest_platform, "wine" ))
5662 5663 5664 5665 5666
    {
        win_skip("broken on 64-bit Windows\n");
        return;
    }

5667
    create_test_files();
5668
    extract_resource("typelib.tlb", "TYPELIB", "msitest\\typelib.dll");
5669
    create_database(msifile, tl_tables, ARRAY_SIZE(tl_tables));
5670 5671 5672

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

5673
    r = MsiInstallProductA(msifile, NULL);
5674 5675 5676 5677 5678
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
5679
    ok(r == ERROR_SUCCESS, "got %u\n", r);
5680

5681 5682 5683
    hr = LoadRegTypeLib(&LIBID_register_test, 7, 1, 0, &tlb);
    ok(hr == S_OK, "got %#x\n", hr);
    ITypeLib_Release(tlb);
5684 5685 5686 5687

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

5688 5689 5690
    hr = LoadRegTypeLib(&LIBID_register_test, 7, 1, 0, &tlb);
    ok(hr == TYPE_E_LIBNOTREGISTERED, "got %#x\n", hr);

5691 5692 5693 5694 5695 5696
    ok(!delete_pf("msitest\\typelib.dll", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\typelib.dll");
    delete_test_files();
5697
    DeleteFileA(msifile);
5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711
}

static void test_create_remove_shortcut(void)
{
    UINT r;

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

    create_test_files();
    create_file("msitest\\target.txt", 1000);
5712
    create_database(msifile, crs_tables, ARRAY_SIZE(crs_tables));
5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736

    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(pf_exists("msitest\\target.txt"), "file not created\n");
    ok(pf_exists("msitest\\shortcut.lnk"), "file not created\n");

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

    ok(!delete_pf("msitest\\shortcut.lnk", TRUE), "file not removed\n");
    ok(!delete_pf("msitest\\target.txt", TRUE), "file not removed\n");
    todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\target.txt");
    delete_test_files();
5737
    DeleteFileA(msifile);
5738 5739 5740 5741
}

static void test_publish_components(void)
{
5742
    static const char keypath[] =
5743
        "Software\\Microsoft\\Installer\\Components\\0CBCFA296AC907244845745CEEB2F8AA";
5744 5745
    static const char keypath2[] =
        "Software\\Classes\\Installer\\Components\\0CBCFA296AC907244845745CEEB2F8AA";
5746 5747 5748 5749

    UINT r;
    LONG res;
    HKEY key;
5750 5751
    BYTE *data;
    DWORD size;
5752 5753 5754 5755 5756 5757 5758 5759 5760

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

    create_test_files();
    create_file("msitest\\english.txt", 1000);
5761
    create_database(msifile, pub_tables, ARRAY_SIZE(pub_tables));
5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772

    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);

5773 5774 5775
    size = 0;
    r = MsiProvideQualifiedComponentA("{92AFCBC0-9CA6-4270-8454-47C5EE2B8FAA}",
            "english.txt", INSTALLMODE_DEFAULT, NULL, &size);
5776
    ok(r == ERROR_SUCCESS, "MsiProvideQualifiedComponent returned %d\n", r);
5777

5778 5779 5780
    res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key);
    ok(res == ERROR_SUCCESS, "components key not created %d\n", res);

5781 5782 5783 5784 5785
    res = RegQueryValueExA(key, "english.txt", NULL, NULL, NULL, &size);
    ok(res == ERROR_SUCCESS, "value not found %d\n", res);

    data = HeapAlloc(GetProcessHeap(), 0, size);
    res = RegQueryValueExA(key, "english.txt", NULL, NULL, data, &size);
5786 5787 5788
    ok(res == ERROR_SUCCESS, "value not found %d\n", res);
    RegCloseKey(key);

5789 5790 5791
    res = RegDeleteKeyA(HKEY_CURRENT_USER, keypath);
    ok(res == ERROR_SUCCESS, "RegDeleteKey failed %d\n", res);

5792 5793
    res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath2, 0, NULL, REG_OPTION_NON_VOLATILE,
            MAXIMUM_ALLOWED | KEY_WOW64_64KEY, NULL, &key, NULL );
5794
    ok(res == ERROR_SUCCESS, "RegCreateKeyEx failed %d\n", res);
5795 5796 5797 5798 5799 5800 5801
    res = RegSetValueExA(key, "english.txt", 0, REG_MULTI_SZ, data, size);
    ok(res == ERROR_SUCCESS, "RegSetValueEx failed %d\n", res);
    RegCloseKey(key);

    size = 0;
    r = MsiProvideQualifiedComponentA("{92AFCBC0-9CA6-4270-8454-47C5EE2B8FAA}",
            "english.txt", INSTALLMODE_DEFAULT, NULL, &size);
5802
    ok(r == ERROR_SUCCESS, "MsiProvideQualifiedComponent returned %d\n", r);
5803

5804 5805 5806 5807
    if (pRegDeleteKeyExA)
        res = pRegDeleteKeyExA(HKEY_LOCAL_MACHINE, keypath2, KEY_WOW64_64KEY, 0);
    else
        res = RegDeleteKeyA(HKEY_LOCAL_MACHINE, keypath2);
5808 5809 5810 5811 5812 5813 5814 5815 5816 5817
    ok(res == ERROR_SUCCESS, "RegDeleteKey failed %d\n", res);

    res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &key);
    ok(res == ERROR_SUCCESS, "RegCreateKey failed %d\n", res);

    res = RegSetValueExA(key, "english.txt", 0, REG_MULTI_SZ, data, size);
    ok(res == ERROR_SUCCESS, "RegSetValueEx failed %d\n", res);
    HeapFree(GetProcessHeap(), 0, data);
    RegCloseKey(key);

5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key);
    ok(res == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", res);

    ok(!delete_pf("msitest\\english.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\english.txt");
    delete_test_files();
5830
    DeleteFileA(msifile);
5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846
}

static void test_remove_duplicate_files(void)
{
    UINT r;

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

    create_test_files();
    create_file("msitest\\original.txt", 1000);
    create_file("msitest\\original2.txt", 1000);
    create_file("msitest\\original3.txt", 1000);
5847
    create_database(msifile, rd_tables, ARRAY_SIZE(rd_tables));
5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879

    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(pf_exists("msitest\\original.txt"), "file not created\n");
    ok(pf_exists("msitest\\original2.txt"), "file not created\n");
    ok(!pf_exists("msitest\\original3.txt"), "file created\n");
    ok(pf_exists("msitest\\duplicate.txt"), "file not created\n");
    ok(!pf_exists("msitest\\duplicate2.txt"), "file created\n");

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

    ok(delete_pf("msitest\\original.txt", TRUE), "file removed\n");
    ok(!delete_pf("msitest\\original2.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest\\original3.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest\\duplicate.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest\\duplicate2.txt", TRUE), "file not removed\n");
    ok(delete_pf("msitest", FALSE), "directory removed\n");

error:
    DeleteFileA("msitest\\original.txt");
    DeleteFileA("msitest\\original2.txt");
    DeleteFileA("msitest\\original3.txt");
    delete_test_files();
5880
    DeleteFileA(msifile);
5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894
}

static void test_find_related_products(void)
{
    UINT r;

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

    create_test_files();
    create_file("msitest\\product.txt", 1000);
5895
    create_database(msifile, frp_tables, ARRAY_SIZE(frp_tables));
5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919

    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);

    /* install again, so it finds the upgrade code */
    r = MsiInstallProductA(msifile, NULL);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

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

    ok(!delete_pf("msitest\\product.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\product.txt");
    delete_test_files();
5920
    DeleteFileA(msifile);
5921 5922
}

5923
static void test_ini_values(void)
5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938
{
    UINT r;
    DWORD len;
    char inifile[MAX_PATH], buf[0x10];
    HANDLE file;
    BOOL ret;

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

    create_test_files();
    create_file("msitest\\inifile.txt", 1000);
5939
    create_database(msifile, ini_tables, ARRAY_SIZE(ini_tables));
5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982

    lstrcpyA(inifile, PROG_FILES_DIR);
    lstrcatA(inifile, "\\msitest");
    ret = CreateDirectoryA(inifile, NULL);
    if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
    {
        skip("Not enough rights to perform tests\n");
        goto error;
    }
    lstrcatA(inifile, "\\test.ini");
    file = CreateFileA(inifile, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, 0, NULL);
    CloseHandle(file);

    ret = WritePrivateProfileStringA("sectionA", "keyA", "valueA", inifile);
    ok(ret, "failed to write profile string %u\n", GetLastError());

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

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

    len = GetPrivateProfileStringA("section1", "key1", NULL, buf, sizeof(buf), inifile);
    ok(len == 6, "got %u expected 6\n", len);

    len = GetPrivateProfileStringA("sectionA", "keyA", NULL, buf, sizeof(buf), inifile);
    ok(!len, "got %u expected 0\n", len);

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

    len = GetPrivateProfileStringA("section1", "key1", NULL, buf, sizeof(buf), inifile);
    ok(!len, "got %u expected 0\n", len);

    len = GetPrivateProfileStringA("sectionA", "keyA", NULL, buf, sizeof(buf), inifile);
    ok(!len, "got %u expected 0\n", len);

    todo_wine ok(!delete_pf("msitest\\test.ini", TRUE), "file removed\n");
    ok(!delete_pf("msitest\\inifile.txt", TRUE), "file not removed\n");
    ok(delete_pf("msitest", FALSE), "directory removed\n");

error:
    DeleteFileA("msitest\\inifile.txt");
    delete_test_files();
5983
    DeleteFileA(msifile);
5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999
}

static void test_register_class_info(void)
{
    UINT r;
    LONG res;
    HKEY hkey;

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

    create_test_files();
    create_file("msitest\\class.txt", 1000);
6000
    create_database(msifile, rci_tables, ARRAY_SIZE(rci_tables));
6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011

    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);

6012
    if (is_64bit)
6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029
        res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Wow6432Node\\CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    else
        res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "FileType\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "AppID\\{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

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

6030
    if (is_64bit)
6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047
        res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Wow6432Node\\CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    else
        res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "FileType\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "AppID\\{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    ok(!delete_pf("msitest\\class.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\class.txt");
    delete_test_files();
6048
    DeleteFileA(msifile);
6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064
}

static void test_register_extension_info(void)
{
    UINT r;
    LONG res;
    HKEY hkey;

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

    create_test_files();
    create_file("msitest\\extension.txt", 1000);
6065
    create_database(msifile, rei_tables, ARRAY_SIZE(rei_tables));
6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099

    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);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, ".extension", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Prog.Id.1\\shell\\Open\\command", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

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

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, ".extension", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Prog.Id.1", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    ok(!delete_pf("msitest\\extension.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\extension.txt");
    delete_test_files();
6100
    DeleteFileA(msifile);
6101 6102
}

6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116
static void test_register_progid_info(void)
{
    UINT r;
    LONG res;
    HKEY hkey;

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

    create_test_files();
    create_file("msitest\\progid.txt", 1000);
6117
    create_database(msifile, rpi_tables, ARRAY_SIZE(rpi_tables));
6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161

    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, "Winetest.Orphaned", 0, NULL, 0,
                          KEY_ALL_ACCESS, NULL, &hkey, NULL);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    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);

    if (is_64bit)
        res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Wow6432Node\\CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    else
        res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Class.1", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Class", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Class.2", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.VerClass.1", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.VerClass", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.NoProgIdClass.1", &hkey);
6162
    ok(res == ERROR_FILE_NOT_FOUND, "key created\n");
6163 6164 6165 6166 6167 6168
    if (res == ERROR_SUCCESS) RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.NoProgIdClass", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key created\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Orphaned", &hkey);
6169
    ok(res == ERROR_SUCCESS, "key deleted\n");
6170 6171 6172 6173 6174
    if (res == ERROR_SUCCESS) RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Orphaned2", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key created\n");

6175 6176 6177 6178
    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Extension", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209
    r = MsiInstallProductA(msifile, "REMOVE=ALL");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    if (is_64bit)
        res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Wow6432Node\\CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    else
        res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Class.1", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Class", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Class.2", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.VerClass.1", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.VerClass", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.NoProgIdClass.1", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.NoProgIdClass", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Orphaned", &hkey);
6210
    ok(res == ERROR_SUCCESS, "key deleted\n");
6211 6212 6213 6214 6215
    if (res == ERROR_SUCCESS) RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Orphaned2", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

6216 6217 6218
    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Winetest.Extension", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

6219 6220 6221 6222 6223 6224 6225 6226 6227 6228
    ok(!delete_pf("msitest\\progid.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\progid.txt");
    delete_test_files();
    DeleteFileA(msifile);
    RegDeleteKeyA(HKEY_CLASSES_ROOT, "Winetest.Orphaned");
}

6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242
static void test_register_mime_info(void)
{
    UINT r;
    LONG res;
    HKEY hkey;

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

    create_test_files();
    create_file("msitest\\mime.txt", 1000);
6243
    create_database(msifile, rmi_tables, ARRAY_SIZE(rmi_tables));
6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270

    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);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "MIME\\Database\\Content Type\\mime/type", &hkey);
    ok(res == ERROR_SUCCESS, "key not created\n");
    RegCloseKey(hkey);

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

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, "MIME\\Database\\Content Type\\mime/type", &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");

    ok(!delete_pf("msitest\\mime.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\mime.txt");
    delete_test_files();
6271
    DeleteFileA(msifile);
6272 6273
}

6274 6275 6276 6277 6278 6279 6280 6281 6282 6283
static void test_publish_assemblies(void)
{
    static const char manifest[] =
        "<assemblyIdentity type=\"win32\" name=\"Wine.Win32.Assembly\" "
        "version=\"1.0.0.0\" publicKeyToken=\"abcdef0123456789\" "
        "processorArchitecture=\"x86\"/>";
    static const char manifest_local[] =
        "<assemblyIdentity type=\"win32\" name=\"Wine.Win32.Local.Assembly\" "
        "version=\"1.0.0.0\" publicKeyToken=\"abcdef0123456789\" "
        "processorArchitecture=\"x86\"/>";
6284 6285 6286 6287 6288 6289
    static const char classes_path_dotnet[] =
        "Installer\\Assemblies\\Global";
    static const char classes_path_dotnet_local[] =
        "Installer\\Assemblies\\C:|Program Files|msitest|application_dotnet.txt";
    static const char classes_path_dotnet_local_wow64[] =
        "Installer\\Assemblies\\C:|Program Files (x86)|msitest|application_dotnet.txt";
6290 6291 6292 6293
    static const char classes_path_fake_local[] =
        "Installer\\Assemblies\\C:|Program Files|msitest|nonexistent.txt";
    static const char classes_path_fake_local_wow64[] =
        "Installer\\Assemblies\\C:|Program Files (x86)|msitest|nonexistent.txt";
6294 6295 6296 6297 6298 6299
    static const char classes_path_win32[] =
        "Installer\\Win32Assemblies\\Global";
    static const char classes_path_win32_local[] =
        "Installer\\Win32Assemblies\\C:|Program Files|msitest|application_win32.txt";
    static const char classes_path_win32_local_wow64[] =
        "Installer\\Win32Assemblies\\C:|Program Files (x86)|msitest|application_win32.txt";
6300 6301 6302 6303 6304 6305
    static const char path_dotnet[] =
        "Software\\Microsoft\\Installer\\Assemblies\\Global";
    static const char path_dotnet_local[] =
        "Software\\Microsoft\\Installer\\Assemblies\\C:|Program Files|msitest|application_dotnet.txt";
    static const char path_dotnet_local_wow64[] =
        "Software\\Microsoft\\Installer\\Assemblies\\C:|Program Files (x86)|msitest|application_dotnet.txt";
6306 6307 6308 6309
    static const char path_fake_local[] =
        "Software\\Microsoft\\Installer\\Assemblies\\C:|Program Files|msitest|nonexistent.txt";
    static const char path_fake_local_wow64[] =
        "Software\\Microsoft\\Installer\\Assemblies\\C:|Program Files (x86)|msitest|nonexistent.txt";
6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331
    static const char path_win32[] =
        "Software\\Microsoft\\Installer\\Win32Assemblies\\Global";
    static const char path_win32_local[] =
        "Software\\Microsoft\\Installer\\Win32Assemblies\\C:|Program Files|msitest|application_win32.txt";
    static const char path_win32_local_wow64[] =
        "Software\\Microsoft\\Installer\\Win32Assemblies\\C:|Program Files (x86)|msitest|application_win32.txt";
    static const char name_dotnet[] =
        "Wine.Dotnet.Assembly,processorArchitecture=\"MSIL\",publicKeyToken=\"abcdef0123456789\","
        "version=\"1.0.0.0\",culture=\"neutral\"";
    static const char name_dotnet_local[] =
        "Wine.Dotnet.Local.Assembly,processorArchitecture=\"MSIL\",publicKeyToken=\"abcdef0123456789\","
        "version=\"1.0.0.0\",culture=\"neutral\"";
    static const char name_win32[] =
        "Wine.Win32.Assembly,processorArchitecture=\"x86\",publicKeyToken=\"abcdef0123456789\","
        "type=\"win32\",version=\"1.0.0.0\"";
    static const char name_win32_local[] =
        "Wine.Win32.Local.Assembly,processorArchitecture=\"x86\",publicKeyToken=\"abcdef0123456789\","
        "type=\"win32\",version=\"1.0.0.0\"";
    UINT r;
    LONG res;
    HKEY hkey;
    const char *path;
6332
    int access;
6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348

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

    create_test_files();
    create_file("msitest\\win32.txt", 1000);
    create_file("msitest\\win32_local.txt", 1000);
    create_file("msitest\\dotnet.txt", 1000);
    create_file("msitest\\dotnet_local.txt", 1000);
    create_file_data("msitest\\manifest.txt", manifest, 0);
    create_file_data("msitest\\manifest_local.txt", manifest_local, 0);
    create_file("msitest\\application_win32.txt", 1000);
    create_file("msitest\\application_dotnet.txt", 1000);
6349
    create_file("msitest\\fake_local.txt", 1000);
6350
    create_database(msifile, pa_tables, ARRAY_SIZE(pa_tables));
6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363

    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);

    r = MsiInstallProductA(msifile, NULL);
    if (r == ERROR_INSTALL_PACKAGE_REJECTED)
    {
        skip("Not enough rights to perform tests\n");
        goto done;
    }
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    res = RegOpenKeyA(HKEY_CURRENT_USER, path_dotnet, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6364
    CHECK_REG_MULTI(hkey, name_dotnet, "rcHQPHq?CA@Uv-XqMI1e>Z'q,T*76M@=YEg6My?~]\0");
6365 6366 6367 6368 6369
    RegCloseKey(hkey);

    path = (is_wow64 || is_64bit) ? path_dotnet_local_wow64 : path_dotnet_local;
    res = RegOpenKeyA(HKEY_CURRENT_USER, path, &hkey);
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6370
    CHECK_REG_MULTI(hkey, name_dotnet_local, "rcHQPHq?CA@Uv-XqMI1e>LF,8A?0d.AW@vcZ$Cgox\0");
6371 6372 6373
    RegCloseKey(hkey);

    res = RegOpenKeyA(HKEY_CURRENT_USER, path_win32, &hkey);
6374
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6375
    CHECK_REG_MULTI(hkey, name_win32, "rcHQPHq?CA@Uv-XqMI1e>}NJjwR'%D9v1p!v{WV(%\0");
6376 6377 6378 6379
    RegCloseKey(hkey);

    path = (is_wow64 || is_64bit) ? path_win32_local_wow64 : path_win32_local;
    res = RegOpenKeyA(HKEY_CURRENT_USER, path, &hkey);
6380
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6381
    CHECK_REG_MULTI(hkey, name_win32_local, "rcHQPHq?CA@Uv-XqMI1e>C)Uvlj*53A)u(QQ9=)X!\0");
6382 6383
    RegCloseKey(hkey);

6384 6385 6386 6387 6388
    /* No registration is done for a local assembly with no matching file */
    path = (is_wow64 || is_64bit) ? path_fake_local_wow64 : path_fake_local;
    res = RegOpenKeyA(HKEY_CURRENT_USER, path, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);

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

    res = RegOpenKeyA(HKEY_CURRENT_USER, path_dotnet, &hkey);
6393 6394 6395 6396 6397 6398
    if (res == ERROR_SUCCESS)
    {
        res = RegDeleteValueA(hkey, name_dotnet);
        ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
        RegCloseKey(hkey);
    }
6399 6400 6401 6402 6403 6404

    path = (is_wow64 || is_64bit) ? path_dotnet_local_wow64 : path_dotnet_local;
    res = RegOpenKeyA(HKEY_CURRENT_USER, path, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegOpenKeyA(HKEY_CURRENT_USER, path_win32, &hkey);
6405 6406 6407 6408 6409 6410
    if (res == ERROR_SUCCESS)
    {
        res = RegDeleteValueA(hkey, name_win32);
        ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
        RegCloseKey(hkey);
    }
6411 6412 6413 6414 6415

    path = (is_wow64 || is_64bit) ? path_win32_local_wow64 : path_win32_local;
    res = RegOpenKeyA(HKEY_CURRENT_USER, path, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

6416 6417 6418
    r = MsiInstallProductA(msifile, "ALLUSERS=1");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

6419 6420 6421 6422 6423 6424 6425 6426
    access = KEY_QUERY_VALUE;
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT, classes_path_dotnet, 0, access, &hkey);
    if (res == ERROR_FILE_NOT_FOUND && is_wow64) /* Vista WOW64 */
    {
        trace("Using 64-bit registry view for HKCR\\Installer\n");
        access = KEY_QUERY_VALUE | KEY_WOW64_64KEY;
        res = RegOpenKeyExA(HKEY_CLASSES_ROOT, classes_path_dotnet, 0, access, &hkey);
    }
6427
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6428
    CHECK_REG_MULTI(hkey, name_dotnet, "rcHQPHq?CA@Uv-XqMI1e>Z'q,T*76M@=YEg6My?~]\0");
6429 6430 6431
    RegCloseKey(hkey);

    path = (is_wow64 || is_64bit) ? classes_path_dotnet_local_wow64 : classes_path_dotnet_local;
6432
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT, path, 0, access, &hkey);
6433
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6434
    CHECK_REG_MULTI(hkey, name_dotnet_local, "rcHQPHq?CA@Uv-XqMI1e>LF,8A?0d.AW@vcZ$Cgox\0");
6435 6436
    RegCloseKey(hkey);

6437
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT, classes_path_win32, 0, access, &hkey);
6438
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6439
    CHECK_REG_MULTI(hkey, name_win32, "rcHQPHq?CA@Uv-XqMI1e>}NJjwR'%D9v1p!v{WV(%\0");
6440 6441 6442
    RegCloseKey(hkey);

    path = (is_wow64 || is_64bit) ? classes_path_win32_local_wow64 : classes_path_win32_local;
6443
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT, path, 0, access, &hkey);
6444
    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6445
    CHECK_REG_MULTI(hkey, name_win32_local, "rcHQPHq?CA@Uv-XqMI1e>C)Uvlj*53A)u(QQ9=)X!\0");
6446 6447
    RegCloseKey(hkey);

6448 6449 6450 6451 6452
    /* No registration is done for a local assembly with no matching file */
    path = (is_wow64 || is_64bit) ? classes_path_fake_local_wow64 : classes_path_fake_local;
    res = RegOpenKeyExA(HKEY_CLASSES_ROOT, path, 0, access, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "got %u\n", res);

6453
    r = MsiInstallProductA(msifile, "REMOVE=ALL ALLUSERS=1");
6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, classes_path_dotnet, &hkey);
    if (res == ERROR_SUCCESS)
    {
        res = RegDeleteValueA(hkey, name_dotnet);
        ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
        RegCloseKey(hkey);
    }

    path = (is_wow64 || is_64bit) ? classes_path_dotnet_local_wow64 : classes_path_dotnet_local;
    res = RegOpenKeyA(HKEY_CLASSES_ROOT, path, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

    res = RegOpenKeyA(HKEY_CLASSES_ROOT, classes_path_win32, &hkey);
    if (res == ERROR_SUCCESS)
    {
        res = RegDeleteValueA(hkey, name_win32);
        ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
        RegCloseKey(hkey);
    }

    path = (is_wow64 || is_64bit) ? classes_path_win32_local_wow64 : classes_path_win32_local;
    res = RegOpenKeyA(HKEY_CLASSES_ROOT, path, &hkey);
    ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);

6480 6481 6482 6483 6484 6485 6486 6487 6488
done:
    DeleteFileA("msitest\\win32.txt");
    DeleteFileA("msitest\\win32_local.txt");
    DeleteFileA("msitest\\dotnet.txt");
    DeleteFileA("msitest\\dotnet_local.txt");
    DeleteFileA("msitest\\manifest.txt");
    DeleteFileA("msitest\\manifest_local.txt");
    DeleteFileA("msitest\\application_win32.txt");
    DeleteFileA("msitest\\application_dotnet.txt");
6489
    DeleteFileA("msitest\\fake_local.txt");
6490
    delete_test_files();
6491
    DeleteFileA(msifile);
6492 6493
}

6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505
static void test_remove_existing_products(void)
{
    UINT r;

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

    create_test_files();
    create_file("msitest\\rep.txt", 1000);
6506
    create_database(msifile, rep_tables, ARRAY_SIZE(rep_tables));
6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526

    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);

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

    ok(!delete_pf("msitest\\rep.txt", TRUE), "file not removed\n");
    ok(!delete_pf("msitest", FALSE), "directory not removed\n");

error:
    DeleteFileA("msitest\\rep.txt");
    delete_test_files();
6527
    DeleteFileA(msifile);
6528 6529
}

6530 6531 6532 6533 6534 6535 6536 6537
START_TEST(action)
{
    DWORD len;
    char temp_path[MAX_PATH], prev_path[MAX_PATH], log_file[MAX_PATH];
    STATEMGRSTATUS status;
    BOOL ret = FALSE;

    init_functionpointers();
6538
    subtest("custom");
6539 6540 6541 6542 6543

    if (pIsWow64Process)
        pIsWow64Process(GetCurrentProcess(), &is_wow64);

    GetCurrentDirectoryA(MAX_PATH, prev_path);
6544
    GetTempPathA(MAX_PATH, temp_path);
6545 6546 6547 6548 6549 6550 6551 6552
    SetCurrentDirectoryA(temp_path);

    lstrcpyA(CURR_DIR, temp_path);
    len = lstrlenA(CURR_DIR);

    if(len && (CURR_DIR[len - 1] == '\\'))
        CURR_DIR[len - 1] = 0;

6553 6554
    ok(get_system_dirs(), "failed to retrieve system dirs\n");
    ok(get_user_dirs(), "failed to retrieve user dirs\n");
6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588

    /* 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.
     *
     * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
     * creation of restore points.
     */
    if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
    {
        memset(&status, 0, sizeof(status));
        ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
    }

    /* Create only one log file and don't append. We have to pass something
     * 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.
     */
    lstrcpyA(log_file, temp_path);
    lstrcatA(log_file, "\\msitest.log");
    MsiEnableLogA(INSTALLLOGMODE_FATALEXIT, log_file, 0);

    test_register_product();
    test_publish_product();
    test_publish_features();
    test_register_user();
    test_process_components();
    test_publish();
    test_publish_sourcelist();
    test_remove_files();
    test_move_files();
    test_duplicate_files();
    test_write_registry_values();
    test_envvar();
6589
    test_create_remove_folder();
6590
    test_start_stop_services();
6591
    test_delete_services();
6592
    test_install_services();
6593 6594 6595 6596 6597 6598 6599 6600 6601
    test_self_registration();
    test_register_font();
    test_validate_product_id();
    test_install_remove_odbc();
    test_register_typelib();
    test_create_remove_shortcut();
    test_publish_components();
    test_remove_duplicate_files();
    test_find_related_products();
6602
    test_ini_values();
6603 6604
    test_register_class_info();
    test_register_extension_info();
6605
    test_register_progid_info();
6606
    test_register_mime_info();
6607
    test_publish_assemblies();
6608
    test_remove_existing_products();
6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620

    DeleteFileA(log_file);

    if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
    {
        ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
        if (ret)
            remove_restore_point(status.llSequenceNumber);
    }

    SetCurrentDirectoryA(prev_path);
}