zsyscall_windows.go (8882B)
1 // MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT 2 3 package win32 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 moduser32 = windows.NewLazySystemDLL("user32.dll") 41 42 procGetDC = moduser32.NewProc("GetDC") 43 procReleaseDC = moduser32.NewProc("ReleaseDC") 44 procSendMessageW = moduser32.NewProc("SendMessageW") 45 procCreateWindowExW = moduser32.NewProc("CreateWindowExW") 46 procDefWindowProcW = moduser32.NewProc("DefWindowProcW") 47 procDestroyWindow = moduser32.NewProc("DestroyWindow") 48 procDispatchMessageW = moduser32.NewProc("DispatchMessageW") 49 procGetClientRect = moduser32.NewProc("GetClientRect") 50 procGetWindowRect = moduser32.NewProc("GetWindowRect") 51 procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") 52 procGetKeyboardState = moduser32.NewProc("GetKeyboardState") 53 procGetKeyState = moduser32.NewProc("GetKeyState") 54 procGetMessageW = moduser32.NewProc("GetMessageW") 55 procLoadCursorW = moduser32.NewProc("LoadCursorW") 56 procLoadIconW = moduser32.NewProc("LoadIconW") 57 procMoveWindow = moduser32.NewProc("MoveWindow") 58 procPostMessageW = moduser32.NewProc("PostMessageW") 59 procPostQuitMessage = moduser32.NewProc("PostQuitMessage") 60 procRegisterClassW = moduser32.NewProc("RegisterClassW") 61 procShowWindow = moduser32.NewProc("ShowWindow") 62 procScreenToClient = moduser32.NewProc("ScreenToClient") 63 procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") 64 procTranslateMessage = moduser32.NewProc("TranslateMessage") 65 procUnregisterClassW = moduser32.NewProc("UnregisterClassW") 66 ) 67 68 func GetDC(hwnd syscall.Handle) (dc syscall.Handle, err error) { 69 r0, _, e1 := syscall.Syscall(procGetDC.Addr(), 1, uintptr(hwnd), 0, 0) 70 dc = syscall.Handle(r0) 71 if dc == 0 { 72 if e1 != 0 { 73 err = errnoErr(e1) 74 } else { 75 err = syscall.EINVAL 76 } 77 } 78 return 79 } 80 81 func ReleaseDC(hwnd syscall.Handle, dc syscall.Handle) (err error) { 82 r1, _, e1 := syscall.Syscall(procReleaseDC.Addr(), 2, uintptr(hwnd), uintptr(dc), 0) 83 if r1 == 0 { 84 if e1 != 0 { 85 err = errnoErr(e1) 86 } else { 87 err = syscall.EINVAL 88 } 89 } 90 return 91 } 92 93 func sendMessage(hwnd syscall.Handle, uMsg uint32, wParam uintptr, lParam uintptr) (lResult uintptr) { 94 r0, _, _ := syscall.Syscall6(procSendMessageW.Addr(), 4, uintptr(hwnd), uintptr(uMsg), uintptr(wParam), uintptr(lParam), 0, 0) 95 lResult = uintptr(r0) 96 return 97 } 98 99 func _CreateWindowEx(exstyle uint32, className *uint16, windowText *uint16, style uint32, x int32, y int32, width int32, height int32, parent syscall.Handle, menu syscall.Handle, hInstance syscall.Handle, lpParam uintptr) (hwnd syscall.Handle, err error) { 100 r0, _, e1 := syscall.Syscall12(procCreateWindowExW.Addr(), 12, uintptr(exstyle), uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(windowText)), uintptr(style), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(parent), uintptr(menu), uintptr(hInstance), uintptr(lpParam)) 101 hwnd = syscall.Handle(r0) 102 if hwnd == 0 { 103 if e1 != 0 { 104 err = errnoErr(e1) 105 } else { 106 err = syscall.EINVAL 107 } 108 } 109 return 110 } 111 112 func _DefWindowProc(hwnd syscall.Handle, uMsg uint32, wParam uintptr, lParam uintptr) (lResult uintptr) { 113 r0, _, _ := syscall.Syscall6(procDefWindowProcW.Addr(), 4, uintptr(hwnd), uintptr(uMsg), uintptr(wParam), uintptr(lParam), 0, 0) 114 lResult = uintptr(r0) 115 return 116 } 117 118 func _DestroyWindow(hwnd syscall.Handle) (err error) { 119 r1, _, e1 := syscall.Syscall(procDestroyWindow.Addr(), 1, uintptr(hwnd), 0, 0) 120 if r1 == 0 { 121 if e1 != 0 { 122 err = errnoErr(e1) 123 } else { 124 err = syscall.EINVAL 125 } 126 } 127 return 128 } 129 130 func _DispatchMessage(msg *_MSG) (ret int32) { 131 r0, _, _ := syscall.Syscall(procDispatchMessageW.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0) 132 ret = int32(r0) 133 return 134 } 135 136 func _GetClientRect(hwnd syscall.Handle, rect *_RECT) (err error) { 137 r1, _, e1 := syscall.Syscall(procGetClientRect.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(rect)), 0) 138 if r1 == 0 { 139 if e1 != 0 { 140 err = errnoErr(e1) 141 } else { 142 err = syscall.EINVAL 143 } 144 } 145 return 146 } 147 148 func _GetWindowRect(hwnd syscall.Handle, rect *_RECT) (err error) { 149 r1, _, e1 := syscall.Syscall(procGetWindowRect.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(rect)), 0) 150 if r1 == 0 { 151 if e1 != 0 { 152 err = errnoErr(e1) 153 } else { 154 err = syscall.EINVAL 155 } 156 } 157 return 158 } 159 160 func _GetKeyboardLayout(threadID uint32) (locale syscall.Handle) { 161 r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(threadID), 0, 0) 162 locale = syscall.Handle(r0) 163 return 164 } 165 166 func _GetKeyboardState(lpKeyState *byte) (err error) { 167 r1, _, e1 := syscall.Syscall(procGetKeyboardState.Addr(), 1, uintptr(unsafe.Pointer(lpKeyState)), 0, 0) 168 if r1 == 0 { 169 if e1 != 0 { 170 err = errnoErr(e1) 171 } else { 172 err = syscall.EINVAL 173 } 174 } 175 return 176 } 177 178 func _GetKeyState(virtkey int32) (keystatus int16) { 179 r0, _, _ := syscall.Syscall(procGetKeyState.Addr(), 1, uintptr(virtkey), 0, 0) 180 keystatus = int16(r0) 181 return 182 } 183 184 func _GetMessage(msg *_MSG, hwnd syscall.Handle, msgfiltermin uint32, msgfiltermax uint32) (ret int32, err error) { 185 r0, _, e1 := syscall.Syscall6(procGetMessageW.Addr(), 4, uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(msgfiltermin), uintptr(msgfiltermax), 0, 0) 186 ret = int32(r0) 187 if ret == -1 { 188 if e1 != 0 { 189 err = errnoErr(e1) 190 } else { 191 err = syscall.EINVAL 192 } 193 } 194 return 195 } 196 197 func _LoadCursor(hInstance syscall.Handle, cursorName uintptr) (cursor syscall.Handle, err error) { 198 r0, _, e1 := syscall.Syscall(procLoadCursorW.Addr(), 2, uintptr(hInstance), uintptr(cursorName), 0) 199 cursor = syscall.Handle(r0) 200 if cursor == 0 { 201 if e1 != 0 { 202 err = errnoErr(e1) 203 } else { 204 err = syscall.EINVAL 205 } 206 } 207 return 208 } 209 210 func _LoadIcon(hInstance syscall.Handle, iconName uintptr) (icon syscall.Handle, err error) { 211 r0, _, e1 := syscall.Syscall(procLoadIconW.Addr(), 2, uintptr(hInstance), uintptr(iconName), 0) 212 icon = syscall.Handle(r0) 213 if icon == 0 { 214 if e1 != 0 { 215 err = errnoErr(e1) 216 } else { 217 err = syscall.EINVAL 218 } 219 } 220 return 221 } 222 223 func _MoveWindow(hwnd syscall.Handle, x int32, y int32, w int32, h int32, repaint bool) (err error) { 224 var _p0 uint32 225 if repaint { 226 _p0 = 1 227 } else { 228 _p0 = 0 229 } 230 r1, _, e1 := syscall.Syscall6(procMoveWindow.Addr(), 6, uintptr(hwnd), uintptr(x), uintptr(y), uintptr(w), uintptr(h), uintptr(_p0)) 231 if r1 == 0 { 232 if e1 != 0 { 233 err = errnoErr(e1) 234 } else { 235 err = syscall.EINVAL 236 } 237 } 238 return 239 } 240 241 func _PostMessage(hwnd syscall.Handle, uMsg uint32, wParam uintptr, lParam uintptr) (lResult bool) { 242 r0, _, _ := syscall.Syscall6(procPostMessageW.Addr(), 4, uintptr(hwnd), uintptr(uMsg), uintptr(wParam), uintptr(lParam), 0, 0) 243 lResult = r0 != 0 244 return 245 } 246 247 func _PostQuitMessage(exitCode int32) { 248 syscall.Syscall(procPostQuitMessage.Addr(), 1, uintptr(exitCode), 0, 0) 249 return 250 } 251 252 func _RegisterClass(wc *_WNDCLASS) (atom uint16, err error) { 253 r0, _, e1 := syscall.Syscall(procRegisterClassW.Addr(), 1, uintptr(unsafe.Pointer(wc)), 0, 0) 254 atom = uint16(r0) 255 if atom == 0 { 256 if e1 != 0 { 257 err = errnoErr(e1) 258 } else { 259 err = syscall.EINVAL 260 } 261 } 262 return 263 } 264 265 func _ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) { 266 r0, _, _ := syscall.Syscall(procShowWindow.Addr(), 2, uintptr(hwnd), uintptr(cmdshow), 0) 267 wasvisible = r0 != 0 268 return 269 } 270 271 func _ScreenToClient(hwnd syscall.Handle, lpPoint *_POINT) (ok bool) { 272 r0, _, _ := syscall.Syscall(procScreenToClient.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(lpPoint)), 0) 273 ok = r0 != 0 274 return 275 } 276 277 func _ToUnicodeEx(wVirtKey uint32, wScanCode uint32, lpKeyState *byte, pwszBuff *uint16, cchBuff int32, wFlags uint32, dwhkl syscall.Handle) (ret int32) { 278 r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(wVirtKey), uintptr(wScanCode), uintptr(unsafe.Pointer(lpKeyState)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(wFlags), uintptr(dwhkl), 0, 0) 279 ret = int32(r0) 280 return 281 } 282 283 func _TranslateMessage(msg *_MSG) (done bool) { 284 r0, _, _ := syscall.Syscall(procTranslateMessage.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0) 285 done = r0 != 0 286 return 287 } 288 289 func _UnregisterClass(lpClassName *uint16, hInstance syscall.Handle) (done bool) { 290 r0, _, _ := syscall.Syscall(procUnregisterClassW.Addr(), 2, uintptr(unsafe.Pointer(lpClassName)), uintptr(hInstance), 0) 291 done = r0 != 0 292 return 293 }