ntdll: Add ACTCTX field limit checks to RtlCreateActivationContext().
[wine.git] / dlls / urlmon / urlmon_main.h
blob81b0d629f536ac6e9284c4ad26330f16516e2fe9
1 /*
2 * Copyright 2002 Huw D M Davies for CodeWeavers
3 * Copyright 2009 Jacek Caban for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_URLMON_MAIN_H
21 #define __WINE_URLMON_MAIN_H
23 #include <stdarg.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "ole2.h"
31 #include "urlmon.h"
32 #include "wininet.h"
34 #include "wine/list.h"
36 extern HINSTANCE hProxyDll;
37 extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
38 extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
39 extern HRESULT StdURLMoniker_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
40 extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
41 extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
42 extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
43 extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
44 extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
45 extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
46 extern HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
47 extern HRESULT Uri_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
49 extern BOOL WINAPI URLMON_DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
50 extern HRESULT WINAPI URLMON_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv);
51 extern HRESULT WINAPI URLMON_DllRegisterServer(void);
52 extern HRESULT WINAPI URLMON_DllUnregisterServer(void);
54 extern GUID const CLSID_PSFactoryBuffer;
55 extern GUID const CLSID_CUri;
57 /**********************************************************************
58 * Dll lifetime tracking declaration for urlmon.dll
60 extern LONG URLMON_refCount;
61 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
62 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
64 extern HINSTANCE urlmon_instance;
66 IInternetProtocolInfo *get_protocol_info(LPCWSTR);
67 HRESULT get_protocol_handler(IUri*,CLSID*,IClassFactory**);
68 IInternetProtocol *get_mime_filter(LPCWSTR);
69 BOOL is_registered_protocol(LPCWSTR);
70 HRESULT register_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL);
71 HINTERNET get_internet_session(IInternetBindInfo*);
72 WCHAR *get_useragent(void);
73 void update_user_agent(WCHAR*);
74 void free_session(void);
76 HRESULT find_mime_from_ext(const WCHAR*,WCHAR**);
78 HRESULT bind_to_storage(IUri*,IBindCtx*,REFIID,void**);
79 HRESULT bind_to_object(IMoniker*,IUri*,IBindCtx*,REFIID,void**ppv);
81 HRESULT create_default_callback(IBindStatusCallback**);
82 HRESULT wrap_callback(IBindStatusCallback*,IBindStatusCallback**);
83 IBindStatusCallback *bsc_from_bctx(IBindCtx*);
85 typedef HRESULT (*stop_cache_binding_proc_t)(void*,const WCHAR*,HRESULT,const WCHAR*);
86 HRESULT download_to_cache(IUri*,stop_cache_binding_proc_t,void*,IBindStatusCallback*);
88 typedef struct ProtocolVtbl ProtocolVtbl;
90 typedef struct {
91 const ProtocolVtbl *vtbl;
93 IInternetProtocol *protocol;
94 IInternetProtocolSink *protocol_sink;
96 DWORD bindf;
97 BINDINFO bind_info;
99 HINTERNET request;
100 HINTERNET connection;
101 DWORD flags;
102 HANDLE lock;
104 ULONG current_position;
105 ULONG content_length;
106 ULONG available_bytes;
107 ULONG query_available;
109 IStream *post_stream;
111 LONG priority;
112 } Protocol;
114 struct ProtocolVtbl {
115 HRESULT (*open_request)(Protocol*,IUri*,DWORD,HINTERNET,IInternetBindInfo*);
116 HRESULT (*end_request)(Protocol*);
117 HRESULT (*start_downloading)(Protocol*);
118 void (*close_connection)(Protocol*);
119 void (*on_error)(Protocol*,DWORD);
122 /* Flags are needed for, among other things, return HRESULTs from the Read function
123 * to conform to native. For example, Read returns:
125 * 1. E_PENDING if called before the request has completed,
126 * (flags = 0)
127 * 2. S_FALSE after all data has been read and S_OK has been reported,
128 * (flags = FLAG_REQUEST_COMPLETE | FLAG_ALL_DATA_READ | FLAG_RESULT_REPORTED)
129 * 3. INET_E_DATA_NOT_AVAILABLE if InternetQueryDataAvailable fails. The first time
130 * this occurs, INET_E_DATA_NOT_AVAILABLE will also be reported to the sink,
131 * (flags = FLAG_REQUEST_COMPLETE)
132 * but upon subsequent calls to Read no reporting will take place, yet
133 * InternetQueryDataAvailable will still be called, and, on failure,
134 * INET_E_DATA_NOT_AVAILABLE will still be returned.
135 * (flags = FLAG_REQUEST_COMPLETE | FLAG_RESULT_REPORTED)
137 * FLAG_FIRST_DATA_REPORTED and FLAG_LAST_DATA_REPORTED are needed for proper
138 * ReportData reporting. For example, if OnResponse returns S_OK, Continue will
139 * report BSCF_FIRSTDATANOTIFICATION, and when all data has been read Read will
140 * report BSCF_INTERMEDIATEDATANOTIFICATION|BSCF_LASTDATANOTIFICATION. However,
141 * if OnResponse does not return S_OK, Continue will not report data, and Read
142 * will report BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION when all
143 * data has been read.
145 #define FLAG_REQUEST_COMPLETE 0x0001
146 #define FLAG_FIRST_CONTINUE_COMPLETE 0x0002
147 #define FLAG_FIRST_DATA_REPORTED 0x0004
148 #define FLAG_ALL_DATA_READ 0x0008
149 #define FLAG_LAST_DATA_REPORTED 0x0010
150 #define FLAG_RESULT_REPORTED 0x0020
151 #define FLAG_ERROR 0x0040
152 #define FLAG_SYNC_READ 0x0080
154 HRESULT protocol_start(Protocol*,IInternetProtocol*,IUri*,IInternetProtocolSink*,IInternetBindInfo*);
155 HRESULT protocol_continue(Protocol*,PROTOCOLDATA*);
156 HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*);
157 HRESULT protocol_lock_request(Protocol*);
158 HRESULT protocol_unlock_request(Protocol*);
159 HRESULT protocol_abort(Protocol*,HRESULT);
160 HRESULT protocol_syncbinding(Protocol*);
161 void protocol_close_connection(Protocol*);
163 void find_domain_name(const WCHAR*,DWORD,INT*);
165 typedef struct _task_header_t task_header_t;
167 typedef struct {
168 IInternetProtocolEx IInternetProtocolEx_iface;
169 IInternetBindInfo IInternetBindInfo_iface;
170 IInternetPriority IInternetPriority_iface;
171 IServiceProvider IServiceProvider_iface;
172 IInternetProtocolSink IInternetProtocolSink_iface;
174 LONG ref;
176 IUnknown *protocol_unk;
177 IInternetProtocol *protocol;
179 IInternetBindInfo *bind_info;
180 IInternetProtocolSink *protocol_sink;
181 IServiceProvider *service_provider;
182 IBindCallbackRedirect *redirect_callback;
184 struct {
185 IInternetProtocol IInternetProtocol_iface;
186 IInternetProtocolSink IInternetProtocolSink_iface;
187 } default_protocol_handler;
188 IInternetProtocol *protocol_handler;
189 IInternetProtocolSink *protocol_sink_handler;
191 LONG priority;
193 BOOL reported_result;
194 BOOL reported_mime;
195 DWORD pi;
197 DWORD bscf;
198 ULONG progress;
199 ULONG progress_max;
201 DWORD apartment_thread;
202 HWND notif_hwnd;
203 DWORD continue_call;
205 CRITICAL_SECTION section;
206 task_header_t *task_queue_head, *task_queue_tail;
208 BYTE *buf;
209 DWORD buf_size;
210 LPWSTR mime;
211 IUri *uri;
212 BSTR display_uri;
213 } BindProtocol;
215 HRESULT create_binding_protocol(BindProtocol**);
216 void set_binding_sink(BindProtocol*,IInternetProtocolSink*,IInternetBindInfo*);
218 typedef struct {
219 HWND notif_hwnd;
220 DWORD notif_hwnd_cnt;
222 struct list entry;
223 } tls_data_t;
225 tls_data_t *get_tls_data(void);
227 void unregister_notif_wnd_class(void);
228 HWND get_notif_hwnd(void);
229 void release_notif_hwnd(HWND);
231 const char *debugstr_bindstatus(ULONG);
233 static inline WCHAR *strndupW(LPCWSTR str, int len)
235 LPWSTR ret = NULL;
237 if(str) {
238 ret = malloc((len + 1) * sizeof(WCHAR));
239 if(ret) {
240 memcpy(ret, str, len*sizeof(WCHAR));
241 ret[len] = 0;
245 return ret;
248 static inline WCHAR *strdupAtoW(const char *str)
250 LPWSTR ret = NULL;
252 if(str) {
253 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
254 ret = malloc(len * sizeof(WCHAR));
255 if(ret)
256 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
259 return ret;
262 #endif /* __WINE_URLMON_MAIN_H */