package mem import "unsafe" func DataToManagedPtr(data []byte) (uint32, uint32) { ptr := unsafe.Pointer(unsafe.SliceData(data)) return uint32(uintptr(ptr)), uint32(len(data)) } func DataFromPtr(ptr, size uint32) []byte { p := unsafe.Pointer(uintptr(ptr)) return unsafe.Slice((*byte)(p), int(size)) } func PtrToData(ptr uint32, size uint32) []byte { return unsafe.Slice((*byte)(unsafe.Pointer(uintptr(ptr))), size) }