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  	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  	modbcryptprimitives = syscall.NewLazyDLL(sysdll.Add("bcryptprimitives.dll"))
    42  	modiphlpapi         = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll"))
    43  	modkernel32         = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
    44  	modnetapi32         = syscall.NewLazyDLL(sysdll.Add("netapi32.dll"))
    45  	modntdll            = syscall.NewLazyDLL(sysdll.Add("ntdll.dll"))
    46  	modpsapi            = syscall.NewLazyDLL(sysdll.Add("psapi.dll"))
    47  	moduserenv          = syscall.NewLazyDLL(sysdll.Add("userenv.dll"))
    48  	modws2_32           = syscall.NewLazyDLL(sysdll.Add("ws2_32.dll"))
    49  
    50  	procAdjustTokenPrivileges             = modadvapi32.NewProc("AdjustTokenPrivileges")
    51  	procDuplicateTokenEx                  = modadvapi32.NewProc("DuplicateTokenEx")
    52  	procFreeSid                           = modadvapi32.NewProc("FreeSid")
    53  	procGetSidIdentifierAuthority         = modadvapi32.NewProc("GetSidIdentifierAuthority")
    54  	procGetSidSubAuthority                = modadvapi32.NewProc("GetSidSubAuthority")
    55  	procGetSidSubAuthorityCount           = modadvapi32.NewProc("GetSidSubAuthorityCount")
    56  	procImpersonateLoggedOnUser           = modadvapi32.NewProc("ImpersonateLoggedOnUser")
    57  	procImpersonateSelf                   = modadvapi32.NewProc("ImpersonateSelf")
    58  	procIsValidSid                        = modadvapi32.NewProc("IsValidSid")
    59  	procLogonUserW                        = modadvapi32.NewProc("LogonUserW")
    60  	procLookupPrivilegeValueW             = modadvapi32.NewProc("LookupPrivilegeValueW")
    61  	procOpenSCManagerW                    = modadvapi32.NewProc("OpenSCManagerW")
    62  	procOpenServiceW                      = modadvapi32.NewProc("OpenServiceW")
    63  	procOpenThreadToken                   = modadvapi32.NewProc("OpenThreadToken")
    64  	procQueryServiceStatus                = modadvapi32.NewProc("QueryServiceStatus")
    65  	procRevertToSelf                      = modadvapi32.NewProc("RevertToSelf")
    66  	procSetEntriesInAclW                  = modadvapi32.NewProc("SetEntriesInAclW")
    67  	procSetNamedSecurityInfoW             = modadvapi32.NewProc("SetNamedSecurityInfoW")
    68  	procSetTokenInformation               = modadvapi32.NewProc("SetTokenInformation")
    69  	procProcessPrng                       = modbcryptprimitives.NewProc("ProcessPrng")
    70  	procGetAdaptersAddresses              = modiphlpapi.NewProc("GetAdaptersAddresses")
    71  	procCancelSynchronousIo               = modkernel32.NewProc("CancelSynchronousIo")
    72  	procCreateEventW                      = modkernel32.NewProc("CreateEventW")
    73  	procCreateIoCompletionPort            = modkernel32.NewProc("CreateIoCompletionPort")
    74  	procCreateJobObjectW                  = modkernel32.NewProc("CreateJobObjectW")
    75  	procCreateNamedPipeW                  = modkernel32.NewProc("CreateNamedPipeW")
    76  	procGetACP                            = modkernel32.NewProc("GetACP")
    77  	procGetComputerNameExW                = modkernel32.NewProc("GetComputerNameExW")
    78  	procGetConsoleCP                      = modkernel32.NewProc("GetConsoleCP")
    79  	procGetCurrentThread                  = modkernel32.NewProc("GetCurrentThread")
    80  	procGetFileInformationByHandleEx      = modkernel32.NewProc("GetFileInformationByHandleEx")
    81  	procGetFileSizeEx                     = modkernel32.NewProc("GetFileSizeEx")
    82  	procGetFinalPathNameByHandleW         = modkernel32.NewProc("GetFinalPathNameByHandleW")
    83  	procGetModuleFileNameW                = modkernel32.NewProc("GetModuleFileNameW")
    84  	procGetModuleHandleW                  = modkernel32.NewProc("GetModuleHandleW")
    85  	procGetOverlappedResult               = modkernel32.NewProc("GetOverlappedResult")
    86  	procGetTempPath2W                     = modkernel32.NewProc("GetTempPath2W")
    87  	procGetVolumeInformationByHandleW     = modkernel32.NewProc("GetVolumeInformationByHandleW")
    88  	procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
    89  	procIsProcessorFeaturePresent         = modkernel32.NewProc("IsProcessorFeaturePresent")
    90  	procLockFileEx                        = modkernel32.NewProc("LockFileEx")
    91  	procModule32FirstW                    = modkernel32.NewProc("Module32FirstW")
    92  	procModule32NextW                     = modkernel32.NewProc("Module32NextW")
    93  	procMoveFileExW                       = modkernel32.NewProc("MoveFileExW")
    94  	procMultiByteToWideChar               = modkernel32.NewProc("MultiByteToWideChar")
    95  	procReOpenFile                        = modkernel32.NewProc("ReOpenFile")
    96  	procRtlLookupFunctionEntry            = modkernel32.NewProc("RtlLookupFunctionEntry")
    97  	procRtlVirtualUnwind                  = modkernel32.NewProc("RtlVirtualUnwind")
    98  	procSetFileInformationByHandle        = modkernel32.NewProc("SetFileInformationByHandle")
    99  	procSetInformationJobObject           = modkernel32.NewProc("SetInformationJobObject")
   100  	procUnlockFileEx                      = modkernel32.NewProc("UnlockFileEx")
   101  	procVirtualQuery                      = modkernel32.NewProc("VirtualQuery")
   102  	procNetShareAdd                       = modnetapi32.NewProc("NetShareAdd")
   103  	procNetShareDel                       = modnetapi32.NewProc("NetShareDel")
   104  	procNetUserAdd                        = modnetapi32.NewProc("NetUserAdd")
   105  	procNetUserDel                        = modnetapi32.NewProc("NetUserDel")
   106  	procNetUserGetLocalGroups             = modnetapi32.NewProc("NetUserGetLocalGroups")
   107  	procNtCreateFile                      = modntdll.NewProc("NtCreateFile")
   108  	procNtOpenFile                        = modntdll.NewProc("NtOpenFile")
   109  	procNtQueryInformationFile            = modntdll.NewProc("NtQueryInformationFile")
   110  	procNtSetInformationFile              = modntdll.NewProc("NtSetInformationFile")
   111  	procRtlGetVersion                     = modntdll.NewProc("RtlGetVersion")
   112  	procRtlIsDosDeviceName_U              = modntdll.NewProc("RtlIsDosDeviceName_U")
   113  	procRtlNtStatusToDosErrorNoTeb        = modntdll.NewProc("RtlNtStatusToDosErrorNoTeb")
   114  	procGetProcessMemoryInfo              = modpsapi.NewProc("GetProcessMemoryInfo")
   115  	procCreateAppContainerProfile         = moduserenv.NewProc("CreateAppContainerProfile")
   116  	procCreateEnvironmentBlock            = moduserenv.NewProc("CreateEnvironmentBlock")
   117  	procDeleteAppContainerProfile         = moduserenv.NewProc("DeleteAppContainerProfile")
   118  	procDestroyEnvironmentBlock           = moduserenv.NewProc("DestroyEnvironmentBlock")
   119  	procGetProfilesDirectoryW             = moduserenv.NewProc("GetProfilesDirectoryW")
   120  	procWSADuplicateSocketW               = modws2_32.NewProc("WSADuplicateSocketW")
   121  	procWSAGetOverlappedResult            = modws2_32.NewProc("WSAGetOverlappedResult")
   122  	procWSASocketW                        = modws2_32.NewProc("WSASocketW")
   123  )
   124  
   125  func adjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, buflen uint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32) (ret uint32, err error) {
   126  	var _p0 uint32
   127  	if disableAllPrivileges {
   128  		_p0 = 1
   129  	}
   130  	r0, _, e1 := syscall.SyscallN(procAdjustTokenPrivileges.Addr(), uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
   131  	ret = uint32(r0)
   132  	if true {
   133  		err = errnoErr(e1)
   134  	}
   135  	return
   136  }
   137  
   138  func DuplicateTokenEx(hExistingToken syscall.Token, dwDesiredAccess uint32, lpTokenAttributes *syscall.SecurityAttributes, impersonationLevel uint32, tokenType TokenType, phNewToken *syscall.Token) (err error) {
   139  	r1, _, e1 := syscall.SyscallN(procDuplicateTokenEx.Addr(), uintptr(hExistingToken), uintptr(dwDesiredAccess), uintptr(unsafe.Pointer(lpTokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(phNewToken)))
   140  	if uint32(r1) == 0 {
   141  		err = errnoErr(e1)
   142  	}
   143  	return
   144  }
   145  
   146  func freeSid(sid *syscall.SID) (rsid *syscall.SID) {
   147  	r0, _, _ := syscall.SyscallN(procFreeSid.Addr(), uintptr(unsafe.Pointer(sid)))
   148  	rsid = (*syscall.SID)(unsafe.Pointer(r0))
   149  	return
   150  }
   151  
   152  func getSidIdentifierAuthority(sid *syscall.SID) (idauth uintptr) {
   153  	r0, _, _ := syscall.SyscallN(procGetSidIdentifierAuthority.Addr(), uintptr(unsafe.Pointer(sid)))
   154  	idauth = uintptr(r0)
   155  	return
   156  }
   157  
   158  func getSidSubAuthority(sid *syscall.SID, subAuthorityIdx uint32) (subAuth uintptr) {
   159  	r0, _, _ := syscall.SyscallN(procGetSidSubAuthority.Addr(), uintptr(unsafe.Pointer(sid)), uintptr(subAuthorityIdx))
   160  	subAuth = uintptr(r0)
   161  	return
   162  }
   163  
   164  func getSidSubAuthorityCount(sid *syscall.SID) (count uintptr) {
   165  	r0, _, _ := syscall.SyscallN(procGetSidSubAuthorityCount.Addr(), uintptr(unsafe.Pointer(sid)))
   166  	count = uintptr(r0)
   167  	return
   168  }
   169  
   170  func ImpersonateLoggedOnUser(token syscall.Token) (err error) {
   171  	r1, _, e1 := syscall.SyscallN(procImpersonateLoggedOnUser.Addr(), uintptr(token))
   172  	if uint32(r1) == 0 {
   173  		err = errnoErr(e1)
   174  	}
   175  	return
   176  }
   177  
   178  func ImpersonateSelf(impersonationlevel uint32) (err error) {
   179  	r1, _, e1 := syscall.SyscallN(procImpersonateSelf.Addr(), uintptr(impersonationlevel))
   180  	if uint32(r1) == 0 {
   181  		err = errnoErr(e1)
   182  	}
   183  	return
   184  }
   185  
   186  func IsValidSid(sid *syscall.SID) (valid bool) {
   187  	r0, _, _ := syscall.SyscallN(procIsValidSid.Addr(), uintptr(unsafe.Pointer(sid)))
   188  	valid = uint32(r0) != 0
   189  	return
   190  }
   191  
   192  func LogonUser(username *uint16, domain *uint16, password *uint16, logonType uint32, logonProvider uint32, token *syscall.Token) (err error) {
   193  	r1, _, e1 := syscall.SyscallN(procLogonUserW.Addr(), uintptr(unsafe.Pointer(username)), uintptr(unsafe.Pointer(domain)), uintptr(unsafe.Pointer(password)), uintptr(logonType), uintptr(logonProvider), uintptr(unsafe.Pointer(token)))
   194  	if uint32(r1) == 0 {
   195  		err = errnoErr(e1)
   196  	}
   197  	return
   198  }
   199  
   200  func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
   201  	r1, _, e1 := syscall.SyscallN(procLookupPrivilegeValueW.Addr(), uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
   202  	if uint32(r1) == 0 {
   203  		err = errnoErr(e1)
   204  	}
   205  	return
   206  }
   207  
   208  func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle syscall.Handle, err error) {
   209  	r0, _, e1 := syscall.SyscallN(procOpenSCManagerW.Addr(), uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
   210  	handle = syscall.Handle(r0)
   211  	if handle == 0 {
   212  		err = errnoErr(e1)
   213  	}
   214  	return
   215  }
   216  
   217  func OpenService(mgr syscall.Handle, serviceName *uint16, access uint32) (handle syscall.Handle, err error) {
   218  	r0, _, e1 := syscall.SyscallN(procOpenServiceW.Addr(), uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
   219  	handle = syscall.Handle(r0)
   220  	if handle == 0 {
   221  		err = errnoErr(e1)
   222  	}
   223  	return
   224  }
   225  
   226  func OpenThreadToken(h syscall.Handle, access uint32, openasself bool, token *syscall.Token) (err error) {
   227  	var _p0 uint32
   228  	if openasself {
   229  		_p0 = 1
   230  	}
   231  	r1, _, e1 := syscall.SyscallN(procOpenThreadToken.Addr(), uintptr(h), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)))
   232  	if uint32(r1) == 0 {
   233  		err = errnoErr(e1)
   234  	}
   235  	return
   236  }
   237  
   238  func QueryServiceStatus(hService syscall.Handle, lpServiceStatus *SERVICE_STATUS) (err error) {
   239  	r1, _, e1 := syscall.SyscallN(procQueryServiceStatus.Addr(), uintptr(hService), uintptr(unsafe.Pointer(lpServiceStatus)))
   240  	if uint32(r1) == 0 {
   241  		err = errnoErr(e1)
   242  	}
   243  	return
   244  }
   245  
   246  func RevertToSelf() (err error) {
   247  	r1, _, e1 := syscall.SyscallN(procRevertToSelf.Addr())
   248  	if uint32(r1) == 0 {
   249  		err = errnoErr(e1)
   250  	}
   251  	return
   252  }
   253  
   254  func SetEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) {
   255  	r0, _, _ := syscall.SyscallN(procSetEntriesInAclW.Addr(), uintptr(countExplicitEntries), uintptr(unsafe.Pointer(explicitEntries)), uintptr(unsafe.Pointer(oldACL)), uintptr(unsafe.Pointer(newACL)))
   256  	if uint32(r0) != 0 {
   257  		ret = syscall.Errno(uint32(r0))
   258  	}
   259  	return
   260  }
   261  
   262  func SetNamedSecurityInfo(objectName string, objectType uint32, securityInformation uint32, owner *syscall.SID, group *syscall.SID, dacl *ACL, sacl *ACL) (ret error) {
   263  	var _p0 *uint16
   264  	_p0, ret = syscall.UTF16PtrFromString(objectName)
   265  	if ret != nil {
   266  		return
   267  	}
   268  	return _SetNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl)
   269  }
   270  
   271  func _SetNamedSecurityInfo(objectName *uint16, objectType uint32, securityInformation uint32, owner *syscall.SID, group *syscall.SID, dacl *ACL, sacl *ACL) (ret error) {
   272  	r0, _, _ := syscall.SyscallN(procSetNamedSecurityInfoW.Addr(), uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)))
   273  	if uint32(r0) != 0 {
   274  		ret = syscall.Errno(uint32(r0))
   275  	}
   276  	return
   277  }
   278  
   279  func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, tokenInformation unsafe.Pointer, tokenInformationLength uint32) (err error) {
   280  	r1, _, e1 := syscall.SyscallN(procSetTokenInformation.Addr(), uintptr(tokenHandle), uintptr(tokenInformationClass), uintptr(tokenInformation), uintptr(tokenInformationLength))
   281  	if uint32(r1) == 0 {
   282  		err = errnoErr(e1)
   283  	}
   284  	return
   285  }
   286  
   287  func ProcessPrng(buf []byte) (err error) {
   288  	var _p0 *byte
   289  	if len(buf) > 0 {
   290  		_p0 = &buf[0]
   291  	}
   292  	r1, _, e1 := syscall.SyscallN(procProcessPrng.Addr(), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)))
   293  	if uint32(r1) == 0 {
   294  		err = errnoErr(e1)
   295  	}
   296  	return
   297  }
   298  
   299  func GetAdaptersAddresses(family uint32, flags uint32, reserved unsafe.Pointer, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
   300  	r0, _, _ := syscall.SyscallN(procGetAdaptersAddresses.Addr(), uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)))
   301  	if uint32(r0) != 0 {
   302  		errcode = syscall.Errno(uint32(r0))
   303  	}
   304  	return
   305  }
   306  
   307  func CancelSynchronousIo(thread syscall.Handle) (err error) {
   308  	r1, _, e1 := syscall.SyscallN(procCancelSynchronousIo.Addr(), uintptr(thread))
   309  	if uint32(r1) == 0 {
   310  		err = errnoErr(e1)
   311  	}
   312  	return
   313  }
   314  
   315  func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle syscall.Handle, err error) {
   316  	r0, _, e1 := syscall.SyscallN(procCreateEventW.Addr(), uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)))
   317  	handle = syscall.Handle(r0)
   318  	if handle == 0 {
   319  		err = errnoErr(e1)
   320  	}
   321  	return
   322  }
   323  
   324  func CreateIoCompletionPort(filehandle syscall.Handle, cphandle syscall.Handle, key uintptr, threadcnt uint32) (handle syscall.Handle, err error) {
   325  	r0, _, e1 := syscall.SyscallN(procCreateIoCompletionPort.Addr(), uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt))
   326  	handle = syscall.Handle(r0)
   327  	if handle == 0 {
   328  		err = errnoErr(e1)
   329  	}
   330  	return
   331  }
   332  
   333  func CreateJobObject(jobAttrs *syscall.SecurityAttributes, name *uint16) (handle syscall.Handle, err error) {
   334  	r0, _, e1 := syscall.SyscallN(procCreateJobObjectW.Addr(), uintptr(unsafe.Pointer(jobAttrs)), uintptr(unsafe.Pointer(name)))
   335  	handle = syscall.Handle(r0)
   336  	if handle == 0 {
   337  		err = errnoErr(e1)
   338  	}
   339  	return
   340  }
   341  
   342  func CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
   343  	r0, _, e1 := syscall.SyscallN(procCreateNamedPipeW.Addr(), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)))
   344  	handle = syscall.Handle(r0)
   345  	if handle == syscall.InvalidHandle {
   346  		err = errnoErr(e1)
   347  	}
   348  	return
   349  }
   350  
   351  func GetACP() (acp uint32) {
   352  	r0, _, _ := syscall.SyscallN(procGetACP.Addr())
   353  	acp = uint32(r0)
   354  	return
   355  }
   356  
   357  func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) {
   358  	r1, _, e1 := syscall.SyscallN(procGetComputerNameExW.Addr(), uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
   359  	if uint32(r1) == 0 {
   360  		err = errnoErr(e1)
   361  	}
   362  	return
   363  }
   364  
   365  func GetConsoleCP() (ccp uint32) {
   366  	r0, _, _ := syscall.SyscallN(procGetConsoleCP.Addr())
   367  	ccp = uint32(r0)
   368  	return
   369  }
   370  
   371  func GetCurrentThread() (pseudoHandle syscall.Handle, err error) {
   372  	r0, _, e1 := syscall.SyscallN(procGetCurrentThread.Addr())
   373  	pseudoHandle = syscall.Handle(r0)
   374  	if pseudoHandle == 0 {
   375  		err = errnoErr(e1)
   376  	}
   377  	return
   378  }
   379  
   380  func GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error) {
   381  	r1, _, e1 := syscall.SyscallN(procGetFileInformationByHandleEx.Addr(), uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(bufsize))
   382  	if uint32(r1) == 0 {
   383  		err = errnoErr(e1)
   384  	}
   385  	return
   386  }
   387  
   388  func GetFileSizeEx(handle syscall.Handle, size *int64) (err error) {
   389  	r1, _, e1 := syscall.SyscallN(procGetFileSizeEx.Addr(), uintptr(handle), uintptr(unsafe.Pointer(size)))
   390  	if uint32(r1) == 0 {
   391  		err = errnoErr(e1)
   392  	}
   393  	return
   394  }
   395  
   396  func GetFinalPathNameByHandle(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
   397  	r0, _, e1 := syscall.SyscallN(procGetFinalPathNameByHandleW.Addr(), uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags))
   398  	n = uint32(r0)
   399  	if n == 0 {
   400  		err = errnoErr(e1)
   401  	}
   402  	return
   403  }
   404  
   405  func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) {
   406  	r0, _, e1 := syscall.SyscallN(procGetModuleFileNameW.Addr(), uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len))
   407  	n = uint32(r0)
   408  	if n == 0 {
   409  		err = errnoErr(e1)
   410  	}
   411  	return
   412  }
   413  
   414  func GetModuleHandle(modulename *uint16) (handle syscall.Handle, err error) {
   415  	r0, _, e1 := syscall.SyscallN(procGetModuleHandleW.Addr(), uintptr(unsafe.Pointer(modulename)))
   416  	handle = syscall.Handle(r0)
   417  	if handle == 0 {
   418  		err = errnoErr(e1)
   419  	}
   420  	return
   421  }
   422  
   423  func GetOverlappedResult(handle syscall.Handle, overlapped *syscall.Overlapped, done *uint32, wait bool) (err error) {
   424  	var _p0 uint32
   425  	if wait {
   426  		_p0 = 1
   427  	}
   428  	r1, _, e1 := syscall.SyscallN(procGetOverlappedResult.Addr(), uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0))
   429  	if uint32(r1) == 0 {
   430  		err = errnoErr(e1)
   431  	}
   432  	return
   433  }
   434  
   435  func GetTempPath2(buflen uint32, buf *uint16) (n uint32, err error) {
   436  	r0, _, e1 := syscall.SyscallN(procGetTempPath2W.Addr(), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
   437  	n = uint32(r0)
   438  	if n == 0 {
   439  		err = errnoErr(e1)
   440  	}
   441  	return
   442  }
   443  
   444  func GetVolumeInformationByHandle(file syscall.Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
   445  	r1, _, e1 := syscall.SyscallN(procGetVolumeInformationByHandleW.Addr(), 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))
   446  	if uint32(r1) == 0 {
   447  		err = errnoErr(e1)
   448  	}
   449  	return
   450  }
   451  
   452  func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
   453  	r1, _, e1 := syscall.SyscallN(procGetVolumeNameForVolumeMountPointW.Addr(), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
   454  	if uint32(r1) == 0 {
   455  		err = errnoErr(e1)
   456  	}
   457  	return
   458  }
   459  
   460  func IsProcessorFeaturePresent(ProcessorFeature uint32) (ret bool) {
   461  	r0, _, _ := syscall.SyscallN(procIsProcessorFeaturePresent.Addr(), uintptr(ProcessorFeature))
   462  	ret = uint32(r0) != 0
   463  	return
   464  }
   465  
   466  func LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
   467  	r1, _, e1 := syscall.SyscallN(procLockFileEx.Addr(), uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
   468  	if uint32(r1) == 0 {
   469  		err = errnoErr(e1)
   470  	}
   471  	return
   472  }
   473  
   474  func Module32First(snapshot syscall.Handle, moduleEntry *ModuleEntry32) (err error) {
   475  	r1, _, e1 := syscall.SyscallN(procModule32FirstW.Addr(), uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)))
   476  	if uint32(r1) == 0 {
   477  		err = errnoErr(e1)
   478  	}
   479  	return
   480  }
   481  
   482  func Module32Next(snapshot syscall.Handle, moduleEntry *ModuleEntry32) (err error) {
   483  	r1, _, e1 := syscall.SyscallN(procModule32NextW.Addr(), uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)))
   484  	if uint32(r1) == 0 {
   485  		err = errnoErr(e1)
   486  	}
   487  	return
   488  }
   489  
   490  func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
   491  	r1, _, e1 := syscall.SyscallN(procMoveFileExW.Addr(), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
   492  	if uint32(r1) == 0 {
   493  		err = errnoErr(e1)
   494  	}
   495  	return
   496  }
   497  
   498  func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
   499  	r0, _, e1 := syscall.SyscallN(procMultiByteToWideChar.Addr(), uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
   500  	nwrite = int32(r0)
   501  	if nwrite == 0 {
   502  		err = errnoErr(e1)
   503  	}
   504  	return
   505  }
   506  
   507  func ReOpenFile(filehandle syscall.Handle, desiredAccess uint32, shareMode uint32, flagAndAttributes uint32) (handle syscall.Handle, err error) {
   508  	r0, _, e1 := syscall.SyscallN(procReOpenFile.Addr(), uintptr(filehandle), uintptr(desiredAccess), uintptr(shareMode), uintptr(flagAndAttributes))
   509  	handle = syscall.Handle(r0)
   510  	if handle == syscall.InvalidHandle {
   511  		err = errnoErr(e1)
   512  	}
   513  	return
   514  }
   515  
   516  func RtlLookupFunctionEntry(pc uintptr, baseAddress *uintptr, table unsafe.Pointer) (ret *RUNTIME_FUNCTION) {
   517  	r0, _, _ := syscall.SyscallN(procRtlLookupFunctionEntry.Addr(), uintptr(pc), uintptr(unsafe.Pointer(baseAddress)), uintptr(table))
   518  	ret = (*RUNTIME_FUNCTION)(unsafe.Pointer(r0))
   519  	return
   520  }
   521  
   522  func RtlVirtualUnwind(handlerType uint32, baseAddress uintptr, pc uintptr, entry *RUNTIME_FUNCTION, ctxt unsafe.Pointer, data unsafe.Pointer, frame *uintptr, ctxptrs unsafe.Pointer) (ret uintptr) {
   523  	r0, _, _ := syscall.SyscallN(procRtlVirtualUnwind.Addr(), uintptr(handlerType), uintptr(baseAddress), uintptr(pc), uintptr(unsafe.Pointer(entry)), uintptr(ctxt), uintptr(data), uintptr(unsafe.Pointer(frame)), uintptr(ctxptrs))
   524  	ret = uintptr(r0)
   525  	return
   526  }
   527  
   528  func SetFileInformationByHandle(handle syscall.Handle, fileInformationClass uint32, buf unsafe.Pointer, bufsize uint32) (err error) {
   529  	r1, _, e1 := syscall.SyscallN(procSetFileInformationByHandle.Addr(), uintptr(handle), uintptr(fileInformationClass), uintptr(buf), uintptr(bufsize))
   530  	if uint32(r1) == 0 {
   531  		err = errnoErr(e1)
   532  	}
   533  	return
   534  }
   535  
   536  func SetInformationJobObject(job syscall.Handle, infoclass uint32, info uintptr, infolien uint32) (err error) {
   537  	r1, _, e1 := syscall.SyscallN(procSetInformationJobObject.Addr(), uintptr(job), uintptr(infoclass), uintptr(info), uintptr(infolien))
   538  	if uint32(r1) == 0 {
   539  		err = errnoErr(e1)
   540  	}
   541  	return
   542  }
   543  
   544  func UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
   545  	r1, _, e1 := syscall.SyscallN(procUnlockFileEx.Addr(), uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
   546  	if uint32(r1) == 0 {
   547  		err = errnoErr(e1)
   548  	}
   549  	return
   550  }
   551  
   552  func VirtualQuery(address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) {
   553  	r1, _, e1 := syscall.SyscallN(procVirtualQuery.Addr(), uintptr(address), uintptr(unsafe.Pointer(buffer)), uintptr(length))
   554  	if uint32(r1) == 0 {
   555  		err = errnoErr(e1)
   556  	}
   557  	return
   558  }
   559  
   560  func NetShareAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint16) (neterr error) {
   561  	r0, _, _ := syscall.SyscallN(procNetShareAdd.Addr(), uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(parmErr)))
   562  	if uint32(r0) != 0 {
   563  		neterr = syscall.Errno(uint32(r0))
   564  	}
   565  	return
   566  }
   567  
   568  func NetShareDel(serverName *uint16, netName *uint16, reserved uint32) (neterr error) {
   569  	r0, _, _ := syscall.SyscallN(procNetShareDel.Addr(), uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(netName)), uintptr(reserved))
   570  	if uint32(r0) != 0 {
   571  		neterr = syscall.Errno(uint32(r0))
   572  	}
   573  	return
   574  }
   575  
   576  func NetUserAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint32) (neterr error) {
   577  	r0, _, _ := syscall.SyscallN(procNetUserAdd.Addr(), uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(parmErr)))
   578  	if uint32(r0) != 0 {
   579  		neterr = syscall.Errno(uint32(r0))
   580  	}
   581  	return
   582  }
   583  
   584  func NetUserDel(serverName *uint16, userName *uint16) (neterr error) {
   585  	r0, _, _ := syscall.SyscallN(procNetUserDel.Addr(), uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)))
   586  	if uint32(r0) != 0 {
   587  		neterr = syscall.Errno(uint32(r0))
   588  	}
   589  	return
   590  }
   591  
   592  func NetUserGetLocalGroups(serverName *uint16, userName *uint16, level uint32, flags uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32) (neterr error) {
   593  	r0, _, _ := syscall.SyscallN(procNetUserGetLocalGroups.Addr(), 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)))
   594  	if uint32(r0) != 0 {
   595  		neterr = syscall.Errno(uint32(r0))
   596  	}
   597  	return
   598  }
   599  
   600  func NtCreateFile(handle *syscall.Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, allocationSize *int64, attributes uint32, share uint32, disposition uint32, options uint32, eabuffer unsafe.Pointer, ealength uint32) (ntstatus error) {
   601  	r0, _, _ := syscall.SyscallN(procNtCreateFile.Addr(), uintptr(unsafe.Pointer(handle)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(allocationSize)), uintptr(attributes), uintptr(share), uintptr(disposition), uintptr(options), uintptr(eabuffer), uintptr(ealength))
   602  	if uint32(r0) != 0 {
   603  		ntstatus = NTStatus(uint32(r0))
   604  	}
   605  	return
   606  }
   607  
   608  func NtOpenFile(handle *syscall.Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, share uint32, options uint32) (ntstatus error) {
   609  	r0, _, _ := syscall.SyscallN(procNtOpenFile.Addr(), uintptr(unsafe.Pointer(handle)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(share), uintptr(options))
   610  	if uint32(r0) != 0 {
   611  		ntstatus = NTStatus(uint32(r0))
   612  	}
   613  	return
   614  }
   615  
   616  func NtQueryInformationFile(handle syscall.Handle, iosb *IO_STATUS_BLOCK, inBuffer unsafe.Pointer, inBufferLen uint32, class uint32) (ntstatus error) {
   617  	r0, _, _ := syscall.SyscallN(procNtQueryInformationFile.Addr(), uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(inBuffer), uintptr(inBufferLen), uintptr(class))
   618  	if uint32(r0) != 0 {
   619  		ntstatus = NTStatus(uint32(r0))
   620  	}
   621  	return
   622  }
   623  
   624  func NtSetInformationFile(handle syscall.Handle, iosb *IO_STATUS_BLOCK, inBuffer unsafe.Pointer, inBufferLen uint32, class uint32) (ntstatus error) {
   625  	r0, _, _ := syscall.SyscallN(procNtSetInformationFile.Addr(), uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(inBuffer), uintptr(inBufferLen), uintptr(class))
   626  	if uint32(r0) != 0 {
   627  		ntstatus = NTStatus(uint32(r0))
   628  	}
   629  	return
   630  }
   631  
   632  func rtlGetVersion(info *_OSVERSIONINFOEXW) {
   633  	syscall.SyscallN(procRtlGetVersion.Addr(), uintptr(unsafe.Pointer(info)))
   634  	return
   635  }
   636  
   637  func RtlIsDosDeviceName_U(name *uint16) (ret uint32) {
   638  	r0, _, _ := syscall.SyscallN(procRtlIsDosDeviceName_U.Addr(), uintptr(unsafe.Pointer(name)))
   639  	ret = uint32(r0)
   640  	return
   641  }
   642  
   643  func rtlNtStatusToDosErrorNoTeb(ntstatus NTStatus) (ret syscall.Errno) {
   644  	r0, _, _ := syscall.SyscallN(procRtlNtStatusToDosErrorNoTeb.Addr(), uintptr(ntstatus))
   645  	ret = syscall.Errno(r0)
   646  	return
   647  }
   648  
   649  func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error) {
   650  	r1, _, e1 := syscall.SyscallN(procGetProcessMemoryInfo.Addr(), uintptr(handle), uintptr(unsafe.Pointer(memCounters)), uintptr(cb))
   651  	if uint32(r1) == 0 {
   652  		err = errnoErr(e1)
   653  	}
   654  	return
   655  }
   656  
   657  func createAppContainerProfile(appContainerName *uint16, displayName *uint16, description *uint16, capabilities *syscall.SIDAndAttributes, capabilityCount uint32, appContainerSid **syscall.SID) (ret error) {
   658  	r0, _, _ := syscall.SyscallN(procCreateAppContainerProfile.Addr(), uintptr(unsafe.Pointer(appContainerName)), uintptr(unsafe.Pointer(displayName)), uintptr(unsafe.Pointer(description)), uintptr(unsafe.Pointer(capabilities)), uintptr(capabilityCount), uintptr(unsafe.Pointer(appContainerSid)))
   659  	if uint32(r0) != 0 {
   660  		ret = syscall.Errno(uint32(r0))
   661  	}
   662  	return
   663  }
   664  
   665  func CreateEnvironmentBlock(block **uint16, token syscall.Token, inheritExisting bool) (err error) {
   666  	var _p0 uint32
   667  	if inheritExisting {
   668  		_p0 = 1
   669  	}
   670  	r1, _, e1 := syscall.SyscallN(procCreateEnvironmentBlock.Addr(), uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
   671  	if uint32(r1) == 0 {
   672  		err = errnoErr(e1)
   673  	}
   674  	return
   675  }
   676  
   677  func DeleteAppContainerProfile(appContainerName *uint16) (ret error) {
   678  	r0, _, _ := syscall.SyscallN(procDeleteAppContainerProfile.Addr(), uintptr(unsafe.Pointer(appContainerName)))
   679  	if uint32(r0) != 0 {
   680  		ret = syscall.Errno(uint32(r0))
   681  	}
   682  	return
   683  }
   684  
   685  func DestroyEnvironmentBlock(block *uint16) (err error) {
   686  	r1, _, e1 := syscall.SyscallN(procDestroyEnvironmentBlock.Addr(), uintptr(unsafe.Pointer(block)))
   687  	if uint32(r1) == 0 {
   688  		err = errnoErr(e1)
   689  	}
   690  	return
   691  }
   692  
   693  func GetProfilesDirectory(dir *uint16, dirLen *uint32) (err error) {
   694  	r1, _, e1 := syscall.SyscallN(procGetProfilesDirectoryW.Addr(), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
   695  	if uint32(r1) == 0 {
   696  		err = errnoErr(e1)
   697  	}
   698  	return
   699  }
   700  
   701  func WSADuplicateSocket(s syscall.Handle, processID uint32, info *syscall.WSAProtocolInfo) (err error) {
   702  	r1, _, e1 := syscall.SyscallN(procWSADuplicateSocketW.Addr(), uintptr(s), uintptr(processID), uintptr(unsafe.Pointer(info)))
   703  	if r1 != 0 {
   704  		err = errnoErr(e1)
   705  	}
   706  	return
   707  }
   708  
   709  func WSAGetOverlappedResult(h syscall.Handle, o *syscall.Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) {
   710  	var _p0 uint32
   711  	if wait {
   712  		_p0 = 1
   713  	}
   714  	r1, _, e1 := syscall.SyscallN(procWSAGetOverlappedResult.Addr(), uintptr(h), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(bytes)), uintptr(_p0), uintptr(unsafe.Pointer(flags)))
   715  	if uint32(r1) == 0 {
   716  		err = errnoErr(e1)
   717  	}
   718  	return
   719  }
   720  
   721  func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (handle syscall.Handle, err error) {
   722  	r0, _, e1 := syscall.SyscallN(procWSASocketW.Addr(), uintptr(af), uintptr(typ), uintptr(protocol), uintptr(unsafe.Pointer(protinfo)), uintptr(group), uintptr(flags))
   723  	handle = syscall.Handle(r0)
   724  	if handle == syscall.InvalidHandle {
   725  		err = errnoErr(e1)
   726  	}
   727  	return
   728  }
   729  

View as plain text