1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
// mksyscall_windows.sh winapi.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package main
import "unsafe"
import "syscall"
var (
modkernel32 = loadDll("kernel32.dll")
moduser32 = loadDll("user32.dll")
procGetModuleHandleW = getSysProcAddr(modkernel32, "GetModuleHandleW")
procRegisterClassExW = getSysProcAddr(moduser32, "RegisterClassExW")
procCreateWindowExW = getSysProcAddr(moduser32, "CreateWindowExW")
procDefWindowProcW = getSysProcAddr(moduser32, "DefWindowProcW")
procDestroyWindow = getSysProcAddr(moduser32, "DestroyWindow")
procPostQuitMessage = getSysProcAddr(moduser32, "PostQuitMessage")
procShowWindow = getSysProcAddr(moduser32, "ShowWindow")
procUpdateWindow = getSysProcAddr(moduser32, "UpdateWindow")
procGetMessageW = getSysProcAddr(moduser32, "GetMessageW")
procTranslateMessage = getSysProcAddr(moduser32, "TranslateMessage")
procDispatchMessageW = getSysProcAddr(moduser32, "DispatchMessageW")
procLoadIconW = getSysProcAddr(moduser32, "LoadIconW")
procLoadCursorW = getSysProcAddr(moduser32, "LoadCursorW")
procSetCursor = getSysProcAddr(moduser32, "SetCursor")
procSendMessageW = getSysProcAddr(moduser32, "SendMessageW")
procPostMessageW = getSysProcAddr(moduser32, "PostMessageW")
)
func GetModuleHandle(modname *uint16) (handle uint32, errno int) {
r0, _, e1 := syscall.Syscall(procGetModuleHandleW, 1, uintptr(unsafe.Pointer(modname)), 0, 0)
handle = uint32(r0)
if handle == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func RegisterClassEx(wndclass *Wndclassex) (atom uint16, errno int) {
r0, _, e1 := syscall.Syscall(procRegisterClassExW, 1, uintptr(unsafe.Pointer(wndclass)), 0, 0)
atom = uint16(r0)
if atom == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent uint32, menu uint32, instance uint32, param uintptr) (hwnd uint32, errno int) {
r0, _, e1 := syscall.Syscall12(procCreateWindowExW, 12, uintptr(exstyle), uintptr(unsafe.Pointer(classname)), uintptr(unsafe.Pointer(windowname)), uintptr(style), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(wndparent), uintptr(menu), uintptr(instance), uintptr(param))
hwnd = uint32(r0)
if hwnd == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func DefWindowProc(hwnd uint32, msg uint32, wparam int32, lparam int32) (lresult int32) {
r0, _, _ := syscall.Syscall6(procDefWindowProcW, 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
lresult = int32(r0)
return
}
func DestroyWindow(hwnd uint32) (errno int) {
r1, _, e1 := syscall.Syscall(procDestroyWindow, 1, uintptr(hwnd), 0, 0)
if int(r1) == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func PostQuitMessage(exitcode int32) {
syscall.Syscall(procPostQuitMessage, 1, uintptr(exitcode), 0, 0)
return
}
func ShowWindow(hwnd uint32, cmdshow int32) (wasvisible bool) {
r0, _, _ := syscall.Syscall(procShowWindow, 2, uintptr(hwnd), uintptr(cmdshow), 0)
wasvisible = bool(r0 != 0)
return
}
func UpdateWindow(hwnd uint32) (errno int) {
r1, _, e1 := syscall.Syscall(procUpdateWindow, 1, uintptr(hwnd), 0, 0)
if int(r1) == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, errno int) {
r0, _, e1 := syscall.Syscall6(procGetMessageW, 4, uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(MsgFilterMin), uintptr(MsgFilterMax), 0, 0)
ret = int32(r0)
if ret == -1 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func TranslateMessage(msg *Msg) (done bool) {
r0, _, _ := syscall.Syscall(procTranslateMessage, 1, uintptr(unsafe.Pointer(msg)), 0, 0)
done = bool(r0 != 0)
return
}
func DispatchMessage(msg *Msg) (ret int32) {
r0, _, _ := syscall.Syscall(procDispatchMessageW, 1, uintptr(unsafe.Pointer(msg)), 0, 0)
ret = int32(r0)
return
}
func LoadIcon(instance uint32, iconname *uint16) (icon uint32, errno int) {
r0, _, e1 := syscall.Syscall(procLoadIconW, 2, uintptr(instance), uintptr(unsafe.Pointer(iconname)), 0)
icon = uint32(r0)
if icon == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func LoadCursor(instance uint32, cursorname *uint16) (cursor uint32, errno int) {
r0, _, e1 := syscall.Syscall(procLoadCursorW, 2, uintptr(instance), uintptr(unsafe.Pointer(cursorname)), 0)
cursor = uint32(r0)
if cursor == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func SetCursor(cursor uint32) (precursor uint32, errno int) {
r0, _, e1 := syscall.Syscall(procSetCursor, 1, uintptr(cursor), 0, 0)
precursor = uint32(r0)
if precursor == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
func SendMessage(hwnd uint32, msg uint32, wparam int32, lparam int32) (lresult int32) {
r0, _, _ := syscall.Syscall6(procSendMessageW, 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
lresult = int32(r0)
return
}
func PostMessage(hwnd uint32, msg uint32, wparam int32, lparam int32) (errno int) {
r1, _, e1 := syscall.Syscall6(procPostMessageW, 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
if int(r1) == 0 {
if e1 != 0 {
errno = int(e1)
} else {
errno = syscall.EINVAL
}
} else {
errno = 0
}
return
}
|