aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/wiutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/dutil/wiutil.cpp121
1 files changed, 68 insertions, 53 deletions
diff --git a/src/dutil/wiutil.cpp b/src/dutil/wiutil.cpp
index 7336d685..ffbfe85a 100644
--- a/src/dutil/wiutil.cpp
+++ b/src/dutil/wiutil.cpp
@@ -3,6 +3,21 @@
3#include "precomp.h" 3#include "precomp.h"
4 4
5 5
6// Exit macros
7#define WiuExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_WIUTIL, x, s, __VA_ARGS__)
8#define WiuExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_WIUTIL, x, s, __VA_ARGS__)
9#define WiuExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_WIUTIL, x, s, __VA_ARGS__)
10#define WiuExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_WIUTIL, x, s, __VA_ARGS__)
11#define WiuExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_WIUTIL, x, s, __VA_ARGS__)
12#define WiuExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_WIUTIL, x, s, __VA_ARGS__)
13#define WiuExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_WIUTIL, p, x, e, s, __VA_ARGS__)
14#define WiuExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_WIUTIL, p, x, s, __VA_ARGS__)
15#define WiuExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_WIUTIL, p, x, e, s, __VA_ARGS__)
16#define WiuExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_WIUTIL, p, x, s, __VA_ARGS__)
17#define WiuExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_WIUTIL, e, x, s, __VA_ARGS__)
18#define WiuExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_WIUTIL, g, x, s, __VA_ARGS__)
19
20
6// constants 21// constants
7 22
8const DWORD WIU_MSI_PROGRESS_INVALID = 0xFFFFFFFF; 23const DWORD WIU_MSI_PROGRESS_INVALID = 0xFFFFFFFF;
@@ -112,8 +127,8 @@ static DWORD CalculatePhaseProgress(
112 __in DWORD dwWeightPercentage 127 __in DWORD dwWeightPercentage
113 ); 128 );
114void InitializeMessageData( 129void InitializeMessageData(
115 __in MSIHANDLE hRecord, 130 __in_opt MSIHANDLE hRecord,
116 __out LPWSTR** prgsczData, 131 __deref_out_ecount(*pcData) LPWSTR** prgsczData,
117 __out DWORD* pcData 132 __out DWORD* pcData
118 ); 133 );
119void UninitializeMessageData( 134void UninitializeMessageData(
@@ -133,7 +148,7 @@ extern "C" HRESULT DAPI WiuInitialize(
133 LPWSTR sczMsiDllPath = NULL; 148 LPWSTR sczMsiDllPath = NULL;
134 149
135 hr = LoadSystemLibraryWithPath(L"Msi.dll", &vhMsiDll, &sczMsiDllPath); 150 hr = LoadSystemLibraryWithPath(L"Msi.dll", &vhMsiDll, &sczMsiDllPath);
136 ExitOnFailure(hr, "Failed to load Msi.DLL"); 151 WiuExitOnFailure(hr, "Failed to load Msi.DLL");
137 152
138 // Ignore failures 153 // Ignore failures
139 FileVersion(sczMsiDllPath, &vdwMsiDllMajorMinor, &vdwMsiDllBuildRevision); 154 FileVersion(sczMsiDllPath, &vdwMsiDllMajorMinor, &vdwMsiDllBuildRevision);
@@ -275,7 +290,7 @@ extern "C" HRESULT DAPI WiuGetComponentPath(
275 DWORD cchCompare; 290 DWORD cchCompare;
276 291
277 hr = StrAlloc(psczValue, cch); 292 hr = StrAlloc(psczValue, cch);
278 ExitOnFailure(hr, "Failed to allocate string for component path."); 293 WiuExitOnFailure(hr, "Failed to allocate string for component path.");
279 294
280 cchCompare = cch; 295 cchCompare = cch;
281 *pInstallState = vpfnMsiGetComponentPathW(wzProductCode, wzComponentId, *psczValue, &cch); 296 *pInstallState = vpfnMsiGetComponentPathW(wzProductCode, wzComponentId, *psczValue, &cch);
@@ -283,7 +298,7 @@ extern "C" HRESULT DAPI WiuGetComponentPath(
283 { 298 {
284 ++cch; 299 ++cch;
285 hr = StrAlloc(psczValue, cch); 300 hr = StrAlloc(psczValue, cch);
286 ExitOnFailure(hr, "Failed to reallocate string for component path."); 301 WiuExitOnFailure(hr, "Failed to reallocate string for component path.");
287 302
288 cchCompare = cch; 303 cchCompare = cch;
289 *pInstallState = vpfnMsiGetComponentPathW(wzProductCode, wzComponentId, *psczValue, &cch); 304 *pInstallState = vpfnMsiGetComponentPathW(wzProductCode, wzComponentId, *psczValue, &cch);
@@ -292,7 +307,7 @@ extern "C" HRESULT DAPI WiuGetComponentPath(
292 if (INSTALLSTATE_INVALIDARG == *pInstallState) 307 if (INSTALLSTATE_INVALIDARG == *pInstallState)
293 { 308 {
294 hr = E_INVALIDARG; 309 hr = E_INVALIDARG;
295 ExitOnRootFailure(hr, "Invalid argument when getting component path."); 310 WiuExitOnRootFailure(hr, "Invalid argument when getting component path.");
296 } 311 }
297 else if (INSTALLSTATE_UNKNOWN == *pInstallState) 312 else if (INSTALLSTATE_UNKNOWN == *pInstallState)
298 { 313 {
@@ -306,7 +321,7 @@ extern "C" HRESULT DAPI WiuGetComponentPath(
306 { 321 {
307 ++cch; 322 ++cch;
308 hr = StrAlloc(psczValue, cch); 323 hr = StrAlloc(psczValue, cch);
309 ExitOnFailure(hr, "Failed to reallocate string for component path."); 324 WiuExitOnFailure(hr, "Failed to reallocate string for component path.");
310 325
311 *pInstallState = vpfnMsiGetComponentPathW(wzProductCode, wzComponentId, *psczValue, &cch); 326 *pInstallState = vpfnMsiGetComponentPathW(wzProductCode, wzComponentId, *psczValue, &cch);
312 } 327 }
@@ -327,7 +342,7 @@ extern "C" HRESULT DAPI WiuLocateComponent(
327 DWORD cchCompare; 342 DWORD cchCompare;
328 343
329 hr = StrAlloc(psczValue, cch); 344 hr = StrAlloc(psczValue, cch);
330 ExitOnFailure(hr, "Failed to allocate string for component path."); 345 WiuExitOnFailure(hr, "Failed to allocate string for component path.");
331 346
332 cchCompare = cch; 347 cchCompare = cch;
333 *pInstallState = vpfnMsiLocateComponentW(wzComponentId, *psczValue, &cch); 348 *pInstallState = vpfnMsiLocateComponentW(wzComponentId, *psczValue, &cch);
@@ -335,7 +350,7 @@ extern "C" HRESULT DAPI WiuLocateComponent(
335 { 350 {
336 ++cch; 351 ++cch;
337 hr = StrAlloc(psczValue, cch); 352 hr = StrAlloc(psczValue, cch);
338 ExitOnFailure(hr, "Failed to reallocate string for component path."); 353 WiuExitOnFailure(hr, "Failed to reallocate string for component path.");
339 354
340 cchCompare = cch; 355 cchCompare = cch;
341 *pInstallState = vpfnMsiLocateComponentW(wzComponentId, *psczValue, &cch); 356 *pInstallState = vpfnMsiLocateComponentW(wzComponentId, *psczValue, &cch);
@@ -344,7 +359,7 @@ extern "C" HRESULT DAPI WiuLocateComponent(
344 if (INSTALLSTATE_INVALIDARG == *pInstallState) 359 if (INSTALLSTATE_INVALIDARG == *pInstallState)
345 { 360 {
346 hr = E_INVALIDARG; 361 hr = E_INVALIDARG;
347 ExitOnRootFailure(hr, "Invalid argument when locating component."); 362 WiuExitOnRootFailure(hr, "Invalid argument when locating component.");
348 } 363 }
349 else if (INSTALLSTATE_UNKNOWN == *pInstallState) 364 else if (INSTALLSTATE_UNKNOWN == *pInstallState)
350 { 365 {
@@ -358,7 +373,7 @@ extern "C" HRESULT DAPI WiuLocateComponent(
358 { 373 {
359 ++cch; 374 ++cch;
360 hr = StrAlloc(psczValue, cch); 375 hr = StrAlloc(psczValue, cch);
361 ExitOnFailure(hr, "Failed to reallocate string for component path."); 376 WiuExitOnFailure(hr, "Failed to reallocate string for component path.");
362 377
363 *pInstallState = vpfnMsiLocateComponentW(wzComponentId, *psczValue, &cch); 378 *pInstallState = vpfnMsiLocateComponentW(wzComponentId, *psczValue, &cch);
364 } 379 }
@@ -380,7 +395,7 @@ extern "C" HRESULT DAPI WiuQueryFeatureState(
380 if (INSTALLSTATE_INVALIDARG == *pInstallState) 395 if (INSTALLSTATE_INVALIDARG == *pInstallState)
381 { 396 {
382 hr = E_INVALIDARG; 397 hr = E_INVALIDARG;
383 ExitOnRootFailure(hr, "Failed to query state of feature: %ls in product: %ls", wzFeature, wzProduct); 398 WiuExitOnRootFailure(hr, "Failed to query state of feature: %ls in product: %ls", wzFeature, wzProduct);
384 } 399 }
385 400
386LExit: 401LExit:
@@ -399,18 +414,18 @@ extern "C" HRESULT DAPI WiuGetProductInfo(
399 DWORD cch = WIU_GOOD_ENOUGH_PROPERTY_LENGTH; 414 DWORD cch = WIU_GOOD_ENOUGH_PROPERTY_LENGTH;
400 415
401 hr = StrAlloc(psczValue, cch); 416 hr = StrAlloc(psczValue, cch);
402 ExitOnFailure(hr, "Failed to allocate string for product info."); 417 WiuExitOnFailure(hr, "Failed to allocate string for product info.");
403 418
404 er = vpfnMsiGetProductInfoW(wzProductCode, wzProperty, *psczValue, &cch); 419 er = vpfnMsiGetProductInfoW(wzProductCode, wzProperty, *psczValue, &cch);
405 if (ERROR_MORE_DATA == er) 420 if (ERROR_MORE_DATA == er)
406 { 421 {
407 ++cch; 422 ++cch;
408 hr = StrAlloc(psczValue, cch); 423 hr = StrAlloc(psczValue, cch);
409 ExitOnFailure(hr, "Failed to reallocate string for product info."); 424 WiuExitOnFailure(hr, "Failed to reallocate string for product info.");
410 425
411 er = vpfnMsiGetProductInfoW(wzProductCode, wzProperty, *psczValue, &cch); 426 er = vpfnMsiGetProductInfoW(wzProductCode, wzProperty, *psczValue, &cch);
412 } 427 }
413 ExitOnWin32Error(er, hr, "Failed to get product info."); 428 WiuExitOnWin32Error(er, hr, "Failed to get product info.");
414 429
415LExit: 430LExit:
416 return hr; 431 return hr;
@@ -432,24 +447,24 @@ extern "C" HRESULT DAPI WiuGetProductInfoEx(
432 if (!vpfnMsiGetProductInfoExW) 447 if (!vpfnMsiGetProductInfoExW)
433 { 448 {
434 hr = WiuGetProductInfo(wzProductCode, wzProperty, psczValue); 449 hr = WiuGetProductInfo(wzProductCode, wzProperty, psczValue);
435 ExitOnFailure(hr, "Failed to get product info when extended info was not available."); 450 WiuExitOnFailure(hr, "Failed to get product info when extended info was not available.");
436 451
437 ExitFunction(); 452 ExitFunction();
438 } 453 }
439 454
440 hr = StrAlloc(psczValue, cch); 455 hr = StrAlloc(psczValue, cch);
441 ExitOnFailure(hr, "Failed to allocate string for extended product info."); 456 WiuExitOnFailure(hr, "Failed to allocate string for extended product info.");
442 457
443 er = vpfnMsiGetProductInfoExW(wzProductCode, wzUserSid, dwContext, wzProperty, *psczValue, &cch); 458 er = vpfnMsiGetProductInfoExW(wzProductCode, wzUserSid, dwContext, wzProperty, *psczValue, &cch);
444 if (ERROR_MORE_DATA == er) 459 if (ERROR_MORE_DATA == er)
445 { 460 {
446 ++cch; 461 ++cch;
447 hr = StrAlloc(psczValue, cch); 462 hr = StrAlloc(psczValue, cch);
448 ExitOnFailure(hr, "Failed to reallocate string for extended product info."); 463 WiuExitOnFailure(hr, "Failed to reallocate string for extended product info.");
449 464
450 er = vpfnMsiGetProductInfoExW(wzProductCode, wzUserSid, dwContext, wzProperty, *psczValue, &cch); 465 er = vpfnMsiGetProductInfoExW(wzProductCode, wzUserSid, dwContext, wzProperty, *psczValue, &cch);
451 } 466 }
452 ExitOnWin32Error(er, hr, "Failed to get extended product info."); 467 WiuExitOnWin32Error(er, hr, "Failed to get extended product info.");
453 468
454LExit: 469LExit:
455 return hr; 470 return hr;
@@ -467,18 +482,18 @@ extern "C" HRESULT DAPI WiuGetProductProperty(
467 DWORD cch = WIU_GOOD_ENOUGH_PROPERTY_LENGTH; 482 DWORD cch = WIU_GOOD_ENOUGH_PROPERTY_LENGTH;
468 483
469 hr = StrAlloc(psczValue, cch); 484 hr = StrAlloc(psczValue, cch);
470 ExitOnFailure(hr, "Failed to allocate string for product property."); 485 WiuExitOnFailure(hr, "Failed to allocate string for product property.");
471 486
472 er = ::MsiGetProductPropertyW(hProduct, wzProperty, *psczValue, &cch); 487 er = ::MsiGetProductPropertyW(hProduct, wzProperty, *psczValue, &cch);
473 if (ERROR_MORE_DATA == er) 488 if (ERROR_MORE_DATA == er)
474 { 489 {
475 ++cch; 490 ++cch;
476 hr = StrAlloc(psczValue, cch); 491 hr = StrAlloc(psczValue, cch);
477 ExitOnFailure(hr, "Failed to reallocate string for product property."); 492 WiuExitOnFailure(hr, "Failed to reallocate string for product property.");
478 493
479 er = ::MsiGetProductPropertyW(hProduct, wzProperty, *psczValue, &cch); 494 er = ::MsiGetProductPropertyW(hProduct, wzProperty, *psczValue, &cch);
480 } 495 }
481 ExitOnWin32Error(er, hr, "Failed to get product property."); 496 WiuExitOnWin32Error(er, hr, "Failed to get product property.");
482 497
483LExit: 498LExit:
484 return hr; 499 return hr;
@@ -504,18 +519,18 @@ extern "C" HRESULT DAPI WiuGetPatchInfoEx(
504 } 519 }
505 520
506 hr = StrAlloc(psczValue, cch); 521 hr = StrAlloc(psczValue, cch);
507 ExitOnFailure(hr, "Failed to allocate string for extended patch info."); 522 WiuExitOnFailure(hr, "Failed to allocate string for extended patch info.");
508 523
509 er = vpfnMsiGetPatchInfoExW(wzPatchCode, wzProductCode, wzUserSid, dwContext, wzProperty, *psczValue, &cch); 524 er = vpfnMsiGetPatchInfoExW(wzPatchCode, wzProductCode, wzUserSid, dwContext, wzProperty, *psczValue, &cch);
510 if (ERROR_MORE_DATA == er) 525 if (ERROR_MORE_DATA == er)
511 { 526 {
512 ++cch; 527 ++cch;
513 hr = StrAlloc(psczValue, cch); 528 hr = StrAlloc(psczValue, cch);
514 ExitOnFailure(hr, "Failed to reallocate string for extended patch info."); 529 WiuExitOnFailure(hr, "Failed to reallocate string for extended patch info.");
515 530
516 er = vpfnMsiGetPatchInfoExW(wzPatchCode, wzProductCode, wzUserSid, dwContext, wzProperty, *psczValue, &cch); 531 er = vpfnMsiGetPatchInfoExW(wzPatchCode, wzProductCode, wzUserSid, dwContext, wzProperty, *psczValue, &cch);
517 } 532 }
518 ExitOnWin32Error(er, hr, "Failed to get extended patch info."); 533 WiuExitOnWin32Error(er, hr, "Failed to get extended patch info.");
519 534
520LExit: 535LExit:
521 return hr; 536 return hr;
@@ -539,7 +554,7 @@ extern "C" HRESULT DAPI WiuDeterminePatchSequence(
539 } 554 }
540 555
541 er = vpfnMsiDeterminePatchSequenceW(wzProductCode, wzUserSid, context, cPatchInfo, pPatchInfo); 556 er = vpfnMsiDeterminePatchSequenceW(wzProductCode, wzUserSid, context, cPatchInfo, pPatchInfo);
542 ExitOnWin32Error(er, hr, "Failed to determine patch sequence for product code."); 557 WiuExitOnWin32Error(er, hr, "Failed to determine patch sequence for product code.");
543 558
544LExit: 559LExit:
545 return hr; 560 return hr;
@@ -561,7 +576,7 @@ extern "C" HRESULT DAPI WiuDetermineApplicablePatches(
561 } 576 }
562 577
563 er = vpfnMsiDetermineApplicablePatchesW(wzProductPackagePath, cPatchInfo, pPatchInfo); 578 er = vpfnMsiDetermineApplicablePatchesW(wzProductPackagePath, cPatchInfo, pPatchInfo);
564 ExitOnWin32Error(er, hr, "Failed to determine applicable patches for product package."); 579 WiuExitOnWin32Error(er, hr, "Failed to determine applicable patches for product package.");
565 580
566LExit: 581LExit:
567 return hr; 582 return hr;
@@ -581,7 +596,7 @@ extern "C" HRESULT DAPI WiuEnumProducts(
581 { 596 {
582 ExitFunction1(hr = HRESULT_FROM_WIN32(er)); 597 ExitFunction1(hr = HRESULT_FROM_WIN32(er));
583 } 598 }
584 ExitOnWin32Error(er, hr, "Failed to enumerate products."); 599 WiuExitOnWin32Error(er, hr, "Failed to enumerate products.");
585 600
586LExit: 601LExit:
587 return hr; 602 return hr;
@@ -612,7 +627,7 @@ extern "C" HRESULT DAPI WiuEnumProductsEx(
612 { 627 {
613 ExitFunction1(hr = HRESULT_FROM_WIN32(er)); 628 ExitFunction1(hr = HRESULT_FROM_WIN32(er));
614 } 629 }
615 ExitOnWin32Error(er, hr, "Failed to enumerate products."); 630 WiuExitOnWin32Error(er, hr, "Failed to enumerate products.");
616 631
617LExit: 632LExit:
618 return hr; 633 return hr;
@@ -633,7 +648,7 @@ extern "C" HRESULT DAPI WiuEnumRelatedProducts(
633 { 648 {
634 ExitFunction1(hr = HRESULT_FROM_WIN32(er)); 649 ExitFunction1(hr = HRESULT_FROM_WIN32(er));
635 } 650 }
636 ExitOnWin32Error(er, hr, "Failed to enumerate related products for updgrade code: %ls", wzUpgradeCode); 651 WiuExitOnWin32Error(er, hr, "Failed to enumerate related products for updgrade code: %ls", wzUpgradeCode);
637 652
638LExit: 653LExit:
639 return hr; 654 return hr;
@@ -650,7 +665,7 @@ LExit:
650********************************************************************/ 665********************************************************************/
651extern "C" HRESULT DAPI WiuEnumRelatedProductCodes( 666extern "C" HRESULT DAPI WiuEnumRelatedProductCodes(
652 __in_z LPCWSTR wzUpgradeCode, 667 __in_z LPCWSTR wzUpgradeCode,
653 __deref_out_ecount_opt(pcRelatedProducts) LPWSTR** prgsczProductCodes, 668 __deref_out_ecount_opt(*pcRelatedProducts) LPWSTR** prgsczProductCodes,
654 __out DWORD* pcRelatedProducts, 669 __out DWORD* pcRelatedProducts,
655 __in BOOL fReturnHighestVersionOnly 670 __in BOOL fReturnHighestVersionOnly
656 ) 671 )
@@ -673,16 +688,16 @@ extern "C" HRESULT DAPI WiuEnumRelatedProductCodes(
673 hr = S_OK; 688 hr = S_OK;
674 break; 689 break;
675 } 690 }
676 ExitOnFailure(hr, "Failed to enumerate related products for upgrade code: %ls", wzUpgradeCode); 691 WiuExitOnFailure(hr, "Failed to enumerate related products for upgrade code: %ls", wzUpgradeCode);
677 692
678 if (fReturnHighestVersionOnly) 693 if (fReturnHighestVersionOnly)
679 { 694 {
680 // get the version 695 // get the version
681 hr = WiuGetProductInfo(wzCurrentProductCode, L"VersionString", &sczInstalledVersion); 696 hr = WiuGetProductInfo(wzCurrentProductCode, L"VersionString", &sczInstalledVersion);
682 ExitOnFailure(hr, "Failed to get version for product code: %ls", wzCurrentProductCode); 697 WiuExitOnFailure(hr, "Failed to get version for product code: %ls", wzCurrentProductCode);
683 698
684 hr = FileVersionFromStringEx(sczInstalledVersion, 0, &qwCurrentVersion); 699 hr = FileVersionFromStringEx(sczInstalledVersion, 0, &qwCurrentVersion);
685 ExitOnFailure(hr, "Failed to convert version: %ls to DWORD64 for product code: %ls", sczInstalledVersion, wzCurrentProductCode); 700 WiuExitOnFailure(hr, "Failed to convert version: %ls to DWORD64 for product code: %ls", sczInstalledVersion, wzCurrentProductCode);
686 701
687 // if this is the first product found then it is the highest version (for now) 702 // if this is the first product found then it is the highest version (for now)
688 if (0 == *pcRelatedProducts) 703 if (0 == *pcRelatedProducts)
@@ -698,7 +713,7 @@ extern "C" HRESULT DAPI WiuEnumRelatedProductCodes(
698 qwHighestVersion = qwCurrentVersion; 713 qwHighestVersion = qwCurrentVersion;
699 714
700 hr = StrAllocString(prgsczProductCodes[0], wzCurrentProductCode, 0); 715 hr = StrAllocString(prgsczProductCodes[0], wzCurrentProductCode, 0);
701 ExitOnFailure(hr, "Failed to update array with higher versioned product code."); 716 WiuExitOnFailure(hr, "Failed to update array with higher versioned product code.");
702 } 717 }
703 718
704 // continue here as we don't want anything else added to the list 719 // continue here as we don't want anything else added to the list
@@ -707,7 +722,7 @@ extern "C" HRESULT DAPI WiuEnumRelatedProductCodes(
707 } 722 }
708 723
709 hr = StrArrayAllocString(prgsczProductCodes, (LPUINT)(pcRelatedProducts), wzCurrentProductCode, 0); 724 hr = StrArrayAllocString(prgsczProductCodes, (LPUINT)(pcRelatedProducts), wzCurrentProductCode, 0);
710 ExitOnFailure(hr, "Failed to add product code to array."); 725 WiuExitOnFailure(hr, "Failed to add product code to array.");
711 } 726 }
712 727
713LExit: 728LExit:
@@ -726,7 +741,7 @@ extern "C" HRESULT DAPI WiuEnableLog(
726 DWORD er = ERROR_SUCCESS; 741 DWORD er = ERROR_SUCCESS;
727 742
728 er = vpfnMsiEnableLogW(dwLogMode, wzLogFile, dwLogAttributes); 743 er = vpfnMsiEnableLogW(dwLogMode, wzLogFile, dwLogAttributes);
729 ExitOnWin32Error(er, hr, "Failed to enable MSI internal logging."); 744 WiuExitOnWin32Error(er, hr, "Failed to enable MSI internal logging.");
730 745
731LExit: 746LExit:
732 return hr; 747 return hr;
@@ -780,7 +795,7 @@ extern "C" HRESULT DAPI WiuInitializeExternalUI(
780 795
781 // Wire the internal and external UI handler. 796 // Wire the internal and external UI handler.
782 hr = WiuInitializeInternalUI(internalUILevel, hwndParent, pExecuteContext); 797 hr = WiuInitializeInternalUI(internalUILevel, hwndParent, pExecuteContext);
783 ExitOnFailure(hr, "Failed to set internal UI level and window."); 798 WiuExitOnFailure(hr, "Failed to set internal UI level and window.");
784 799
785 pExecuteContext->fRollback = fRollback; 800 pExecuteContext->fRollback = fRollback;
786 pExecuteContext->pfnMessageHandler = pfnMessageHandler; 801 pExecuteContext->pfnMessageHandler = pfnMessageHandler;
@@ -791,7 +806,7 @@ extern "C" HRESULT DAPI WiuInitializeExternalUI(
791 if (vpfnMsiSetExternalUIRecord) 806 if (vpfnMsiSetExternalUIRecord)
792 { 807 {
793 er = vpfnMsiSetExternalUIRecord(InstallEngineRecordCallback, dwMessageFilter, pExecuteContext, &pExecuteContext->pfnPreviousExternalUIRecord); 808 er = vpfnMsiSetExternalUIRecord(InstallEngineRecordCallback, dwMessageFilter, pExecuteContext, &pExecuteContext->pfnPreviousExternalUIRecord);
794 ExitOnWin32Error(er, hr, "Failed to wire up external UI record handler."); 809 WiuExitOnWin32Error(er, hr, "Failed to wire up external UI record handler.");
795 pExecuteContext->fSetPreviousExternalUIRecord = TRUE; 810 pExecuteContext->fSetPreviousExternalUIRecord = TRUE;
796 } 811 }
797 else 812 else
@@ -841,7 +856,7 @@ extern "C" HRESULT DAPI WiuConfigureProductEx(
841 856
842 er = vpfnMsiConfigureProductExW(wzProduct, iInstallLevel, eInstallState, wzCommandLine); 857 er = vpfnMsiConfigureProductExW(wzProduct, iInstallLevel, eInstallState, wzCommandLine);
843 er = CheckForRestartErrorCode(er, pRestart); 858 er = CheckForRestartErrorCode(er, pRestart);
844 ExitOnWin32Error(er, hr, "Failed to configure product: %ls", wzProduct); 859 WiuExitOnWin32Error(er, hr, "Failed to configure product: %ls", wzProduct);
845 860
846LExit: 861LExit:
847 return hr; 862 return hr;
@@ -859,7 +874,7 @@ extern "C" HRESULT DAPI WiuInstallProduct(
859 874
860 er = vpfnMsiInstallProductW(wzPackagePath, wzCommandLine); 875 er = vpfnMsiInstallProductW(wzPackagePath, wzCommandLine);
861 er = CheckForRestartErrorCode(er, pRestart); 876 er = CheckForRestartErrorCode(er, pRestart);
862 ExitOnWin32Error(er, hr, "Failed to install product: %ls", wzPackagePath); 877 WiuExitOnWin32Error(er, hr, "Failed to install product: %ls", wzPackagePath);
863 878
864LExit: 879LExit:
865 return hr; 880 return hr;
@@ -878,7 +893,7 @@ extern "C" HRESULT DAPI WiuRemovePatches(
878 893
879 er = vpfnMsiRemovePatchesW(wzPatchList, wzProductCode, INSTALLTYPE_SINGLE_INSTANCE, wzPropertyList); 894 er = vpfnMsiRemovePatchesW(wzPatchList, wzProductCode, INSTALLTYPE_SINGLE_INSTANCE, wzPropertyList);
880 er = CheckForRestartErrorCode(er, pRestart); 895 er = CheckForRestartErrorCode(er, pRestart);
881 ExitOnWin32Error(er, hr, "Failed to remove patches."); 896 WiuExitOnWin32Error(er, hr, "Failed to remove patches.");
882 897
883LExit: 898LExit:
884 return hr; 899 return hr;
@@ -898,7 +913,7 @@ extern "C" HRESULT DAPI WiuSourceListAddSourceEx(
898 DWORD er = ERROR_SUCCESS; 913 DWORD er = ERROR_SUCCESS;
899 914
900 er = vpfnMsiSourceListAddSourceExW(wzProductCodeOrPatchCode, wzUserSid, dwContext, MSISOURCETYPE_NETWORK | dwCode, wzSource, dwIndex); 915 er = vpfnMsiSourceListAddSourceExW(wzProductCodeOrPatchCode, wzUserSid, dwContext, MSISOURCETYPE_NETWORK | dwCode, wzSource, dwIndex);
901 ExitOnWin32Error(er, hr, "Failed to add source."); 916 WiuExitOnWin32Error(er, hr, "Failed to add source.");
902 917
903LExit: 918LExit:
904 return hr; 919 return hr;
@@ -924,14 +939,14 @@ extern "C" HRESULT DAPI WiuBeginTransaction(
924 939
925 if (!WiuIsMsiTransactionSupported()) 940 if (!WiuIsMsiTransactionSupported())
926 { 941 {
927 ExitOnFailure(hr = E_NOTIMPL, "Msi transactions are not supported"); 942 WiuExitOnFailure(hr = E_NOTIMPL, "Msi transactions are not supported");
928 } 943 }
929 944
930 hr = WiuEnableLog(dwLogMode, szLogPath, INSTALLLOGATTRIBUTES_APPEND); 945 hr = WiuEnableLog(dwLogMode, szLogPath, INSTALLLOGATTRIBUTES_APPEND);
931 ExitOnFailure(hr, "Failed to enable logging for MSI transaction"); 946 WiuExitOnFailure(hr, "Failed to enable logging for MSI transaction");
932 947
933 er = vpfnMsiBeginTransaction(szName, dwTransactionAttributes, phTransactionHandle, phChangeOfOwnerEvent); 948 er = vpfnMsiBeginTransaction(szName, dwTransactionAttributes, phTransactionHandle, phChangeOfOwnerEvent);
934 ExitOnWin32Error(er, hr, "Failed to begin transaction."); 949 WiuExitOnWin32Error(er, hr, "Failed to begin transaction.");
935 950
936LExit: 951LExit:
937 return hr; 952 return hr;
@@ -948,14 +963,14 @@ extern "C" HRESULT DAPI WiuEndTransaction(
948 963
949 if (!WiuIsMsiTransactionSupported()) 964 if (!WiuIsMsiTransactionSupported())
950 { 965 {
951 ExitOnFailure(hr = E_NOTIMPL, "Msi transactions are not supported"); 966 WiuExitOnFailure(hr = E_NOTIMPL, "Msi transactions are not supported");
952 } 967 }
953 968
954 hr = WiuEnableLog(dwLogMode, szLogPath, INSTALLLOGATTRIBUTES_APPEND); 969 hr = WiuEnableLog(dwLogMode, szLogPath, INSTALLLOGATTRIBUTES_APPEND);
955 ExitOnFailure(hr, "Failed to enable logging for MSI transaction"); 970 WiuExitOnFailure(hr, "Failed to enable logging for MSI transaction");
956 971
957 er = vpfnMsiEndTransaction(dwTransactionState); 972 er = vpfnMsiEndTransaction(dwTransactionState);
958 ExitOnWin32Error(er, hr, "Failed to end transaction."); 973 WiuExitOnWin32Error(er, hr, "Failed to end transaction.");
959 974
960LExit: 975LExit:
961 return hr; 976 return hr;
@@ -1048,10 +1063,10 @@ static INT CALLBACK InstallEngineRecordCallback(
1048 { 1063 {
1049 hr = HRESULT_FROM_WIN32(er); 1064 hr = HRESULT_FROM_WIN32(er);
1050 } 1065 }
1051 ExitOnFailure(hr, "Failed to allocate string for formated message."); 1066 WiuExitOnFailure(hr, "Failed to allocate string for formated message.");
1052 1067
1053 er = ::MsiFormatRecordW(NULL, hRecord, sczMessage, &cchMessage); 1068 er = ::MsiFormatRecordW(NULL, hRecord, sczMessage, &cchMessage);
1054 ExitOnWin32Error(er, hr, "Failed to format message record."); 1069 WiuExitOnWin32Error(er, hr, "Failed to format message record.");
1055 1070
1056 // Pass to handler including both the formated message and the original record. 1071 // Pass to handler including both the formated message and the original record.
1057 nResult = HandleInstallMessage(pContext, mt, uiFlags, sczMessage, hRecord); 1072 nResult = HandleInstallMessage(pContext, mt, uiFlags, sczMessage, hRecord);
@@ -1213,7 +1228,7 @@ static INT HandleInstallProgress(
1213 1228
1214 // parse number 1229 // parse number
1215 hr = StrStringToInt32(pwz, cch, &iFields[cFields]); 1230 hr = StrStringToInt32(pwz, cch, &iFields[cFields]);
1216 ExitOnFailure(hr, "Failed to parse MSI message part."); 1231 WiuExitOnFailure(hr, "Failed to parse MSI message part.");
1217 1232
1218 // increment field count 1233 // increment field count
1219 ++cFields; 1234 ++cFields;
@@ -1255,7 +1270,7 @@ static INT HandleInstallProgress(
1255 else 1270 else
1256 { 1271 {
1257 hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); 1272 hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
1258 ExitOnRootFailure(hr, "Insufficient space to hold progress information."); 1273 WiuExitOnRootFailure(hr, "Insufficient space to hold progress information.");
1259 } 1274 }
1260 1275
1261 // we only care about the first stage after script execution has started 1276 // we only care about the first stage after script execution has started