zsyscall_windows.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Code generated by 'go generate'; DO NOT EDIT.
  2. package tshttpproxy
  3. import (
  4. "syscall"
  5. "unsafe"
  6. "golang.org/x/sys/windows"
  7. )
  8. var _ unsafe.Pointer
  9. // Do the interface allocations only once for common
  10. // Errno values.
  11. const (
  12. errnoERROR_IO_PENDING = 997
  13. )
  14. var (
  15. errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
  16. errERROR_EINVAL error = syscall.EINVAL
  17. )
  18. // errnoErr returns common boxed Errno values, to prevent
  19. // allocations at runtime.
  20. func errnoErr(e syscall.Errno) error {
  21. switch e {
  22. case 0:
  23. return errERROR_EINVAL
  24. case errnoERROR_IO_PENDING:
  25. return errERROR_IO_PENDING
  26. }
  27. // TODO: add more here, after collecting data on the common
  28. // error values see on Windows. (perhaps when running
  29. // all.bat?)
  30. return e
  31. }
  32. var (
  33. modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
  34. modwinhttp = windows.NewLazySystemDLL("winhttp.dll")
  35. procGlobalFree = modkernel32.NewProc("GlobalFree")
  36. procWinHttpCloseHandle = modwinhttp.NewProc("WinHttpCloseHandle")
  37. procWinHttpGetProxyForUrl = modwinhttp.NewProc("WinHttpGetProxyForUrl")
  38. procWinHttpOpen = modwinhttp.NewProc("WinHttpOpen")
  39. )
  40. func globalFree(hglobal winHGlobal) (err error) {
  41. r1, _, e1 := syscall.Syscall(procGlobalFree.Addr(), 1, uintptr(hglobal), 0, 0)
  42. if r1 == 0 {
  43. err = errnoErr(e1)
  44. }
  45. return
  46. }
  47. func winHTTPCloseHandle(whi winHTTPInternet) (err error) {
  48. r1, _, e1 := syscall.Syscall(procWinHttpCloseHandle.Addr(), 1, uintptr(whi), 0, 0)
  49. if r1 == 0 {
  50. err = errnoErr(e1)
  51. }
  52. return
  53. }
  54. func winHTTPGetProxyForURL(whi winHTTPInternet, url *uint16, options *winHTTPAutoProxyOptions, proxyInfo *winHTTPProxyInfo) (err error) {
  55. r1, _, e1 := syscall.Syscall6(procWinHttpGetProxyForUrl.Addr(), 4, uintptr(whi), uintptr(unsafe.Pointer(url)), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(proxyInfo)), 0, 0)
  56. if r1 == 0 {
  57. err = errnoErr(e1)
  58. }
  59. return
  60. }
  61. func winHTTPOpen(agent *uint16, accessType uint32, proxy *uint16, proxyBypass *uint16, flags uint32) (whi winHTTPInternet, err error) {
  62. r0, _, e1 := syscall.Syscall6(procWinHttpOpen.Addr(), 5, uintptr(unsafe.Pointer(agent)), uintptr(accessType), uintptr(unsafe.Pointer(proxy)), uintptr(unsafe.Pointer(proxyBypass)), uintptr(flags), 0)
  63. whi = winHTTPInternet(r0)
  64. if whi == 0 {
  65. err = errnoErr(e1)
  66. }
  67. return
  68. }