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 static 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
)(const WCHAR
*,int);
124 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
126 pIEWinMain
= (void*)GetProcAddress(get_ieframe_instance(), MAKEINTRESOURCEA(101));
130 len
= MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, NULL
, 0);
131 cmdline
= heap_alloc(len
*sizeof(WCHAR
));
134 MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, cmdline
, len
);
136 ret
= pIEWinMain(cmdline
, nShowWindow
);
142 /*************************************************************************
145 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD fdwReason
, LPVOID fImpLoad
)
147 TRACE("%p 0x%x %p\n", hinst
, fdwReason
, fImpLoad
);
150 case DLL_PROCESS_ATTACH
:
151 shdocvw_hinstance
= hinst
;
153 case DLL_PROCESS_DETACH
:
154 if (SHDOCVW_hshell32
) FreeLibrary(SHDOCVW_hshell32
);
156 FreeLibrary(ieframe_instance
);
162 /*************************************************************************
163 * DllCanUnloadNow (SHDOCVW.@)
165 HRESULT WINAPI
DllCanUnloadNow(void)
167 return SHDOCVW_refCount
? S_FALSE
: S_OK
;
170 /***********************************************************************
171 * DllGetVersion (SHDOCVW.@)
173 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*info
)
175 if (info
->cbSize
!= sizeof(DLLVERSIONINFO
)) FIXME("support DLLVERSIONINFO2\n");
177 /* this is what IE6 on Windows 98 reports */
178 info
->dwMajorVersion
= 6;
179 info
->dwMinorVersion
= 0;
180 info
->dwBuildNumber
= 2600;
181 info
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
186 /*************************************************************************
187 * DllInstall (SHDOCVW.@)
189 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
191 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
196 /*************************************************************************
197 * SHDOCVW_LoadShell32
199 * makes sure the handle to shell32 is valid
201 static BOOL
SHDOCVW_LoadShell32(void)
203 if (SHDOCVW_hshell32
)
205 return ((SHDOCVW_hshell32
= LoadLibraryA("shell32.dll")) != NULL
);
208 /***********************************************************************
211 * Called by Win98 explorer.exe main binary, definitely has 0
214 DWORD WINAPI
WinList_Init(void)
216 FIXME("(), stub!\n");
220 /***********************************************************************
223 * Called by Win98 explorer.exe main binary, definitely has only one
226 static BOOL (WINAPI
*pShellDDEInit
)(BOOL start
) = NULL
;
228 BOOL WINAPI
ShellDDEInit(BOOL start
)
230 TRACE("(%d)\n", start
);
234 if (!SHDOCVW_LoadShell32())
236 pShellDDEInit
= (void *)GetProcAddress(SHDOCVW_hshell32
, (LPCSTR
)188);
240 return pShellDDEInit(start
);
245 /***********************************************************************
248 * Called by Win98 explorer.exe main binary, definitely has 0
251 DWORD WINAPI
RunInstallUninstallStubs(void)
253 FIXME("(), stub!\n");
257 /***********************************************************************
260 * Called by Emerge Desktop (alternative Windows Shell).
262 DWORD WINAPI
RunInstallUninstallStubs2(void)
264 FIXME("(), stub!\n");
268 /***********************************************************************
269 * SetQueryNetSessionCount (SHDOCVW.@)
271 DWORD WINAPI
SetQueryNetSessionCount(DWORD arg
)
273 FIXME("(%u), stub!\n", arg
);
277 /**********************************************************************
278 * Some forwards (by ordinal) to SHLWAPI
281 static void* fetch_shlwapi_ordinal(UINT_PTR ord
)
283 static const WCHAR shlwapiW
[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
286 if (!h
&& !(h
= GetModuleHandleW(shlwapiW
))) return NULL
;
287 return (void*)GetProcAddress(h
, (const char*)ord
);
290 /******************************************************************
291 * WhichPlatformFORWARD (SHDOCVW.@)
293 DWORD WINAPI
WhichPlatformFORWARD(void)
295 static DWORD (WINAPI
*p
)(void);
297 if (p
|| (p
= fetch_shlwapi_ordinal(276))) return p();
298 return 1; /* not integrated, see shlwapi.WhichPlatform */
301 /******************************************************************
302 * StopWatchModeFORWARD (SHDOCVW.@)
304 void WINAPI
StopWatchModeFORWARD(void)
306 static void (WINAPI
*p
)(void);
308 if (p
|| (p
= fetch_shlwapi_ordinal(241))) p();
311 /******************************************************************
312 * StopWatchFlushFORWARD (SHDOCVW.@)
314 void WINAPI
StopWatchFlushFORWARD(void)
316 static void (WINAPI
*p
)(void);
318 if (p
|| (p
= fetch_shlwapi_ordinal(242))) p();
321 /******************************************************************
322 * StopWatchWFORWARD (SHDOCVW.@)
324 DWORD WINAPI
StopWatchWFORWARD(DWORD dwClass
, LPCWSTR lpszStr
, DWORD dwUnknown
,
325 DWORD dwMode
, DWORD dwTimeStamp
)
327 static DWORD (WINAPI
*p
)(DWORD
, LPCWSTR
, DWORD
, DWORD
, DWORD
);
329 if (p
|| (p
= fetch_shlwapi_ordinal(243)))
330 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
331 return ERROR_CALL_NOT_IMPLEMENTED
;
334 /******************************************************************
335 * StopWatchAFORWARD (SHDOCVW.@)
337 DWORD WINAPI
StopWatchAFORWARD(DWORD dwClass
, LPCSTR lpszStr
, DWORD dwUnknown
,
338 DWORD dwMode
, DWORD dwTimeStamp
)
340 static DWORD (WINAPI
*p
)(DWORD
, LPCSTR
, DWORD
, DWORD
, DWORD
);
342 if (p
|| (p
= fetch_shlwapi_ordinal(244)))
343 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
344 return ERROR_CALL_NOT_IMPLEMENTED
;
347 /******************************************************************
348 * URLSubRegQueryA (SHDOCVW.151)
350 HRESULT WINAPI
URLSubRegQueryA(LPCSTR regpath
, LPCSTR name
, DWORD type
,
351 LPSTR out
, DWORD outlen
, DWORD unknown
)
353 CHAR buffer
[INTERNET_MAX_URL_LENGTH
];
357 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath
), debugstr_a(name
),
358 type
, out
, outlen
, unknown
);
360 if (!out
) return S_OK
;
362 len
= sizeof(buffer
);
363 res
= SHRegGetUSValueA(regpath
, name
, NULL
, buffer
, &len
, FALSE
, NULL
, 0);
365 lstrcpynA(out
, buffer
, outlen
);
372 /******************************************************************
373 * ParseURLFromOutsideSourceW (SHDOCVW.170)
375 DWORD WINAPI
ParseURLFromOutsideSourceW(LPCWSTR url
, LPWSTR out
, LPDWORD plen
, LPDWORD unknown
)
377 WCHAR buffer_in
[INTERNET_MAX_URL_LENGTH
];
378 WCHAR buffer_out
[INTERNET_MAX_URL_LENGTH
];
386 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url
), out
, plen
, unknown
,
387 plen
? *plen
: 0, unknown
? *unknown
: 0);
389 if (!PathIsURLW(ptr
)) {
390 len
= sizeof(buffer_in
) / sizeof(buffer_in
[0]);
392 hr
= UrlApplySchemeW(ptr
, buffer_in
, &len
, URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
);
393 TRACE("got 0x%x with %s\n", hr
, debugstr_w(buffer_in
));
395 /* we parsed the url to buffer_in */
400 FIXME("call search hook for %s\n", debugstr_w(ptr
));
404 len
= sizeof(buffer_out
) / sizeof(buffer_out
[0]);
405 buffer_out
[0] = '\0';
406 hr
= UrlCanonicalizeW(ptr
, buffer_out
, &len
, URL_ESCAPE_SPACES_ONLY
);
407 needed
= lstrlenW(buffer_out
)+1;
408 TRACE("got 0x%x with %s (need %d)\n", hr
, debugstr_w(buffer_out
), needed
);
410 if (*plen
>= needed
) {
412 lstrcpyW(out
, buffer_out
);
420 TRACE("=> %d\n", res
);
424 /******************************************************************
425 * ParseURLFromOutsideSourceA (SHDOCVW.169)
427 * See ParseURLFromOutsideSourceW
429 DWORD WINAPI
ParseURLFromOutsideSourceA(LPCSTR url
, LPSTR out
, LPDWORD plen
, LPDWORD unknown
)
431 WCHAR buffer
[INTERNET_MAX_URL_LENGTH
];
437 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url
), out
, plen
, unknown
,
438 plen
? *plen
: 0, unknown
? *unknown
: 0);
441 len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
442 urlW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
443 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
446 len
= sizeof(buffer
) / sizeof(buffer
[0]);
447 res
= ParseURLFromOutsideSourceW(urlW
, buffer
, &len
, unknown
);
448 HeapFree(GetProcessHeap(), 0, urlW
);
450 needed
= WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, NULL
, 0, NULL
, NULL
);
453 if (*plen
>= needed
) {
455 WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, out
, *plen
, NULL
, NULL
);
463 TRACE("=> %d\n", res
);
467 /******************************************************************
468 * IEParseDisplayNameWithBCW (SHDOCVW.218)
470 HRESULT WINAPI
IEParseDisplayNameWithBCW(DWORD codepage
, LPCWSTR lpszDisplayName
, LPBC pbc
, LPITEMIDLIST
*ppidl
)
472 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
473 FIXME("stub: 0x%x %s %p %p\n",codepage
,debugstr_w(lpszDisplayName
),pbc
,ppidl
);
477 /******************************************************************
478 * SHRestricted2W (SHDOCVW.159)
480 DWORD WINAPI
SHRestricted2W(DWORD res
, LPCWSTR url
, DWORD reserved
)
482 FIXME("(%d %s %d) stub\n", res
, debugstr_w(url
), reserved
);
486 /******************************************************************
487 * SHRestricted2A (SHDOCVW.158)
491 DWORD WINAPI
SHRestricted2A(DWORD restriction
, LPCSTR url
, DWORD reserved
)
496 TRACE("(%d, %s, %d)\n", restriction
, debugstr_a(url
), reserved
);
498 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
499 urlW
= heap_alloc(len
* sizeof(WCHAR
));
500 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
502 res
= SHRestricted2W(restriction
, urlW
, reserved
);
507 /******************************************************************
508 * ImportPrivacySettings (SHDOCVW.@)
510 * Import global and/or per site privacy preferences from an xml file
513 * filename [I] XML file to use
514 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
515 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
518 * Success: TRUE (the privacy preferences where updated)
519 * Failure: FALSE (the privacy preferences are unchanged)
522 * Set the flag to TRUE, when the related privacy preferences in the xml file
523 * should be used (parsed and overwrite the current settings).
524 * On return, the flag is TRUE, when the related privacy settings where used
527 BOOL WINAPI
ImportPrivacySettings(LPCWSTR filename
, BOOL
*pGlobalPrefs
, BOOL
* pPerSitePrefs
)
529 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename
),
530 pGlobalPrefs
, pGlobalPrefs
? *pGlobalPrefs
: 0,
531 pPerSitePrefs
, pPerSitePrefs
? *pPerSitePrefs
: 0);
533 if (pGlobalPrefs
) *pGlobalPrefs
= FALSE
;
534 if (pPerSitePrefs
) *pPerSitePrefs
= FALSE
;