Index: trunk/src/ole32/antimoniker.cpp
===================================================================
--- trunk/src/ole32/antimoniker.cpp	(revision 4257)
+++ trunk/src/ole32/antimoniker.cpp	(revision 4258)
@@ -1,12 +1,14 @@
-/* $Id: antimoniker.cpp,v 1.2 1999-09-24 21:49:42 davidr Exp $ */
+/* $Id: antimoniker.cpp,v 1.3 2000-09-14 14:57:00 davidr Exp $ */
 /* 
  * AntiMonikers functions.
  * 
- * 20/9/99
- * 
- * Copyright 1999 David J. Raison
+ * Copyright 1999, 2000 David J. Raison
  * 
  * Direct port of Wine Implementation
  *   Copyright 1999  Noomen Hamza
+ *
+ * Updates.
+ *   14/09/2000 Updated from CorelWine
+ * 
  */
 
@@ -14,5 +16,5 @@
 #include "debugtools.h"
 
-DEFAULT_DEBUG_CHANNEL(ole)
+DEFAULT_DEBUG_CHANNEL(moniker)
 
 /* AntiMoniker data structure */
@@ -196,5 +198,5 @@
 HRESULT WINAPI AntiMonikerImpl_GetClassID(IMoniker* iface,CLSID *pClassID)
 {
-    TRACE("(%p,%p),stub!\n",iface,pClassID);
+    TRACE("(iface:%p ClassID:%p [CLSID_AntiMoniker])\n",iface,pClassID);
 
     if (pClassID==NULL)
@@ -252,4 +254,18 @@
 
 /******************************************************************************
+ *        AntiMonikerImpl_GetSizeToSave
+ ******************************************************************************/
+HRESULT AntiMonikerImpl_GetSizeToSave(IMoniker* iface,ULARGE_INTEGER* pcbSize)
+{
+    if (pcbSize==NULL)
+        return E_POINTER;
+
+    pcbSize->LowPart =  sizeof(DWORD);
+    pcbSize->HighPart = 0;
+
+    return S_OK;
+}
+
+/******************************************************************************
  *        AntiMoniker_GetSizeMax
  ******************************************************************************/
@@ -259,17 +275,15 @@
     TRACE("(%p,%p)\n",iface,pcbSize);
 
-    if (pcbSize!=NULL)
-        return E_POINTER;
-
-    /* for more details see AntiMonikerImpl_Save coments */
-    
-    /* Normaly the sizemax must be the  size of DWORD ! but I tested this function it ususlly return 16 bytes */
-    /* more than the number of bytes used by AntiMoniker::Save function */
-    pcbSize->LowPart =  sizeof(DWORD)+16;
-
-    pcbSize->HighPart=0;
-
-    return S_OK;
-}
+    if (pcbSize == NULL)
+        return E_POINTER;
+
+    /* GetSizeMax = SizeToSave + 16 */
+    AntiMonikerImpl_GetSizeToSave(iface,pcbSize);
+    pcbSize->LowPart += 16;	//FIXME - 64bit math
+//    pcbSize->HighPart = 0;
+
+    return S_OK;
+}
+
 
 /******************************************************************************
@@ -434,5 +448,5 @@
 
     if (FAILED(res))
-    return res;
+	return res;
 
     res = IRunningObjectTable_IsRunning(rot,iface);
Index: trunk/src/ole32/bindctx.cpp
===================================================================
--- trunk/src/ole32/bindctx.cpp	(revision 4257)
+++ trunk/src/ole32/bindctx.cpp	(revision 4258)
@@ -1,3 +1,3 @@
-/* $Id: bindctx.cpp,v 1.3 2000-05-05 18:21:36 sandervl Exp $ */
+/* $Id: bindctx.cpp,v 1.4 2000-09-14 14:57:00 davidr Exp $ */
 /* 
  * BindCtx implementation
@@ -300,4 +300,6 @@
 HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
 {
+    DWORD size = sizeof(BIND_OPTS2);
+
     ICOM_THIS(BindCtxImpl,iface);
 
@@ -306,11 +308,10 @@
     if (pbindopts==NULL)
         return E_POINTER;
-    
-    if (pbindopts->cbStruct > sizeof(BIND_OPTS2))
-    {
-        WARN("invalid size");
-        return E_INVALIDARG; /* FIXME : not verified */
-    }
-    memcpy(&This->bindOption2, pbindopts, pbindopts->cbStruct);
+
+    /* make sure we don't copy more bytes than we can */
+    if (pbindopts->cbStruct < size)
+	size = pbindopts->cbStruct;
+    
+    memcpy(&This->bindOption2, pbindopts, size);
 
     return S_OK;
