Sync to Wine-20050211
James Hawkins <truiken@gmail.com>
- Use Interlocked* instead of ++/-- in AddRef/Release.
- Use only stored result of Interlocked* in AddRef/Release.
- Expand TRACEs to display the ref count.
Alex Villacis Lasso <a_villacis@palosanto.com>
- Initialize temporary variants before calling VariantChangeTypeEx.
- When parsing an hex/oct integer value, copy value verbatim in VARIANT,
  rather than a negated value. Add test case for this behavior.
Vincent Beron <vberon@mecano.gme.usherb.ca>
- Remove message telling users to copy native stdole32.tlb over as we
  now provide it.
- Better trace in LoadTypeLib.
- Change debug messages type to reflect we provide stdole32.tlb.
Robert Shearman <rob@codeweavers.com>
- Move OLE automation interface registration to oleaut32.
- Add IRemUnknown to list of interfaces to register.
Mike Hearn <mh@codeweavers.com>
- Change some FIXMEs to ERRs to reflect the fact that nothing needs
  fixing.
- Fix some memory leaks on error paths in _marshal_interface.
- Fix a typo, propagate errors better from inside the typelib
  marshaller.
- Return OLE automation build value as win2k by default.
Rein Klazes <wijn@wanadoo.nl>
- SafeArrayDestroy() returns success when called with a NULL
  pointer. Added to the test cases.
Paul Vriens <Paul.Vriens@xs4all.nl>
- Add WinXP to OaBuildVersion.
Modified: trunk/reactos/lib/oleaut32/connpt.c
Modified: trunk/reactos/lib/oleaut32/dispatch.c
Modified: trunk/reactos/lib/oleaut32/oleaut.c
Deleted: trunk/reactos/lib/oleaut32/oleaut32_Ru.rc
Added: trunk/reactos/lib/oleaut32/oleaut32_Ru.rc
Modified: trunk/reactos/lib/oleaut32/olefont.c
Modified: trunk/reactos/lib/oleaut32/olepicture.c
Modified: trunk/reactos/lib/oleaut32/regsvr.c
Modified: trunk/reactos/lib/oleaut32/safearray.c
Modified: trunk/reactos/lib/oleaut32/tmarshal.c
Modified: trunk/reactos/lib/oleaut32/typelib.c
Modified: trunk/reactos/lib/oleaut32/variant.c

Modified: trunk/reactos/lib/oleaut32/connpt.c
--- trunk/reactos/lib/oleaut32/connpt.c	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/connpt.c	2005-02-13 21:03:37 UTC (rev 13533)
@@ -196,8 +196,11 @@
 static ULONG WINAPI ConnectionPointImpl_AddRef(IConnectionPoint* iface)
 {
   ConnectionPointImpl *This = (ConnectionPointImpl *)iface;
-  TRACE("(%p)->(ref=%ld)\n", This, This->ref);
-  return InterlockedIncrement(&This->ref);
+  ULONG refCount = InterlockedIncrement(&This->ref);
+
+  TRACE("(%p)->(ref before=%ld)\n", This, refCount - 1);
+
+  return refCount;
 }
 
 /************************************************************************
@@ -209,20 +212,16 @@
       IConnectionPoint* iface)
 {
   ConnectionPointImpl *This = (ConnectionPointImpl *)iface;
-  ULONG ref;
-  TRACE("(%p)->(ref=%ld)\n", This, This->ref);
+  ULONG refCount = InterlockedDecrement(&This->ref);
 
-  /*
-   * Decrease the reference count on this object.
-   */
-  ref = InterlockedDecrement(&This->ref);
+  TRACE("(%p)->(ref before=%ld)\n", This, refCount + 1);
 
   /*
    * If the reference count goes down to 0, perform suicide.
    */
-  if (ref == 0) ConnectionPointImpl_Destroy(This);
+  if (!refCount) ConnectionPointImpl_Destroy(This);
 
