wireguard-windows icon indicating copy to clipboard operation
wireguard-windows copied to clipboard

fix memmod checkptr fail

Open lysShub opened this issue 7 months ago • 0 comments

old code will checkptr fail :

// main.go
package main

import (
	"io"
	"os"

	"golang.zx2c4.com/wireguard/windows/driver/memmod"
)

func main() {
	fh, err := os.OpenFile(`C:\Windows\System32\iphlpapi.dll`, os.O_RDONLY, 0666)
	if err != nil {
		panic(err)
	}
	defer fh.Close()

	data, err := io.ReadAll(fh)
	if err != nil {
		panic(err)
	}

	d, err := memmod.LoadLibrary(data)
	if err != nil {
		panic(err)
	}
	defer d.Free()

	_, err = d.ProcAddressByName("AddIPAddress")
	if err != nil {
		panic(err)
	}
}
go run -race main.go

fatal error: checkptr: pointer arithmetic result points to invalid allocation

lysShub avatar Jul 05 '24 09:07 lysShub