github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/internal/syscall/windows/zsyscall_windows.go (about)

     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  	errERROR_EINVAL     error = syscall.EINVAL
    22  )
    23  
    24  // errnoErr returns common boxed Errno values, to prevent
    25  // allocations at runtime.
    26  func errnoErr(e syscall.Errno) error {
    27  	switch e {
    28  	case 0:
    29  		return errERROR_EINVAL
    30  	case errnoERROR_IO_PENDING:
    31  		return errERROR_IO_PENDING
    32  	}
    33  	// TODO: add more here, after collecting data on the common
    34  	// error values see on Windows. (perhaps when running
    35  	// all.bat?)
    36  	return e
    37  }
    38  
    39  var (
    40  	modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll"))
    41  	modiphlpapi = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll"))
    42  	modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
    43  	modnetapi32 = syscall.NewLazyDLL(sysdll.Add("netapi32.dll"))
    44  	modpsapi    = syscall.NewLazyDLL(sysdll.Add("psapi.dll"))
    45  	moduserenv  = syscall.NewLazyDLL(sysdll.Add("userenv.dll"))
    46  	modws2_32   = syscall.NewLazyDLL(sysdll.Add("ws2_32.dll"))
    47  
    48  	procAdjustTokenPrivileges         = modadvapi32.NewProc("AdjustTokenPrivileges")
    49  	procDuplicateTokenEx              = modadvapi32.NewProc("DuplicateTokenEx")
    50  	procImpersonateSelf               = modadvapi32.NewProc("ImpersonateSelf")
    51  	procLookupPrivilegeValueW         = modadvapi32.NewProc("LookupPrivilegeValueW")
    52  	procOpenThreadToken               = modadvapi32.NewProc("OpenThreadToken")
    53  	procRevertToSelf                  = modadvapi32.NewProc("RevertToSelf")
    54  	procSetTokenInformation           = modadvapi32.NewProc("SetTokenInformation")
    55  	procSystemFunction036             = modadvapi32.NewProc("SystemFunction036")
    56  	procGetAdaptersAddresses          = modiphlpapi.NewProc("GetAdaptersAddresses")
    57  	procCreateEventW                  = modkernel32.NewProc("CreateEventW")
    58  	procGetACP                        = modkernel32.NewProc("GetACP")
    59  	procGetComputerNameExW            = modkernel32.NewProc("GetComputerNameExW")
    60  	procGetConsoleCP                  = modkernel32.NewProc("GetConsoleCP")
    61  	procGetCurrentThread              = modkernel32.NewProc("GetCurrentThread")
    62  	procGetFileInformationByHandleEx  = modkernel32.NewProc("GetFileInformationByHandleEx")
    63  	procGetFinalPathNameByHandleW     = modkernel32.NewProc("GetFinalPathNameByHandleW")
    64  	procGetModuleFileNameW            = modkernel32.NewProc("GetModuleFileNameW")
    65  	procGetTempPath2W                 = modkernel32.NewProc("GetTempPath2W")
    66  	procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
    67  	procLockFileEx                    = modkernel32.NewProc("LockFileEx")
    68  	procModule32FirstW                = modkernel32.NewProc("Module32FirstW")
    69  	procModule32NextW                 = modkernel32.NewProc("Module32NextW")
    70  	procMoveFileExW                   = modkernel32.NewProc("MoveFileExW")
    71  	procMultiByteToWideChar           = modkernel32.NewProc("MultiByteToWideChar")
    72  	procRtlLookupFunctionEntry        = modkernel32.NewProc("RtlLookupFunctionEntry")
    73  	procRtlVirtualUnwind              = modkernel32.NewProc("RtlVirtualUnwind")
    74  	procSetFileInformationByHandle    = modkernel32.NewProc("SetFileInformationByHandle")
    75  	procUnlockFileEx                  = modkernel32.NewProc("UnlockFileEx")
    76  	procVirtualQuery                  = modkernel32.NewProc("VirtualQuery")
    77  	procNetShareAdd                   = modnetapi32.NewProc("NetShareAdd")
    78  	procNetShareDel                   = modnetapi32.NewProc("NetShareDel")
    79  	procNetUserGetLocalGroups         = modnetapi32.NewProc("NetUserGetLocalGroups")
    80  	procGetProcessMemoryInfo          = modpsapi.NewProc("GetProcessMemoryInfo")
    81  	procCreateEnvironmentBlock        = moduserenv.NewProc("CreateEnvironmentBlock")
    82  	procDestroyEnvironmentBlock       = moduserenv.NewProc("DestroyEnvironmentBlock")
    83  	procGetProfilesDirectoryW         = moduserenv.NewProc("GetProfilesDirectoryW")
    84  	procWSASocketW                    = modws2_32.NewProc("WSASocketW")
    85  )
    86  
    87  func adjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, buflen uint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32) (ret uint32, err error) {
    88  	var _p0 uint32
    89  	if disableAllPrivileges {
    90  		_p0 = 1
    91  	}
    92  	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)))
    93  	ret = uint32(r0)
    94  	if true {
    95  		err = errnoErr(e1)
    96  	}
    97  	return
    98  }
    99  
   100  func DuplicateTokenEx(hExistingToken syscall.Token, dwDesiredAccess uint32, lpTokenAttributes *syscall.SecurityAttributes, impersonationLevel uint32, tokenType TokenType, phNewToken *syscall.Token) (err error) {
   101  	r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(hExistingToken), uintptr(dwDesiredAccess), uintptr(unsafe.Pointer(lpTokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(phNewToken)))
   102  	if r1 == 0 {
   103  		err = errnoErr(e1)
   104  	}
   105  	return
   106  }
   107  
   108  func ImpersonateSelf(impersonationlevel uint32) (err error) {
   109  	r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
   110  	if r1 == 0 {
   111  		err = errnoErr(e1)
   112  	}
   113  	return
   114  }
   115  
   116  func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
   117  	r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
   118  	if r1 == 0 {
   119  		err = errnoErr(e1)
   120  	}
   121  	return
   122  }
   123  
   124  func OpenThreadToken(h syscall.Handle, access uint32, openasself bool, token *syscall.Token) (err error) {
   125  	var _p0 uint32
   126  	if openasself {
   127  		_p0 = 1
   128  	}
   129  	r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(h), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
   130  	if r1 == 0 {
   131  		err = errnoErr(e1)
   132  	}
   133  	return
   134  }
   135  
   136  func RevertToSelf() (err error) {
   137  	r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
   138  	if r1 == 0 {
   139  		err = errnoErr(e1)
   140  	}
   141  	return
   142  }
   143  
   144  func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, tokenInformation uintptr, tokenInformationLength uint32) (err error) {
   145  	r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(tokenHandle), uintptr(tokenInformationClass), uintptr(tokenInformation), uintptr(tokenInformationLength), 0, 0)
   146  	if r1 == 0 {
   147  		err = errnoErr(e1)
   148  	}
   149  	return
   150  }
   151  
   152  func RtlGenRandom(buf []byte) (err error) {
   153  	var _p0 *byte
   154  	if len(buf) > 0 {
   155  		_p0 = &buf[0]
   156  	}
   157  	r1, _, e1 := syscall.Syscall(procSystemFunction036.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), 0)
   158  	if r1 == 0 {
   159  		err = errnoErr(e1)
   160  	}
   161  	return
   162  }
   163  
   164  func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
   165  	r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
   166  	if r0 != 0 {
   167  		errcode = syscall.Errno(r0)
   168  	}
   169  	return
   170  }
   171  
   172  func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle syscall.Handle, err error) {
   173  	r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
   174  	handle = syscall.Handle(r0)
   175  	if handle == 0 {
   176  		err = errnoErr(e1)
   177  	}
   178  	return
   179  }
   180  
   181  func GetACP() (acp uint32) {
   182  	r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
   183  	acp = uint32(r0)
   184  	return
   185  }
   186  
   187  func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) {
   188  	r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
   189  	if r1 == 0 {
   190  		err = errnoErr(e1)
   191  	}
   192  	return
   193  }
   194  
   195  func GetConsoleCP() (ccp uint32) {
   196  	r0, _, _ := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0)
   197  	ccp = uint32(r0)
   198  	return
   199  }
   200  
   201  func GetCurrentThread() (pseudoHandle syscall.Handle, err error) {
   202  	r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
   203  	pseudoHandle = syscall.Handle(r0)
   204  	if pseudoHandle == 0 {
   205  		err = errnoErr(e1)
   206  	}
   207  	return
   208  }
   209  
   210  func GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error) {
   211  	r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(bufsize), 0, 0)
   212  	if r1 == 0 {
   213  		err = errnoErr(e1)
   214  	}
   215  	return
   216  }
   217  
   218  func GetFinalPathNameByHandle(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
   219  	r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0)
   220  	n = uint32(r0)
   221  	if n == 0 {
   222  		err = errnoErr(e1)
   223  	}
   224  	return
   225  }
   226  
   227  func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) {
   228  	r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len))
   229  	n = uint32(r0)
   230  	if n == 0 {
   231  		err = errnoErr(e1)
   232  	}
   233  	return
   234  }
   235  
   236  func GetTempPath2(buflen uint32, buf *uint16) (n uint32, err error) {
   237  	r0, _, e1 := syscall.Syscall(procGetTempPath2W.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
   238  	n = uint32(r0)
   239  	if n == 0 {
   240  		err = errnoErr(e1)
   241  	}
   242  	return
   243  }
   244  
   245  func GetVolumeInformationByHandle(file syscall.Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
   246  	r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
   247  	if r1 == 0 {
   248  		err = errnoErr(e1)
   249  	}
   250  	return
   251  }
   252  
   253  func LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
   254  	r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
   255  	if r1 == 0 {
   256  		err = errnoErr(e1)
   257  	}
   258  	return
   259  }
   260  
   261  func Module32First(snapshot syscall.Handle, moduleEntry *ModuleEntry32) (err error) {
   262  	r1, _, e1 := syscall.Syscall(procModule32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0)
   263  	if r1 == 0 {
   264  		err = errnoErr(e1)
   265  	}
   266  	return
   267  }
   268  
   269  func Module32Next(snapshot syscall.Handle, moduleEntry *ModuleEntry32) (err error) {
   270  	r1, _, e1 := syscall.Syscall(procModule32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0)
   271  	if r1 == 0 {
   272  		err = errnoErr(e1)
   273  	}
   274  	return
   275  }
   276  
   277  func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
   278  	r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
   279  	if r1 == 0 {
   280  		err = errnoErr(e1)
   281  	}
   282  	return
   283  }
   284  
   285  func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
   286  	r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
   287  	nwrite = int32(r0)
   288  	if nwrite == 0 {
   289  		err = errnoErr(e1)
   290  	}
   291  	return
   292  }
   293  
   294  func RtlLookupFunctionEntry(pc uintptr, baseAddress *uintptr, table *byte) (ret uintptr) {
   295  	r0, _, _ := syscall.Syscall(procRtlLookupFunctionEntry.Addr(), 3, uintptr(pc), uintptr(unsafe.Pointer(baseAddress)), uintptr(unsafe.Pointer(table)))
   296  	ret = uintptr(r0)
   297  	return
   298  }
   299  
   300  func RtlVirtualUnwind(handlerType uint32, baseAddress uintptr, pc uintptr, entry uintptr, ctxt uintptr, data *uintptr, frame *uintptr, ctxptrs *byte) (ret uintptr) {
   301  	r0, _, _ := syscall.Syscall9(procRtlVirtualUnwind.Addr(), 8, uintptr(handlerType), uintptr(baseAddress), uintptr(pc), uintptr(entry), uintptr(ctxt), uintptr(unsafe.Pointer(data)), uintptr(unsafe.Pointer(frame)), uintptr(unsafe.Pointer(ctxptrs)), 0)
   302  	ret = uintptr(r0)
   303  	return
   304  }
   305  
   306  func SetFileInformationByHandle(handle syscall.Handle, fileInformationClass uint32, buf uintptr, bufsize uint32) (err error) {
   307  	r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(fileInformationClass), uintptr(buf), uintptr(bufsize), 0, 0)
   308  	if r1 == 0 {
   309  		err = errnoErr(e1)
   310  	}
   311  	return
   312  }
   313  
   314  func UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
   315  	r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
   316  	if r1 == 0 {
   317  		err = errnoErr(e1)
   318  	}
   319  	return
   320  }
   321  
   322  func VirtualQuery(address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) {
   323  	r1, _, e1 := syscall.Syscall(procVirtualQuery.Addr(), 3, uintptr(address), uintptr(unsafe.Pointer(buffer)), uintptr(length))
   324  	if r1 == 0 {
   325  		err = errnoErr(e1)
   326  	}
   327  	return
   328  }
   329  
   330  func NetShareAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint16) (neterr error) {
   331  	r0, _, _ := syscall.Syscall6(procNetShareAdd.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(parmErr)), 0, 0)
   332  	if r0 != 0 {
   333  		neterr = syscall.Errno(r0)
   334  	}
   335  	return
   336  }
   337  
   338  func NetShareDel(serverName *uint16, netName *uint16, reserved uint32) (neterr error) {
   339  	r0, _, _ := syscall.Syscall(procNetShareDel.Addr(), 3, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(netName)), uintptr(reserved))
   340  	if r0 != 0 {
   341  		neterr = syscall.Errno(r0)
   342  	}
   343  	return
   344  }
   345  
   346  func NetUserGetLocalGroups(serverName *uint16, userName *uint16, level uint32, flags uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32) (neterr error) {
   347  	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)
   348  	if r0 != 0 {
   349  		neterr = syscall.Errno(r0)
   350  	}
   351  	return
   352  }
   353  
   354  func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error) {
   355  	r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(memCounters)), uintptr(cb))
   356  	if r1 == 0 {
   357  		err = errnoErr(e1)
   358  	}
   359  	return
   360  }
   361  
   362  func CreateEnvironmentBlock(block **uint16, token syscall.Token, inheritExisting bool) (err error) {
   363  	var _p0 uint32
   364  	if inheritExisting {
   365  		_p0 = 1
   366  	}
   367  	r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
   368  	if r1 == 0 {
   369  		err = errnoErr(e1)
   370  	}
   371  	return
   372  }
   373  
   374  func DestroyEnvironmentBlock(block *uint16) (err error) {
   375  	r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
   376  	if r1 == 0 {
   377  		err = errnoErr(e1)
   378  	}
   379  	return
   380  }
   381  
   382  func GetProfilesDirectory(dir *uint16, dirLen *uint32) (err error) {
   383  	r1, _, e1 := syscall.Syscall(procGetProfilesDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)), 0)
   384  	if r1 == 0 {
   385  		err = errnoErr(e1)
   386  	}
   387  	return
   388  }
   389  
   390  func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (handle syscall.Handle, err error) {
   391  	r0, _, e1 := syscall.Syscall6(procWSASocketW.Addr(), 6, uintptr(af), uintptr(typ), uintptr(protocol), uintptr(unsafe.Pointer(protinfo)), uintptr(group), uintptr(flags))
   392  	handle = syscall.Handle(r0)
   393  	if handle == syscall.InvalidHandle {
   394  		err = errnoErr(e1)
   395  	}
   396  	return
   397  }