rpcrt4: Check for integer overflows when increasing the buffer length.
[wine] / dlls / shdocvw / shdocvw.h
1 /*
2  * Header includes for shdocvw.dll
3  *
4  * Copyright 2001 John R. Sheets (for CodeWeavers)
5  * Copyright 2005-2006 Jacek Caban for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #ifndef __WINE_SHDOCVW_H
23 #define __WINE_SHDOCVW_H
24
25 #define COBJMACROS
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33
34 #include "ole2.h"
35 #include "olectl.h"
36 #include "shlobj.h"
37 #include "exdisp.h"
38 #include "mshtmhst.h"
39 #include "hlink.h"
40
41 /**********************************************************************
42  * Shell Instance Objects
43  */
44 extern HRESULT SHDOCVW_GetShellInstanceObjectClassObject(REFCLSID rclsid, 
45     REFIID riid, LPVOID *ppvClassObj);
46
47 /**********************************************************************
48  * WebBrowser declaration for SHDOCVW.DLL
49  */
50
51 typedef struct ConnectionPoint ConnectionPoint;
52
53 typedef struct {
54     const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
55
56     ConnectionPoint *wbe2;
57     ConnectionPoint *wbe;
58     ConnectionPoint *pns;
59
60     IUnknown *impl;
61 } ConnectionPointContainer;
62
63 typedef struct {
64     const IOleClientSiteVtbl      *lpOleClientSiteVtbl;
65     const IOleInPlaceSiteVtbl     *lpOleInPlaceSiteVtbl;
66     const IDocHostUIHandler2Vtbl  *lpDocHostUIHandlerVtbl;
67     const IOleDocumentSiteVtbl    *lpOleDocumentSiteVtbl;
68     const IOleCommandTargetVtbl   *lpOleCommandTargetVtbl;
69     const IDispatchVtbl           *lpDispatchVtbl;
70     const IServiceProviderVtbl    *lpServiceProviderVtbl;
71
72     /* Interfaces of InPlaceFrame object */
73     const IOleInPlaceFrameVtbl          *lpOleInPlaceFrameVtbl;
74
75     IDispatch *disp;
76
77     IDispatch *client_disp;
78     IDocHostUIHandler *hostui;
79     IOleInPlaceFrame *frame;
80
81     IUnknown *document;
82     IOleDocumentView *view;
83
84     HWND hwnd;
85     HWND frame_hwnd;
86
87     LPOLESTR url;
88
89     VARIANT_BOOL silent;
90     VARIANT_BOOL offline;
91
92     ConnectionPointContainer cps;
93 } DocHost;
94
95 struct WebBrowser {
96     /* Interfaces available via WebBrowser object */
97
98     const IWebBrowser2Vtbl              *lpWebBrowser2Vtbl;
99     const IOleObjectVtbl                *lpOleObjectVtbl;
100     const IOleInPlaceObjectVtbl         *lpOleInPlaceObjectVtbl;
101     const IOleControlVtbl               *lpOleControlVtbl;
102     const IPersistStorageVtbl           *lpPersistStorageVtbl;
103     const IPersistMemoryVtbl            *lpPersistMemoryVtbl;
104     const IPersistStreamInitVtbl        *lpPersistStreamInitVtbl;
105     const IProvideClassInfo2Vtbl        *lpProvideClassInfoVtbl;
106     const IViewObject2Vtbl              *lpViewObjectVtbl;
107     const IOleInPlaceActiveObjectVtbl   *lpOleInPlaceActiveObjectVtbl;
108     const IOleCommandTargetVtbl         *lpOleCommandTargetVtbl;
109     const IHlinkFrameVtbl               *lpHlinkFrameVtbl;
110
111     LONG ref;
112
113     INT version;
114
115     IOleClientSite *client;
116     IOleContainer *container;
117     IOleInPlaceSite *inplace;
118
119     /* window context */
120
121     HWND frame_hwnd;
122     IOleInPlaceUIWindow *uiwindow;
123     RECT pos_rect;
124     RECT clip_rect;
125     OLEINPLACEFRAMEINFO frameinfo;
126     SIZEL extent;
127
128     HWND shell_embedding_hwnd;
129
130     VARIANT_BOOL visible;
131     VARIANT_BOOL menu_bar;
132     VARIANT_BOOL address_bar;
133     VARIANT_BOOL status_bar;
134     VARIANT_BOOL tool_bar;
135     VARIANT_BOOL full_screen;
136
137     DocHost doc_host;
138 };
139
140 struct InternetExplorer {
141     const IWebBrowser2Vtbl *lpWebBrowser2Vtbl;
142
143     LONG ref;
144
145     HWND frame_hwnd;
146
147     DocHost doc_host;
148 };
149
150 #define WEBBROWSER(x)   ((IWebBrowser*)                 &(x)->lpWebBrowser2Vtbl)
151 #define WEBBROWSER2(x)  ((IWebBrowser2*)                &(x)->lpWebBrowser2Vtbl)
152 #define OLEOBJ(x)       ((IOleObject*)                  &(x)->lpOleObjectVtbl)
153 #define INPLACEOBJ(x)   ((IOleInPlaceObject*)           &(x)->lpOleInPlaceObjectVtbl)
154 #define CONTROL(x)      ((IOleControl*)                 &(x)->lpOleControlVtbl)
155 #define PERSTORAGE(x)   ((IPersistStorage*)             &(x)->lpPersistStorageVtbl)
156 #define PERMEMORY(x)    ((IPersistMemory*)              &(x)->lpPersistMemoryVtbl)
157 #define PERSTRINIT(x)   ((IPersistStreamInit*)          &(x)->lpPersistStreamInitVtbl)
158 #define CLASSINFO(x)    ((IProvideClassInfo2*)          &(x)->lpProvideClassInfoVtbl)
159 #define CONPTCONT(x)    ((IConnectionPointContainer*)   &(x)->lpConnectionPointContainerVtbl)
160 #define VIEWOBJ(x)      ((IViewObject*)                 &(x)->lpViewObjectVtbl);
161 #define VIEWOBJ2(x)     ((IViewObject2*)                &(x)->lpViewObjectVtbl);
162 #define ACTIVEOBJ(x)    ((IOleInPlaceActiveObject*)     &(x)->lpOleInPlaceActiveObjectVtbl)
163 #define OLECMD(x)       ((IOleCommandTarget*)           &(x)->lpOleCommandTargetVtbl)
164 #define HLINKFRAME(x)   ((IHlinkFrame*)                 &(x)->lpHlinkFrameVtbl)
165
166 #define CLIENTSITE(x)   ((IOleClientSite*)              &(x)->lpOleClientSiteVtbl)
167 #define INPLACESITE(x)  ((IOleInPlaceSite*)             &(x)->lpOleInPlaceSiteVtbl)
168 #define DOCHOSTUI(x)    ((IDocHostUIHandler*)           &(x)->lpDocHostUIHandlerVtbl)
169 #define DOCHOSTUI2(x)   ((IDocHostUIHandler2*)          &(x)->lpDocHostUIHandlerVtbl)
170 #define DOCSITE(x)      ((IOleDocumentSite*)            &(x)->lpOleDocumentSiteVtbl)
171 #define CLDISP(x)       ((IDispatch*)                   &(x)->lpDispatchVtbl)
172 #define SERVPROV(x)     ((IServiceProvider*)            &(x)->lpServiceProviderVtbl)
173
174 #define INPLACEFRAME(x) ((IOleInPlaceFrame*)            &(x)->lpOleInPlaceFrameVtbl)
175
176 void WebBrowser_OleObject_Init(WebBrowser*);
177 void WebBrowser_ViewObject_Init(WebBrowser*);
178 void WebBrowser_Persist_Init(WebBrowser*);
179 void WebBrowser_ClassInfo_Init(WebBrowser*);
180 void WebBrowser_HlinkFrame_Init(WebBrowser*);
181
182 void WebBrowser_OleObject_Destroy(WebBrowser*);
183
184 void DocHost_Init(DocHost*,IDispatch*);
185 void DocHost_ClientSite_Init(DocHost*);
186 void DocHost_Frame_Init(DocHost*);
187
188 void DocHost_Release(DocHost*);
189 void DocHost_ClientSite_Release(DocHost*);
190
191 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
192 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
193
194 HRESULT WebBrowserV1_Create(IUnknown*,REFIID,void**);
195 HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**);
196
197 void create_doc_view_hwnd(DocHost*);
198 void deactivate_document(DocHost*);
199 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
200 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*);
201 HRESULT go_home(DocHost*);
202
203 HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**);
204 void InternetExplorer_WebBrowser_Init(InternetExplorer*);
205
206 HRESULT CUrlHistory_Create(IUnknown*,REFIID,void**);
207
208 #define WB_WM_NAVIGATE2 (WM_USER+100)
209
210 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
211
212 /**********************************************************************
213  * Dll lifetime tracking declaration for shdocvw.dll
214  */
215 extern LONG SHDOCVW_refCount;
216 static inline void SHDOCVW_LockModule(void) { InterlockedIncrement( &SHDOCVW_refCount ); }
217 static inline void SHDOCVW_UnlockModule(void) { InterlockedDecrement( &SHDOCVW_refCount ); }
218
219 extern HINSTANCE shdocvw_hinstance;
220 extern void register_iewindow_class(void);
221 extern void unregister_iewindow_class(void);
222
223 HRESULT register_class_object(BOOL);
224 HRESULT get_typeinfo(ITypeInfo**);
225 DWORD register_iexplore(BOOL);
226
227 /* memory allocation functions */
228
229 static inline void *heap_alloc(size_t len)
230 {
231     return HeapAlloc(GetProcessHeap(), 0, len);
232 }
233
234 static inline void *heap_realloc(void *mem, size_t len)
235 {
236     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
237 }
238
239 static inline BOOL heap_free(void *mem)
240 {
241     return HeapFree(GetProcessHeap(), 0, mem);
242 }
243
244 #endif /* __WINE_SHDOCVW_H */