diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-24 12:26:02 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-27 11:14:21 -0500 |
commit | 4f41db7eaa48b0e061a68fd5fc70ce6d127d9039 (patch) | |
tree | 4f15f65a79f2482b6948c69eb6673b0bf230530c | |
parent | 00c2987aabe6a003b1345ebe1ff3a4bd58d8222e (diff) | |
download | wix-4f41db7eaa48b0e061a68fd5fc70ce6d127d9039.tar.gz wix-4f41db7eaa48b0e061a68fd5fc70ce6d127d9039.tar.bz2 wix-4f41db7eaa48b0e061a68fd5fc70ce6d127d9039.zip |
Burn can only log errors while logutil is initialized and not closed.
-rw-r--r-- | src/burn/engine/engine.cpp | 41 | ||||
-rw-r--r-- | src/burn/stub/stub.cpp | 43 |
2 files changed, 41 insertions, 43 deletions
diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp index aca43438..7fca1141 100644 --- a/src/burn/engine/engine.cpp +++ b/src/burn/engine/engine.cpp | |||
@@ -50,6 +50,15 @@ static HRESULT DAPI RedirectLoggingOverPipe( | |||
50 | __in_opt LPVOID pvContext | 50 | __in_opt LPVOID pvContext |
51 | ); | 51 | ); |
52 | static HRESULT Restart(); | 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 | ); | ||
53 | 62 | ||
54 | 63 | ||
55 | // function definitions | 64 | // function definitions |
@@ -105,6 +114,7 @@ extern "C" HRESULT EngineRun( | |||
105 | 114 | ||
106 | // Always initialize logging first | 115 | // Always initialize logging first |
107 | LogInitialize(::GetModuleHandleW(NULL)); | 116 | LogInitialize(::GetModuleHandleW(NULL)); |
117 | DutilInitialize(&BurnTraceError); | ||
108 | fLogInitialized = TRUE; | 118 | fLogInitialized = TRUE; |
109 | 119 | ||
110 | // Ensure that log contains approriate level of information | 120 | // Ensure that log contains approriate level of information |
@@ -313,6 +323,7 @@ LExit: | |||
313 | 323 | ||
314 | if (fLogInitialized) | 324 | if (fLogInitialized) |
315 | { | 325 | { |
326 | DutilUninitialize(); | ||
316 | LogClose(FALSE); | 327 | LogClose(FALSE); |
317 | } | 328 | } |
318 | 329 | ||
@@ -969,3 +980,33 @@ LExit: | |||
969 | ReleaseHandle(hProcessToken); | 980 | ReleaseHandle(hProcessToken); |
970 | return hr; | 981 | return hr; |
971 | } | 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 | } | ||
diff --git a/src/burn/stub/stub.cpp b/src/burn/stub/stub.cpp index 090a8dbb..339a54da 100644 --- a/src/burn/stub/stub.cpp +++ b/src/burn/stub/stub.cpp | |||
@@ -3,16 +3,6 @@ | |||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | 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 | |||
16 | int WINAPI wWinMain( | 6 | int WINAPI wWinMain( |
17 | __in HINSTANCE hInstance, | 7 | __in HINSTANCE hInstance, |
18 | __in_opt HINSTANCE /* hPrevInstance */, | 8 | __in_opt HINSTANCE /* hPrevInstance */, |
@@ -40,8 +30,6 @@ int WINAPI wWinMain( | |||
40 | L"feclient.dll", // unsafely loaded by DecryptFile(). | 30 | L"feclient.dll", // unsafely loaded by DecryptFile(). |
41 | }; | 31 | }; |
42 | 32 | ||
43 | DutilInitialize(&BurnTraceError); | ||
44 | |||
45 | // Best effort attempt to get our file handle as soon as possible. | 33 | // Best effort attempt to get our file handle as soon as possible. |
46 | hr = PathForCurrentProcess(&sczPath, NULL); | 34 | hr = PathForCurrentProcess(&sczPath, NULL); |
47 | if (SUCCEEDED(hr)) | 35 | if (SUCCEEDED(hr)) |
@@ -72,37 +60,6 @@ LExit: | |||
72 | ReleaseFileHandle(hEngineFile); | 60 | ReleaseFileHandle(hEngineFile); |
73 | ReleaseStr(sczPath); | 61 | ReleaseStr(sczPath); |
74 | 62 | ||
75 | DutilUninitialize(); | ||
76 | 63 | ||
77 | return FAILED(hr) ? (int)hr : (int)dwExitCode; | 64 | return FAILED(hr) ? (int)hr : (int)dwExitCode; |
78 | } | 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 | } | ||