TdhGetEventMapInformation helper added
This commit is contained in:
parent
0507e4c5e8
commit
08bacb9e65
@ -31,6 +31,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
inline ULONG TdhGetEventInformation(_In_ PEVENT_RECORD pEvent, _In_ ULONG TdhContextCount, _In_ PTDH_CONTEXT pTdhContext, _Out_ std::unique_ptr<TRACE_EVENT_INFO> &info);
|
inline ULONG TdhGetEventInformation(_In_ PEVENT_RECORD pEvent, _In_ ULONG TdhContextCount, _In_ PTDH_CONTEXT pTdhContext, _Out_ std::unique_ptr<TRACE_EVENT_INFO> &info);
|
||||||
|
inline ULONG TdhGetEventMapInformation(_In_ PEVENT_RECORD pEvent, _In_ LPWSTR pMapName, _Out_ std::unique_ptr<EVENT_MAP_INFO> &info);
|
||||||
|
|
||||||
namespace winstd
|
namespace winstd
|
||||||
{
|
{
|
||||||
@ -74,6 +75,33 @@ inline ULONG TdhGetEventInformation(_In_ PEVENT_RECORD pEvent, _In_ ULONG TdhCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Retrieves information about the event map contained in the event.
|
||||||
|
///
|
||||||
|
/// \sa [TdhGetEventMapInformation function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa964841.aspx)
|
||||||
|
///
|
||||||
|
inline ULONG TdhGetEventMapInformation(_In_ PEVENT_RECORD pEvent, _In_ LPWSTR pMapName, _Out_ std::unique_ptr<EVENT_MAP_INFO> &info)
|
||||||
|
{
|
||||||
|
BYTE szBuffer[WINSTD_STACK_BUFFER_BYTES];
|
||||||
|
ULONG ulSize = sizeof(szBuffer), ulResult;
|
||||||
|
|
||||||
|
// Try with stack buffer first.
|
||||||
|
ulResult = TdhGetEventMapInformation(pEvent, pMapName, (PEVENT_MAP_INFO)szBuffer, &ulSize);
|
||||||
|
if (ulResult == ERROR_SUCCESS) {
|
||||||
|
// Copy from stack.
|
||||||
|
info.reset((PEVENT_MAP_INFO)new char[ulSize]);
|
||||||
|
memcpy(info.get(), szBuffer, ulSize);
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
} else if (ulResult == ERROR_INSUFFICIENT_BUFFER) {
|
||||||
|
// Create buffer on heap and retry.
|
||||||
|
info.reset((PEVENT_MAP_INFO)new char[ulSize]);
|
||||||
|
return TdhGetEventMapInformation(pEvent, pMapName, info.get(), &ulSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ulResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace winstd
|
namespace winstd
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user