diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index 7a0d8c3e..b8c4b313 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -104,6 +104,7 @@ func NewCallbackCDecl(fn interface{}) uintptr //sys DeleteFile(path *uint16) (err error) = DeleteFileW //sys MoveFile(from *uint16, to *uint16) (err error) = MoveFileW //sys GetComputerName(buf *uint16, n *uint32) (err error) = GetComputerNameW +//sys GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) = GetComputerNameExW //sys SetEndOfFile(handle Handle) (err error) //sys GetSystemTimeAsFileTime(time *Filetime) //sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff] diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index 26c6fdcc..a0bcfa19 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -1,11 +1,12 @@ -// go build mksyscall_windows.go && ./mksyscall_windows syscall_windows.go security_windows.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT package windows import "unsafe" import "syscall" +var _ unsafe.Pointer + var ( modkernel32 = syscall.NewLazyDLL("kernel32.dll") modadvapi32 = syscall.NewLazyDLL("advapi32.dll") @@ -43,6 +44,7 @@ var ( procDeleteFileW = modkernel32.NewProc("DeleteFileW") procMoveFileW = modkernel32.NewProc("MoveFileW") procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") + procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") procSetEndOfFile = modkernel32.NewProc("SetEndOfFile") procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime") procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation") @@ -479,6 +481,18 @@ func GetComputerName(buf *uint16, n *uint32) (err error) { return } +func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) + if r1 == 0 { + if e1 != 0 { + err = error(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func SetEndOfFile(handle Handle) (err error) { r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0) if r1 == 0 { diff --git a/windows/ztypes_windows.go b/windows/ztypes_windows.go index 9787253b..2fe0745b 100644 --- a/windows/ztypes_windows.go +++ b/windows/ztypes_windows.go @@ -1108,3 +1108,15 @@ const ( IO_REPARSE_TAG_SYMLINK = 0xA000000C SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1 ) + +const ( + ComputerNameNetBIOS = 0 + ComputerNameDnsHostname = 1 + ComputerNameDnsDomain = 2 + ComputerNameDnsFullyQualified = 3 + ComputerNamePhysicalNetBIOS = 4 + ComputerNamePhysicalDnsHostname = 5 + ComputerNamePhysicalDnsDomain = 6 + ComputerNamePhysicalDnsFullyQualified = 7 + ComputerNameMax = 8 +)