Skip to content

Commit 80a6b2d

Browse files
committed
feat(sys): Pass filter data to ETW provider session's callback
1 parent 72f0973 commit 80a6b2d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/sys/etw/etw.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ func CaptureProviderState(guid windows.GUID, handle TraceHandle) error {
236236
type EnableTraceOpts struct {
237237
// WithStacktrace indicates call stack trace is added to the extended data of events.
238238
WithStacktrace bool
239+
// EventFilterDescriptors defines the filter data that a session passes to the provider's
240+
// enable callback function.
241+
EventFilterDescriptors []EventFilterDescriptor
239242
}
240243

241244
// EnableTraceWithOpts influences the behaviour of the specified event trace provider
@@ -245,9 +248,16 @@ func EnableTraceWithOpts(guid windows.GUID, handle TraceHandle, keywords uint64,
245248
Version: EnableTraceParametersVersion,
246249
SourceID: guid,
247250
}
251+
248252
if opts.WithStacktrace {
249253
params.EnableProperty = EventEnablePropertyStacktrace
250254
}
255+
256+
if len(opts.EventFilterDescriptors) > 0 {
257+
params.EnableFilterDesc = uintptr(unsafe.Pointer(&opts.EventFilterDescriptors[0]))
258+
params.FilterDescCount = uint32(len(opts.EventFilterDescriptors))
259+
}
260+
251261
err := enableTraceEx2(handle, &guid, ControlCodeEnableProvider, TraceLevelInformation, keywords, 0, 0, params)
252262
if err != nil {
253263
return os.NewSyscallError("EnableTraceEx2", err)

0 commit comments

Comments
 (0)