-  return ref;
+  return refCount;
 }
 
 /************************************************************************
@@ -470,11 +469,12 @@
 static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface)
 {
   EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface;
-  ULONG ref;
-  TRACE("(%p)->(ref=%ld)\n", This, This->ref);
-  ref = InterlockedIncrement(&This->ref);
+  ULONG refCount = InterlockedIncrement(&This->ref);
+
+  TRACE("(%p)->(ref before=%ld)\n", This, refCount - 1);
+
   IUnknown_AddRef(This->pUnk);
-  return ref;
+  return refCount;
 }
 
 /************************************************************************
@@ -485,22 +485,18 @@
 static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface)
 {
   EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface;
-  ULONG ref;
-  TRACE("(%p)->(ref=%ld)\n", This, This->ref);
+  ULONG refCount = InterlockedDecrement(&This->ref);
 
+  TRACE("(%p)->(ref before=%ld)\n", This, refCount + 1);
+
   IUnknown_Release(This->pUnk);
 
   /*
-   * Decrease the reference count on this object.
-   */
-  ref = InterlockedDecrement(&This->ref);
-
-  /*
    * If the reference count goes down to 0, perform suicide.
    */
-  if (ref == 0) EnumConnectionsImpl_Destroy(This);
+  if (!refCount) EnumConnectionsImpl_Destroy(This);
 
-  return ref;
+  return refCount;
 }
 
 /************************************************************************

Modified: trunk/reactos/lib/oleaut32/dispatch.c
--- trunk/reactos/lib/oleaut32/dispatch.c	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/dispatch.c	2005-02-13 21:03:37 UTC (rev 13533)
@@ -256,9 +256,11 @@
 static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface)
 {
     StdDispatch *This = (StdDispatch *)iface;
-    TRACE("()\n");
+    ULONG refCount = InterlockedIncrement(&This->ref);
 
-    return InterlockedIncrement(&This->ref);
+    TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
+
+    return refCount;
 }
 
 /******************************************************************************
@@ -269,18 +271,17 @@
 static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface)
 {
     StdDispatch *This = (StdDispatch *)iface;
-    ULONG ref;
-    TRACE("(%p)->()\n", This);
+    ULONG refCount = InterlockedDecrement(&This->ref);
 
-    ref = InterlockedDecrement(&This->ref);
+    TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1);
 
-    if (ref == 0)
+    if (!refCount)
     {
         ITypeInfo_Release(This->pTypeInfo);
         CoTaskMemFree(This);
     }
 
-    return ref;
+    return refCount;
 }
 
 /******************************************************************************

Modified: trunk/reactos/lib/oleaut32/oleaut.c
--- trunk/reactos/lib/oleaut32/oleaut.c	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/oleaut.c	2005-02-13 21:03:37 UTC (rev 13533)
@@ -563,10 +563,11 @@
     case 0x80000a04:  /* WIN98 */
     case 0x00000004:  /* NT40 */
     case 0x00000005:  /* W2K */
+    case 0x00000105:  /* WinXP */
 		return MAKELONG(0xffff, 40);
     default:
-		ERR("Version value not known yet. Please investigate it !\n");
-		return 0x0;
+		FIXME("Version value not known yet. Please investigate it !\n");
+		return MAKELONG(0xffff, 40);  /* for now return the same value as for w2k */
     }
 }
 

Deleted: trunk/reactos/lib/oleaut32/oleaut32_Ru.rc
--- trunk/reactos/lib/oleaut32/oleaut32_Ru.rc	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/oleaut32_Ru.rc	2005-02-13 21:03:37 UTC (rev 13533)
@@ -1,31 +0,0 @@
-/*
- * Russian resources for oleaut32
- *
- * Copyright 2004 Dmitry Timoshkov
- *
- * 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
- */
-
-LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
-
-STRINGTABLE DISCARDABLE
-{
-  IDS_TRUE  "¤­ÓÔõÓ"
-  IDS_FALSE "?¯µ³"
-  IDS_YES   "?Ó"
-  IDS_NO    "?Õ?"
-  IDS_ON    "?ÛÙ?¸Õݯ"
-  IDS_OFF   "?¹ÛÙ?¸Õݯ"
-}

