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