2 * SHDOCVW - Internet Explorer Web Control
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2004 Mike McCormack (for CodeWeavers)
6 * Copyright 2008 Detlef Riekenberg
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/unicode.h"
29 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw
);
42 LONG SHDOCVW_refCount
= 0;
44 HINSTANCE shdocvw_hinstance
= 0;
45 static HMODULE SHDOCVW_hshell32
= 0;
46 static HINSTANCE ieframe_instance
;
48 HINSTANCE
get_ieframe_instance(void)
50 static const WCHAR ieframe_dllW
[] = {'i','e','f','r','a','m','e','.','d','l','l',0};
53 ieframe_instance
= LoadLibraryW(ieframe_dllW
);
55 return ieframe_instance
;
58 static HRESULT
get_ieframe_object(REFCLSID rclsid
, REFIID riid
, void **ppv
)
60 HINSTANCE ieframe_instance
;
62 static HRESULT (WINAPI
*ieframe_DllGetClassObject
)(REFCLSID
,REFIID
,void**);
64 if(!ieframe_DllGetClassObject
) {
65 ieframe_instance
= get_ieframe_instance();
67 return CLASS_E_CLASSNOTAVAILABLE
;
69 ieframe_DllGetClassObject
= (void*)GetProcAddress(ieframe_instance
, "DllGetClassObject");
70 if(!ieframe_DllGetClassObject
)
71 return CLASS_E_CLASSNOTAVAILABLE
;
74 return ieframe_DllGetClassObject(rclsid
, riid
, ppv
);
77 /*************************************************************************
78 * DllGetClassObject (SHDOCVW.@)
80 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **ppv
)
84 if(IsEqualGUID(&CLSID_WebBrowser
, rclsid
)
85 || IsEqualGUID(&CLSID_WebBrowser_V1
, rclsid
)
86 || IsEqualGUID(&CLSID_InternetShortcut
, rclsid
)
87 || IsEqualGUID(&CLSID_CUrlHistory
, rclsid
)
88 || IsEqualGUID(&CLSID_TaskbarList
, rclsid
))
89 return get_ieframe_object(rclsid
, riid
, ppv
);
91 /* As a last resort, figure if the CLSID belongs to a 'Shell Instance Object' */
92 return SHDOCVW_GetShellInstanceObjectClassObject(rclsid
, riid
, ppv
);
95 /***********************************************************************
96 * DllRegisterServer (shdocvw.@)
98 HRESULT WINAPI
DllRegisterServer(void)
104 /***********************************************************************
105 * DllUnregisterServer (shdocvw.@)
107 HRESULT WINAPI
DllUnregisterServer(void)
113 /******************************************************************
114 * IEWinMain (SHDOCVW.101)
116 * Only returns on error.
118 DWORD WINAPI
IEWinMain(LPSTR szCommandLine
, int nShowWindow
)
120 DWORD (WINAPI
*pIEWinMain
)(LPSTR
,int);
122 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
124 pIEWinMain
= (void*)GetProcAddress(get_ieframe_instance(), MAKEINTRESOURCEA(101));
128 return pIEWinMain(szCommandLine
, nShowWindow
);
131 /*************************************************************************
134 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD fdwReason
, LPVOID fImpLoad
)
136 TRACE("%p 0x%x %p\n", hinst
, fdwReason
, fImpLoad
);
139 case DLL_PROCESS_ATTACH
:
140 shdocvw_hinstance
= hinst
;
142 case DLL_PROCESS_DETACH
:
143 if (SHDOCVW_hshell32
) FreeLibrary(SHDOCVW_hshell32
);
145 FreeLibrary(ieframe_instance
);
151 /*************************************************************************
152 * DllCanUnloadNow (SHDOCVW.@)
154 HRESULT WINAPI
DllCanUnloadNow(void)
156 return SHDOCVW_refCount
? S_FALSE
: S_OK
;
159 /***********************************************************************
160 * DllGetVersion (SHDOCVW.@)
162 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*info
)
164 if (info
->cbSize
!= sizeof(DLLVERSIONINFO
)) FIXME("support DLLVERSIONINFO2\n");
166 /* this is what IE6 on Windows 98 reports */
167 info
->dwMajorVersion
= 6;
168 info
->dwMinorVersion
= 0;
169 info
->dwBuildNumber
= 2600;
170 info
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
175 /*************************************************************************
176 * DllInstall (SHDOCVW.@)
178 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
180 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
185 /*************************************************************************
186 * SHDOCVW_LoadShell32
188 * makes sure the handle to shell32 is valid
190 static BOOL
SHDOCVW_LoadShell32(void)
192 if (SHDOCVW_hshell32
)
194 return ((SHDOCVW_hshell32
= LoadLibraryA("shell32.dll")) != NULL
);
197 /***********************************************************************
200 * Called by Win98 explorer.exe main binary, definitely has 0
203 DWORD WINAPI
WinList_Init(void)
205 FIXME("(), stub!\n");
209 /***********************************************************************
212 * Called by Win98 explorer.exe main binary, definitely has only one
215 static BOOL (WINAPI
*pShellDDEInit
)(BOOL start
) = NULL
;
217 BOOL WINAPI
ShellDDEInit(BOOL start
)
219 TRACE("(%d)\n", start
);
223 if (!SHDOCVW_LoadShell32())
225 pShellDDEInit
= (void *)GetProcAddress(SHDOCVW_hshell32
, (LPCSTR
)188);
229 return pShellDDEInit(start
);
234 /***********************************************************************
237 * Called by Win98 explorer.exe main binary, definitely has 0
240 DWORD WINAPI
RunInstallUninstallStubs(void)
242 FIXME("(), stub!\n");
246 /***********************************************************************
249 * Called by Emerge Desktop (alternative Windows Shell).
251 DWORD WINAPI
RunInstallUninstallStubs2(void)
253 FIXME("(), stub!\n");
257 /***********************************************************************
258 * SetQueryNetSessionCount (SHDOCVW.@)
260 DWORD WINAPI
SetQueryNetSessionCount(DWORD arg
)
262 FIXME("(%u), stub!\n", arg
);
266 /**********************************************************************
267 * Some forwards (by ordinal) to SHLWAPI
270 static void* fetch_shlwapi_ordinal(UINT_PTR ord
)
272 static const WCHAR shlwapiW
[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
275 if (!h
&& !(h
= GetModuleHandleW(shlwapiW
))) return NULL
;
276 return (void*)GetProcAddress(h
, (const char*)ord
);
279 /******************************************************************
280 * WhichPlatformFORWARD (SHDOCVW.@)
282 DWORD WINAPI
WhichPlatformFORWARD(void)
284 static DWORD (WINAPI
*p
)(void);
286 if (p
|| (p
= fetch_shlwapi_ordinal(276))) return p();
287 return 1; /* not integrated, see shlwapi.WhichPlatform */
290 /******************************************************************
291 * StopWatchModeFORWARD (SHDOCVW.@)
293 void WINAPI
StopWatchModeFORWARD(void)
295 static void (WINAPI
*p
)(void);
297 if (p
|| (p
= fetch_shlwapi_ordinal(241))) p();
300 /******************************************************************
301 * StopWatchFlushFORWARD (SHDOCVW.@)
303 void WINAPI
StopWatchFlushFORWARD(void)
305 static void (WINAPI
*p
)(void);
307 if (p
|| (p
= fetch_shlwapi_ordinal(242))) p();
310 /******************************************************************
311 * StopWatchWFORWARD (SHDOCVW.@)
313 DWORD WINAPI
StopWatchWFORWARD(DWORD dwClass
, LPCWSTR lpszStr
, DWORD dwUnknown
,
314 DWORD dwMode
, DWORD dwTimeStamp
)
316 static DWORD (WINAPI
*p
)(DWORD
, LPCWSTR
, DWORD
, DWORD
, DWORD
);
318 if (p
|| (p
= fetch_shlwapi_ordinal(243)))
319 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
320 return ERROR_CALL_NOT_IMPLEMENTED
;
323 /******************************************************************
324 * StopWatchAFORWARD (SHDOCVW.@)
326 DWORD WINAPI
StopWatchAFORWARD(DWORD dwClass
, LPCSTR lpszStr
, DWORD dwUnknown
,
327 DWORD dwMode
, DWORD dwTimeStamp
)
329 static DWORD (WINAPI
*p
)(DWORD
, LPCSTR
, DWORD
, DWORD
, DWORD
);
331 if (p
|| (p
= fetch_shlwapi_ordinal(244)))
332 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
333 return ERROR_CALL_NOT_IMPLEMENTED
;
336 /******************************************************************
337 * URLSubRegQueryA (SHDOCVW.151)
339 HRESULT WINAPI
URLSubRegQueryA(LPCSTR regpath
, LPCSTR name
, DWORD type
,
340 LPSTR out
, DWORD outlen
, DWORD unknown
)
342 CHAR buffer
[INTERNET_MAX_URL_LENGTH
];
346 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath
), debugstr_a(name
),
347 type
, out
, outlen
, unknown
);
349 if (!out
) return S_OK
;
351 len
= sizeof(buffer
);
352 res
= SHRegGetUSValueA(regpath
, name
, NULL
, buffer
, &len
, FALSE
, NULL
, 0);
354 lstrcpynA(out
, buffer
, outlen
);
361 /******************************************************************
362 * ParseURLFromOutsideSourceW (SHDOCVW.170)
364 DWORD WINAPI
ParseURLFromOutsideSourceW(LPCWSTR url
, LPWSTR out
, LPDWORD plen
, LPDWORD unknown
)
366 WCHAR buffer_in
[INTERNET_MAX_URL_LENGTH
];
367 WCHAR buffer_out
[INTERNET_MAX_URL_LENGTH
];
375 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url
), out
, plen
, unknown
,
376 plen
? *plen
: 0, unknown
? *unknown
: 0);
378 if (!PathIsURLW(ptr
)) {
379 len
= sizeof(buffer_in
) / sizeof(buffer_in
[0]);
381 hr
= UrlApplySchemeW(ptr
, buffer_in
, &len
, URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
);
382 TRACE("got 0x%x with %s\n", hr
, debugstr_w(buffer_in
));
384 /* we parsed the url to buffer_in */
389 FIXME("call search hook for %s\n", debugstr_w(ptr
));
393 len
= sizeof(buffer_out
) / sizeof(buffer_out
[0]);
394 buffer_out
[0] = '\0';
395 hr
= UrlCanonicalizeW(ptr
, buffer_out
, &len
, URL_ESCAPE_SPACES_ONLY
);
396 needed
= lstrlenW(buffer_out
)+1;
397 TRACE("got 0x%x with %s (need %d)\n", hr
, debugstr_w(buffer_out
), needed
);
399 if (*plen
>= needed
) {
401 lstrcpyW(out
, buffer_out
);
409 TRACE("=> %d\n", res
);
413 /******************************************************************
414 * ParseURLFromOutsideSourceA (SHDOCVW.169)
416 * See ParseURLFromOutsideSourceW
418 DWORD WINAPI
ParseURLFromOutsideSourceA(LPCSTR url
, LPSTR out
, LPDWORD plen
, LPDWORD unknown
)
420 WCHAR buffer
[INTERNET_MAX_URL_LENGTH
];
426 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url
), out
, plen
, unknown
,
427 plen
? *plen
: 0, unknown
? *unknown
: 0);
430 len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
431 urlW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
432 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
435 len
= sizeof(buffer
) / sizeof(buffer
[0]);
436 res
= ParseURLFromOutsideSourceW(urlW
, buffer
, &len
, unknown
);
437 HeapFree(GetProcessHeap(), 0, urlW
);
439 needed
= WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, NULL
, 0, NULL
, NULL
);
442 if (*plen
>= needed
) {
444 WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, out
, *plen
, NULL
, NULL
);
452 TRACE("=> %d\n", res
);
456 /******************************************************************
457 * IEParseDisplayNameWithBCW (SHDOCVW.218)
459 HRESULT WINAPI
IEParseDisplayNameWithBCW(DWORD codepage
, LPCWSTR lpszDisplayName
, LPBC pbc
, LPITEMIDLIST
*ppidl
)
461 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
462 FIXME("stub: 0x%x %s %p %p\n",codepage
,debugstr_w(lpszDisplayName
),pbc
,ppidl
);
466 /******************************************************************
467 * SHRestricted2W (SHDOCVW.159)
469 DWORD WINAPI
SHRestricted2W(DWORD res
, LPCWSTR url
, DWORD reserved
)
471 FIXME("(%d %s %d) stub\n", res
, debugstr_w(url
), reserved
);
475 /******************************************************************
476 * SHRestricted2A (SHDOCVW.158)
480 DWORD WINAPI
SHRestricted2A(DWORD restriction
, LPCSTR url
, DWORD reserved
)
485 TRACE("(%d, %s, %d)\n", restriction
, debugstr_a(url
), reserved
);
487 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
488 urlW
= heap_alloc(len
* sizeof(WCHAR
));
489 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
491 res
= SHRestricted2W(restriction
, urlW
, reserved
);
496 /******************************************************************
497 * ImportPrivacySettings (SHDOCVW.@)
499 * Import global and/or per site privacy preferences from an xml file
502 * filename [I] XML file to use
503 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
504 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
507 * Success: TRUE (the privacy preferences where updated)
508 * Failure: FALSE (the privacy preferences are unchanged)
511 * Set the flag to TRUE, when the related privacy preferences in the xml file
512 * should be used (parsed and overwrite the current settings).
513 * On return, the flag is TRUE, when the related privacy settings where used
516 BOOL WINAPI
ImportPrivacySettings(LPCWSTR filename
, BOOL
*pGlobalPrefs
, BOOL
* pPerSitePrefs
)
518 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename
),
519 pGlobalPrefs
, pGlobalPrefs
? *pGlobalPrefs
: 0,
520 pPerSitePrefs
, pPerSitePrefs
? *pPerSitePrefs
: 0);
522 if (pGlobalPrefs
) *pGlobalPrefs
= FALSE
;
523 if (pPerSitePrefs
) *pPerSitePrefs
= FALSE
;