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