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