1// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT 2 3package winio 4 5import "unsafe" 6import "syscall" 7 8var _ unsafe.Pointer 9 10var ( 11 modkernel32 = syscall.NewLazyDLL("kernel32.dll") 12 modadvapi32 = syscall.NewLazyDLL("advapi32.dll") 13 14 procCancelIoEx = modkernel32.NewProc("CancelIoEx") 15 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort") 16 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus") 17 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes") 18 procConnectNamedPipe = modkernel32.NewProc("ConnectNamedPipe") 19 procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW") 20 procCreateFileW = modkernel32.NewProc("CreateFileW") 21 procWaitNamedPipeW = modkernel32.NewProc("WaitNamedPipeW") 22 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW") 23 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW") 24 procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW") 25 procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW") 26 procLocalFree = modkernel32.NewProc("LocalFree") 27 procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength") 28 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") 29 procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle") 30 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") 31 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") 32 procRevertToSelf = modadvapi32.NewProc("RevertToSelf") 33 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") 34 procGetCurrentThread = modkernel32.NewProc("GetCurrentThread") 35 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") 36 procLookupPrivilegeNameW = modadvapi32.NewProc("LookupPrivilegeNameW") 37 procLookupPrivilegeDisplayNameW = modadvapi32.NewProc("LookupPrivilegeDisplayNameW") 38 procBackupRead = modkernel32.NewProc("BackupRead") 39 procBackupWrite = modkernel32.NewProc("BackupWrite") 40) 41 42func cancelIoEx(file syscall.Handle, o *syscall.Overlapped) (err error) { 43 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(file), uintptr(unsafe.Pointer(o)), 0) 44 if r1 == 0 { 45 if e1 != 0 { 46 err = error(e1) 47 } else { 48 err = syscall.EINVAL 49 } 50 } 51 return 52} 53 54func createIoCompletionPort(file syscall.Handle, port syscall.Handle, key uintptr, threadCount uint32) (newport syscall.Handle, err error) { 55 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(file), uintptr(port), uintptr(key), uintptr(threadCount), 0, 0) 56 newport = syscall.Handle(r0) 57 if newport == 0 { 58 if e1 != 0 { 59 err = error(e1) 60 } else { 61 err = syscall.EINVAL 62 } 63 } 64 return 65} 66 67func getQueuedCompletionStatus(port syscall.Handle, bytes *uint32, key *uintptr, o **ioOperation, timeout uint32) (err error) { 68 r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(port), uintptr(unsafe.Pointer(bytes)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(o)), uintptr(timeout), 0) 69 if r1 == 0 { 70 if e1 != 0 { 71 err = error(e1) 72 } else { 73 err = syscall.EINVAL 74 } 75 } 76 return 77} 78 79func setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) { 80 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(h), uintptr(flags), 0) 81 if r1 == 0 { 82 if e1 != 0 { 83 err = error(e1) 84 } else { 85 err = syscall.EINVAL 86 } 87 } 88 return 89} 90 91func connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) { 92 r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(o)), 0) 93 if r1 == 0 { 94 if e1 != 0 { 95 err = error(e1) 96 } else { 97 err = syscall.EINVAL 98 } 99 } 100 return 101} 102 103func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *securityAttributes) (handle syscall.Handle, err error) { 104 var _p0 *uint16 105 _p0, err = syscall.UTF16PtrFromString(name) 106 if err != nil { 107 return 108 } 109 return _createNamedPipe(_p0, flags, pipeMode, maxInstances, outSize, inSize, defaultTimeout, sa) 110} 111 112func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *securityAttributes) (handle syscall.Handle, err error) { 113 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) 114 handle = syscall.Handle(r0) 115 if handle == syscall.InvalidHandle { 116 if e1 != 0 { 117 err = error(e1) 118 } else { 119 err = syscall.EINVAL 120 } 121 } 122 return 123} 124 125func createFile(name string, access uint32, mode uint32, sa *securityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) { 126 var _p0 *uint16 127 _p0, err = syscall.UTF16PtrFromString(name) 128 if err != nil { 129 return 130 } 131 return _createFile(_p0, access, mode, sa, createmode, attrs, templatefile) 132} 133 134func _createFile(name *uint16, access uint32, mode uint32, sa *securityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) { 135 r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0) 136 handle = syscall.Handle(r0) 137 if handle == syscall.InvalidHandle { 138 if e1 != 0 { 139 err = error(e1) 140 } else { 141 err = syscall.EINVAL 142 } 143 } 144 return 145} 146 147func waitNamedPipe(name string, timeout uint32) (err error) { 148 var _p0 *uint16 149 _p0, err = syscall.UTF16PtrFromString(name) 150 if err != nil { 151 return 152 } 153 return _waitNamedPipe(_p0, timeout) 154} 155 156func _waitNamedPipe(name *uint16, timeout uint32) (err error) { 157 r1, _, e1 := syscall.Syscall(procWaitNamedPipeW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(timeout), 0) 158 if r1 == 0 { 159 if e1 != 0 { 160 err = error(e1) 161 } else { 162 err = syscall.EINVAL 163 } 164 } 165 return 166} 167 168func lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) { 169 var _p0 *uint16 170 _p0, err = syscall.UTF16PtrFromString(accountName) 171 if err != nil { 172 return 173 } 174 return _lookupAccountName(systemName, _p0, sid, sidSize, refDomain, refDomainSize, sidNameUse) 175} 176 177func _lookupAccountName(systemName *uint16, accountName *uint16, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) { 178 r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidSize)), uintptr(unsafe.Pointer(refDomain)), uintptr(unsafe.Pointer(refDomainSize)), uintptr(unsafe.Pointer(sidNameUse)), 0, 0) 179 if r1 == 0 { 180 if e1 != 0 { 181 err = error(e1) 182 } else { 183 err = syscall.EINVAL 184 } 185 } 186 return 187} 188 189func convertSidToStringSid(sid *byte, str **uint16) (err error) { 190 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(str)), 0) 191 if r1 == 0 { 192 if e1 != 0 { 193 err = error(e1) 194 } else { 195 err = syscall.EINVAL 196 } 197 } 198 return 199} 200 201func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd *uintptr, size *uint32) (err error) { 202 var _p0 *uint16 203 _p0, err = syscall.UTF16PtrFromString(str) 204 if err != nil { 205 return 206 } 207 return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size) 208} 209 210func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd *uintptr, size *uint32) (err error) { 211 r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0) 212 if r1 == 0 { 213 if e1 != 0 { 214 err = error(e1) 215 } else { 216 err = syscall.EINVAL 217 } 218 } 219 return 220} 221 222func convertSecurityDescriptorToStringSecurityDescriptor(sd *byte, revision uint32, secInfo uint32, sddl **uint16, sddlSize *uint32) (err error) { 223 r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(secInfo), uintptr(unsafe.Pointer(sddl)), uintptr(unsafe.Pointer(sddlSize)), 0) 224 if r1 == 0 { 225 if e1 != 0 { 226 err = error(e1) 227 } else { 228 err = syscall.EINVAL 229 } 230 } 231 return 232} 233 234func localFree(mem uintptr) { 235 syscall.Syscall(procLocalFree.Addr(), 1, uintptr(mem), 0, 0) 236 return 237} 238 239func getSecurityDescriptorLength(sd uintptr) (len uint32) { 240 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(sd), 0, 0) 241 len = uint32(r0) 242 return 243} 244 245func getFileInformationByHandleEx(h syscall.Handle, class uint32, buffer *byte, size uint32) (err error) { 246 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0) 247 if r1 == 0 { 248 if e1 != 0 { 249 err = error(e1) 250 } else { 251 err = syscall.EINVAL 252 } 253 } 254 return 255} 256 257func setFileInformationByHandle(h syscall.Handle, class uint32, buffer *byte, size uint32) (err error) { 258 r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0) 259 if r1 == 0 { 260 if e1 != 0 { 261 err = error(e1) 262 } else { 263 err = syscall.EINVAL 264 } 265 } 266 return 267} 268 269func adjustTokenPrivileges(token syscall.Handle, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) { 270 var _p0 uint32 271 if releaseAll { 272 _p0 = 1 273 } else { 274 _p0 = 0 275 } 276 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))) 277 success = r0 != 0 278 if true { 279 if e1 != 0 { 280 err = error(e1) 281 } else { 282 err = syscall.EINVAL 283 } 284 } 285 return 286} 287 288func impersonateSelf(level uint32) (err error) { 289 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(level), 0, 0) 290 if r1 == 0 { 291 if e1 != 0 { 292 err = error(e1) 293 } else { 294 err = syscall.EINVAL 295 } 296 } 297 return 298} 299 300func revertToSelf() (err error) { 301 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0) 302 if r1 == 0 { 303 if e1 != 0 { 304 err = error(e1) 305 } else { 306 err = syscall.EINVAL 307 } 308 } 309 return 310} 311 312func openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool, token *syscall.Handle) (err error) { 313 var _p0 uint32 314 if openAsSelf { 315 _p0 = 1 316 } else { 317 _p0 = 0 318 } 319 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(accessMask), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0) 320 if r1 == 0 { 321 if e1 != 0 { 322 err = error(e1) 323 } else { 324 err = syscall.EINVAL 325 } 326 } 327 return 328} 329 330func getCurrentThread() (h syscall.Handle) { 331 r0, _, _ := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0) 332 h = syscall.Handle(r0) 333 return 334} 335 336func lookupPrivilegeValue(systemName string, name string, luid *uint64) (err error) { 337 var _p0 *uint16 338 _p0, err = syscall.UTF16PtrFromString(systemName) 339 if err != nil { 340 return 341 } 342 var _p1 *uint16 343 _p1, err = syscall.UTF16PtrFromString(name) 344 if err != nil { 345 return 346 } 347 return _lookupPrivilegeValue(_p0, _p1, luid) 348} 349 350func _lookupPrivilegeValue(systemName *uint16, name *uint16, luid *uint64) (err error) { 351 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid))) 352 if r1 == 0 { 353 if e1 != 0 { 354 err = error(e1) 355 } else { 356 err = syscall.EINVAL 357 } 358 } 359 return 360} 361 362func lookupPrivilegeName(systemName string, luid *uint64, buffer *uint16, size *uint32) (err error) { 363 var _p0 *uint16 364 _p0, err = syscall.UTF16PtrFromString(systemName) 365 if err != nil { 366 return 367 } 368 return _lookupPrivilegeName(_p0, luid, buffer, size) 369} 370 371func _lookupPrivilegeName(systemName *uint16, luid *uint64, buffer *uint16, size *uint32) (err error) { 372 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) 373 if r1 == 0 { 374 if e1 != 0 { 375 err = error(e1) 376 } else { 377 err = syscall.EINVAL 378 } 379 } 380 return 381} 382 383func lookupPrivilegeDisplayName(systemName string, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) { 384 var _p0 *uint16 385 _p0, err = syscall.UTF16PtrFromString(systemName) 386 if err != nil { 387 return 388 } 389 return _lookupPrivilegeDisplayName(_p0, name, buffer, size, languageId) 390} 391 392func _lookupPrivilegeDisplayName(systemName *uint16, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) { 393 r1, _, e1 := syscall.Syscall6(procLookupPrivilegeDisplayNameW.Addr(), 5, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(languageId)), 0) 394 if r1 == 0 { 395 if e1 != 0 { 396 err = error(e1) 397 } else { 398 err = syscall.EINVAL 399 } 400 } 401 return 402} 403 404func backupRead(h syscall.Handle, b []byte, bytesRead *uint32, abort bool, processSecurity bool, context *uintptr) (err error) { 405 var _p0 *byte 406 if len(b) > 0 { 407 _p0 = &b[0] 408 } 409 var _p1 uint32 410 if abort { 411 _p1 = 1 412 } else { 413 _p1 = 0 414 } 415 var _p2 uint32 416 if processSecurity { 417 _p2 = 1 418 } else { 419 _p2 = 0 420 } 421 r1, _, e1 := syscall.Syscall9(procBackupRead.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesRead)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0) 422 if r1 == 0 { 423 if e1 != 0 { 424 err = error(e1) 425 } else { 426 err = syscall.EINVAL 427 } 428 } 429 return 430} 431 432func backupWrite(h syscall.Handle, b []byte, bytesWritten *uint32, abort bool, processSecurity bool, context *uintptr) (err error) { 433 var _p0 *byte 434 if len(b) > 0 { 435 _p0 = &b[0] 436 } 437 var _p1 uint32 438 if abort { 439 _p1 = 1 440 } else { 441 _p1 = 0 442 } 443 var _p2 uint32 444 if processSecurity { 445 _p2 = 1 446 } else { 447 _p2 = 0 448 } 449 r1, _, e1 := syscall.Syscall9(procBackupWrite.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesWritten)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0) 450 if r1 == 0 { 451 if e1 != 0 { 452 err = error(e1) 453 } else { 454 err = syscall.EINVAL 455 } 456 } 457 return 458} 459