2006-06-06 12:26:24 +02:00
|
|
|
/*
|
|
|
|
* Implementation of hyperlinking (hlink.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2007-11-21 02:13:36 +01:00
|
|
|
#include "hlink_private.h"
|
2006-06-06 12:26:24 +02:00
|
|
|
|
2006-06-06 13:42:39 +02:00
|
|
|
#include "winreg.h"
|
2010-12-02 14:40:00 +01:00
|
|
|
#include "rpcproxy.h"
|
2007-11-21 02:13:36 +01:00
|
|
|
#include "hlguids.h"
|
2006-06-06 12:26:24 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2006-06-06 12:26:24 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(hlink);
|
|
|
|
|
2011-10-21 15:12:09 +02:00
|
|
|
typedef HRESULT (*LPFNCREATEINSTANCE)(IUnknown*, REFIID, LPVOID*);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2010-12-30 01:52:04 +01:00
|
|
|
IClassFactory IClassFactory_iface;
|
|
|
|
LPFNCREATEINSTANCE lpfnCI;
|
2006-06-06 12:39:58 +02:00
|
|
|
} CFImpl;
|
2006-06-06 12:26:24 +02:00
|
|
|
|
2010-12-30 01:52:04 +01:00
|
|
|
static inline CFImpl *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, CFImpl, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkCreateFromMoniker (HLINK.@)
|
|
|
|
*/
|
2006-06-06 12:26:24 +02:00
|
|
|
HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation,
|
|
|
|
LPCWSTR pwzFriendlyName, IHlinkSite* pihlsite, DWORD dwSiteData,
|
|
|
|
IUnknown* piunkOuter, REFIID riid, void** ppvObj)
|
|
|
|
{
|
2006-06-06 12:39:58 +02:00
|
|
|
IHlink *hl = NULL;
|
2022-04-11 10:40:32 +02:00
|
|
|
HRESULT hr;
|
2006-06-06 12:26:24 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("%p %s %s %p %li %p %s %p\n", pimkTrgt, debugstr_w(pwzLocation),
|
2006-06-06 12:39:58 +02:00
|
|
|
debugstr_w(pwzFriendlyName), pihlsite, dwSiteData, piunkOuter,
|
|
|
|
debugstr_guid(riid), ppvObj);
|
|
|
|
|
2022-04-11 10:40:32 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, &IID_IHlink, (LPVOID*)&hl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2009-12-30 18:43:05 +01:00
|
|
|
IHlink_SetMonikerReference(hl, HLINKSETF_LOCATION | HLINKSETF_TARGET, pimkTrgt, pwzLocation);
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
if (pwzFriendlyName)
|
|
|
|
IHlink_SetFriendlyName(hl, pwzFriendlyName);
|
|
|
|
if (pihlsite)
|
|
|
|
IHlink_SetHlinkSite(hl, pihlsite, dwSiteData);
|
|
|
|
|
2022-04-11 10:40:32 +02:00
|
|
|
hr = IHlink_QueryInterface(hl, riid, ppvObj);
|
|
|
|
IHlink_Release(hl);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-04-11 10:40:32 +02:00
|
|
|
return hr;
|
2006-06-06 12:26:24 +02:00
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkCreateFromString (HLINK.@)
|
|
|
|
*/
|
2006-06-06 12:26:24 +02:00
|
|
|
HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
|
|
|
|
LPCWSTR pwzFriendlyName, IHlinkSite* pihlsite, DWORD dwSiteData,
|
|
|
|
IUnknown* piunkOuter, REFIID riid, void** ppvObj)
|
|
|
|
{
|
2006-06-06 12:39:58 +02:00
|
|
|
IHlink *hl = NULL;
|
2022-04-11 10:40:33 +02:00
|
|
|
HRESULT hr;
|
2010-03-16 20:52:04 +01:00
|
|
|
WCHAR *hash, *tgt;
|
|
|
|
const WCHAR *loc;
|
2006-06-06 12:26:24 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("%s %s %s %p %li %p %s %p\n", debugstr_w(pwzTarget),
|
2006-06-06 12:39:58 +02:00
|
|
|
debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), pihlsite,
|
|
|
|
dwSiteData, piunkOuter, debugstr_guid(riid), ppvObj);
|
|
|
|
|
2022-04-11 10:40:33 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, &IID_IHlink, (void **)&hl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2010-03-16 20:52:04 +01:00
|
|
|
if (pwzTarget)
|
|
|
|
{
|
2019-06-05 08:37:02 +02:00
|
|
|
hash = wcschr(pwzTarget, '#');
|
2010-03-16 20:52:04 +01:00
|
|
|
if (hash)
|
|
|
|
{
|
|
|
|
if (hash == pwzTarget)
|
|
|
|
tgt = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int tgt_len = hash - pwzTarget;
|
2022-04-11 10:40:29 +02:00
|
|
|
tgt = malloc((tgt_len + 1) * sizeof(WCHAR));
|
2010-03-16 20:52:04 +01:00
|
|
|
if (!tgt)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
memcpy(tgt, pwzTarget, tgt_len * sizeof(WCHAR));
|
|
|
|
tgt[tgt_len] = 0;
|
|
|
|
}
|
|
|
|
if (!pwzLocation)
|
|
|
|
loc = hash + 1;
|
|
|
|
else
|
|
|
|
loc = pwzLocation;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-11 10:40:29 +02:00
|
|
|
tgt = wcsdup(pwzTarget);
|
2010-03-16 20:52:04 +01:00
|
|
|
if (!tgt)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
loc = pwzLocation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tgt = NULL;
|
|
|
|
loc = pwzLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
IHlink_SetStringReference(hl, HLINKSETF_TARGET | HLINKSETF_LOCATION, tgt, loc);
|
|
|
|
|
2022-04-11 10:40:29 +02:00
|
|
|
free(tgt);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
if (pwzFriendlyName)
|
|
|
|
IHlink_SetFriendlyName(hl, pwzFriendlyName);
|
2009-12-30 18:43:05 +01:00
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
if (pihlsite)
|
|
|
|
IHlink_SetHlinkSite(hl, pihlsite, dwSiteData);
|
|
|
|
|
2022-04-11 10:40:33 +02:00
|
|
|
hr = IHlink_QueryInterface(hl, riid, ppvObj);
|
|
|
|
IHlink_Release(hl);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-04-11 10:40:33 +02:00
|
|
|
return hr;
|
2006-06-06 12:26:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
2009-12-31 23:37:27 +01:00
|
|
|
* HlinkCreateBrowseContext (HLINK.@)
|
2008-01-29 00:22:54 +01:00
|
|
|
*/
|
2006-06-06 12:26:24 +02:00
|
|
|
HRESULT WINAPI HlinkCreateBrowseContext( IUnknown* piunkOuter, REFIID riid, void** ppvObj)
|
|
|
|
{
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("%p %s %p\n", piunkOuter, debugstr_guid(riid), ppvObj);
|
2013-03-23 18:53:14 +01:00
|
|
|
return CoCreateInstance(&CLSID_StdHlinkBrowseContext, piunkOuter, CLSCTX_INPROC_SERVER, riid, ppvObj);
|
2006-06-06 12:26:24 +02:00
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkNavigate (HLINK.@)
|
|
|
|
*/
|
2006-06-06 12:26:24 +02:00
|
|
|
HRESULT WINAPI HlinkNavigate(IHlink *phl, IHlinkFrame *phlFrame,
|
|
|
|
DWORD grfHLNF, LPBC pbc, IBindStatusCallback *pbsc,
|
|
|
|
IHlinkBrowseContext *phlbc)
|
|
|
|
{
|
2006-06-06 12:39:58 +02:00
|
|
|
HRESULT r = S_OK;
|
2006-06-06 12:26:24 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("%p %p %li %p %p %p\n", phl, phlFrame, grfHLNF, pbc, pbsc, phlbc);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
if (phlFrame)
|
|
|
|
r = IHlinkFrame_Navigate(phlFrame, grfHLNF, pbc, pbsc, phl);
|
|
|
|
else if (phl)
|
|
|
|
r = IHlink_Navigate(phl, grfHLNF, pbc, pbsc, phlbc);
|
|
|
|
|
|
|
|
return r;
|
2006-06-06 12:26:24 +02:00
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkOnNavigate (HLINK.@)
|
|
|
|
*/
|
2006-06-06 12:26:24 +02:00
|
|
|
HRESULT WINAPI HlinkOnNavigate( IHlinkFrame *phlFrame,
|
|
|
|
IHlinkBrowseContext* phlbc, DWORD grfHLNF, IMoniker *pmkTarget,
|
|
|
|
LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, ULONG* puHLID)
|
|
|
|
{
|
2013-03-23 18:53:14 +01:00
|
|
|
HRESULT r;
|
2006-06-06 12:26:24 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("%p %p %li %p %s %s %p\n",phlFrame, phlbc, grfHLNF, pmkTarget,
|
2006-06-06 12:39:58 +02:00
|
|
|
debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), puHLID);
|
|
|
|
|
|
|
|
r = IHlinkBrowseContext_OnNavigateHlink(phlbc, grfHLNF, pmkTarget,
|
|
|
|
pwzLocation, pwzFriendlyName, puHLID);
|
|
|
|
|
|
|
|
if (phlFrame)
|
|
|
|
r = IHlinkFrame_OnNavigate(phlFrame,grfHLNF,pmkTarget, pwzLocation,
|
|
|
|
pwzFriendlyName, 0);
|
|
|
|
|
|
|
|
return r;
|
2006-06-06 12:26:24 +02:00
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkCreateFromData (HLINK.@)
|
|
|
|
*/
|
2006-06-06 12:26:24 +02:00
|
|
|
HRESULT WINAPI HlinkCreateFromData(IDataObject *piDataObj,
|
|
|
|
IHlinkSite *pihlsite, DWORD dwSiteData, IUnknown *piunkOuter,
|
|
|
|
REFIID riid, void **ppvObj)
|
|
|
|
{
|
2022-02-10 08:43:37 +01:00
|
|
|
FIXME("%p, %p, %ld, %p, %s, %p\n", piDataObj, pihlsite, dwSiteData,
|
2016-07-22 11:56:48 +02:00
|
|
|
piunkOuter, debugstr_guid(riid), ppvObj);
|
2006-06-06 12:39:58 +02:00
|
|
|
*ppvObj = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2006-06-06 12:26:24 +02:00
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkQueryCreateFromData (HLINK.@)
|
|
|
|
*/
|
2006-06-06 12:39:58 +02:00
|
|
|
HRESULT WINAPI HlinkQueryCreateFromData(IDataObject* piDataObj)
|
|
|
|
{
|
|
|
|
FIXME("%p\n", piDataObj);
|
2006-06-06 12:26:24 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkNavigateToStringReference (HLINK.@)
|
|
|
|
*/
|
2006-06-19 09:58:22 +02:00
|
|
|
HRESULT WINAPI HlinkNavigateToStringReference( LPCWSTR pwzTarget,
|
|
|
|
LPCWSTR pwzLocation, IHlinkSite *pihlsite, DWORD dwSiteData,
|
|
|
|
IHlinkFrame *pihlframe, DWORD grfHLNF, LPBC pibc,
|
|
|
|
IBindStatusCallback *pibsc, IHlinkBrowseContext *pihlbc)
|
|
|
|
{
|
2006-07-24 04:56:15 +02:00
|
|
|
HRESULT r;
|
|
|
|
IHlink *hlink = NULL;
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("%s %s %p %08lx %p %08lx %p %p %p\n",
|
2006-06-19 09:58:22 +02:00
|
|
|
debugstr_w(pwzTarget), debugstr_w(pwzLocation), pihlsite,
|
|
|
|
dwSiteData, pihlframe, grfHLNF, pibc, pibsc, pihlbc);
|
2006-07-24 04:56:15 +02:00
|
|
|
|
|
|
|
r = HlinkCreateFromString( pwzTarget, pwzLocation, NULL, pihlsite,
|
|
|
|
dwSiteData, NULL, &IID_IHlink, (LPVOID*) &hlink );
|
2011-12-13 15:14:13 +01:00
|
|
|
if (SUCCEEDED(r)) {
|
2006-07-24 04:56:15 +02:00
|
|
|
r = HlinkNavigate(hlink, pihlframe, grfHLNF, pibc, pibsc, pihlbc);
|
2011-12-13 15:14:13 +01:00
|
|
|
IHlink_Release(hlink);
|
|
|
|
}
|
2006-07-24 04:56:15 +02:00
|
|
|
|
|
|
|
return r;
|
2006-06-19 09:58:22 +02:00
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkIsShortcut (HLINK.@)
|
|
|
|
*/
|
2006-08-02 21:29:58 +02:00
|
|
|
HRESULT WINAPI HlinkIsShortcut(LPCWSTR pwzFileName)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_w(pwzFileName));
|
|
|
|
|
|
|
|
if(!pwzFileName)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-06-05 08:37:02 +02:00
|
|
|
len = lstrlenW(pwzFileName)-4;
|
2006-08-02 21:29:58 +02:00
|
|
|
if(len < 0)
|
|
|
|
return S_FALSE;
|
|
|
|
|
2020-10-03 20:28:12 +02:00
|
|
|
return wcsicmp(pwzFileName+len, L".url") ? S_FALSE : S_OK;
|
2006-08-02 21:29:58 +02:00
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkGetSpecialReference (HLINK.@)
|
|
|
|
*/
|
2007-09-26 19:45:27 +02:00
|
|
|
HRESULT WINAPI HlinkGetSpecialReference(ULONG uReference, LPWSTR *ppwzReference)
|
|
|
|
{
|
2007-11-12 19:17:45 +01:00
|
|
|
DWORD res, type, size = 100;
|
|
|
|
LPCWSTR value_name;
|
|
|
|
WCHAR *buf;
|
|
|
|
HKEY hkey;
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%lu %p)\n", uReference, ppwzReference);
|
2007-11-12 19:17:45 +01:00
|
|
|
|
|
|
|
*ppwzReference = NULL;
|
|
|
|
|
|
|
|
switch(uReference) {
|
|
|
|
case HLSR_HOME:
|
2020-10-03 20:28:12 +02:00
|
|
|
value_name = L"Start Page";
|
2007-11-12 19:17:45 +01:00
|
|
|
break;
|
|
|
|
case HLSR_SEARCHPAGE:
|
2020-10-03 20:28:12 +02:00
|
|
|
value_name = L"Search Page";
|
2007-11-12 19:17:45 +01:00
|
|
|
break;
|
|
|
|
case HLSR_HISTORYFOLDER:
|
|
|
|
return E_NOTIMPL;
|
|
|
|
default:
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2020-10-03 20:28:12 +02:00
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main", &hkey);
|
2007-11-12 19:17:45 +01:00
|
|
|
if(res != ERROR_SUCCESS) {
|
2022-02-10 08:43:37 +01:00
|
|
|
WARN("Could not open key: %lu\n", res);
|
2007-11-12 19:17:45 +01:00
|
|
|
return HRESULT_FROM_WIN32(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
buf = CoTaskMemAlloc(size);
|
|
|
|
res = RegQueryValueExW(hkey, value_name, NULL, &type, (PBYTE)buf, &size);
|
|
|
|
buf = CoTaskMemRealloc(buf, size);
|
|
|
|
if(res == ERROR_MORE_DATA)
|
|
|
|
res = RegQueryValueExW(hkey, value_name, NULL, &type, (PBYTE)buf, &size);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
2022-02-10 08:43:37 +01:00
|
|
|
WARN("Could not query value %s: %lu\n", debugstr_w(value_name), res);
|
2007-11-12 19:17:45 +01:00
|
|
|
CoTaskMemFree(buf);
|
|
|
|
return HRESULT_FROM_WIN32(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppwzReference = buf;
|
|
|
|
return S_OK;
|
2007-09-26 19:45:27 +02:00
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkTranslateURL (HLINK.@)
|
|
|
|
*/
|
2006-08-02 21:30:46 +02:00
|
|
|
HRESULT WINAPI HlinkTranslateURL(LPCWSTR pwzURL, DWORD grfFlags, LPWSTR *ppwzTranslatedURL)
|
|
|
|
{
|
2022-02-10 08:43:37 +01:00
|
|
|
FIXME("(%s %08lx %p)\n", debugstr_w(pwzURL), grfFlags, ppwzTranslatedURL);
|
2006-08-02 21:30:46 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkUpdateStackItem (HLINK.@)
|
|
|
|
*/
|
2013-03-23 08:03:35 +01:00
|
|
|
HRESULT WINAPI HlinkUpdateStackItem(IHlinkFrame *frame, IHlinkBrowseContext *bc,
|
|
|
|
ULONG hlid, IMoniker *target, LPCWSTR location, LPCWSTR friendly_name)
|
2007-11-21 02:13:16 +01:00
|
|
|
{
|
2013-03-23 08:03:35 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p %p 0x%lx %p %s %s)\n", frame, bc, hlid, target, debugstr_w(location), debugstr_w(friendly_name));
|
2013-03-23 08:03:35 +01:00
|
|
|
|
|
|
|
if (!frame && !bc) return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (frame)
|
|
|
|
hr = IHlinkFrame_UpdateHlink(frame, hlid, target, location, friendly_name);
|
|
|
|
else
|
|
|
|
hr = IHlinkBrowseContext_UpdateHlink(bc, hlid, target, location, friendly_name);
|
|
|
|
|
|
|
|
return hr;
|
2007-11-21 02:13:16 +01:00
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkParseDisplayName (HLINK.@)
|
|
|
|
*/
|
2008-01-29 00:21:19 +01:00
|
|
|
HRESULT WINAPI HlinkParseDisplayName(LPBC pibc, LPCWSTR pwzDisplayName, BOOL fNoForceAbs,
|
|
|
|
ULONG *pcchEaten, IMoniker **ppimk)
|
|
|
|
{
|
2020-10-03 20:28:12 +02:00
|
|
|
ULONG eaten = 0, len;
|
2008-01-29 00:21:19 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %s %x %p %p)\n", pibc, debugstr_w(pwzDisplayName), fNoForceAbs, pcchEaten, ppimk);
|
|
|
|
|
|
|
|
if(fNoForceAbs)
|
|
|
|
FIXME("Unsupported fNoForceAbs\n");
|
|
|
|
|
2020-10-03 20:28:12 +02:00
|
|
|
len = ARRAY_SIZE(L"file:") - 1;
|
|
|
|
if(!wcsnicmp(pwzDisplayName, L"file:", len)) {
|
|
|
|
pwzDisplayName += len;
|
|
|
|
eaten += len;
|
2008-01-29 00:21:19 +01:00
|
|
|
|
2014-03-04 16:53:05 +01:00
|
|
|
while(*pwzDisplayName == '/') {
|
|
|
|
pwzDisplayName++;
|
|
|
|
eaten++;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
hres = MkParseDisplayNameEx(pibc, pwzDisplayName, pcchEaten, ppimk);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = MkParseDisplayName(pibc, pwzDisplayName, pcchEaten, ppimk);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
2008-01-29 00:21:19 +01:00
|
|
|
|
|
|
|
hres = CreateFileMoniker(pwzDisplayName, ppimk);
|
|
|
|
if(SUCCEEDED(hres))
|
2019-06-05 08:37:02 +02:00
|
|
|
*pcchEaten = eaten + lstrlenW(pwzDisplayName);
|
2008-01-29 00:21:19 +01:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2008-01-29 00:22:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkResolveMonikerForData (HLINK.@)
|
|
|
|
*/
|
2008-01-29 00:22:12 +01:00
|
|
|
HRESULT WINAPI HlinkResolveMonikerForData(LPMONIKER pimkReference, DWORD reserved, LPBC pibc,
|
|
|
|
ULONG cFmtetc, FORMATETC *rgFmtetc, IBindStatusCallback *pibsc, LPMONIKER pimkBase)
|
|
|
|
{
|
|
|
|
LPOLESTR name = NULL;
|
|
|
|
IBindCtx *bctx;
|
|
|
|
DWORD mksys = 0;
|
|
|
|
void *obj = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p %lx %p %ld %p %p %p)\n", pimkReference, reserved, pibc, cFmtetc, rgFmtetc, pibsc, pimkBase);
|
2008-01-29 00:22:12 +01:00
|
|
|
|
|
|
|
if(cFmtetc || rgFmtetc || pimkBase)
|
|
|
|
FIXME("Unsupported args\n");
|
|
|
|
|
|
|
|
hres = RegisterBindStatusCallback(pibc, pibsc, NULL /* FIXME */, 0);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IMoniker_IsSystemMoniker(pimkReference, &mksys);
|
|
|
|
if(SUCCEEDED(hres) && mksys != MKSYS_URLMONIKER)
|
2022-02-10 08:43:37 +01:00
|
|
|
WARN("sysmk = %lx\n", mksys);
|
2008-01-29 00:22:12 +01:00
|
|
|
|
|
|
|
/* FIXME: What is it for? */
|
|
|
|
CreateBindCtx(0, &bctx);
|
|
|
|
hres = IMoniker_GetDisplayName(pimkReference, bctx, NULL, &name);
|
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
TRACE("got display name %s\n", debugstr_w(name));
|
|
|
|
CoTaskMemFree(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return IMoniker_BindToStorage(pimkReference, pibc, NULL, &IID_IUnknown, &obj);
|
|
|
|
}
|
2008-01-29 00:22:54 +01:00
|
|
|
|
2010-11-01 18:06:05 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkClone (HLINK.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI HlinkClone(IHlink *hlink, REFIID riid, IHlinkSite *hls,
|
|
|
|
DWORD site_data, void **obj)
|
|
|
|
{
|
|
|
|
IMoniker *mk, *clone_mk = NULL;
|
|
|
|
WCHAR *loc, *name = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!hlink || !riid || !obj)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &mk, &loc);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(mk) {
|
|
|
|
IStream *strm;
|
|
|
|
LARGE_INTEGER lgint;
|
|
|
|
|
|
|
|
hres = CreateStreamOnHGlobal(NULL, TRUE, &strm);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IMoniker_Release(mk);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = OleSaveToStream((IPersistStream*)mk, strm);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IStream_Release(strm);
|
|
|
|
IMoniker_Release(mk);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
IMoniker_Release(mk);
|
|
|
|
|
|
|
|
lgint.QuadPart = 0;
|
|
|
|
hres = IStream_Seek(strm, lgint, STREAM_SEEK_SET, NULL);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IStream_Release(strm);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = OleLoadFromStream(strm, &IID_IMoniker, (void**)&clone_mk);
|
|
|
|
IStream_Release(strm);
|
|
|
|
if(FAILED(hres))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IHlink_GetFriendlyName(hlink, HLFNAMEF_DEFAULT, &name);
|
|
|
|
if(FAILED(hres))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hres = HlinkCreateFromMoniker(clone_mk, loc, name, hls, site_data, NULL,
|
|
|
|
&IID_IHlink, obj);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if(clone_mk)
|
|
|
|
IMoniker_Release(clone_mk);
|
|
|
|
CoTaskMemFree(loc);
|
|
|
|
CoTaskMemFree(name);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
static HRESULT WINAPI HLinkCF_fnQueryInterface ( LPCLASSFACTORY iface,
|
|
|
|
REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
2010-12-30 01:52:04 +01:00
|
|
|
CFImpl *This = impl_from_IClassFactory(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2016-12-12 12:15:42 +01:00
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObj);
|
2006-06-06 12:26:24 +02:00
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
*ppvObj = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IClassFactory))
|
|
|
|
{
|
2017-02-13 12:16:03 +01:00
|
|
|
*ppvObj = &This->IClassFactory_iface;
|
2006-06-06 12:39:58 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("-- E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HLinkCF_fnAddRef (LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HLinkCF_fnRelease(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HLinkCF_fnCreateInstance( LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
|
|
|
|
{
|
2010-12-30 01:52:04 +01:00
|
|
|
CFImpl *This = impl_from_IClassFactory(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
TRACE("%p->(%p,%s,%p)\n", This, pUnkOuter, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
return This->lpfnCI(pUnkOuter, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HLinkCF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
|
|
|
|
{
|
|
|
|
FIXME("%p %d\n", iface, fLock);
|
2006-06-06 12:26:24 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
static const IClassFactoryVtbl hlcfvt =
|
|
|
|
{
|
|
|
|
HLinkCF_fnQueryInterface,
|
|
|
|
HLinkCF_fnAddRef,
|
|
|
|
HLinkCF_fnRelease,
|
|
|
|
HLinkCF_fnCreateInstance,
|
|
|
|
HLinkCF_fnLockServer
|
|
|
|
};
|
|
|
|
|
2010-12-30 01:52:04 +01:00
|
|
|
static CFImpl HLink_cf = { { &hlcfvt }, HLink_Constructor };
|
|
|
|
static CFImpl HLinkBrowseContext_cf = { { &hlcfvt }, HLinkBrowseContext_Constructor };
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2006-11-12 20:23:28 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (HLINK.@)
|
|
|
|
*/
|
2006-06-06 12:26:24 +02:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
|
|
|
|
{
|
2006-06-06 12:39:58 +02:00
|
|
|
IClassFactory *pcf = NULL;
|
|
|
|
|
|
|
|
TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
|
2006-06-06 12:26:24 +02:00
|
|
|
|
|
|
|
if (!ppv)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*ppv = NULL;
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
if (IsEqualIID(rclsid, &CLSID_StdHlink))
|
2010-12-30 01:52:04 +01:00
|
|
|
pcf = &HLink_cf.IClassFactory_iface;
|
2006-06-06 12:39:58 +02:00
|
|
|
else if (IsEqualIID(rclsid, &CLSID_StdHlinkBrowseContext))
|
2010-12-30 01:52:04 +01:00
|
|
|
pcf = &HLinkBrowseContext_cf.IClassFactory_iface;
|
2006-06-06 12:39:58 +02:00
|
|
|
else
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
|
|
|
|
return IClassFactory_QueryInterface(pcf, iid, ppv);
|
2006-06-06 12:26:24 +02:00
|
|
|
}
|