Merge pull request #108 from kevpar/etw-set-provider-info

Set ETW provider info so it's always treated as TraceLogging
This commit is contained in:
Kevin Parsons
2019-01-17 13:15:22 -08:00
committed by GitHub
4 changed files with 38 additions and 3 deletions
+19
View File
@@ -8,6 +8,7 @@ import (
"fmt"
"strings"
"unicode/utf16"
"unsafe"
"golang.org/x/sys/windows"
)
@@ -60,6 +61,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)
@@ -152,6 +162,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
}