/* AntiMoniker data structure */
typedef struct AntiMonikerImpl{
- IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
+ const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
/* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
* two monikers are equal. That's whay IROTData interface is implemented by monikers.
*/
- IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
+ const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
ULONG ref; /* reference counter for this object */
/********************************************************************************/
/* Virtual function table for the AntiMonikerImpl class which include IPersist,*/
/* IPersistStream and IMoniker functions. */
-static IMonikerVtbl VT_AntiMonikerImpl =
+static const IMonikerVtbl VT_AntiMonikerImpl =
{
AntiMonikerImpl_QueryInterface,
AntiMonikerImpl_AddRef,
/********************************************************************************/
/* Virtual function table for the IROTData class. */
-static IROTDataVtbl VT_ROTDataImpl =
+static const IROTDataVtbl VT_ROTDataImpl =
{
AntiMonikerROTDataImpl_QueryInterface,
AntiMonikerROTDataImpl_AddRef,
/* BindCtx data strucrture */
typedef struct BindCtxImpl{
- IBindCtxVtbl *lpVtbl; /* VTable relative to the IBindCtx interface.*/
+ const IBindCtxVtbl *lpVtbl; /* VTable relative to the IBindCtx interface.*/
ULONG ref; /* reference counter for this object */
}
/* Virtual function table for the BindCtx class. */
-static IBindCtxVtbl VT_BindCtxImpl =
+static const IBindCtxVtbl VT_BindCtxImpl =
{
BindCtxImpl_QueryInterface,
BindCtxImpl_AddRef,
/*
* List all interface VTables here
*/
- IDataObjectVtbl* lpvtbl1; /* IDataObject VTable */
+ const IDataObjectVtbl* lpvtbl1; /* IDataObject VTable */
/*
* The hidden OLE clipboard window. This window is used as the bridge between the
typedef struct
{
/* IEnumFORMATETC VTable */
- IEnumFORMATETCVtbl *lpVtbl;
+ const IEnumFORMATETCVtbl *lpVtbl;
/* IEnumFORMATETC fields */
UINT posFmt; /* current enumerator position */
/*
* Virtual function table for the OLEClipbrd's exposed IDataObject interface
*/
-static IDataObjectVtbl OLEClipbrd_IDataObject_VTable =
+static const IDataObjectVtbl OLEClipbrd_IDataObject_VTable =
{
OLEClipbrd_IDataObject_QueryInterface,
OLEClipbrd_IDataObject_AddRef,
/*
* Virtual function table for IEnumFORMATETC interface
*/
-static struct IEnumFORMATETCVtbl efvt =
+static const IEnumFORMATETCVtbl efvt =
{
OLEClipbrd_IEnumFORMATETC_QueryInterface,
OLEClipbrd_IEnumFORMATETC_AddRef,
HINSTANCE OLE32_hInstance = 0; /* FIXME: make static ... */
+#define ARRAYSIZE(array) (sizeof(array)/sizeof((array)[0]))
+
/****************************************************************************
* This section defines variables internal to the COM module.
*
UnregisterClassW(wszAptWinClass, OLE32_hInstance);
}
-static void COM_TlsDestroy()
+static void COM_TlsDestroy(void)
{
struct oletls *info = NtCurrentTeb()->ReservedForOle;
if (info)
return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
}
+/* open HKCR\\CLSID\\{string form of clsid} key */
+DWORD COM_OpenKeyForCLSID(REFCLSID clsid, REGSAM access, HKEY *key)
+{
+ static const WCHAR wszCLSIDSlash[] = {'C','L','S','I','D','\\',0};
+ WCHAR path[CHARS_IN_GUID + ARRAYSIZE(wszCLSIDSlash) - 1];
+ strcpyW(path, wszCLSIDSlash);
+ StringFromGUID2(clsid, path + strlenW(wszCLSIDSlash), CHARS_IN_GUID);
+ return RegOpenKeyExW(HKEY_CLASSES_ROOT, path, 0, access, key);
+}
+
/******************************************************************************
* ProgIDFromCLSID [OLE32.@]
*
*/
HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *lplpszProgID)
{
- char strCLSID[50], *buf, *buf2;
- DWORD buf2len;
- HKEY xhkey;
- LPMALLOC mllc;
+ static const WCHAR wszProgID[] = {'P','r','o','g','I','D',0};
+ HKEY hkey = NULL;
+ HKEY hkey_clsid;
HRESULT ret = S_OK;
- WINE_StringFromCLSID(clsid, strCLSID);
-
- buf = HeapAlloc(GetProcessHeap(), 0, strlen(strCLSID)+14);
- sprintf(buf,"CLSID\\%s\\ProgID", strCLSID);
- if (RegOpenKeyA(HKEY_CLASSES_ROOT, buf, &xhkey))
+ if (ERROR_SUCCESS != COM_OpenKeyForCLSID(clsid, KEY_READ, &hkey_clsid))
ret = REGDB_E_CLASSNOTREG;
- HeapFree(GetProcessHeap(), 0, buf);
+ if (ret == S_OK)
+ {
+ if (RegOpenKeyExW(hkey_clsid, wszProgID, 0, KEY_READ, &hkey))
+ ret = REGDB_E_CLASSNOTREG;
+ RegCloseKey(hkey_clsid);
+ }
if (ret == S_OK)
{
- buf2 = HeapAlloc(GetProcessHeap(), 0, 255);
- buf2len = 255;
- if (RegQueryValueA(xhkey, NULL, buf2, &buf2len))
+ DWORD progidlen = 0;
+
+ if (RegQueryValueW(hkey, NULL, NULL, &progidlen))
ret = REGDB_E_CLASSNOTREG;
if (ret == S_OK)
{
- if (CoGetMalloc(0,&mllc))
- ret = E_OUTOFMEMORY;
- else
+ *lplpszProgID = CoTaskMemAlloc(progidlen * sizeof(WCHAR));
+ if (*lplpszProgID)
{
- DWORD len = MultiByteToWideChar( CP_ACP, 0, buf2, -1, NULL, 0 );
- *lplpszProgID = IMalloc_Alloc(mllc, len * sizeof(WCHAR) );
- MultiByteToWideChar( CP_ACP, 0, buf2, -1, *lplpszProgID, len );
+ if (RegQueryValueW(hkey, NULL, *lplpszProgID, &progidlen))
+ ret = REGDB_E_CLASSNOTREG;
}
+ else
+ ret = E_OUTOFMEMORY;
}
- HeapFree(GetProcessHeap(), 0, buf2);
- RegCloseKey(xhkey);
}
+ RegCloseKey(hkey);
return ret;
}
HRESULT WINAPI CLSIDFromProgID(LPCOLESTR progid, LPCLSID riid)
{
static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 };
- char buf2[80];
+ WCHAR buf2[CHARS_IN_GUID];
DWORD buf2len = sizeof(buf2);
HKEY xhkey;
}
HeapFree(GetProcessHeap(),0,buf);
- if (RegQueryValueA(xhkey,NULL,buf2,&buf2len))
+ if (RegQueryValueW(xhkey,NULL,buf2,&buf2len))
{
RegCloseKey(xhkey);
return CO_E_CLASSSTRING;
}
RegCloseKey(xhkey);
- return __CLSIDFromStringA(buf2,riid);
+ return CLSIDFromString(buf2,riid);
}
*/
HRESULT WINAPI CoGetPSClsid(REFIID riid, CLSID *pclsid)
{
- char *buf, buf2[40];
- DWORD buf2len;
- HKEY xhkey;
+ static const WCHAR wszInterface[] = {'I','n','t','e','r','f','a','c','e','\\',0};
+ static const WCHAR wszPSC[] = {'\\','P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0};
+ WCHAR path[ARRAYSIZE(wszInterface) - 1 + CHARS_IN_GUID - 1 + ARRAYSIZE(wszPSC)];
+ WCHAR value[CHARS_IN_GUID];
+ DWORD len;
+ HKEY hkey;
TRACE("() riid=%s, pclsid=%p\n", debugstr_guid(riid), pclsid);
- /* Get the input iid as a string */
- WINE_StringFromCLSID(riid, buf2);
- /* Allocate memory for the registry key we will construct.
- (length of iid string plus constant length of static text */
- buf = HeapAlloc(GetProcessHeap(), 0, strlen(buf2)+27);
- if (buf == NULL)
- return E_OUTOFMEMORY;
-
- /* Construct the registry key we want */
- sprintf(buf,"Interface\\%s\\ProxyStubClsid32", buf2);
+ /* Interface\\{string form of riid}\\ProxyStubClsid32 */
+ strcpyW(path, wszInterface);
+ StringFromGUID2(riid, path + ARRAYSIZE(wszInterface) - 1, CHARS_IN_GUID);
+ strcpyW(path + ARRAYSIZE(wszInterface) - 1 + CHARS_IN_GUID - 1, wszPSC);
/* Open the key.. */
- if (RegOpenKeyA(HKEY_CLASSES_ROOT, buf, &xhkey))
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, path, 0, KEY_READ, &hkey))
{
WARN("No PSFactoryBuffer object is registered for IID %s\n", debugstr_guid(riid));
- HeapFree(GetProcessHeap(),0,buf);
return REGDB_E_IIDNOTREG;
}
- HeapFree(GetProcessHeap(),0,buf);
/* ... Once we have the key, query the registry to get the
value of CLSID as a string, and convert it into a
proper CLSID structure to be passed back to the app */
- buf2len = sizeof(buf2);
- if ( (RegQueryValueA(xhkey,NULL,buf2,&buf2len)) )
+ len = sizeof(value);
+ if (ERROR_SUCCESS != RegQueryValueW(hkey, NULL, value, &len))
{
- RegCloseKey(xhkey);
+ RegCloseKey(hkey);
return REGDB_E_IIDNOTREG;
}
- RegCloseKey(xhkey);
+ RegCloseKey(hkey);
/* We have the CLSid we want back from the registry as a string, so
lets convert it into a CLSID structure */
- if ( (__CLSIDFromStringA(buf2,pclsid)) != NOERROR)
+ if (CLSIDFromString(value, pclsid) != NOERROR)
return REGDB_E_IIDNOTREG;
TRACE ("() Returning CLSID=%s\n", debugstr_guid(pclsid));
}
/***********************************************************************
- * compobj_RegReadPath [internal]
+ * COM_RegReadPath [internal]
*
* Reads a registry value and expands it when necessary
*/
-static HRESULT
-compobj_RegReadPath(char * keyname, char * valuename, char * dst, DWORD dstlen)
+HRESULT COM_RegReadPath(HKEY hkeyroot, const WCHAR *keyname, const WCHAR *valuename, WCHAR * dst, DWORD dstlen)
{
HRESULT hres;
HKEY key;
DWORD keytype;
- char src[MAX_PATH];
- DWORD dwLength = dstlen;
+ WCHAR src[MAX_PATH];
+ DWORD dwLength = dstlen * sizeof(WCHAR);
- if((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &key)) == ERROR_SUCCESS) {
- if( (hres = RegQueryValueExA(key, NULL, NULL, &keytype, (LPBYTE)src, &dwLength)) == ERROR_SUCCESS ) {
+ if((hres = RegOpenKeyExW(hkeyroot, keyname, 0, KEY_READ, &key)) == ERROR_SUCCESS) {
+ if( (hres = RegQueryValueExW(key, NULL, NULL, &keytype, (LPBYTE)src, &dwLength)) == ERROR_SUCCESS ) {
if (keytype == REG_EXPAND_SZ) {
- if (dstlen <= ExpandEnvironmentStringsA(src, dst, dstlen)) hres = ERROR_MORE_DATA;
+ if (dstlen <= ExpandEnvironmentStringsW(src, dst, dstlen)) hres = ERROR_MORE_DATA;
} else {
- lstrcpynA(dst, src, dstlen);
+ lstrcpynW(dst, src, dstlen);
}
}
RegCloseKey (key);
*/
HRESULT WINAPI CoGetClassObject(
REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
- REFIID iid, LPVOID *ppv
-) {
+ REFIID iid, LPVOID *ppv)
+{
LPUNKNOWN regClassObject;
HRESULT hres = E_UNEXPECTED;
- char xclsid[80];
- HINSTANCE hLibrary;
- typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
- DllGetClassObjectFunc DllGetClassObject;
-
- WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
*/
if (S_OK == COM_GetRegisteredClassObject(rclsid, dwClsContext, ®ClassObject))
{
- /*
- * Get the required interface from the retrieved pointer.
- */
+ /* Get the required interface from the retrieved pointer. */
hres = IUnknown_QueryInterface(regClassObject, iid, ppv);
/*
}
/* first try: in-process */
- if ((CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER) & dwClsContext) {
- char keyname[MAX_PATH];
- char dllpath[MAX_PATH+1];
-
- sprintf(keyname,"CLSID\\%s\\InprocServer32",xclsid);
+ if ((CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER) & dwClsContext)
+ {
+ static const WCHAR wszInprocServer32[] = {'I','n','p','r','o','c','S','e','r','v','e','r','3','2',0};
+ HINSTANCE hLibrary;
+ typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
+ DllGetClassObjectFunc DllGetClassObject;
+ WCHAR dllpath[MAX_PATH+1];
+ HKEY hkey;
+
+ if (ERROR_SUCCESS != COM_OpenKeyForCLSID(rclsid, KEY_READ, &hkey))
+ {
+ ERR("class %s not registered\n", debugstr_guid(rclsid));
+ hres = REGDB_E_CLASSNOTREG;
+ }
- if ( compobj_RegReadPath(keyname, NULL, dllpath, sizeof(dllpath)) != ERROR_SUCCESS) {
- /* failure: CLSID is not found in registry */
- WARN("class %s not registered inproc\n", xclsid);
+ if (COM_RegReadPath(hkey, wszInprocServer32, NULL, dllpath, ARRAYSIZE(dllpath)) != ERROR_SUCCESS)
+ {
+ /* failure: CLSID is not found in registry */
+ WARN("class %s not registered inproc\n", debugstr_guid(rclsid));
hres = REGDB_E_CLASSNOTREG;
- } else {
- if ((hLibrary = LoadLibraryExA(dllpath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) {
- /* failure: DLL could not be loaded */
- ERR("couldn't load InprocServer32 dll %s\n", dllpath);
- hres = E_ACCESSDENIED; /* FIXME: or should this be CO_E_DLLNOTFOUND? */
- } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) {
- /* failure: the dll did not export DllGetClassObject */
- ERR("couldn't find function DllGetClassObject in %s\n", dllpath);
- FreeLibrary( hLibrary );
- hres = CO_E_DLLNOTFOUND;
- } else {
- /* OK: get the ClassObject */
- COMPOBJ_DLLList_Add( hLibrary );
- return DllGetClassObject(rclsid, iid, ppv);
- }
- }
+ }
+ else
+ {
+ if ((hLibrary = LoadLibraryExW(dllpath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0)
+ {
+ /* failure: DLL could not be loaded */
+ ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(dllpath));
+ hres = E_ACCESSDENIED; /* FIXME: or should this be CO_E_DLLNOTFOUND? */
+ }
+ else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject")))
+ {
+ /* failure: the dll did not export DllGetClassObject */
+ ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllpath));
+ FreeLibrary( hLibrary );
+ hres = CO_E_DLLNOTFOUND;
+ }
+ else
+ {
+ /* OK: get the ClassObject */
+ COMPOBJ_DLLList_Add( hLibrary );
+ return DllGetClassObject(rclsid, iid, ppv);
+ }
+ }
}
/* Next try out of process */
*/
HRESULT WINAPI OleGetAutoConvert(REFCLSID clsidOld, LPCLSID pClsidNew)
{
- HKEY hkey = 0;
- char buf[200];
- WCHAR wbuf[200];
+ static const WCHAR wszAutoConvertTo[] = {'A','u','t','o','C','o','n','v','e','r','t','T','o',0};
+ HKEY hkey = NULL;
+ WCHAR buf[CHARS_IN_GUID];
DWORD len;
HRESULT res = S_OK;
- sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
- if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey))
+ if (ERROR_SUCCESS != COM_OpenKeyForCLSID(clsidOld, KEY_READ, &hkey))
{
res = REGDB_E_CLASSNOTREG;
- goto done;
+ goto done;
}
- len = 200;
+
+ len = sizeof(buf);
/* we can just query for the default value of AutoConvertTo key like that,
without opening the AutoConvertTo key and querying for NULL (default) */
- if (RegQueryValueA(hkey,"AutoConvertTo",buf,&len))
+ if (RegQueryValueW(hkey, wszAutoConvertTo, buf, &len))
{
res = REGDB_E_KEYMISSING;
- goto done;
+ goto done;
}
- MultiByteToWideChar( CP_ACP, 0, buf, -1, wbuf, sizeof(wbuf)/sizeof(WCHAR) );
- CLSIDFromString(wbuf,pClsidNew);
+ res = CLSIDFromString(buf, pClsidNew);
done:
if (hkey) RegCloseKey(hkey);
return res;
*/
HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
{
- HKEY hkey = 0;
- char buf[47];
- char szClsidNew[39];
+ static const WCHAR wszAutoTreatAs[] = {'A','u','t','o','T','r','e','a','t','A','s',0};
+ static const WCHAR wszTreatAs[] = {'T','r','e','a','t','A','s',0};
+ HKEY hkey = NULL;
+ WCHAR szClsidNew[CHARS_IN_GUID];
HRESULT res = S_OK;
- char auto_treat_as[39];
+ WCHAR auto_treat_as[CHARS_IN_GUID];
LONG auto_treat_as_size = sizeof(auto_treat_as);
CLSID id;
- sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
- WINE_StringFromCLSID(clsidNew, szClsidNew);
- if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey))
+ if (ERROR_SUCCESS != COM_OpenKeyForCLSID(clsidOld, KEY_READ | KEY_WRITE, &hkey))
{
res = REGDB_E_CLASSNOTREG;
goto done;
}
if (!memcmp( clsidOld, clsidNew, sizeof(*clsidOld) ))
{
- if (!RegQueryValueA(hkey, "AutoTreatAs", auto_treat_as, &auto_treat_as_size) &&
- !__CLSIDFromStringA(auto_treat_as, &id))
+ if (!RegQueryValueW(hkey, wszAutoTreatAs, auto_treat_as, &auto_treat_as_size) &&
+ !CLSIDFromString(auto_treat_as, &id))
{
- if (RegSetValueA(hkey, "TreatAs", REG_SZ, auto_treat_as, strlen(auto_treat_as)+1))
+ if (RegSetValueW(hkey, wszTreatAs, REG_SZ, auto_treat_as, sizeof(auto_treat_as)))
{
res = REGDB_E_WRITEREGDB;
goto done;
}
else
{
- RegDeleteKeyA(hkey, "TreatAs");
+ RegDeleteKeyW(hkey, wszTreatAs);
goto done;
}
}
- else if (RegSetValueA(hkey, "TreatAs", REG_SZ, szClsidNew, strlen(szClsidNew)+1))
+ else if (!StringFromGUID2(clsidNew, szClsidNew, ARRAYSIZE(szClsidNew)) &&
+ !RegSetValueW(hkey, wszTreatAs, REG_SZ, szClsidNew, sizeof(szClsidNew)))
{
- res = REGDB_E_WRITEREGDB;
+ res = REGDB_E_WRITEREGDB;
goto done;
}
*/
HRESULT WINAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID clsidNew)
{
- HKEY hkey = 0;
- char buf[200], szClsidNew[200];
+ static const WCHAR wszTreatAs[] = {'T','r','e','a','t','A','s',0};
+ HKEY hkey = NULL;
+ WCHAR szClsidNew[CHARS_IN_GUID];
HRESULT res = S_OK;
LONG len = sizeof(szClsidNew);
FIXME("(%s,%p)\n", debugstr_guid(clsidOld), clsidNew);
- sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
memcpy(clsidNew,clsidOld,sizeof(CLSID)); /* copy over old value */
- if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey))
+ if (COM_OpenKeyForCLSID(clsidOld, KEY_READ, &hkey))
{
res = REGDB_E_CLASSNOTREG;
goto done;
}
- if (RegQueryValueA(hkey, "TreatAs", szClsidNew, &len))
+ if (RegQueryValueW(hkey, wszTreatAs, szClsidNew, &len))
{
res = S_FALSE;
goto done;
}
- res = __CLSIDFromStringA(szClsidNew,clsidNew);
+ res = CLSIDFromString(szClsidNew,clsidNew);
if (FAILED(res))
- FIXME("Failed CLSIDFromStringA(%s), hres %lx?\n",szClsidNew,res);
+ ERR("Failed CLSIDFromStringA(%s), hres 0x%08lx\n", debugstr_w(szClsidNew), res);
done:
if (hkey) RegCloseKey(hkey);
return res;
-
}
/******************************************************************************
extern HRESULT WINE_StringFromCLSID(const CLSID *id,LPSTR idstr);
HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id);
+DWORD COM_OpenKeyForCLSID(REFCLSID clsid, REGSAM access, HKEY *key);
HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv);
/* Stub Manager */
extern HINSTANCE OLE32_hInstance; /* FIXME: make static */
+#define CHARS_IN_GUID 39 /* including NULL */
+
#endif /* __WINE_OLE_COMPOBJ_H */
WINE_DEFAULT_DEBUG_CHANNEL(ole);
-const CLSID CLSID_CompositeMoniker = {
+static const CLSID CLSID_CompositeMoniker = {
0x309, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}
};
/* CompositeMoniker data structure */
typedef struct CompositeMonikerImpl{
- IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
+ const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
/* The ROT (RunningObjectTable implementation) uses the IROTData
* interface to test whether two monikers are equal. That's why IROTData
* interface is implemented by monikers.
*/
- IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
+ const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
ULONG ref; /* reference counter for this object */
/* EnumMoniker data structure */
typedef struct EnumMonikerImpl{
- IEnumMonikerVtbl *lpVtbl; /* VTable relative to the IEnumMoniker interface.*/
+ const IEnumMonikerVtbl *lpVtbl; /* VTable relative to the IEnumMoniker interface.*/
ULONG ref; /* reference counter for this object */
/********************************************************************************/
/* Virtual function table for the IROTData class */
-static IEnumMonikerVtbl VT_EnumMonikerImpl =
+static const IEnumMonikerVtbl VT_EnumMonikerImpl =
{
EnumMonikerImpl_QueryInterface,
EnumMonikerImpl_AddRef,
/* Virtual function table for the CompositeMonikerImpl class which includes */
/* IPersist, IPersistStream and IMoniker functions. */
-static IMonikerVtbl VT_CompositeMonikerImpl =
+static const IMonikerVtbl VT_CompositeMonikerImpl =
{
CompositeMonikerImpl_QueryInterface,
CompositeMonikerImpl_AddRef,
/********************************************************************************/
/* Virtual function table for the IROTData class. */
-static IROTDataVtbl VT_ROTDataImpl =
+static const IROTDataVtbl VT_ROTDataImpl =
{
CompositeMonikerROTDataImpl_QueryInterface,
CompositeMonikerROTDataImpl_AddRef,
/*
* List all interface VTables here
*/
- IDataObjectVtbl* lpvtbl1;
- IUnknownVtbl* lpvtbl2;
- IPersistStorageVtbl* lpvtbl3;
- IViewObject2Vtbl* lpvtbl4;
- IOleCache2Vtbl* lpvtbl5;
- IOleCacheControlVtbl* lpvtbl6;
+ const IDataObjectVtbl* lpvtbl1;
+ const IUnknownVtbl* lpvtbl2;
+ const IPersistStorageVtbl* lpvtbl3;
+ const IViewObject2Vtbl* lpvtbl4;
+ const IOleCache2Vtbl* lpvtbl5;
+ const IOleCacheControlVtbl* lpvtbl6;
/*
* Reference count of this object
/*
* Virtual function tables for the DataCache class.
*/
-static IUnknownVtbl DataCache_NDIUnknown_VTable =
+static const IUnknownVtbl DataCache_NDIUnknown_VTable =
{
DataCache_NDIUnknown_QueryInterface,
DataCache_NDIUnknown_AddRef,
DataCache_NDIUnknown_Release
};
-static IDataObjectVtbl DataCache_IDataObject_VTable =
+static const IDataObjectVtbl DataCache_IDataObject_VTable =
{
DataCache_IDataObject_QueryInterface,
DataCache_IDataObject_AddRef,
DataCache_EnumDAdvise
};
-static IPersistStorageVtbl DataCache_IPersistStorage_VTable =
+static const IPersistStorageVtbl DataCache_IPersistStorage_VTable =
{
DataCache_IPersistStorage_QueryInterface,
DataCache_IPersistStorage_AddRef,
DataCache_HandsOffStorage
};
-static IViewObject2Vtbl DataCache_IViewObject2_VTable =
+static const IViewObject2Vtbl DataCache_IViewObject2_VTable =
{
DataCache_IViewObject2_QueryInterface,
DataCache_IViewObject2_AddRef,
DataCache_GetExtent
};
-static IOleCache2Vtbl DataCache_IOleCache2_VTable =
+static const IOleCache2Vtbl DataCache_IOleCache2_VTable =
{
DataCache_IOleCache2_QueryInterface,
DataCache_IOleCache2_AddRef,
DataCache_DiscardCache
};
-static IOleCacheControlVtbl DataCache_IOleCacheControl_VTable =
+static const IOleCacheControlVtbl DataCache_IOleCacheControl_VTable =
{
DataCache_IOleCacheControl_QueryInterface,
DataCache_IOleCacheControl_AddRef,
/*
* List all interface VTables here
*/
- IOleObjectVtbl* lpvtbl1;
- IUnknownVtbl* lpvtbl2;
- IDataObjectVtbl* lpvtbl3;
- IRunnableObjectVtbl* lpvtbl4;
+ const IOleObjectVtbl* lpvtbl1;
+ const IUnknownVtbl* lpvtbl2;
+ const IDataObjectVtbl* lpvtbl3;
+ const IRunnableObjectVtbl* lpvtbl4;
/*
* Reference count of this object
/*
* Virtual function tables for the DefaultHandler class.
*/
-static IOleObjectVtbl DefaultHandler_IOleObject_VTable =
+static const IOleObjectVtbl DefaultHandler_IOleObject_VTable =
{
DefaultHandler_QueryInterface,
DefaultHandler_AddRef,
DefaultHandler_SetColorScheme
};
-static IUnknownVtbl DefaultHandler_NDIUnknown_VTable =
+static const IUnknownVtbl DefaultHandler_NDIUnknown_VTable =
{
DefaultHandler_NDIUnknown_QueryInterface,
DefaultHandler_NDIUnknown_AddRef,
DefaultHandler_NDIUnknown_Release,
};
-static IDataObjectVtbl DefaultHandler_IDataObject_VTable =
+static const IDataObjectVtbl DefaultHandler_IDataObject_VTable =
{
DefaultHandler_IDataObject_QueryInterface,
DefaultHandler_IDataObject_AddRef,
DefaultHandler_EnumDAdvise
};
-static IRunnableObjectVtbl DefaultHandler_IRunnableObject_VTable =
+static const IRunnableObjectVtbl DefaultHandler_IRunnableObject_VTable =
{
DefaultHandler_IRunnableObject_QueryInterface,
DefaultHandler_IRunnableObject_AddRef,
typedef struct ErrorInfoImpl
{
- IErrorInfoVtbl *lpvtei;
- ICreateErrorInfoVtbl *lpvtcei;
- ISupportErrorInfoVtbl *lpvtsei;
+ const IErrorInfoVtbl *lpvtei;
+ const ICreateErrorInfoVtbl *lpvtcei;
+ const ISupportErrorInfoVtbl *lpvtsei;
DWORD ref;
GUID m_Guid;
DWORD m_dwHelpContext;
} ErrorInfoImpl;
-static IErrorInfoVtbl IErrorInfoImpl_VTable;
-static ICreateErrorInfoVtbl ICreateErrorInfoImpl_VTable;
-static ISupportErrorInfoVtbl ISupportErrorInfoImpl_VTable;
+static const IErrorInfoVtbl IErrorInfoImpl_VTable;
+static const ICreateErrorInfoVtbl ICreateErrorInfoImpl_VTable;
+static const ISupportErrorInfoVtbl ISupportErrorInfoImpl_VTable;
/*
converts an object pointer to This
return S_OK;
}
-static IErrorInfoVtbl IErrorInfoImpl_VTable =
+static const IErrorInfoVtbl IErrorInfoImpl_VTable =
{
IErrorInfoImpl_QueryInterface,
IErrorInfoImpl_AddRef,
return S_OK;
}
-static ICreateErrorInfoVtbl ICreateErrorInfoImpl_VTable =
+static const ICreateErrorInfoVtbl ICreateErrorInfoImpl_VTable =
{
ICreateErrorInfoImpl_QueryInterface,
ICreateErrorInfoImpl_AddRef,
return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
}
-static ISupportErrorInfoVtbl ISupportErrorInfoImpl_VTable =
+static const ISupportErrorInfoVtbl ISupportErrorInfoImpl_VTable =
{
ISupportErrorInfoImpl_QueryInterface,
ISupportErrorInfoImpl_AddRef,
/* filemoniker data structure */
typedef struct FileMonikerImpl{
- IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
+ const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
/* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
* two monikers are equal. That's whay IROTData interface is implemented by monikers.
*/
- IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
+ const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
ULONG ref; /* reference counter for this object */
* written by FileMonikerImpl_Save
*/
static HRESULT WINAPI
-FileMonikerImpl_Load(IMoniker* iface,IStream* pStm)
+FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
{
HRESULT res;
- CHAR* filePathA;
- WCHAR* filePathW;
+ CHAR* filePathA = NULL;
+ WCHAR* filePathW = NULL;
ULONG bread;
WORD wbuffer;
- DWORD dwbuffer,length,i,doubleLenHex,doubleLenDec;
+ DWORD dwbuffer, bytesA, bytesW, len;
+ int i;
FileMonikerImpl *This = (FileMonikerImpl *)iface;
TRACE("(%p,%p)\n",iface,pStm);
- /* first WORD is non significative */
+ /* first WORD must be 0 */
res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
if (bread!=sizeof(WORD) || wbuffer!=0)
{
- ERR("Couldn't read 0 word\n");
- return E_FAIL;
+ WARN("Couldn't read 0 word\n");
+ goto fail;
}
/* read filePath string length (plus one) */
- res=IStream_Read(pStm,&length,sizeof(DWORD),&bread);
+ res=IStream_Read(pStm,&bytesA,sizeof(DWORD),&bread);
if (bread != sizeof(DWORD))
{
- ERR("Couldn't read file string length\n");
- return E_FAIL;
+ WARN("Couldn't read file string length\n");
+ goto fail;
}
/* read filePath string */
- filePathA=HeapAlloc(GetProcessHeap(),0,length);
- res=IStream_Read(pStm,filePathA,length,&bread);
- HeapFree(GetProcessHeap(),0,filePathA);
- if (bread != length)
+ filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
+ if (!filePathA)
+ {
+ res = E_OUTOFMEMORY;
+ goto fail;
+ }
+
+ res=IStream_Read(pStm,filePathA,bytesA,&bread);
+ if (bread != bytesA)
{
- ERR("Couldn't read file path string\n");
- return E_FAIL;
+ WARN("Couldn't read file path string\n");
+ goto fail;
}
/* read the first constant */
IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF)
{
- ERR("Couldn't read 0xDEADFFFF constant\n");
- return E_FAIL;
+ WARN("Couldn't read 0xDEADFFFF constant\n");
+ goto fail;
}
- length--;
-
- for(i=0;i<10;i++){
- res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
- if (bread!=sizeof(WORD) || wbuffer!=0)
+ for(i=0;i<5;i++)
+ {
+ res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
+ if (bread!=sizeof(DWORD) || dwbuffer!=0)
{
- ERR("Couldn't read 0 padding\n");
- return E_FAIL;
+ WARN("Couldn't read 0 padding\n");
+ goto fail;
}
}
- if (length>8)
- length=0;
-
- doubleLenHex=doubleLenDec=2*length;
- if (length > 5)
- doubleLenDec+=6;
-
res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
- if (bread!=sizeof(DWORD) || dwbuffer!=doubleLenDec)
- return E_FAIL;
+ if (bread!=sizeof(DWORD))
+ goto fail;
+
+ if (!dwbuffer) /* No W-string */
+ {
+ bytesA--;
+ len=MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, bytesA, NULL, 0);
+ if (!len)
+ goto fail;
+
+ filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
+ if (!filePathW)
+ {
+ res = E_OUTOFMEMORY;
+ goto fail;
+ }
+ MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, -1, filePathW, len+1);
+ goto succeed;
+ }
- if (length==0)
- return res;
+ if (dwbuffer < 6)
+ goto fail;
+
+ bytesW=dwbuffer - 6;
res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
- if (bread!=sizeof(DWORD) || dwbuffer!=doubleLenHex)
- return E_FAIL;
+ if (bread!=sizeof(DWORD) || dwbuffer!=bytesW)
+ goto fail;
res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
if (bread!=sizeof(WORD) || wbuffer!=0x3)
- return E_FAIL;
-
- filePathW=HeapAlloc(GetProcessHeap(),0,(length+1)*sizeof(WCHAR));
- filePathW[length]=0;
- res=IStream_Read(pStm,filePathW,doubleLenHex,&bread);
- if (bread!=doubleLenHex) {
- HeapFree(GetProcessHeap(), 0, filePathW);
- return E_FAIL;
+ goto fail;
+
+ len=bytesW/sizeof(WCHAR);
+ filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
+ if(!filePathW)
+ {
+ res = E_OUTOFMEMORY;
+ goto fail;
}
+ res=IStream_Read(pStm,filePathW,bytesW,&bread);
+ if (bread!=bytesW)
+ goto fail;
- HeapFree(GetProcessHeap(),0,This->filePathName);
+ filePathW[len]=0;
+ succeed:
+ HeapFree(GetProcessHeap(),0,filePathA);
+ HeapFree(GetProcessHeap(),0,This->filePathName);
This->filePathName=filePathW;
+ return S_OK;
+
+ fail:
+ HeapFree(GetProcessHeap(), 0, filePathA);
+ HeapFree(GetProcessHeap(), 0, filePathW);
+
+ if (SUCCEEDED(res))
+ res = E_FAIL;
return res;
}
/******************************************************************************
* FileMoniker_Save
*
- * This function saves data of this object. In the beginning I thougth
+ * This function saves data of this object. In the beginning I thought
* that I have just to write the filePath string on Stream. But, when I
- * tested this function whith windows programs samples, I noticed that it
- * was not the case. So I analysed data written by this function on
- * Windows and what this did function exactly ! But I have no idea about
- * its logic !
- * I guessed data which must be written on stream is:
+ * tested this function with windows programs samples, I noticed that it
+ * was not the case. This implementation is based on XP SP2. Other versions
+ * of Windows have minor variations.
+ *
+ * Data which must be written on stream is:
* 1) WORD constant:zero
* 2) length of the path string ("\0" included)
* 3) path string type A
* 4) DWORD constant : 0xDEADFFFF
- * 5) ten WORD constant: zero
- * 6) DWORD: double-length of the the path string type W ("\0" not
+ * 5) five DWORD constant: zero
+ * 6) If we're only writing the multibyte version,
+ * write a zero DWORD and finish.
+ *
+ * 7) DWORD: double-length of the the path string type W ("\0" not
* included)
- * 7) WORD constant: 0x3
- * 8) filePath unicode string.
- * if the length(filePath) > 8 or length(filePath) == 8 stop at step 5)
+ * 8) WORD constant: 0x3
+ * 9) filePath unicode string.
+ *
*/
static HRESULT WINAPI
FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
HRESULT res;
LPOLESTR filePathW=This->filePathName;
- CHAR* filePathA;
- DWORD len;
+ CHAR* filePathA;
+ DWORD bytesA, bytesW, len;
- DWORD constant1 = 0xDEADFFFF; /* these constants are detected after analysing the data structure written by */
- WORD constant2 = 0x3; /* FileMoniker_Save function in a windows program system */
+ static const DWORD DEADFFFF = 0xDEADFFFF; /* Constants */
+ static const DWORD ZERO = 0;
+ static const WORD THREE = 0x3;
- WORD zero=0;
- DWORD doubleLenHex;
- DWORD doubleLenDec;
- int i=0;
+ int i;
+ BOOL bUsedDefault, bWriteWide;
TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
if (pStm==NULL)
return E_POINTER;
- /* write a DWORD set to 0 : constant */
- res=IStream_Write(pStm,&zero,sizeof(WORD),NULL);
+ /* write a 0 WORD */
+ res=IStream_Write(pStm,&ZERO,sizeof(WORD),NULL);
+ if (!SUCCEEDED(res)) return res;
- /* write length of filePath string ( "\0" included )*/
- len = WideCharToMultiByte( CP_ACP, 0, filePathW, -1, NULL, 0, NULL, NULL );
- res=IStream_Write(pStm,&len,sizeof(DWORD),NULL);
+ /* write length of filePath string ( 0 included )*/
+ bytesA = WideCharToMultiByte( CP_ACP, 0, filePathW, -1, NULL, 0, NULL, NULL );
+ res=IStream_Write(pStm,&bytesA,sizeof(DWORD),NULL);
+ if (!SUCCEEDED(res)) return res;
- /* write filePath string type A */
- filePathA=HeapAlloc(GetProcessHeap(),0,len);
- WideCharToMultiByte( CP_ACP, 0, filePathW, -1, filePathA, len, NULL, NULL );
- res=IStream_Write(pStm,filePathA,len,NULL);
+ /* write A string (with '\0') */
+ filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
+ if (!filePathA)
+ return E_OUTOFMEMORY;
+ WideCharToMultiByte( CP_ACP, 0, filePathW, -1, filePathA, bytesA, NULL, &bUsedDefault);
+ res=IStream_Write(pStm,filePathA,bytesA,NULL);
HeapFree(GetProcessHeap(),0,filePathA);
+ if (!SUCCEEDED(res)) return res;
- /* write a DWORD set to 0xDEADFFFF: constant */
- res=IStream_Write(pStm,&constant1,sizeof(DWORD),NULL);
-
- len--;
- /* write 10 times a DWORD set to 0 : constants */
- for(i=0;i<10;i++)
- res=IStream_Write(pStm,&zero,sizeof(WORD),NULL);
-
- if (len>8)
- len=0;
+ /* write a DWORD 0xDEADFFFF */
+ res=IStream_Write(pStm,&DEADFFFF,sizeof(DWORD),NULL);
+ if (!SUCCEEDED(res)) return res;
- doubleLenHex=doubleLenDec=2*len;
- if (len > 5)
- doubleLenDec+=6;
+ /* write 5 zero DWORDs */
+ for(i=0;i<5;i++)
+ {
+ res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
+ if (!SUCCEEDED(res)) return res;
+ }
- /* write double-length of the path string ( "\0" included )*/
- res=IStream_Write(pStm,&doubleLenDec,sizeof(DWORD),NULL);
+ /* Write the wide version if:
+ * + couldn't convert to CP_ACP,
+ * or + it's a directory,
+ * or + there's a character > 0xFF
+ */
+ len = lstrlenW(filePathW);
+ bWriteWide = (bUsedDefault || (len > 0 && filePathW[len-1]=='\\' ));
+ if (!bWriteWide)
+ {
+ WCHAR* pch;
+ for(pch=filePathW;*pch;++pch)
+ {
+ if (*pch > 0xFF)
+ {
+ bWriteWide = TRUE;
+ break;
+ }
+ }
+ }
- if (len==0)
+ if (!bWriteWide)
+ {
+ res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
return res;
+ }
+
+ /* write bytes needed for the filepathW (without 0) + 6 */
+ bytesW = len*sizeof(WCHAR) + 6;
+ res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
+ if (!SUCCEEDED(res)) return res;
- /* write double-length (hexa representation) of the path string ( "\0" included ) */
- res=IStream_Write(pStm,&doubleLenHex,sizeof(DWORD),NULL);
+ /* try again, without the extra 6 */
+ bytesW -= 6;
+ res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
+ if (!SUCCEEDED(res)) return res;
- /* write a WORD set to 0x3: constant */
- res=IStream_Write(pStm,&constant2,sizeof(WORD),NULL);
+ /* write a WORD 3 */
+ res=IStream_Write(pStm,&THREE,sizeof(WORD),NULL);
+ if (!SUCCEEDED(res)) return res;
- /* write path unicode string */
- res=IStream_Write(pStm,filePathW,doubleLenHex,NULL);
+ /* write W string (no 0) */
+ res=IStream_Write(pStm,filePathW,bytesW,NULL);
return res;
}
FileMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
{
FileMonikerImpl *This = (FileMonikerImpl *)iface;
- DWORD len=lstrlenW(This->filePathName);
- DWORD sizeMAx;
TRACE("(%p,%p)\n",iface,pcbSize);
if (!pcbSize)
return E_POINTER;
- /* for more details see FileMonikerImpl_Save coments */
-
- sizeMAx = sizeof(WORD) + /* first WORD is 0 */
- sizeof(DWORD)+ /* length of filePath including "\0" in the end of the string */
- (len+1)+ /* filePath string */
- sizeof(DWORD)+ /* constant : 0xDEADFFFF */
- 10*sizeof(WORD)+ /* 10 zero WORD */
- sizeof(DWORD); /* size of the unicode filePath: "\0" not included */
-
- if (len==0 || len > 8)
- return S_OK;
-
- sizeMAx += sizeof(DWORD)+ /* size of the unicode filePath: "\0" not included */
- sizeof(WORD)+ /* constant : 0x3 */
- len*sizeof(WCHAR); /* unicde filePath string */
-
- pcbSize->u.LowPart=sizeMAx;
- pcbSize->u.HighPart=0;
+ /* We could calculate exactly (see ...::Save()) but instead
+ * we'll make a quick over-estimate, like Windows (NT4, XP) does.
+ */
+ pcbSize->u.LowPart = 0x38 + 4 * lstrlenW(This->filePathName);
+ pcbSize->u.HighPart = 0;
return S_OK;
}
* Virtual function table for the FileMonikerImpl class which include IPersist,
* IPersistStream and IMoniker functions.
*/
-static IMonikerVtbl VT_FileMonikerImpl =
+static const IMonikerVtbl VT_FileMonikerImpl =
{
FileMonikerImpl_QueryInterface,
FileMonikerImpl_AddRef,
};
/* Virtual function table for the IROTData class. */
-static IROTDataVtbl VT_ROTDataImpl =
+static const IROTDataVtbl VT_ROTDataImpl =
{
FileMonikerROTDataImpl_QueryInterface,
FileMonikerROTDataImpl_AddRef,
WINE_DEFAULT_DEBUG_CHANNEL(ole);
typedef struct _FTMarshalImpl {
- IUnknownVtbl *lpVtbl;
+ const IUnknownVtbl *lpVtbl;
DWORD ref;
- IMarshalVtbl *lpvtblFTM;
+ const IMarshalVtbl *lpvtblFTM;
IUnknown *pUnkOuter;
} FTMarshalImpl;
return 0;
}
-static IUnknownVtbl iunkvt =
+static const IUnknownVtbl iunkvt =
{
IiFTMUnknown_fnQueryInterface,
IiFTMUnknown_fnAddRef,
return S_OK;
}
-static IMarshalVtbl ftmvtbl =
+static const IMarshalVtbl ftmvtbl =
{
FTMarshalImpl_QueryInterface,
FTMarshalImpl_AddRef,
/* Class data */
typedef struct StdGlobalInterfaceTableImpl
{
- IGlobalInterfaceTableVtbl *lpVtbl;
+ const IGlobalInterfaceTableVtbl *lpVtbl;
ULONG ref;
struct StdGITEntry* firstEntry;
return S_OK;
}
-static IClassFactoryVtbl GITClassFactoryVtbl = {
+static const IClassFactoryVtbl GITClassFactoryVtbl = {
GITCF_QueryInterface,
GITCF_AddRef,
GITCF_Release,
GITCF_LockServer
};
-static IClassFactoryVtbl *PGITClassFactoryVtbl = &GITClassFactoryVtbl;
+static const IClassFactoryVtbl *PGITClassFactoryVtbl = &GITClassFactoryVtbl;
HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv)
{
}
/* Virtual function table */
-static IGlobalInterfaceTableVtbl StdGlobalInterfaceTableImpl_Vtbl =
+static const IGlobalInterfaceTableVtbl StdGlobalInterfaceTableImpl_Vtbl =
{
StdGlobalInterfaceTable_QueryInterface,
StdGlobalInterfaceTable_AddRef,
*/
struct HGLOBALStreamImpl
{
- IStreamVtbl *lpVtbl; /* Needs to be the first item in the struct
+ const IStreamVtbl *lpVtbl; /* Needs to be the first item in the struct
* since we want to cast this in an IStream pointer */
/*
/*
* Virtual function table for the HGLOBALStreamImpl class.
*/
-static IStreamVtbl HGLOBALStreamImpl_Vtbl =
+static const IStreamVtbl HGLOBALStreamImpl_Vtbl =
{
HGLOBALStreamImpl_QueryInterface,
HGLOBALStreamImpl_AddRef,
*
*****************************************************************************/
/* set the vtable later */
-static IMallocVtbl VT_IMalloc32;
+static const IMallocVtbl VT_IMalloc32;
typedef struct {
- IMallocVtbl *lpVtbl;
+ const IMallocVtbl *lpVtbl;
DWORD dummy; /* nothing, we are static */
IMallocSpy * pSpy; /* the spy when active */
DWORD SpyedAllocationsLeft; /* number of spyed allocations left */
} _Malloc32;
/* this is the static object instance */
-_Malloc32 Malloc32 = {&VT_IMalloc32, 0, NULL, 0, 0, NULL, 0};
+static _Malloc32 Malloc32 = {&VT_IMalloc32, 0, NULL, 0, 0, NULL, 0};
/* with a spy active all calls from pre to post methods are threadsave */
static CRITICAL_SECTION IMalloc32_SpyCS;
}
}
-static IMallocVtbl VT_IMalloc32 =
+static const IMallocVtbl VT_IMalloc32 =
{
IMalloc_fnQueryInterface,
IMalloc_fnAddRefRelease,
*****************************************************************************/
/* set the vtable later */
-static IMallocSpyVtbl VT_IMallocSpy;
+static const IMallocSpyVtbl VT_IMallocSpy;
typedef struct {
- IMallocSpyVtbl *lpVtbl;
+ const IMallocSpyVtbl *lpVtbl;
DWORD ref;
} _MallocSpy;
/* this is the static object instance */
-_MallocSpy MallocSpy = {&VT_IMallocSpy, 0};
+static _MallocSpy MallocSpy = {&VT_IMallocSpy, 0};
/******************************************************************************
* IMalloc32_QueryInterface [VTABLE]
TRACE ("(%p)->()\n", This);
}
-static void MallocSpyDumpLeaks() {
+static void MallocSpyDumpLeaks(void) {
TRACE("leaks: %lu\n", Malloc32.SpyedAllocationsLeft);
}
-static IMallocSpyVtbl VT_IMallocSpy =
+static const IMallocSpyVtbl VT_IMallocSpy =
{
IMallocSpy_fnQueryInterface,
IMallocSpy_fnAddRef,
/* ItemMoniker data structure */
typedef struct ItemMonikerImpl{
- IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
+ const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
/* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
* two monikers are equal. That's whay IROTData interface is implemented by monikers.
*/
- IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
+ const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
ULONG ref; /* reference counter for this object */
/********************************************************************************/
/* Virtual function table for the ItemMonikerImpl class which include IPersist,*/
/* IPersistStream and IMoniker functions. */
-static IMonikerVtbl VT_ItemMonikerImpl =
+static const IMonikerVtbl VT_ItemMonikerImpl =
{
ItemMonikerImpl_QueryInterface,
ItemMonikerImpl_AddRef,
/********************************************************************************/
/* Virtual function table for the IROTData class. */
-static IROTDataVtbl VT_ROTDataImpl =
+static const IROTDataVtbl VT_ROTDataImpl =
{
ItemMonikerROTDataImpl_QueryInterface,
ItemMonikerROTDataImpl_AddRef,
struct stub_manager *manager;
struct ifstub *ifstub;
BOOL tablemarshal;
- IRpcStubBuffer *stub;
- IPSFactoryBuffer *psfb;
+ IRpcStubBuffer *stub = NULL;
HRESULT hr;
hr = apartment_getoxid(apt, &stdobjref->oxid);
if (hr != S_OK)
return hr;
- hr = get_facbuf_for_iid(riid, &psfb);
- if (hr != S_OK)
+ /* IUnknown doesn't require a stub buffer, because it never goes out on
+ * the wire */
+ if (!IsEqualIID(riid, &IID_IUnknown))
{
- ERR("couldn't get IPSFactory buffer for interface %s\n", debugstr_guid(riid));
- return hr;
- }
+ IPSFactoryBuffer *psfb;
- hr = IPSFactoryBuffer_CreateStub(psfb, riid, obj, &stub);
- IPSFactoryBuffer_Release(psfb);
- if (hr != S_OK)
- {
- ERR("Failed to create an IRpcStubBuffer from IPSFactory for %s\n", debugstr_guid(riid));
- return hr;
+ hr = get_facbuf_for_iid(riid, &psfb);
+ if (hr != S_OK)
+ {
+ ERR("couldn't get IPSFactory buffer for interface %s\n", debugstr_guid(riid));
+ return hr;
+ }
+
+ hr = IPSFactoryBuffer_CreateStub(psfb, riid, obj, &stub);
+ IPSFactoryBuffer_Release(psfb);
+ if (hr != S_OK)
+ {
+ ERR("Failed to create an IRpcStubBuffer from IPSFactory for %s\n", debugstr_guid(riid));
+ return hr;
+ }
}
+ else /* need to addref object anyway */
+ IUnknown_AddRef(obj);
if (mshlflags & MSHLFLAGS_NOPING)
stdobjref->flags = SORF_NOPING;
manager = new_stub_manager(apt, obj, mshlflags);
if (!manager)
{
- IRpcStubBuffer_Release(stub);
+ if (stub) IRpcStubBuffer_Release(stub);
return E_OUTOFMEMORY;
}
}
TRACE("oxid = %s, oid = %s\n", wine_dbgstr_longlong(This->oxid),
wine_dbgstr_longlong(This->oid));
+ /* SORFP_NOLIFTIMEMGMT proxies (for IRemUnknown) shouldn't be
+ * disconnected - it won't do anything anyway, except cause
+ * problems for other objects that depend on this proxy always
+ * working */
+ if (This->sorflags & SORFP_NOLIFETIMEMGMT) return;
+
EnterCriticalSection(&This->cs);
LIST_FOR_EACH(cursor, &This->interfaces)
* Needs to be the first item in the struct
* since we want to cast this in an ILockBytes pointer
*/
- ILockBytesVtbl *lpVtbl;
+ const ILockBytesVtbl *lpVtbl;
/*
* Reference count
/*
* Virtual function table for the HGLOBALLockBytesImpl class.
*/
-static ILockBytesVtbl HGLOBALLockBytesImpl_Vtbl =
+static const ILockBytesVtbl HGLOBALLockBytesImpl_Vtbl =
{
HGLOBALLockBytesImpl_QueryInterface,
HGLOBALLockBytesImpl_AddRef,
* Needs to be the first item in the struct
* since we want to cast this in an ILockBytes pointer
*/
- ILockBytes16Vtbl *lpVtbl;
+ const ILockBytes16Vtbl *lpVtbl;
ULONG ref;
/*
#undef VTENT
msegvt16 = MapLS( &vt16 );
}
- newLockBytes->lpVtbl = (ILockBytes16Vtbl*)msegvt16;
+ newLockBytes->lpVtbl = (const ILockBytes16Vtbl*)msegvt16;
newLockBytes->ref = 0;
/*
* Initialize the support.
}
/* Virtual function table for the IRunningObjectTable class. */
-static IRunningObjectTableVtbl VT_RunningObjectTableImpl =
+static const IRunningObjectTableVtbl VT_RunningObjectTableImpl =
{
RunningObjectTableImpl_QueryInterface,
RunningObjectTableImpl_AddRef,
/* the initial reference is set to "1" */
This->ref = 1; /* set the ref count to one */
- This->pos = 0; /* Set the list start posn to start */
+ This->pos = current_pos; /* Set the list start posn */
This->moniker_count = moniker_count; /* Need the same size table as ROT */
This->monikers = monikers;
extern const CLSID CLSID_FileMoniker;
extern const CLSID CLSID_ItemMoniker;
extern const CLSID CLSID_AntiMoniker;
-extern const CLSID CLSID_CompositeMoniker;
HRESULT FileMonikerCF_Create(REFIID riid, LPVOID *ppv);
HRESULT ItemMonikerCF_Create(REFIID riid, LPVOID *ppv);
WINE_DEFAULT_DEBUG_CHANNEL(ole);
-HTASK16 hETask = 0;
-WORD Table_ETask[62];
+static HTASK16 hETask = 0;
+static WORD Table_ETask[62];
-LPMALLOC16 currentMalloc16=NULL;
+static LPMALLOC16 currentMalloc16=NULL;
/* --- IMalloc16 implementation */
typedef struct
{
/* IUnknown fields */
- IMalloc16Vtbl *lpVtbl;
+ const IMalloc16Vtbl *lpVtbl;
DWORD ref;
/* IMalloc16 fields */
} IMalloc16Impl;
#undef VTENT
msegvt16 = MapLS( &vt16 );
}
- This->lpVtbl = (IMalloc16Vtbl*)msegvt16;
+ This->lpVtbl = (const IMalloc16Vtbl*)msegvt16;
This->ref = 1;
return (LPMALLOC16)MapLS( This );
}
* everything we need.
*/
if (!K32WOWCallback16Ex(
- (DWORD)((IMalloc16Vtbl*)MapSL(
+ (DWORD)((const IMalloc16Vtbl*)MapSL(
(SEGPTR)((LPMALLOC16)MapSL((SEGPTR)mllc))->lpVtbl )
)->Alloc,
WCB16_CDECL,
REFCLSID clsid, /* [in] class id as found in registry */
LPOLESTR16 *lplpszProgID/* [out] associated Prog ID */
) {
- char strCLSID[50], *buf, *buf2;
- DWORD buf2len;
+ static const WCHAR wszProgID[] = {'P','r','o','g','I','D',0};
HKEY xhkey;
+ HKEY hkey;
HRESULT ret = S_OK;
- WINE_StringFromCLSID(clsid, strCLSID);
-
- buf = HeapAlloc(GetProcessHeap(), 0, strlen(strCLSID)+14);
- sprintf(buf,"CLSID\\%s\\ProgID", strCLSID);
- if (RegOpenKeyA(HKEY_CLASSES_ROOT, buf, &xhkey))
+ if (COM_OpenKeyForCLSID(clsid, KEY_READ, &hkey))
+ ret = REGDB_E_CLASSNOTREG;
+
+ if ((ret == S_OK) &&
+ RegOpenKeyW(hkey, wszProgID, &xhkey))
ret = REGDB_E_CLASSNOTREG;
-
- HeapFree(GetProcessHeap(), 0, buf);
if (ret == S_OK)
{
- buf2 = HeapAlloc(GetProcessHeap(), 0, 255);
+ DWORD buf2len;
+ char *buf2 = HeapAlloc(GetProcessHeap(), 0, 255);
buf2len = 255;
if (RegQueryValueA(xhkey, NULL, buf2, &buf2len))
ret = REGDB_E_CLASSNOTREG;
DWORD flags, /* [in] REGCLS flags indicating how connections are made */
LPDWORD lpdwRegister
) {
- char buf[80];
-
- WINE_StringFromCLSID(rclsid,buf);
-
FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
- buf,pUnk,dwClsContext,flags,lpdwRegister
+ debugstr_guid(rclsid),pUnk,dwClsContext,flags,lpdwRegister
);
return 0;
}
#include "ole2ver.h"
#include "wownt32.h"
+#include "wine/unicode.h"
#include "wine/winbase16.h"
#include "wine/wingdi16.h"
#include "wine/winuser16.h"
*/
HRESULT WINAPI OleSetAutoConvert(REFCLSID clsidOld, REFCLSID clsidNew)
{
- HKEY hkey = 0;
- char buf[200], szClsidNew[200];
+ static const WCHAR wszAutoConvertTo[] = {'A','u','t','o','C','o','n','v','e','r','t','T','o',0};
+ HKEY hkey = NULL;
+ WCHAR szClsidNew[CHARS_IN_GUID];
HRESULT res = S_OK;
- /* FIXME: convert to Unicode */
TRACE("(%s,%s)\n", debugstr_guid(clsidOld), debugstr_guid(clsidNew));
- sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
- WINE_StringFromCLSID(clsidNew, szClsidNew);
- if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey))
+
+ if (COM_OpenKeyForCLSID(clsidOld, KEY_READ | KEY_WRITE, &hkey))
{
res = REGDB_E_CLASSNOTREG;
goto done;
}
- if (RegSetValueA(hkey, "AutoConvertTo", REG_SZ, szClsidNew, strlen(szClsidNew)+1))
+ StringFromGUID2(clsidNew, szClsidNew, CHARS_IN_GUID);
+ if (RegSetValueW(hkey, wszAutoConvertTo, REG_SZ, szClsidNew, (strlenW(szClsidNew)+1) * sizeof(WCHAR)))
{
res = REGDB_E_WRITEREGDB;
goto done;
@ stdcall CoRevokeMallocSpy()\r
@ stdcall CoSetProxyBlanket(ptr long long wstr long long ptr long)\r
@ stdcall CoSetState(ptr)\r
-@ stub CoSwitchCallContext\r
@ stdcall CoSuspendClassObjects()\r
+@ stub CoSwitchCallContext\r
@ stdcall CoTaskMemAlloc(long)\r
@ stdcall CoTaskMemFree(ptr)\r
@ stdcall CoTaskMemRealloc(ptr long)\r
@ stub HWND_UserMarshal\r
@ stub HWND_UserSize\r
@ stub HWND_UserUnmarshal\r
-@ stub I_RemoteMain\r
@ stdcall IIDFromString(wstr ptr) CLSIDFromString\r
+@ stub I_RemoteMain\r
@ stdcall IsAccelerator(long long ptr long)\r
@ stdcall IsEqualGUID(ptr ptr)\r
@ stub IsValidIid\r
@ stdcall RegisterDragDrop(long ptr)\r
@ stdcall ReleaseStgMedium(ptr)\r
@ stdcall RevokeDragDrop(long)\r
-@ stdcall SetConvertStg(ptr long)\r
-@ stub SetDocumentBitStg\r
-@ stdcall SetErrorInfo(long ptr)\r
@ stub SNB_UserFree\r
@ stub SNB_UserMarshal\r
@ stub SNB_UserSize\r
@ stub SNB_UserUnmarshal\r
+@ stub STGMEDIUM_UserFree\r
+@ stub STGMEDIUM_UserMarshal\r
+@ stub STGMEDIUM_UserSize\r
+@ stub STGMEDIUM_UserUnmarshal\r
+@ stdcall SetConvertStg(ptr long)\r
+@ stub SetDocumentBitStg\r
+@ stdcall SetErrorInfo(long ptr)\r
@ stdcall StgCreateDocfile(wstr long long ptr)\r
@ stdcall StgCreateDocfileOnILockBytes(ptr long long ptr)\r
@ stdcall StgCreatePropSetStg(ptr long ptr)\r
@ stub StgGetIFillLockBytesOnILockBytes\r
@ stdcall StgIsStorageFile(wstr)\r
@ stdcall StgIsStorageILockBytes(ptr)\r
-@ stub STGMEDIUM_UserFree\r
-@ stub STGMEDIUM_UserMarshal\r
-@ stub STGMEDIUM_UserSize\r
-@ stub STGMEDIUM_UserUnmarshal\r
@ stub StgOpenAsyncDocfileOnIFillLockBytes\r
@ stdcall StgOpenStorage(wstr ptr long ptr long ptr)\r
@ stdcall StgOpenStorageEx(wstr long long long ptr ptr ptr ptr)\r
*/
typedef struct OleAdviseHolderImpl
{
- IOleAdviseHolderVtbl *lpVtbl;
+ const IOleAdviseHolderVtbl *lpVtbl;
DWORD ref;
/**************************************************************************
* OleAdviseHolderImpl_VTable
*/
-static struct IOleAdviseHolderVtbl oahvt =
+static const IOleAdviseHolderVtbl oahvt =
{
OleAdviseHolderImpl_QueryInterface,
OleAdviseHolderImpl_AddRef,
* OleAdviseHolderImpl_Constructor
*/
-static LPOLEADVISEHOLDER OleAdviseHolderImpl_Constructor()
+static LPOLEADVISEHOLDER OleAdviseHolderImpl_Constructor(void)
{
OleAdviseHolderImpl* lpoah;
DWORD index;
typedef struct DataAdviseHolder
{
- IDataAdviseHolderVtbl *lpVtbl;
+ const IDataAdviseHolderVtbl *lpVtbl;
DWORD ref;
DWORD maxCons;
/**************************************************************************
* DataAdviseHolderImpl_VTable
*/
-static struct IDataAdviseHolderVtbl DataAdviseHolderImpl_VTable =
+static const IDataAdviseHolderVtbl DataAdviseHolderImpl_VTable =
{
DataAdviseHolder_QueryInterface,
DataAdviseHolder_AddRef,
/******************************************************************************
* DataAdviseHolder_Constructor
*/
-static IDataAdviseHolder* DataAdviseHolder_Constructor()
+static IDataAdviseHolder* DataAdviseHolder_Constructor(void)
{
DataAdviseHolder* newHolder;
* COM will load the appropriate interface stubs and proxies as needed.
*/
typedef struct _CFStub {
- IRpcStubBufferVtbl *lpvtbl;
+ const IRpcStubBufferVtbl *lpvtbl;
DWORD ref;
LPUNKNOWN pUnkServer;
FIXME("(%p), stub!\n",pv);
}
-static IRpcStubBufferVtbl cfstubvt = {
+static const IRpcStubBufferVtbl cfstubvt = {
CFStub_QueryInterface,
CFStub_AddRef,
CFStub_Release,
ULONG ref = InterlockedDecrement(&This->ref);
if (!ref) {
- IRpcChannelBuffer_Release(This->chanbuf);This->chanbuf = NULL;
+ IRpcChannelBuffer_Release(This->chanbuf);
+ This->chanbuf = NULL;
HeapFree(GetProcessHeap(),0,This);
}
return ref;
return S_OK;
}
-static IRpcProxyBufferVtbl pspbvtbl = {
+static const IRpcProxyBufferVtbl pspbvtbl = {
IRpcProxyBufferImpl_QueryInterface,
IRpcProxyBufferImpl_AddRef,
IRpcProxyBufferImpl_Release,
IRpcProxyBufferImpl_Connect,
IRpcProxyBufferImpl_Disconnect
};
-static IClassFactoryVtbl cfproxyvt = {
+static const IClassFactoryVtbl cfproxyvt = {
CFProxy_QueryInterface,
CFProxy_AddRef,
CFProxy_Release,
static ULONG WINAPI RURpcProxyBufferImpl_AddRef(LPRPCPROXYBUFFER iface) {
ICOM_THIS_MULTI(RemUnkProxy,lpvtbl_proxy,iface);
+ TRACE("%p, %ld\n", iface, This->refs + 1);
return InterlockedIncrement(&This->refs);
}
static ULONG WINAPI RURpcProxyBufferImpl_Release(LPRPCPROXYBUFFER iface) {
ICOM_THIS_MULTI(RemUnkProxy,lpvtbl_proxy,iface);
ULONG ref = InterlockedDecrement(&This->refs);
-
+ TRACE("%p, %ld\n", iface, ref);
if (!ref) {
IRpcChannelBuffer_Release(This->chan);This->chan = NULL;
HeapFree(GetProcessHeap(),0,This);
static HRESULT WINAPI RURpcProxyBufferImpl_Connect(LPRPCPROXYBUFFER iface,IRpcChannelBuffer* pRpcChannelBuffer) {
ICOM_THIS_MULTI(RemUnkProxy,lpvtbl_proxy,iface);
+ TRACE("%p, %p\n", iface, pRpcChannelBuffer);
This->chan = pRpcChannelBuffer;
IRpcChannelBuffer_AddRef(This->chan);
return S_OK;
}
static void WINAPI RURpcProxyBufferImpl_Disconnect(LPRPCPROXYBUFFER iface) {
ICOM_THIS_MULTI(RemUnkProxy,lpvtbl_proxy,iface);
+ TRACE("%p, %p\n", iface, This->chan);
if (This->chan) {
IRpcChannelBuffer_Release(This->chan);
This->chan = NULL;
return E_FAIL;
}
-static IPSFactoryBufferVtbl psfacbufvtbl = {
+static const IPSFactoryBufferVtbl psfacbufvtbl = {
PSFacBuf_QueryInterface,
PSFacBuf_AddRef,
PSFacBuf_Release,
};
/* This is the whole PSFactoryBuffer object, just the vtableptr */
-static IPSFactoryBufferVtbl *lppsfac = &psfacbufvtbl;
+static const IPSFactoryBufferVtbl *lppsfac = &psfacbufvtbl;
/***********************************************************************
* DllGetClassObject [OLE32.@]
#define INTERFACE_ENTRY(interface, base, clsid32, clsid16) { &IID_##interface, #interface, base, sizeof(interface##Vtbl)/sizeof(void*), clsid16, clsid32 }
#define STD_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, &CLSID_PSFactoryBuffer, NULL)
+#define LCL_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, NULL, NULL)
-static struct regsvr_interface const interface_list[] = {
- STD_INTERFACE_ENTRY(IUnknown),
+static const struct regsvr_interface interface_list[] = {
+ LCL_INTERFACE_ENTRY(IUnknown),
STD_INTERFACE_ENTRY(IClassFactory),
+ LCL_INTERFACE_ENTRY(IMalloc),
+ LCL_INTERFACE_ENTRY(IMarshal),
STD_INTERFACE_ENTRY(IStorage),
- STD_INTERFACE_ENTRY(IStream ),
+ LCL_INTERFACE_ENTRY(IMessageFilter),
+ LCL_INTERFACE_ENTRY(IStdMarshalInfo),
+ LCL_INTERFACE_ENTRY(IExternalConnection),
+ LCL_INTERFACE_ENTRY(IMallocSpy),
+ LCL_INTERFACE_ENTRY(IMultiQI),
+ STD_INTERFACE_ENTRY(IStream),
STD_INTERFACE_ENTRY(IPersistStorage),
STD_INTERFACE_ENTRY(IDataObject),
STD_INTERFACE_ENTRY(IAdviseSink),
+ LCL_INTERFACE_ENTRY(IDataAdviseHolder),
+ LCL_INTERFACE_ENTRY(IOleAdviseHolder),
STD_INTERFACE_ENTRY(IOleObject),
STD_INTERFACE_ENTRY(IOleClientSite),
+ LCL_INTERFACE_ENTRY(IDropSource),
STD_INTERFACE_ENTRY(IRemUnknown),
+ LCL_INTERFACE_ENTRY(IClientSecurity),
+ LCL_INTERFACE_ENTRY(IServerSecurity),
{ NULL } /* list terminator */
};
static HRESULT create_server(REFCLSID rclsid)
{
+ static const WCHAR wszLocalServer32[] = { 'L','o','c','a','l','S','e','r','v','e','r','3','2',0 };
static const WCHAR embedding[] = { ' ', '-','E','m','b','e','d','d','i','n','g',0 };
+ HKEY hkeyclsid;
HKEY key;
- char buf[200];
HRESULT hres = E_UNEXPECTED;
- char xclsid[80];
WCHAR exe[MAX_PATH+1];
DWORD exelen = sizeof(exe);
WCHAR command[MAX_PATH+sizeof(embedding)/sizeof(WCHAR)];
STARTUPINFOW sinfo;
PROCESS_INFORMATION pinfo;
- WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
+ hres = HRESULT_FROM_WIN32(COM_OpenKeyForCLSID(rclsid, KEY_READ, &hkeyclsid));
+ if (hres != S_OK) {
+ ERR("class %s not registered\n", debugstr_guid(rclsid));
+ return REGDB_E_READREGDB;
+ }
- sprintf(buf,"CLSID\\%s\\LocalServer32",xclsid);
- hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key);
+ hres = RegOpenKeyExW(hkeyclsid, wszLocalServer32, 0, KEY_READ, &key);
if (hres != ERROR_SUCCESS) {
- WARN("CLSID %s not registered as LocalServer32\n", xclsid);
+ WARN("class %s not registered as LocalServer32\n", debugstr_guid(rclsid));
return REGDB_E_READREGDB; /* Probably */
}
strcpyW(command, exe);
strcatW(command, embedding);
- TRACE("activating local server '%s' for %s\n", debugstr_w(command), xclsid);
+ TRACE("activating local server %s for %s\n", debugstr_w(command), debugstr_guid(rclsid));
if (!CreateProcessW(exe, command, NULL, NULL, FALSE, 0, NULL, NULL, &sinfo, &pinfo)) {
WARN("failed to run local server %s\n", debugstr_w(exe));
static HRESULT create_local_service(REFCLSID rclsid)
{
HRESULT hres = REGDB_E_READREGDB;
- WCHAR buf[40], keyname[50];
- static const WCHAR szClsId[] = { 'C','L','S','I','D','\\',0 };
+ WCHAR buf[CHARS_IN_GUID], keyname[50];
static const WCHAR szAppId[] = { 'A','p','p','I','d',0 };
static const WCHAR szAppIdKey[] = { 'A','p','p','I','d','\\',0 };
static const WCHAR szLocalService[] = { 'L','o','c','a','l','S','e','r','v','i','c','e',0 };
TRACE("Attempting to start Local service for %s\n", debugstr_guid(rclsid));
/* read the AppID value under the class's key */
- strcpyW(keyname,szClsId);
- StringFromGUID2(rclsid,&keyname[6],39);
- r = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &hkey);
+ r = COM_OpenKeyForCLSID(rclsid, KEY_READ, &hkey);
if (r!=ERROR_SUCCESS)
return hres;
sz = sizeof buf;
return hres;
}
-#define PIPEPREF "\\\\.\\pipe\\"
+
+static void get_localserver_pipe_name(WCHAR *pipefn, REFCLSID rclsid)
+{
+ static const WCHAR wszPipeRef[] = {'\\','\\','.','\\','p','i','p','e','\\',0};
+ strcpyW(pipefn, wszPipeRef);
+ StringFromGUID2(rclsid, pipefn + sizeof(wszPipeRef)/sizeof(wszPipeRef[0]) - 1, CHARS_IN_GUID);
+}
/* FIXME: should call to rpcss instead */
HRESULT RPC_GetLocalClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
{
HRESULT hres;
HANDLE hPipe;
- char pipefn[200];
+ WCHAR pipefn[100];
DWORD res, bufferlen;
char marshalbuffer[200];
IStream *pStm;
TRACE("rclsid=%s, iid=%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
- strcpy(pipefn,PIPEPREF);
- WINE_StringFromCLSID(rclsid,pipefn+strlen(PIPEPREF));
+ get_localserver_pipe_name(pipefn, rclsid);
while (tries++ < MAXTRIES) {
- TRACE("waiting for %s\n", pipefn);
+ TRACE("waiting for %s\n", debugstr_w(pipefn));
- WaitNamedPipeA( pipefn, NMPWAIT_WAIT_FOREVER );
- hPipe = CreateFileA(pipefn, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
+ WaitNamedPipeW( pipefn, NMPWAIT_WAIT_FOREVER );
+ hPipe = CreateFileW(pipefn, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
if (hPipe == INVALID_HANDLE_VALUE) {
if (tries == 1) {
if ( (hres = create_server(rclsid)) &&
return hres;
Sleep(1000);
} else {
- WARN("Connecting to %s, no response yet, retrying: le is %lx\n",pipefn,GetLastError());
+ WARN("Connecting to %s, no response yet, retrying: le is %lx\n", debugstr_w(pipefn), GetLastError());
Sleep(1000);
}
continue;
{
struct local_server_params * lsp = (struct local_server_params *)param;
HANDLE hPipe;
- char pipefn[200];
+ WCHAR pipefn[100];
HRESULT hres;
IStream *pStm = lsp->stream;
STATSTG ststg;
TRACE("Starting threader for %s.\n",debugstr_guid(&lsp->clsid));
- strcpy(pipefn,PIPEPREF);
- WINE_StringFromCLSID(&lsp->clsid,pipefn+strlen(PIPEPREF));
+ get_localserver_pipe_name(pipefn, &lsp->clsid);
HeapFree(GetProcessHeap(), 0, lsp);
- hPipe = CreateNamedPipeA( pipefn, PIPE_ACCESS_DUPLEX,
+ hPipe = CreateNamedPipeW( pipefn, PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE|PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,
4096, 4096, 500 /* 0.5 second timeout */, NULL );
if (hPipe == INVALID_HANDLE_VALUE)
{
- FIXME("pipe creation failed for %s, le is %ld\n",pipefn,GetLastError());
+ FIXME("pipe creation failed for %s, le is %ld\n", debugstr_w(pipefn), GetLastError());
return 1;
}
static HRESULT PropertyStorage_StringCopy(LPCSTR src, LCID srcCP, LPSTR *dst,
LCID targetCP);
-static IPropertyStorageVtbl IPropertyStorage_Vtbl;
+static const IPropertyStorageVtbl IPropertyStorage_Vtbl;
/***********************************************************************
* Implementation of IPropertyStorage
*/
typedef struct tagPropertyStorage_impl
{
- IPropertyStorageVtbl *vtbl;
+ const IPropertyStorageVtbl *vtbl;
DWORD ref;
CRITICAL_SECTION cs;
IStream *stm;
/***********************************************************************
* vtables
*/
-IPropertySetStorageVtbl IPropertySetStorage_Vtbl =
+const IPropertySetStorageVtbl IPropertySetStorage_Vtbl =
{
IPropertySetStorage_fnQueryInterface,
IPropertySetStorage_fnAddRef,
IPropertySetStorage_fnEnum
};
-static IPropertyStorageVtbl IPropertyStorage_Vtbl =
+static const IPropertyStorageVtbl IPropertyStorage_Vtbl =
{
IPropertyStorage_fnQueryInterface,
IPropertyStorage_fnAddRef,
}
else
{
- if (++fmtptr < (BYTE *)rfmtid + sizeof(FMTID))
+ if (++fmtptr < (const BYTE *)rfmtid + sizeof(FMTID))
i |= *fmtptr << bitsRemaining;
*pstr++ = (WCHAR)(fmtMap[i & CHARMASK]);
bitsRemaining += BITS_PER_BYTE - BITS_IN_CHARMASK;
/*
* Virtual function table for the StgStreamImpl class.
*/
-static IStreamVtbl StgStreamImpl_Vtbl =
+static const IStreamVtbl StgStreamImpl_Vtbl =
{
StgStreamImpl_QueryInterface,
StgStreamImpl_AddRef,
#define READ_HEADER STORAGE_get_big_block(hf,-1,(LPBYTE)&sth);assert(!memcmp(STORAGE_magic,sth.magic,sizeof(STORAGE_magic)));
static IStorage16Vtbl stvt16;
-static IStorage16Vtbl *segstvt16 = NULL;
+static const IStorage16Vtbl *segstvt16 = NULL;
static IStream16Vtbl strvt16;
-static IStream16Vtbl *segstrvt16 = NULL;
+static const IStream16Vtbl *segstrvt16 = NULL;
/*ULONG WINAPI IStorage16_AddRef(LPSTORAGE16 this);*/
static void _create_istorage16(LPSTORAGE16 *stg);
typedef struct
{
/* IUnknown fields */
- IStream16Vtbl *lpVtbl;
+ const IStream16Vtbl *lpVtbl;
DWORD ref;
/* IStream16 fields */
SEGPTR thisptr; /* pointer to this struct as segmented */
VTENT(Stat);
VTENT(Clone);
#undef VTENT
- segstrvt16 = (IStream16Vtbl*)MapLS( &strvt16 );
+ segstrvt16 = (const IStream16Vtbl*)MapLS( &strvt16 );
} else {
#define VTENT(xfn) strvt16.xfn = IStream16_fn##xfn;
VTENT(QueryInterface);
typedef struct
{
/* IUnknown fields */
- IStreamVtbl *lpVtbl;
+ const IStreamVtbl *lpVtbl;
DWORD ref;
/* IStream32 fields */
struct storage_pps_entry stde;
typedef struct
{
/* IUnknown fields */
- IStorage16Vtbl *lpVtbl;
+ const IStorage16Vtbl *lpVtbl;
DWORD ref;
/* IStorage16 fields */
SEGPTR thisptr; /* pointer to this struct as segmented */
VTENT(SetStateBits)
VTENT(Stat)
#undef VTENT
- segstvt16 = (IStorage16Vtbl*)MapLS( &stvt16 );
+ segstvt16 = (const IStorage16Vtbl*)MapLS( &stvt16 );
} else {
#define VTENT(xfn) stvt16.xfn = IStorage16_fn##xfn;
VTENT(QueryInterface)
args[5] = 0;
if (!K32WOWCallback16Ex(
- (DWORD)((ILockBytes16Vtbl*)MapSL(
+ (DWORD)((const ILockBytes16Vtbl*)MapSL(
(SEGPTR)((LPLOCKBYTES16)MapSL(plkbyt))->lpVtbl)
)->ReadAt,
WCB16_PASCAL,
static DWORD GetAccessModeFromSTGM(DWORD stgm);
static DWORD GetCreationModeFromSTGM(DWORD stgm);
-extern IPropertySetStorageVtbl IPropertySetStorage_Vtbl;
+extern const IPropertySetStorageVtbl IPropertySetStorage_Vtbl;
/*
* Virtual function table for the IStorage32Impl class.
*/
-static IStorageVtbl Storage32Impl_Vtbl =
+static const IStorageVtbl Storage32Impl_Vtbl =
{
StorageBaseImpl_QueryInterface,
StorageBaseImpl_AddRef,
/*
* Virtual function table for the IEnumSTATSTGImpl class.
*/
-static IEnumSTATSTGVtbl IEnumSTATSTGImpl_Vtbl =
+static const IEnumSTATSTGVtbl IEnumSTATSTGImpl_Vtbl =
{
IEnumSTATSTGImpl_QueryInterface,
IEnumSTATSTGImpl_AddRef,
/*
* Virtual function table for the Storage32InternalImpl class.
*/
-static IStorageVtbl Storage32InternalImpl_Vtbl =
+static const IStorageVtbl Storage32InternalImpl_Vtbl =
{
StorageBaseImpl_QueryInterface,
StorageBaseImpl_AddRef,
*/
struct StorageBaseImpl
{
- IStorageVtbl *lpVtbl; /* Needs to be the first item in the struct
+ const IStorageVtbl *lpVtbl; /* Needs to be the first item in the struct
* since we want to cast this in a Storage32 pointer */
- IPropertySetStorageVtbl *pssVtbl; /* interface for adding a properties stream */
+ const IPropertySetStorageVtbl *pssVtbl; /* interface for adding a properties stream */
/*
* Reference count of this object
*/
struct IEnumSTATSTGImpl
{
- IEnumSTATSTGVtbl *lpVtbl; /* Needs to be the first item in the struct
+ const IEnumSTATSTGVtbl *lpVtbl; /* Needs to be the first item in the struct
* since we want to cast this in an IEnumSTATSTG pointer */
ULONG ref; /* Reference count */
*/
struct StgStreamImpl
{
- IStreamVtbl *lpVtbl; /* Needs to be the first item in the struct
+ const IStreamVtbl *lpVtbl; /* Needs to be the first item in the struct
* since we want to cast this to an IStream pointer */
/*
if (!stub) return NULL;
stub->stubbuffer = sb;
- IUnknown_AddRef(sb);
+ if (sb) IRpcStubBuffer_AddRef(sb);
/* no need to ref this, same object as sb */
stub->iface = iptr;
RPC_UnregisterInterface(&ifstub->iid);
- IUnknown_Release(ifstub->stubbuffer);
+ if (ifstub->stubbuffer) IUnknown_Release(ifstub->stubbuffer);
IUnknown_Release(ifstub->iface);
HeapFree(GetProcessHeap(), 0, ifstub);