github.com/elastic/gosigar@v0.14.3/sys/windows/zsyscall_windows.go (about) 1 // Code generated by 'go generate'; DO NOT EDIT. 2 3 package windows 4 5 import ( 6 "syscall" 7 "unsafe" 8 9 "golang.org/x/sys/windows" 10 ) 11 12 var _ unsafe.Pointer 13 14 // Do the interface allocations only once for common 15 // Errno values. 16 const ( 17 errnoERROR_IO_PENDING = 997 18 ) 19 20 var ( 21 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) 22 errERROR_EINVAL error = syscall.EINVAL 23 ) 24 25 // errnoErr returns common boxed Errno values, to prevent 26 // allocations at runtime. 27 func errnoErr(e syscall.Errno) error { 28 switch e { 29 case 0: 30 return errERROR_EINVAL 31 case errnoERROR_IO_PENDING: 32 return errERROR_IO_PENDING 33 } 34 // TODO: add more here, after collecting data on the common 35 // error values see on Windows. (perhaps when running 36 // all.bat?) 37 return e 38 } 39 40 var ( 41 modadvapi32 = windows.NewLazySystemDLL("advapi32.dll") 42 modkernel32 = windows.NewLazySystemDLL("kernel32.dll") 43 modntdll = windows.NewLazySystemDLL("ntdll.dll") 44 modpsapi = windows.NewLazySystemDLL("psapi.dll") 45 46 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") 47 procLookupPrivilegeNameW = modadvapi32.NewProc("LookupPrivilegeNameW") 48 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") 49 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot") 50 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW") 51 procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW") 52 procFindVolumeClose = modkernel32.NewProc("FindVolumeClose") 53 procGetDiskFreeSpaceExW = modkernel32.NewProc("GetDiskFreeSpaceExW") 54 procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW") 55 procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW") 56 procGetSystemTimes = modkernel32.NewProc("GetSystemTimes") 57 procGetTickCount64 = modkernel32.NewProc("GetTickCount64") 58 procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW") 59 procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW") 60 procGlobalMemoryStatusEx = modkernel32.NewProc("GlobalMemoryStatusEx") 61 procProcess32FirstW = modkernel32.NewProc("Process32FirstW") 62 procProcess32NextW = modkernel32.NewProc("Process32NextW") 63 procReadProcessMemory = modkernel32.NewProc("ReadProcessMemory") 64 procNtQueryInformationProcess = modntdll.NewProc("NtQueryInformationProcess") 65 procNtQuerySystemInformation = modntdll.NewProc("NtQuerySystemInformation") 66 procEnumProcesses = modpsapi.NewProc("EnumProcesses") 67 procGetProcessImageFileNameW = modpsapi.NewProc("GetProcessImageFileNameW") 68 procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo") 69 ) 70 71 func _AdjustTokenPrivileges(token syscall.Token, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) { 72 var _p0 uint32 73 if releaseAll { 74 _p0 = 1 75 } 76 r0, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(input)), uintptr(outputSize), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(requiredSize))) 77 success = r0 != 0 78 if true { 79 err = errnoErr(e1) 80 } 81 return 82 } 83 84 func _LookupPrivilegeName(systemName string, luid *int64, buffer *uint16, size *uint32) (err error) { 85 var _p0 *uint16 86 _p0, err = syscall.UTF16PtrFromString(systemName) 87 if err != nil { 88 return 89 } 90 return __LookupPrivilegeName(_p0, luid, buffer, size) 91 } 92 93 func __LookupPrivilegeName(systemName *uint16, luid *int64, buffer *uint16, size *uint32) (err error) { 94 r1, _, e1 := syscall.Syscall6(procLookupPrivilegeNameW.Addr(), 4, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(luid)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), 0, 0) 95 if r1 == 0 { 96 err = errnoErr(e1) 97 } 98 return 99 } 100 101 func _LookupPrivilegeValue(systemName string, name string, luid *int64) (err error) { 102 var _p0 *uint16 103 _p0, err = syscall.UTF16PtrFromString(systemName) 104 if err != nil { 105 return 106 } 107 var _p1 *uint16 108 _p1, err = syscall.UTF16PtrFromString(name) 109 if err != nil { 110 return 111 } 112 return __LookupPrivilegeValue(_p0, _p1, luid) 113 } 114 115 func __LookupPrivilegeValue(systemName *uint16, name *uint16, luid *int64) (err error) { 116 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid))) 117 if r1 == 0 { 118 err = errnoErr(e1) 119 } 120 return 121 } 122 123 func _CreateToolhelp32Snapshot(flags uint32, processID uint32) (handle syscall.Handle, err error) { 124 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processID), 0) 125 handle = syscall.Handle(r0) 126 if handle == 0 { 127 err = errnoErr(e1) 128 } 129 return 130 } 131 132 func _FindFirstVolume(volumeName *uint16, size uint32) (handle syscall.Handle, err error) { 133 r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(size), 0) 134 handle = syscall.Handle(r0) 135 if handle == 0 { 136 err = errnoErr(e1) 137 } 138 return 139 } 140 141 func _FindNextVolume(handle syscall.Handle, volumeName *uint16, size uint32) (err error) { 142 r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(volumeName)), uintptr(size)) 143 if r1 == 0 { 144 err = errnoErr(e1) 145 } 146 return 147 } 148 149 func _FindVolumeClose(handle syscall.Handle) (err error) { 150 r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(handle), 0, 0) 151 if r1 == 0 { 152 err = errnoErr(e1) 153 } 154 return 155 } 156 157 func _GetDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailable *uint64, totalNumberOfBytes *uint64, totalNumberOfFreeBytes *uint64) (err error) { 158 r1, _, e1 := syscall.Syscall6(procGetDiskFreeSpaceExW.Addr(), 4, uintptr(unsafe.Pointer(directoryName)), uintptr(unsafe.Pointer(freeBytesAvailable)), uintptr(unsafe.Pointer(totalNumberOfBytes)), uintptr(unsafe.Pointer(totalNumberOfFreeBytes)), 0, 0) 159 if r1 == 0 { 160 err = errnoErr(e1) 161 } 162 return 163 } 164 165 func _GetDriveType(rootPathName *uint16) (dt DriveType, err error) { 166 r0, _, e1 := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0) 167 dt = DriveType(r0) 168 if dt == 0 { 169 err = errnoErr(e1) 170 } 171 return 172 } 173 174 func _GetLogicalDriveStringsW(bufferLength uint32, buffer *uint16) (length uint32, err error) { 175 r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0) 176 length = uint32(r0) 177 if length == 0 { 178 err = errnoErr(e1) 179 } 180 return 181 } 182 183 func _GetSystemTimes(idleTime *syscall.Filetime, kernelTime *syscall.Filetime, userTime *syscall.Filetime) (err error) { 184 r1, _, e1 := syscall.Syscall(procGetSystemTimes.Addr(), 3, uintptr(unsafe.Pointer(idleTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime))) 185 if r1 == 0 { 186 err = errnoErr(e1) 187 } 188 return 189 } 190 191 func _GetTickCount64() (uptime uint64, err error) { 192 r0, _, e1 := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0) 193 uptime = uint64(r0) 194 if uptime == 0 { 195 err = errnoErr(e1) 196 } 197 return 198 } 199 200 func _GetVolumeInformation(rootPathName *uint16, volumeName *uint16, volumeNameSize uint32, volumeSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemName *uint16, fileSystemNameSize uint32) (success bool, err error) { 201 r0, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemName)), uintptr(fileSystemNameSize), 0) 202 success = r0 != 0 203 if true { 204 err = errnoErr(e1) 205 } 206 return 207 } 208 209 func _GetVolumePathNamesForVolumeName(volumeName string, buffer *uint16, bufferSize uint32, length *uint32) (err error) { 210 var _p0 *uint16 211 _p0, err = syscall.UTF16PtrFromString(volumeName) 212 if err != nil { 213 return 214 } 215 return __GetVolumePathNamesForVolumeName(_p0, buffer, bufferSize, length) 216 } 217 218 func __GetVolumePathNamesForVolumeName(volumeName *uint16, buffer *uint16, bufferSize uint32, length *uint32) (err error) { 219 r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(buffer)), uintptr(bufferSize), uintptr(unsafe.Pointer(length)), 0, 0) 220 if r1 == 0 { 221 err = errnoErr(e1) 222 } 223 return 224 } 225 226 func _GlobalMemoryStatusEx(buffer *MemoryStatusEx) (err error) { 227 r1, _, e1 := syscall.Syscall(procGlobalMemoryStatusEx.Addr(), 1, uintptr(unsafe.Pointer(buffer)), 0, 0) 228 if r1 == 0 { 229 err = errnoErr(e1) 230 } 231 return 232 } 233 234 func _Process32First(handle syscall.Handle, processEntry32 *ProcessEntry32) (err error) { 235 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(processEntry32)), 0) 236 if r1 == 0 { 237 err = errnoErr(e1) 238 } 239 return 240 } 241 242 func _Process32Next(handle syscall.Handle, processEntry32 *ProcessEntry32) (err error) { 243 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(processEntry32)), 0) 244 if r1 == 0 { 245 err = errnoErr(e1) 246 } 247 return 248 } 249 250 func _ReadProcessMemory(handle syscall.Handle, baseAddress uintptr, buffer uintptr, size uintptr, numRead *uintptr) (err error) { 251 r1, _, e1 := syscall.Syscall6(procReadProcessMemory.Addr(), 5, uintptr(handle), uintptr(baseAddress), uintptr(buffer), uintptr(size), uintptr(unsafe.Pointer(numRead)), 0) 252 if r1 == 0 { 253 err = errnoErr(e1) 254 } 255 return 256 } 257 258 func _NtQueryInformationProcess(processHandle syscall.Handle, processInformationClass uint32, processInformation *byte, processInformationLength uint32, returnLength *uint32) (ntstatus uint32, err error) { 259 r0, _, e1 := syscall.Syscall6(procNtQueryInformationProcess.Addr(), 5, uintptr(processHandle), uintptr(processInformationClass), uintptr(unsafe.Pointer(processInformation)), uintptr(processInformationLength), uintptr(unsafe.Pointer(returnLength)), 0) 260 ntstatus = uint32(r0) 261 if ntstatus == 0 { 262 err = errnoErr(e1) 263 } 264 return 265 } 266 267 func _NtQuerySystemInformation(systemInformationClass uint32, systemInformation *byte, systemInformationLength uint32, returnLength *uint32) (ntstatus uint32, err error) { 268 r0, _, e1 := syscall.Syscall6(procNtQuerySystemInformation.Addr(), 4, uintptr(systemInformationClass), uintptr(unsafe.Pointer(systemInformation)), uintptr(systemInformationLength), uintptr(unsafe.Pointer(returnLength)), 0, 0) 269 ntstatus = uint32(r0) 270 if ntstatus == 0 { 271 err = errnoErr(e1) 272 } 273 return 274 } 275 276 func _EnumProcesses(processIds *uint32, sizeBytes uint32, bytesReturned *uint32) (err error) { 277 r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(processIds)), uintptr(sizeBytes), uintptr(unsafe.Pointer(bytesReturned))) 278 if r1 == 0 { 279 err = errnoErr(e1) 280 } 281 return 282 } 283 284 func _GetProcessImageFileName(handle syscall.Handle, outImageFileName *uint16, size uint32) (length uint32, err error) { 285 r0, _, e1 := syscall.Syscall(procGetProcessImageFileNameW.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(outImageFileName)), uintptr(size)) 286 length = uint32(r0) 287 if length == 0 { 288 err = errnoErr(e1) 289 } 290 return 291 } 292 293 func _GetProcessMemoryInfo(handle syscall.Handle, psmemCounters *ProcessMemoryCountersEx, cb uint32) (err error) { 294 r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(psmemCounters)), uintptr(cb)) 295 if r1 == 0 { 296 err = errnoErr(e1) 297 } 298 return 299 }