Set ETW provider info so it's always treated as TraceLogging

Signed-off-by: Kevin Parsons <kevpar@ntdev.microsoft.com>
This commit is contained in:
Kevin Parsons
2019-01-17 10:45:50 -08:00
parent 6c8aa416ae
commit 7dba96a333
4 changed files with 38 additions and 3 deletions
+19
View File
@@ -6,6 +6,7 @@ import (
"encoding/binary"
"strings"
"unicode/utf16"
"unsafe"
"golang.org/x/sys/windows"
)
@@ -41,6 +42,15 @@ const (
ProviderStateCaptureState
)
type eventInfoClass uint32
const (
eventInfoClassProviderBinaryTrackInfo eventInfoClass = iota
eventInfoClassProviderSetReserved1
eventInfoClassProviderSetTraits
eventInfoClassProviderUseDescriptorType
)
// EnableCallback is the form of the callback function that receives provider
// enable/disable notifications from ETW.
type EnableCallback func(*windows.GUID, ProviderState, Level, uint64, uint64, uintptr)
@@ -133,6 +143,15 @@ func NewProviderWithID(name string, id *windows.GUID, callback EnableCallback) (
binary.LittleEndian.PutUint16(metadata.Bytes(), uint16(metadata.Len())) // Update the size at the beginning of the buffer
provider.metadata = metadata.Bytes()
if err := eventSetInformation(
provider.handle,
eventInfoClassProviderSetTraits,
uintptr(unsafe.Pointer(&provider.metadata[0])),
uint32(len(provider.metadata))); err != nil {
return nil, err
}
return provider, nil
}