Use MSI transaction end result to detect whether reboot is needed
Nir Bar committed
Dec 6, 2022 at 13:22 UTC
50e24e9cf2084b6cb67b5d8fc509163061408bb6
17 files changed
+347
-155
src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
+14
@@ -293,6 +293,14 @@ enum BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION
293
BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_SUSPEND,
294
};
295
296
+enum BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION
297
+{
298
+ BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_NONE,
299
+ // Instructs the engine to stop processing the chain and restart.
300
+ // The engine will launch again after the machine is restarted.
301
+ BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_RESTART,
302
+};
303
+
304
enum BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION
305
{
306
// Instructs the engine to stop waiting for the process to exit.
@@ -697,11 +705,14 @@ struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS
705
DWORD cbSize;
706
LPCWSTR wzTransactionId;
707
HRESULT hrStatus;
708
+ BOOTSTRAPPER_APPLY_RESTART restart;
709
+ BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation;
710
};
711
712
struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS
713
{
714
DWORD cbSize;
715
+ BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action;
716
};
717
718
struct BA_ONDETECTBEGIN_ARGS
@@ -1417,11 +1428,14 @@ struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS
1428
DWORD cbSize;
1429
LPCWSTR wzTransactionId;
1430
HRESULT hrStatus;
1431
+ BOOTSTRAPPER_APPLY_RESTART restart;
1432
+ BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation;
1433
};
1434
1435
struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS
1436
{
1437
DWORD cbSize;
1438
+ BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action;
1439
};
1440
1441
struct BA_ONSETUPDATEBEGIN_ARGS
src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
+7
-5
@@ -60,7 +60,7 @@ namespace WixToolset.Mba.Core
60
61
/// <inheritdoc/>
62
public event EventHandler<DetectCompatibleMsiPackageEventArgs> DetectCompatibleMsiPackage;
63
-
63
+
64
/// <inheritdoc/>
65
public event EventHandler<DetectRelatedMsiPackageEventArgs> DetectRelatedMsiPackage;
66
@@ -1985,11 +1985,12 @@ namespace WixToolset.Mba.Core
1985
return args.HResult;
1986
}
1987
1988
- int IBootstrapperApplication.OnCommitMsiTransactionComplete(string transactionId, int hrStatus)
1988
+ int IBootstrapperApplication.OnCommitMsiTransactionComplete(string transactionId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION pAction)
1989
{
1990
- CommitMsiTransactionCompleteEventArgs args = new CommitMsiTransactionCompleteEventArgs(transactionId, hrStatus);
1990
+ CommitMsiTransactionCompleteEventArgs args = new CommitMsiTransactionCompleteEventArgs(transactionId, hrStatus, restart, recommendation, pAction);
1991
this.OnCommitMsiTransactionComplete(args);
1992
1993
+ pAction = args.Action;
1994
return args.HResult;
1995
}
1996
@@ -2001,11 +2002,12 @@ namespace WixToolset.Mba.Core
2002
return args.HResult;
2003
}
2004
2004
- int IBootstrapperApplication.OnRollbackMsiTransactionComplete(string transactionId, int hrStatus)
2005
+ int IBootstrapperApplication.OnRollbackMsiTransactionComplete(string transactionId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION pAction)
2006
{
2006
- RollbackMsiTransactionCompleteEventArgs args = new RollbackMsiTransactionCompleteEventArgs(transactionId, hrStatus);
2007
+ RollbackMsiTransactionCompleteEventArgs args = new RollbackMsiTransactionCompleteEventArgs(transactionId, hrStatus, restart, recommendation, pAction);
2008
this.OnRollbackMsiTransactionComplete(args);
2009
2010
+ pAction = args.Action;
2011
return args.HResult;
2012
}
2013
src/api/burn/WixToolset.Mba.Core/EventArgs.cs
+25
-13
@@ -568,7 +568,7 @@ namespace WixToolset.Mba.Core
568
public class DetectPatchTargetEventArgs : CancellableHResultEventArgs
569
{
570
/// <summary>
571
- ///
571
+ ///
572
/// </summary>
573
/// <param name="packageId"></param>
574
/// <param name="productCode"></param>
@@ -944,7 +944,7 @@ namespace WixToolset.Mba.Core
944
public class PlanPatchTargetEventArgs : CancellableHResultEventArgs
945
{
946
/// <summary>
947
- ///
947
+ ///
948
/// </summary>
949
/// <param name="packageId"></param>
950
/// <param name="productCode"></param>
@@ -1086,7 +1086,7 @@ namespace WixToolset.Mba.Core
1086
public class PlanPackageCompleteEventArgs : StatusEventArgs
1087
{
1088
/// <summary>
1089
- ///
1089
+ ///
1090
/// </summary>
1091
/// <param name="packageId"></param>
1092
/// <param name="hrStatus"></param>
@@ -2117,19 +2117,25 @@ namespace WixToolset.Mba.Core
2117
/// Additional arguments passed by the engine after committing an MSI transaction.
2118
/// </summary>
2119
[Serializable]
2120
- public class CommitMsiTransactionCompleteEventArgs : StatusEventArgs
2120
+ public class CommitMsiTransactionCompleteEventArgs : ActionEventArgs<BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION>
2121
{
2122
/// <summary />
2123
- public CommitMsiTransactionCompleteEventArgs(string transactionId, int hrStatus)
2124
- : base(hrStatus)
2123
+ public CommitMsiTransactionCompleteEventArgs(string transactionId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation, BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action)
2124
+ : base(hrStatus, recommendation, action)
2125
{
2126
this.TransactionId = transactionId;
2127
+ this.Restart = restart;
2128
}
2129
2130
/// <summary>
2131
/// Gets the MSI transaction Id.
2132
/// </summary>
2133
public string TransactionId { get; private set; }
2134
+
2135
+ /// <summary>
2136
+ /// Gets the package restart state after being applied.
2137
+ /// </summary>
2138
+ public ApplyRestart Restart { get; private set; }
2139
}
2140
2141
/// <summary>
@@ -2154,19 +2160,25 @@ namespace WixToolset.Mba.Core
2160
/// Additional arguments passed by the engine after rolling back an MSI transaction.
2161
/// </summary>
2162
[Serializable]
2157
- public class RollbackMsiTransactionCompleteEventArgs : StatusEventArgs
2163
+ public class RollbackMsiTransactionCompleteEventArgs : ActionEventArgs<BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION>
2164
{
2165
/// <summary />
2160
- public RollbackMsiTransactionCompleteEventArgs(string transactionId, int hrStatus)
2161
- : base(hrStatus)
2166
+ public RollbackMsiTransactionCompleteEventArgs(string transactionId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation, BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action)
2167
+ : base(hrStatus, recommendation, action)
2168
{
2169
this.TransactionId = transactionId;
2170
+ this.Restart = restart;
2171
}
2172
2173
/// <summary>
2174
/// Gets the MSI transaction Id.
2175
/// </summary>
2176
public string TransactionId { get; private set; }
2177
+
2178
+ /// <summary>
2179
+ /// Gets the package restart state after being applied.
2180
+ /// </summary>
2181
+ public ApplyRestart Restart { get; private set; }
2182
}
2183
2184
/// <summary>
@@ -2176,7 +2188,7 @@ namespace WixToolset.Mba.Core
2188
public class PauseAutomaticUpdatesBeginEventArgs : HResultEventArgs
2189
{
2190
/// <summary>
2179
- ///
2191
+ ///
2192
/// </summary>
2193
public PauseAutomaticUpdatesBeginEventArgs()
2194
{
@@ -2190,7 +2202,7 @@ namespace WixToolset.Mba.Core
2202
public class PauseAutomaticUpdatesCompleteEventArgs : StatusEventArgs
2203
{
2204
/// <summary>
2193
- ///
2205
+ ///
2206
/// </summary>
2207
/// <param name="hrStatus"></param>
2208
public PauseAutomaticUpdatesCompleteEventArgs(int hrStatus)
@@ -2206,7 +2218,7 @@ namespace WixToolset.Mba.Core
2218
public class SystemRestorePointBeginEventArgs : HResultEventArgs
2219
{
2220
/// <summary>
2209
- ///
2221
+ ///
2222
/// </summary>
2223
public SystemRestorePointBeginEventArgs()
2224
{
@@ -2220,7 +2232,7 @@ namespace WixToolset.Mba.Core
2232
public class SystemRestorePointCompleteEventArgs : StatusEventArgs
2233
{
2234
/// <summary>
2223
- ///
2235
+ ///
2236
/// </summary>
2237
/// <param name="hrStatus"></param>
2238
public SystemRestorePointCompleteEventArgs(int hrStatus)
src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs
+78
-49
@@ -933,12 +933,18 @@ namespace WixToolset.Mba.Core
933
/// </summary>
934
/// <param name="wzTransactionId"></param>
935
/// <param name="hrStatus"></param>
936
+ /// <param name="restart"></param>
937
+ /// <param name="recommendation"></param>
938
+ /// <param name="pAction"></param>
939
/// <returns></returns>
940
[PreserveSig]
941
[return: MarshalAs(UnmanagedType.I4)]
942
int OnCommitMsiTransactionComplete(
943
[MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId,
941
- int hrStatus
944
+ int hrStatus,
945
+ [MarshalAs(UnmanagedType.U4)] ApplyRestart restart,
946
+ [MarshalAs(UnmanagedType.I4)] BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation,
947
+ [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION pAction
948
);
949
950
/// <summary>
@@ -957,12 +963,18 @@ namespace WixToolset.Mba.Core
963
/// </summary>
964
/// <param name="wzTransactionId"></param>
965
/// <param name="hrStatus"></param>
966
+ /// <param name="restart"></param>
967
+ /// <param name="recommendation"></param>
968
+ /// <param name="pAction"></param>
969
/// <returns></returns>
970
[PreserveSig]
971
[return: MarshalAs(UnmanagedType.I4)]
972
int OnRollbackMsiTransactionComplete(
973
[MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId,
965
- int hrStatus
974
+ int hrStatus,
975
+ [MarshalAs(UnmanagedType.U4)] ApplyRestart restart,
976
+ [MarshalAs(UnmanagedType.I4)] BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation,
977
+ [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION pAction
978
);
979
980
/// <summary>
@@ -1199,27 +1211,27 @@ namespace WixToolset.Mba.Core
1211
public enum Display
1212
{
1213
/// <summary>
1202
- ///
1214
+ ///
1215
/// </summary>
1216
Unknown,
1217
1218
/// <summary>
1207
- ///
1219
+ ///
1220
/// </summary>
1221
Embedded,
1222
1223
/// <summary>
1212
- ///
1224
+ ///
1225
/// </summary>
1226
None,
1227
1228
/// <summary>
1217
- ///
1229
+ ///
1230
/// </summary>
1231
Passive,
1232
1233
/// <summary>
1222
- ///
1234
+ ///
1235
/// </summary>
1236
Full,
1237
}
@@ -1331,27 +1343,27 @@ namespace WixToolset.Mba.Core
1343
public enum Restart
1344
{
1345
/// <summary>
1334
- ///
1346
+ ///
1347
/// </summary>
1348
Unknown,
1349
1350
/// <summary>
1339
- ///
1351
+ ///
1352
/// </summary>
1353
Never,
1354
1355
/// <summary>
1344
- ///
1356
+ ///
1357
/// </summary>
1358
Prompt,
1359
1360
/// <summary>
1349
- ///
1361
+ ///
1362
/// </summary>
1363
Automatic,
1364
1365
/// <summary>
1354
- ///
1366
+ ///
1367
/// </summary>
1368
Always,
1369
}
@@ -1384,47 +1396,47 @@ namespace WixToolset.Mba.Core
1396
public enum Result
1397
{
1398
/// <summary>
1387
- ///
1399
+ ///
1400
/// </summary>
1401
Error = -1,
1402
1403
/// <summary>
1392
- ///
1404
+ ///
1405
/// </summary>
1406
None,
1407
1408
/// <summary>
1397
- ///
1409
+ ///
1410
/// </summary>
1411
Ok,
1412
1413
/// <summary>
1402
- ///
1414
+ ///
1415
/// </summary>
1416
Cancel,
1417
1418
/// <summary>
1407
- ///
1419
+ ///
1420
/// </summary>
1421
Abort,
1422
1423
/// <summary>
1412
- ///
1424
+ ///
1425
/// </summary>
1426
Retry,
1427
1428
/// <summary>
1417
- ///
1429
+ ///
1430
/// </summary>
1431
Ignore,
1432
1433
/// <summary>
1422
- ///
1434
+ ///
1435
/// </summary>
1436
Yes,
1437
1438
/// <summary>
1427
- ///
1439
+ ///
1440
/// </summary>
1441
No,
1442
@@ -1434,17 +1446,17 @@ namespace WixToolset.Mba.Core
1446
Close,
1447
1448
/// <summary>
1437
- ///
1449
+ ///
1450
/// </summary>
1451
Help,
1452
1453
/// <summary>
1442
- ///
1454
+ ///
1455
/// </summary>
1456
TryAgain,
1457
1458
/// <summary>
1447
- ///
1459
+ ///
1460
/// </summary>
1461
Continue,
1462
}
@@ -1455,7 +1467,7 @@ namespace WixToolset.Mba.Core
1467
public enum ResumeType
1468
{
1469
/// <summary>
1458
- ///
1470
+ ///
1471
/// </summary>
1472
None,
1473
@@ -1546,7 +1558,7 @@ namespace WixToolset.Mba.Core
1558
public enum RelatedOperation
1559
{
1560
/// <summary>
1549
- ///
1561
+ ///
1562
/// </summary>
1563
None,
1564
@@ -1685,47 +1697,47 @@ namespace WixToolset.Mba.Core
1697
public enum RelationType
1698
{
1699
/// <summary>
1688
- ///
1700
+ ///
1701
/// </summary>
1702
None,
1703
1704
/// <summary>
1693
- ///
1705
+ ///
1706
/// </summary>
1707
Detect,
1708
1709
/// <summary>
1698
- ///
1710
+ ///
1711
/// </summary>
1712
Upgrade,
1713
1714
/// <summary>
1703
- ///
1715
+ ///
1716
/// </summary>
1717
Addon,
1718
1719
/// <summary>
1708
- ///
1720
+ ///
1721
/// </summary>
1722
Patch,
1723
1724
/// <summary>
1713
- ///
1725
+ ///
1726
/// </summary>
1727
DependentAddon,
1728
1729
/// <summary>
1718
- ///
1730
+ ///
1731
/// </summary>
1732
DependentPatch,
1733
1734
/// <summary>
1723
- ///
1735
+ ///
1736
/// </summary>
1737
Update,
1738
1739
/// <summary>
1728
- ///
1740
+ ///
1741
/// </summary>
1742
ChainPackage,
1743
}
@@ -1736,37 +1748,37 @@ namespace WixToolset.Mba.Core
1748
public enum RelatedBundlePlanType
1749
{
1750
/// <summary>
1739
- ///
1751
+ ///
1752
/// </summary>
1753
None,
1754
1755
/// <summary>
1744
- ///
1756
+ ///
1757
/// </summary>
1758
Downgrade,
1759
1760
/// <summary>
1749
- ///
1761
+ ///
1762
/// </summary>
1763
Upgrade,
1764
1765
/// <summary>
1754
- ///
1766
+ ///
1767
/// </summary>
1768
Addon,
1769
1770
/// <summary>
1759
- ///
1771
+ ///
1772
/// </summary>
1773
Patch,
1774
1775
/// <summary>
1764
- ///
1776
+ ///
1777
/// </summary>
1778
DependentAddon,
1779
1780
/// <summary>
1769
- ///
1781
+ ///
1782
/// </summary>
1783
DependentPatch,
1784
}
@@ -1804,7 +1816,7 @@ namespace WixToolset.Mba.Core
1816
public enum BOOTSTRAPPER_APPLYCOMPLETE_ACTION
1817
{
1818
/// <summary>
1807
- ///
1819
+ ///
1820
/// </summary>
1821
None,
1822
@@ -1843,7 +1855,7 @@ namespace WixToolset.Mba.Core
1855
public enum BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION
1856
{
1857
/// <summary>
1846
- ///
1858
+ ///
1859
/// </summary>
1860
None,
1861
@@ -1860,7 +1872,7 @@ namespace WixToolset.Mba.Core
1872
public enum BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION
1873
{
1874
/// <summary>
1863
- ///
1875
+ ///
1876
/// </summary>
1877
None,
1878
@@ -1883,7 +1895,7 @@ namespace WixToolset.Mba.Core
1895
public enum BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION
1896
{
1897
/// <summary>
1886
- ///
1898
+ ///
1899
/// </summary>
1900
None,
1901
@@ -1900,7 +1912,7 @@ namespace WixToolset.Mba.Core
1912
public enum BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION
1913
{
1914
/// <summary>
1903
- ///
1915
+ ///
1916
/// </summary>
1917
None,
1918
@@ -1921,7 +1933,7 @@ namespace WixToolset.Mba.Core
1933
public enum BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION
1934
{
1935
/// <summary>
1924
- ///
1936
+ ///
1937
/// </summary>
1938
None,
1939
@@ -1949,6 +1961,23 @@ namespace WixToolset.Mba.Core
1961
Suspend,
1962
}
1963
1964
+ /// <summary>
1965
+ /// The available actions for <see cref="IDefaultBootstrapperApplication.CommitMsiTransactionComplete"/> and <see cref="IDefaultBootstrapperApplication.RollbackMsiTransactionComplete"/>.
1966
+ /// </summary>
1967
+ public enum BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION
1968
+ {
1969
+ /// <summary>
1970
+ ///
1971
+ /// </summary>
1972
+ None,
1973
+
1974
+ /// <summary>
1975
+ /// Instructs the engine to stop processing the chain and restart.
1976
+ /// The engine will launch again after the machine is restarted.
1977
+ /// </summary>
1978
+ Restart,
1979
+ };
1980
+
1981
/// <summary>
1982
/// The available actions for <see cref="IDefaultBootstrapperApplication.ExecuteProcessCancel"/>.
1983
/// </summary>
@@ -2017,7 +2046,7 @@ namespace WixToolset.Mba.Core
2046
public enum BOOTSTRAPPER_SHUTDOWN_ACTION
2047
{
2048
/// <summary>
2020
- ///
2049
+ ///
2050
/// </summary>
2051
None,
2052
src/api/burn/balutil/inc/BalBaseBAFunctions.h
+8
-2
@@ -710,7 +710,10 @@ public: // IBootstrapperApplication
710
711
virtual STDMETHODIMP OnCommitMsiTransactionComplete(
712
__in_z LPCWSTR /*wzTransactionId*/,
713
- __in HRESULT /*hrStatus*/
713
+ __in HRESULT /*hrStatus*/,
714
+ __in BOOTSTRAPPER_APPLY_RESTART /*restart*/,
715
+ __in BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION /*recommendation*/,
716
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* /*pAction*/
717
)
718
{
719
return S_OK;
@@ -725,7 +728,10 @@ public: // IBootstrapperApplication
728
729
virtual STDMETHODIMP OnRollbackMsiTransactionComplete(
730
__in_z LPCWSTR /*wzTransactionId*/,
728
- __in HRESULT /*hrStatus*/
731
+ __in HRESULT /*hrStatus*/,
732
+ __in BOOTSTRAPPER_APPLY_RESTART /*restart*/,
733
+ __in BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION /*recommendation*/,
734
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* /*pAction*/
735
)
736
{
737
return S_OK;
src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h
+27
-5
@@ -197,7 +197,7 @@ public: // IBootstrapperApplication
197
__in LPCWSTR /*wzVersion*/,
198
__in BOOTSTRAPPER_RELATED_OPERATION /*operation*/,
199
__inout BOOL* pfCancel
200
- )
200
+ )
201
{
202
*pfCancel |= CheckCanceled();
203
return S_OK;
@@ -902,10 +902,21 @@ public: // IBootstrapperApplication
902
903
virtual STDMETHODIMP OnCommitMsiTransactionComplete(
904
__in_z LPCWSTR /*wzTransactionId*/,
905
- __in HRESULT /*hrStatus*/
905
+ __in HRESULT /*hrStatus*/,
906
+ __in BOOTSTRAPPER_APPLY_RESTART /*restart*/,
907
+ __in BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION /*recommendation*/,
908
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* /*pAction*/
909
)
910
{
908
- return S_OK;
911
+ HRESULT hr = S_OK;
912
+
913
+ if (CheckCanceled())
914
+ {
915
+ ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT));
916
+ }
917
+
918
+ LExit:
919
+ return hr;
920
}
921
922
virtual STDMETHODIMP OnRollbackMsiTransactionBegin(
@@ -917,10 +928,21 @@ public: // IBootstrapperApplication
928
929
virtual STDMETHODIMP OnRollbackMsiTransactionComplete(
930
__in_z LPCWSTR /*wzTransactionId*/,
920
- __in HRESULT /*hrStatus*/
931
+ __in HRESULT /*hrStatus*/,
932
+ __in BOOTSTRAPPER_APPLY_RESTART /*restart*/,
933
+ __in BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION /*recommendation*/,
934
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* /*pAction*/
935
)
936
{
923
- return S_OK;
937
+ HRESULT hr = S_OK;
938
+
939
+ if (CheckCanceled())
940
+ {
941
+ ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT));
942
+ }
943
+
944
+ LExit:
945
+ return hr;
946
}
947
948
virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin(
src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h
+5
-5
@@ -579,10 +579,10 @@ static HRESULT BalBaseBAProcOnCommitMsiTransactionBegin(
579
static HRESULT BalBaseBAProcOnCommitMsiTransactionComplete(
580
__in IBootstrapperApplication* pBA,
581
__in BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS* pArgs,
582
- __inout BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/
582
+ __inout BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS* pResults
583
)
584
{
585
- return pBA->OnCommitMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus);
585
+ return pBA->OnCommitMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action);
586
}
587
588
static HRESULT BalBaseBAProcOnRollbackMsiTransactionBegin(
@@ -597,10 +597,10 @@ static HRESULT BalBaseBAProcOnRollbackMsiTransactionBegin(
597
static HRESULT BalBaseBAProcOnRollbackMsiTransactionComplete(
598
__in IBootstrapperApplication* pBA,
599
__in BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS* pArgs,
600
- __inout BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/
600
+ __inout BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS* pResults
601
)
602
{
603
- return pBA->OnRollbackMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus);
603
+ return pBA->OnRollbackMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action);
604
}
605
606
static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesBegin(
@@ -780,7 +780,7 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc(
780
{
781
IBootstrapperApplication* pBA = reinterpret_cast<IBootstrapperApplication*>(pvContext);
782
HRESULT hr = pBA->BAProc(message, pvArgs, pvResults, pvContext);
783
-
783
+
784
if (E_NOTIMPL == hr)
785
{
786
switch (message)
src/api/burn/balutil/inc/IBootstrapperApplication.h
+9
-3
@@ -574,7 +574,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A
574
) = 0;
575
576
// OnLaunchApprovedExeBegin - called before trying to launch the preapproved executable.
577
- //
577
+ //
578
STDMETHOD(OnLaunchApprovedExeBegin)(
579
__inout BOOL* pfCancel
580
) = 0;
@@ -603,7 +603,10 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A
603
604
STDMETHOD(OnCommitMsiTransactionComplete)(
605
__in_z LPCWSTR wzTransactionId,
606
- __in HRESULT hrStatus
606
+ __in HRESULT hrStatus,
607
+ __in BOOTSTRAPPER_APPLY_RESTART restart,
608
+ __in BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation,
609
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* pAction
610
) = 0;
611
612
STDMETHOD(OnRollbackMsiTransactionBegin)(
@@ -612,7 +615,10 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A
615
616
STDMETHOD(OnRollbackMsiTransactionComplete)(
617
__in_z LPCWSTR wzTransactionId,
615
- __in HRESULT hrStatus
618
+ __in HRESULT hrStatus,
619
+ __in BOOTSTRAPPER_APPLY_RESTART restart,
620
+ __in BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation,
621
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* pAction
622
) = 0;
623
624
STDMETHOD(OnPauseAutomaticUpdatesBegin)(
src/burn/engine/apply.cpp
+32
-16
@@ -300,12 +300,14 @@ static HRESULT ExecuteMsiBeginTransaction(
300
static HRESULT ExecuteMsiCommitTransaction(
301
__in BURN_ENGINE_STATE* pEngineState,
302
__in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
303
- __in BURN_EXECUTE_CONTEXT* pContext
303
+ __in BURN_EXECUTE_CONTEXT* pContext,
304
+ __out BOOTSTRAPPER_APPLY_RESTART *pRestart
305
);
306
static HRESULT ExecuteMsiRollbackTransaction(
307
__in BURN_ENGINE_STATE* pEngineState,
308
__in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
308
- __in BURN_EXECUTE_CONTEXT* pContext
309
+ __in BURN_EXECUTE_CONTEXT* pContext,
310
+ __out BOOTSTRAPPER_APPLY_RESTART *pRestart
311
);
312
static void ResetTransactionRegistrationState(
313
__in BURN_ENGINE_STATE* pEngineState,
@@ -645,7 +647,7 @@ extern "C" HRESULT ApplyCache(
647
Assert(pPlan->sczLayoutDirectory);
648
hr = ApplyLayoutContainer(&cacheContext, pCacheAction->container.pContainer);
649
ExitOnFailure(hr, "Failed cache action: %ls", L"layout container");
648
-
650
+
651
break;
652
653
case BURN_CACHE_ACTION_TYPE_SIGNAL_SYNCPOINT:
@@ -793,7 +795,7 @@ extern "C" HRESULT ApplyExecute(
795
796
if (pCheckpoint && pCheckpoint->pActiveRollbackBoundary && pCheckpoint->pActiveRollbackBoundary->fActiveTransaction)
797
{
796
- hrRollback = ExecuteMsiCommitTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context);
798
+ hrRollback = ExecuteMsiCommitTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context, pRestart);
799
IgnoreRollbackError(hrRollback, "Failed commit transaction from disable rollback");
800
}
801
@@ -806,7 +808,7 @@ extern "C" HRESULT ApplyExecute(
808
// If inside a MSI transaction, roll it back.
809
if (pCheckpoint->pActiveRollbackBoundary && pCheckpoint->pActiveRollbackBoundary->fActiveTransaction)
810
{
809
- hrRollback = ExecuteMsiRollbackTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context);
811
+ hrRollback = ExecuteMsiRollbackTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context, pRestart);
812
IgnoreRollbackError(hrRollback, "Failed rolling back transaction");
813
}
814
@@ -2058,13 +2060,13 @@ static HRESULT DownloadPayload(
2060
cacheCallback.pfnProgress = CacheProgressRoutine;
2061
cacheCallback.pfnCancel = NULL; // TODO: set this
2062
cacheCallback.pv = pProgress;
2061
-
2063
+
2064
authenticationData.pUX = pProgress->pCacheContext->pUX;
2065
authenticationData.wzPackageOrContainerId = wzPackageOrContainerId;
2066
authenticationData.wzPayloadId = wzPayloadId;
2067
authenticationCallback.pv = static_cast<LPVOID>(&authenticationData);
2068
authenticationCallback.pfnAuthenticate = &AuthenticationRequired;
2067
-
2069
+
2070
hr = DownloadUrl(pDownloadSource, qwDownloadSize, wzDestinationPath, &cacheCallback, &authenticationCallback);
2071
ExitOnFailure(hr, "Failed attempt to download URL: '%ls' to: '%ls'", pDownloadSource->sczUrl, wzDestinationPath);
2072
@@ -2526,7 +2528,7 @@ static HRESULT DoExecuteAction(
2528
break;
2529
2530
case BURN_EXECUTE_ACTION_TYPE_COMMIT_MSI_TRANSACTION:
2529
- hr = ExecuteMsiCommitTransaction(pEngineState, pExecuteAction->msiTransaction.pRollbackBoundary, pContext);
2531
+ hr = ExecuteMsiCommitTransaction(pEngineState, pExecuteAction->msiTransaction.pRollbackBoundary, pContext, &restart);
2532
ExitOnFailure(hr, "Failed to execute commit MSI transaction action.");
2533
break;
2534
@@ -3381,11 +3383,13 @@ LExit:
3383
static HRESULT ExecuteMsiCommitTransaction(
3384
__in BURN_ENGINE_STATE* pEngineState,
3385
__in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
3384
- __in BURN_EXECUTE_CONTEXT* /*pContext*/
3386
+ __in BURN_EXECUTE_CONTEXT* pContext,
3387
+ __out BOOTSTRAPPER_APPLY_RESTART *pRestart
3388
)
3389
{
3390
HRESULT hr = S_OK;
3391
BOOL fCommitBeginCalled = FALSE;
3392
+ BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action = BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_NONE;
3393
3394
if (!pRollbackBoundary->fActiveTransaction)
3395
{
@@ -3398,12 +3402,12 @@ static HRESULT ExecuteMsiCommitTransaction(
3402
3403
if (pEngineState->plan.fPerMachine)
3404
{
3401
- hr = ElevationMsiCommitTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary);
3405
+ hr = ElevationMsiCommitTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary, MsiExecuteMessageHandler, pContext, pRestart);
3406
ExitOnFailure(hr, "Failed to commit an elevated MSI transaction.");
3407
}
3408
else
3409
{
3406
- hr = MsiEngineCommitTransaction(pRollbackBoundary);
3410
+ hr = MsiEngineCommitTransaction(pRollbackBoundary, pRestart);
3411
}
3412
3413
// Assume that MsiEndTransaction can only be called once for each MsiBeginTransaction.
@@ -3414,7 +3418,12 @@ static HRESULT ExecuteMsiCommitTransaction(
3418
LExit:
3419
if (fCommitBeginCalled)
3420
{
3417
- UserExperienceOnCommitMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr);
3421
+ UserExperienceOnCommitMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr, *pRestart, &action);
3422
+
3423
+ if (action == BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_RESTART)
3424
+ {
3425
+ *pRestart = BOOTSTRAPPER_APPLY_RESTART_INITIATED;
3426
+ }
3427
}
3428
3429
return hr;
@@ -3423,11 +3432,13 @@ LExit:
3432
static HRESULT ExecuteMsiRollbackTransaction(
3433
__in BURN_ENGINE_STATE* pEngineState,
3434
__in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
3426
- __in BURN_EXECUTE_CONTEXT* /*pContext*/
3435
+ __in BURN_EXECUTE_CONTEXT* pContext,
3436
+ __out BOOTSTRAPPER_APPLY_RESTART *pRestart
3437
)
3438
{
3439
HRESULT hr = S_OK;
3440
BOOL fRollbackBeginCalled = FALSE;
3441
+ BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action = BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_NONE;
3442
3443
if (!pRollbackBoundary->fActiveTransaction)
3444
{
@@ -3439,12 +3450,12 @@ static HRESULT ExecuteMsiRollbackTransaction(
3450
3451
if (pEngineState->plan.fPerMachine)
3452
{
3442
- hr = ElevationMsiRollbackTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary);
3453
+ hr = ElevationMsiRollbackTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary, MsiExecuteMessageHandler, pContext, pRestart);
3454
ExitOnFailure(hr, "Failed to rollback an elevated MSI transaction.");
3455
}
3456
else
3457
{
3447
- hr = MsiEngineRollbackTransaction(pRollbackBoundary);
3458
+ hr = MsiEngineRollbackTransaction(pRollbackBoundary, pRestart);
3459
}
3460
3461
LExit:
@@ -3454,7 +3465,12 @@ LExit:
3465
3466
if (fRollbackBeginCalled)
3467
{
3457
- UserExperienceOnRollbackMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr);
3468
+ UserExperienceOnRollbackMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr, *pRestart, &action);
3469
+
3470
+ if (action == BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_RESTART)
3471
+ {
3472
+ *pRestart = BOOTSTRAPPER_APPLY_RESTART_INITIATED;
3473
+ }
3474
}
3475
3476
return hr;
src/burn/engine/elevation.cpp
+52
-28
@@ -371,12 +371,14 @@ static HRESULT OnMsiBeginTransaction(
371
static HRESULT OnMsiCommitTransaction(
372
__in BURN_PACKAGES* pPackages,
373
__in BYTE* pbData,
374
- __in SIZE_T cbData
374
+ __in SIZE_T cbData,
375
+ __out BOOTSTRAPPER_APPLY_RESTART *pRestart
376
);
377
static HRESULT OnMsiRollbackTransaction(
378
__in BURN_PACKAGES* pPackages,
379
__in BYTE* pbData,
379
- __in SIZE_T cbData
380
+ __in SIZE_T cbData,
381
+ __out BOOTSTRAPPER_APPLY_RESTART *pRestart
382
);
383
static HRESULT ElevatedOnPauseAUBegin(
384
__in HANDLE hPipe
@@ -496,7 +498,7 @@ extern "C" HRESULT ElevationApplyInitialize(
498
499
hr = BuffWriteNumber(&pbData, &cbData, (DWORD)!pPlan->pInternalCommand->fDisableSystemRestore);
500
ExitOnFailure(hr, "Failed to write system restore point action to message buffer.");
499
-
501
+
502
hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData);
503
ExitOnFailure(hr, "Failed to write variables.");
504
@@ -544,7 +546,7 @@ LExit:
546
}
547
548
/*******************************************************************
547
- ElevationSessionBegin -
549
+ ElevationSessionBegin -
550
551
*******************************************************************/
552
extern "C" HRESULT ElevationSessionBegin(
@@ -602,7 +604,7 @@ LExit:
604
}
605
606
/*******************************************************************
605
- ElevationSessionEnd -
607
+ ElevationSessionEnd -
608
609
*******************************************************************/
610
extern "C" HRESULT ElevationSessionEnd(
@@ -648,7 +650,7 @@ LExit:
650
}
651
652
/*******************************************************************
651
- ElevationSaveState -
653
+ ElevationSaveState -
654
655
*******************************************************************/
656
HRESULT ElevationSaveState(
@@ -697,7 +699,7 @@ LExit:
699
}
700
701
/*******************************************************************
700
- ElevationCacheCompletePayload -
702
+ ElevationCacheCompletePayload -
703
704
*******************************************************************/
705
extern "C" HRESULT ElevationCacheCompletePayload(
@@ -785,7 +787,7 @@ LExit:
787
}
788
789
/*******************************************************************
788
- ElevationCacheCleanup -
790
+ ElevationCacheCleanup -
791
792
*******************************************************************/
793
extern "C" HRESULT ElevationCacheCleanup(
@@ -838,7 +840,7 @@ LExit:
840
}
841
842
/*******************************************************************
841
- ElevationExecuteRelatedBundle -
843
+ ElevationExecuteRelatedBundle -
844
845
*******************************************************************/
846
extern "C" HRESULT ElevationExecuteRelatedBundle(
@@ -899,7 +901,7 @@ LExit:
901
}
902
903
/*******************************************************************
902
- ElevationExecuteBundlePackage -
904
+ ElevationExecuteBundlePackage -
905
906
*******************************************************************/
907
extern "C" HRESULT ElevationExecuteBundlePackage(
@@ -963,7 +965,7 @@ LExit:
965
}
966
967
/*******************************************************************
966
- ElevationExecuteExePackage -
968
+ ElevationExecuteExePackage -
969
970
*******************************************************************/
971
extern "C" HRESULT ElevationExecuteExePackage(
@@ -1047,12 +1049,16 @@ LExit:
1049
1050
extern "C" HRESULT ElevationMsiCommitTransaction(
1051
__in HANDLE hPipe,
1050
- __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
1052
+ __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
1053
+ __in PFN_MSIEXECUTEMESSAGEHANDLER pfnMessageHandler,
1054
+ __in LPVOID pvContext,
1055
+ __out BOOTSTRAPPER_APPLY_RESTART* pRestart
1056
)
1057
{
1058
HRESULT hr = S_OK;
1059
BYTE* pbData = NULL;
1060
SIZE_T cbData = 0;
1061
+ BURN_ELEVATION_MSI_MESSAGE_CONTEXT context = { };
1062
DWORD dwResult = ERROR_SUCCESS;
1063
1064
// serialize message data
@@ -1062,10 +1068,15 @@ extern "C" HRESULT ElevationMsiCommitTransaction(
1068
hr = BuffWriteString(&pbData, &cbData, pRollbackBoundary->sczLogPath);
1069
ExitOnFailure(hr, "Failed to write transaction log path to message buffer.");
1070
1065
- hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION, pbData, cbData, NULL, NULL, &dwResult);
1071
+ // send message
1072
+ context.pfnMessageHandler = pfnMessageHandler;
1073
+ context.pvContext = pvContext;
1074
+
1075
+ hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION, pbData, cbData, ProcessMsiPackageMessages, &context, &dwResult);
1076
ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION message to per-machine process.");
1077
1078
hr = static_cast<HRESULT>(dwResult);
1079
+ *pRestart = context.restart;
1080
1081
LExit:
1082
ReleaseBuffer(pbData);
@@ -1075,12 +1086,16 @@ LExit:
1086
1087
extern "C" HRESULT ElevationMsiRollbackTransaction(
1088
__in HANDLE hPipe,
1078
- __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
1089
+ __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
1090
+ __in PFN_MSIEXECUTEMESSAGEHANDLER pfnMessageHandler,
1091
+ __in LPVOID pvContext,
1092
+ __out BOOTSTRAPPER_APPLY_RESTART* pRestart
1093
)
1094
{
1095
HRESULT hr = S_OK;
1096
BYTE* pbData = NULL;
1097
SIZE_T cbData = 0;
1098
+ BURN_ELEVATION_MSI_MESSAGE_CONTEXT context = { };
1099
DWORD dwResult = ERROR_SUCCESS;
1100
1101
// serialize message data
@@ -1090,10 +1105,15 @@ extern "C" HRESULT ElevationMsiRollbackTransaction(
1105
hr = BuffWriteString(&pbData, &cbData, pRollbackBoundary->sczLogPath);
1106
ExitOnFailure(hr, "Failed to write transaction log path to message buffer.");
1107
1093
- hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION, pbData, cbData, NULL, NULL, &dwResult);
1108
+ // send message
1109
+ context.pfnMessageHandler = pfnMessageHandler;
1110
+ context.pvContext = pvContext;
1111
+
1112
+ hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION, pbData, cbData, ProcessMsiPackageMessages, &context, &dwResult);
1113
ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION message to per-machine process.");
1114
1115
hr = static_cast<HRESULT>(dwResult);
1116
+ *pRestart = context.restart;
1117
1118
LExit:
1119
ReleaseBuffer(pbData);
@@ -1104,7 +1124,7 @@ LExit:
1124
1125
1126
/*******************************************************************
1107
- ElevationExecuteMsiPackage -
1127
+ ElevationExecuteMsiPackage -
1128
1129
*******************************************************************/
1130
extern "C" HRESULT ElevationExecuteMsiPackage(
@@ -1189,7 +1209,7 @@ LExit:
1209
}
1210
1211
/*******************************************************************
1192
- ElevationExecuteMspPackage -
1212
+ ElevationExecuteMspPackage -
1213
1214
*******************************************************************/
1215
extern "C" HRESULT ElevationExecuteMspPackage(
@@ -1269,7 +1289,7 @@ LExit:
1289
}
1290
1291
/*******************************************************************
1272
- ElevationExecuteMsuPackage -
1292
+ ElevationExecuteMsuPackage -
1293
1294
*******************************************************************/
1295
extern "C" HRESULT ElevationExecuteMsuPackage(
@@ -1480,7 +1500,7 @@ LExit:
1500
}
1501
1502
/*******************************************************************
1483
- ElevationCleanPackage -
1503
+ ElevationCleanPackage -
1504
1505
*******************************************************************/
1506
extern "C" HRESULT ElevationCleanPackage(
@@ -1545,7 +1565,7 @@ LExit:
1565
}
1566
1567
/*******************************************************************
1548
- ElevationChildPumpMessages -
1568
+ ElevationChildPumpMessages -
1569
1570
*******************************************************************/
1571
extern "C" HRESULT ElevationChildPumpMessages(
@@ -1875,7 +1895,7 @@ static HRESULT ProcessGenericExecuteMessages(
1895
1896
hr = BuffReadNumber((BYTE*)pMsg->pvData, pMsg->cbData, &iData, &message.dwUIHint);
1897
ExitOnFailure(hr, "Failed to allowed results.");
1878
-
1898
+
1899
// Process the message.
1900
switch (pMsg->dwMessage)
1901
{
@@ -2052,7 +2072,7 @@ static HRESULT ProcessMsiPackageMessages(
2072
ExitOnRootFailure(hr, "Invalid package message.");
2073
break;
2074
}
2055
-
2075
+
2076
// send message
2077
*pdwResult = (DWORD)pContext->pfnMessageHandler(&message, pContext->pvContext);
2078
@@ -2154,11 +2174,13 @@ static HRESULT ProcessElevatedChildMessage(
2174
break;
2175
2176
case BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION:
2157
- hrResult = OnMsiCommitTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData);
2177
+ hrResult = OnMsiCommitTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData, &restart);
2178
+ fSendRestart = TRUE;
2179
break;
2180
2181
case BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION:
2161
- hrResult = OnMsiRollbackTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData);
2182
+ hrResult = OnMsiRollbackTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData, &restart);
2183
+ fSendRestart = TRUE;
2184
break;
2185
2186
case BURN_ELEVATION_MESSAGE_TYPE_APPLY_INITIALIZE:
@@ -3922,7 +3944,8 @@ LExit:
3944
static HRESULT OnMsiCommitTransaction(
3945
__in BURN_PACKAGES* pPackages,
3946
__in BYTE* pbData,
3925
- __in SIZE_T cbData
3947
+ __in SIZE_T cbData,
3948
+ __out BOOTSTRAPPER_APPLY_RESTART *pRestart
3949
)
3950
{
3951
HRESULT hr = S_OK;
@@ -3946,7 +3969,7 @@ static HRESULT OnMsiCommitTransaction(
3969
pRollbackBoundary->sczLogPath = sczLogPath;
3970
}
3971
3949
- hr = MsiEngineCommitTransaction(pRollbackBoundary);
3972
+ hr = MsiEngineCommitTransaction(pRollbackBoundary, pRestart);
3973
3974
LExit:
3975
ReleaseStr(sczId);
@@ -3963,7 +3986,8 @@ LExit:
3986
static HRESULT OnMsiRollbackTransaction(
3987
__in BURN_PACKAGES* pPackages,
3988
__in BYTE* pbData,
3966
- __in SIZE_T cbData
3989
+ __in SIZE_T cbData,
3990
+ __out BOOTSTRAPPER_APPLY_RESTART *pRestart
3991
)
3992
{
3993
HRESULT hr = S_OK;
@@ -3987,7 +4011,7 @@ static HRESULT OnMsiRollbackTransaction(
4011
pRollbackBoundary->sczLogPath = sczLogPath;
4012
}
4013
3990
- hr = MsiEngineRollbackTransaction(pRollbackBoundary);
4014
+ hr = MsiEngineRollbackTransaction(pRollbackBoundary, pRestart);
4015
4016
LExit:
4017
ReleaseStr(sczId);
src/burn/engine/elevation.h
+8
-2
@@ -191,11 +191,17 @@ HRESULT ElevationMsiBeginTransaction(
191
);
192
HRESULT ElevationMsiCommitTransaction(
193
__in HANDLE hPipe,
194
- __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
194
+ __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
195
+ __in PFN_MSIEXECUTEMESSAGEHANDLER pfnMessageHandler,
196
+ __in LPVOID pvContext,
197
+ __out BOOTSTRAPPER_APPLY_RESTART* pRestart
198
);
199
HRESULT ElevationMsiRollbackTransaction(
200
__in HANDLE hPipe,
198
- __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
201
+ __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
202
+ __in PFN_MSIEXECUTEMESSAGEHANDLER pfnMessageHandler,
203
+ __in LPVOID pvContext,
204
+ __out BOOTSTRAPPER_APPLY_RESTART* pRestart
205
);
206
207
#ifdef __cplusplus
src/burn/engine/msiengine.cpp
+37
-5
@@ -1139,33 +1139,65 @@ LExit:
1139
}
1140
1141
extern "C" HRESULT MsiEngineCommitTransaction(
1142
- __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
1142
+ __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
1143
+ __out BOOTSTRAPPER_APPLY_RESTART* pRestart
1144
)
1145
{
1146
HRESULT hr = S_OK;
1147
+ WIU_RESTART restart = WIU_RESTART_NONE;
1148
1149
LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_COMMIT, pRollbackBoundary->sczId);
1150
1149
- hr = WiuEndTransaction(MSITRANSACTIONSTATE_COMMIT, WIU_LOG_DEFAULT | INSTALLLOGMODE_VERBOSE, pRollbackBoundary->sczLogPath);
1151
+ hr = WiuEndTransaction(MSITRANSACTIONSTATE_COMMIT, WIU_LOG_DEFAULT | INSTALLLOGMODE_VERBOSE, pRollbackBoundary->sczLogPath, &restart);
1152
ExitOnFailure(hr, "Failed to commit the MSI transaction");
1153
1154
LExit:
1155
+ switch (restart)
1156
+ {
1157
+ case WIU_RESTART_NONE:
1158
+ *pRestart = BOOTSTRAPPER_APPLY_RESTART_NONE;
1159
+ break;
1160
+
1161
+ case WIU_RESTART_REQUIRED:
1162
+ *pRestart = BOOTSTRAPPER_APPLY_RESTART_REQUIRED;
1163
+ break;
1164
+
1165
+ case WIU_RESTART_INITIATED:
1166
+ *pRestart = BOOTSTRAPPER_APPLY_RESTART_INITIATED;
1167
+ break;
1168
+ }
1169
1170
return hr;
1171
}
1172
1173
extern "C" HRESULT MsiEngineRollbackTransaction(
1158
- __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
1174
+ __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
1175
+ __out BOOTSTRAPPER_APPLY_RESTART* pRestart
1176
)
1177
{
1178
HRESULT hr = S_OK;
1179
+ WIU_RESTART restart = WIU_RESTART_NONE;
1180
1181
LogId(REPORT_WARNING, MSG_MSI_TRANSACTION_ROLLBACK, pRollbackBoundary->sczId);
1182
1165
- hr = WiuEndTransaction(MSITRANSACTIONSTATE_ROLLBACK, WIU_LOG_DEFAULT | INSTALLLOGMODE_VERBOSE, pRollbackBoundary->sczLogPath);
1183
+ hr = WiuEndTransaction(MSITRANSACTIONSTATE_ROLLBACK, WIU_LOG_DEFAULT | INSTALLLOGMODE_VERBOSE, pRollbackBoundary->sczLogPath, &restart);
1184
ExitOnFailure(hr, "Failed to rollback the MSI transaction");
1185
1186
LExit:
1187
+ switch (restart)
1188
+ {
1189
+ case WIU_RESTART_NONE:
1190
+ *pRestart = BOOTSTRAPPER_APPLY_RESTART_NONE;
1191
+ break;
1192
+
1193
+ case WIU_RESTART_REQUIRED:
1194
+ *pRestart = BOOTSTRAPPER_APPLY_RESTART_REQUIRED;
1195
+ break;
1196
+
1197
+ case WIU_RESTART_INITIATED:
1198
+ *pRestart = BOOTSTRAPPER_APPLY_RESTART_INITIATED;
1199
+ break;
1200
+ }
1201
1202
return hr;
1203
}
@@ -1246,7 +1278,7 @@ extern "C" HRESULT MsiEngineExecutePackage(
1278
1279
// Best effort to set the execute package action variable.
1280
VariableSetNumeric(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_ACTION, pExecuteAction->msiPackage.action, TRUE);
1249
-
1281
+
1282
// Wire up the external UI handler and logging.
1283
if (pExecuteAction->msiPackage.fDisableExternalUiHandler)
1284
{
src/burn/engine/msiengine.h
+4
-2
@@ -60,10 +60,12 @@ HRESULT MsiEngineBeginTransaction(
60
__in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
61
);
62
HRESULT MsiEngineCommitTransaction(
63
- __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
63
+ __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
64
+ __out BOOTSTRAPPER_APPLY_RESTART* pRestart
65
);
66
HRESULT MsiEngineRollbackTransaction(
66
- __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
67
+ __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
68
+ __out BOOTSTRAPPER_APPLY_RESTART* pRestart
69
);
70
HRESULT MsiEngineExecutePackage(
71
__in_opt HWND hwndParent,
src/burn/engine/userexperience.cpp
+26
-12
@@ -35,7 +35,7 @@ static HRESULT SendBAMessageFromInactiveEngine(
35
// function definitions
36
37
/*******************************************************************
38
- UserExperienceParseFromXml -
38
+ UserExperienceParseFromXml -
39
40
*******************************************************************/
41
extern "C" HRESULT UserExperienceParseFromXml(
@@ -72,7 +72,7 @@ LExit:
72
}
73
74
/*******************************************************************
75
- UserExperienceUninitialize -
75
+ UserExperienceUninitialize -
76
77
*******************************************************************/
78
extern "C" void UserExperienceUninitialize(
@@ -87,7 +87,7 @@ extern "C" void UserExperienceUninitialize(
87
}
88
89
/*******************************************************************
90
- UserExperienceLoad -
90
+ UserExperienceLoad -
91
92
*******************************************************************/
93
extern "C" HRESULT UserExperienceLoad(
@@ -129,7 +129,7 @@ LExit:
129
}
130
131
/*******************************************************************
132
- UserExperienceUnload -
132
+ UserExperienceUnload -
133
134
*******************************************************************/
135
extern "C" HRESULT UserExperienceUnload(
@@ -380,7 +380,7 @@ EXTERN_C BAAPI UserExperienceOnBeginMsiTransactionBegin(
380
args.wzTransactionId = wzTransactionId;
381
382
results.cbSize = sizeof(results);
383
-
383
+
384
hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, &args, &results);
385
ExitOnFailure(hr, "BA OnBeginMsiTransactionBegin failed.");
386
@@ -1017,7 +1017,7 @@ EXTERN_C BAAPI UserExperienceOnCommitMsiTransactionBegin(
1017
args.wzTransactionId = wzTransactionId;
1018
1019
results.cbSize = sizeof(results);
1020
-
1020
+
1021
hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, &args, &results);
1022
ExitOnFailure(hr, "BA OnCommitMsiTransactionBegin failed.");
1023
@@ -1033,8 +1033,10 @@ LExit:
1033
EXTERN_C BAAPI UserExperienceOnCommitMsiTransactionComplete(
1034
__in BURN_USER_EXPERIENCE* pUserExperience,
1035
__in LPCWSTR wzTransactionId,
1036
- __in HRESULT hrStatus
1037
- )
1036
+ __in HRESULT hrStatus,
1037
+ __in BOOTSTRAPPER_APPLY_RESTART restart,
1038
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* pAction
1039
+)
1040
{
1041
HRESULT hr = S_OK;
1042
BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS args = { };
@@ -1043,12 +1045,17 @@ EXTERN_C BAAPI UserExperienceOnCommitMsiTransactionComplete(
1045
args.cbSize = sizeof(args);
1046
args.wzTransactionId = wzTransactionId;
1047
args.hrStatus = hrStatus;
1048
+ args.restart = restart;
1049
+ args.recommendation = *pAction;
1050
1051
results.cbSize = sizeof(results);
1052
+ results.action = *pAction;
1053
1054
hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, &args, &results);
1055
ExitOnFailure(hr, "BA OnCommitMsiTransactionComplete failed.");
1056
1057
+ *pAction = results.action;
1058
+
1059
LExit:
1060
return hr;
1061
}
@@ -1908,7 +1915,7 @@ EXTERN_C BAAPI UserExperienceOnPauseAUBegin(
1915
args.cbSize = sizeof(args);
1916
1917
results.cbSize = sizeof(results);
1911
-
1918
+
1919
hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, &args, &results);
1920
ExitOnFailure(hr, "BA OnPauseAUBegin failed.");
1921
@@ -2523,7 +2530,7 @@ EXTERN_C BAAPI UserExperienceOnRollbackMsiTransactionBegin(
2530
args.wzTransactionId = wzTransactionId;
2531
2532
results.cbSize = sizeof(results);
2526
-
2533
+
2534
hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, &args, &results);
2535
ExitOnFailure(hr, "BA OnRollbackMsiTransactionBegin failed.");
2536
@@ -2534,7 +2541,9 @@ LExit:
2541
EXTERN_C BAAPI UserExperienceOnRollbackMsiTransactionComplete(
2542
__in BURN_USER_EXPERIENCE* pUserExperience,
2543
__in LPCWSTR wzTransactionId,
2537
- __in HRESULT hrStatus
2544
+ __in HRESULT hrStatus,
2545
+ __in BOOTSTRAPPER_APPLY_RESTART restart,
2546
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION *pAction
2547
)
2548
{
2549
HRESULT hr = S_OK;
@@ -2544,12 +2553,17 @@ EXTERN_C BAAPI UserExperienceOnRollbackMsiTransactionComplete(
2553
args.cbSize = sizeof(args);
2554
args.wzTransactionId = wzTransactionId;
2555
args.hrStatus = hrStatus;
2556
+ args.restart = restart;
2557
+ args.recommendation = *pAction;
2558
2559
results.cbSize = sizeof(results);
2560
+ results.action = *pAction;
2561
2562
hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, &args, &results);
2563
ExitOnFailure(hr, "BA OnRollbackMsiTransactionComplete failed.");
2564
2565
+ *pAction = results.action;
2566
+
2567
LExit:
2568
return hr;
2569
}
@@ -2651,7 +2665,7 @@ EXTERN_C BAAPI UserExperienceOnSystemRestorePointBegin(
2665
args.cbSize = sizeof(args);
2666
2667
results.cbSize = sizeof(results);
2654
-
2668
+
2669
hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, &args, &results);
2670
ExitOnFailure(hr, "BA OnSystemRestorePointBegin failed.");
2671
src/burn/engine/userexperience.h
+8
-4
@@ -251,8 +251,10 @@ BAAPI UserExperienceOnCommitMsiTransactionBegin(
251
BAAPI UserExperienceOnCommitMsiTransactionComplete(
252
__in BURN_USER_EXPERIENCE* pUserExperience,
253
__in LPCWSTR wzTransactionId,
254
- __in HRESULT hrStatus
255
- );
254
+ __in HRESULT hrStatus,
255
+ __in BOOTSTRAPPER_APPLY_RESTART restart,
256
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* pAction
257
+);
258
BAAPI UserExperienceOnDetectBegin(
259
__in BURN_USER_EXPERIENCE* pUserExperience,
260
__in BOOL fCached,
@@ -567,8 +569,10 @@ BAAPI UserExperienceOnRollbackMsiTransactionBegin(
569
BAAPI UserExperienceOnRollbackMsiTransactionComplete(
570
__in BURN_USER_EXPERIENCE* pUserExperience,
571
__in LPCWSTR wzTransactionId,
570
- __in HRESULT hrStatus
571
- );
572
+ __in HRESULT hrStatus,
573
+ __in BOOTSTRAPPER_APPLY_RESTART restart,
574
+ __inout BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION* pAction
575
+);
576
BAAPI UserExperienceOnSetUpdateBegin(
577
__in BURN_USER_EXPERIENCE* pUserExperience
578
);
src/libs/dutil/WixToolset.DUtil/inc/wiutil.h
+2
-1
@@ -392,7 +392,8 @@ HRESULT DAPI WiuBeginTransaction(
392
HRESULT DAPI WiuEndTransaction(
393
__in DWORD dwTransactionState,
394
__in DWORD dwLogMode,
395
- __in_z LPCWSTR szLogPath
395
+ __in_z LPCWSTR szLogPath,
396
+ __out WIU_RESTART *pRestart
397
);
398
BOOL DAPI WiuIsMsiTransactionSupported(
399
);
src/libs/dutil/WixToolset.DUtil/wiutil.cpp
+5
-3
@@ -317,7 +317,7 @@ extern "C" HRESULT DAPI WiuGetComponentPath(
317
}
318
319
// If the actual path length is greater than or equal to the original buffer
320
- // allocate a larger buffer and get the path again, just in case we are
320
+ // allocate a larger buffer and get the path again, just in case we are
321
// missing any part of the path.
322
if (cchCompare <= cch)
323
{
@@ -369,7 +369,7 @@ extern "C" HRESULT DAPI WiuLocateComponent(
369
}
370
371
// If the actual path length is greater than or equal to the original buffer
372
- // allocate a larger buffer and get the path again, just in case we are
372
+ // allocate a larger buffer and get the path again, just in case we are
373
// missing any part of the path.
374
if (cchCompare <= cch)
375
{
@@ -993,7 +993,8 @@ LExit:
993
extern "C" HRESULT DAPI WiuEndTransaction(
994
__in DWORD dwTransactionState,
995
__in DWORD dwLogMode,
996
- __in_z LPCWSTR szLogPath
996
+ __in_z LPCWSTR szLogPath,
997
+ __out WIU_RESTART *pRestart
998
)
999
{
1000
HRESULT hr = S_OK;
@@ -1008,6 +1009,7 @@ extern "C" HRESULT DAPI WiuEndTransaction(
1009
WiuExitOnFailure(hr, "Failed to enable logging for MSI transaction");
1010
1011
er = vpfnMsiEndTransaction(dwTransactionState);
1012
+ er = CheckForRestartErrorCode(er, pRestart);
1013
WiuExitOnWin32Error(er, hr, "Failed to end transaction.");
1014
1015
LExit: