diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/wcautil/inc/wcautil.h | 21 | ||||
| -rw-r--r-- | src/wcautil/packages.config | 2 | ||||
| -rw-r--r-- | src/wcautil/wcalog.cpp | 24 | ||||
| -rw-r--r-- | src/wcautil/wcautil.cpp | 27 | ||||
| -rw-r--r-- | src/wcautil/wcautil.vcxproj | 4 |
5 files changed, 68 insertions, 10 deletions
diff --git a/src/wcautil/inc/wcautil.h b/src/wcautil/inc/wcautil.h index 8139a7ca..982173f4 100644 --- a/src/wcautil/inc/wcautil.h +++ b/src/wcautil/inc/wcautil.h | |||
| @@ -6,14 +6,22 @@ | |||
| 6 | extern "C" { | 6 | extern "C" { |
| 7 | #endif | 7 | #endif |
| 8 | 8 | ||
| 9 | #include "dutilsources.h" | ||
| 10 | |||
| 9 | #define WIXAPI __stdcall | 11 | #define WIXAPI __stdcall |
| 10 | #define ExitTrace WcaLogError | 12 | #ifndef DUTIL_SOURCE_DEFAULT |
| 13 | #define DUTIL_SOURCE_DEFAULT DUTIL_SOURCE_EXTERNAL | ||
| 14 | #endif | ||
| 11 | 15 | ||
| 12 | #include "dutil.h" | 16 | #include "dutil.h" |
| 13 | 17 | ||
| 14 | #define MessageExitOnLastError(x, e, s, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ExitTrace(x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, MB_OK, -1, __VA_ARGS__); goto LExit; } } | 18 | #define MessageExitOnLastErrorSource(d, x, e, s, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ExitTraceSource(d, x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, MB_OK, -1, __VA_ARGS__); goto LExit; } } |
| 15 | #define MessageExitOnFailure(x, e, s, ...) if (FAILED(x)) { ExitTrace(x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, INSTALLMESSAGE_ERROR | MB_OK, -1, __VA_ARGS__); goto LExit; } | 19 | #define MessageExitOnFailureSource(d, x, e, s, ...) if (FAILED(x)) { ExitTraceSource(d, x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, INSTALLMESSAGE_ERROR | MB_OK, -1, __VA_ARGS__); goto LExit; } |
| 16 | #define MessageExitOnNullWithLastError(p, x, e, s, ...) if (NULL == p) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (!FAILED(x)) { x = E_FAIL; } ExitTrace(x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, MB_OK, -1, __VA_ARGS__); goto LExit; } | 20 | #define MessageExitOnNullWithLastErrorSource(d, p, x, e, s, ...) if (NULL == p) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (!FAILED(x)) { x = E_FAIL; } ExitTraceSource(d, x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, MB_OK, -1, __VA_ARGS__); goto LExit; } |
| 21 | |||
| 22 | #define MessageExitOnLastError(x, e, s, ...) MessageExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, e, s, __VA_ARGS__) | ||
| 23 | #define MessageExitOnFailure(x, e, s, ...) MessageExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, e, s, __VA_ARGS__) | ||
| 24 | #define MessageExitOnNullWithLastError(p, x, e, s, ...) MessageExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, e, s, __VA_ARGS__) | ||
| 17 | 25 | ||
| 18 | // Generic action enum. | 26 | // Generic action enum. |
| 19 | typedef enum WCA_ACTION | 27 | typedef enum WCA_ACTION |
| @@ -101,6 +109,11 @@ void __cdecl WcaLogError( | |||
| 101 | __in LPCSTR szMessage, | 109 | __in LPCSTR szMessage, |
| 102 | ... | 110 | ... |
| 103 | ); | 111 | ); |
| 112 | void WIXAPI WcaLogErrorArgs( | ||
| 113 | __in HRESULT hr, | ||
| 114 | __in LPCSTR szMessage, | ||
| 115 | __in va_list args | ||
| 116 | ); | ||
| 104 | 117 | ||
| 105 | UINT WIXAPI WcaProcessMessage( | 118 | UINT WIXAPI WcaProcessMessage( |
| 106 | __in INSTALLMESSAGE eMessageType, | 119 | __in INSTALLMESSAGE eMessageType, |
diff --git a/src/wcautil/packages.config b/src/wcautil/packages.config index adda87b9..924b5e93 100644 --- a/src/wcautil/packages.config +++ b/src/wcautil/packages.config | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <packages> | 2 | <packages> |
| 3 | <package id="Nerdbank.GitVersioning" version="2.1.65" developmentDependency="true" targetFramework="net40" /> | 3 | <package id="Nerdbank.GitVersioning" version="2.1.65" developmentDependency="true" targetFramework="net40" /> |
| 4 | <package id="WixToolset.DUtil" version="4.0.28" targetFramework="native" /> | 4 | <package id="WixToolset.DUtil" version="4.0.30" targetFramework="native" /> |
| 5 | </packages> \ No newline at end of file | 5 | </packages> \ No newline at end of file |
diff --git a/src/wcautil/wcalog.cpp b/src/wcautil/wcalog.cpp index fa969bff..faa7f8fd 100644 --- a/src/wcautil/wcalog.cpp +++ b/src/wcautil/wcalog.cpp | |||
| @@ -228,7 +228,7 @@ extern "C" BOOL WIXAPI WcaDisplayAssert( | |||
| 228 | 228 | ||
| 229 | 229 | ||
| 230 | /******************************************************************** | 230 | /******************************************************************** |
| 231 | WcaLogError() - called before ExitOnXXX() macro exists the function | 231 | WcaLogError() - called before ExitOnXXX() macro exits the function |
| 232 | 232 | ||
| 233 | NOTE: writes the hresult and error string to the MSI log | 233 | NOTE: writes the hresult and error string to the MSI log |
| 234 | ********************************************************************/ | 234 | ********************************************************************/ |
| @@ -238,14 +238,32 @@ extern "C" void WcaLogError( | |||
| 238 | ... | 238 | ... |
| 239 | ) | 239 | ) |
| 240 | { | 240 | { |
| 241 | char szBuffer[LOG_BUFFER]; | ||
| 242 | va_list dots; | 241 | va_list dots; |
| 243 | 242 | ||
| 244 | va_start(dots, szMessage); | 243 | va_start(dots, szMessage); |
| 245 | StringCchVPrintfA(szBuffer, countof(szBuffer), szMessage, dots); | 244 | WcaLogErrorArgs(hr, szMessage, dots); |
| 246 | va_end(dots); | 245 | va_end(dots); |
| 246 | } | ||
| 247 | |||
| 248 | |||
| 249 | /******************************************************************** | ||
| 250 | WcaLogErrorArgs() - called before ExitOnXXX() macro exits the function | ||
| 251 | |||
| 252 | NOTE: writes the hresult and error string to the MSI log | ||
| 253 | ********************************************************************/ | ||
| 254 | extern "C" void WcaLogErrorArgs( | ||
| 255 | __in HRESULT hr, | ||
| 256 | __in LPCSTR szMessage, | ||
| 257 | __in va_list args | ||
| 258 | ) | ||
| 259 | { | ||
| 260 | char szBuffer[LOG_BUFFER]; | ||
| 261 | |||
| 262 | StringCchVPrintfA(szBuffer, countof(szBuffer), szMessage, args); | ||
| 247 | 263 | ||
| 248 | // log the message if using Wca common layer | 264 | // log the message if using Wca common layer |
| 249 | if (WcaIsInitialized()) | 265 | if (WcaIsInitialized()) |
| 266 | { | ||
| 250 | WcaLog(LOGMSG_STANDARD, "Error 0x%x: %s", hr, szBuffer); | 267 | WcaLog(LOGMSG_STANDARD, "Error 0x%x: %s", hr, szBuffer); |
| 268 | } | ||
| 251 | } | 269 | } |
diff --git a/src/wcautil/wcautil.cpp b/src/wcautil/wcautil.cpp index ce5ef151..11867d10 100644 --- a/src/wcautil/wcautil.cpp +++ b/src/wcautil/wcautil.cpp | |||
| @@ -12,6 +12,15 @@ static MSIHANDLE s_hDatabase; | |||
| 12 | static char s_szCustomActionLogName[32]; | 12 | static char s_szCustomActionLogName[32]; |
| 13 | static UINT s_iRetVal; | 13 | static UINT s_iRetVal; |
| 14 | 14 | ||
| 15 | static void CALLBACK WcaTraceError( | ||
| 16 | __in_z LPCSTR szFile, | ||
| 17 | __in int iLine, | ||
| 18 | __in REPORT_LEVEL rl, | ||
| 19 | __in UINT source, | ||
| 20 | __in HRESULT hrError, | ||
| 21 | __in_z __format_string LPCSTR szFormat, | ||
| 22 | __in va_list args | ||
| 23 | ); | ||
| 15 | 24 | ||
| 16 | /******************************************************************** | 25 | /******************************************************************** |
| 17 | WcaGlobalInitialize() - initializes the Wca library, should be | 26 | WcaGlobalInitialize() - initializes the Wca library, should be |
| @@ -24,6 +33,7 @@ extern "C" void WIXAPI WcaGlobalInitialize( | |||
| 24 | ) | 33 | ) |
| 25 | { | 34 | { |
| 26 | g_hInstCADLL = hInst; | 35 | g_hInstCADLL = hInst; |
| 36 | DutilInitialize(&WcaTraceError); | ||
| 27 | MemInitialize(); | 37 | MemInitialize(); |
| 28 | 38 | ||
| 29 | AssertSetModule(g_hInstCADLL); | 39 | AssertSetModule(g_hInstCADLL); |
| @@ -49,6 +59,7 @@ extern "C" void WIXAPI WcaGlobalFinalize() | |||
| 49 | } | 59 | } |
| 50 | #endif | 60 | #endif |
| 51 | MemUninitialize(); | 61 | MemUninitialize(); |
| 62 | DutilUninitialize(); | ||
| 52 | g_hInstCADLL = NULL; | 63 | g_hInstCADLL = NULL; |
| 53 | } | 64 | } |
| 54 | 65 | ||
| @@ -214,3 +225,19 @@ extern "C" BOOL WIXAPI WcaCancelDetected() | |||
| 214 | { | 225 | { |
| 215 | return ERROR_INSTALL_USEREXIT == s_iRetVal; | 226 | return ERROR_INSTALL_USEREXIT == s_iRetVal; |
| 216 | } | 227 | } |
| 228 | |||
| 229 | static void CALLBACK WcaTraceError( | ||
| 230 | __in_z LPCSTR /*szFile*/, | ||
| 231 | __in int /*iLine*/, | ||
| 232 | __in REPORT_LEVEL /*rl*/, | ||
| 233 | __in UINT source, | ||
| 234 | __in HRESULT hrError, | ||
| 235 | __in_z __format_string LPCSTR szFormat, | ||
| 236 | __in va_list args | ||
| 237 | ) | ||
| 238 | { | ||
| 239 | if (DUTIL_SOURCE_DEFAULT == source) | ||
| 240 | { | ||
| 241 | WcaLogErrorArgs(hrError, szFormat, args); | ||
| 242 | } | ||
| 243 | } | ||
diff --git a/src/wcautil/wcautil.vcxproj b/src/wcautil/wcautil.vcxproj index 9d1dd28a..2c4f9062 100644 --- a/src/wcautil/wcautil.vcxproj +++ b/src/wcautil/wcautil.vcxproj | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | 2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> |
| 3 | <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | 3 | <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 4 | <Import Project="..\..\packages\WixToolset.DUtil.4.0.28\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.28\build\WixToolset.DUtil.props')" /> | 4 | <Import Project="..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props')" /> |
| 5 | <ItemGroup Label="ProjectConfigurations"> | 5 | <ItemGroup Label="ProjectConfigurations"> |
| 6 | <ProjectConfiguration Include="Debug|ARM"> | 6 | <ProjectConfiguration Include="Debug|ARM"> |
| 7 | <Configuration>Debug</Configuration> | 7 | <Configuration>Debug</Configuration> |
| @@ -97,6 +97,6 @@ | |||
| 97 | <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | 97 | <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
| 98 | </PropertyGroup> | 98 | </PropertyGroup> |
| 99 | <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" /> | 99 | <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" /> |
| 100 | <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.28\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.28\build\WixToolset.DUtil.props'))" /> | 100 | <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props'))" /> |
| 101 | </Target> | 101 | </Target> |
| 102 | </Project> \ No newline at end of file | 102 | </Project> \ No newline at end of file |