Copied: trunk/reactos/lib/oleaut32/oleaut32_Ru.rc (from rev 13532, vendor/wine/dlls/oleaut32/current/oleaut32_Ru.rc)

Modified: trunk/reactos/lib/oleaut32/olefont.c
--- trunk/reactos/lib/oleaut32/olefont.c	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/olefont.c	2005-02-13 21:03:37 UTC (rev 13533)
@@ -1214,7 +1214,7 @@
     return E_FAIL;
   hres = LoadTypeLib(stdole32tlb, &tl);
   if (FAILED(hres)) {
-    FIXME("Could not load the stdole32.tlb?\n");
+    ERR("Could not load the stdole32.tlb?\n");
     return hres;
   }
   hres = ITypeLib_GetTypeInfoOfGuid(tl, &IID_IDispatch, ppTInfo);

Modified: trunk/reactos/lib/oleaut32/olepicture.c
--- trunk/reactos/lib/oleaut32/olepicture.c	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/olepicture.c	2005-02-13 21:03:37 UTC (rev 13533)
@@ -409,8 +409,11 @@
   IPicture* iface)
 {
   OLEPictureImpl *This = (OLEPictureImpl *)iface;
-  TRACE("(%p)->(ref=%ld)\n", This, This->ref);
-  return InterlockedIncrement(&This->ref);
+  ULONG refCount = InterlockedIncrement(&This->ref);
+
+  TRACE("(%p)->(ref before=%ld)\n", This, refCount - 1);
+
+  return refCount;
 }
 
 /************************************************************************
@@ -422,20 +425,16 @@
       IPicture* iface)
 {
   OLEPictureImpl *This = (OLEPictureImpl *)iface;
-  ULONG ret;
-  TRACE("(%p)->(ref=%ld)\n", This, This->ref);
+  ULONG refCount = InterlockedDecrement(&This->ref);
 
-  /*
-   * Decrease the reference count on this object.
-   */
-  ret = InterlockedDecrement(&This->ref);
+  TRACE("(%p)->(ref before=%ld)\n", This, refCount + 1);
 
   /*
    * If the reference count goes down to 0, perform suicide.
    */
-  if (ret==0) OLEPictureImpl_Destroy(This);
+  if (!refCount) OLEPictureImpl_Destroy(This);
 
-  return ret;
+  return refCount;
 }
 
 

Modified: trunk/reactos/lib/oleaut32/regsvr.c
--- trunk/reactos/lib/oleaut32/regsvr.c	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/regsvr.c	2005-02-13 21:03:37 UTC (rev 13533)
@@ -545,7 +545,358 @@
  *		interface list
  */
 
