Skip to content

x/sys/windows: FormatMessage can't accept a DLL handle on 64-bit systems #11147

@actgardner

Description

@actgardner
  1. What version of Go are you using (go version)?
    go1.3.3 windows/amd64
  2. What operating system and processor architecture are you using?
    Windows x86-64
  3. What did you do?
    Try to call syscall.FormatMessage with a DLL handle.
var flags uint32 = syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS | syscall.FORMAT_MESSAGE_FROM_HMODULE
libpdhDll := syscall.MustLoadDLL("pdh.dll")
buffer := make([]uint16, 300)

// Have to cast Handle, which is a uintptr, to a uint32 due to the signature of FormatMessage
syscall.FormatMessage(flags, uint32(libpdhDll.Handle), <some error number>, 0, buffer, nil)
  1. What did you expect to see?
    FormatMessage should accept a syscall.Handle or a uintptr so the cast to uint32 doesn't have to happen.

5.What did you see instead?
FormatMessage returns an error because the truncated pointer doesn't point to a DLL.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions