Module: check_mk
Branch: master
Commit: 8649ba5b9b0429f00a187d5067d89c1db2836564
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8649ba5b9b0429…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Sep 22 11:49:54 2017 +0200
Fix Windows Agent crash with vista_api = yes
The crash was caused by refactoring the dynamically loaded functions
in EvtFunctionMap, done in commit
d0e60a30a20ed75349ea192a6200fc0c7501dc1a. The original reason for the
problematic change was to try to avoid Windows headers in unit tess.
Now that we can use Windows headers in tests through Wine, the
problematic change with dynamically loaded functions in EvtFunctionMap
can be simply reverted.
Change-Id: I4348886989c4f704a5c26c562da7b8b55db9d22b
---
agents/windows/EventLogVista.cc | 57 +++++++++--------------
agents/windows/EventLogVista.h | 38 ++++++---------
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 1565696 -> 1565696 bytes
agents/windows/check_mk_agent-64.unstripped.exe | Bin 22787160 -> 22787160 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 1565696 -> 1565696 bytes
agents/windows/check_mk_agent.exe | Bin 1548800 -> 1548800 bytes
agents/windows/check_mk_agent.msi | Bin 3388416 -> 3388416 bytes
agents/windows/check_mk_agent.unstripped.exe | Bin 19628063 -> 19627551 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 1548800 -> 1548800 bytes
agents/windows/crash.exe | Bin 358864 -> 358864 bytes
agents/windows/install_agent-64.exe | Bin 681533 -> 681464 bytes
agents/windows/install_agent.exe | Bin 676613 -> 676446 bytes
agents/windows/nowin.exe | Bin 361000 -> 361000 bytes
agents/windows/plugins/mk_jolokia.exe | Bin 10106814 -> 10106814 bytes
15 files changed, 36 insertions(+), 61 deletions(-)
diff --git a/agents/windows/EventLogVista.cc b/agents/windows/EventLogVista.cc
index 9b1edbd..2a84699 100644
--- a/agents/windows/EventLogVista.cc
+++ b/agents/windows/EventLogVista.cc
@@ -241,44 +241,29 @@ EventApiModule::~EventApiModule() {
}
}
-#define getFunc(winapi, hModule, funcType, funcName) \
- hModule ? (funcType)(winapi.GetProcAddress(hModule, funcName)) : nullptr
+#define GET_FUNC(func) \
+ ((decltype(&func))winapi.GetProcAddress(_mod->get_module(), #func))
EvtFunctionMap::EvtFunctionMap(const WinApiAdaptor &winapi)
- : _mod(std::make_unique<EventApiModule>(winapi))
- , openLog(getFunc(winapi, _mod->get_module(), decltype(openLog),
- static_cast<LPCSTR>("EvtOpenLog")))
- , query(getFunc(winapi, _mod->get_module(), decltype(query),
- static_cast<LPCSTR>("EvtQuery")))
- , close(getFunc(winapi, _mod->get_module(), decltype(close),
- static_cast<LPCSTR>("EvtClose")))
- , seek(getFunc(winapi, _mod->get_module(), decltype(seek),
- static_cast<LPCSTR>("EvtSeek")))
- , next(getFunc(winapi, _mod->get_module(), decltype(next),
- static_cast<LPCSTR>("EvtNext")))
- , createBookmark(getFunc(winapi, _mod->get_module(),
- decltype(createBookmark),
- static_cast<LPCSTR>("EvtCreateBookmark")))
- , updateBookmark(getFunc(winapi, _mod->get_module(),
- decltype(updateBookmark),
- static_cast<LPCSTR>("EvtUpdateBookmark")))
- , createRenderContext(
- getFunc(winapi, _mod->get_module(), decltype(createRenderContext),
- static_cast<LPCSTR>("EvtCreateRenderContext")))
- , render(getFunc(winapi, _mod->get_module(), decltype(render),
- static_cast<LPCSTR>("EvtRender")))
- , subscribe(getFunc(winapi, _mod->get_module(), decltype(subscribe),
- static_cast<LPCSTR>("EvtSubscribe")))
- , formatMessage(getFunc(winapi, _mod->get_module(), decltype(formatMessage),
- static_cast<LPCSTR>("EvtFormatMessage")))
- , getEventMetadataProperty(getFunc(
- winapi, _mod->get_module(), decltype(getEventMetadataProperty),
- static_cast<LPCSTR>("EvtGetEventMetadataProperty")))
- , openPublisherMetadata(
- getFunc(winapi, _mod->get_module(), decltype(openPublisherMetadata),
- static_cast<LPCSTR>("EvtOpenPublisherMetadata")))
- , getLogInfo(getFunc(winapi, _mod->get_module(), decltype(getLogInfo),
- static_cast<LPCSTR>("EvtGetLogInfo"))) {}
+ : _mod(std::make_unique<EventApiModule>(winapi)) {
+ if (_mod->get_module() == nullptr) {
+ return;
+ }
+ this->openLog = GET_FUNC(EvtOpenLog);
+ this->query = GET_FUNC(EvtQuery);
+ this->close = GET_FUNC(EvtClose);
+ this->seek = GET_FUNC(EvtSeek);
+ this->next = GET_FUNC(EvtNext);
+ this->createBookmark = GET_FUNC(EvtCreateBookmark);
+ this->updateBookmark = GET_FUNC(EvtUpdateBookmark);
+ this->createRenderContext = GET_FUNC(EvtCreateRenderContext);
+ this->render = GET_FUNC(EvtRender);
+ this->subscribe = GET_FUNC(EvtSubscribe);
+ this->formatMessage = GET_FUNC(EvtFormatMessage);
+ this->getEventMetadataProperty = GET_FUNC(EvtGetEventMetadataProperty);
+ this->openPublisherMetadata = GET_FUNC(EvtOpenPublisherMetadata);
+ this->getLogInfo = GET_FUNC(EvtGetLogInfo);
+}
EventLogVista::EventLogVista(const std::wstring &path,
const WinApiAdaptor &winapi)
diff --git a/agents/windows/EventLogVista.h b/agents/windows/EventLogVista.h
index 5315ee6..60cf67c 100644
--- a/agents/windows/EventLogVista.h
+++ b/agents/windows/EventLogVista.h
@@ -63,30 +63,20 @@ struct EvtFunctionMap {
explicit EvtFunctionMap(const WinApiAdaptor &winapi);
std::unique_ptr<EventApiModule> _mod;
- const EVT_HANDLE (*openLog)(EVT_HANDLE, LPCWSTR, DWORD);
- const EVT_HANDLE (*query)(EVT_HANDLE, LPCWSTR, LPCWSTR, DWORD);
- const WINBOOL (*close)(EVT_HANDLE);
- const WINBOOL (*seek)(EVT_HANDLE, LONGLONG, EVT_HANDLE, DWORD, DWORD);
- const WINBOOL (*next)(EVT_HANDLE, DWORD, EVT_HANDLE *, DWORD, DWORD,
- PDWORD);
- const EVT_HANDLE (*createBookmark)(LPCWSTR);
- const WINBOOL (*updateBookmark)(EVT_HANDLE, EVT_HANDLE);
- const EVT_HANDLE (*createRenderContext)(DWORD, LPCWSTR *, DWORD);
- const WINBOOL (*render)(EVT_HANDLE, EVT_HANDLE, DWORD, DWORD, PVOID, PDWORD,
- PDWORD);
- const EVT_HANDLE (*subscribe)(EVT_HANDLE, HANDLE, LPCWSTR, LPCWSTR,
- EVT_HANDLE, PVOID, EVT_SUBSCRIBE_CALLBACK,
- DWORD);
- const WINBOOL (*formatMessage)(EVT_HANDLE, EVT_HANDLE, DWORD, DWORD,
- PEVT_VARIANT, DWORD, DWORD, LPWSTR, PDWORD);
- const WINBOOL (*getEventMetadataProperty)(EVT_HANDLE,
- EVT_EVENT_METADATA_PROPERTY_ID,
- DWORD, DWORD, PEVT_VARIANT,
- PDWORD);
- const EVT_HANDLE (*openPublisherMetadata)(EVT_HANDLE, LPCWSTR, LPCWSTR,
- LCID, DWORD);
- const WINBOOL (*getLogInfo)(EVT_HANDLE, EVT_LOG_PROPERTY_ID, DWORD,
- PEVT_VARIANT, PDWORD);
+ decltype(&EvtOpenLog) openLog;
+ decltype(&EvtQuery) query;
+ decltype(&EvtClose) close;
+ decltype(&EvtSeek) seek;
+ decltype(&EvtNext) next;
+ decltype(&EvtCreateBookmark) createBookmark;
+ decltype(&EvtUpdateBookmark) updateBookmark;
+ decltype(&EvtCreateRenderContext) createRenderContext;
+ decltype(&EvtRender) render;
+ decltype(&EvtSubscribe) subscribe;
+ decltype(&EvtFormatMessage) formatMessage;
+ decltype(&EvtGetEventMetadataProperty) getEventMetadataProperty;
+ decltype(&EvtOpenPublisherMetadata) openPublisherMetadata;
+ decltype(&EvtGetLogInfo) getLogInfo;
};
class ManagedEventHandle {
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 537c182..9b0efd1 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-2926
+2928
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index 294a317..a292297 100755
Binary files a/agents/windows/check_mk_agent-64.exe and
b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unstripped.exe
b/agents/windows/check_mk_agent-64.unstripped.exe
index 82daaa7..dd1dc1b 100755
Binary files a/agents/windows/check_mk_agent-64.unstripped.exe and
b/agents/windows/check_mk_agent-64.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index a237b3d..5cf4442 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and
b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 28303d3..822aae6 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/check_mk_agent.msi b/agents/windows/check_mk_agent.msi
index 2b6b73f..2093c92 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi
differ
diff --git a/agents/windows/check_mk_agent.unstripped.exe
b/agents/windows/check_mk_agent.unstripped.exe
index 0f1363e..a1f58a0 100755
Binary files a/agents/windows/check_mk_agent.unstripped.exe and
b/agents/windows/check_mk_agent.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 4b506e4..c8698a4 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and
b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/crash.exe b/agents/windows/crash.exe
index b3f50eb..6069703 100755
Binary files a/agents/windows/crash.exe and b/agents/windows/crash.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index c9253e4..f2fa75d 100755
Binary files a/agents/windows/install_agent-64.exe and
b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 1f3dfc7..835a251 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ
diff --git a/agents/windows/nowin.exe b/agents/windows/nowin.exe
index f7ac67e..de789ac 100755
Binary files a/agents/windows/nowin.exe and b/agents/windows/nowin.exe differ
diff --git a/agents/windows/plugins/mk_jolokia.exe
b/agents/windows/plugins/mk_jolokia.exe
index c8f7106..1245e08 100755
Binary files a/agents/windows/plugins/mk_jolokia.exe and
b/agents/windows/plugins/mk_jolokia.exe differ