Skip to content

x/sys/windows: mkwinsyscall: Add support for DLLs with extensions other than .dll #58337

Open
@ranganath42

Description

@ranganath42

What version of Go are you using (go version)?

$ go version
go version go1.20 windows/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
    :
GOARCH=amd64
GOOS=windows
    :

What did you do?

Some of the Windows system dynamic link library (DLL) files have extensions other than .dll.
For example,

  • ActiveX Controls files with .ocx extension
  • Control Panel applets with .cpl extension
  • Device drivers with .drv extension

mkwinsyscall does not support generating the syscall wrappers for these DLLs with different extensions.
The extension is always hard-coded to .dll in the generated code.

//sys ClosePrinter(h syscall.Handle) (err error) = winspool.ClosePrinter

What did you expect to see?

var (
        modwinspool = windows.NewLazySystemDLL("winspool.drv")
        procClosePrinter = modwinspool.NewProc("ClosePrinter")
)

What did you see instead?

var (
        modwinspool = windows.NewLazySystemDLL("winspool.dll")
        procClosePrinter = modwinspool.NewProc("ClosePrinter")
)

Proposed solution

If the user specified the extension of the DLL in the //sys comment, use that extension instead of adding the .dll extension.
Going back to the previous example, the user can specify the extension as .drv in the //sys comment.

//sys ClosePrinter(h syscall.Handle) (err error) = winspool.drv.ClosePrinter

Then, the generated code will be,

var (
        modwinspool = windows.NewLazySystemDLL("winspool.drv")
        procClosePrinter = modwinspool.NewProc("ClosePrinter")
)

The code changes are fairly straightforward. I have working code that I can submit as a pull request if the proposal makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windowscompiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions