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

View as plain text