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

View as plain text