-
Notifications
You must be signed in to change notification settings - Fork 316
/
shdocvw.go
327 lines (287 loc) · 9.34 KB
/
shdocvw.go
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
// Copyright 2010 The win Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build windows
package win
import (
"syscall"
"unsafe"
)
const (
DOCHOSTUIDBLCLK_DEFAULT = 0
DOCHOSTUIDBLCLK_SHOWPROPERTIES = 1
DOCHOSTUIDBLCLK_SHOWCODE = 2
)
const (
DOCHOSTUIFLAG_DIALOG = 0x1
DOCHOSTUIFLAG_DISABLE_HELP_MENU = 0x2
DOCHOSTUIFLAG_NO3DBORDER = 0x4
DOCHOSTUIFLAG_SCROLL_NO = 0x8
DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 0x10
DOCHOSTUIFLAG_OPENNEWWIN = 0x20
DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 0x40
DOCHOSTUIFLAG_FLAT_SCROLLBAR = 0x80
DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 0x100
DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 0x200
DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY = 0x400
DOCHOSTUIFLAG_CODEPAGELINKEDFONTS = 0x800
DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8 = 0x1000
DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 = 0x2000
DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE = 0x4000
DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION = 0x10000
DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION = 0x20000
DOCHOSTUIFLAG_THEME = 0x40000
DOCHOSTUIFLAG_NOTHEME = 0x80000
DOCHOSTUIFLAG_NOPICS = 0x100000
DOCHOSTUIFLAG_NO3DOUTERBORDER = 0x200000
DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP = 0x400000
DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK = 0x800000
DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL = 0x1000000
)
// BrowserNavConstants
const (
NavOpenInNewWindow = 0x1
NavNoHistory = 0x2
NavNoReadFromCache = 0x4
NavNoWriteToCache = 0x8
NavAllowAutosearch = 0x10
NavBrowserBar = 0x20
NavHyperlink = 0x40
NavEnforceRestricted = 0x80
NavNewWindowsManaged = 0x0100
NavUntrustedForDownload = 0x0200
NavTrustedForActiveX = 0x0400
NavOpenInNewTab = 0x0800
NavOpenInBackgroundTab = 0x1000
NavKeepWordWheelText = 0x2000
NavVirtualTab = 0x4000
NavBlockRedirectsXDomain = 0x8000
NavOpenNewForegroundTab = 0x10000
)
var (
CLSID_WebBrowser = CLSID{0x8856F961, 0x340A, 0x11D0, [8]byte{0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2}}
DIID_DWebBrowserEvents2 = IID{0x34A715A0, 0x6587, 0x11D0, [8]byte{0x92, 0x4A, 0x00, 0x20, 0xAF, 0xC7, 0xAC, 0x4D}}
IID_IWebBrowser2 = IID{0xD30C1661, 0xCDAF, 0x11D0, [8]byte{0x8A, 0x3E, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E}}
IID_IDocHostUIHandler = IID{0xBD3F23C0, 0xD43E, 0x11CF, [8]byte{0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A}}
IID_IOleInPlaceActiveObject = IID{0x00000117, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}
)
type DWebBrowserEvents2Vtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
GetTypeInfoCount uintptr
GetTypeInfo uintptr
GetIDsOfNames uintptr
Invoke uintptr
}
type DWebBrowserEvents2 struct {
LpVtbl *DWebBrowserEvents2Vtbl
}
type IWebBrowser2Vtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
GetTypeInfoCount uintptr
GetTypeInfo uintptr
GetIDsOfNames uintptr
Invoke uintptr
GoBack uintptr
GoForward uintptr
GoHome uintptr
GoSearch uintptr
Navigate uintptr
Refresh uintptr
Refresh2 uintptr
Stop uintptr
Get_Application uintptr
Get_Parent uintptr
Get_Container uintptr
Get_Document uintptr
Get_TopLevelContainer uintptr
Get_Type uintptr
Get_Left uintptr
Put_Left uintptr
Get_Top uintptr
Put_Top uintptr
Get_Width uintptr
Put_Width uintptr
Get_Height uintptr
Put_Height uintptr
Get_LocationName uintptr
Get_LocationURL uintptr
Get_Busy uintptr
Quit uintptr
ClientToWindow uintptr
PutProperty uintptr
GetProperty uintptr
Get_Name uintptr
Get_HWND uintptr
Get_FullName uintptr
Get_Path uintptr
Get_Visible uintptr
Put_Visible uintptr
Get_StatusBar uintptr
Put_StatusBar uintptr
Get_StatusText uintptr
Put_StatusText uintptr
Get_ToolBar uintptr
Put_ToolBar uintptr
Get_MenuBar uintptr
Put_MenuBar uintptr
Get_FullScreen uintptr
Put_FullScreen uintptr
Navigate2 uintptr
QueryStatusWB uintptr
ExecWB uintptr
ShowBrowserBar uintptr
Get_ReadyState uintptr
Get_Offline uintptr
Put_Offline uintptr
Get_Silent uintptr
Put_Silent uintptr
Get_RegisterAsBrowser uintptr
Put_RegisterAsBrowser uintptr
Get_RegisterAsDropTarget uintptr
Put_RegisterAsDropTarget uintptr
Get_TheaterMode uintptr
Put_TheaterMode uintptr
Get_AddressBar uintptr
Put_AddressBar uintptr
Get_Resizable uintptr
Put_Resizable uintptr
}
type IWebBrowser2 struct {
LpVtbl *IWebBrowser2Vtbl
}
func (wb2 *IWebBrowser2) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT {
ret, _, _ := syscall.Syscall(wb2.LpVtbl.QueryInterface, 3,
uintptr(unsafe.Pointer(wb2)),
uintptr(unsafe.Pointer(riid)),
uintptr(unsafe.Pointer(ppvObject)))
return HRESULT(ret)
}
func (wb2 *IWebBrowser2) Release() HRESULT {
ret, _, _ := syscall.Syscall(wb2.LpVtbl.Release, 1,
uintptr(unsafe.Pointer(wb2)),
0,
0)
return HRESULT(ret)
}
func (wb2 *IWebBrowser2) Refresh() HRESULT {
ret, _, _ := syscall.Syscall(wb2.LpVtbl.Refresh, 1,
uintptr(unsafe.Pointer(wb2)),
0,
0)
return HRESULT(ret)
}
func (wb2 *IWebBrowser2) Put_Left(Left int32) HRESULT {
ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Left, 2,
uintptr(unsafe.Pointer(wb2)),
uintptr(Left),
0)
return HRESULT(ret)
}
func (wb2 *IWebBrowser2) Put_Top(Top int32) HRESULT {
ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Top, 2,
uintptr(unsafe.Pointer(wb2)),
uintptr(Top),
0)
return HRESULT(ret)
}
func (wb2 *IWebBrowser2) Put_Width(Width int32) HRESULT {
ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Width, 2,
uintptr(unsafe.Pointer(wb2)),
uintptr(Width),
0)
return HRESULT(ret)
}
func (wb2 *IWebBrowser2) Put_Height(Height int32) HRESULT {
ret, _, _ := syscall.Syscall(wb2.LpVtbl.Put_Height, 2,
uintptr(unsafe.Pointer(wb2)),
uintptr(Height),
0)
return HRESULT(ret)
}
func (wb2 *IWebBrowser2) Get_LocationURL(pbstrLocationURL **uint16 /*BSTR*/) HRESULT {
ret, _, _ := syscall.Syscall(wb2.LpVtbl.Get_LocationURL, 2,
uintptr(unsafe.Pointer(wb2)),
uintptr(unsafe.Pointer(pbstrLocationURL)),
0)
return HRESULT(ret)
}
func (wb2 *IWebBrowser2) Navigate2(URL *VAR_BSTR, Flags *VAR_I4, TargetFrameName *VAR_BSTR, PostData unsafe.Pointer, Headers *VAR_BSTR) HRESULT {
ret, _, _ := syscall.Syscall6(wb2.LpVtbl.Navigate2, 6,
uintptr(unsafe.Pointer(wb2)),
uintptr(unsafe.Pointer(URL)),
uintptr(unsafe.Pointer(Flags)),
uintptr(unsafe.Pointer(TargetFrameName)),
uintptr(PostData),
uintptr(unsafe.Pointer(Headers)))
return HRESULT(ret)
}
type IDocHostUIHandlerVtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
ShowContextMenu uintptr
GetHostInfo uintptr
ShowUI uintptr
HideUI uintptr
UpdateUI uintptr
EnableModeless uintptr
OnDocWindowActivate uintptr
OnFrameWindowActivate uintptr
ResizeBorder uintptr
TranslateAccelerator uintptr
GetOptionKeyPath uintptr
GetDropTarget uintptr
GetExternal uintptr
TranslateUrl uintptr
FilterDataObject uintptr
}
type IDocHostUIHandler struct {
LpVtbl *IDocHostUIHandlerVtbl
}
type DOCHOSTUIINFO struct {
CbSize uint32
DwFlags uint32
DwDoubleClick uint32
PchHostCss *uint16
PchHostNS *uint16
}
type IOleInPlaceActiveObjectVtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
GetWindow uintptr
ContextSensitiveHelp uintptr
TranslateAccelerator uintptr
OnFrameWindowActivate uintptr
OnDocWindowActivate uintptr
ResizeBorder uintptr
EnableModeless uintptr
}
type IOleInPlaceActiveObject struct {
LpVtbl *IOleInPlaceActiveObjectVtbl
}
func (activeObj *IOleInPlaceActiveObject) Release() HRESULT {
ret, _, _ := syscall.Syscall(activeObj.LpVtbl.Release, 1,
uintptr(unsafe.Pointer(activeObj)),
0,
0)
return HRESULT(ret)
}
func (activeObj *IOleInPlaceActiveObject) GetWindow(hWndPtr *HWND) HRESULT {
ret, _, _ := syscall.Syscall(activeObj.LpVtbl.GetWindow, 2,
uintptr(unsafe.Pointer(activeObj)),
uintptr(unsafe.Pointer(hWndPtr)),
0)
return HRESULT(ret)
}
func (activeObj *IOleInPlaceActiveObject) TranslateAccelerator(msg *MSG) HRESULT {
ret, _, _ := syscall.Syscall(activeObj.LpVtbl.TranslateAccelerator, 2,
uintptr(unsafe.Pointer(activeObj)),
uintptr(unsafe.Pointer(msg)),
0)
return HRESULT(ret)
}