1
2
3
4
5 package etw
6
7 import (
8 "syscall"
9 "unsafe"
10
11 "golang.org/x/sys/windows"
12 )
13
14 var _ unsafe.Pointer
15
16
17
18 const (
19 errnoERROR_IO_PENDING = 997
20 )
21
22 var (
23 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
24 errERROR_EINVAL error = syscall.EINVAL
25 )
26
27
28
29 func errnoErr(e syscall.Errno) error {
30 switch e {
31 case 0:
32 return errERROR_EINVAL
33 case errnoERROR_IO_PENDING:
34 return errERROR_IO_PENDING
35 }
36
37
38
39 return e
40 }
41
42 var (
43 modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
44
45 procEventRegister = modadvapi32.NewProc("EventRegister")
46 procEventSetInformation = modadvapi32.NewProc("EventSetInformation")
47 procEventUnregister = modadvapi32.NewProc("EventUnregister")
48 procEventWriteTransfer = modadvapi32.NewProc("EventWriteTransfer")
49 )
50
51 func eventRegister(providerId *windows.GUID, callback uintptr, callbackContext uintptr, providerHandle *providerHandle) (win32err error) {
52 r0, _, _ := syscall.Syscall6(procEventRegister.Addr(), 4, uintptr(unsafe.Pointer(providerId)), uintptr(callback), uintptr(callbackContext), uintptr(unsafe.Pointer(providerHandle)), 0, 0)
53 if r0 != 0 {
54 win32err = syscall.Errno(r0)
55 }
56 return
57 }
58
59 func eventSetInformation_64(providerHandle providerHandle, class eventInfoClass, information uintptr, length uint32) (win32err error) {
60 r0, _, _ := syscall.Syscall6(procEventSetInformation.Addr(), 4, uintptr(providerHandle), uintptr(class), uintptr(information), uintptr(length), 0, 0)
61 if r0 != 0 {
62 win32err = syscall.Errno(r0)
63 }
64 return
65 }
66
67 func eventSetInformation_32(providerHandle_low uint32, providerHandle_high uint32, class eventInfoClass, information uintptr, length uint32) (win32err error) {
68 r0, _, _ := syscall.Syscall6(procEventSetInformation.Addr(), 5, uintptr(providerHandle_low), uintptr(providerHandle_high), uintptr(class), uintptr(information), uintptr(length), 0)
69 if r0 != 0 {
70 win32err = syscall.Errno(r0)
71 }
72 return
73 }
74
75 func eventUnregister_64(providerHandle providerHandle) (win32err error) {
76 r0, _, _ := syscall.Syscall(procEventUnregister.Addr(), 1, uintptr(providerHandle), 0, 0)
77 if r0 != 0 {
78 win32err = syscall.Errno(r0)
79 }
80 return
81 }
82
83 func eventUnregister_32(providerHandle_low uint32, providerHandle_high uint32) (win32err error) {
84 r0, _, _ := syscall.Syscall(procEventUnregister.Addr(), 2, uintptr(providerHandle_low), uintptr(providerHandle_high), 0)
85 if r0 != 0 {
86 win32err = syscall.Errno(r0)
87 }
88 return
89 }
90
91 func eventWriteTransfer_64(providerHandle providerHandle, descriptor *eventDescriptor, activityID *windows.GUID, relatedActivityID *windows.GUID, dataDescriptorCount uint32, dataDescriptors *eventDataDescriptor) (win32err error) {
92 r0, _, _ := syscall.Syscall6(procEventWriteTransfer.Addr(), 6, uintptr(providerHandle), uintptr(unsafe.Pointer(descriptor)), uintptr(unsafe.Pointer(activityID)), uintptr(unsafe.Pointer(relatedActivityID)), uintptr(dataDescriptorCount), uintptr(unsafe.Pointer(dataDescriptors)))
93 if r0 != 0 {
94 win32err = syscall.Errno(r0)
95 }
96 return
97 }
98
99 func eventWriteTransfer_32(providerHandle_low uint32, providerHandle_high uint32, descriptor *eventDescriptor, activityID *windows.GUID, relatedActivityID *windows.GUID, dataDescriptorCount uint32, dataDescriptors *eventDataDescriptor) (win32err error) {
100 r0, _, _ := syscall.Syscall9(procEventWriteTransfer.Addr(), 7, uintptr(providerHandle_low), uintptr(providerHandle_high), uintptr(unsafe.Pointer(descriptor)), uintptr(unsafe.Pointer(activityID)), uintptr(unsafe.Pointer(relatedActivityID)), uintptr(dataDescriptorCount), uintptr(unsafe.Pointer(dataDescriptors)), 0, 0)
101 if r0 != 0 {
102 win32err = syscall.Errno(r0)
103 }
104 return
105 }
106
View as plain text