Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix memmod checkptr fail #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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