Skip to content

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

@bupjae

Description

@bupjae

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions