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

View as plain text