diff --git a/internal/etw/eventdatadescriptor.go b/internal/etw/eventdatadescriptor.go index efa5f78..e7c53cf 100644 --- a/internal/etw/eventdatadescriptor.go +++ b/internal/etw/eventdatadescriptor.go @@ -13,7 +13,7 @@ const ( ) type eventDataDescriptor struct { - ptr uint64 + ptr ptr64 size uint32 dataType eventDataDescriptorType reserved1 uint8 @@ -21,11 +21,8 @@ type eventDataDescriptor struct { } func newEventDataDescriptor(dataType eventDataDescriptorType, buffer []byte) eventDataDescriptor { - // Passing a pointer to Go-managed memory as part of a block of memory is - // risky since the GC doesn't know about it. If we find a better way to do - // this we should use it instead. return eventDataDescriptor{ - ptr: uint64(uintptr(unsafe.Pointer(&buffer[0]))), + ptr: ptr64{ptr: unsafe.Pointer(&buffer[0])}, size: uint32(len(buffer)), dataType: dataType, } diff --git a/internal/etw/ptr64_32.go b/internal/etw/ptr64_32.go new file mode 100644 index 0000000..435ec3c --- /dev/null +++ b/internal/etw/ptr64_32.go @@ -0,0 +1,16 @@ +// +build 386 arm + +package etw + +import ( + "unsafe" +) + +// byteptr64 defines a struct containing a pointer. The struct is guaranteed to +// be 64 bits, regardless of the actual size of a pointer on the platform. This +// is intended for use with certain Windows APIs that expect a pointer as a +// ULONGLONG. +type ptr64 struct { + ptr unsafe.Pointer + _ uint32 +} diff --git a/internal/etw/ptr64_64.go b/internal/etw/ptr64_64.go new file mode 100644 index 0000000..903d3c0 --- /dev/null +++ b/internal/etw/ptr64_64.go @@ -0,0 +1,15 @@ +// +build amd64 arm64 + +package etw + +import ( + "unsafe" +) + +// byteptr64 defines a struct containing a pointer. The struct is guaranteed to +// be 64 bits, regardless of the actual size of a pointer on the platform. This +// is intended for use with certain Windows APIs that expect a pointer as a +// ULONGLONG. +type ptr64 struct { + ptr unsafe.Pointer +}