...

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

     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		procLockFileEx                   = modkernel32.NewProc("LockFileEx")
    53		procUnlockFileEx                 = modkernel32.NewProc("UnlockFileEx")
    54		procGetACP                       = modkernel32.NewProc("GetACP")
    55		procGetConsoleCP                 = modkernel32.NewProc("GetConsoleCP")
    56		procMultiByteToWideChar          = modkernel32.NewProc("MultiByteToWideChar")
    57		procGetCurrentThread             = modkernel32.NewProc("GetCurrentThread")
    58		procNetShareAdd                  = modnetapi32.NewProc("NetShareAdd")
    59		procNetShareDel                  = modnetapi32.NewProc("NetShareDel")
    60		procGetFinalPathNameByHandleW    = modkernel32.NewProc("GetFinalPathNameByHandleW")
    61		procCreateEnvironmentBlock       = moduserenv.NewProc("CreateEnvironmentBlock")
    62		procDestroyEnvironmentBlock      = moduserenv.NewProc("DestroyEnvironmentBlock")
    63		procImpersonateSelf              = modadvapi32.NewProc("ImpersonateSelf")
    64		procRevertToSelf                 = modadvapi32.NewProc("RevertToSelf")
    65		procOpenThreadToken              = modadvapi32.NewProc("OpenThreadToken")
    66		procLookupPrivilegeValueW        = modadvapi32.NewProc("LookupPrivilegeValueW")
    67		procAdjustTokenPrivileges        = modadvapi32.NewProc("AdjustTokenPrivileges")
    68		procDuplicateTokenEx             = modadvapi32.NewProc("DuplicateTokenEx")
    69		procSetTokenInformation          = modadvapi32.NewProc("SetTokenInformation")
    70		procGetProfilesDirectoryW        = moduserenv.NewProc("GetProfilesDirectoryW")
    71		procNetUserGetLocalGroups        = modnetapi32.NewProc("NetUserGetLocalGroups")
    72		procGetProcessMemoryInfo         = modpsapi.NewProc("GetProcessMemoryInfo")
    73		procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
    74	)
    75	
    76	func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
    77		r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
    78		if r0 != 0 {
    79			errcode = syscall.Errno(r0)
    80		}
    81		return
    82	}
    83	
    84	func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) {
    85		r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
    86		if r1 == 0 {
    87			if e1 != 0 {
    88				err = errnoErr(e1)
    89			} else {
    90				err = syscall.EINVAL
    91			}
    92		}
    93		return
    94	}
    95	
    96	func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
    97		r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
    98		if r1 == 0 {
    99			if e1 != 0 {
   100				err = errnoErr(e1)
   101			} else {
   102				err = syscall.EINVAL
   103			}
   104		}
   105		return
   106	}
   107	
   108	func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) {
   109		r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len))
   110		n = uint32(r0)
   111		if n == 0 {
   112			if e1 != 0 {
   113				err = errnoErr(e1)
   114			} else {
   115				err = syscall.EINVAL
   116			}
   117		}
   118		return
   119	}
   120	
   121	func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (handle syscall.Handle, err error) {
   122		r0, _, e1 := syscall.Syscall6(procWSASocketW.Addr(), 6, uintptr(af), uintptr(typ), uintptr(protocol), uintptr(unsafe.Pointer(protinfo)), uintptr(group), uintptr(flags))
   123		handle = syscall.Handle(r0)
   124		if handle == syscall.InvalidHandle {
   125			if e1 != 0 {
   126				err = errnoErr(e1)
   127			} else {
   128				err = syscall.EINVAL
   129			}
   130		}
   131		return
   132	}
   133	
   134	func LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
   135		r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
   136		if r1 == 0 {
   137			if e1 != 0 {
   138				err = errnoErr(e1)
   139			} else {
   140				err = syscall.EINVAL
   141			}
   142		}
   143		return
   144	}
   145	
   146	func UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
   147		r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
   148		if r1 == 0 {
   149			if e1 != 0 {
   150				err = errnoErr(e1)
   151			} else {
   152				err = syscall.EINVAL
   153			}
   154		}
   155		return
   156	}
   157	
   158	func GetACP() (acp uint32) {
   159		r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
   160		acp = uint32(r0)
   161		return
   162	}
   163	
   164	func GetConsoleCP() (ccp uint32) {
   165		r0, _, _ := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0)
   166		ccp = uint32(r0)
   167		return
   168	}
   169	
   170	func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
   171		r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
   172		nwrite = int32(r0)
   173		if nwrite == 0 {
   174			if e1 != 0 {
   175				err = errnoErr(e1)
   176			} else {
   177				err = syscall.EINVAL
   178			}
   179		}
   180		return
   181	}
   182	
   183	func GetCurrentThread() (pseudoHandle syscall.Handle, err error) {
   184		r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
   185		pseudoHandle = syscall.Handle(r0)
   186		if pseudoHandle == 0 {
   187			if e1 != 0 {
   188				err = errnoErr(e1)
   189			} else {
   190				err = syscall.EINVAL
   191			}
   192		}
   193		return
   194	}
   195	
   196	func NetShareAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint16) (neterr error) {
   197		r0, _, _ := syscall.Syscall6(procNetShareAdd.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(parmErr)), 0, 0)
   198		if r0 != 0 {
   199			neterr = syscall.Errno(r0)
   200		}
   201		return
   202	}
   203	
   204	func NetShareDel(serverName *uint16, netName *uint16, reserved uint32) (neterr error) {
   205		r0, _, _ := syscall.Syscall(procNetShareDel.Addr(), 3, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(netName)), uintptr(reserved))
   206		if r0 != 0 {
   207			neterr = syscall.Errno(r0)
   208		}
   209		return
   210	}
   211	
   212	func GetFinalPathNameByHandle(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
   213		r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0)
   214		n = uint32(r0)
   215		if n == 0 {
   216			if e1 != 0 {
   217				err = errnoErr(e1)
   218			} else {
   219				err = syscall.EINVAL
   220			}
   221		}
   222		return
   223	}
   224	
   225	func CreateEnvironmentBlock(block **uint16, token syscall.Token, inheritExisting bool) (err error) {
   226		var _p0 uint32
   227		if inheritExisting {
   228			_p0 = 1
   229		} else {
   230			_p0 = 0
   231		}
   232		r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
   233		if r1 == 0 {
   234			if e1 != 0 {
   235				err = errnoErr(e1)
   236			} else {
   237				err = syscall.EINVAL
   238			}
   239		}
   240		return
   241	}
   242	
   243	func DestroyEnvironmentBlock(block *uint16) (err error) {
   244		r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
   245		if r1 == 0 {
   246			if e1 != 0 {
   247				err = errnoErr(e1)
   248			} else {
   249				err = syscall.EINVAL
   250			}
   251		}
   252		return
   253	}
   254	
   255	func ImpersonateSelf(impersonationlevel uint32) (err error) {
   256		r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
   257		if r1 == 0 {
   258			if e1 != 0 {
   259				err = errnoErr(e1)
   260			} else {
   261				err = syscall.EINVAL
   262			}
   263		}
   264		return
   265	}
   266	
   267	func RevertToSelf() (err error) {
   268		r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
   269		if r1 == 0 {
   270			if e1 != 0 {
   271				err = errnoErr(e1)
   272			} else {
   273				err = syscall.EINVAL
   274			}
   275		}
   276		return
   277	}
   278	
   279	func OpenThreadToken(h syscall.Handle, access uint32, openasself bool, token *syscall.Token) (err error) {
   280		var _p0 uint32
   281		if openasself {
   282			_p0 = 1
   283		} else {
   284			_p0 = 0
   285		}
   286		r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(h), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
   287		if r1 == 0 {
   288			if e1 != 0 {
   289				err = errnoErr(e1)
   290			} else {
   291				err = syscall.EINVAL
   292			}
   293		}
   294		return
   295	}
   296	
   297	func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
   298		r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
   299		if r1 == 0 {
   300			if e1 != 0 {
   301				err = errnoErr(e1)
   302			} else {
   303				err = syscall.EINVAL
   304			}
   305		}
   306		return
   307	}
   308	
   309	func adjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, buflen uint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32) (ret uint32, err error) {
   310		var _p0 uint32
   311		if disableAllPrivileges {
   312			_p0 = 1
   313		} else {
   314			_p0 = 0
   315		}
   316		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)))
   317		ret = uint32(r0)
   318		if true {
   319			if e1 != 0 {
   320				err = errnoErr(e1)
   321			} else {
   322				err = syscall.EINVAL
   323			}
   324		}
   325		return
   326	}
   327	
   328	func DuplicateTokenEx(hExistingToken syscall.Token, dwDesiredAccess uint32, lpTokenAttributes *syscall.SecurityAttributes, impersonationLevel uint32, tokenType TokenType, phNewToken *syscall.Token) (err error) {
   329		r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(hExistingToken), uintptr(dwDesiredAccess), uintptr(unsafe.Pointer(lpTokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(phNewToken)))
   330		if r1 == 0 {
   331			if e1 != 0 {
   332				err = errnoErr(e1)
   333			} else {
   334				err = syscall.EINVAL
   335			}
   336		}
   337		return
   338	}
   339	
   340	func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, tokenInformation uintptr, tokenInformationLength uint32) (err error) {
   341		r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(tokenHandle), uintptr(tokenInformationClass), uintptr(tokenInformation), uintptr(tokenInformationLength), 0, 0)
   342		if r1 == 0 {
   343			if e1 != 0 {
   344				err = errnoErr(e1)
   345			} else {
   346				err = syscall.EINVAL
   347			}
   348		}
   349		return
   350	}
   351	
   352	func GetProfilesDirectory(dir *uint16, dirLen *uint32) (err error) {
   353		r1, _, e1 := syscall.Syscall(procGetProfilesDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)), 0)
   354		if r1 == 0 {
   355			if e1 != 0 {
   356				err = errnoErr(e1)
   357			} else {
   358				err = syscall.EINVAL
   359			}
   360		}
   361		return
   362	}
   363	
   364	func NetUserGetLocalGroups(serverName *uint16, userName *uint16, level uint32, flags uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32) (neterr error) {
   365		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)
   366		if r0 != 0 {
   367			neterr = syscall.Errno(r0)
   368		}
   369		return
   370	}
   371	
   372	func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error) {
   373		r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(memCounters)), uintptr(cb))
   374		if r1 == 0 {
   375			if e1 != 0 {
   376				err = errnoErr(e1)
   377			} else {
   378				err = syscall.EINVAL
   379			}
   380		}
   381		return
   382	}
   383	
   384	func GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error) {
   385		r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(bufsize), 0, 0)
   386		if r1 == 0 {
   387			if e1 != 0 {
   388				err = errnoErr(e1)
   389			} else {
   390				err = syscall.EINVAL
   391			}
   392		}
   393		return
   394	}
   395	

View as plain text