| // MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT |
| |
| package windows |
| |
| import ( |
| "internal/syscall/windows/sysdll" |
| "syscall" |
| "unsafe" |
| ) |
| |
| var _ unsafe.Pointer |
| |
| // Do the interface allocations only once for common |
| // Errno values. |
| const ( |
| errnoWSAEINPROGRESS = 10036 |
| ) |
| |
| var ( |
| errWSAEINPROGRESS error = syscall.Errno(errnoWSAEINPROGRESS) |
| ) |
| |
| // errnoErr returns common boxed Errno values, to prevent |
| // allocations at runtime. |
| func errnoErr(e syscall.Errno) error { |
| switch e { |
| case 0: |
| return nil |
| case errnoWSAEINPROGRESS: |
| return errWSAEINPROGRESS |
| } |
| // TODO: add more here, after collecting data on the common |
| // error values see on Windows. (perhaps when running |
| // all.bat?) |
| return e |
| } |
| |
| var ( |
| modiphlpapi = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll")) |
| modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll")) |
| |
| procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") |
| procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") |
| procMoveFileExW = modkernel32.NewProc("MoveFileExW") |
| procGetACP = modkernel32.NewProc("GetACP") |
| procGetConsoleCP = modkernel32.NewProc("GetConsoleCP") |
| procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") |
| ) |
| |
| func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { |
| r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) |
| if r0 != 0 { |
| errcode = syscall.Errno(r0) |
| } |
| 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))) |
| if r1 == 0 { |
| if e1 != 0 { |
| err = errnoErr(e1) |
| } else { |
| err = syscall.EINVAL |
| } |
| } |
| 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 { |
| if e1 != 0 { |
| err = errnoErr(e1) |
| } else { |
| err = syscall.EINVAL |
| } |
| } |
| return |
| } |
| |
| func GetACP() (acp uint32) { |
| r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) |
| acp = uint32(r0) |
| return |
| } |
| |
| func GetConsoleCP() (ccp uint32) { |
| r0, _, _ := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0) |
| ccp = uint32(r0) |
| return |
| } |
| |
| func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) { |
| r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) |
| nwrite = int32(r0) |
| if nwrite == 0 { |
| if e1 != 0 { |
| err = errnoErr(e1) |
| } else { |
| err = syscall.EINVAL |
| } |
| } |
| return |
| } |