// protects from directory traversal func safeJoin(baseDir, path string) string{ return filepath.Join(baseDir, filepath.Join("/", path)) } func getSyscallArg(v interface{}) uintptr { r := reflect.ValueOf(v) switch r.Kind(){ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return uintptr(r.Int()) case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return uintptr(r.Uint()) case reflect.Ptr, reflect.UnsafePointer, reflect.Slice: return r.Pointer() case reflect.String: b := []byte(r.String()) b = append(b, 0) return reflect.ValueOf(b).Pointer() // TODO: add&test support Array and Struct //case reflect.Array: // return r.Index(0).Addr() } // or panic? return 0 } func getByte(addr uintptr) byte{ return (*struct{b byte})(unsafe.Pointer(addr)).b } func setByte(addr uintptr, value byte){ (*struct{b byte})(unsafe.Pointer(addr)).b = value }