Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ package etw
#cgo LDFLAGS: -ltdh

#include "session.h"
#include "stdint.h"
*/
import "C"

import (
"fmt"
"math/rand"
Expand Down Expand Up @@ -322,7 +324,10 @@ func (s *Session) processEvents(callbackContextKey uintptr) error {
(C.LPWSTR)(unsafe.Pointer(&s.etwSessionName[0])),
(C.PVOID)(callbackContextKey),
)
if C.INVALID_PROCESSTRACE_HANDLE == traceHandle {
// Based on the API docs:
// (INVALID_PROCESSTRACE_HANDLE is equivalent to (UINT64)UINTPTR_MAX.)
// Ref: https://learn.microsoft.com/en-us/windows/win32/api/evntrace/nf-evntrace-opentracea
if uint64(C.UINTPTR_MAX) == uint64(traceHandle) {
return fmt.Errorf("OpenTraceW failed; %w", windows.GetLastError())
}

Expand Down