Skip to content

Conversation

lysShub
Copy link

@lysShub lysShub commented Jul 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant