github.com/elijahmorg/goternal@v1.18.0/syscall/windows/zsyscall_windows.go (about)

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