github.com/octohelm/cuemod@v0.9.4/internal/internals/syscall/windows/zsyscall_windows.go (about) 1 // Code generated by 'go generate'; DO NOT EDIT. 2 3 package windows 4 5 import ( 6 "github.com/octohelm/cuemod/internal/internals/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 modpsapi = syscall.NewLazyDLL(sysdll.Add("psapi.dll")) 46 moduserenv = syscall.NewLazyDLL(sysdll.Add("userenv.dll")) 47 modws2_32 = syscall.NewLazyDLL(sysdll.Add("ws2_32.dll")) 48 49 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") 50 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx") 51 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") 52 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") 53 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW") 54 procOpenServiceW = modadvapi32.NewProc("OpenServiceW") 55 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") 56 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus") 57 procRevertToSelf = modadvapi32.NewProc("RevertToSelf") 58 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation") 59 procProcessPrng = modbcryptprimitives.NewProc("ProcessPrng") 60 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") 61 procCreateEventW = modkernel32.NewProc("CreateEventW") 62 procGetACP = modkernel32.NewProc("GetACP") 63 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") 64 procGetConsoleCP = modkernel32.NewProc("GetConsoleCP") 65 procGetCurrentThread = modkernel32.NewProc("GetCurrentThread") 66 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") 67 procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW") 68 procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") 69 procGetTempPath2W = modkernel32.NewProc("GetTempPath2W") 70 procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW") 71 procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW") 72 procLockFileEx = modkernel32.NewProc("LockFileEx") 73 procModule32FirstW = modkernel32.NewProc("Module32FirstW") 74 procModule32NextW = modkernel32.NewProc("Module32NextW") 75 procMoveFileExW = modkernel32.NewProc("MoveFileExW") 76 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") 77 procRtlLookupFunctionEntry = modkernel32.NewProc("RtlLookupFunctionEntry") 78 procRtlVirtualUnwind = modkernel32.NewProc("RtlVirtualUnwind") 79 procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle") 80 procUnlockFileEx = modkernel32.NewProc("UnlockFileEx") 81 procVirtualQuery = modkernel32.NewProc("VirtualQuery") 82 procNetShareAdd = modnetapi32.NewProc("NetShareAdd") 83 procNetShareDel = modnetapi32.NewProc("NetShareDel") 84 procNetUserGetLocalGroups = modnetapi32.NewProc("NetUserGetLocalGroups") 85 procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo") 86 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") 87 procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") 88 procGetProfilesDirectoryW = moduserenv.NewProc("GetProfilesDirectoryW") 89 procWSASocketW = modws2_32.NewProc("WSASocketW") 90 ) 91 92 func adjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, buflen uint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32) (ret uint32, err error) { 93 var _p0 uint32 94 if disableAllPrivileges { 95 _p0 = 1 96 } 97 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))) 98 ret = uint32(r0) 99 if true { 100 err = errnoErr(e1) 101 } 102 return 103 } 104 105 func DuplicateTokenEx(hExistingToken syscall.Token, dwDesiredAccess uint32, lpTokenAttributes *syscall.SecurityAttributes, impersonationLevel uint32, tokenType TokenType, phNewToken *syscall.Token) (err error) { 106 r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(hExistingToken), uintptr(dwDesiredAccess), uintptr(unsafe.Pointer(lpTokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(phNewToken))) 107 if r1 == 0 { 108 err = errnoErr(e1) 109 } 110 return 111 } 112 113 func ImpersonateSelf(impersonationlevel uint32) (err error) { 114 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0) 115 if r1 == 0 { 116 err = errnoErr(e1) 117 } 118 return 119 } 120 121 func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) { 122 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid))) 123 if r1 == 0 { 124 err = errnoErr(e1) 125 } 126 return 127 } 128 129 func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle syscall.Handle, err error) { 130 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access)) 131 handle = syscall.Handle(r0) 132 if handle == 0 { 133 err = errnoErr(e1) 134 } 135 return 136 } 137 138 func OpenService(mgr syscall.Handle, serviceName *uint16, access uint32) (handle syscall.Handle, err error) { 139 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access)) 140 handle = syscall.Handle(r0) 141 if handle == 0 { 142 err = errnoErr(e1) 143 } 144 return 145 } 146 147 func OpenThreadToken(h syscall.Handle, access uint32, openasself bool, token *syscall.Token) (err error) { 148 var _p0 uint32 149 if openasself { 150 _p0 = 1 151 } 152 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(h), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0) 153 if r1 == 0 { 154 err = errnoErr(e1) 155 } 156 return 157 } 158 159 func QueryServiceStatus(hService syscall.Handle, lpServiceStatus *SERVICE_STATUS) (err error) { 160 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(hService), uintptr(unsafe.Pointer(lpServiceStatus)), 0) 161 if r1 == 0 { 162 err = errnoErr(e1) 163 } 164 return 165 } 166 167 func RevertToSelf() (err error) { 168 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0) 169 if r1 == 0 { 170 err = errnoErr(e1) 171 } 172 return 173 } 174 175 func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, tokenInformation uintptr, tokenInformationLength uint32) (err error) { 176 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(tokenHandle), uintptr(tokenInformationClass), uintptr(tokenInformation), uintptr(tokenInformationLength), 0, 0) 177 if r1 == 0 { 178 err = errnoErr(e1) 179 } 180 return 181 } 182 183 func ProcessPrng(buf []byte) (err error) { 184 var _p0 *byte 185 if len(buf) > 0 { 186 _p0 = &buf[0] 187 } 188 r1, _, e1 := syscall.Syscall(procProcessPrng.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), 0) 189 if r1 == 0 { 190 err = errnoErr(e1) 191 } 192 return 193 } 194 195 func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { 196 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) 197 if r0 != 0 { 198 errcode = syscall.Errno(r0) 199 } 200 return 201 } 202 203 func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle syscall.Handle, err error) { 204 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0) 205 handle = syscall.Handle(r0) 206 if handle == 0 { 207 err = errnoErr(e1) 208 } 209 return 210 } 211 212 func GetACP() (acp uint32) { 213 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) 214 acp = uint32(r0) 215 return 216 } 217 218 func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) { 219 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) 220 if r1 == 0 { 221 err = errnoErr(e1) 222 } 223 return 224 } 225 226 func GetConsoleCP() (ccp uint32) { 227 r0, _, _ := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0) 228 ccp = uint32(r0) 229 return 230 } 231 232 func GetCurrentThread() (pseudoHandle syscall.Handle, err error) { 233 r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0) 234 pseudoHandle = syscall.Handle(r0) 235 if pseudoHandle == 0 { 236 err = errnoErr(e1) 237 } 238 return 239 } 240 241 func GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error) { 242 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(bufsize), 0, 0) 243 if r1 == 0 { 244 err = errnoErr(e1) 245 } 246 return 247 } 248 249 func GetFinalPathNameByHandle(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) { 250 r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0) 251 n = uint32(r0) 252 if n == 0 { 253 err = errnoErr(e1) 254 } 255 return 256 } 257 258 func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) { 259 r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len)) 260 n = uint32(r0) 261 if n == 0 { 262 err = errnoErr(e1) 263 } 264 return 265 } 266 267 func GetTempPath2(buflen uint32, buf *uint16) (n uint32, err error) { 268 r0, _, e1 := syscall.Syscall(procGetTempPath2W.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) 269 n = uint32(r0) 270 if n == 0 { 271 err = errnoErr(e1) 272 } 273 return 274 } 275 276 func GetVolumeInformationByHandle(file syscall.Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { 277 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) 278 if r1 == 0 { 279 err = errnoErr(e1) 280 } 281 return 282 } 283 284 func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) { 285 r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength)) 286 if r1 == 0 { 287 err = errnoErr(e1) 288 } 289 return 290 } 291 292 func LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) { 293 r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped))) 294 if r1 == 0 { 295 err = errnoErr(e1) 296 } 297 return 298 } 299 300 func Module32First(snapshot syscall.Handle, moduleEntry *ModuleEntry32) (err error) { 301 r1, _, e1 := syscall.Syscall(procModule32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0) 302 if r1 == 0 { 303 err = errnoErr(e1) 304 } 305 return 306 } 307 308 func Module32Next(snapshot syscall.Handle, moduleEntry *ModuleEntry32) (err error) { 309 r1, _, e1 := syscall.Syscall(procModule32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0) 310 if r1 == 0 { 311 err = errnoErr(e1) 312 } 313 return 314 } 315 316 func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { 317 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) 318 if r1 == 0 { 319 err = errnoErr(e1) 320 } 321 return 322 } 323 324 func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) { 325 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) 326 nwrite = int32(r0) 327 if nwrite == 0 { 328 err = errnoErr(e1) 329 } 330 return 331 } 332 333 func RtlLookupFunctionEntry(pc uintptr, baseAddress *uintptr, table *byte) (ret uintptr) { 334 r0, _, _ := syscall.Syscall(procRtlLookupFunctionEntry.Addr(), 3, uintptr(pc), uintptr(unsafe.Pointer(baseAddress)), uintptr(unsafe.Pointer(table))) 335 ret = uintptr(r0) 336 return 337 } 338 339 func RtlVirtualUnwind(handlerType uint32, baseAddress uintptr, pc uintptr, entry uintptr, ctxt uintptr, data *uintptr, frame *uintptr, ctxptrs *byte) (ret uintptr) { 340 r0, _, _ := syscall.Syscall9(procRtlVirtualUnwind.Addr(), 8, uintptr(handlerType), uintptr(baseAddress), uintptr(pc), uintptr(entry), uintptr(ctxt), uintptr(unsafe.Pointer(data)), uintptr(unsafe.Pointer(frame)), uintptr(unsafe.Pointer(ctxptrs)), 0) 341 ret = uintptr(r0) 342 return 343 } 344 345 func SetFileInformationByHandle(handle syscall.Handle, fileInformationClass uint32, buf unsafe.Pointer, bufsize uint32) (err error) { 346 r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(fileInformationClass), uintptr(buf), uintptr(bufsize), 0, 0) 347 if r1 == 0 { 348 err = errnoErr(e1) 349 } 350 return 351 } 352 353 func UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) { 354 r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0) 355 if r1 == 0 { 356 err = errnoErr(e1) 357 } 358 return 359 } 360 361 func VirtualQuery(address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) { 362 r1, _, e1 := syscall.Syscall(procVirtualQuery.Addr(), 3, uintptr(address), uintptr(unsafe.Pointer(buffer)), uintptr(length)) 363 if r1 == 0 { 364 err = errnoErr(e1) 365 } 366 return 367 } 368 369 func NetShareAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint16) (neterr error) { 370 r0, _, _ := syscall.Syscall6(procNetShareAdd.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(parmErr)), 0, 0) 371 if r0 != 0 { 372 neterr = syscall.Errno(r0) 373 } 374 return 375 } 376 377 func NetShareDel(serverName *uint16, netName *uint16, reserved uint32) (neterr error) { 378 r0, _, _ := syscall.Syscall(procNetShareDel.Addr(), 3, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(netName)), uintptr(reserved)) 379 if r0 != 0 { 380 neterr = syscall.Errno(r0) 381 } 382 return 383 } 384 385 func NetUserGetLocalGroups(serverName *uint16, userName *uint16, level uint32, flags uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32) (neterr error) { 386 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) 387 if r0 != 0 { 388 neterr = syscall.Errno(r0) 389 } 390 return 391 } 392 393 func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error) { 394 r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(memCounters)), uintptr(cb)) 395 if r1 == 0 { 396 err = errnoErr(e1) 397 } 398 return 399 } 400 401 func CreateEnvironmentBlock(block **uint16, token syscall.Token, inheritExisting bool) (err error) { 402 var _p0 uint32 403 if inheritExisting { 404 _p0 = 1 405 } 406 r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0)) 407 if r1 == 0 { 408 err = errnoErr(e1) 409 } 410 return 411 } 412 413 func DestroyEnvironmentBlock(block *uint16) (err error) { 414 r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0) 415 if r1 == 0 { 416 err = errnoErr(e1) 417 } 418 return 419 } 420 421 func GetProfilesDirectory(dir *uint16, dirLen *uint32) (err error) { 422 r1, _, e1 := syscall.Syscall(procGetProfilesDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)), 0) 423 if r1 == 0 { 424 err = errnoErr(e1) 425 } 426 return 427 } 428 429 func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (handle syscall.Handle, err error) { 430 r0, _, e1 := syscall.Syscall6(procWSASocketW.Addr(), 6, uintptr(af), uintptr(typ), uintptr(protocol), uintptr(unsafe.Pointer(protinfo)), uintptr(group), uintptr(flags)) 431 handle = syscall.Handle(r0) 432 if handle == syscall.InvalidHandle { 433 err = errnoErr(e1) 434 } 435 return 436 }