+/* FIXME: these interfaces should be defined in ocidl.idl */
+
+static IID const IID_IFontEventsDisp = {
+    0x4EF6100A, 0xAF88, 0x11D0, {0x98,0x46,0x00,0xC0,0x4F,0xC2,0x99,0x93} };
+
+static IID const IID_IProvideMultipleClassInfo = {
+    0xA7ABA9C1, 0x8983, 0x11CF, {0x8F,0x20,0x00,0x80,0x5F,0x2C,0xD0,0x64} };
+
 static struct regsvr_interface const interface_list[] = {
+    {   &IID_IDispatch,
+	"IDispatch",
+	NULL,
+	7,
+	&CLSID_PSDispatch,
+	&CLSID_PSDispatch
+    },
+    {   &IID_ITypeInfo,
+	"ITypeInfo",
+	NULL,
+	22,
+	NULL,
+	&CLSID_PSTypeInfo
+    },
+    {   &IID_ITypeLib,
+	"ITypeLib",
+	NULL,
+	13,
+	NULL,
+	&CLSID_PSTypeLib
+    },
+    {   &IID_ITypeComp,
+	"ITypeComp",
+	NULL,
+	5,
+	NULL,
+	&CLSID_PSTypeComp
+    },
+    {   &IID_IEnumVARIANT,
+	"IEnumVARIANT",
+	NULL,
+	15,
+	NULL,
+	&CLSID_PSEnumVariant
+    },
+    {   &IID_ICreateTypeInfo,
+	"ICreateTypeInfo",
+	NULL,
+	26,
+	NULL,
+	NULL
+    },
+    {   &IID_ICreateTypeLib,
+	"ICreateTypeLib",
+	NULL,
+	13,
+	NULL,
+	NULL
+    },
+    {   &IID_ITypeInfo2,
+	"ITypeInfo2",
+	NULL,
+	32,
+	NULL,
+	&CLSID_PSDispatch
+    },
+    {   &IID_ITypeLib2,
+	"ITypeLib2",
+	NULL,
+	16,
+	NULL,
+	&CLSID_PSDispatch
+    },
+    {   &IID_IPropertyPage2,
+	"IPropertyPage2",
+	NULL,
+	15,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IErrorInfo,
+	"IErrorInfo",
+	NULL,
+	8,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_ICreateErrorInfo,
+	"ICreateErrorInfo",
+	NULL,
+	8,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPersistPropertyBag2,
+	"IPersistPropertyBag2",
+	NULL,
+	8,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPropertyBag2,
+	"IPropertyBag2",
+	NULL,
+	8,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IErrorLog,
+	"IErrorLog",
+	NULL,
+	4,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPerPropertyBrowsing,
+	"IPerPropertyBrowsing",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPersistPropertyBag,
+	"IPersistPropertyBag",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IAdviseSinkEx,
+	"IAdviseSinkEx",
+	NULL,
+	9,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IFontEventsDisp,
+	"IFontEventsDisp",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPropertyBag,
+	"IPropertyBag",
+	NULL,
+	5,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPointerInactive,
+	"IPointerInactive",
+	NULL,
+	6,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_ISimpleFrameSite,
+	"ISimpleFrameSite",
+	NULL,
+	5,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPicture,
+	"IPicture",
+	NULL,
+	17,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPictureDisp,
+	"IPictureDisp",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPersistStreamInit,
+	"IPersistStreamInit",
+	NULL,
+	9,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IOleUndoUnit,
+	"IOleUndoUnit",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPropertyNotifySink,
+	"IPropertyNotifySink",
+	NULL,
+	5,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IOleInPlaceSiteEx,
+	"IOleInPlaceSiteEx",
+	NULL,
+	18,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IOleParentUndoUnit,
+	"IOleParentUndoUnit",
+	NULL,
+	12,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IProvideClassInfo2,
+	"IProvideClassInfo2",
+	NULL,
+	5,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IProvideMultipleClassInfo,
+	"IProvideMultipleClassInfo",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IProvideClassInfo,
+	"IProvideClassInfo",
+	NULL,
+	4,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IConnectionPointContainer,
+	"IConnectionPointContainer",
+	NULL,
+	5,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IEnumConnectionPoints,
+	"IEnumConnectionPoints",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IConnectionPoint,
+	"IConnectionPoint",
+	NULL,
+	8,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IEnumConnections,
+	"IEnumConnections",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IOleControl,
+	"IOleControl",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IOleControlSite,
+	"IOleControlSite",
+	NULL,
+	10,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_ISpecifyPropertyPages,
+	"ISpecifyPropertyPages",
+	NULL,
+	4,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPropertyPageSite,
+	"IPropertyPageSite",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPropertyPage,
+	"IPropertyPage",
+	NULL,
+	14,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IClassFactory2,
+	"IClassFactory2",
+	NULL,
+	8,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IEnumOleUndoUnits,
+	"IEnumOleUndoUnits",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IPersistMemory,
+	"IPersistMemory",
+	NULL,
+	9,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IFont,
+	"IFont",
+	NULL,
+	27,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IFontDisp,
+	"IFontDisp",
+	NULL,
+	7,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IQuickActivate,
+	"IQuickActivate",
+	NULL,
+	6,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IOleUndoManager,
+	"IOleUndoManager",
+	NULL,
+	15,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
+    {   &IID_IObjectWithSite,
+	"IObjectWithSite",
+	NULL,
+	5,
+	NULL,
+	&CLSID_PSFactoryBuffer
+    },
     { NULL }			/* list terminator */
 };
 

Modified: trunk/reactos/lib/oleaut32/safearray.c
--- trunk/reactos/lib/oleaut32/safearray.c	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/safearray.c	2005-02-13 21:03:37 UTC (rev 13533)
@@ -1337,7 +1337,7 @@
   TRACE("(%p)\n", psa);
 
   if(!psa)
-    return E_INVALIDARG;
+    return S_OK;
 
   if(psa->cLocks > 0)
     return DISP_E_ARRAYISLOCKED;

Modified: trunk/reactos/lib/oleaut32/tmarshal.c
--- trunk/reactos/lib/oleaut32/tmarshal.c	2005-02-13 20:52:16 UTC (rev 13532)
+++ trunk/reactos/lib/oleaut32/tmarshal.c	2005-02-13 21:03:37 UTC (rev 13533)
@@ -116,34 +116,50 @@
     DWORD		xsize;
 
     TRACE("...%s...\n",debugstr_guid(riid));
+    
     *pUnk = NULL;
     hres = xbuf_get(buf,(LPBYTE)&xsize,sizeof(xsize));
-    if (hres) return hres;
+    if (hres) {
+        ERR("xbuf_get failed\n");
+        return hres;
+    }
+    
     if (xsize == 0) return S_OK;
+    
     hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
     if (hres) {
-	FIXME("Stream create failed %lx\n",hres);
+	ERR("Stream create failed %lx\n",hres);
 	return hres;
     }
+    
     hres = IStream_Write(pStm,buf->base+buf->curoff,xsize,&res);
-    if (hres) { FIXME("stream write %lx\n",hres); return hres; }
+    if (hres) {
+        ERR("stream write %lx\n",hres);
+        return hres;
+    }
+    
     memset(&seekto,0,sizeof(seekto));
     hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
-    if (hres) { FIXME("Failed Seek %lx\n",hres); return hres;}
+    if (hres) {
+        ERR("Failed Seek %lx\n",hres);
+        return hres;
+    }
+    
     hres = CoUnmarshalInterface(pStm,riid,(LPVOID*)pUnk);
     if (hres) {
-	FIXME("Marshalling interface %s failed with %lx\n",debugstr_guid(riid),hres);
+	ERR("Unmarshalling interface %s failed with %lx\n",debugstr_guid(riid),hres);
 	return hres;
     }
+    
     IStream_Release(pStm);
     return xbuf_skip(buf,xsize);
 }
 
 static HRESULT
 _marshal_interface(marshal_state *buf, REFIID riid, LPUNKNOWN pUnk) {
-    LPUNKNOWN		newiface;
-    LPBYTE		tempbuf;
-    IStream		*pStm;
+    LPUNKNOWN		newiface = NULL;
+    LPBYTE		tempbuf = NULL;
+    IStream		*pStm = NULL;
     STATSTG		ststg;
     ULARGE_INTEGER	newpos;
     LARGE_INTEGER	seekto;
@@ -151,45 +167,67 @@
     DWORD		xsize;
     HRESULT		hres;
 
-    hres = S_OK;
-    if (!pUnk)
+    hres = E_FAIL;
+    if (!pUnk) {
+        ERR("pUnk is NULL?\n");
 	goto fail;
+    }
 
     TRACE("...%s...\n",debugstr_guid(riid));
-    hres=IUnknown_QueryInterface(pUnk,riid,(LPVOID*)&newiface);
+    hres = IUnknown_QueryInterface(pUnk,riid,(LPVOID*)&newiface);
     if (hres) {
-	TRACE("%p does not support iface %s\n",pUnk,debugstr_guid(riid));
+	WARN("%p does not support iface %s\n",pUnk,debugstr_guid(riid));
 	goto fail;
     }
+    
     hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
     if (hres) {
-	FIXME("Stream create failed %lx\n",hres);
+	ERR("Stream create failed %lx\n",hres);
 	goto fail;
     }
+    
     hres = CoMarshalInterface(pStm,riid,newiface,0,NULL,0);
-    IUnknown_Release(newiface);
     if (hres) {
-	FIXME("Marshalling interface %s failed with %lx\n",
-		debugstr_guid(riid),hres
-	);
+	ERR("Marshalling interface %s failed with %lx\n", debugstr_guid(riid), hres);
 	goto fail;
     }
+    
     hres = IStream_Stat(pStm,&ststg,0);
+    if (hres) {
+        ERR("Stream stat failed\n");
+        goto fail;
+    }
+    
     tempbuf = HeapAlloc(GetProcessHeap(), 0, ststg.cbSize.u.LowPart);
     memset(&seekto,0,sizeof(seekto));
     hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
-    if (hres) { FIXME("Failed Seek %lx\n",hres); goto fail;}
+    if (hres) {
+        ERR("Failed Seek %lx\n",hres);
+        goto fail;
+    }
+    
     hres = IStream_Read(pStm,tempbuf,ststg.cbSize.u.LowPart,&res);
-    if (hres) { FIXME("Failed Read %lx\n",hres); goto fail;}
-    IStream_Release(pStm);
+    if (hres) {
+        ERR("Failed Read %lx\n",hres);
+        goto fail;
+    }
+    
     xsize = ststg.cbSize.u.LowPart;
     xbuf_add(buf,(LPBYTE)&xsize,sizeof(xsize));
     hres = xbuf_add(buf,tempbuf,ststg.cbSize.u.LowPart);
+    
     HeapFree(GetProcessHeap(),0,tempbuf);
+    IUnknown_Release(newiface);
+    IStream_Release(pStm);
+    
     return hres;
+    
 fail:
     xsize = 0;
     xbuf_add(buf,(LPBYTE)&xsize,sizeof(xsize));
+    if (pStm) IUnknown_Release(pStm);
+    if (newiface) IUnknown_Release(newiface);
+    HeapFree(GetProcessHeap(), 0, tempbuf);
     return hres;
 }
 
@@ -225,20 +263,20 @@
     );
 
     if (RegOpenKeyA(HKEY_CLASSES_ROOT,interfacekey,&ikey)) {
-	FIXME("No %s key found.\n",interfacekey);
+	ERR("No %s key found.\n",interfacekey);
        	return E_FAIL;
     }
     type = (1<<REG_SZ);
     tlguidlen = sizeof(tlguid);
     if (RegQueryValueExA(ikey,NULL,NULL,&type,tlguid,&tlguidlen)) {
-	FIXME("Getting typelib guid failed.\n");
+	ERR("Getting typelib guid failed.\n");
 	RegCloseKey(ikey);
 	return E_FAIL;
     }
     type = (1<<REG_SZ);
     verlen = sizeof(ver);
     if (RegQueryValueExA(ikey,"Version",NULL,&type,ver,&verlen)) {
-	FIXME("Could not get version value?\n");
+	ERR("Could not get version value?\n");
 	RegCloseKey(ikey);
 	return E_FAIL;
     }
@@ -246,7 +284,7 @@
     sprintf(typelibkey,"Typelib\\%s\\%s\\0\\win32",tlguid,ver);
     tlfnlen = sizeof(tlfn);
     if (RegQueryValueA(HKEY_CLASSES_ROOT,typelibkey,tlfn,&tlfnlen)) {
-	FIXME("Could not get typelib fn?\n");
+	ERR("Could not get typelib fn?\n");
 	return E_FAIL;
     }
     MultiByteToWideChar(CP_ACP, 0, tlfn, -1, tlfnW, -1);
@@ -336,29 +374,29 @@
 TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface)
 {
     ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
+    ULONG refCount = InterlockedIncrement(&This->ref);
 
-    TRACE("()\n");
+    TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
 
-    return InterlockedIncrement(&This->ref);
+    return refCount;
 }
 
 static ULONG WINAPI
 TMProxyImpl_Release(LPRPCPROXYBUFFER iface)
 {
-    ULONG refs;
     ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
+    ULONG refCount = InterlockedDecrement(&This->ref);
 
-    TRACE("()\n");
+    TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
 
-    refs = InterlockedDecrement(&This->ref);
-    if (!refs)
+    if (!refCount)
     {
         DeleteCriticalSection(&This->crit);
         if (This->chanbuf) IRpcChannelBuffer_Release(This->chanbuf);
         VirtualFree(This->asmstubs, 0, MEM_RELEASE);
         CoTaskMemFree(This);
     }
-    return refs;
+    return refCount;
 }
 
 static HRESULT WINAPI
@@ -551,7 +589,7 @@
 
 	hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
 	if (hres) {
-	    FIXME("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc->u.hreftype);
+	    ERR("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc->u.hreftype);
 	    return hres;
 	}
 	ITypeInfo_GetTypeAttr(tinfo2,&tattr);
@@ -571,7 +609,7 @@
 
 		hres = ITypeInfo2_GetVarDesc(tinfo2, i, &vdesc);
 		if (hres) {
-		    FIXME("Could not get vardesc of %d\n",i);
+		    ERR("Could not get vardesc of %d\n",i);
 		    return hres;
 		}
 		/* Need them for hack below */
@@ -816,7 +854,7 @@
 	case VT_UI1:
 	    if (readit) {
 		hres = xbuf_get(buf,(LPBYTE)arg,sizeof(DWORD));
-		if (hres) FIXME("Failed to read integer 4 byte\n");
+		if (hres) ERR("Failed to read integer 4 byte\n");
 	    }
 	    if (debugout) TRACE_(olerelay)("%lx",*arg);
 	    return hres;
@@ -827,7 +865,7 @@
 	    if (readit) {
 		hres = xbuf_get(buf,(LPBYTE)&len,sizeof(DWORD));
 		if (hres) {
-		    FIXME("failed to read bstr klen\n");
+		    ERR("failed to read bstr klen\n");
 		    return hres;
 		}
 		if (len == -1) {
@@ -837,7 +875,7 @@
 		    str  = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,len+sizeof(WCHAR));
 		    hres = xbuf_get(buf,(LPBYTE)str,len);
 		    if (hres) {
-			FIXME("Failed to read BSTR.\n");
+			ERR("Failed to read BSTR.\n");
 			return hres;
 		    }
 		    *arg = (DWORD)SysAllocStringLen(str,len);
@@ -858,7 +896,7 @@
 	    if (readit) {
 		hres = xbuf_get(buf,(LPBYTE)&cookie,sizeof(cookie));
 		if (hres) {
-		    FIXME("Failed to load pointer cookie.\n");
+		    ERR("Failed to load pointer cookie.\n");
 		    return hres;
 		}
 		if (cookie != 0x42424242) {
@@ -903,12 +941,12 @@
 
 	    hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
 	    if (hres) {
-		FIXME("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc->u.hreftype);
+		ERR("Could not get typeinfo of hreftype %lx for VT_USERDEFINED.\n",tdesc->u.hreftype);
 		return hres;
 	    }
 	    hres = ITypeInfo_GetTypeAttr(tinfo2,&tattr);
 	    if (hres) {
-		FIXME("Could not get typeattr in VT_USERDEFINED.\n");
+		ERR("Could not get typeattr in VT_USERDEFINED.\n");
 	    } else {
 		if (alloc)
 		    *arg = (DWORD)HeapAlloc(GetProcessHeap(),0,tattr->cbSizeInstance);
@@ -927,7 +965,7 @@
 
 			hres = ITypeInfo2_GetVarDesc(tinfo2, i, &vdesc);
 			if (hres) {
-			    FIXME("Could not get vardesc of %d\n",i);
+			    ERR("Could not get vardesc of %d\n",i);
 			    return hres;
 			}
 			hres = deserialize_param(
@@ -953,7 +991,7 @@
 		}
 	    }
 	    if (hres)
-		FIXME("failed to stuballoc in TKIND_RECORD.\n");
+		ERR("failed to stuballoc in TKIND_RECORD.\n");
 	    ITypeInfo_Release(tinfo2);
 	    return hres;
 	}
@@ -1126,26 +1164,26 @@
 
 	    hres = ITypeInfo_GetTypeAttr(tinfo, &attr);
 	    if (hres) {
-		FIXME("GetTypeAttr failed with %lx\n",hres);
+		ERR("GetTypeAttr failed with %lx\n",hres);
 		return hres;
 	    }
 	    /* Not found, so look in inherited ifaces. */
 	    for (j=0;j<attr->cImplTypes;j++) {
 		hres = ITypeInfo_GetRefTypeOfImplType(tinfo, j, &href);
 		if (hres) {
-		    FIXME("Did not find a reftype for interface offset %d?\n",j);
+		    ERR("Did not find a reftype for interface offset %d?\n",j);
 		    break;
 		}
 		hres = ITypeInfo_GetRefTypeInfo(tinfo, href, &tinfo2);
 		if (hres) {
-		    FIXME("Did not find a typeinfo for reftype %ld?\n",href);
+		    ERR("Did not find a typeinfo for reftype %ld?\n",href);
 		    continue;
 		}
 		hres = _get_funcdesc(tinfo2,iMethod,fdesc,iname,fname);
 		ITypeInfo_Release(tinfo2);
 		if (!hres) return S_OK;
 	    }
-	    return E_FAIL;
+	    return hres;
 	}
 	if (((*fdesc)->oVft/4) == iMethod) {
 	    if (fname)
@@ -1273,7 +1311,7 @@
 		);
 
 	    if (hres) {
-		FIXME("Failed to serialize param, hres %lx\n",hres);
+		ERR("Failed to serialize param, hres %lx\n",hres);
 		break;
 	    }
 	    xargs+=_argsize(elem->tdesc.vt);
@@ -1285,7 +1323,7 @@
     msg.iMethod  = method;
     hres = IRpcChannelBuffer_GetBuffer(tpinfo->chanbuf,&msg,&(tpinfo->iid));
     if (hres) {
-	FIXME("RpcChannelBuffer GetBuffer failed, %lx\n",hres);
+	ERR("RpcChannelBuffer GetBuffer failed, %lx\n",hres);
         LeaveCriticalSection(&tpinfo->crit);
 	return hres;
     }
@@ -1293,7 +1331,7 @@
     if (relaydeb) TRACE_(olerelay)("\n");
     hres = IRpcChannelBuffer_SendReceive(tpinfo->chanbuf,&msg,&status);
     if (hres) {
-	FIXME("RpcChannelBuffer SendReceive failed, %lx\n",hres);
+	ERR("RpcChannelBuffer SendReceive failed, %lx\n",hres);
         LeaveCriticalSection(&tpinfo->crit);
 	return hres;
     }
@@ -1343,7 +1381,7 @@
 			&buf
 		    );
 		    if (hres) {
-			FIXME("Failed to deserialize DISPPARAM*, hres %lx\n",hres);
+			ERR("Failed to deserialize DISPPARAM*, hres %lx\n",hres);
 			break;
 		    }
 		    isdeserialized = TRUE;
@@ -1373,7 +1411,8 @@
 		    &buf
 		);
 	    if (hres) {
-		FIXME("Failed to unmarshall param, hres %lx\n",hres);
+		ERR("Failed to unmarshall param, hres %lx\n",hres);
+		status = hres;
 		break;
 	    }
 	    xargs += _argsize(elem->tdesc.vt);
@@ -1401,7 +1440,7 @@
     TRACE("(...%s...)\n",debugstr_guid(riid));
     hres = _get_typeinfo_for_iid(riid,&tinfo);
     if (hres) {
-	FIXME("No typeinfo for %s?\n",debugstr_guid(riid));
+	ERR("No typeinfo for %s?\n",debugstr_guid(riid));
 	return hres;
[truncated at 1000 lines; 236 more skipped]