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

Provide the method to retrieve why the system call has been failed. #108

Open
bupjae opened this issue Sep 5, 2020 · 0 comments
Open

Provide the method to retrieve why the system call has been failed. #108

bupjae opened this issue Sep 5, 2020 · 0 comments

Comments

@bupjae
Copy link

bupjae commented Sep 5, 2020

Source code:

package main

import (
	"fmt"
	"github.com/lxn/win"
	"golang.org/x/sys/windows"
)

func main() {
	wrongName := windows.StringToUTF16Ptr("ADFADFASDFSDAFASFD")
	handle := win.GetModuleHandle(wrongName)
	if handle == 0 {
		fmt.Println(win.GetLastError()) // This always returns 0. See https://github.com/golang/go/issues/41220
	}
}

Expected result:
Error code describing 'module not found' (ERROR_MOD_NOT_FOUND, 126)

Actual result:
0

According to golang/go#41220 , windows.GetLastError always returns nil. As the same reason, win.GetLastError always returns 0.

As wrapper provided by this package doesn't handle err return value from syscall.Syscall, the client doesn't know why the function call was failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant