Sync to Wine-20050725:

Felix Nawothnig <felix.nawothnig@t-online.de>
- Fix misuse of UrlCombineW.
Mike McCormack <mike@codeweavers.com>
- Fix -Wpointer-sign warnings.
Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
- URLMonikerImpl_BindToStorage: Don't use a HeapAllocated pointer for
  other purposes.
- URLMonikerImpl_BindToStorage: Escape special characters.
Jacek Caban <jack@itma.pwr.wroc.pl>
- Register protocols.
- Better module locking.
- Fix handling of pmkContext in CreateURLMoniker.

svn path=/trunk/; revision=17341
This commit is contained in:
Gé van Geldorp 2005-08-12 18:17:37 +00:00
parent 66359f3c63
commit dbd7ad25e3
11 changed files with 286 additions and 44 deletions

View file

@ -14,6 +14,8 @@ C_SRCS = \
umstream.c \
urlmon_main.c
RC_SRCS = rsrc.rc
SUBDIRS = tests
@MAKE_DLL_RULES@

View file

@ -20,6 +20,7 @@
#define COM_NO_WINDOWS_H
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
@ -28,6 +29,7 @@
#include "wingdi.h"
#include "winreg.h"
#include "winerror.h"
#include "advpub.h"
#include "objbase.h"
@ -35,6 +37,9 @@
#include "wine/debug.h"
#include "initguid.h"
#include "urlmon_main.h"
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
/*
@ -511,6 +516,48 @@ static struct regsvr_coclass const coclass_list[] = {
"urlmon.dll",
"Apartment"
},
{ &CLSID_CdlProtocol,
"CDL: Asynchronous Pluggable Protocol Handler",
NULL,
"urlmon.dll",
"Apartment"
},
{ &CLSID_FileProtocol,
"file:, local: Asynchronous Pluggable Protocol Handler",
NULL,
"urlmon.dll",
"Apartment"
},
{ &CLSID_FtpProtocol,
"ftp: Asynchronous Pluggable Protocol Handler",
NULL,
"urlmon.dll",
"Apartment"
},
{ &CLSID_GopherProtocol,
"gopher: Asynchronous Pluggable Protocol Handler",
NULL,
"urlmon.dll",
"Apartment"
},
{ &CLSID_HttpProtocol,
"http: Asynchronous Pluggable Protocol Handler",
NULL,
"urlmon.dll",
"Apartment"
},
{ &CLSID_HttpsProtocol,
"https: Asynchronous Pluggable Protocol Handler",
NULL,
"urlmon.dll",
"Apartment"
},
{ &CLSID_MkProtocol,
"mk: Asynchronous Pluggable Protocol Handler",
NULL,
"urlmon.dll",
"Apartment"
},
{ NULL } /* list terminator */
};
@ -522,6 +569,58 @@ static struct regsvr_interface const interface_list[] = {
{ NULL } /* list terminator */
};
/***********************************************************************
* register_inf
*/
#define INF_SET_CLSID(clsid) \
pse[i].pszName = "CLSID_" #clsid; \
clsids[i++] = &CLSID_ ## clsid;
static HRESULT register_inf(BOOL doregister)
{
HRESULT hres;
HMODULE hAdvpack;
typeof(RegInstall) *pRegInstall;
STRTABLE strtable;
STRENTRY pse[7];
static CLSID const *clsids[34];
int i = 0;
static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
INF_SET_CLSID(CdlProtocol);
INF_SET_CLSID(FileProtocol);
INF_SET_CLSID(FtpProtocol);
INF_SET_CLSID(GopherProtocol);
INF_SET_CLSID(HttpProtocol);
INF_SET_CLSID(HttpsProtocol);
INF_SET_CLSID(MkProtocol);
for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) {
pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
sprintf(pse[i].pszValue, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
}
strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
strtable.pse = pse;
hAdvpack = LoadLibraryW(wszAdvpack);
pRegInstall = (typeof(RegInstall)*)GetProcAddress(hAdvpack, "RegInstall");
hres = pRegInstall(URLMON_hInstance, doregister ? "RegisterDll" : "UnregisterDll", &strtable);
for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
return hres;
}
#undef INF_SET_CLSID
/***********************************************************************
* DllRegisterServer (URLMON.@)
*/
@ -534,7 +633,9 @@ HRESULT WINAPI URLMON_DllRegisterServer(void)
hr = register_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = register_interfaces(interface_list);
return hr;
if(FAILED(hr))
return hr;
return register_inf(TRUE);
}
/***********************************************************************
@ -549,5 +650,7 @@ HRESULT WINAPI URLMON_DllUnregisterServer(void)
hr = unregister_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = unregister_interfaces(interface_list);
return hr;
if(FAILED(hr))
return hr;
return register_inf(FALSE);
}

View file

@ -0,0 +1,19 @@
/*
* Copyright 2005 Jacek Caban
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
REGINST REGINST urlmon.inf

View file

@ -43,7 +43,7 @@ typedef struct SecManagerImpl{
const IInternetSecurityManagerVtbl* lpvtbl1; /* VTable relative to the IInternetSecurityManager interface.*/
ULONG ref; /* reference counter for this object */
LONG ref; /* reference counter for this object */
} SecManagerImpl;
@ -82,8 +82,6 @@ static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
URLMON_LockModule();
return refCount;
}
@ -97,10 +95,9 @@ static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
/* destroy the object if there's no more reference on it */
if (!refCount){
HeapFree(GetProcessHeap(),0,This);
URLMON_UnlockModule();
}
URLMON_UnlockModule();
return refCount;
}
@ -201,6 +198,9 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
This->ref = 1;
*ppobj = This;
URLMON_LockModule();
return S_OK;
}
@ -210,7 +210,7 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
*/
typedef struct {
const IInternetZoneManagerVtbl* lpVtbl;
ULONG ref;
LONG ref;
} ZoneMgrImpl;
/********************************************************************
@ -247,8 +247,6 @@ static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
URLMON_LockModule();
return refCount;
}
@ -262,10 +260,10 @@ static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
if(!refCount)
if(!refCount) {
HeapFree(GetProcessHeap(), 0, This);
URLMON_UnlockModule();
URLMON_UnlockModule();
}
return refCount;
}
@ -457,6 +455,8 @@ HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
ret->ref = 1;
*ppobj = (IInternetZoneManager*)ret;
URLMON_LockModule();
return S_OK;
}

View file

@ -51,7 +51,7 @@ static const WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e',
typedef struct {
const IBindingVtbl *lpVtbl;
ULONG ref;
LONG ref;
LPWSTR URLName;
@ -291,7 +291,7 @@ typedef struct {
const IMonikerVtbl* lpvtbl; /* VTable relative to the IMoniker interface.*/
ULONG ref; /* reference counter for this object */
LONG ref; /* reference counter for this object */
LPOLESTR URLName; /* URL string identified by this URLmoniker */
} URLMonikerImpl;
@ -340,8 +340,6 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
URLMON_LockModule();
return refCount;
}
@ -359,9 +357,9 @@ static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
if (!refCount) {
HeapFree(GetProcessHeap(),0,This->URLName);
HeapFree(GetProcessHeap(),0,This);
}
URLMON_UnlockModule();
URLMON_UnlockModule();
}
return refCount;
}
@ -600,7 +598,7 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
if(SUCCEEDED(hres)) {
WCHAR *urlcopy, *tmpwc;
URL_COMPONENTSW url;
WCHAR *host, *path, *user, *pass;
WCHAR *host, *path, *partial_path, *user, *pass;
DWORD lensz = sizeof(bind->expected_size);
DWORD dwService = 0;
BOOL bSuccess;
@ -638,7 +636,7 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
memset(&url, 0, sizeof(url));
url.dwStructSize = sizeof(url);
url.dwSchemeLength = url.dwHostNameLength = url.dwUrlPathLength = url.dwUserNameLength = url.dwPasswordLength = 1;
InternetCrackUrlW(urlcopy, 0, 0, &url);
InternetCrackUrlW(urlcopy, 0, ICU_ESCAPE, &url);
host = HeapAlloc(GetProcessHeap(), 0, (url.dwHostNameLength + 1) * sizeof(WCHAR));
memcpy(host, url.lpszHostName, url.dwHostNameLength * sizeof(WCHAR));
host[url.dwHostNameLength] = '\0';
@ -799,9 +797,9 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
break;
case INTERNET_SCHEME_FILE:
path = bind->URLName + 5; /* Skip the "file:" part */
if ((path[0] != '/' && path[0] != '\\') ||
(path[1] != '/' && path[1] != '\\'))
partial_path = bind->URLName + 5; /* Skip the "file:" part */
if ((partial_path[0] != '/' && partial_path[0] != '\\') ||
(partial_path[1] != '/' && partial_path[1] != '\\'))
{
hres = E_FAIL;
}
@ -809,10 +807,10 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
{
HANDLE h;
path += 2;
if (path[0] == '/' || path[0] == '\\')
++path;
h = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
partial_path += 2;
if (partial_path[0] == '/' || partial_path[0] == '\\')
++partial_path;
h = CreateFileW(partial_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
if (h == (HANDLE) HFILE_ERROR)
{
hres = HRESULT_FROM_WIN32(GetLastError());
@ -1136,7 +1134,7 @@ static const IMonikerVtbl VT_URLMonikerImpl =
static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeftURLName, LPCOLESTR lpszURLName)
{
HRESULT hres;
DWORD sizeStr;
DWORD sizeStr = INTERNET_MAX_URL_LENGTH;
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszLeftURLName),debugstr_w(lpszURLName));
memset(This, 0, sizeof(*This));
@ -1170,6 +1168,8 @@ static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeft
else
strcpyW(This->URLName,lpszURLName);
URLMON_LockModule();
return S_OK;
}
@ -1255,11 +1255,12 @@ HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **
return E_OUTOFMEMORY;
if(pmkContext) {
CLSID clsid;
IBindCtx* bind;
IMoniker_GetClassID(pmkContext, &clsid);
if(IsEqualCLSID(&clsid, &CLSID_StdURLMoniker) && SUCCEEDED(CreateBindCtx(0, &bind))) {
URLMonikerImpl_GetDisplayName(pmkContext, bind, NULL, &lefturl);
DWORD dwMksys = 0;
IMoniker_IsSystemMoniker(pmkContext, &dwMksys);
if(dwMksys == MKSYS_URLMONIKER && SUCCEEDED(CreateBindCtx(0, &bind))) {
IMoniker_GetDisplayName(pmkContext, bind, NULL, &lefturl);
TRACE("lefturl = %s\n", debugstr_w(lefturl));
IBindCtx_Release(bind);
}
}

View file

@ -253,7 +253,8 @@ static HRESULT WINAPI IStream_fnSeek ( IStream * iface,
DWORD dwOrigin,
ULARGE_INTEGER* plibNewPosition)
{
DWORD pos, newposlo, newposhi;
DWORD pos, newposlo;
LONG newposhi;
IUMCacheStream *This = (IUMCacheStream *)iface;
@ -262,7 +263,7 @@ static HRESULT WINAPI IStream_fnSeek ( IStream * iface,
pos = dlibMove.QuadPart; /* FIXME: truncates */
newposhi = 0;
newposlo = SetFilePointer( This->handle, pos, &newposhi, dwOrigin );
if( newposlo == INVALID_SET_FILE_POINTER )
if( newposlo == INVALID_SET_FILE_POINTER && GetLastError())
return E_FAIL;
if (plibNewPosition)

View file

@ -0,0 +1,29 @@
[version]
Signature="$CHICAGO$"
[RegisterDll]
AddReg=Protocols.Reg
[UnregisterDll]
DelReg=Protocols.Reg
[Protocols.Reg]
HKCR,"PROTOCOLS\Handler\cdl",,,"CDL: Asynchronous Pluggable Protocol Handler"
HKCR,"PROTOCOLS\Handler\cdl","CLSID",,"%CLSID_CdlProtocol%"
HKCR,"PROTOCOLS\Handler\file",,,"file:, local: Asynchronous Pluggable Protocol Handler"
HKCR,"PROTOCOLS\Handler\file","CLSID",,"%CLSID_FileProtocol%"
HKCR,"PROTOCOLS\Handler\local",,,"file:, local: Asynchronous Pluggable Protocol Handler"
HKCR,"PROTOCOLS\Handler\local","CLSID",,"%CLSID_FileProtocol%"
HKCR,"PROTOCOLS\Handler\ftp",,,"ftp: Asynchronous Pluggable Protocol Handler"
HKCR,"PROTOCOLS\Handler\ftp","CLSID",,"%CLSID_FtpProtocol%"
HKCR,"PROTOCOLS\Handler\gopher",,,"gopher: Asynchronous Pluggable Protocol Handler"
HKCR,"PROTOCOLS\Handler\gopher","CLSID",,"%CLSID_GopherProtocol%"
HKCR,"PROTOCOLS\Handler\http",,,"http: Asynchronous Pluggable Protocol Handler"
HKCR,"PROTOCOLS\Handler\http","CLSID",,"%CLSID_HttpProtocol%"
HKCR,"PROTOCOLS\Handler\https",,,"https: Asynchronous Pluggable Protocol Handler"
HKCR,"PROTOCOLS\Handler\https","CLSID",,"%CLSID_HttpsProtocol%"
HKCR,"PROTOCOLS\Handler\mk",,,"mk: Asynchronous Pluggable Protocol Handler"
HKCR,"PROTOCOLS\Handler\mk","CLSID",,"%CLSID_MkProtocol%"

View file

@ -23,5 +23,6 @@
<file>umon.c</file>
<file>umstream.c</file>
<file>urlmon_main.c</file>
<file>rsrc.rc</file>
<file>urlmon.spec</file>
</module>

View file

@ -89,7 +89,7 @@ HRESULT WINAPI URLMON_DllCanUnloadNow(void)
typedef struct {
IClassFactory ITF_IClassFactory;
DWORD ref;
LONG ref;
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
} IClassFactoryImpl;
@ -125,8 +125,6 @@ CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
URLMON_LockModule();
return InterlockedIncrement(&This->ref);
}
@ -136,10 +134,10 @@ static ULONG WINAPI CF_Release(LPCLASSFACTORY iface)
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
URLMON_UnlockModule();
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
URLMON_UnlockModule();
}
return ref;
}
@ -229,10 +227,12 @@ DWORD WINAPI URLMON_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
factory->ITF_IClassFactory.lpVtbl = &CF_Vtbl;
factory->ref = 1;
factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
*ppv = &(factory->ITF_IClassFactory);
URLMON_LockModule();
return S_OK;
}

View file

@ -40,7 +40,7 @@ static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_ref
typedef struct
{
const IStreamVtbl *lpVtbl;
DWORD ref;
LONG ref;
HANDLE handle;
BOOL closed;
WCHAR *pszFileName;
@ -50,4 +50,13 @@ typedef struct
HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL, DWORD dwSize, LPWSTR pszFileName, HANDLE *phfile, IUMCacheStream **ppstr);
void UMCloseCacheFileStream(IUMCacheStream *pstr);
DEFINE_GUID(CLSID_CdlProtocol, 0x3dd53d40, 0x7b8b, 0x11D0, 0xb0,0x13, 0x00,0xaa,0x00,0x59,0xce,0x02);
DEFINE_GUID(CLSID_FileProtocol, 0x79EAC9E7, 0xBAF9, 0x11CE, 0x8C,0x82, 0x00,0xAA,0x00,0x4B,0xA9,0x0B);
DEFINE_GUID(CLSID_FtpProtocol, 0x79EAC9E3, 0xBAF9, 0x11CE, 0x8C,0x82, 0x00,0xAA,0x00,0x4B,0xA9,0x0B);
DEFINE_GUID(CLSID_GopherProtocol, 0x79EAC9E4, 0xBAF9, 0x11CE, 0x8C,0x82, 0x00,0xAA,0x00,0x4B,0xA9,0x0B);
DEFINE_GUID(CLSID_HttpProtocol, 0x79EAC9E2, 0xBAF9, 0x11CE, 0x8C,0x82, 0x00,0xAA,0x00,0x4B,0xA9,0x0B);
DEFINE_GUID(CLSID_HttpsProtocol, 0x79EAC9E5, 0xBAF9, 0x11CE, 0x8C,0x82, 0x00,0xAA,0x00,0x4B,0xA9,0x0B);
DEFINE_GUID(CLSID_MkProtocol, 0x79EAC9E6, 0xBAF9, 0x11CE, 0x8C,0x82, 0x00,0xAA,0x00,0x4B,0xA9,0x0B);
#endif /* __WINE_URLMON_MAIN_H */

