From cb65c8d58ac76abdaa6d14cc0742ca23d00ff524 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Mon, 12 Oct 2020 10:51:34 -0400 Subject: syscall: switch go:generate directives back to mksyscall_windows.go Adjust mksyscall_windows.go to activate module mode and set -mod=readonly, and to suppress its own deprecation warning when run from within GOROOT/src. We can't vendor the mkwinsyscall tool in to the std module directly, because std-vendored dependencies (unlike the dependencies of all other modules) turn into actual, distinct packages in 'std' when viewed from outside the 'std' module. We don't want to introduce a binary in the 'std' meta-pattern, but we also don't particularly want to add more special-cases to the 'go' command right now when we have an existing wrapper program that can do the job. I also regenerated the affected packages to ensure that they are consistent with the current version of mksyscall, which produced some declaration-order changes in internal/syscall/windows/zsyscall_windows.go. Fixes #41916 Updates #25922 Change-Id: If6e6f8ba3dd372a7ecd6820ee6c0ca38d55f0f35 Reviewed-on: https://go-review.googlesource.com/c/go/+/261499 Trust: Bryan C. Mills Trust: Alex Brainman Reviewed-by: Dmitri Shuralyov Reviewed-by: Alex Brainman --- src/internal/syscall/windows/mksyscall.go | 2 +- src/internal/syscall/windows/registry/mksyscall.go | 2 +- src/internal/syscall/windows/zsyscall_windows.go | 26 +++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/internal/syscall') diff --git a/src/internal/syscall/windows/mksyscall.go b/src/internal/syscall/windows/mksyscall.go index 95e36f7aa3..599f07601b 100644 --- a/src/internal/syscall/windows/mksyscall.go +++ b/src/internal/syscall/windows/mksyscall.go @@ -6,4 +6,4 @@ package windows -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go syscall_windows.go security_windows.go psapi_windows.go symlink_windows.go +//go:generate go run ../../../syscall/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go security_windows.go psapi_windows.go symlink_windows.go diff --git a/src/internal/syscall/windows/registry/mksyscall.go b/src/internal/syscall/windows/registry/mksyscall.go index cb4906a7b2..320abf7fc6 100644 --- a/src/internal/syscall/windows/registry/mksyscall.go +++ b/src/internal/syscall/windows/registry/mksyscall.go @@ -6,4 +6,4 @@ package registry -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go syscall.go +//go:generate go run ../../../../syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go diff --git a/src/internal/syscall/windows/zsyscall_windows.go b/src/internal/syscall/windows/zsyscall_windows.go index 0840dc283a..1eb8c2dfd2 100644 --- a/src/internal/syscall/windows/zsyscall_windows.go +++ b/src/internal/syscall/windows/zsyscall_windows.go @@ -40,14 +40,15 @@ var ( modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll")) modws2_32 = syscall.NewLazyDLL(sysdll.Add("ws2_32.dll")) modnetapi32 = syscall.NewLazyDLL(sysdll.Add("netapi32.dll")) - modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll")) moduserenv = syscall.NewLazyDLL(sysdll.Add("userenv.dll")) + modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll")) modpsapi = syscall.NewLazyDLL(sysdll.Add("psapi.dll")) procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") procMoveFileExW = modkernel32.NewProc("MoveFileExW") procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") + procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle") procWSASocketW = modws2_32.NewProc("WSASocketW") procLockFileEx = modkernel32.NewProc("LockFileEx") procUnlockFileEx = modkernel32.NewProc("UnlockFileEx") @@ -71,7 +72,6 @@ var ( procNetUserGetLocalGroups = modnetapi32.NewProc("NetUserGetLocalGroups") procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo") procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") - procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle") ) func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { @@ -82,8 +82,8 @@ func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapter return } -func SetFileInformationByHandle(handle syscall.Handle, fileInformationClass uint32, buf uintptr, bufsize uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(fileInformationClass), uintptr(buf), uintptr(bufsize), 0, 0) +func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -94,8 +94,8 @@ func SetFileInformationByHandle(handle syscall.Handle, fileInformationClass uint return } -func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) +func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { + r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -106,9 +106,10 @@ func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) { return } -func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { - r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) - if r1 == 0 { +func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len)) + n = uint32(r0) + if n == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -118,10 +119,9 @@ func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { return } -func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len)) - n = uint32(r0) - if n == 0 { +func SetFileInformationByHandle(handle syscall.Handle, fileInformationClass uint32, buf uintptr, bufsize uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(fileInformationClass), uintptr(buf), uintptr(bufsize), 0, 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { -- cgit v1.3