aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dutil/inc/conutil.h8
-rw-r--r--src/dutil/inc/strutil.h5
-rw-r--r--src/dutil/inc/wiutil.h7
-rw-r--r--src/dutil/strutil.cpp36
-rw-r--r--src/dutil/wiutil.cpp35
5 files changed, 76 insertions, 15 deletions
diff --git a/src/dutil/inc/conutil.h b/src/dutil/inc/conutil.h
index cfb65332..a098cd4c 100644
--- a/src/dutil/inc/conutil.h
+++ b/src/dutil/inc/conutil.h
@@ -9,12 +9,8 @@ extern "C" {
9#define ConsoleExitOnFailure(x, c, f, ...) if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } 9#define ConsoleExitOnFailure(x, c, f, ...) if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
10#define ConsoleExitOnLastError(x, c, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } } 10#define ConsoleExitOnLastError(x, c, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } }
11#define ConsoleExitOnNull(p, x, e, c, f, ...) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } 11#define ConsoleExitOnNull(p, x, e, c, f, ...) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
12 12#define ConsoleExitOnNullWithLastError(p, x, c, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
13 13#define ConsoleExitWithLastError(x, c, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
14// the following macros need to go away
15#define ConsoleTrace(l, f, ...) { ConsoleWriteLine(CONSOLE_COLOR_NORMAL, f, __VA_ARGS__); Trace(l, f, __VA_ARGS__); }
16#define ConsoleWarning(f, ...) { ConsoleWriteLine(CONSOLE_COLOR_YELLOW, f, __VA_ARGS__); Trace(REPORT_STANDARD, f, __VA_ARGS__); }
17#define ConsoleError(x, f, ...) { ConsoleWriteError(x, CONSOLE_COLOR_RED, f, __VA_ARGS__); TraceError(x, f, __VA_ARGS__); }
18 14
19 15
20// enums 16// enums
diff --git a/src/dutil/inc/strutil.h b/src/dutil/inc/strutil.h
index 1a2ed1d8..c73615aa 100644
--- a/src/dutil/inc/strutil.h
+++ b/src/dutil/inc/strutil.h
@@ -100,6 +100,11 @@ HRESULT __cdecl StrAllocConcatFormatted(
100 __in __format_string LPCWSTR wzFormat, 100 __in __format_string LPCWSTR wzFormat,
101 ... 101 ...
102 ); 102 );
103HRESULT __cdecl StrAllocConcatFormattedSecure(
104 __deref_out_z LPWSTR* ppwz,
105 __in __format_string LPCWSTR wzFormat,
106 ...
107 );
103HRESULT __cdecl StrAllocFormattedSecure( 108HRESULT __cdecl StrAllocFormattedSecure(
104 __deref_out_z LPWSTR* ppwz, 109 __deref_out_z LPWSTR* ppwz,
105 __in __format_string LPCWSTR wzFormat, 110 __in __format_string LPCWSTR wzFormat,
diff --git a/src/dutil/inc/wiutil.h b/src/dutil/inc/wiutil.h
index 4264b815..07f6b56c 100644
--- a/src/dutil/inc/wiutil.h
+++ b/src/dutil/inc/wiutil.h
@@ -330,10 +330,15 @@ HRESULT DAPI WiuEnableLog(
330 __in_z LPCWSTR wzLogFile, 330 __in_z LPCWSTR wzLogFile,
331 __in DWORD dwLogAttributes 331 __in DWORD dwLogAttributes
332 ); 332 );
333HRESULT DAPI WiuInitializeInternalUI(
334 __in INSTALLUILEVEL internalUILevel,
335 __in_opt HWND hwndParent,
336 __in WIU_MSI_EXECUTE_CONTEXT* pExecuteContext
337 );
333HRESULT DAPI WiuInitializeExternalUI( 338HRESULT DAPI WiuInitializeExternalUI(
334 __in PFN_MSIEXECUTEMESSAGEHANDLER pfnMessageHandler, 339 __in PFN_MSIEXECUTEMESSAGEHANDLER pfnMessageHandler,
335 __in INSTALLUILEVEL internalUILevel, 340 __in INSTALLUILEVEL internalUILevel,
336 __in HWND hwndParent, 341 __in_opt HWND hwndParent,
337 __in LPVOID pvContext, 342 __in LPVOID pvContext,
338 __in BOOL fRollback, 343 __in BOOL fRollback,
339 __in WIU_MSI_EXECUTE_CONTEXT* pExecuteContext 344 __in WIU_MSI_EXECUTE_CONTEXT* pExecuteContext
diff --git a/src/dutil/strutil.cpp b/src/dutil/strutil.cpp
index 2e5e2f96..4e184c34 100644
--- a/src/dutil/strutil.cpp
+++ b/src/dutil/strutil.cpp
@@ -920,8 +920,42 @@ LExit:
920 920
921 921
922/******************************************************************** 922/********************************************************************
923StrAllocConcatFormattedSecure - allocates or reuses dynamic string
924memory and adds a formatted string. If the memory needs to be
925reallocated, calls SecureZeroMemory on original block of memory after
926it is moved.
927
928NOTE: caller is responsible for freeing ppwz even if function fails
929********************************************************************/
930extern "C" HRESULT __cdecl StrAllocConcatFormattedSecure(
931 __deref_out_z LPWSTR* ppwz,
932 __in __format_string LPCWSTR wzFormat,
933 ...
934 )
935{
936 Assert(ppwz && wzFormat && *wzFormat);
937
938 HRESULT hr = S_OK;
939 LPWSTR sczFormatted = NULL;
940 va_list args;
941
942 va_start(args, wzFormat);
943 hr = StrAllocFormattedArgsSecure(&sczFormatted, wzFormat, args);
944 va_end(args);
945 ExitOnFailure(hr, "Failed to allocate formatted string");
946
947 hr = StrAllocConcatSecure(ppwz, sczFormatted, 0);
948
949LExit:
950 ReleaseStr(sczFormatted);
951
952 return hr;
953}
954
955
956/********************************************************************
923StrAllocFormattedSecure - allocates or reuses dynamic string memory 957StrAllocFormattedSecure - allocates or reuses dynamic string memory
924and formats it. If the memory needs to reallocated, 958and formats it. If the memory needs to be reallocated,
925calls SecureZeroMemory on original block of memory after it is moved. 959calls SecureZeroMemory on original block of memory after it is moved.
926 960
927NOTE: caller is responsible for freeing ppwz even if function fails 961NOTE: caller is responsible for freeing ppwz even if function fails
diff --git a/src/dutil/wiutil.cpp b/src/dutil/wiutil.cpp
index 1a489d54..1b3dd317 100644
--- a/src/dutil/wiutil.cpp
+++ b/src/dutil/wiutil.cpp
@@ -715,10 +715,32 @@ LExit:
715} 715}
716 716
717 717
718extern "C" HRESULT DAPI WiuInitializeInternalUI(
719 __in INSTALLUILEVEL internalUILevel,
720 __in_opt HWND hwndParent,
721 __in WIU_MSI_EXECUTE_CONTEXT* pExecuteContext
722 )
723{
724 HRESULT hr = S_OK;
725
726 memset(pExecuteContext, 0, sizeof(WIU_MSI_EXECUTE_CONTEXT));
727
728 pExecuteContext->previousInstallUILevel = vpfnMsiSetInternalUI(internalUILevel, &hwndParent);
729 pExecuteContext->hwndPreviousParentWindow = hwndParent;
730
731 if (INSTALLUILEVEL_NOCHANGE == pExecuteContext->previousInstallUILevel)
732 {
733 hr = E_INVALIDARG;
734 }
735
736 return hr;
737}
738
739
718extern "C" HRESULT DAPI WiuInitializeExternalUI( 740extern "C" HRESULT DAPI WiuInitializeExternalUI(
719 __in PFN_MSIEXECUTEMESSAGEHANDLER pfnMessageHandler, 741 __in PFN_MSIEXECUTEMESSAGEHANDLER pfnMessageHandler,
720 __in INSTALLUILEVEL internalUILevel, 742 __in INSTALLUILEVEL internalUILevel,
721 __in HWND hwndParent, 743 __in_opt HWND hwndParent,
722 __in LPVOID pvContext, 744 __in LPVOID pvContext,
723 __in BOOL fRollback, 745 __in BOOL fRollback,
724 __in WIU_MSI_EXECUTE_CONTEXT* pExecuteContext 746 __in WIU_MSI_EXECUTE_CONTEXT* pExecuteContext
@@ -730,7 +752,7 @@ extern "C" HRESULT DAPI WiuInitializeExternalUI(
730 DWORD dwMessageFilter = INSTALLLOGMODE_INITIALIZE | INSTALLLOGMODE_TERMINATE | 752 DWORD dwMessageFilter = INSTALLLOGMODE_INITIALIZE | INSTALLLOGMODE_TERMINATE |
731 INSTALLLOGMODE_FATALEXIT | INSTALLLOGMODE_ERROR | INSTALLLOGMODE_WARNING | 753 INSTALLLOGMODE_FATALEXIT | INSTALLLOGMODE_ERROR | INSTALLLOGMODE_WARNING |
732 INSTALLLOGMODE_RESOLVESOURCE | INSTALLLOGMODE_OUTOFDISKSPACE | 754 INSTALLLOGMODE_RESOLVESOURCE | INSTALLLOGMODE_OUTOFDISKSPACE |
733 INSTALLLOGMODE_ACTIONSTART | INSTALLLOGMODE_ACTIONDATA | INSTALLLOGMODE_COMMONDATA| 755 INSTALLLOGMODE_ACTIONSTART | INSTALLLOGMODE_ACTIONDATA | INSTALLLOGMODE_COMMONDATA |
734 INSTALLLOGMODE_PROGRESS | INSTALLLOGMODE_FILESINUSE; 756 INSTALLLOGMODE_PROGRESS | INSTALLLOGMODE_FILESINUSE;
735 757
736 if (MAKEDWORD(0, 4) <= vdwMsiDllMajorMinor) 758 if (MAKEDWORD(0, 4) <= vdwMsiDllMajorMinor)
@@ -738,15 +760,14 @@ extern "C" HRESULT DAPI WiuInitializeExternalUI(
738 dwMessageFilter |= INSTALLLOGMODE_RMFILESINUSE; 760 dwMessageFilter |= INSTALLLOGMODE_RMFILESINUSE;
739 } 761 }
740 762
741 memset(pExecuteContext, 0, sizeof(WIU_MSI_EXECUTE_CONTEXT)); 763 // Wire the internal and external UI handler.
764 hr = WiuInitializeInternalUI(internalUILevel, hwndParent, pExecuteContext);
765 ExitOnFailure(hr, "Failed to set internal UI level and window.");
766
742 pExecuteContext->fRollback = fRollback; 767 pExecuteContext->fRollback = fRollback;
743 pExecuteContext->pfnMessageHandler = pfnMessageHandler; 768 pExecuteContext->pfnMessageHandler = pfnMessageHandler;
744 pExecuteContext->pvContext = pvContext; 769 pExecuteContext->pvContext = pvContext;
745 770
746 // Wire the internal and external UI handler.
747 pExecuteContext->previousInstallUILevel = vpfnMsiSetInternalUI(internalUILevel, &hwndParent);
748 pExecuteContext->hwndPreviousParentWindow = hwndParent;
749
750 // If the external UI record is available (MSI version >= 3.1) use it but fall back to the standard external 771 // If the external UI record is available (MSI version >= 3.1) use it but fall back to the standard external
751 // UI handler if necesary. 772 // UI handler if necesary.
752 if (vpfnMsiSetExternalUIRecord) 773 if (vpfnMsiSetExternalUIRecord)