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

View as plain text