Pass blob pointers safely to ETW

This commit is contained in:
Kevin Parsons
2019-01-03 13:57:57 -08:00
parent b87cea3696
commit 37af28e005
3 changed files with 33 additions and 5 deletions
+2 -5
View File
@@ -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,
}