Commit 5b683257 authored by Carlos Castillo's avatar Carlos Castillo Committed by Alex Brainman

x/sys/windows: Add GetComputerNameEx

Provides access to the GetComputerNameEx syscall.

This mirrors the change golang.org/cl/5852 in the standard library, but
provides public access to all name types provided by windows.

Change-Id: I5fbad5abe721de70e9d2b5dda2fafb7a9c419220
Reviewed-on: https://go-review.googlesource.com/6320Reviewed-by: 's avatarAlex Brainman <alex.brainman@gmail.com>
parent fb0c33c5
...@@ -104,6 +104,7 @@ func NewCallbackCDecl(fn interface{}) uintptr ...@@ -104,6 +104,7 @@ func NewCallbackCDecl(fn interface{}) uintptr
//sys DeleteFile(path *uint16) (err error) = DeleteFileW //sys DeleteFile(path *uint16) (err error) = DeleteFileW
//sys MoveFile(from *uint16, to *uint16) (err error) = MoveFileW //sys MoveFile(from *uint16, to *uint16) (err error) = MoveFileW
//sys GetComputerName(buf *uint16, n *uint32) (err error) = GetComputerNameW //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 SetEndOfFile(handle Handle) (err error)
//sys GetSystemTimeAsFileTime(time *Filetime) //sys GetSystemTimeAsFileTime(time *Filetime)
//sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff] //sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff]
......
// go build mksyscall_windows.go && ./mksyscall_windows syscall_windows.go security_windows.go // MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package windows package windows
import "unsafe" import "unsafe"
import "syscall" import "syscall"
var _ unsafe.Pointer
var ( var (
modkernel32 = syscall.NewLazyDLL("kernel32.dll") modkernel32 = syscall.NewLazyDLL("kernel32.dll")
modadvapi32 = syscall.NewLazyDLL("advapi32.dll") modadvapi32 = syscall.NewLazyDLL("advapi32.dll")
...@@ -43,6 +44,7 @@ var ( ...@@ -43,6 +44,7 @@ var (
procDeleteFileW = modkernel32.NewProc("DeleteFileW") procDeleteFileW = modkernel32.NewProc("DeleteFileW")
procMoveFileW = modkernel32.NewProc("MoveFileW") procMoveFileW = modkernel32.NewProc("MoveFileW")
procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
procSetEndOfFile = modkernel32.NewProc("SetEndOfFile") procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime") procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation") procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
...@@ -479,6 +481,18 @@ func GetComputerName(buf *uint16, n *uint32) (err error) { ...@@ -479,6 +481,18 @@ func GetComputerName(buf *uint16, n *uint32) (err error) {
return 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) { func SetEndOfFile(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0) r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 { if r1 == 0 {
......
...@@ -1108,3 +1108,15 @@ const ( ...@@ -1108,3 +1108,15 @@ const (
IO_REPARSE_TAG_SYMLINK = 0xA000000C IO_REPARSE_TAG_SYMLINK = 0xA000000C
SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1 SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
) )
const (
ComputerNameNetBIOS = 0
ComputerNameDnsHostname = 1
ComputerNameDnsDomain = 2
ComputerNameDnsFullyQualified = 3
ComputerNamePhysicalNetBIOS = 4
ComputerNamePhysicalDnsHostname = 5
ComputerNamePhysicalDnsDomain = 6
ComputerNamePhysicalDnsFullyQualified = 7
ComputerNameMax = 8
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment