@joebigelow / wix-1 / commits / 4f41db7e

Burn can only log errors while logutil is initialized and not closed.

Sean Hall committed Jun 24, 2022 at 12:26 UTC 4f41db7eaa48b0e061a68fd5fc70ce6d127d9039
2 files changed +41 -43
src/burn/engine/engine.cpp
+41
@@ -50,6 +50,15 @@ static HRESULT DAPI RedirectLoggingOverPipe(
50 __in_opt LPVOID pvContext
51 );
52 static HRESULT Restart();
53 +static void CALLBACK BurnTraceError(
54 + __in_z LPCSTR szFile,
55 + __in int iLine,
56 + __in REPORT_LEVEL rl,
57 + __in UINT source,
58 + __in HRESULT hrError,
59 + __in_z __format_string LPCSTR szFormat,
60 + __in va_list args
61 + );
62
63
64 // function definitions
@@ -105,6 +114,7 @@ extern "C" HRESULT EngineRun(
114
115 // Always initialize logging first
116 LogInitialize(::GetModuleHandleW(NULL));
117 + DutilInitialize(&BurnTraceError);
118 fLogInitialized = TRUE;
119
120 // Ensure that log contains approriate level of information
@@ -313,6 +323,7 @@ LExit:
323
324 if (fLogInitialized)
325 {
326 + DutilUninitialize();
327 LogClose(FALSE);
328 }
329
@@ -969,3 +980,33 @@ LExit:
980 ReleaseHandle(hProcessToken);
981 return hr;
982 }
983 +
984 +static void CALLBACK BurnTraceError(
985 + __in_z LPCSTR /*szFile*/,
986 + __in int /*iLine*/,
987 + __in REPORT_LEVEL /*rl*/,
988 + __in UINT source,
989 + __in HRESULT hrError,
990 + __in_z __format_string LPCSTR szFormat,
991 + __in va_list args
992 + )
993 +{
994 + BOOL fLog = FALSE;
995 +
996 + switch (source)
997 + {
998 + case DUTIL_SOURCE_DEFAULT:
999 + fLog = TRUE;
1000 + break;
1001 + default:
1002 + fLog = REPORT_VERBOSE < LogGetLevel();
1003 + break;
1004 + }
1005 +
1006 + if (fLog)
1007 + {
1008 + DutilSuppressTraceErrorSource();
1009 + LogErrorStringArgs(hrError, szFormat, args);
1010 + DutilUnsuppressTraceErrorSource();
1011 + }
1012 +}
src/burn/stub/stub.cpp
-43
@@ -3,16 +3,6 @@
3 #include "precomp.h"
4
5
6 -static void CALLBACK BurnTraceError(
7 - __in_z LPCSTR szFile,
8 - __in int iLine,
9 - __in REPORT_LEVEL rl,
10 - __in UINT source,
11 - __in HRESULT hrError,
12 - __in_z __format_string LPCSTR szFormat,
13 - __in va_list args
14 - );
15 -
6 int WINAPI wWinMain(
7 __in HINSTANCE hInstance,
8 __in_opt HINSTANCE /* hPrevInstance */,
@@ -40,8 +30,6 @@ int WINAPI wWinMain(
30 L"feclient.dll", // unsafely loaded by DecryptFile().
31 };
32
43 - DutilInitialize(&BurnTraceError);
44 -
33 // Best effort attempt to get our file handle as soon as possible.
34 hr = PathForCurrentProcess(&sczPath, NULL);
35 if (SUCCEEDED(hr))
@@ -72,37 +60,6 @@ LExit:
60 ReleaseFileHandle(hEngineFile);
61 ReleaseStr(sczPath);
62
75 - DutilUninitialize();
63
64 return FAILED(hr) ? (int)hr : (int)dwExitCode;
65 }
79 -
80 -static void CALLBACK BurnTraceError(
81 - __in_z LPCSTR /*szFile*/,
82 - __in int /*iLine*/,
83 - __in REPORT_LEVEL /*rl*/,
84 - __in UINT source,
85 - __in HRESULT hrError,
86 - __in_z __format_string LPCSTR szFormat,
87 - __in va_list args
88 - )
89 -{
90 - BOOL fLog = FALSE;
91 -
92 - switch (source)
93 - {
94 - case DUTIL_SOURCE_DEFAULT:
95 - fLog = TRUE;
96 - break;
97 - default:
98 - fLog = REPORT_VERBOSE < LogGetLevel();
99 - break;
100 - }
101 -
102 - if (fLog)
103 - {
104 - DutilSuppressTraceErrorSource();
105 - LogErrorStringArgs(hrError, szFormat, args);
106 - DutilUnsuppressTraceErrorSource();
107 - }
108 -}