| 1 |
|
| 2 |
|
| 3 |
package efw |
| 4 |
|
| 5 |
import ( |
| 6 |
"syscall" |
| 7 |
"unsafe" |
| 8 |
|
| 9 |
"golang.org/x/sys/windows" |
| 10 |
) |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
var ebpfObjectLoadNativeByFdsProc = newProc("ebpf_object_load_native_by_fds") |
| 22 |
|
| 23 |
func EbpfObjectLoadNativeFds(fileName string, mapFds []FD, programFds []FD) (int, int, error) { |
| 24 |
addr, err := ebpfObjectLoadNativeByFdsProc.Find() |
| 25 |
if err != nil { |
| 26 |
return 0, 0, err |
| 27 |
} |
| 28 |
|
| 29 |
fileBytes, err := windows.ByteSliceFromString(fileName) |
| 30 |
if err != nil { |
| 31 |
return 0, 0, err |
| 32 |
} |
| 33 |
|
| 34 |
countOfMaps := Size(len(mapFds)) |
| 35 |
countOfPrograms := Size(len(programFds)) |
| 36 |
err = errorResult(syscall.SyscallN(addr, |
| 37 |
uintptr(unsafe.Pointer(&fileBytes[0])), |
| 38 |
uintptr(unsafe.Pointer(&countOfMaps)), |
| 39 |
uintptr(unsafe.Pointer(&mapFds[0])), |
| 40 |
uintptr(unsafe.Pointer(&countOfPrograms)), |
| 41 |
uintptr(unsafe.Pointer(&programFds[0])), |
| 42 |
)) |
| 43 |
return int(countOfMaps), int(countOfPrograms), err |
| 44 |
} |