...
Run Format

Source file src/internal/syscall/windows/zsyscall_windows.go

Documentation: internal/syscall/windows

     1  // Code generated by 'go generate'; DO NOT EDIT.
     2  
     3  package windows
     4  
     5  import (
     6  	"internal/syscall/windows/sysdll"
     7  	"syscall"
     8  	"unsafe"
     9  )
    10  
    11  var _ unsafe.Pointer
    12  
    13  // Do the interface allocations only once for common
    14  // Errno values.
    15  const (
    16  	errnoERROR_IO_PENDING = 997
    17  )
    18  
    19  var (
    20  	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
    21  )
    22  
    23  // errnoErr returns common boxed Errno values, to prevent
    24  // allocations at runtime.
    25  func errnoErr(e syscall.Errno) error {
    26  	switch e {
    27  	case 0:
    28  		return nil
    29  	case errnoERROR_IO_PENDING:
    30  		return errERROR_IO_PENDING
    31  	}
    32  	// TODO: add more here, after collecting data on the common
    33  	// error values see on Windows. (perhaps when running
    34  	// all.bat?)
    35  	return e
    36  }
    37  
    38  var (
    39  	modiphlpapi = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll"))
    40  	modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
    41  	modws2_32   = syscall.NewLazyDLL(sysdll.Add("ws2_32.dll"))
    42  	modnetapi32 = syscall.NewLazyDLL(sysdll.Add("netapi32.dll"))
    43  	modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll"))
    44  	moduserenv  = syscall.NewLazyDLL(sysdll.Add("userenv.dll"))
    45  	modpsapi    = syscall.NewLazyDLL(sysdll.Add("psapi.dll"))
    46  
    47  	procGetAdaptersAddresses      = modiphlpapi.NewProc("GetAdaptersAddresses")
    48  	procGetComputerNameExW        = modkernel32.NewProc("GetComputerNameExW")
    49  	procMoveFileExW               = modkernel32.NewProc("MoveFileExW")
    50  	procGetModuleFileNameW        = modkernel32.NewProc("GetModuleFileNameW")
    51  	procWSASocketW                = modws2_32.NewProc("WSASocketW")
    52  	procGetACP                    = modkernel32.NewProc("GetACP")
    53  	procGetConsoleCP              = modkernel32.NewProc("GetConsoleCP")
    54  	procMultiByteToWideChar       = modkernel32.NewProc("MultiByteToWideChar")
    55  	procGetCurrentThread          = modkernel32.NewProc("GetCurrentThread")
    56  	procNetShareAdd               = modnetapi32.NewProc("NetShareAdd")
    57  	procNetShareDel               = modnetapi32.NewProc("NetShareDel")
    58  	procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW")
    59  	procImpersonateSelf           = modadvapi32.NewProc("ImpersonateSelf")
    60  	procRevertToSelf              = modadvapi32.NewProc("RevertToSelf")
    61  	procOpenThreadToken           = modadvapi32.NewProc("OpenThreadToken")
    62  	procLookupPrivilegeValueW     = modadvapi32.NewProc("LookupPrivilegeValueW")
    63  	procAdjustTokenPrivileges     = modadvapi32.NewProc("AdjustTokenPrivileges")
    64  	procDuplicateTokenEx          = modadvapi32.NewProc("DuplicateTokenEx")
    65  	procSetTokenInformation       = modadvapi32.NewProc("SetTokenInformation")
    66  	procGetProfilesDirectoryW     = moduserenv.NewProc("GetProfilesDirectoryW")
    67  	procNetUserGetLocalGroups     = modnetapi32.NewProc("NetUserGetLocalGroups")
    68  	procGetProcessMemoryInfo      = modpsapi.NewProc("GetProcessMemoryInfo")
    69  )
    70  
    71  func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
    72  	r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
    73  	if r0 != 0 {
    74  		errcode = syscall.Errno(r0)
    75  	}
    76  	return
    77  }
    78  
    79  func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) {
    80  	r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
    81  	if r1 == 0 {
    82  		if e1 != 0 {
    83  			err = errnoErr(e1)
    84  		} else {
    85  			err = syscall.EINVAL
    86  		}
    87  	}
    88  	return
    89  }
    90  
    91  func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
    92  	r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
    93  	if r1 == 0 {
    94  		if e1 != 0 {
    95  			err = errnoErr(e1)
    96  		} else {
    97  			err = syscall.EINVAL
    98  		}
    99  	}
   100  	return
   101  }
   102  
   103  func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) {
   104  	r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len))
   105  	n = uint32(r0)
   106  	if n == 0 {
   107  		if e1 != 0 {
   108  			err = errnoErr(e1)
   109  		} else {
   110  			err = syscall.EINVAL
   111  		}
   112  	}
   113  	return
   114  }
   115  
   116  func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (handle syscall.Handle, err error) {
   117  	r0, _, e1 := syscall.Syscall6(procWSASocketW.Addr(), 6, uintptr(af), uintptr(typ), uintptr(protocol), uintptr(unsafe.Pointer(protinfo)), uintptr(group), uintptr(flags))
   118  	handle = syscall.Handle(r0)
   119  	if handle == syscall.InvalidHandle {
   120  		if e1 != 0 {
   121  			err = errnoErr(e1)
   122  		} else {
   123  			err = syscall.EINVAL
   124  		}
   125  	}
   126  	return
   127  }
   128  
   129  func GetACP() (acp uint32) {
   130  	r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
   131  	acp = uint32(r0)
   132  	return
   133  }
   134  
   135  func GetConsoleCP() (ccp uint32) {
   136  	r0, _, _ := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0)
   137  	ccp = uint32(r0)
   138  	return
   139  }
   140  
   141  func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
   142  	r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
   143  	nwrite = int32(r0)
   144  	if nwrite == 0 {
   145  		if e1 != 0 {
   146  			err = errnoErr(e1)
   147  		} else {
   148  			err = syscall.EINVAL
   149  		}
   150  	}
   151  	return
   152  }
   153  
   154  func GetCurrentThread() (pseudoHandle syscall.Handle, err error) {
   155  	r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
   156  	pseudoHandle = syscall.Handle(r0)
   157  	if pseudoHandle == 0 {
   158  		if e1 != 0 {
   159  			err = errnoErr(e1)
   160  		} else {
   161  			err = syscall.EINVAL
   162  		}
   163  	}
   164  	return
   165  }
   166  
   167  func NetShareAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint16) (neterr error) {
   168  	r0, _, _ := syscall.Syscall6(procNetShareAdd.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(parmErr)), 0, 0)
   169  	if r0 != 0 {
   170  		neterr = syscall.Errno(r0)
   171  	}
   172  	return
   173  }
   174  
   175  func NetShareDel(serverName *uint16, netName *uint16, reserved uint32) (neterr error) {
   176  	r0, _, _ := syscall.Syscall(procNetShareDel.Addr(), 3, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(netName)), uintptr(reserved))
   177  	if r0 != 0 {
   178  		neterr = syscall.Errno(r0)
   179  	}
   180  	return
   181  }
   182  
   183  func GetFinalPathNameByHandle(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
   184  	r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0)
   185  	n = uint32(r0)
   186  	if n == 0 {
   187  		if e1 != 0 {
   188  			err = errnoErr(e1)
   189  		} else {
   190  			err = syscall.EINVAL
   191  		}
   192  	}
   193  	return
   194  }
   195  
   196  func ImpersonateSelf(impersonationlevel uint32) (err error) {
   197  	r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
   198  	if r1 == 0 {
   199  		if e1 != 0 {
   200  			err = errnoErr(e1)
   201  		} else {
   202  			err = syscall.EINVAL
   203  		}
   204  	}
   205  	return
   206  }
   207  
   208  func RevertToSelf() (err error) {
   209  	r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
   210  	if r1 == 0 {
   211  		if e1 != 0 {
   212  			err = errnoErr(e1)
   213  		} else {
   214  			err = syscall.EINVAL
   215  		}
   216  	}
   217  	return
   218  }
   219  
   220  func OpenThreadToken(h syscall.Handle, access uint32, openasself bool, token *syscall.Token) (err error) {
   221  	var _p0 uint32
   222  	if openasself {
   223  		_p0 = 1
   224  	} else {
   225  		_p0 = 0
   226  	}
   227  	r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(h), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
   228  	if r1 == 0 {
   229  		if e1 != 0 {
   230  			err = errnoErr(e1)
   231  		} else {
   232  			err = syscall.EINVAL
   233  		}
   234  	}
   235  	return
   236  }
   237  
   238  func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
   239  	r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
   240  	if r1 == 0 {
   241  		if e1 != 0 {
   242  			err = errnoErr(e1)
   243  		} else {
   244  			err = syscall.EINVAL
   245  		}
   246  	}
   247  	return
   248  }
   249  
   250  func adjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, buflen uint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32) (ret uint32, err error) {
   251  	var _p0 uint32
   252  	if disableAllPrivileges {
   253  		_p0 = 1
   254  	} else {
   255  		_p0 = 0
   256  	}
   257  	r0, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
   258  	ret = uint32(r0)
   259  	if true {
   260  		if e1 != 0 {
   261  			err = errnoErr(e1)
   262  		} else {
   263  			err = syscall.EINVAL
   264  		}
   265  	}
   266  	return
   267  }
   268  
   269  func DuplicateTokenEx(hExistingToken syscall.Token, dwDesiredAccess uint32, lpTokenAttributes *syscall.SecurityAttributes, impersonationLevel uint32, tokenType TokenType, phNewToken *syscall.Token) (err error) {
   270  	r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(hExistingToken), uintptr(dwDesiredAccess), uintptr(unsafe.Pointer(lpTokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(phNewToken)))
   271  	if r1 == 0 {
   272  		if e1 != 0 {
   273  			err = errnoErr(e1)
   274  		} else {
   275  			err = syscall.EINVAL
   276  		}
   277  	}
   278  	return
   279  }
   280  
   281  func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, tokenInformation uintptr, tokenInformationLength uint32) (err error) {
   282  	r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(tokenHandle), uintptr(tokenInformationClass), uintptr(tokenInformation), uintptr(tokenInformationLength), 0, 0)
   283  	if r1 == 0 {
   284  		if e1 != 0 {
   285  			err = errnoErr(e1)
   286  		} else {
   287  			err = syscall.EINVAL
   288  		}
   289  	}
   290  	return
   291  }
   292  
   293  func GetProfilesDirectory(dir *uint16, dirLen *uint32) (err error) {
   294  	r1, _, e1 := syscall.Syscall(procGetProfilesDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)), 0)
   295  	if r1 == 0 {
   296  		if e1 != 0 {
   297  			err = errnoErr(e1)
   298  		} else {
   299  			err = syscall.EINVAL
   300  		}
   301  	}
   302  	return
   303  }
   304  
   305  func NetUserGetLocalGroups(serverName *uint16, userName *uint16, level uint32, flags uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32) (neterr error) {
   306  	r0, _, _ := syscall.Syscall9(procNetUserGetLocalGroups.Addr(), 8, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(flags), uintptr(unsafe.Pointer(buf)), uintptr(prefMaxLen), uintptr(unsafe.Pointer(entriesRead)), uintptr(unsafe.Pointer(totalEntries)), 0)
   307  	if r0 != 0 {
   308  		neterr = syscall.Errno(r0)
   309  	}
   310  	return
   311  }
   312  
   313  func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error) {
   314  	r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(memCounters)), uintptr(cb))
   315  	if r1 == 0 {
   316  		if e1 != 0 {
   317  			err = errnoErr(e1)
   318  		} else {
   319  			err = syscall.EINVAL
   320  		}
   321  	}
   322  	return
   323  }
   324  

View as plain text