Merge branch '4630' of git://github.com/rseanhall/wix4 into develop

Conflicts:
	History.md
This commit is contained in:
Bob Arnson 2015-04-14 22:13:34 -04:00
Родитель 3c2ef84d41 ec235d7973
Коммит 74134d5461
6 изменённых файлов: 76 добавлений и 58 удалений

Просмотреть файл

@ -1,3 +1,5 @@
* SeanHall: WIXBUG:4630 - Serialize all variables to the elevated Burn process.
* SeanHall: WIXFEAT:3933 - Make WixBundleManufacturer variable writable.
* BobArnson: WIXBUG:4700 - Added blurb about SequenceType.first.

Просмотреть файл

@ -179,7 +179,7 @@ extern "C" HRESULT CoreQueryRegistration(
hr = RegistrationLoadState(&pEngineState->registration, &pbBuffer, &cbBuffer);
if (SUCCEEDED(hr))
{
hr = VariableDeserialize(&pEngineState->variables, pbBuffer, cbBuffer, &iBuffer);
hr = VariableDeserialize(&pEngineState->variables, TRUE, pbBuffer, cbBuffer, &iBuffer);
}
// Log any failures and continue.

Просмотреть файл

@ -1592,7 +1592,7 @@ static HRESULT OnApplyInitialize(
DWORD dwTakeSystemRestorePoint = 0;
LPWSTR sczBundleName = NULL;
// deserialize message data
// Deserialize message data.
hr = BuffReadNumber(pbData, cbData, &iData, &dwAction);
ExitOnFailure(hr, "Failed to read action.");
@ -1600,12 +1600,12 @@ static HRESULT OnApplyInitialize(
ExitOnFailure(hr, "Failed to read update action.");
hr = BuffReadNumber(pbData, cbData, &iData, &dwTakeSystemRestorePoint);
ExitOnFailure(hr, "Failed to read sysem restore point action.");
ExitOnFailure(hr, "Failed to read system restore point action.");
hr = VariableDeserialize(pVariables, pbData, cbData, &iData);
hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData);
ExitOnFailure(hr, "Failed to read variables.");
// initialize.
// Initialize.
hr = ApplyLock(TRUE, phLock);
ExitOnFailure(hr, "Failed to acquire lock due to setup in other session.");
@ -1698,7 +1698,7 @@ static HRESULT OnSessionBegin(
DWORD dwDependencyRegistrationAction = 0;
DWORD64 qwEstimatedSize = 0;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &sczEngineWorkingPath);
ExitOnFailure(hr, "Failed to read engine working path.");
@ -1717,10 +1717,10 @@ static HRESULT OnSessionBegin(
hr = BuffReadNumber64(pbData, cbData, &iData, &qwEstimatedSize);
ExitOnFailure(hr, "Failed to read estimated size.");
hr = VariableDeserialize(pVariables, pbData, cbData, &iData);
hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData);
ExitOnFailure(hr, "Failed to read variables.");
// begin session in per-machine process
// Begin session in per-machine process.
hr = RegistrationSessionBegin(sczEngineWorkingPath, pRegistration, pVariables, pUserExperience, dwRegistrationOperations, (BURN_DEPENDENCY_REGISTRATION_ACTION)dwDependencyRegistrationAction, qwEstimatedSize);
ExitOnFailure(hr, "Failed to begin registration session.");
@ -1739,7 +1739,7 @@ static HRESULT OnSessionResume(
HRESULT hr = S_OK;
SIZE_T iData = 0;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &pRegistration->sczResumeCommandLine);
ExitOnFailure(hr, "Failed to read resume command line.");
@ -1766,7 +1766,7 @@ static HRESULT OnSessionEnd(
DWORD dwRestart = 0;
DWORD dwDependencyRegistrationAction = 0;
// deserialize message data
// Deserialize message data.
hr = BuffReadNumber(pbData, cbData, &iData, &dwResumeMode);
ExitOnFailure(hr, "Failed to read resume mode enum.");
@ -1811,7 +1811,7 @@ static HRESULT OnLayoutBundle(
LPWSTR sczLayoutDirectory = NULL;
LPWSTR sczUnverifiedPath = NULL;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &sczLayoutDirectory);
ExitOnFailure(hr, "Failed to read layout directory.");
@ -1847,7 +1847,7 @@ static HRESULT OnCacheOrLayoutContainerOrPayload(
LPWSTR sczUnverifiedPath = NULL;
BOOL fMove = FALSE;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &scz);
ExitOnFailure(hr, "Failed to read package id.");
@ -1939,7 +1939,7 @@ static HRESULT OnProcessDependentRegistration(
SIZE_T iData = 0;
BURN_DEPENDENT_REGISTRATION_ACTION action = { };
// deserialize message data
// Deserialize message data.
hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&action.type);
ExitOnFailure(hr, "Failed to read action type.");
@ -1982,9 +1982,9 @@ static HRESULT OnExecuteExePackage(
executeAction.type = BURN_EXECUTE_ACTION_TYPE_EXE_PACKAGE;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &sczPackage);
ExitOnFailure(hr, "Failed to read exe package.");
ExitOnFailure(hr, "Failed to read EXE package id.");
hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&executeAction.exePackage.action);
ExitOnFailure(hr, "Failed to read action.");
@ -1998,7 +1998,7 @@ static HRESULT OnExecuteExePackage(
hr = BuffReadString(pbData, cbData, &iData, &sczAncestors);
ExitOnFailure(hr, "Failed to read the list of ancestors.");
hr = VariableDeserialize(pVariables, pbData, cbData, &iData);
hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData);
ExitOnFailure(hr, "Failed to read variables.");
hr = PackageFindById(pPackages, sczPackage, &executeAction.exePackage.pPackage);
@ -2022,7 +2022,7 @@ static HRESULT OnExecuteExePackage(
ExitOnFailure(hr, "Failed to allocate the list of ancestors.");
}
// execute EXE package
// Execute EXE package.
hr = ExeEngineExecutePackage(&executeAction, pVariables, static_cast<BOOL>(dwRollback), GenericExecuteMessageHandler, hPipe, &exeRestart);
ExitOnFailure(hr, "Failed to execute EXE package.");
@ -2065,9 +2065,9 @@ static HRESULT OnExecuteMsiPackage(
executeAction.type = BURN_EXECUTE_ACTION_TYPE_MSI_PACKAGE;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &sczPackage);
ExitOnFailure(hr, "Failed to read action.");
ExitOnFailure(hr, "Failed to read MSI package id.");
hr = PackageFindById(pPackages, sczPackage, &executeAction.msiPackage.pPackage);
ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
@ -2110,13 +2110,13 @@ static HRESULT OnExecuteMsiPackage(
}
}
hr = VariableDeserialize(pVariables, pbData, cbData, &iData);
hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData);
ExitOnFailure(hr, "Failed to read variables.");
hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&fRollback);
ExitOnFailure(hr, "Failed to read rollback flag.");
// execute MSI package
// Execute MSI package.
hr = MsiEngineExecutePackage(hwndParent, &executeAction, pVariables, fRollback, MsiExecuteMessageHandler, hPipe, &msiRestart);
ExitOnFailure(hr, "Failed to execute MSI package.");
@ -2157,9 +2157,9 @@ static HRESULT OnExecuteMspPackage(
executeAction.type = BURN_EXECUTE_ACTION_TYPE_MSP_TARGET;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &sczPackage);
ExitOnFailure(hr, "Failed to read action.");
ExitOnFailure(hr, "Failed to read MSP package id.");
hr = PackageFindById(pPackages, sczPackage, &executeAction.mspTarget.pPackage);
ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
@ -2170,7 +2170,7 @@ static HRESULT OnExecuteMspPackage(
executeAction.mspTarget.fPerMachineTarget = TRUE; // we're in the elevated process, clearly we're targeting a per-machine product.
hr = BuffReadString(pbData, cbData, &iData, &executeAction.mspTarget.sczTargetProductCode);
ExitOnFailure(hr, "Failed to read package log.");
ExitOnFailure(hr, "Failed to read target product code.");
hr = BuffReadString(pbData, cbData, &iData, &executeAction.mspTarget.sczLogPath);
ExitOnFailure(hr, "Failed to read package log.");
@ -2202,13 +2202,13 @@ static HRESULT OnExecuteMspPackage(
}
}
hr = VariableDeserialize(pVariables, pbData, cbData, &iData);
hr = VariableDeserialize(pVariables, FALSE, pbData, cbData, &iData);
ExitOnFailure(hr, "Failed to read variables.");
hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&fRollback);
ExitOnFailure(hr, "Failed to read rollback flag.");
// execute MSP package
// Execute MSP package.
hr = MspEngineExecutePackage(hwndParent, &executeAction, pVariables, fRollback, MsiExecuteMessageHandler, hPipe, &restart);
ExitOnFailure(hr, "Failed to execute MSP package.");
@ -2249,9 +2249,9 @@ static HRESULT OnExecuteMsuPackage(
executeAction.type = BURN_EXECUTE_ACTION_TYPE_MSU_PACKAGE;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &sczPackage);
ExitOnFailure(hr, "Failed to read package id.");
ExitOnFailure(hr, "Failed to read MSU package id.");
hr = BuffReadString(pbData, cbData, &iData, &executeAction.msuPackage.sczLogPath);
ExitOnFailure(hr, "Failed to read package log.");
@ -2571,7 +2571,7 @@ static HRESULT OnCleanPackage(
LPWSTR sczPackage = NULL;
BURN_PACKAGE* pPackage = NULL;
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &sczPackage);
ExitOnFailure(hr, "Failed to read package id.");
@ -2608,7 +2608,7 @@ static HRESULT OnLaunchApprovedExe(
pLaunchApprovedExe = (BURN_LAUNCH_APPROVED_EXE*)MemAlloc(sizeof(BURN_LAUNCH_APPROVED_EXE), TRUE);
// deserialize message data
// Deserialize message data.
hr = BuffReadString(pbData, cbData, &iData, &pLaunchApprovedExe->sczId);
ExitOnFailure(hr, "Failed to read approved exe id.");

Просмотреть файл

@ -55,6 +55,7 @@ enum SET_VARIABLE
SET_VARIABLE_NOT_BUILTIN,
SET_VARIABLE_OVERRIDE_BUILTIN,
SET_VARIABLE_OVERRIDE_PERSISTED_BUILTINS,
SET_VARIABLE_ANY,
};
// internal function declarations
@ -811,19 +812,19 @@ extern "C" HRESULT VariableSerialize(
::EnterCriticalSection(&pVariables->csAccess);
// write variable count
// Write variable count.
hr = BuffWriteNumber(ppbBuffer, piBuffer, pVariables->cVariables);
ExitOnFailure(hr, "Failed to write variable count.");
// write variables
// Write variables.
for (DWORD i = 0; i < pVariables->cVariables; ++i)
{
BURN_VARIABLE* pVariable = &pVariables->rgVariables[i];
// If we are persisting, include only variables that should be persisted. When not persisting, skip all the built-ins.
fIncluded = fPersisting ? pVariable->fPersisted : !pVariable->fBuiltIn;
// If we are persisting, include only variables that should be persisted.
fIncluded = !fPersisting || pVariable->fPersisted;
// write included flag
// Write included flag.
hr = BuffWriteNumber(ppbBuffer, piBuffer, (DWORD)fIncluded);
ExitOnFailure(hr, "Failed to write included flag.");
@ -832,38 +833,44 @@ extern "C" HRESULT VariableSerialize(
continue;
}
// write variable name
// Write variable name.
hr = BuffWriteString(ppbBuffer, piBuffer, pVariable->sczName);
ExitOnFailure(hr, "Failed to write variable name.");
// write variable value type
// Write variable value type.
hr = BuffWriteNumber(ppbBuffer, piBuffer, (DWORD)pVariable->Value.Type);
ExitOnFailure(hr, "Failed to write variable value type.");
// write variable value
// Write variable value.
switch (pVariable->Value.Type)
{
case BURN_VARIANT_TYPE_NONE:
break;
case BURN_VARIANT_TYPE_NUMERIC:
hr = BVariantGetNumeric(&pVariable->Value, &ll);
ExitOnFailure(hr, "Failed to get numeric");
ExitOnFailure(hr, "Failed to get numeric.");
hr = BuffWriteNumber64(ppbBuffer, piBuffer, static_cast<DWORD64>(ll));
ExitOnFailure(hr, "Failed to write variable value as number.");
SecureZeroMemory(&ll, sizeof(ll));
break;
case BURN_VARIANT_TYPE_VERSION:
hr = BVariantGetVersion(&pVariable->Value, &qw);
ExitOnFailure(hr, "Failed to get version");
ExitOnFailure(hr, "Failed to get version.");
hr = BuffWriteNumber64(ppbBuffer, piBuffer, qw);
ExitOnFailure(hr, "Failed to write variable value as number.");
SecureZeroMemory(&qw, sizeof(qw));
break;
case BURN_VARIANT_TYPE_STRING:
hr = BVariantGetString(&pVariable->Value, &scz);
ExitOnFailure(hr, "Failed to get string");
ExitOnFailure(hr, "Failed to get string.");
hr = BuffWriteString(ppbBuffer, piBuffer, scz);
ExitOnFailure(hr, "Failed to write variable value as string.");
ReleaseNullStrSecure(scz);
break;
default:
@ -883,6 +890,7 @@ LExit:
extern "C" HRESULT VariableDeserialize(
__in BURN_VARIABLES* pVariables,
__in BOOL fWasPersisted,
__in_bcount(cbBuffer) BYTE* pbBuffer,
__in SIZE_T cbBuffer,
__inout SIZE_T* piBuffer
@ -898,31 +906,31 @@ extern "C" HRESULT VariableDeserialize(
::EnterCriticalSection(&pVariables->csAccess);
// read variable count
// Read variable count.
hr = BuffReadNumber(pbBuffer, cbBuffer, piBuffer, &cVariables);
ExitOnFailure(hr, "Failed to read variable count.");
// read variables
// Read variables.
for (DWORD i = 0; i < cVariables; ++i)
{
// read variable included flag
// Read variable included flag.
hr = BuffReadNumber(pbBuffer, cbBuffer, piBuffer, (DWORD*)&fIncluded);
ExitOnFailure(hr, "Failed to read variable included flag.");
if (!fIncluded)
{
continue; // if variable is not included, skip
continue; // if variable is not included, skip.
}
// read variable name
// Read variable name.
hr = BuffReadString(pbBuffer, cbBuffer, piBuffer, &sczName);
ExitOnFailure(hr, "Failed to read variable name.");
// read variable value type
// Read variable value type.
hr = BuffReadNumber(pbBuffer, cbBuffer, piBuffer, (DWORD*)&value.Type);
ExitOnFailure(hr, "Failed to read variable value type.");
// read variable value
// Read variable value.
switch (value.Type)
{
case BURN_VARIANT_TYPE_NONE:
@ -930,22 +938,28 @@ extern "C" HRESULT VariableDeserialize(
case BURN_VARIANT_TYPE_NUMERIC:
hr = BuffReadNumber64(pbBuffer, cbBuffer, piBuffer, &qw);
ExitOnFailure(hr, "Failed to read variable value as number.");
hr = BVariantSetNumeric(&value, static_cast<LONGLONG>(qw));
ExitOnFailure(hr, "Failed to set variable value.");
SecureZeroMemory(&qw, sizeof(qw));
break;
case BURN_VARIANT_TYPE_VERSION:
hr = BuffReadNumber64(pbBuffer, cbBuffer, piBuffer, &qw);
ExitOnFailure(hr, "Failed to read variable value as number.");
hr = BVariantSetVersion(&value, qw);
ExitOnFailure(hr, "Failed to set variable value.");
SecureZeroMemory(&qw, sizeof(qw));
break;
case BURN_VARIANT_TYPE_STRING:
hr = BuffReadString(pbBuffer, cbBuffer, piBuffer, &scz);
ExitOnFailure(hr, "Failed to read variable value as string.");
hr = BVariantSetString(&value, scz, NULL);
ExitOnFailure(hr, "Failed to set variable value.");
ReleaseNullStrSecure(scz);
break;
default:
@ -953,11 +967,11 @@ extern "C" HRESULT VariableDeserialize(
ExitOnFailure(hr, "Unsupported variable type.");
}
// set variable
hr = SetVariableValue(pVariables, sczName, &value, SET_VARIABLE_OVERRIDE_PERSISTED_BUILTINS, FALSE);
// Set variable.
hr = SetVariableValue(pVariables, sczName, &value, fWasPersisted ? SET_VARIABLE_OVERRIDE_PERSISTED_BUILTINS : SET_VARIABLE_ANY, FALSE);
ExitOnFailure(hr, "Failed to set variable.");
// clean up
// Clean up.
BVariantUninitialize(&value);
}
@ -1460,16 +1474,17 @@ static HRESULT SetVariableValue(
hr = FindVariableIndexByName(pVariables, wzVariable, &iVariable);
ExitOnFailure(hr, "Failed to find variable value '%ls'.", wzVariable);
// insert element if not found
// Insert element if not found.
if (S_FALSE == hr)
{
hr = InsertVariable(pVariables, wzVariable, iVariable);
ExitOnFailure(hr, "Failed to insert variable '%ls'.", wzVariable);
}
else if (pVariables->rgVariables[iVariable].fBuiltIn) // built-in variables must be overridden
else if (pVariables->rgVariables[iVariable].fBuiltIn) // built-in variables must be overridden.
{
if (SET_VARIABLE_OVERRIDE_BUILTIN == setBuiltin ||
(SET_VARIABLE_OVERRIDE_PERSISTED_BUILTINS == setBuiltin && pVariables->rgVariables[iVariable].fPersisted))
(SET_VARIABLE_OVERRIDE_PERSISTED_BUILTINS == setBuiltin && pVariables->rgVariables[iVariable].fPersisted) ||
SET_VARIABLE_ANY == setBuiltin)
{
hr = S_OK;
}
@ -1485,8 +1500,8 @@ static HRESULT SetVariableValue(
AssertSz(SET_VARIABLE_OVERRIDE_BUILTIN != setBuiltin, "Intent to overwrite non-built-in variable.");
}
// log value when not overwriting a built-in variable
if (fLog && SET_VARIABLE_NOT_BUILTIN == setBuiltin)
// Log value when not overwriting a built-in variable.
if (fLog && !pVariables->rgVariables[iVariable].fBuiltIn)
{
if (pVariables->rgVariables[iVariable].fHidden)
{
@ -1526,7 +1541,7 @@ static HRESULT SetVariableValue(
}
}
// update variable value
// Update variable value.
hr = BVariantSetValue(&pVariables->rgVariables[iVariable].Value, pVariant);
ExitOnFailure(hr, "Failed to set value of variable: %ls", wzVariable);

Просмотреть файл

@ -149,6 +149,7 @@ HRESULT VariableSerialize(
);
HRESULT VariableDeserialize(
__in BURN_VARIABLES* pVariables,
__in BOOL fWasPersisted,
__in_bcount(cbBuffer) BYTE* pbBuffer,
__in SIZE_T cbBuffer,
__inout SIZE_T* piBuffer

Просмотреть файл

@ -384,7 +384,7 @@ namespace Bootstrapper
hr = VariableInitialize(&variables2);
TestThrowOnFailure(hr, L"Failed to initialize variables.");
hr = VariableDeserialize(&variables2, pbBuffer, cbBuffer, &iBuffer);
hr = VariableDeserialize(&variables2, FALSE, pbBuffer, cbBuffer, &iBuffer);
TestThrowOnFailure(hr, L"Failed to deserialize variables.");
Assert::Equal(gcnew String(L"VAL1"), VariableGetStringHelper(&variables2, L"PROP1"));