@@ -322,4 +323,6 @@
 HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
 {
+    DWORD size = sizeof(BIND_OPTS2);
+
     ICOM_THIS(BindCtxImpl,iface);
 
@@ -329,10 +332,9 @@
         return E_POINTER;
 
-    if (pbindopts->cbStruct > sizeof(BIND_OPTS2))
-    {
-        WARN("invalid size");
-        return E_INVALIDARG; /* FIXME : not verified */
-    }
-    memcpy(pbindopts, &This->bindOption2, pbindopts->cbStruct);
+    /* make sure we don't copy more bytes than we can */
+    if (pbindopts->cbStruct < size)
+	size = pbindopts->cbStruct;
+
+    memcpy(pbindopts, &This->bindOption2, size);
     
     return S_OK;
Index: trunk/src/ole32/compositemoniker.cpp
===================================================================
--- trunk/src/ole32/compositemoniker.cpp	(revision 4257)
+++ trunk/src/ole32/compositemoniker.cpp	(revision 4258)
@@ -1,3 +1,3 @@
-/* $Id: compositemoniker.cpp,v 1.1 1999-09-24 21:49:42 davidr Exp $ */
+/* $Id: compositemoniker.cpp,v 1.2 2000-09-14 14:57:01 davidr Exp $ */
 /* 
  * CompositeMonikers functions.
@@ -14,5 +14,5 @@
 #include "debugtools.h"
 
-DEFAULT_DEBUG_CHANNEL(ole)
+DEFAULT_DEBUG_CHANNEL(moniker)
 
 #define  BLOCK_TAB_SIZE 5 /* represent the first size table and it's increment block size */
@@ -42,5 +42,5 @@
 typedef struct EnumMonikerImpl{
 
-    ICOM_VTABLE(IEnumMoniker)*  lpvtbl;  /* VTable relative to the IEnumMoniker interface.*/
+    ICOM_VFIELD(IEnumMoniker);  /* VTable relative to the IEnumMoniker interface.*/
 
     ULONG ref; /* reference counter for this object */
@@ -285,8 +285,8 @@
 HRESULT WINAPI CompositeMonikerImpl_Load(IMoniker* iface,IStream* pStm)
 {
-    HRESULT res;
-    DWORD constant;
-    CLSID clsid;
-    WCHAR string[1]={0};
+    HRESULT	res;
+    CLSID	clsid;
+    WCHAR	string[1]={0};
+    ULONG	countMoniker;
     
     ICOM_THIS(CompositeMonikerImpl,iface);    
@@ -296,60 +296,51 @@
     /* this function call OleLoadFromStream function for each moniker within this object */
 
-    /* read the a constant writen by CompositeMonikerImpl_Save (see CompositeMonikerImpl_Save for more details)*/
-    res=IStream_Read(pStm,&constant,sizeof(DWORD),NULL);
-
-    if (SUCCEEDED(res)&& constant!=3)
-        return E_FAIL;
-
-    while(1){
+    /* read the number of monikers within the composite moniker*/
+    res=IStream_Read(pStm,&countMoniker,sizeof(countMoniker),NULL);
+
+    for(This->tabLastIndex=0; This->tabLastIndex < countMoniker; This->tabLastIndex++)
+    {
 #if 0
         res=OleLoadFromStream(pStm,&IID_IMoniker,(void**)&This->tabMoniker[This->tabLastIndex]);
 #endif
         res=ReadClassStm(pStm,&clsid);
-        printf("res=%ld",res);
+
         if (FAILED(res))
-            break;
-
-        if (IsEqualIID(&clsid,&CLSID_FileMoniker)){
+            return res;
+
+        if (IsEqualIID(&clsid,&CLSID_FileMoniker))
+        {
             res=CreateFileMoniker(string,&This->tabMoniker[This->tabLastIndex]);
             if (FAILED(res))
-                break;
-            res=IMoniker_Load(This->tabMoniker[This->tabLastIndex],pStm);
+                return res;
+        }
+        else if (IsEqualIID(&clsid,&CLSID_ItemMoniker))
+        {
+            CreateItemMoniker(string,string,&This->tabMoniker[This->tabLastIndex]);
             if (FAILED(res))
-                break;
-        }
-        else if (IsEqualIID(&clsid,&CLSID_ItemMoniker)){
-            CreateItemMoniker(string,string,&This->tabMoniker[This->tabLastIndex]);
-            if (res!=S_OK)
-                break;
-            IMoniker_Load(This->tabMoniker[This->tabLastIndex],pStm);
-            if (FAILED(res))
-                break;
-        }
-        else if (IsEqualIID(&clsid,&CLSID_AntiMoniker)){
+                return res;
+        }
+        else if (IsEqualIID(&clsid,&CLSID_AntiMoniker))
+        {
             CreateAntiMoniker(&This->tabMoniker[This->tabLastIndex]);
             if (FAILED(res))
-                break;
-            IMoniker_Load(This->tabMoniker[This->tabLastIndex],pStm);
-            if (FAILED(res))
-                break;
-        }
-        else if (IsEqualIID(&clsid,&CLSID_CompositeMoniker))
+                return res;
+        }
+        else
             return E_FAIL;
 
-        else{
-            FIXME("()");
-            break;
-            return E_NOTIMPL;
-        }
+	res=IMoniker_Load(This->tabMoniker[This->tabLastIndex],pStm);
+	if (FAILED(res))
+	    return res;
 
         /* resize the table if needed */
-        if (++This->tabLastIndex==This->tabSize){
+        if (This->tabLastIndex==This->tabSize){
                 
             This->tabSize+=BLOCK_TAB_SIZE;
-            This->tabMoniker=(IMoniker**)HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
+            This->tabMoniker=(IMoniker**)HeapReAlloc(
+		GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
 
             if (This->tabMoniker==NULL)
-            return E_OUTOFMEMORY;
+		return E_OUTOFMEMORY;
         }
     }
@@ -366,5 +357,6 @@
     IEnumMoniker *enumMk;
     IMoniker *pmk;
-    DWORD constant=3;
+
+    ICOM_THIS(CompositeMonikerImpl,iface);
     
     TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
@@ -372,7 +364,6 @@
     /* this function call OleSaveToStream function for each moniker within this object */
 
-    /* when I tested this function in windows system ! I usually found this constant in the begining of */
-    /* the stream  I dont known why (there's no indication in specification) ! */
-    res=IStream_Write(pStm,&constant,sizeof(constant),NULL);
+    /* write the number of monikers within the composite moniker*/
+    res=IStream_Write(pStm,&(This->tabLastIndex),sizeof(This->tabLastIndex),NULL);
 
     IMoniker_Enum(iface,TRUE,&enumMk);
@@ -410,8 +401,8 @@
     TRACE("(%p,%p)\n",iface,pcbSize);
 
-    if (pcbSize!=NULL)
+    if (pcbSize==NULL)
         return E_POINTER;
 
-    pcbSize->LowPart =0;
+    pcbSize->LowPart =sizeof(DWORD) + 48;
     pcbSize->HighPart=0;
 
@@ -424,5 +415,5 @@
         IMoniker_Release(pmk);
 
-        pcbSize->LowPart +=ptmpSize.LowPart;
+        pcbSize->LowPart +=ptmpSize.LowPart;	// FIXME - 64bit Math
         pcbSize->HighPart+=ptmpSize.HighPart;
     }
@@ -432,4 +423,38 @@
     return S_OK;
 }
+
+#if 0
+/******************************************************************************
+ *         CompositeMonikerImpl_GetSizeToSave (Local)
+ *******************************************************************************/
+HRESULT CompositeMonikerImpl_GetSizeToSave(IMoniker* iface,ULARGE_INTEGER* pcbSize)
+{
+    IEnumMoniker *enumMk;
+    IMoniker *pmk;
+    HRESULT hRes;
+    ULARGE_INTEGER ptmpSize;
+
+    if (pcbSize==NULL)
+        return E_POINTER;
+
+    pcbSize->LowPart = sizeof(DWORD);
+    pcbSize->HighPart=0;
+
+    IMoniker_Enum(iface,TRUE,&enumMk);
+
+    while((hRes = IEnumMoniker_Next(enumMk,1,&pmk,NULL))==S_OK){
+
+        GetSizeToSaveMoniker(pmk,&ptmpSize);
+        IMoniker_Release(pmk);
+
+        pcbSize->LowPart +=ptmpSize.LowPart;	// FIXME - 64bit math
+        pcbSize->HighPart+=ptmpSize.HighPart;
+    }
+    IEnumMoniker_Release(enumMk);
+
+    return S_OK;
+}
+#endif
+
 
 /******************************************************************************
@@ -1509,7 +1534,6 @@
 {
     ICOM_THIS(EnumMonikerImpl,iface);
-    ULONG i
-        ;
-    TRACE("(%p)\n",This);
+
+    ULONG i;
 
     This->ref--;
@@ -1610,11 +1634,11 @@
     
     /* Initialize the virtual function table. */
-    newEnumMoniker->lpvtbl      = &VT_EnumMonikerImpl;
-    newEnumMoniker->ref          = 0;
-
-    newEnumMoniker->tabSize=tabSize;
-    newEnumMoniker->currentPos=currentPos;
-
-    newEnumMoniker->tabMoniker=(IMoniker**)HeapAlloc(GetProcessHeap(),0,tabSize*sizeof(IMoniker));
+    ICOM_VTBL(newEnumMoniker)  = &VT_EnumMonikerImpl;
+    newEnumMoniker->ref        = 0;
+
+    newEnumMoniker->tabSize    = tabSize;
+    newEnumMoniker->currentPos = currentPos;
+
+    newEnumMoniker->tabMoniker =(IMoniker**)HeapAlloc(GetProcessHeap(),0,tabSize*sizeof(IMoniker));
 
     if (newEnumMoniker->tabMoniker==NULL)
