aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-08-03 18:09:36 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-08-04 10:03:57 -0500
commit4d0798ec6311b48bfe6ee3cb4dd41379b4653528 (patch)
tree87e3a02f540a206403c5e61b242dabbe87c8363a /src
parentcdba28de1ee229369b254c62bc58cf2f001899a3 (diff)
downloadwix-4d0798ec6311b48bfe6ee3cb4dd41379b4653528.tar.gz
wix-4d0798ec6311b48bfe6ee3cb4dd41379b4653528.tar.bz2
wix-4d0798ec6311b48bfe6ee3cb4dd41379b4653528.zip
Always use user's temp directory as basis for acquisition folder.
Fixes #5830
Diffstat (limited to 'src')
-rw-r--r--src/burn/engine/apply.cpp3
-rw-r--r--src/burn/engine/cache.cpp90
-rw-r--r--src/burn/engine/cache.h12
-rw-r--r--src/burn/engine/core.cpp8
-rw-r--r--src/burn/engine/core.h4
-rw-r--r--src/burn/engine/engine.cpp4
-rw-r--r--src/burn/engine/plan.cpp2
-rw-r--r--src/burn/engine/userexperience.cpp2
8 files changed, 82 insertions, 43 deletions
diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp
index 002158b6..8711344d 100644
--- a/src/burn/engine/apply.cpp
+++ b/src/burn/engine/apply.cpp
@@ -533,6 +533,9 @@ extern "C" HRESULT ApplyCache(
533 hr = UserExperienceOnCacheBegin(pUX); 533 hr = UserExperienceOnCacheBegin(pUX);
534 ExitOnRootFailure(hr, "BA aborted cache."); 534 ExitOnRootFailure(hr, "BA aborted cache.");
535 535
536 hr = CacheEnsureAcquisitionFolder(pPlan->pCache);
537 ExitOnFailure(hr, "Failed to ensure acquisition folder.");
538
536 cacheContext.hSourceEngineFile = hSourceEngineFile; 539 cacheContext.hSourceEngineFile = hSourceEngineFile;
537 cacheContext.pCache = pPlan->pCache; 540 cacheContext.pCache = pPlan->pCache;
538 cacheContext.pPayloads = pPlan->pPayloads; 541 cacheContext.pPayloads = pPlan->pPayloads;
diff --git a/src/burn/engine/cache.cpp b/src/burn/engine/cache.cpp
index 0c5266a0..5d81e1ba 100644
--- a/src/burn/engine/cache.cpp
+++ b/src/burn/engine/cache.cpp
@@ -16,9 +16,10 @@ static HRESULT CacheVerifyPayloadSignature(
16 ); 16 );
17static HRESULT CalculateBaseWorkingFolder( 17static HRESULT CalculateBaseWorkingFolder(
18 __in BURN_ENGINE_COMMAND* pInternalCommand, 18 __in BURN_ENGINE_COMMAND* pInternalCommand,
19 __in LPCWSTR wzAcquisitionFolder,
19 __inout_z LPWSTR* psczBaseWorkingFolder 20 __inout_z LPWSTR* psczBaseWorkingFolder
20 ); 21 );
21static HRESULT CalculateWorkingFolder( 22static HRESULT CalculateWorkingFolders(
22 __in BURN_CACHE* pCache, 23 __in BURN_CACHE* pCache,
23 __in BURN_ENGINE_COMMAND* pInternalCommand 24 __in BURN_ENGINE_COMMAND* pInternalCommand
24 ); 25 );
@@ -214,7 +215,7 @@ extern "C" HRESULT CacheInitialize(
214 ExitOnFailure(hr, "Failed to backslash terminate default %hs package cache directory name.", "per-user"); 215 ExitOnFailure(hr, "Failed to backslash terminate default %hs package cache directory name.", "per-user");
215 216
216 217
217 hr = CalculateWorkingFolder(pCache, pInternalCommand); 218 hr = CalculateWorkingFolders(pCache, pInternalCommand);
218 219
219 pCache->fInitializedCache = TRUE; 220 pCache->fInitializedCache = TRUE;
220 221
@@ -309,24 +310,42 @@ LExit:
309 return hr; 310 return hr;
310} 311}
311 312
312extern "C" HRESULT CacheEnsureWorkingFolder( 313extern "C" HRESULT CacheEnsureAcquisitionFolder(
314 __in BURN_CACHE* pCache
315 )
316{
317 Assert(pCache->fInitializedCache);
318
319 HRESULT hr = S_OK;
320
321 hr = DirEnsureExists(pCache->sczAcquisitionFolder, NULL);
322 ExitOnFailure(hr, "Failed create acquisition folder.");
323
324 // Best effort to ensure our working folder is not encrypted.
325 ::DecryptFileW(pCache->sczBaseWorkingFolder, 0);
326
327LExit:
328 return hr;
329}
330
331extern "C" HRESULT CacheEnsureBaseWorkingFolder(
313 __in BURN_CACHE* pCache, 332 __in BURN_CACHE* pCache,
314 __deref_out_z_opt LPWSTR* psczWorkingFolder 333 __deref_out_z_opt LPWSTR* psczBaseWorkingFolder
315 ) 334 )
316{ 335{
317 Assert(pCache->fInitializedCache); 336 Assert(pCache->fInitializedCache);
318 337
319 HRESULT hr = S_OK; 338 HRESULT hr = S_OK;
320 339
321 hr = DirEnsureExists(pCache->sczWorkingFolder, NULL); 340 hr = DirEnsureExists(pCache->sczBaseWorkingFolder, NULL);
322 ExitOnFailure(hr, "Failed create working folder."); 341 ExitOnFailure(hr, "Failed create working folder.");
323 342
324 // Best effort to ensure our working folder is not encrypted. 343 // Best effort to ensure our working folder is not encrypted.
325 ::DecryptFileW(pCache->sczWorkingFolder, 0); 344 ::DecryptFileW(pCache->sczBaseWorkingFolder, 0);
326 345
327 if (psczWorkingFolder) 346 if (psczBaseWorkingFolder)
328 { 347 {
329 hr = StrAllocString(psczWorkingFolder, pCache->sczWorkingFolder, 0); 348 hr = StrAllocString(psczBaseWorkingFolder, pCache->sczBaseWorkingFolder, 0);
330 ExitOnFailure(hr, "Failed to copy working folder."); 349 ExitOnFailure(hr, "Failed to copy working folder.");
331 } 350 }
332 351
@@ -353,7 +372,7 @@ extern "C" HRESULT CacheCalculateBundleWorkingPath(
353 } 372 }
354 else // Otherwise, use the real working folder. 373 else // Otherwise, use the real working folder.
355 { 374 {
356 hr = StrAllocFormatted(psczWorkingPath, L"%ls%ls\\%ls", pCache->sczWorkingFolder, BUNDLE_WORKING_FOLDER_NAME, wzExecutableName); 375 hr = StrAllocFormatted(psczWorkingPath, L"%ls%ls\\%ls", pCache->sczBaseWorkingFolder, BUNDLE_WORKING_FOLDER_NAME, wzExecutableName);
357 ExitOnFailure(hr, "Failed to calculate the bundle working path."); 376 ExitOnFailure(hr, "Failed to calculate the bundle working path.");
358 } 377 }
359 378
@@ -371,7 +390,7 @@ extern "C" HRESULT CacheCalculateBundleLayoutWorkingPath(
371 390
372 HRESULT hr = S_OK; 391 HRESULT hr = S_OK;
373 392
374 hr = PathConcat(pCache->sczWorkingFolder, wzBundleId, psczWorkingPath); 393 hr = PathConcat(pCache->sczAcquisitionFolder, wzBundleId, psczWorkingPath);
375 ExitOnFailure(hr, "Failed to append bundle id for bundle layout working path."); 394 ExitOnFailure(hr, "Failed to append bundle id for bundle layout working path.");
376 395
377LExit: 396LExit:
@@ -388,7 +407,7 @@ extern "C" HRESULT CacheCalculatePayloadWorkingPath(
388 407
389 HRESULT hr = S_OK; 408 HRESULT hr = S_OK;
390 409
391 hr = PathConcat(pCache->sczWorkingFolder, pPayload->sczKey, psczWorkingPath); 410 hr = PathConcat(pCache->sczAcquisitionFolder, pPayload->sczKey, psczWorkingPath);
392 ExitOnFailure(hr, "Failed to append Id as payload unverified path."); 411 ExitOnFailure(hr, "Failed to append Id as payload unverified path.");
393 412
394LExit: 413LExit:
@@ -405,7 +424,7 @@ extern "C" HRESULT CacheCalculateContainerWorkingPath(
405 424
406 HRESULT hr = S_OK; 425 HRESULT hr = S_OK;
407 426
408 hr = PathConcat(pCache->sczWorkingFolder, pContainer->sczHash, psczWorkingPath); 427 hr = PathConcat(pCache->sczAcquisitionFolder, pContainer->sczHash, psczWorkingPath);
409 ExitOnFailure(hr, "Failed to append hash as container unverified path."); 428 ExitOnFailure(hr, "Failed to append hash as container unverified path.");
410 429
411LExit: 430LExit:
@@ -1155,7 +1174,7 @@ LExit:
1155 return hr; 1174 return hr;
1156} 1175}
1157 1176
1158extern "C" HRESULT CacheRemoveWorkingFolder( 1177extern "C" HRESULT CacheRemoveBaseWorkingFolder(
1159 __in BURN_CACHE* pCache 1178 __in BURN_CACHE* pCache
1160 ) 1179 )
1161{ 1180{
@@ -1164,7 +1183,7 @@ extern "C" HRESULT CacheRemoveWorkingFolder(
1164 if (pCache->fInitializedCacheSources) 1183 if (pCache->fInitializedCacheSources)
1165 { 1184 {
1166 // Try to clean out everything in the working folder. 1185 // Try to clean out everything in the working folder.
1167 hr = DirEnsureDeleteEx(pCache->sczWorkingFolder, DIR_DELETE_FILES | DIR_DELETE_RECURSE | DIR_DELETE_SCHEDULE); 1186 hr = DirEnsureDeleteEx(pCache->sczBaseWorkingFolder, DIR_DELETE_FILES | DIR_DELETE_RECURSE | DIR_DELETE_SCHEDULE);
1168 TraceError(hr, "Could not delete bundle engine working folder."); 1187 TraceError(hr, "Could not delete bundle engine working folder.");
1169 } 1188 }
1170 1189
@@ -1275,9 +1294,9 @@ extern "C" void CacheCleanup(
1275 1294
1276 if (!fPerMachine) 1295 if (!fPerMachine)
1277 { 1296 {
1278 if (pCache->sczWorkingFolder) 1297 if (pCache->sczAcquisitionFolder)
1279 { 1298 {
1280 hr = PathConcat(pCache->sczWorkingFolder, L"*.*", &sczFiles); 1299 hr = PathConcat(pCache->sczAcquisitionFolder, L"*.*", &sczFiles);
1281 if (SUCCEEDED(hr)) 1300 if (SUCCEEDED(hr))
1282 { 1301 {
1283 hFind = ::FindFirstFileW(sczFiles, &wfd); 1302 hFind = ::FindFirstFileW(sczFiles, &wfd);
@@ -1299,7 +1318,7 @@ extern "C" void CacheCleanup(
1299 continue; 1318 continue;
1300 } 1319 }
1301 1320
1302 hr = PathConcatCch(pCache->sczWorkingFolder, 0, wfd.cFileName, cchFileName, &sczDelete); 1321 hr = PathConcatCch(pCache->sczAcquisitionFolder, 0, wfd.cFileName, cchFileName, &sczDelete);
1303 if (SUCCEEDED(hr)) 1322 if (SUCCEEDED(hr))
1304 { 1323 {
1305 hr = FileEnsureDelete(sczDelete); 1324 hr = FileEnsureDelete(sczDelete);
@@ -1327,7 +1346,8 @@ extern "C" void CacheUninitialize(
1327 ReleaseNullStr(pCache->sczCurrentMachinePackageCache); 1346 ReleaseNullStr(pCache->sczCurrentMachinePackageCache);
1328 ReleaseNullStr(pCache->sczDefaultMachinePackageCache); 1347 ReleaseNullStr(pCache->sczDefaultMachinePackageCache);
1329 ReleaseNullStr(pCache->sczDefaultUserPackageCache); 1348 ReleaseNullStr(pCache->sczDefaultUserPackageCache);
1330 ReleaseNullStr(pCache->sczWorkingFolder); 1349 ReleaseNullStr(pCache->sczBaseWorkingFolder);
1350 ReleaseNullStr(pCache->sczAcquisitionFolder);
1331 ReleaseNullStr(pCache->sczSourceProcessFolder); 1351 ReleaseNullStr(pCache->sczSourceProcessFolder);
1332 1352
1333 pCache->fRunningFromCache = FALSE; 1353 pCache->fRunningFromCache = FALSE;
@@ -1343,6 +1363,7 @@ extern "C" void CacheUninitialize(
1343 1363
1344static HRESULT CalculateBaseWorkingFolder( 1364static HRESULT CalculateBaseWorkingFolder(
1345 __in BURN_ENGINE_COMMAND* pInternalCommand, 1365 __in BURN_ENGINE_COMMAND* pInternalCommand,
1366 __in LPCWSTR wzAcquisitionFolder,
1346 __inout_z LPWSTR* psczBaseWorkingFolder 1367 __inout_z LPWSTR* psczBaseWorkingFolder
1347 ) 1368 )
1348{ 1369{
@@ -1351,10 +1372,10 @@ static HRESULT CalculateBaseWorkingFolder(
1351 ReleaseNullStr(*psczBaseWorkingFolder); 1372 ReleaseNullStr(*psczBaseWorkingFolder);
1352 1373
1353 // The value from the command line takes precedence. 1374 // The value from the command line takes precedence.
1354 if (pInternalCommand->sczWorkingDirectory) 1375 if (pInternalCommand->sczEngineWorkingDirectory)
1355 { 1376 {
1356 hr = PathExpand(psczBaseWorkingFolder, pInternalCommand->sczWorkingDirectory, PATH_EXPAND_FULLPATH); 1377 hr = PathExpand(psczBaseWorkingFolder, pInternalCommand->sczEngineWorkingDirectory, PATH_EXPAND_FULLPATH);
1357 ExitOnFailure(hr, "Failed to expand engine working directory from command-line: '%ls'", pInternalCommand->sczWorkingDirectory); 1378 ExitOnFailure(hr, "Failed to expand engine working directory from command-line: '%ls'", pInternalCommand->sczEngineWorkingDirectory);
1358 1379
1359 ExitFunction(); 1380 ExitFunction();
1360 } 1381 }
@@ -1373,34 +1394,41 @@ static HRESULT CalculateBaseWorkingFolder(
1373 } 1394 }
1374 } 1395 }
1375 1396
1376 // Default to the temp path specified in environment variables, but need to use system temp path for security reasons if running elevated. 1397 // Default to the acquisition folder, but need to use system temp path for security reasons if running elevated.
1377 if (pInternalCommand->fInitiallyElevated) 1398 if (pInternalCommand->fInitiallyElevated)
1378 { 1399 {
1379 hr = PathGetSystemTempPath(psczBaseWorkingFolder); 1400 hr = PathGetSystemTempPath(psczBaseWorkingFolder);
1380 ExitOnFailure(hr, "Failed to get system temp folder path for working folder."); 1401 ExitOnFailure(hr, "Failed to get system temp folder path for base working folder.");
1381 } 1402 }
1382 else 1403 else
1383 { 1404 {
1384 hr = PathGetTempPath(psczBaseWorkingFolder); 1405 hr = StrAllocString(psczBaseWorkingFolder, wzAcquisitionFolder, 0);
1385 ExitOnFailure(hr, "Failed to get temp folder path for working folder."); 1406 ExitOnFailure(hr, "Failed to copy acquisition folder path for base working folder.");
1386 } 1407 }
1387 1408
1388LExit: 1409LExit:
1389 return hr; 1410 return hr;
1390} 1411}
1391 1412
1392static HRESULT CalculateWorkingFolder( 1413static HRESULT CalculateWorkingFolders(
1393 __in BURN_CACHE* pCache, 1414 __in BURN_CACHE* pCache,
1394 __in BURN_ENGINE_COMMAND* pInternalCommand 1415 __in BURN_ENGINE_COMMAND* pInternalCommand
1395 ) 1416 )
1396{ 1417{
1397 HRESULT hr = S_OK; 1418 HRESULT hr = S_OK;
1398 RPC_STATUS rs = RPC_S_OK; 1419 RPC_STATUS rs = RPC_S_OK;
1420 LPWSTR sczBaseAcquisitionPath = NULL;
1399 LPWSTR sczTempPath = NULL; 1421 LPWSTR sczTempPath = NULL;
1400 UUID guid = {}; 1422 UUID guid = {};
1401 WCHAR wzGuid[39]; 1423 WCHAR wzGuid[39];
1402 1424
1403 hr = CalculateBaseWorkingFolder(pInternalCommand, &sczTempPath); 1425 hr = PathGetTempPath(&sczBaseAcquisitionPath);
1426 ExitOnFailure(hr, "Failed to get temp folder path for acquisition folder base.");
1427
1428 hr = PathBackslashTerminate(&sczBaseAcquisitionPath);
1429 ExitOnFailure(hr, "Failed to backslashify base engine working directory.");
1430
1431 hr = CalculateBaseWorkingFolder(pInternalCommand, sczBaseAcquisitionPath, &sczTempPath);
1404 ExitOnFailure(hr, "Failed to get base engine working directory."); 1432 ExitOnFailure(hr, "Failed to get base engine working directory.");
1405 1433
1406 hr = PathBackslashTerminate(&sczTempPath); 1434 hr = PathBackslashTerminate(&sczTempPath);
@@ -1416,10 +1444,14 @@ static HRESULT CalculateWorkingFolder(
1416 ExitOnRootFailure(hr, "Failed to convert working folder guid into string."); 1444 ExitOnRootFailure(hr, "Failed to convert working folder guid into string.");
1417 } 1445 }
1418 1446
1419 hr = StrAllocFormatted(&pCache->sczWorkingFolder, L"%ls%ls\\", sczTempPath, wzGuid); 1447 hr = StrAllocFormatted(&pCache->sczAcquisitionFolder, L"%ls%ls\\", sczBaseAcquisitionPath, wzGuid);
1448 ExitOnFailure(hr, "Failed to append random guid on to temp path for acquisition folder.");
1449
1450 hr = StrAllocFormatted(&pCache->sczBaseWorkingFolder, L"%ls%ls\\", sczTempPath, wzGuid);
1420 ExitOnFailure(hr, "Failed to append random guid on to temp path for working folder."); 1451 ExitOnFailure(hr, "Failed to append random guid on to temp path for working folder.");
1421 1452
1422LExit: 1453LExit:
1454 ReleaseStr(sczBaseAcquisitionPath);
1423 ReleaseStr(sczTempPath); 1455 ReleaseStr(sczTempPath);
1424 1456
1425 return hr; 1457 return hr;
@@ -2020,7 +2052,7 @@ static HRESULT CopyEngineToWorkingFolder(
2020 LPWSTR sczPayloadSourcePath = NULL; 2052 LPWSTR sczPayloadSourcePath = NULL;
2021 LPWSTR sczPayloadTargetPath = NULL; 2053 LPWSTR sczPayloadTargetPath = NULL;
2022 2054
2023 hr = CacheEnsureWorkingFolder(pCache, &sczWorkingFolder); 2055 hr = CacheEnsureBaseWorkingFolder(pCache, &sczWorkingFolder);
2024 ExitOnFailure(hr, "Failed to create working path to copy engine."); 2056 ExitOnFailure(hr, "Failed to create working path to copy engine.");
2025 2057
2026 hr = PathConcat(sczWorkingFolder, wzWorkingFolderName, &sczTargetDirectory); 2058 hr = PathConcat(sczWorkingFolder, wzWorkingFolderName, &sczTargetDirectory);
diff --git a/src/burn/engine/cache.h b/src/burn/engine/cache.h
index 69d82639..8b038b99 100644
--- a/src/burn/engine/cache.h
+++ b/src/burn/engine/cache.h
@@ -39,7 +39,8 @@ typedef struct _BURN_CACHE
39 BOOL fInitializedCacheSources; 39 BOOL fInitializedCacheSources;
40 BOOL fRunningFromCache; 40 BOOL fRunningFromCache;
41 LPWSTR sczSourceProcessFolder; 41 LPWSTR sczSourceProcessFolder;
42 LPWSTR sczWorkingFolder; 42 LPWSTR sczAcquisitionFolder;
43 LPWSTR sczBaseWorkingFolder;
43} BURN_CACHE; 44} BURN_CACHE;
44 45
45typedef struct _BURN_CACHE_MESSAGE 46typedef struct _BURN_CACHE_MESSAGE
@@ -80,9 +81,12 @@ HRESULT CacheInitializeSources(
80 __in BURN_VARIABLES* pVariables, 81 __in BURN_VARIABLES* pVariables,
81 __in BURN_ENGINE_COMMAND* pInternalCommand 82 __in BURN_ENGINE_COMMAND* pInternalCommand
82 ); 83 );
83HRESULT CacheEnsureWorkingFolder( 84HRESULT CacheEnsureAcquisitionFolder(
85 __in BURN_CACHE* pCache
86 );
87HRESULT CacheEnsureBaseWorkingFolder(
84 __in BURN_CACHE* pCache, 88 __in BURN_CACHE* pCache,
85 __deref_out_z_opt LPWSTR* psczWorkingFolder 89 __deref_out_z_opt LPWSTR* psczBaseWorkingFolder
86 ); 90 );
87HRESULT CacheCalculateBundleWorkingPath( 91HRESULT CacheCalculateBundleWorkingPath(
88 __in BURN_CACHE* pCache, 92 __in BURN_CACHE* pCache,
@@ -228,7 +232,7 @@ HRESULT CacheVerifyPayload(
228 __in LPPROGRESS_ROUTINE pfnProgress, 232 __in LPPROGRESS_ROUTINE pfnProgress,
229 __in LPVOID pContext 233 __in LPVOID pContext
230 ); 234 );
231HRESULT CacheRemoveWorkingFolder( 235HRESULT CacheRemoveBaseWorkingFolder(
232 __in BURN_CACHE* pCache 236 __in BURN_CACHE* pCache
233 ); 237 );
234HRESULT CacheRemoveBundle( 238HRESULT CacheRemoveBundle(
diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp
index e8c51187..87d748cc 100644
--- a/src/burn/engine/core.cpp
+++ b/src/burn/engine/core.cpp
@@ -229,7 +229,7 @@ extern "C" HRESULT CoreInitializeConstants(
229 { 229 {
230 // Pass along any ancestors and ourself to prevent infinite loops. 230 // Pass along any ancestors and ourself to prevent infinite loops.
231 pPackage->Exe.wzAncestors = pRegistration->sczBundlePackageAncestors; 231 pPackage->Exe.wzAncestors = pRegistration->sczBundlePackageAncestors;
232 pPackage->Exe.wzEngineWorkingDirectory = pInternalCommand->sczWorkingDirectory; 232 pPackage->Exe.wzEngineWorkingDirectory = pInternalCommand->sczEngineWorkingDirectory;
233 } 233 }
234 } 234 }
235 235
@@ -1019,7 +1019,7 @@ static HRESULT CoreRecreateCommandLine(
1019 ExitOnFailure(hr, "Failed to append ancestors to command-line."); 1019 ExitOnFailure(hr, "Failed to append ancestors to command-line.");
1020 } 1020 }
1021 1021
1022 hr = CoreAppendEngineWorkingDirectoryToCommandLine(pInternalCommand->sczWorkingDirectory, psczCommandLine, NULL); 1022 hr = CoreAppendEngineWorkingDirectoryToCommandLine(pInternalCommand->sczEngineWorkingDirectory, psczCommandLine, NULL);
1023 ExitOnFailure(hr, "Failed to append the custom working directory to command-line."); 1023 ExitOnFailure(hr, "Failed to append the custom working directory to command-line.");
1024 1024
1025 if (wzRelationTypeCommandLine) 1025 if (wzRelationTypeCommandLine)
@@ -1733,12 +1733,12 @@ extern "C" HRESULT CoreParseCommandLine(
1733 else if (L'\0' == wzParam[1]) 1733 else if (L'\0' == wzParam[1])
1734 { 1734 {
1735 // Need to grab the current directory here since this is passed on to other processes. 1735 // Need to grab the current directory here since this is passed on to other processes.
1736 hr = DirGetCurrent(&pInternalCommand->sczWorkingDirectory); 1736 hr = DirGetCurrent(&pInternalCommand->sczEngineWorkingDirectory);
1737 ExitOnFailure(hr, "Failed to get current directory for custom working directory."); 1737 ExitOnFailure(hr, "Failed to get current directory for custom working directory.");
1738 } 1738 }
1739 else 1739 else
1740 { 1740 {
1741 hr = StrAllocString(&pInternalCommand->sczWorkingDirectory, wzParam + 1, 0); 1741 hr = StrAllocString(&pInternalCommand->sczEngineWorkingDirectory, wzParam + 1, 0);
1742 ExitOnFailure(hr, "Failed to allocate the custom working directory."); 1742 ExitOnFailure(hr, "Failed to allocate the custom working directory.");
1743 } 1743 }
1744 } 1744 }
diff --git a/src/burn/engine/core.h b/src/burn/engine/core.h
index 5361a5c0..ff983d60 100644
--- a/src/burn/engine/core.h
+++ b/src/burn/engine/core.h
@@ -14,7 +14,7 @@ const LPCWSTR BURN_POLICY_REGISTRY_PATH = L"WiX\\Burn";
14const LPCWSTR BURN_COMMANDLINE_SWITCH_PARENT = L"parent"; 14const LPCWSTR BURN_COMMANDLINE_SWITCH_PARENT = L"parent";
15const LPCWSTR BURN_COMMANDLINE_SWITCH_PARENT_NONE = L"parent:none"; 15const LPCWSTR BURN_COMMANDLINE_SWITCH_PARENT_NONE = L"parent:none";
16const LPCWSTR BURN_COMMANDLINE_SWITCH_CLEAN_ROOM = L"burn.clean.room"; 16const LPCWSTR BURN_COMMANDLINE_SWITCH_CLEAN_ROOM = L"burn.clean.room";
17const LPCWSTR BURN_COMMANDLINE_SWITCH_WORKING_DIRECTORY = L"burn.working.directory"; 17const LPCWSTR BURN_COMMANDLINE_SWITCH_WORKING_DIRECTORY = L"burn.engine.working.directory";
18const LPCWSTR BURN_COMMANDLINE_SWITCH_ELEVATED = L"burn.elevated"; 18const LPCWSTR BURN_COMMANDLINE_SWITCH_ELEVATED = L"burn.elevated";
19const LPCWSTR BURN_COMMANDLINE_SWITCH_EMBEDDED = L"burn.embedded"; 19const LPCWSTR BURN_COMMANDLINE_SWITCH_EMBEDDED = L"burn.embedded";
20const LPCWSTR BURN_COMMANDLINE_SWITCH_RUNONCE = L"burn.runonce"; 20const LPCWSTR BURN_COMMANDLINE_SWITCH_RUNONCE = L"burn.runonce";
@@ -100,7 +100,7 @@ typedef struct _BURN_ENGINE_COMMAND
100 100
101 LPWSTR sczSourceProcessPath; 101 LPWSTR sczSourceProcessPath;
102 LPWSTR sczOriginalSource; 102 LPWSTR sczOriginalSource;
103 LPWSTR sczWorkingDirectory; 103 LPWSTR sczEngineWorkingDirectory;
104 104
105 DWORD dwLoggingAttributes; 105 DWORD dwLoggingAttributes;
106 LPWSTR sczLogFile; 106 LPWSTR sczLogFile;
diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp
index d5dc0545..1f2dac3c 100644
--- a/src/burn/engine/engine.cpp
+++ b/src/burn/engine/engine.cpp
@@ -246,7 +246,7 @@ LExit:
246 246
247 UserExperienceRemove(&engineState.userExperience); 247 UserExperienceRemove(&engineState.userExperience);
248 248
249 CacheRemoveWorkingFolder(&engineState.cache); 249 CacheRemoveBaseWorkingFolder(&engineState.cache);
250 CacheUninitialize(&engineState.cache); 250 CacheUninitialize(&engineState.cache);
251 251
252 // If this is a related bundle (but not an update) suppress restart and return the standard restart error code. 252 // If this is a related bundle (but not an update) suppress restart and return the standard restart error code.
@@ -401,7 +401,7 @@ static void UninitializeEngineState(
401 ReleaseStr(pEngineState->internalCommand.sczLogFile); 401 ReleaseStr(pEngineState->internalCommand.sczLogFile);
402 ReleaseStr(pEngineState->internalCommand.sczOriginalSource); 402 ReleaseStr(pEngineState->internalCommand.sczOriginalSource);
403 ReleaseStr(pEngineState->internalCommand.sczSourceProcessPath); 403 ReleaseStr(pEngineState->internalCommand.sczSourceProcessPath);
404 ReleaseStr(pEngineState->internalCommand.sczWorkingDirectory); 404 ReleaseStr(pEngineState->internalCommand.sczEngineWorkingDirectory);
405 405
406 ReleaseStr(pEngineState->log.sczExtension); 406 ReleaseStr(pEngineState->log.sczExtension);
407 ReleaseStr(pEngineState->log.sczPrefix); 407 ReleaseStr(pEngineState->log.sczPrefix);
diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp
index 04da2a9d..d78f2846 100644
--- a/src/burn/engine/plan.cpp
+++ b/src/burn/engine/plan.cpp
@@ -1283,7 +1283,7 @@ extern "C" HRESULT PlanRelatedBundlesBegin(
1283 1283
1284 // Pass along any ancestors and ourself to prevent infinite loops. 1284 // Pass along any ancestors and ourself to prevent infinite loops.
1285 pRelatedBundle->package.Exe.wzAncestors = pRegistration->sczBundlePackageAncestors; 1285 pRelatedBundle->package.Exe.wzAncestors = pRegistration->sczBundlePackageAncestors;
1286 pRelatedBundle->package.Exe.wzEngineWorkingDirectory = pPlan->pInternalCommand->sczWorkingDirectory; 1286 pRelatedBundle->package.Exe.wzEngineWorkingDirectory = pPlan->pInternalCommand->sczEngineWorkingDirectory;
1287 1287
1288 hr = PlanDefaultRelatedBundleRequestState(relationType, pRelatedBundle->relationType, pPlan->action, pRegistration->pVersion, pRelatedBundle->pVersion, &pRelatedBundle->package.requested); 1288 hr = PlanDefaultRelatedBundleRequestState(relationType, pRelatedBundle->relationType, pPlan->action, pRegistration->pVersion, pRelatedBundle->pVersion, &pRelatedBundle->package.requested);
1289 ExitOnFailure(hr, "Failed to get default request state for related bundle."); 1289 ExitOnFailure(hr, "Failed to get default request state for related bundle.");
diff --git a/src/burn/engine/userexperience.cpp b/src/burn/engine/userexperience.cpp
index 69ec6347..f48e60de 100644
--- a/src/burn/engine/userexperience.cpp
+++ b/src/burn/engine/userexperience.cpp
@@ -168,7 +168,7 @@ extern "C" HRESULT UserExperienceEnsureWorkingFolder(
168 HRESULT hr = S_OK; 168 HRESULT hr = S_OK;
169 LPWSTR sczWorkingFolder = NULL; 169 LPWSTR sczWorkingFolder = NULL;
170 170
171 hr = CacheEnsureWorkingFolder(pCache, &sczWorkingFolder); 171 hr = CacheEnsureBaseWorkingFolder(pCache, &sczWorkingFolder);
172 ExitOnFailure(hr, "Failed to create working folder."); 172 ExitOnFailure(hr, "Failed to create working folder.");
173 173
174 hr = StrAllocFormatted(psczUserExperienceWorkingFolder, L"%ls%ls\\", sczWorkingFolder, L".ba"); 174 hr = StrAllocFormatted(psczUserExperienceWorkingFolder, L"%ls%ls\\", sczWorkingFolder, L".ba");