Open bupjae opened 3 years ago
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 https://github.com/golang/go/issues/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.
Source code:
Expected result: Error code describing 'module not found' (ERROR_MOD_NOT_FOUND, 126)
Actual result: 0
According to https://github.com/golang/go/issues/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.