View file

@ -0,0 +1,77 @@
/*
* Copyright 2004 Huw D M Davies
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_ADVPUB_H
#define __WINE_ADVPUB_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _CabInfo {
PSTR pszCab;
PSTR pszInf;
PSTR pszSection;
char szSrcPath[MAX_PATH];
DWORD dwFlags;
} CABINFO, *PCABINFO;
typedef struct _StrEntry {
LPSTR pszName;
LPSTR pszValue;
} STRENTRY, *LPSTRENTRY;
typedef const STRENTRY CSTRENTRY;
typedef CSTRENTRY *LPCSTRENTRY;
typedef struct _StrTable {
DWORD cEntries;
LPSTRENTRY pse;
} STRTABLE, *LPSTRTABLE;
typedef const STRTABLE CSTRTABLE;
typedef CSTRTABLE *LPCSTRTABLE;
/* Flags for RunSetupCommand */
#define RSC_FLAG_INF 0x00000001
#define RSC_FLAG_SKIPDISKSPACECHECK 0x00000002
#define RSC_FLAG_QUIET 0x00000004
#define RSC_FLAG_NGCONV 0x00000008
#define RSC_FLAG_UPDHLPDLLS 0x00000010
#define RSC_FLAG_DELAYREGISTEROCX 0x00000200
#define RSC_FLAG_SETUPAPI 0x00000400
/* Flags for DelNode */
#define ADN_DEL_IF_EMPTY 0x00000001
#define ADN_DONT_DEL_SUBDIRS 0x00000002
#define ADN_DONT_DEL_DIR 0x00000004
HRESULT WINAPI RunSetupCommand(HWND hWnd,
LPCSTR szCmdName, LPCSTR szInfSection, LPCSTR szDir, LPCSTR lpszTitle,
HANDLE *phEXE, DWORD dwFlags, LPVOID pvReserved);
HRESULT WINAPI DelNode(LPCSTR pszFileOrDirName, DWORD dwFlags);
DWORD WINAPI NeedRebootInit(VOID);
BOOL WINAPI NeedReboot(DWORD dwRebootCheck);
HRESULT WINAPI RegInstall(HMODULE hm, LPCSTR pszSection, LPCSTRTABLE pstTable);
HRESULT WINAPI GetVersionFromFile(LPSTR lpszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer, BOOL bVersion);
HRESULT WINAPI GetVersionFromFileEx(LPSTR lpszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer, BOOL bVersion);
#ifdef __cplusplus
}
#endif
#endif /* __WINE_ADVPUB_H */