- Sync ole32, oleaut32, olesvr32 with Wine head
authorDmitry Chapyshev <dmitry@reactos.org>
Fri, 13 Mar 2009 13:40:31 +0000 (13:40 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Fri, 13 Mar 2009 13:40:31 +0000 (13:40 +0000)
svn path=/trunk/; revision=40000

16 files changed:
reactos/dll/win32/ole32/compobj.c
reactos/dll/win32/ole32/compobj.spec [deleted file]
reactos/dll/win32/ole32/compobj_private.h
reactos/dll/win32/ole32/memlockbytes16.c [deleted file]
reactos/dll/win32/ole32/ole2.c
reactos/dll/win32/ole32/ole2.spec [deleted file]
reactos/dll/win32/ole32/ole2_16.c [deleted file]
reactos/dll/win32/ole32/ole2conv.spec [deleted file]
reactos/dll/win32/ole32/ole2nls.c [deleted file]
reactos/dll/win32/ole32/ole2nls.spec [deleted file]
reactos/dll/win32/ole32/ole2prox.spec [deleted file]
reactos/dll/win32/ole32/storage.c [deleted file]
reactos/dll/win32/ole32/storage.spec [deleted file]
reactos/dll/win32/oleaut32/hash.c
reactos/dll/win32/olesvr32/olesvr.spec [deleted file]
reactos/dll/win32/olesvr32/olesvr_main.c

index b8ddba8..3eb0182 100644 (file)
@@ -934,6 +934,7 @@ static HRESULT COMPOBJ_DllList_Add(LPCWSTR library_name, OpenDll **ret)
         }
         else
         {
+            HeapFree(GetProcessHeap(), 0, entry);
             hr = E_OUTOFMEMORY;
             FreeLibrary(hLibrary);
         }
@@ -998,7 +999,6 @@ static void COMPOBJ_DllList_Free(void)
 
 /******************************************************************************
  *           CoBuildVersion [OLE32.@]
- *           CoBuildVersion [COMPOBJ.1]
  *
  * Gets the build version of the DLL.
  *
@@ -1317,7 +1317,6 @@ HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
 
 /******************************************************************************
  *             CoCreateGuid [OLE32.@]
- *             CoCreateGuid [COMPOBJ.73]
  *
  * Simply forwards to UuidCreate in RPCRT4.
  *
@@ -1430,40 +1429,6 @@ HRESULT WINAPI CLSIDFromString(LPOLESTR idstr, CLSID *id )
     return ret;
 }
 
-/* Converts a GUID into the respective string representation. */
-HRESULT WINE_StringFromCLSID(
-       const CLSID *id,        /* [in] GUID to be converted */
-       LPSTR idstr             /* [out] pointer to buffer to contain converted guid */
-) {
-  static const char hex[] = "0123456789ABCDEF";
-  char *s;
-  int  i;
-
-  if (!id)
-       { ERR("called with id=Null\n");
-         *idstr = 0x00;
-         return E_FAIL;
-       }
-
-  sprintf(idstr, "{%08X-%04X-%04X-%02X%02X-",
-         id->Data1, id->Data2, id->Data3,
-         id->Data4[0], id->Data4[1]);
-  s = &idstr[25];
-
-  /* 6 hex bytes */
-  for (i = 2; i < 8; i++) {
-    *s++ = hex[id->Data4[i]>>4];
-    *s++ = hex[id->Data4[i] & 0xf];
-  }
-
-  *s++ = '}';
-  *s++ = '\0';
-
-  TRACE("%p->%s\n", id, idstr);
-
-  return S_OK;
-}
-
 
 /******************************************************************************
  *             StringFromCLSID [OLE32.@]
@@ -1485,25 +1450,17 @@ HRESULT WINE_StringFromCLSID(
  */
 HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
 {
-       char            buf[80];
-       HRESULT       ret;
-       LPMALLOC        mllc;
-
-       if ((ret = CoGetMalloc(0,&mllc)))
-               return ret;
+    HRESULT ret;
+    LPMALLOC mllc;
 
-       ret=WINE_StringFromCLSID(id,buf);
-       if (ret == S_OK) {
-            DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 );
-            *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) );
-            MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len );
-       }
-       return ret;
+    if ((ret = CoGetMalloc(0,&mllc))) return ret;
+    if (!(*idstr = IMalloc_Alloc( mllc, CHARS_IN_GUID * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
+    StringFromGUID2( id, *idstr, CHARS_IN_GUID );
+    return S_OK;
 }
 
 /******************************************************************************
  *             StringFromGUID2 [OLE32.@]
- *             StringFromGUID2 [COMPOBJ.76]
  *
  * Modified version of StringFromCLSID that allows you to specify max
  * buffer size.
@@ -1519,11 +1476,15 @@ HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
  */
 INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
 {
-  char         xguid[80];
-
-  if (WINE_StringFromCLSID(id,xguid))
-       return 0;
-  return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
+    static const WCHAR formatW[] = { '{','%','0','8','X','-','%','0','4','X','-',
+                                     '%','0','4','X','-','%','0','2','X','%','0','2','X','-',
+                                     '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',
+                                     '%','0','2','X','%','0','2','X','}',0 };
+    if (cmax < CHARS_IN_GUID) return 0;
+    sprintfW( str, formatW, id->Data1, id->Data2, id->Data3,
+              id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
+              id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
+    return CHARS_IN_GUID;
 }
 
 /* open HKCR\\CLSID\\{string form of clsid}\\{keyname} key */
@@ -2683,7 +2644,6 @@ void WINAPI CoFreeUnusedLibrariesEx(DWORD dwUnloadDelay, DWORD dwReserved)
 
 /***********************************************************************
  *           CoFreeUnusedLibraries [OLE32.@]
- *           CoFreeUnusedLibraries [COMPOBJ.17]
  *
  * Frees any unused libraries. Unused are identified as those that return
  * S_OK from their DllCanUnloadNow function.
@@ -2701,7 +2661,6 @@ void WINAPI CoFreeUnusedLibraries(void)
 
 /***********************************************************************
  *           CoFileTimeNow [OLE32.@]
- *           CoFileTimeNow [COMPOBJ.82]
  *
  * Retrieves the current time in FILETIME format.
  *
@@ -2979,7 +2938,6 @@ done:
 
 /******************************************************************************
  *             CoGetCurrentProcess     [OLE32.@]
- *             CoGetCurrentProcess     [COMPOBJ.34]
  *
  * Gets the current process ID.
  *
diff --git a/reactos/dll/win32/ole32/compobj.spec b/reactos/dll/win32/ole32/compobj.spec
deleted file mode 100644 (file)
index 3ac8568..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-1 pascal CoBuildVersion() CoBuildVersion
-2 pascal CoInitialize(long) CoInitialize16
-3 pascal CoUninitialize() CoUninitialize16
-4 pascal CoGetMalloc(long ptr) CoGetMalloc16
-5 pascal CoRegisterClassObject(ptr ptr long long ptr) CoRegisterClassObject16
-6 pascal CoRevokeClassObject(long) CoRevokeClassObject16
-7 pascal CoGetClassObject(ptr long ptr ptr ptr) CoGetClassObject16
-8 stub COMARSHALINTERFACE
-9 stub COUNMARSHALINTERFACE
-10 stub COLOADLIBRARY
-11 stub COFREELIBRARY
-12 stub COFREEALLLIBRARIES
-13 pascal CoCreateInstance(ptr ptr long ptr ptr) CoCreateInstance16
-14 stub STRINGFROMIID
-15 pascal CoDisconnectObject(ptr long) CoDisconnectObject16
-16 stub CORELEASEMARSHALDATA
-17 pascal -ret16 CoFreeUnusedLibraries() CoFreeUnusedLibraries
-18 pascal -ret16 IsEqualGUID(ptr ptr) IsEqualGUID16
-19 pascal StringFromCLSID(ptr ptr) StringFromCLSID16
-20 pascal CLSIDFromString(str ptr) CLSIDFromString16
-21 stub ISVALIDPTRIN
-22 stub ISVALIDPTROUT
-23 pascal IsValidInterface(segptr) IsValidInterface16
-24 stub ISVALIDIID
-25 stub RESULTFROMSCODE
-26 stub GETSCODE
-27 pascal CoRegisterMessageFilter(ptr ptr) CoRegisterMessageFilter16
-28 stub COISHANDLERCONNECTED
-29 stub SHRADDREF
-30 pascal -ret16 CoFileTimeToDosDateTime(ptr ptr ptr) CoFileTimeToDosDateTime16
-31 pascal -ret16 CoDosDateTimeToFileTime(word word ptr) CoDosDateTimeToFileTime16
-32 stub COMARSHALHRESULT
-33 stub COUNMARSHALHRESULT
-34 pascal CoGetCurrentProcess() CoGetCurrentProcess
-35 stub SHRCREATE
-36 stub COISOLE1CLASS
-37 stub _GUID_NULL
-38 stub _IID_IUNKNOWN
-39 stub _IID_ICLASSFACTORY
-40 stub _IID_IMALLOC
-41 stub _IID_IMARSHAL
-42 stub _IID_IRPCCHANNEL
-43 stub _IID_IRPCSTUB
-44 stub _IID_ISTUBMANAGER
-45 stub _IID_IRPCPROXY
-46 stub _IID_IPROXYMANAGER
-47 stub _IID_IPSFACTORY
-48 stub _IID_ILOCKBYTES
-49 stub _IID_ISTORAGE
-50 stub _IID_ISTREAM
-51 stub _IID_IENUMSTATSTG
-52 stub _IID_IBINDCTX
-53 stub _IID_IMONIKER
-54 stub _IID_IRUNNINGOBJECTTABLE
-55 stub _IID_IINTERNALMONIKER
-56 stub _IID_IROOTSTORAGE
-57 stub _IID_IDFRESERVED1
-58 stub _IID_IDFRESERVED2
-59 stub _IID_IDFRESERVED3
-60 stub _IID_IMESSAGEFILTER
-61 pascal CLSIDFromProgID(str ptr) CLSIDFromProgID16
-62 pascal ProgIDFromCLSID(ptr ptr) ProgIDFromCLSID16
-63 pascal CoLockObjectExternal(segptr word word) CoLockObjectExternal16
-64 stub _CLSID_STDMARSHAL
-65 stub COGETTREATASCLASS
-66 stub COTREATASCLASS
-67 stub COGETSTANDARDMARSHAL
-68 stub PROPAGATERESULT
-69 stub IIDFROMSTRING
-70 stub _IID_ISTDMARSHALINFO
-71 pascal CoCreateStandardMalloc(long ptr) CoCreateStandardMalloc16
-72 stub _IID_IEXTERNALCONNECTION
-73 pascal CoCreateGuid(ptr) CoCreateGuid
-75 stub FNASSERT
-76 pascal StringFromGUID2(ptr ptr word) StringFromGUID2
-77 stub COGETCLASSEXT
-78 stub OLE1CLASSFROMCLSID2
-79 stub CLSIDFROMOLE1CLASS
-80 stub COOPENCLASSKEY
-81 stub GUIDFROMSTRING
-82 pascal CoFileTimeNow(ptr) CoFileTimeNow
-83 stub REMALLOCOID
-84 stub REMFREEOID
-85 stub REMCREATEREMOTEHANDLER
-86 stub REMCONNECTTOOBJECT
-87 stub REMGETINFOFORCID
-88 stub LRPCCALL
-89 stub LRPCDISPATCH
-90 stub LRPCREGISTERMONITOR
-91 stub LRPCREVOKEMONITOR
-92 stub LRPCGETTHREADWINDOW
-93 stub TIMERCALLBACKPROC
-94 pascal LookupETask(ptr ptr) LookupETask16
-95 pascal -ret16 SetETask(word ptr) SetETask16
-96 stub LRPCFREEMONITORDATA
-97 stub REMLOOKUPSHUNK
-98 stub SHRGETSIZE
-99 stub CALLTHKMGRUNINITIALIZE
-100 stub ??0CARRAYFVALUE@@REC@KI@Z
-101 stub ??1CARRAYFVALUE@@REC@XZ
-102 stub ?ASSERTVALID@CARRAYFVALUE@@RFCXXZ
-103 stub ?FREEEXTRA@CARRAYFVALUE@@RECXXZ
-104 stub ?_GETAT@CARRAYFVALUE@@RFCPEXH@Z
-105 stub ?GETSIZE@CARRAYFVALUE@@RFCHXZ
-106 stub ?REMOVEALL@CARRAYFVALUE@@RECXXZ
-107 stub SHRDESTROY
-108 stub ?INDEXOF@CARRAYFVALUE@@RECHPEXII@Z
-109 stub ?INSERTAT@CARRAYFVALUE@@RECHHPEXH@Z
-110 stub COSETSTATE
-111 stub ?REMOVEAT@CARRAYFVALUE@@RECXHH@Z
-112 stub ?SETAT@CARRAYFVALUE@@RECXHPEX@Z
-113 stub ?SETATGROW@CARRAYFVALUE@@RECHHPEX@Z
-114 stub ?SETSIZE@CARRAYFVALUE@@RECHHH@Z
-115 pascal CoGetState(ptr) CoGetState16
-116 pascal DllEntryPoint(long word word word long word) COMPOBJ_DllEntryPoint
-117 stub ?RELEASE@CSTDMALLOC@@VEAKXZ
-118 stub ?ALLOC@CSTDMALLOC@@VEAPEXK@Z
-119 stub SHRRELEASE
-120 stub ?GETASSOCAT@CMAPKEYTOVALUE@@BFCPEUCASSOC@1@PEXIAEI@Z
-121 stub ?SETASSOCKEY@CMAPKEYTOVALUE@@BFCHPEUCASSOC@1@PEXI@Z
-122 stub ??1CMAPKEYTOVALUE@@REC@XZ
-123 stub ?GETASSOCKEYPTR@CMAPKEYTOVALUE@@BFCXPEUCASSOC@1@PEPEXPEI@Z
-124 stub ?NEWASSOC@CMAPKEYTOVALUE@@BECPEUCASSOC@1@IPEXI0@Z
-125 stub ?SIZEASSOC@CMAPKEYTOVALUE@@BFCIXZ
-126 stub ?FREEASSOC@CMAPKEYTOVALUE@@BECXPEUCASSOC@1@@Z
-127 stub ?GETSTARTPOSITION@CMAPKEYTOVALUE@@RFCPEXXZ
-128 stub ?GETNEXTASSOC@CMAPKEYTOVALUE@@RFCXPEPEXPEXPEI1@Z
-129 stub ?COMPAREASSOCKEY@CMAPKEYTOVALUE@@BFCHPEUCASSOC@1@PEXI@Z
-130 stub ?REMOVEHKEY@CMAPKEYTOVALUE@@RECHK@Z
-131 stub ?GETHKEY@CMAPKEYTOVALUE@@RFCKPEXI@Z
-132 stub ?GETCOUNT@CMAPKEYTOVALUE@@RFCHXZ
-133 stub ?LOOKUP@CMAPKEYTOVALUE@@RFCHPEXI0@Z
-134 stub ?GETASSOCVALUE@CMAPKEYTOVALUE@@BFCXPEUCASSOC@1@PEX@Z
-135 stub ?REMOVEKEY@CMAPKEYTOVALUE@@RECHPEXI@Z
-136 stub ?REMOVEALL@CMAPKEYTOVALUE@@RECXXZ
-137 stub SHRALLOC
-138 stub ?FREEASSOCKEY@CMAPKEYTOVALUE@@BFCXPEUCASSOC@1@@Z
-139 stub ?SETAT@CMAPKEYTOVALUE@@RECHPEXI0@Z
-140 stub ?LOOKUPHKEY@CMAPKEYTOVALUE@@RFCHKPEX@Z
-141 stub ?ASSERTVALID@CMAPKEYTOVALUE@@RFCXXZ
-142 stub ?SETASSOCVALUE@CMAPKEYTOVALUE@@BFCXPEUCASSOC@1@PEX@Z
-143 stub ?SETATHKEY@CMAPKEYTOVALUE@@RECHKPEX@Z
-144 stub ??0CMAPKEYTOVALUE@@REC@KIIHP7CIPEXI@ZI@Z
-145 stub ?INITHASHTABLE@CMAPKEYTOVALUE@@BECHXZ
-146 stub ?GETASSOCVALUEPTR@CMAPKEYTOVALUE@@BFCXPEUCASSOC@1@PEPEX@Z
-147 stub ?LOOKUPADD@CMAPKEYTOVALUE@@RFCHPEXI0@Z
-148 stub MKVDEFAULTHASHKEY
-149 stub DELETE16
-150 stub COMEMCTXOF
-151 pascal CoMemAlloc(long long long)
-152 stub COMEMFREE
-153 stub SHRREALLOC
-154 stub ___EXPORTEDSTUB
-155 stub LRPCREGISTERWIN32SMONITOR
-156 stub MYREMGETINFOFORCID
-157 stub SHRFREE
-158 stub OPNEW16
-159 stub ADDCOINFO
-160 stub CORUNMODALLOOP
-161 stub COHANDLEINCOMINGCALL
-162 stub COSETACKSTATE
-163 stub SHRDIDALLOC
-164 stub ?GETAT@CARRAYFVALUE@@RFCPEXH@Z
-165 stub ?GETUPPERBOUND@CARRAYFVALUE@@RFCHXZ
-166 stub OPDELETE16
-167 stub ?GETSIZEVALUE@CARRAYFVALUE@@RFCHXZ
-168 stub ?PROXY1632ADDREF@@ZAKPEVCPROXY1632@@@Z
-# FIXME: 169 is a duplicate of 97
-169 stub REMLOOKUPSHUNK_dup
-170 stub ?ISEMPTY@CMAPKEYTOVALUE@@RFCHXZ
-171 stub ?FREE@CSTDMALLOC@@VEAXPEX@Z
-172 stub CALLTHKMGRINITIALIZE
-173 stub ?REALLOC@CSTDMALLOC@@VEAPEXPEXK@Z
-174 stub ?SM16RHQI@@ZAPEXPEVCSM16RELEASEHANDLER@@AFUGUID@@PEPEX@Z
-175 stub ?PROXY1632METHOD10@@ZAKPEVCPROXY1632@@@Z
-# FIXME: 176 is a duplicate of 154
-176 stub ___EXPORTEDSTUB_dup
-177 stub ?PROXY1632METHOD20@@ZAKPEVCPROXY1632@@@Z
-178 stub ?PROXY1632METHOD11@@ZAKPEVCPROXY1632@@@Z
-179 stub ?PROXY1632METHOD30@@ZAKPEVCPROXY1632@@@Z
-180 stub ?PROXY1632METHOD21@@ZAKPEVCPROXY1632@@@Z
-181 stub ?PROXY1632METHOD12@@ZAKPEVCPROXY1632@@@Z
-182 stub ?PROXY1632METHOD31@@ZAKPEVCPROXY1632@@@Z
-183 stub ?PROXY1632METHOD22@@ZAKPEVCPROXY1632@@@Z
-184 stub ?PROXY1632METHOD13@@ZAKPEVCPROXY1632@@@Z
-185 stub ?GETSIZE@CSTDMALLOC@@VEAKPEX@Z
-186 stub ?PROXY1632METHOD23@@ZAKPEVCPROXY1632@@@Z
-187 stub ?PROXY1632METHOD14@@ZAKPEVCPROXY1632@@@Z
-188 stub ?PROXY1632METHOD24@@ZAKPEVCPROXY1632@@@Z
-189 stub ?PROXY1632METHOD15@@ZAKPEVCPROXY1632@@@Z
-190 stub ?PROXY1632METHOD25@@ZAKPEVCPROXY1632@@@Z
-191 stub ?PROXY1632METHOD16@@ZAKPEVCPROXY1632@@@Z
-192 stub ?PROXY1632METHOD26@@ZAKPEVCPROXY1632@@@Z
-193 stub ?PROXY1632METHOD17@@ZAKPEVCPROXY1632@@@Z
-194 stub ?PROXY1632METHOD27@@ZAKPEVCPROXY1632@@@Z
-195 stub ?PROXY1632METHOD18@@ZAKPEVCPROXY1632@@@Z
-196 stub ?PROXY1632METHOD28@@ZAKPEVCPROXY1632@@@Z
-197 stub ?ADDREF@CSTDMALLOC@@VEAKXZ
-198 stub ?PROXY1632METHOD19@@ZAKPEVCPROXY1632@@@Z
-199 stub ?PROXY1632METHOD29@@ZAKPEVCPROXY1632@@@Z
-200 stub CALL32INITIALIZE
-201 pascal CALLOBJECTINWOW(ptr ptr) CallObjectInWOW
-203 stub CALLOBJECTINWOWCHECKINIT
-204 stub CALLOBJECTINWOWCHECKTHKMGR
-205 stub CONVERTHR1632
-206 stub CONVERTHR3216
-207 stub ADDAPPCOMPATFLAG
-
-# WINE internal relays (for Win16 interfaces)
-500 cdecl IMalloc16_QueryInterface(ptr ptr ptr) IMalloc16_fnQueryInterface
-501 cdecl IMalloc16_AddRef(ptr) IMalloc16_fnAddRef
-502 cdecl IMalloc16_Release(ptr) IMalloc16_fnRelease
-503 cdecl IMalloc16_Alloc(ptr long) IMalloc16_fnAlloc
-504 cdecl IMalloc16_Realloc(ptr segptr long) IMalloc16_fnRealloc
-505 cdecl IMalloc16_Free(ptr segptr) IMalloc16_fnFree
-506 cdecl IMalloc16_GetSize(ptr segptr) IMalloc16_fnGetSize
-507 cdecl IMalloc16_DidAlloc(ptr segptr) IMalloc16_fnDidAlloc
-508 cdecl IMalloc16_HeapMinimize(ptr) IMalloc16_fnHeapMinimize
index 38a6475..65d459f 100644 (file)
@@ -196,9 +196,6 @@ extern void* StdGlobalInterfaceTable_Construct(void);
 extern HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv);
 extern void* StdGlobalInterfaceTableInstance;
 
-/* FIXME: these shouldn't be needed, except for 16-bit functions */
-extern HRESULT WINE_StringFromCLSID(const CLSID *id,LPSTR idstr);
-
 HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *key);
 HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey);
 HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv);
diff --git a/reactos/dll/win32/ole32/memlockbytes16.c b/reactos/dll/win32/ole32/memlockbytes16.c
deleted file mode 100644 (file)
index bca7aa1..0000000
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * Global memory implementation of ILockBytes.
- *
- * Copyright 1999 Thuy Nguyen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdarg.h>
-#include <string.h>
-
-#define NONAMELESSUNION
-#define NONAMELESSSTRUCT
-#include "windef.h"
-#include "winbase.h"
-#include "wine/winbase16.h"
-#include "winuser.h"
-#include "objbase.h"
-#include "ole2.h"
-#include "winerror.h"
-
-#include "ifs.h"
-
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
-
-/******************************************************************************
- * HGLOBALLockBytesImpl16 definition.
- *
- * This class implements the ILockBytes interface and represents a byte array
- * object supported by an HGLOBAL pointer.
- */
-struct HGLOBALLockBytesImpl16
-{
-  /*
-   * Needs to be the first item in the struct
-   * since we want to cast this in an ILockBytes pointer
-   */
-  const ILockBytes16Vtbl *lpVtbl;
-  LONG        ref;
-
-  /*
-   * Support for the LockBytes object
-   */
-  HGLOBAL16 supportHandle;
-
-  /*
-   * This flag is TRUE if the HGLOBAL is destroyed when the object
-   * is finally released.
-   */
-  BOOL    deleteOnRelease;
-  /*
-   * Helper variable that contains the size of the byte array
-   */
-  ULARGE_INTEGER     byteArraySize;
-};
-
-typedef struct HGLOBALLockBytesImpl16 HGLOBALLockBytesImpl16;
-
-/******************************************************************************
- *
- * HGLOBALLockBytesImpl16 implementation
- *
- */
-
-/******************************************************************************
- * This is the constructor for the HGLOBALLockBytesImpl16 class.
- *
- * Params:
- *    hGlobal          - Handle that will support the stream. can be NULL.
- *    fDeleteOnRelease - Flag set to TRUE if the HGLOBAL16 will be released
- *                       when the IStream object is destroyed.
- */
-static HGLOBALLockBytesImpl16*
-HGLOBALLockBytesImpl16_Construct(HGLOBAL16 hGlobal,
-                                BOOL16 fDeleteOnRelease)
-{
-  HGLOBALLockBytesImpl16* newLockBytes;
-
-  static ILockBytes16Vtbl vt16;
-  static SEGPTR msegvt16;
-  HMODULE16 hcomp = GetModuleHandle16("OLE2");
-
-
-  TRACE("(%x,%d)\n",hGlobal,fDeleteOnRelease);
-  newLockBytes = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALLockBytesImpl16));
-  if (newLockBytes == NULL)
-    return NULL;
-
-  /*
-   * Set up the virtual function table and reference count.
-   */
-  if (!msegvt16)
-  {
-#define VTENT(x) vt16.x = (void*)GetProcAddress16(hcomp,"HGLOBALLockBytesImpl16_"#x);assert(vt16.x)
-      VTENT(QueryInterface);
-      VTENT(AddRef);
-      VTENT(Release);
-      VTENT(ReadAt);
-      VTENT(WriteAt);
-      VTENT(Flush);
-      VTENT(SetSize);
-      VTENT(LockRegion);
-      VTENT(UnlockRegion);
-#undef VTENT
-      msegvt16 = MapLS( &vt16 );
-  }
-  newLockBytes->lpVtbl = (const ILockBytes16Vtbl*)msegvt16;
-  newLockBytes->ref    = 0;
-  /*
-   * Initialize the support.
-   */
-  newLockBytes->supportHandle = hGlobal;
-  newLockBytes->deleteOnRelease = fDeleteOnRelease;
-
-  /*
-   * This method will allocate a handle if one is not supplied.
-   */
-  if (newLockBytes->supportHandle == 0)
-    newLockBytes->supportHandle = GlobalAlloc16(GMEM_MOVEABLE | GMEM_NODISCARD, 0);
-
-  /*
-   * Initialize the size of the array to the size of the handle.
-   */
-  newLockBytes->byteArraySize.u.HighPart = 0;
-  newLockBytes->byteArraySize.u.LowPart  = GlobalSize16(
-                                           newLockBytes->supportHandle);
-
-  return (HGLOBALLockBytesImpl16*)MapLS(newLockBytes);
-}
-
-/******************************************************************************
- * This is the destructor of the HGLOBALStreamImpl class.
- *
- * This method will clean-up all the resources used-up by the given
- * HGLOBALLockBytesImpl16 class. The pointer passed-in to this function will be
- * freed and will not be valid anymore.
- */
-static void HGLOBALLockBytesImpl16_Destroy(HGLOBALLockBytesImpl16* This)
-{
-  TRACE("()\n");
-  /*
-   * Release the HGlobal if the constructor asked for that.
-   */
-  if (This->deleteOnRelease)
-  {
-    GlobalFree16(This->supportHandle);
-    This->supportHandle = 0;
-  }
-
-  /*
-   * Finally, free the memory used-up by the class.
-   */
-  HeapFree(GetProcessHeap(), 0, This);
-}
-
-/******************************************************************************
- * This implements the IUnknown method AddRef for this
- * class
- */
-ULONG CDECL HGLOBALLockBytesImpl16_AddRef(ILockBytes16* iface)
-{
-  HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
-
-  TRACE("(%p)\n",This);
-
-  return InterlockedIncrement(&This->ref);
-}
-
-
-/******************************************************************************
- * This implements the IUnknown method QueryInterface for this
- * class
- */
-HRESULT CDECL HGLOBALLockBytesImpl16_QueryInterface(
-      ILockBytes16*  iface,    /* [in] SEGPTR */
-      REFIID       riid,        /* [in] */
-      void**       ppvObject)   /* [out][iid_is] (ptr to SEGPTR!) */
-{
-  HGLOBALLockBytesImpl16* const This = MapSL((SEGPTR)iface);
-
-  TRACE("(%p,%s,%p)\n",iface,debugstr_guid(riid),ppvObject);
-  /*
-   * Perform a sanity check on the parameters.
-   */
-  if (ppvObject==0)
-    return E_INVALIDARG;
-
-  /*
-   * Initialize the return parameter.
-   */
-  *ppvObject = 0;
-  /*
-   * Compare the riid with the interface IDs implemented by this object.
-   */
-  if ( !memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) ||
-        !memcmp(&IID_ILockBytes, riid, sizeof(IID_ILockBytes))
-  )
-    *ppvObject = (void*)iface;
-
-  /*
-   * Check that we obtained an interface.
-   */
-  if ((*ppvObject)==0) {
-    FIXME("Unknown IID %s\n", debugstr_guid(riid));
-    return E_NOINTERFACE;
-  }
-
-  /*
-   * Query Interface always increases the reference count by one when it is
-   * successful
-   */
-  HGLOBALLockBytesImpl16_AddRef((ILockBytes16*)This);
-
-  return S_OK;
-}
-
-/******************************************************************************
- * This implements the IUnknown method Release for this
- * class
- */
-ULONG CDECL HGLOBALLockBytesImpl16_Release(ILockBytes16* iface)
-{
-  HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
-  ULONG ref;
-
-  TRACE("(%p)\n",This);
-
-  ref = InterlockedDecrement(&This->ref);
-
-  /*
-   * If the reference count goes down to 0, perform suicide.
-   */
-  if (ref==0)
-    HGLOBALLockBytesImpl16_Destroy(This);
-  return ref;
-}
-
-/******************************************************************************
- * This method is part of the ILockBytes interface.
- *
- * It reads a block of information from the byte array at the specified
- * offset.
- *
- * See the documentation of ILockBytes for more info.
- */
-HRESULT CDECL HGLOBALLockBytesImpl16_ReadAt(
-      ILockBytes16*  iface,
-      ULARGE_INTEGER ulOffset,  /* [in] */
-      void*          pv,        /* [out][length_is][size_is] */
-      ULONG          cb,        /* [in] */
-      ULONG*         pcbRead)   /* [out] */
-{
-  HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
-
-  void* supportBuffer;
-  ULONG bytesReadBuffer = 0;
-  ULONG bytesToReadFromBuffer;
-
-  TRACE("(%p,%d,%p,%d,%p)\n",This,ulOffset.u.LowPart,pv,cb,pcbRead);
-  /*
-   * If the caller is not interested in the number of bytes read,
-   * we use another buffer to avoid "if" statements in the code.
-   */
-  if (pcbRead == 0)
-    pcbRead = &bytesReadBuffer;
-
-  /*
-   * Make sure the offset is valid.
-   */
-  if (ulOffset.u.LowPart > This->byteArraySize.u.LowPart)
-    return E_FAIL;
-
-  /*
-   * Using the known size of the array, calculate the number of bytes
-   * to read.
-   */
-  bytesToReadFromBuffer = min(This->byteArraySize.u.LowPart -
-                              ulOffset.u.LowPart, cb);
-
-  /*
-   * Lock the buffer in position and copy the data.
-   */
-  supportBuffer = GlobalLock16(This->supportHandle);
-
-  memcpy(pv,
-         (char *) supportBuffer + ulOffset.u.LowPart,
-         bytesToReadFromBuffer);
-
-  /*
-   * Return the number of bytes read.
-   */
-  *pcbRead = bytesToReadFromBuffer;
-
-  /*
-   * Cleanup
-   */
-  GlobalUnlock16(This->supportHandle);
-
-  /*
-   * The function returns S_OK if the specified number of bytes were read
-   * or the end of the array was reached.
-   * It returns STG_E_READFAULT if the number of bytes to read does not equal
-   * the number of bytes actually read.
-   */
-  if(*pcbRead == cb)
-    return S_OK;
-
-  return STG_E_READFAULT;
-}
-
-/******************************************************************************
- * This method is part of the ILockBytes interface.
- *
- * It will change the size of the byte array.
- *
- * See the documentation of ILockBytes for more info.
- */
-HRESULT CDECL HGLOBALLockBytesImpl16_SetSize(
-      ILockBytes16*   iface,
-      ULARGE_INTEGER  libNewSize)   /* [in] */
-{
-  HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
-  HGLOBAL16 supportHandle;
-
-  TRACE("(%p,%d)\n",This,libNewSize.u.LowPart);
-  /*
-   * As documented.
-   */
-  if (libNewSize.u.HighPart != 0)
-    return STG_E_INVALIDFUNCTION;
-
-  if (This->byteArraySize.u.LowPart == libNewSize.u.LowPart)
-    return S_OK;
-
-  /*
-   * Re allocate the HGlobal to fit the new size of the stream.
-   */
-  supportHandle = GlobalReAlloc16(This->supportHandle, libNewSize.u.LowPart, 0);
-
-  if (supportHandle == 0)
-    return STG_E_MEDIUMFULL;
-
-  This->supportHandle = supportHandle;
-  This->byteArraySize.u.LowPart = libNewSize.u.LowPart;
-
-  return S_OK;
-}
-
-/******************************************************************************
- * This method is part of the ILockBytes interface.
- *
- * It writes the specified bytes at the specified offset.
- * position. If the array is too small, it will be resized.
- *
- * See the documentation of ILockBytes for more info.
- */
-HRESULT CDECL HGLOBALLockBytesImpl16_WriteAt(
-      ILockBytes16*  iface,
-      ULARGE_INTEGER ulOffset,    /* [in] */
-      const void*    pv,          /* [in][size_is] */
-      ULONG          cb,          /* [in] */
-      ULONG*         pcbWritten)  /* [out] */
-{
-  HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
-
-  void*          supportBuffer;
-  ULARGE_INTEGER newSize;
-  ULONG          bytesWritten = 0;
-
-  TRACE("(%p,%d,%p,%d,%p)\n",This,ulOffset.u.LowPart,pv,cb,pcbWritten);
-  /*
-   * If the caller is not interested in the number of bytes written,
-   * we use another buffer to avoid "if" statements in the code.
-   */
-  if (pcbWritten == 0)
-    pcbWritten = &bytesWritten;
-
-  if (cb == 0)
-    return S_OK;
-
-  newSize.u.HighPart = 0;
-  newSize.u.LowPart = ulOffset.u.LowPart + cb;
-
-  /*
-   * Verify if we need to grow the stream
-   */
-  if (newSize.u.LowPart > This->byteArraySize.u.LowPart)
-  {
-    /* grow stream */
-    if (HGLOBALLockBytesImpl16_SetSize(iface, newSize) == STG_E_MEDIUMFULL)
-      return STG_E_MEDIUMFULL;
-  }
-
-  /*
-   * Lock the buffer in position and copy the data.
-   */
-  supportBuffer = GlobalLock16(This->supportHandle);
-
-  memcpy((char *) supportBuffer + ulOffset.u.LowPart, pv, cb);
-
-  /*
-   * Return the number of bytes written.
-   */
-  *pcbWritten = cb;
-
-  /*
-   * Cleanup
-   */
-  GlobalUnlock16(This->supportHandle);
-
-  return S_OK;
-}
-
-/******************************************************************************
- * This method is part of the ILockBytes interface.
- *
- * See the documentation of ILockBytes for more info.
- */
-HRESULT CDECL HGLOBALLockBytesImpl16_Flush(ILockBytes16* iface)
-{
-  TRACE("(%p)\n",iface);
-  return S_OK;
-}
-
-/******************************************************************************
- * This method is part of the ILockBytes interface.
- *
- * The global memory implementation of ILockBytes does not support locking.
- *
- * See the documentation of ILockBytes for more info.
- */
-HRESULT CDECL HGLOBALLockBytesImpl16_LockRegion(
-      ILockBytes16*  iface,
-      ULARGE_INTEGER libOffset,   /* [in] */
-      ULARGE_INTEGER cb,          /* [in] */
-      DWORD          dwLockType)  /* [in] */
-{
-  return STG_E_INVALIDFUNCTION;
-}
-
-/******************************************************************************
- * This method is part of the ILockBytes interface.
- *
- * The global memory implementation of ILockBytes does not support locking.
- *
- * See the documentation of ILockBytes for more info.
- */
-HRESULT CDECL HGLOBALLockBytesImpl16_UnlockRegion(
-      ILockBytes16*  iface,
-      ULARGE_INTEGER libOffset,   /* [in] */
-      ULARGE_INTEGER cb,          /* [in] */
-      DWORD          dwLockType)  /* [in] */
-{
-  return STG_E_INVALIDFUNCTION;
-}
-
-/******************************************************************************
- * This method is part of the ILockBytes interface.
- *
- * This method returns information about the current
- * byte array object.
- *
- * See the documentation of ILockBytes for more info.
- */
-HRESULT CDECL HGLOBALLockBytesImpl16_Stat(
-      ILockBytes16*iface,
-      STATSTG16*   pstatstg,     /* [out] */
-      DWORD        grfStatFlag)  /* [in] */
-{
-  HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
-
-  memset(pstatstg, 0, sizeof(STATSTG16));
-
-  pstatstg->pwcsName = NULL;
-  pstatstg->type     = STGTY_LOCKBYTES;
-  pstatstg->cbSize   = This->byteArraySize;
-
-  return S_OK;
-}
-
-/******************************************************************************
- *           CreateILockBytesOnHGlobal     [OLE2.54]
- * 
- * Creates an ILockBytes interface for a HGLOBAL handle.
- *
- * PARAMS
- *     hGlobal                 the global handle (16bit)
- *     fDeleteOnRelease        delete handle on release.
- *     ppLkbyt                 pointer to ILockBytes interface.
- *
- * RETURNS
- *     Staddard OLE error return codes.
- *
- */
-HRESULT WINAPI CreateILockBytesOnHGlobal16(
-       HGLOBAL16      hGlobal,          /* [in] */
-       BOOL16         fDeleteOnRelease, /* [in] */
-       LPLOCKBYTES16 *ppLkbyt)          /* [out] (ptr to SEGPTR!) */
-{
-  HGLOBALLockBytesImpl16* newLockBytes; /* SEGPTR */
-
-  newLockBytes = HGLOBALLockBytesImpl16_Construct(hGlobal, fDeleteOnRelease);
-
-  if (newLockBytes != NULL)
-    return HGLOBALLockBytesImpl16_QueryInterface((ILockBytes16*)newLockBytes,
-                                   &IID_ILockBytes,
-                                   (void**)ppLkbyt);
-  return E_OUTOFMEMORY;
-}
index ae225dc..fe00066 100644 (file)
@@ -161,7 +161,6 @@ static DWORD OLEDD_GetButtonState(void);
 
 
 /******************************************************************************
- *             OleBuildVersion [OLE2.1]
  *             OleBuildVersion [OLE32.@]
  */
 DWORD WINAPI OleBuildVersion(void)
@@ -171,7 +170,6 @@ DWORD WINAPI OleBuildVersion(void)
 }
 
 /***********************************************************************
- *           OleInitialize       (OLE2.2)
  *           OleInitialize       (OLE32.@)
  */
 HRESULT WINAPI OleInitialize(LPVOID reserved)
@@ -228,7 +226,6 @@ HRESULT WINAPI OleInitialize(LPVOID reserved)
 }
 
 /******************************************************************************
- *             OleUninitialize [OLE2.3]
  *             OleUninitialize [OLE32.@]
  */
 void WINAPI OleUninitialize(void)
diff --git a/reactos/dll/win32/ole32/ole2.spec b/reactos/dll/win32/ole32/ole2.spec
deleted file mode 100644 (file)
index 1c33737..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-1 pascal OleBuildVersion() OleBuildVersion
-2 pascal OleInitialize(ptr) OleInitialize
-3 pascal OleUninitialize() OleUninitialize
-4 pascal DllGetClassObject(ptr ptr ptr) DllGetClassObject16
-#5 WEP
-6 stub OLEQUERYLINKFROMDATA
-7 stub OLEQUERYCREATEFROMDATA
-8 stub OLECREATEFROMDATA
-9 stub OLECREATELINKFROMDATA
-10 stub OLECREATE
-11 stub OLECREATELINK
-12 pascal OleLoad(segptr ptr segptr ptr) OleLoad16
-13 stub OLESAVE
-14 stub OLERUN
-#15 ___EXPORTEDSTUB
-16 stub OLEISRUNNING
-17 stub OLELOCKRUNNING
-18 pascal ReadClassStg(segptr ptr) ReadClassStg16
-19 stub WRITECLASSSTG
-20 stub READCLASSSTM
-21 stub WRITECLASSSTM
-22 stub BINDMONIKER
-23 stub MKPARSEDISPLAYNAME
-24 stub OLESAVETOSTREAM
-25 stub OLELOADFROMSTREAM
-26 stub CREATEBINDCTX
-27 pascal CreateItemMoniker(str str ptr) CreateItemMoniker16
-28 pascal CreateFileMoniker(str ptr) CreateFileMoniker16
-29 stub CREATEGENERICCOMPOSITE
-30 pascal GetRunningObjectTable(long ptr) GetRunningObjectTable16
-31 stub OLEGETMALLOC
-32 stub RELEASESTGMEDIUM
-33 stub READSTRINGSTREAM
-34 stub WRITESTRINGSTREAM
-35 pascal RegisterDragDrop(word segptr) RegisterDragDrop16
-36 pascal RevokeDragDrop(word) RevokeDragDrop16
-37 stub DODRAGDROP
-38 stub CREATEOLEADVISEHOLDER
-39 stub CREATEDATAADVISEHOLDER
-40 stub OLECREATEMENUDESCRIPTOR
-41 pascal OleSetMenuDescriptor(word word word ptr ptr) OleSetMenuDescriptor16
-42 stub OLEDESTROYMENUDESCRIPTOR
-43 stub OPENORCREATESTREAM
-44 stub CREATEANTIMONIKER
-45 stub CREATEPOINTERMONIKER
-46 stub MONIKERRELATIVEPATHTO
-47 stub MONIKERCOMMONPREFIXWITH
-48 stub ISACCELERATOR
-49 pascal OleSetClipboard(ptr) OleSetClipboard16
-50 pascal OleGetClipboard(ptr) OleGetClipboard16
-51 stub OLEDUPLICATEDATA
-52 stub OLEGETICONOFFILE
-53 stub OLEGETICONOFCLASS
-54 pascal CreateILockBytesOnHGlobal(word word ptr) CreateILockBytesOnHGlobal16
-55 stub GETHGLOBALFROMILOCKBYTES
-56 pascal -ret16 OleMetaFilePictFromIconAndLabel(word str str word) OleMetaFilePictFromIconAndLabel16
-57 stub GETCLASSFILE
-58 stub OLEDRAW
-59 stub OLECREATEDEFAULTHANDLER
-60 stub OLECREATEEMBEDDINGHELPER
-61 stub OLECONVERTISTORAGETOOLESTREAMEX
-62 stub OLECONVERTOLESTREAMTOISTORAGEEX
-63 stub SETDOCUMENTBITSTG
-64 stub GETDOCUMENTBITSTG
-65 stub WRITEOLESTG
-66 stub READOLESTG
-67 stub OLECREATEFROMFILE
-68 stub OLECREATELINKTOFILE
-69 stub CREATEDATACACHE
-70 stub OLECONVERTISTORAGETOOLESTREAM
-71 stub OLECONVERTOLESTREAMTOISTORAGE
-74 stub READFMTUSERTYPESTG
-75 stub WRITEFMTUSERTYPESTG
-76 pascal -ret16 OleFlushClipboard() OleFlushClipboard16
-77 stub OLEISCURRENTCLIPBOARD
-78 stub OLETRANSLATEACCELERATOR
-79 pascal OleDoAutoConvert(ptr ptr) OleDoAutoConvert16
-80 stub OLEGETAUTOCONVERT
-81 stub OLESETAUTOCONVERT
-82 pascal GetConvertStg(ptr) GetConvertStg16
-83 stub SETCONVERTSTG
-84 stub CREATESTREAMONHGLOBAL
-85 stub GETHGLOBALFROMSTREAM
-86 stub OLESETCONTAINEDOBJECT
-87 stub OLENOTEOBJECTVISIBLE
-88 stub OLECREATESTATICFROMDATA
-89 stub OLEREGGETUSERTYPE
-90 stub OLEREGGETMISCSTATUS
-91 stub OLEREGENUMFORMATETC
-92 stub OLEREGENUMVERBS
-93 stub OLEGETENUMFORMATETC
-100 stub MAKEDEBUGSTREAM
-104 stub DBGLOGOPEN
-105 stub DBGLOGCLOSE
-106 stub DBGLOGOUTPUTDEBUGSTRING
-107 stub DBGLOGWRITE
-108 stub DBGLOGTIMESTAMP
-109 stub DBGLOGWRITEBANNER
-110 stub DBGDUMPOBJECT
-111 stub DBGISOBJECTVALID
-112 stub DUMPALLOBJECTS
-113 stub VALIDATEALLOBJECTS
-114 stub DBGDUMPCLASSNAME
-115 stub DBGDUMPEXTERNALOBJECT
-120 stub _IID_IENUMUNKNOWN
-121 stub _IID_IENUMSTRING
-122 stub _IID_IENUMMONIKER
-123 stub _IID_IENUMFORMATETC
-124 stub _IID_IENUMOLEVERB
-125 stub _IID_IENUMSTATDATA
-126 stub _IID_IENUMGENERIC
-127 stub _IID_IENUMHOLDER
-128 stub _IID_IENUMCALLBACK
-129 stub _IID_IPERSISTSTREAM
-130 stub _IID_IPERSISTSTORAGE
-131 stub _IID_IPERSISTFILE
-132 stub _IID_IPERSIST
-133 stub _IID_IVIEWOBJECT
-134 stub _IID_IDATAOBJECT
-135 stub _IID_IADVISESINK
-136 stub _IID_IDATAADVISEHOLDER
-137 stub _IID_IOLEADVISEHOLDER
-138 stub _IID_IOLEOBJECT
-139 stub _IID_IOLEINPLACEOBJECT
-140 stub _IID_IOLEWINDOW
-141 stub _IID_IOLEINPLACEUIWINDOW
-142 stub _IID_IOLEINPLACEFRAME
-143 stub _IID_IOLEINPLACEACTIVEOBJECT
-144 stub _IID_IOLECLIENTSITE
-145 stub _IID_IOLEINPLACESITE
-146 stub _IID_IPARSEDISPLAYNAME
-147 stub _IID_IOLECONTAINER
-148 stub _IID_IOLEITEMCONTAINER
-149 stub _IID_IOLELINK
-150 stub _IID_IOLECACHE
-151 stub _IID_IOLEMANAGER
-152 stub _IID_IOLEPRESOBJ
-153 stub _IID_IDROPSOURCE
-154 stub _IID_IDROPTARGET
-155 stub _IID_IDEBUG
-156 stub _IID_IDEBUGSTREAM
-157 stub _IID_IADVISESINK2
-158 stub _IID_IVIEWOBJECT2
-159 stub _IID_IOLECACHE2
-160 stub _IID_IOLECACHECONTROL
-161 stub _IID_IRUNNABLEOBJECT
-
-# WINE MemLockBytes implementation.
-500 cdecl HGLOBALLockBytesImpl16_QueryInterface(segptr ptr ptr) HGLOBALLockBytesImpl16_QueryInterface
-501 cdecl HGLOBALLockBytesImpl16_AddRef(ptr) HGLOBALLockBytesImpl16_AddRef
-502 cdecl HGLOBALLockBytesImpl16_Release(ptr) HGLOBALLockBytesImpl16_Release
-503 cdecl HGLOBALLockBytesImpl16_ReadAt(ptr double ptr long ptr) HGLOBALLockBytesImpl16_ReadAt
-504 cdecl HGLOBALLockBytesImpl16_WriteAt(ptr double ptr long ptr) HGLOBALLockBytesImpl16_WriteAt
-505 cdecl HGLOBALLockBytesImpl16_Flush(ptr) HGLOBALLockBytesImpl16_Flush
-506 cdecl HGLOBALLockBytesImpl16_SetSize(ptr double) HGLOBALLockBytesImpl16_SetSize
-507 cdecl HGLOBALLockBytesImpl16_LockRegion(ptr double double long) HGLOBALLockBytesImpl16_LockRegion
-508 cdecl HGLOBALLockBytesImpl16_UnlockRegion(ptr double double long) HGLOBALLockBytesImpl16_UnlockRegion
-509 cdecl HGLOBALLockBytesImpl16_Stat(ptr ptr long) HGLOBALLockBytesImpl16_Stat
diff --git a/reactos/dll/win32/ole32/ole2_16.c b/reactos/dll/win32/ole32/ole2_16.c
deleted file mode 100644 (file)
index fc88d8a..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-
-/*
- *     OLE2 library - 16 bit only interfaces
- *
- *     Copyright 1995  Martin von Loewis
- *      Copyright 1999  Francis Beaudet
- *      Copyright 1999  Noel Borthwick
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-
-#define NONAMELESSUNION
-#define NONAMELESSSTRUCT
-#include "windef.h"
-#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "ole2.h"
-#include "winerror.h"
-
-#include "wine/winbase16.h"
-#include "wine/wingdi16.h"
-#include "wine/winuser16.h"
-#include "ifs.h"
-
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
-
-#define HICON_16(h32)          (LOWORD(h32))
-#define HICON_32(h16)          ((HICON)(ULONG_PTR)(h16))
-#define HINSTANCE_32(h16)      ((HINSTANCE)(ULONG_PTR)(h16))
-
-/***********************************************************************
- *           RegisterDragDrop (OLE2.35)
- */
-HRESULT WINAPI RegisterDragDrop16(
-       HWND16 hwnd,
-       LPDROPTARGET pDropTarget
-) {
-       FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
-       return S_OK;
-}
-
-/***********************************************************************
- *           RevokeDragDrop (OLE2.36)
- */
-HRESULT WINAPI RevokeDragDrop16(
-       HWND16 hwnd
-) {
-       FIXME("(0x%04x),stub!\n",hwnd);
-       return S_OK;
-}
-
-/******************************************************************************
- * OleMetaFilePictFromIconAndLabel (OLE2.56)
- *
- * Returns a global memory handle to a metafile which contains the icon and
- * label given.
- * I guess the result of that should look somehow like desktop icons.
- * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
- * This code might be wrong at some places.
- */
-HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16(
-       HICON16 hIcon,
-       LPCOLESTR16 lpszLabel,
-       LPCOLESTR16 lpszSourceFile,
-       UINT16 iIconIndex
-) {
-    METAFILEPICT16 *mf16;
-    HGLOBAL16 hmf16;
-    HMETAFILE hmf;
-    INT mfSize;
-    HDC hdc;
-
-    if (!hIcon) {
-        if (lpszSourceFile) {
-           HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);
-
-           /* load the icon at index from lpszSourceFile */
-           hIcon = HICON_16(LoadIconA(HINSTANCE_32(hInstance), (LPCSTR)(DWORD)iIconIndex));
-           FreeLibrary16(hInstance);
-       } else
-           return 0;
-    }
-
-    FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n", 
-          hIcon, lpszLabel, lpszSourceFile, iIconIndex);
-
-    hdc = CreateMetaFileW(NULL);
-    DrawIcon(hdc, 0, 0, HICON_32(hIcon)); /* FIXME */
-    TextOutA(hdc, 0, 0, lpszLabel, 1); /* FIXME */
-    hmf = CloseMetaFile(hdc);
-
-    hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
-    mf16 = GlobalLock16(hmf16);
-    mf16->mm = MM_ANISOTROPIC;
-    mf16->xExt = 20; /* FIXME: bogus */
-    mf16->yExt = 20; /* ditto */
-    mfSize = GetMetaFileBitsEx(hmf, 0, 0);
-    mf16->hMF = GlobalAlloc16(GMEM_MOVEABLE, mfSize);
-    if(mf16->hMF)
-    {
-        GetMetaFileBitsEx(hmf, mfSize, GlobalLock16(mf16->hMF));
-        GlobalUnlock16(mf16->hMF);
-    }
-    return hmf16;
-}
-
-
-/******************************************************************************
- *        CreateItemMoniker    (OLE2.27)
- */
-HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR16 lpszItem,LPMONIKER* ppmk)
-{
-    FIXME("(%s,%p),stub!\n",lpszDelim,ppmk);
-    *ppmk = NULL;
-    return E_NOTIMPL;
-}
-
-
-/******************************************************************************
- *        CreateFileMoniker (OLE2.28)
- */
-HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName,LPMONIKER* ppmk)
-{
-    FIXME("(%s,%p),stub!\n",lpszPathName,ppmk);
-    return E_NOTIMPL;
-}
-
-/******************************************************************************
- *        OleSetMenuDescriptor (OLE2.41)
- *
- * PARAMS
- *  hOleMenu  FIXME: Should probably be an HOLEMENU16.
- */
-HRESULT WINAPI OleSetMenuDescriptor16(
-    HOLEMENU               hOleMenu,
-    HWND16                 hwndFrame,
-    HWND16                 hwndActiveObject,
-    LPOLEINPLACEFRAME        lpFrame,
-    LPOLEINPLACEACTIVEOBJECT lpActiveObject)
-{
-    FIXME("(%p, %x, %x, %p, %p), stub!\n", hOleMenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObject);
-    return E_NOTIMPL;
-}
-
-/******************************************************************************
- *              IsValidInterface        [COMPOBJ.23]
- *
- * Determines whether a pointer is a valid interface.
- *
- * PARAMS
- *  punk [I] Interface to be tested.
- *
- * RETURNS
- *  TRUE, if the passed pointer is a valid interface, or FALSE otherwise.
- */
-BOOL WINAPI IsValidInterface16(SEGPTR punk)
-{
-       DWORD **ptr;
-
-       if (IsBadReadPtr16(punk,4))
-               return FALSE;
-       ptr = MapSL(punk);
-       if (IsBadReadPtr16((SEGPTR)ptr[0],4))   /* check vtable ptr */
-               return FALSE;
-       ptr = MapSL((SEGPTR)ptr[0]);            /* ptr to first method */
-       if (IsBadReadPtr16((SEGPTR)ptr[0],2))
-               return FALSE;
-       return TRUE;
-}
-
-/******************************************************************************
- *              OleLoad        [OLE2.12]
- *
- * PARAMS
- *  pStg Segmented LPSTORAGE pointer.
- *  pClientSite Segmented LPOLECLIENTSITE pointer.
- */
-HRESULT WINAPI OleLoad16(
-    SEGPTR             pStg,
-    REFIID             riid,
-    SEGPTR             pClientSite,
-    LPVOID*            ppvObj)
-{
-  FIXME("(%x,%s,%x,%p), stub!\n", pStg, debugstr_guid(riid), pClientSite, ppvObj);
-  return E_NOTIMPL;
-}
-
-/******************************************************************************
- *              OleDoAutoConvert        [OLE2.79]
- */
-HRESULT WINAPI OleDoAutoConvert16(LPSTORAGE pStg, LPCLSID pClsidNew)
-{
-    FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
-    return E_NOTIMPL;
-}
-
-/***********************************************************************
- *           OleSetClipboard                            [OLE2.49]
- */
-HRESULT WINAPI OleSetClipboard16(IDataObject* pDataObj)
-{
-  FIXME("(%p): stub\n", pDataObj);
-  return S_OK;
-}
-
-/***********************************************************************
- *           OleGetClipboard                            [OLE2.50]
- */
-HRESULT WINAPI OleGetClipboard16(IDataObject** ppDataObj)
-{
-  FIXME("(%p): stub\n", ppDataObj);
-  return E_NOTIMPL;
-}
-
-/***********************************************************************
- *           OleFlushClipboard   [OLE2.76]
- */
-
-HRESULT WINAPI OleFlushClipboard16(void)
-{
-  return OleFlushClipboard();
-}
diff --git a/reactos/dll/win32/ole32/ole2conv.spec b/reactos/dll/win32/ole32/ole2conv.spec
deleted file mode 100644 (file)
index 0a457e5..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-1 stub GETFILTERINFO
-2 stub IMPORTGR
-3 stub GETFILTERPREF
-4 stub IMPORTEMBEDDEDGR
-5 stub QD2GDI
-6 stub STATUSPROC
-7 stub ENUMFONTFUNC
-#8 WEP
-#9 ___EXPORTEDSTUB
diff --git a/reactos/dll/win32/ole32/ole2nls.c b/reactos/dll/win32/ole32/ole2nls.c
deleted file mode 100644 (file)
index b21601b..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- *     OLE2NLS library
- *
- *     Copyright 1995  Martin von Loewis
- *      Copyright 1998  David Lee Lambert
- *      Copyright 2000  Julio César Gázquez
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <locale.h>
-
-#include "windef.h"
-#include "winbase.h"
-#include "winnls.h"
-#include "winuser.h"
-
-#include "wine/winbase16.h"
-
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
-
-static LPVOID lpNLSInfo = NULL;
-
-/******************************************************************************
- *             GetLocaleInfoA  [OLE2NLS.5]
- * Is the last parameter really WORD for Win16?
- */
-INT16 WINAPI GetLocaleInfo16(LCID lcid,LCTYPE LCType,LPSTR buf,INT16 len)
-{
-       return GetLocaleInfoA(lcid,LCType,buf,len);
-}
-
-/******************************************************************************
- *             GetStringTypeA  [OLE2NLS.7]
- */
-BOOL16 WINAPI GetStringType16(LCID locale,DWORD dwInfoType,LPCSTR src,
-                              INT16 cchSrc,LPWORD chartype)
-{
-       return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype);
-}
-
-/******************************************************************************
- *             GetUserDefaultLCID      [OLE2NLS.1]
- */
-LCID WINAPI GetUserDefaultLCID16(void)
-{
-    return GetUserDefaultLCID();
-}
-
-/******************************************************************************
- *             GetSystemDefaultLCID    [OLE2NLS.2]
- */
-LCID WINAPI GetSystemDefaultLCID16(void)
-{
-    return GetSystemDefaultLCID();
-}
-
-/******************************************************************************
- *             GetUserDefaultLangID    [OLE2NLS.3]
- */
-LANGID WINAPI GetUserDefaultLangID16(void)
-{
-    return GetUserDefaultLangID();
-}
-
-/******************************************************************************
- *             GetSystemDefaultLangID  [OLE2NLS.4]
- */
-LANGID WINAPI GetSystemDefaultLangID16(void)
-{
-    return GetSystemDefaultLangID();
-}
-
-/******************************************************************************
- *             LCMapStringA    [OLE2NLS.6]
- */
-INT16 WINAPI LCMapString16(LCID lcid, DWORD mapflags, LPCSTR srcstr, INT16 srclen,
-                          LPSTR dststr, INT16 dstlen)
-{
-    return LCMapStringA(lcid, mapflags, srcstr, srclen, dststr, dstlen);
-}
-
-/***********************************************************************
- *           CompareStringA       (OLE2NLS.8)
- */
-UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
-                              LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
-{
-       return (UINT16)CompareStringA(lcid,fdwStyle,s1,l1,s2,l2);
-}
-
-/******************************************************************************
- *      RegisterNLSInfoChanged  [OLE2NLS.9]
- */
-BOOL16 WINAPI RegisterNLSInfoChanged16(LPVOID lpNewNLSInfo) /* [???] FIXME */
-{
-       FIXME("Fully implemented, but doesn't effect anything.\n");
-
-       if (!lpNewNLSInfo) {
-               lpNLSInfo = NULL;
-               return TRUE;
-       }
-       else {
-               if (!lpNLSInfo) {
-                       lpNLSInfo = lpNewNLSInfo;
-                       return TRUE;
-               }
-       }
-
-       return FALSE; /* ptr not set */
-}
diff --git a/reactos/dll/win32/ole32/ole2nls.spec b/reactos/dll/win32/ole32/ole2nls.spec
deleted file mode 100644 (file)
index d3fc613..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-1 pascal GetUserDefaultLCID() GetUserDefaultLCID16
-2 pascal GetSystemDefaultLCID() GetSystemDefaultLCID16
-3 pascal -ret16 GetUserDefaultLangID() GetUserDefaultLangID16
-4 pascal -ret16 GetSystemDefaultLangID() GetSystemDefaultLangID16
-5 pascal GetLocaleInfoA(long long ptr word) GetLocaleInfo16
-6 pascal -ret16 LCMapStringA(word long ptr word ptr word) LCMapString16
-7 pascal -ret16 GetStringTypeA(long long str word ptr) GetStringType16
-8 pascal -ret16 CompareStringA(long long str word str word) CompareString16
-9 pascal -ret16 RegisterNLSInfoChanged(ptr) RegisterNLSInfoChanged16
-#10 stub WEP
-11 stub LIBMAIN
-12 stub NOTIFYWINDOWPROC
diff --git a/reactos/dll/win32/ole32/ole2prox.spec b/reactos/dll/win32/ole32/ole2prox.spec
deleted file mode 100644 (file)
index 3d05d2e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-1 stub DLLGETCLASSOBJECT
-#2 WEP
-#3 ___EXPORTEDSTUB
diff --git a/reactos/dll/win32/ole32/storage.c b/reactos/dll/win32/ole32/storage.c
deleted file mode 100644 (file)
index 1748ef3..0000000
+++ /dev/null
@@ -1,2245 +0,0 @@
-/* Compound Storage
- *
- * Implemented using the documentation of the LAOLA project at
- * <URL:http://wwwwbs.cs.tu-berlin.de/~schwartz/pmh/index.html>
- * (Thanks to Martin Schwartz <schwartz@cs.tu-berlin.de>)
- *
- * Copyright 1998 Marcus Meissner
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-
-#include <assert.h>
-#include <time.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#define NONAMELESSUNION
-#define NONAMELESSSTRUCT
-#include "windef.h"
-#include "winbase.h"
-#include "winternl.h"
-#include "winerror.h"
-#include "wine/winbase16.h"
-#include "wownt32.h"
-#include "wine/unicode.h"
-#include "objbase.h"
-#include "wine/debug.h"
-
-#include "ifs.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
-WINE_DECLARE_DEBUG_CHANNEL(relay);
-
-struct storage_header {
-       BYTE    magic[8];       /* 00: magic */
-       BYTE    unknown1[36];   /* 08: unknown */
-       DWORD   num_of_bbd_blocks;/* 2C: length of big datablocks */
-       DWORD   root_startblock;/* 30: root storage first big block */
-       DWORD   unknown2[2];    /* 34: unknown */
-       DWORD   sbd_startblock; /* 3C: small block depot first big block */
-       DWORD   unknown3[3];    /* 40: unknown */
-       DWORD   bbd_list[109];  /* 4C: big data block list (up to end of sector)*/
-};
-struct storage_pps_entry {
-       WCHAR   pps_rawname[32];/* 00: \0 terminated widechar name */
-       WORD    pps_sizeofname; /* 40: namelength in bytes */
-       BYTE    pps_type;       /* 42: flags, 1 storage/dir, 2 stream, 5 root */
-       BYTE    pps_unknown0;   /* 43: unknown */
-       DWORD   pps_prev;       /* 44: previous pps */
-       DWORD   pps_next;       /* 48: next pps */
-       DWORD   pps_dir;        /* 4C: directory pps */
-       GUID    pps_guid;       /* 50: class ID */
-       DWORD   pps_unknown1;   /* 60: unknown */
-       FILETIME pps_ft1;       /* 64: filetime1 */
-       FILETIME pps_ft2;       /* 70: filetime2 */
-       DWORD   pps_sb;         /* 74: data startblock */
-       DWORD   pps_size;       /* 78: datalength. (<0x1000)?small:big blocks*/
-       DWORD   pps_unknown2;   /* 7C: unknown */
-};
-
-#define STORAGE_CHAINENTRY_FAT         0xfffffffd
-#define STORAGE_CHAINENTRY_ENDOFCHAIN  0xfffffffe
-#define STORAGE_CHAINENTRY_FREE                0xffffffff
-
-
-static const BYTE STORAGE_magic[8]   ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1};
-
-#define BIGSIZE                512
-#define SMALLSIZE              64
-
-#define SMALLBLOCKS_PER_BIGBLOCK       (BIGSIZE/SMALLSIZE)
-
-#define READ_HEADER(str)       STORAGE_get_big_block(str,-1,(LPBYTE)&sth);assert(!memcmp(STORAGE_magic,sth.magic,sizeof(STORAGE_magic)));
-static IStorage16Vtbl stvt16;
-static const IStorage16Vtbl *segstvt16 = NULL;
-static IStream16Vtbl strvt16;
-static const IStream16Vtbl *segstrvt16 = NULL;
-
-/*ULONG WINAPI IStorage16_AddRef(LPSTORAGE16 this);*/
-static void _create_istorage16(LPSTORAGE16 *stg);
-static void _create_istream16(LPSTREAM16 *str);
-
-#define IMPLEMENTED 1
-
-/* The following is taken from the CorVu implementation of docfiles, and
- * documents things about the file format that are not implemented here, and
- * not documented by the LAOLA project. The CorVu implementation was posted
- * to wine-devel in February 2004, and released under the LGPL at the same
- * time. Because that implementation is in C++, it's not directly usable in
- * Wine, but does have documentation value.
- *
- *
- * #define DF_EXT_VTOC         -4
- * #define DF_VTOC_VTOC                -3
- * #define DF_VTOC_EOF         -2
- * #define DF_VTOC_FREE                -1
- * #define DF_NAMELEN  0x20    // Maximum entry name length - 31 characters plus
- *                             // a NUL terminator
- * 
- * #define DF_FT_STORAGE       1
- * #define DF_FT_STREAM                2
- * #define DF_FT_LOCKBYTES     3       // Not used -- How the bloody hell did I manage
- * #define DF_FT_PROPERTY      4       // Not Used -- to figure these two out?
- * #define DF_FT_ROOT          5
- * 
- * #define DF_BLOCK_SIZE       0x200
- * #define DF_VTOC_SIZE                0x80
- * #define DF_DE_PER_BLOCK     4
- * #define DF_STREAM_BLOCK_SIZE        0x40
- * 
- * A DocFile is divided into blocks of 512 bytes.
- * The first block contains the header.
- *
- * The file header contains The first 109 entries in the VTOC of VTOCs.
- *
- * Each block pointed to by a VTOC of VTOCs contains a VTOC, which
- * includes block chains - just like FAT. This is a somewhat poor
- * design for the following reasons:
- *
- *     1. FAT was a poor file system design to begin with, and
- *        has long been known to be horrendously inefficient
- *        for day to day operations.
- *
- *     2. The problem is compounded here, since the file
- *        level streams are generally *not* read sequentially.
- *        This means that a significant percentage of reads
- *        require seeking from the start of the chain.
- *
- * Data chains also contain an internal VTOC. The block size for
- * the standard VTOC is 512. The block size for the internal VTOC
- * is 64.
- *
- * Now, the 109 blocks in the VTOC of VTOCs allows for files of
- * up to around 7MB. So what do you think happens if that's
- * exceeded? Well, there's an entry in the header block which
- * points to the first block used as additional storage for
- * the VTOC of VTOCs.
- *
- * Now we can get up to around 15MB. Now, guess how the file
- * format adds in another block to the VTOC of VTOCs. Come on,
- * it's no big surprise. That's right - the last entry in each
- * block extending the VTOC of VTOCs is, you guessed it, the
- * block number of the next block containing an extension to
- * the VTOC of VTOCs. The VTOC of VTOCs is chained!!!!
- *
- * So, to review:
- *
- * 1. If you are using a FAT file system, the location of
- *    your file's blocks is stored in chains.
- *
- * 2. At the abstract level, the file contains a VTOC of VTOCs,
- *    which is stored in the most inefficient possible format for
- *    random access - a chain (AKA list).
- *
- * 3. The VTOC of VTOCs contains descriptions of three file level
- *    streams:
- *
- *    a. The Directory stream
- *    b. The Data stream
- *    c. The Data VTOC stream
- *
- *    These are, of course, represented as chains.
- *
- * 4. The Data VTOC contains data describing the chains of blocks
- *    within the Data stream.
- *
- * That's right - we have a total of four levels of block chains!
- *
- * Now, is that complicated enough for you? No? OK, there's another
- * complication. If an individual stream (ie. an IStream) reaches
- * 4096 bytes in size, it gets moved from the Data Stream to
- * a new file level stream. Now, if the stream then gets truncated
- * back to less than 4096 bytes, it returns to the data stream.
- *
- * The effect of using this format can be seen very easily. Pick
- * an arbitrary application with a grid data representation that
- * can export to both Lotus 123 and Excel 5 or higher. Export
- * a large file to Lotus 123 and time it. Export the same thing
- * to Excel 5 and time that. The difference is the inefficiency
- * of the Microsoft DocFile format.
- *
- *
- * #define TOTAL_SIMPLE_VTOCS  109
- * 
- * struct      DocFile_Header
- * {
- *     df_byte iMagic1;        // 0xd0 
- *     df_byte iMagic2;        // 0xcf 
- *     df_byte iMagic3;        // 0x11 
- *     df_byte iMagic4;        // 0xe0 - Spells D0CF11E0, or DocFile 
- *     df_byte iMagic5;        // 161  (igi upside down) 
- *     df_byte iMagic6;        // 177  (lli upside down - see below 
- *     df_byte iMagic7;        // 26 (gz upside down) 
- *     df_byte iMagic8;        // 225 (szz upside down) - see below 
- *     df_int4 aiUnknown1[4];
- *     df_int4 iVersion;       // DocFile Version - 0x03003E   
- *     df_int4 aiUnknown2[4];
- *     df_int4 nVTOCs;         // Number of VTOCs 
- *     df_int4 iFirstDirBlock; // First Directory Block 
- *     df_int4 aiUnknown3[2];
- *     df_int4 iFirstDataVTOC; // First data VTOC block 
- *     df_int4 iHasData;       // 1 if there is data in the file - yes, this is important
- *     df_int4 iExtendedVTOC;  // Extended VTOC location 
- *     df_int4 iExtendedVTOCSize; // Size of extended VTOC (+1?) 
- *     df_int4 aiVTOCofVTOCs[TOTAL_SIMPLE_VTOCS];
- * };
- * 
- * struct      DocFile_VTOC
- * {
- *     df_int4 aiBlocks[DF_VTOC_SIZE];
- * };
- * 
- * 
- * The meaning of the magic numbers
- *
- * 0xd0cf11e0 is DocFile with a zero on the end (sort of)
- *
- * If you key 177161 into a calculator, then turn the calculator
- * upside down, you get igilli, which may be a reference to
- * somebody's name, or to the Hebrew word for "angel".
- *
- * If you key 26225 into a calculator, then turn it upside down, you
- * get szzgz. Microsoft has a tradition of creating nonsense words
- * using the letters s, g, z and y. We think szzgz may be one of the
- * Microsoft placeholder variables, along the lines of foo, bar and baz.
- * Alternatively, it could be 22526, which would be gzszz.
- *
- * 
- * struct      DocFile_DirEnt
- * {
- *     df_char achEntryName[DF_NAMELEN];       // Entry Name 
- *     df_int2 iNameLen;                       // Name length in bytes, including NUL terminator 
- *     df_byte iFileType;                      // Entry type 
- *     df_byte iColour;                        // 1 = Black, 0 = Red 
- *     df_int4 iLeftSibling;                   // Next Left Sibling Entry - See below 
- *     df_int4 iRightSibling;                  // Next Right Sibling Entry 
- *     df_int4 iFirstChild;                    // First Child Entry 
- *     df_byte achClassID[16];                 // Class ID 
- *     df_int4 iStateBits;                     // [GS]etStateBits value 
- *     df_int4 iCreatedLow;                    // Low DWORD of creation time 
- *     df_int4 iCreatedHigh;                   // High DWORD of creation time 
- *     df_int4 iModifiedLow;                   // Low DWORD of modification time 
- *     df_int4 iModifiedHigh;                  // High DWORD of modification time 
- *     df_int4 iVTOCPosition;                  // VTOC Position 
- *     df_int4 iFileSize;                      // Size of the stream 
- *     df_int4 iZero;                          // We think this is part of the 64 bit stream size - must be 0 
- * };
- * 
- * Siblings
- * ========
- *
- * Siblings are stored in an obscure but incredibly elegant
- * data structure called a red-black tree. This is generally
- * defined as a 2-3-4 tree stored in a binary tree.
- *
- * A red-black tree can always be balanced very easily. The rules
- * for a red-black tree are as follows:
- *
- *     1. The root node is always black.
- *     2. The parent of a red node is always black.
- *
- * There is a Java demo of red-black trees at:
- *
- *     http://langevin.usc.edu/BST/RedBlackTree-Example.html
- *
- * This demo is an excellent tool for learning how red-black
- * trees work, without having to go through the process of
- * learning how they were derived.
- *
- * Within the tree, elements are ordered by the length of the
- * name and within that, ASCII order by name. This causes the
- * apparently bizarre reordering you see when you use dfview.
- *
- * This is a somewhat bizarre choice. It suggests that the
- * designer of the DocFile format was trying to optimise
- * searching through the directory entries. However searching
- * through directory entries is a relatively rare operation.
- * Reading and seeking within a stream are much more common
- * operations, especially within the file level streams, yet
- * these use the horrendously inefficient FAT chains.
- *
- * This suggests that the designer was probably somebody
- * fresh out of university, who had some basic knowledge of
- * basic data structures, but little knowledge of anything
- * more practical. It is bizarre to attempt to optimise
- * directory searches while not using a more efficient file
- * block locating system than FAT (seedling/sapling/tree
- * would result in a massive improvement - in fact we have
- * an alternative to docfiles that we use internally that
- * uses seedling/sapling/tree and *is* far more efficient).
- *
- * It is worth noting that the MS implementation of red-black
- * trees is incorrect (I can tell you're surprised) and
- * actually causes more operations to occur than are really
- * needed. Fortunately the fact that our implementation is
- * correct will not cause any problems - the MS implementation
- * still appears to cause the tree to satisfy the rules, albeit
- * a sequence of the same insertions in the different
- * implementations may result in a different, and possibly
- * deeper (but never shallower) tree.
- */
-
-typedef struct {
-       HANDLE          hf;
-       SEGPTR          lockbytes;
-} stream_access16;
-/* --- IStorage16 implementation struct */
-
-typedef struct
-{
-        /* IUnknown fields */
-        const IStorage16Vtbl           *lpVtbl;
-        LONG                            ref;
-        /* IStorage16 fields */
-        SEGPTR                          thisptr; /* pointer to this struct as segmented */
-        struct storage_pps_entry        stde;
-        int                             ppsent;
-       stream_access16                 str;
-} IStorage16Impl;
-
-
-/******************************************************************************
- *             STORAGE_get_big_block   [Internal]
- *
- * Reading OLE compound storage
- */
-static BOOL
-STORAGE_get_big_block(stream_access16 *str,int n,BYTE *block)
-{
-    DWORD result;
-
-    assert(n>=-1);
-    if (str->hf) {
-       if ((SetFilePointer( str->hf, (n+1)*BIGSIZE, NULL,
-                            SEEK_SET ) == INVALID_SET_FILE_POINTER) && GetLastError())
-       {
-            WARN("(%p,%d,%p), seek failed (%d)\n",str->hf, n, block, GetLastError());
-           return FALSE;
-       }
-       if (!ReadFile( str->hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE)
-       {
-            WARN("(hf=%p, block size %d): read didn't read (%d)\n",str->hf,n,GetLastError());
-           return FALSE;
-       }
-    } else {
-       DWORD args[6];
-       HRESULT hres;
-       HANDLE16 hsig;
-       
-       args[0] = (DWORD)str->lockbytes;        /* iface */
-       args[1] = (n+1)*BIGSIZE;
-       args[2] = 0;    /* ULARGE_INTEGER offset */
-       args[3] = WOWGlobalAllocLock16( 0, BIGSIZE, &hsig ); /* sig */
-       args[4] = BIGSIZE;
-       args[5] = 0;
-
-       if (!WOWCallback16Ex(
-           (DWORD)((const ILockBytes16Vtbl*)MapSL(
-                       (SEGPTR)((LPLOCKBYTES16)MapSL(str->lockbytes))->lpVtbl)
-           )->ReadAt,
-           WCB16_PASCAL,
-           6*sizeof(DWORD),
-           (LPVOID)args,
-           (LPDWORD)&hres
-       )) {
-            ERR("CallTo16 ILockBytes16::ReadAt() failed, hres %x\n",hres);
-           return FALSE;
-       }
-       memcpy(block, MapSL(args[3]), BIGSIZE);
-       WOWGlobalUnlockFree16(args[3]);
-    }
-    return TRUE;
-}
-
-static BOOL
-_ilockbytes16_writeat(SEGPTR lockbytes, DWORD offset, DWORD length, void *buffer) {
-    DWORD args[6];
-    HRESULT hres;
-
-    args[0] = (DWORD)lockbytes;        /* iface */
-    args[1] = offset;
-    args[2] = 0;       /* ULARGE_INTEGER offset */
-    args[3] = (DWORD)MapLS( buffer );
-    args[4] = length;
-    args[5] = 0;
-
-    /* THIS_ ULARGE_INTEGER ulOffset, const void *pv, ULONG cb, ULONG *pcbWritten); */
-
-    if (!WOWCallback16Ex(
-       (DWORD)((const ILockBytes16Vtbl*)MapSL(
-                   (SEGPTR)((LPLOCKBYTES16)MapSL(lockbytes))->lpVtbl)
-       )->WriteAt,
-       WCB16_PASCAL,
-       6*sizeof(DWORD),
-       (LPVOID)args,
-       (LPDWORD)&hres
-    )) {
-       ERR("CallTo16 ILockBytes16::WriteAt() failed, hres %x\n",hres);
-       return FALSE;
-    }
-    UnMapLS(args[3]);
-    return TRUE;
-}
-
-/******************************************************************************
- * STORAGE_put_big_block [INTERNAL]
- */
-static BOOL
-STORAGE_put_big_block(stream_access16 *str,int n,BYTE *block)
-{
-    DWORD result;
-
-    assert(n>=-1);
-    if (str->hf) {
-       if ((SetFilePointer( str->hf, (n+1)*BIGSIZE, NULL,
-                            SEEK_SET ) == INVALID_SET_FILE_POINTER) && GetLastError())
-       {
-            WARN("seek failed (%d)\n",GetLastError());
-           return FALSE;
-       }
-       if (!WriteFile( str->hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE)
-       {
-            WARN(" write failed (%d)\n",GetLastError());
-           return FALSE;
-       }
-       return TRUE;
-    } else {
-       _ilockbytes16_writeat(str->lockbytes, (n+1)*BIGSIZE, BIGSIZE, block);
-       return TRUE;
-    }
-}
-
-/******************************************************************************
- * STORAGE_get_next_big_blocknr [INTERNAL]
- */
-static int
-STORAGE_get_next_big_blocknr(stream_access16 *str,int blocknr) {
-       INT     bbs[BIGSIZE/sizeof(INT)];
-       struct  storage_header  sth;
-
-       READ_HEADER(str);
-
-       assert(blocknr>>7<sth.num_of_bbd_blocks);
-       if (sth.bbd_list[blocknr>>7]==0xffffffff)
-               return -5;
-       if (!STORAGE_get_big_block(str,sth.bbd_list[blocknr>>7],(LPBYTE)bbs))
-               return -5;
-       assert(bbs[blocknr&0x7f]!=STORAGE_CHAINENTRY_FREE);
-       return bbs[blocknr&0x7f];
-}
-
-/******************************************************************************
- * STORAGE_get_nth_next_big_blocknr [INTERNAL]
- */
-static int
-STORAGE_get_nth_next_big_blocknr(stream_access16 *str,int blocknr,int nr) {
-       INT     bbs[BIGSIZE/sizeof(INT)];
-       int     lastblock = -1;
-       struct storage_header sth;
-
-       TRACE("(blocknr=%d, nr=%d)\n", blocknr, nr);
-       READ_HEADER(str);
-
-       assert(blocknr>=0);
-       while (nr--) {
-               assert((blocknr>>7)<sth.num_of_bbd_blocks);
-               assert(sth.bbd_list[blocknr>>7]!=0xffffffff);
-
-               /* simple caching... */
-               if (lastblock!=sth.bbd_list[blocknr>>7]) {
-                       BOOL ret = STORAGE_get_big_block(str,sth.bbd_list[blocknr>>7],(LPBYTE)bbs);
-                       assert(ret);
-                       lastblock = sth.bbd_list[blocknr>>7];
-               }
-               blocknr = bbs[blocknr&0x7f];
-       }
-       return blocknr;
-}
-
-/******************************************************************************
- *             STORAGE_get_root_pps_entry      [Internal]
- */
-static BOOL
-STORAGE_get_root_pps_entry(stream_access16* str,struct storage_pps_entry *pstde) {
-       int     blocknr,i;
-       BYTE    block[BIGSIZE];
-       struct storage_pps_entry        *stde=(struct storage_pps_entry*)block;
-       struct storage_header sth;
-
-       READ_HEADER(str);
-       blocknr = sth.root_startblock;
-       TRACE("startblock is %d\n", blocknr);
-       while (blocknr>=0) {
-               BOOL ret = STORAGE_get_big_block(str,blocknr,block);
-               assert(ret);
-               for (i=0;i<4;i++) {
-                       if (!stde[i].pps_sizeofname)
-                               continue;
-                       if (stde[i].pps_type==5) {
-                               *pstde=stde[i];
-                               return TRUE;
-                       }
-               }
-               blocknr=STORAGE_get_next_big_blocknr(str,blocknr);
-               TRACE("next block is %d\n", blocknr);
-       }
-       return FALSE;
-}
-
-/******************************************************************************
- * STORAGE_get_small_block [INTERNAL]
- */
-static BOOL
-STORAGE_get_small_block(stream_access16 *str,int blocknr,BYTE *sblock) {
-       BYTE                            block[BIGSIZE];
-       int                             bigblocknr;
-       struct storage_pps_entry        root;
-       BOOL ret;
-
-       TRACE("(blocknr=%d)\n", blocknr);
-       assert(blocknr>=0);
-       ret = STORAGE_get_root_pps_entry(str,&root);
-       assert(ret);
-       bigblocknr = STORAGE_get_nth_next_big_blocknr(str,root.pps_sb,blocknr/SMALLBLOCKS_PER_BIGBLOCK);
-       assert(bigblocknr>=0);
-       ret = STORAGE_get_big_block(str,bigblocknr,block);
-       assert(ret);
-
-       memcpy(sblock,((LPBYTE)block)+SMALLSIZE*(blocknr&(SMALLBLOCKS_PER_BIGBLOCK-1)),SMALLSIZE);
-       return TRUE;
-}
-
-/******************************************************************************
- * STORAGE_put_small_block [INTERNAL]
- */
-static BOOL
-STORAGE_put_small_block(stream_access16 *str,int blocknr,const BYTE *sblock) {
-       BYTE                            block[BIGSIZE];
-       int                             bigblocknr;
-       struct storage_pps_entry        root;
-       BOOL ret;
-
-       assert(blocknr>=0);
-       TRACE("(blocknr=%d)\n", blocknr);
-
-       ret = STORAGE_get_root_pps_entry(str,&root);
-       assert(ret);
-       bigblocknr = STORAGE_get_nth_next_big_blocknr(str,root.pps_sb,blocknr/SMALLBLOCKS_PER_BIGBLOCK);
-       assert(bigblocknr>=0);
-       ret = STORAGE_get_big_block(str,bigblocknr,block);
-       assert(ret);
-
-       memcpy(((LPBYTE)block)+SMALLSIZE*(blocknr&(SMALLBLOCKS_PER_BIGBLOCK-1)),sblock,SMALLSIZE);
-       ret = STORAGE_put_big_block(str,bigblocknr,block);
-       assert(ret);
-       return TRUE;
-}
-
-/******************************************************************************
- * STORAGE_get_next_small_blocknr [INTERNAL]
- */
-static int
-STORAGE_get_next_small_blocknr(stream_access16 *str,int blocknr) {
-       BYTE                            block[BIGSIZE];
-       LPINT                           sbd = (LPINT)block;
-       int                             bigblocknr;
-       struct storage_header           sth;
-       BOOL ret;
-
-       TRACE("(blocknr=%d)\n", blocknr);
-       READ_HEADER(str);
-       assert(blocknr>=0);
-       bigblocknr = STORAGE_get_nth_next_big_blocknr(str,sth.sbd_startblock,blocknr/128);
-       assert(bigblocknr>=0);
-       ret = STORAGE_get_big_block(str,bigblocknr,block);
-       assert(ret);
-       assert(sbd[blocknr & 127]!=STORAGE_CHAINENTRY_FREE);
-       return sbd[blocknr & (128-1)];
-}
-
-/******************************************************************************
- * STORAGE_get_nth_next_small_blocknr [INTERNAL]
- */
-static int
-STORAGE_get_nth_next_small_blocknr(stream_access16*str,int blocknr,int nr) {
-       int     lastblocknr=-1;
-       BYTE    block[BIGSIZE];
-       LPINT   sbd = (LPINT)block;
-       struct storage_header sth;
-       BOOL ret;
-
-       TRACE("(blocknr=%d, nr=%d)\n", blocknr, nr);
-       READ_HEADER(str);
-       assert(blocknr>=0);
-       while ((nr--) && (blocknr>=0)) {
-               if (lastblocknr/128!=blocknr/128) {
-                       int     bigblocknr;
-                       bigblocknr = STORAGE_get_nth_next_big_blocknr(str,sth.sbd_startblock,blocknr/128);
-                       assert(bigblocknr>=0);
-                       ret = STORAGE_get_big_block(str,bigblocknr,block);
-                       assert(ret);
-                       lastblocknr = blocknr;
-               }
-               assert(lastblocknr>=0);
-               lastblocknr=blocknr;
-               blocknr=sbd[blocknr & (128-1)];
-               assert(blocknr!=STORAGE_CHAINENTRY_FREE);
-       }
-       return blocknr;
-}
-
-/******************************************************************************
- * STORAGE_get_pps_entry [INTERNAL]
- */
-static int
-STORAGE_get_pps_entry(stream_access16*str,int n,struct storage_pps_entry *pstde) {
-       int     blocknr;
-       BYTE    block[BIGSIZE];
-       struct storage_pps_entry *stde = (struct storage_pps_entry*)(((LPBYTE)block)+128*(n&3));
-       struct storage_header sth;
-       BOOL ret;
-
-       TRACE("(n=%d)\n", n);
-       READ_HEADER(str);
-       /* we have 4 pps entries per big block */
-       blocknr = STORAGE_get_nth_next_big_blocknr(str,sth.root_startblock,n/4);
-       assert(blocknr>=0);
-       ret = STORAGE_get_big_block(str,blocknr,block);
-       assert(ret);
-
-       *pstde=*stde;
-       return 1;
-}
-
-/******************************************************************************
- *             STORAGE_put_pps_entry   [Internal]
- */
-static int
-STORAGE_put_pps_entry(stream_access16*str,int n,const struct storage_pps_entry *pstde) {
-       int     blocknr;
-       BYTE    block[BIGSIZE];
-       struct storage_pps_entry *stde = (struct storage_pps_entry*)(((LPBYTE)block)+128*(n&3));
-       struct storage_header sth;
-       BOOL ret;
-
-       TRACE("(n=%d)\n", n);
-       READ_HEADER(str);
-       /* we have 4 pps entries per big block */
-       blocknr = STORAGE_get_nth_next_big_blocknr(str,sth.root_startblock,n/4);
-       assert(blocknr>=0);
-       ret = STORAGE_get_big_block(str,blocknr,block);
-       assert(ret);
-       *stde=*pstde;
-       ret = STORAGE_put_big_block(str,blocknr,block);
-       assert(ret);
-       return 1;
-}
-
-/******************************************************************************
- *             STORAGE_look_for_named_pps      [Internal]
- */
-static int
-STORAGE_look_for_named_pps(stream_access16*str,int n,LPOLESTR name) {
-       struct storage_pps_entry        stde;
-       int                             ret;
-
-       TRACE("(n=%d,name=%s)\n", n, debugstr_w(name));
-       if (n==-1)
-               return -1;
-       if (1!=STORAGE_get_pps_entry(str,n,&stde))
-               return -1;
-
-       if (!lstrcmpW(name,stde.pps_rawname))
-               return n;
-       if (stde.pps_prev != -1) {
-               ret=STORAGE_look_for_named_pps(str,stde.pps_prev,name);
-               if (ret!=-1)
-                       return ret;
-       }
-       if (stde.pps_next != -1) {
-               ret=STORAGE_look_for_named_pps(str,stde.pps_next,name);
-               if (ret!=-1)
-                       return ret;
-       }
-       return -1;
-}
-
-/******************************************************************************
- *             STORAGE_dump_pps_entry  [Internal]
- *
- * This function is there to simplify debugging. It is otherwise unused.
- */
-void
-STORAGE_dump_pps_entry(struct storage_pps_entry *stde) {
-    char       name[33];
-
-    WideCharToMultiByte( CP_ACP, 0, stde->pps_rawname, -1, name, sizeof(name), NULL, NULL);
-       if (!stde->pps_sizeofname)
-               return;
-       TRACE("name: %s\n",name);
-       TRACE("type: %d\n",stde->pps_type);
-       TRACE("prev pps: %d\n",stde->pps_prev);
-       TRACE("next pps: %d\n",stde->pps_next);
-       TRACE("dir pps: %d\n",stde->pps_dir);
-       TRACE("guid: %s\n",debugstr_guid(&(stde->pps_guid)));
-       if (stde->pps_type !=2) {
-               time_t  t;
-                DWORD dw;
-               RtlTimeToSecondsSince1970((LARGE_INTEGER *)&(stde->pps_ft1),&dw);
-                t = dw;
-               TRACE("ts1: %s\n",ctime(&t));
-               RtlTimeToSecondsSince1970((LARGE_INTEGER *)&(stde->pps_ft2),&dw);
-                t = dw;
-               TRACE("ts2: %s\n",ctime(&t));
-       }
-       TRACE("startblock: %d\n",stde->pps_sb);
-       TRACE("size: %d\n",stde->pps_size);
-}
-
-/******************************************************************************
- * STORAGE_init_storage [INTERNAL]
- */
-static BOOL
-STORAGE_init_storage(stream_access16 *str) {
-       BYTE    block[BIGSIZE];
-       LPDWORD bbs;
-       struct storage_header *sth;
-       struct storage_pps_entry *stde;
-        DWORD result;
-
-       if (str->hf)
-           SetFilePointer( str->hf, 0, NULL, SEEK_SET );
-       /* block -1 is the storage header */
-       sth = (struct storage_header*)block;
-       memcpy(sth->magic,STORAGE_magic,8);
-       memset(sth->unknown1,0,sizeof(sth->unknown1));
-       memset(sth->unknown2,0,sizeof(sth->unknown2));
-       memset(sth->unknown3,0,sizeof(sth->unknown3));
-       sth->num_of_bbd_blocks  = 1;
-       sth->root_startblock    = 1;
-       sth->sbd_startblock     = 0xffffffff;
-       memset(sth->bbd_list,0xff,sizeof(sth->bbd_list));
-       sth->bbd_list[0]        = 0;
-       if (str->hf) {
-           if (!WriteFile( str->hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE) return FALSE;
-       } else {
-           if (!_ilockbytes16_writeat(str->lockbytes, 0, BIGSIZE, block)) return FALSE;
-       }
-       /* block 0 is the big block directory */
-       bbs=(LPDWORD)block;
-       memset(block,0xff,sizeof(block)); /* mark all blocks as free */
-       bbs[0]=STORAGE_CHAINENTRY_ENDOFCHAIN; /* for this block */
-       bbs[1]=STORAGE_CHAINENTRY_ENDOFCHAIN; /* for directory entry */
-       if (str->hf) {
-           if (!WriteFile( str->hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE) return FALSE;
-       } else {
-           if (!_ilockbytes16_writeat(str->lockbytes, BIGSIZE, BIGSIZE, block)) return FALSE;
-       }
-       /* block 1 is the root directory entry */
-       memset(block,0x00,sizeof(block));
-       stde = (struct storage_pps_entry*)block;
-        MultiByteToWideChar( CP_ACP, 0, "RootEntry", -1, stde->pps_rawname,
-                             sizeof(stde->pps_rawname)/sizeof(WCHAR));
-       stde->pps_sizeofname    = (strlenW(stde->pps_rawname)+1) * sizeof(WCHAR);
-       stde->pps_type          = 5;
-       stde->pps_dir           = -1;
-       stde->pps_next          = -1;
-       stde->pps_prev          = -1;
-       stde->pps_sb            = 0xffffffff;
-       stde->pps_size          = 0;
-       if (str->hf) {
-           return (WriteFile( str->hf, block, BIGSIZE, &result, NULL ) && result == BIGSIZE);
-       } else {
-           return _ilockbytes16_writeat(str->lockbytes, BIGSIZE, BIGSIZE, block);
-       }
-}
-
-/******************************************************************************
- *             STORAGE_set_big_chain   [Internal]
- */
-static BOOL
-STORAGE_set_big_chain(stream_access16*str,int blocknr,INT type) {
-       BYTE    block[BIGSIZE];
-       LPINT   bbd = (LPINT)block;
-       int     nextblocknr,bigblocknr;
-       struct storage_header sth;
-       BOOL ret;
-
-       READ_HEADER(str);
-       assert(blocknr!=type);
-       while (blocknr>=0) {
-               bigblocknr = sth.bbd_list[blocknr/128];
-               assert(bigblocknr>=0);
-               ret = STORAGE_get_big_block(str,bigblocknr,block);
-               assert(ret);
-
-               nextblocknr = bbd[blocknr&(128-1)];
-               bbd[blocknr&(128-1)] = type;
-               if (type>=0)
-                       return TRUE;
-               ret = STORAGE_put_big_block(str,bigblocknr,block);
-               assert(ret);
-               type = STORAGE_CHAINENTRY_FREE;
-               blocknr = nextblocknr;
-       }
-       return TRUE;
-}
-
-/******************************************************************************
- * STORAGE_set_small_chain [Internal]
- */
-static BOOL
-STORAGE_set_small_chain(stream_access16*str,int blocknr,INT type) {
-       BYTE    block[BIGSIZE];
-       LPINT   sbd = (LPINT)block;
-       int     lastblocknr,nextsmallblocknr,bigblocknr;
-       struct storage_header sth;
-       BOOL ret;
-
-       READ_HEADER(str);
-
-       assert(blocknr!=type);
-       lastblocknr=-129;bigblocknr=-2;
-       while (blocknr>=0) {
-               /* cache block ... */
-               if (lastblocknr/128!=blocknr/128) {
-                       bigblocknr = STORAGE_get_nth_next_big_blocknr(str,sth.sbd_startblock,blocknr/128);
-                       assert(bigblocknr>=0);
-                       ret = STORAGE_get_big_block(str,bigblocknr,block);
-                       assert(ret);
-               }
-               lastblocknr = blocknr;
-               nextsmallblocknr = sbd[blocknr&(128-1)];
-               sbd[blocknr&(128-1)] = type;
-               ret = STORAGE_put_big_block(str,bigblocknr,block);
-               assert(ret);
-               if (type>=0)
-                       return TRUE;
-               type = STORAGE_CHAINENTRY_FREE;
-               blocknr = nextsmallblocknr;
-       }
-       return TRUE;
-}
-
-/******************************************************************************
- *             STORAGE_get_free_big_blocknr    [Internal]
- */
-static int
-STORAGE_get_free_big_blocknr(stream_access16 *str) {
-       BYTE    block[BIGSIZE];
-       LPINT   sbd = (LPINT)block;
-       int     lastbigblocknr,i,bigblocknr;
-       unsigned int curblock;
-       struct storage_header sth;
-       BOOL ret;
-
-       READ_HEADER(str);
-       curblock        = 0;
-       lastbigblocknr  = -1;
-       bigblocknr      = sth.bbd_list[curblock];
-       while (curblock<sth.num_of_bbd_blocks) {
-               assert(bigblocknr>=0);
-               ret = STORAGE_get_big_block(str,bigblocknr,block);
-               assert(ret);
-               for (i=0;i<128;i++)
-                       if (sbd[i]==STORAGE_CHAINENTRY_FREE) {
-                               sbd[i] = STORAGE_CHAINENTRY_ENDOFCHAIN;
-                               ret = STORAGE_put_big_block(str,bigblocknr,block);
-                               assert(ret);
-                               memset(block,0x42,sizeof(block));
-                               ret = STORAGE_put_big_block(str,i+curblock*128,block);
-                               assert(ret);
-                               return i+curblock*128;
-                       }
-               lastbigblocknr = bigblocknr;
-               bigblocknr = sth.bbd_list[++curblock];
-       }
-       bigblocknr = curblock*128;
-       /* since we have marked all blocks from 0 up to curblock*128-1
-        * the next free one is curblock*128, where we happily put our
-        * next large block depot.
-        */
-       memset(block,0xff,sizeof(block));
-       /* mark the block allocated and returned by this function */
-       sbd[1] = STORAGE_CHAINENTRY_ENDOFCHAIN;
-       ret = STORAGE_put_big_block(str,bigblocknr,block);
-       assert(ret);
-
-       /* if we had a bbd block already (mostlikely) we need
-        * to link the new one into the chain
-        */
-       if (lastbigblocknr!=-1) {
-               ret = STORAGE_set_big_chain(str,lastbigblocknr,bigblocknr);
-               assert(ret);
-       }
-       sth.bbd_list[curblock]=bigblocknr;
-       sth.num_of_bbd_blocks++;
-       assert(sth.num_of_bbd_blocks==curblock+1);
-       ret = STORAGE_put_big_block(str,-1,(LPBYTE)&sth);
-       assert(ret);
-
-       /* Set the end of the chain for the bigblockdepots */
-       ret = STORAGE_set_big_chain(str,bigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN);
-       assert(ret);
-       /* add 1, for the first entry is used for the additional big block
-        * depot. (means we already used bigblocknr) */
-       memset(block,0x42,sizeof(block));
-       /* allocate this block (filled with 0x42) */
-       ret = STORAGE_put_big_block(str,bigblocknr+1,block);
-       assert(ret);
-       return bigblocknr+1;
-}
-
-
-/******************************************************************************
- *             STORAGE_get_free_small_blocknr  [Internal]
- */
-static int
-STORAGE_get_free_small_blocknr(stream_access16 *str) {
-       BYTE    block[BIGSIZE];
-       LPINT   sbd = (LPINT)block;
-       int     lastbigblocknr,newblocknr,i,curblock,bigblocknr;
-       struct storage_pps_entry        root;
-       struct storage_header sth;
-
-       READ_HEADER(str);
-       bigblocknr      = sth.sbd_startblock;
-       curblock        = 0;
-       lastbigblocknr  = -1;
-       newblocknr      = -1;
-       while (bigblocknr>=0) {
-               if (!STORAGE_get_big_block(str,bigblocknr,block))
-                       return -1;
-               for (i=0;i<128;i++)
-                       if (sbd[i]==STORAGE_CHAINENTRY_FREE) {
-                               sbd[i]=STORAGE_CHAINENTRY_ENDOFCHAIN;
-                               newblocknr = i+curblock*128;
-                               break;
-                       }
-               if (i!=128)
-                       break;
-               lastbigblocknr = bigblocknr;
-               bigblocknr = STORAGE_get_next_big_blocknr(str,bigblocknr);
-               curblock++;
-       }
-       if (newblocknr==-1) {
-               bigblocknr = STORAGE_get_free_big_blocknr(str);
-               if (bigblocknr<0)
-                       return -1;
-               READ_HEADER(str);
-               memset(block,0xff,sizeof(block));
-               sbd[0]=STORAGE_CHAINENTRY_ENDOFCHAIN;
-               if (!STORAGE_put_big_block(str,bigblocknr,block))
-                       return -1;
-               if (lastbigblocknr==-1) {
-                       sth.sbd_startblock = bigblocknr;
-                       if (!STORAGE_put_big_block(str,-1,(LPBYTE)&sth)) /* need to write it */
-                               return -1;
-               } else {
-                       if (!STORAGE_set_big_chain(str,lastbigblocknr,bigblocknr))
-                               return -1;
-               }
-               if (!STORAGE_set_big_chain(str,bigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-                       return -1;
-               newblocknr = curblock*128;
-       }
-       /* allocate enough big blocks for storing the allocated small block */
-       if (!STORAGE_get_root_pps_entry(str,&root))
-               return -1;
-       if (root.pps_sb==-1)
-               lastbigblocknr  = -1;
-       else
-               lastbigblocknr  = STORAGE_get_nth_next_big_blocknr(str,root.pps_sb,(root.pps_size-1)/BIGSIZE);
-       while (root.pps_size < (newblocknr*SMALLSIZE+SMALLSIZE-1)) {
-               /* we need to allocate more stuff */
-               bigblocknr = STORAGE_get_free_big_blocknr(str);
-               if (bigblocknr<0)
-                       return -1;
-               READ_HEADER(str);
-               if (root.pps_sb==-1) {
-                       root.pps_sb      = bigblocknr;
-                       root.pps_size   += BIGSIZE;
-               } else {
-                       if (!STORAGE_set_big_chain(str,lastbigblocknr,bigblocknr))
-                               return -1;
-                       root.pps_size   += BIGSIZE;
-               }
-               lastbigblocknr = bigblocknr;
-       }
-       if (!STORAGE_set_big_chain(str,lastbigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-               return -1;
-       if (!STORAGE_put_pps_entry(str,0,&root))
-               return -1;
-       return newblocknr;
-}
-
-/******************************************************************************
- *             STORAGE_get_free_pps_entry      [Internal]
- */
-static int
-STORAGE_get_free_pps_entry(stream_access16*str) {
-       int     blocknr, i, curblock, lastblocknr=-1;
-       BYTE    block[BIGSIZE];
-       struct storage_pps_entry *stde = (struct storage_pps_entry*)block;
-       struct storage_header sth;
-
-       READ_HEADER(str);
-       blocknr = sth.root_startblock;
-       assert(blocknr>=0);
-       curblock=0;
-       while (blocknr>=0) {
-               if (!STORAGE_get_big_block(str,blocknr,block))
-                       return -1;
-               for (i=0;i<4;i++)
-                       if (stde[i].pps_sizeofname==0) /* free */
-                               return curblock*4+i;
-               lastblocknr = blocknr;
-               blocknr = STORAGE_get_next_big_blocknr(str,blocknr);
-               curblock++;
-       }
-       assert(blocknr==STORAGE_CHAINENTRY_ENDOFCHAIN);
-       blocknr = STORAGE_get_free_big_blocknr(str);
-       /* sth invalidated */
-       if (blocknr<0)
-               return -1;
-
-       if (!STORAGE_set_big_chain(str,lastblocknr,blocknr))
-               return -1;
-       if (!STORAGE_set_big_chain(str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-               return -1;
-       memset(block,0,sizeof(block));
-       STORAGE_put_big_block(str,blocknr,block);
-       return curblock*4;
-}
-
-/* --- IStream16 implementation */
-
-typedef struct
-{
-        /* IUnknown fields */
-        const IStream16Vtbl            *lpVtbl;
-        LONG                            ref;
-        /* IStream16 fields */
-        SEGPTR                          thisptr; /* pointer to this struct as segmented */
-        struct storage_pps_entry        stde;
-        int                             ppsent;
-        ULARGE_INTEGER                  offset;
-       stream_access16                 str;
-} IStream16Impl;
-
-/******************************************************************************
- *             IStream16_QueryInterface        [STORAGE.518]
- */
-HRESULT CDECL IStream16_fnQueryInterface(
-       IStream16* iface,REFIID refiid,LPVOID *obj
-) {
-       IStream16Impl *This = (IStream16Impl *)iface;
-       TRACE_(relay)("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
-       if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
-               *obj = This;
-               return 0;
-       }
-       return OLE_E_ENUM_NOMORE;
-
-}
-
-/******************************************************************************
- * IStream16_AddRef [STORAGE.519]
- */
-ULONG CDECL IStream16_fnAddRef(IStream16* iface) {
-       IStream16Impl *This = (IStream16Impl *)iface;
-       return InterlockedIncrement(&This->ref);
-}
-
-static void
-_ilockbytes16_addref(SEGPTR lockbytes) {
-    DWORD args[1];
-    HRESULT hres;
-    
-    args[0] = (DWORD)lockbytes;        /* iface */
-    if (!WOWCallback16Ex(
-       (DWORD)((const ILockBytes16Vtbl*)MapSL(
-                   (SEGPTR)((LPLOCKBYTES16)MapSL(lockbytes))->lpVtbl)
-       )->AddRef,
-       WCB16_PASCAL,
-       1*sizeof(DWORD),
-       (LPVOID)args,
-       (LPDWORD)&hres
-    ))
-       ERR("CallTo16 ILockBytes16::AddRef() failed, hres %x\n",hres);
-}
-
-static void
-_ilockbytes16_release(SEGPTR lockbytes) {
-    DWORD args[1];
-    HRESULT hres;
-    
-    args[0] = (DWORD)lockbytes;        /* iface */
-    if (!WOWCallback16Ex(
-       (DWORD)((const ILockBytes16Vtbl*)MapSL(
-                   (SEGPTR)((LPLOCKBYTES16)MapSL(lockbytes))->lpVtbl)
-       )->Release,
-       WCB16_PASCAL,
-       1*sizeof(DWORD),
-       (LPVOID)args,
-       (LPDWORD)&hres
-    ))
-       ERR("CallTo16 ILockBytes16::Release() failed, hres %x\n",hres);
-}
-
-static void
-_ilockbytes16_flush(SEGPTR lockbytes) {
-    DWORD args[1];
-    HRESULT hres;
-    
-    args[0] = (DWORD)lockbytes;        /* iface */
-    if (!WOWCallback16Ex(
-       (DWORD)((const ILockBytes16Vtbl*)MapSL(
-                   (SEGPTR)((LPLOCKBYTES16)MapSL(lockbytes))->lpVtbl)
-       )->Flush,
-       WCB16_PASCAL,
-       1*sizeof(DWORD),
-       (LPVOID)args,
-       (LPDWORD)&hres
-    ))
-       ERR("CallTo16 ILockBytes16::Flush() failed, hres %x\n",hres);
-}
-
-/******************************************************************************
- * IStream16_Release [STORAGE.520]
- */
-ULONG CDECL IStream16_fnRelease(IStream16* iface) {
-       IStream16Impl *This = (IStream16Impl *)iface;
-        ULONG ref;
-
-       if (This->str.hf)
-           FlushFileBuffers(This->str.hf);
-       else
-           _ilockbytes16_flush(This->str.lockbytes);
-        ref = InterlockedDecrement(&This->ref);
-       if (ref)
-           return ref;
-
-       if (This->str.hf)
-           CloseHandle(This->str.hf);
-       else
-           _ilockbytes16_release(This->str.lockbytes);
-        UnMapLS( This->thisptr );
-       HeapFree( GetProcessHeap(), 0, This );
-       return 0;
-}
-
-/******************************************************************************
- *             IStream16_Seek  [STORAGE.523]
- *
- * FIXME
- *    Does not handle 64 bits
- */
-HRESULT CDECL IStream16_fnSeek(
-       IStream16* iface,LARGE_INTEGER offset,DWORD whence,ULARGE_INTEGER *newpos
-) {
-       IStream16Impl *This = (IStream16Impl *)iface;
-       TRACE_(relay)("(%p)->([%d.%d],%d,%p)\n",This,offset.u.HighPart,offset.u.LowPart,whence,newpos);
-
-       switch (whence) {
-       /* unix SEEK_xx should be the same as win95 ones */
-       case SEEK_SET:
-               /* offset must be ==0 (<0 is invalid, and >0 cannot be handled
-                * right now.
-                */
-               assert(offset.u.HighPart==0);
-               This->offset.u.HighPart = offset.u.HighPart;
-               This->offset.u.LowPart = offset.u.LowPart;
-               break;
-       case SEEK_CUR:
-               if (offset.u.HighPart < 0) {
-                       /* FIXME: is this negation correct ? */
-                       offset.u.HighPart = -offset.u.HighPart;
-                       offset.u.LowPart = (0xffffffff ^ offset.u.LowPart)+1;
-
-                       assert(offset.u.HighPart==0);
-                       assert(This->offset.u.LowPart >= offset.u.LowPart);
-                       This->offset.u.LowPart -= offset.u.LowPart;
-               } else {
-                       assert(offset.u.HighPart==0);
-                       This->offset.u.LowPart+= offset.u.LowPart;
-               }
-               break;
-       case SEEK_END:
-               assert(offset.u.HighPart==0);
-               This->offset.u.LowPart = This->stde.pps_size-offset.u.LowPart;
-               break;
-       }
-       if (This->offset.u.LowPart>This->stde.pps_size)
-               This->offset.u.LowPart=This->stde.pps_size;
-       if (newpos) *newpos = This->offset;
-       return S_OK;
-}
-
-/******************************************************************************
- *             IStream16_Read  [STORAGE.521]
- */
-HRESULT CDECL IStream16_fnRead(
-        IStream16* iface,void  *pv,ULONG cb,ULONG  *pcbRead
-) {
-       IStream16Impl *This = (IStream16Impl *)iface;
-       BYTE    block[BIGSIZE];
-       ULONG   *bytesread=pcbRead,xxread;
-       int     blocknr;
-       LPBYTE  pbv = pv;
-
-       TRACE_(relay)("(%p)->(%p,%d,%p)\n",This,pv,cb,pcbRead);
-       if (!pcbRead) bytesread=&xxread;
-       *bytesread = 0;
-
-       if (cb>This->stde.pps_size-This->offset.u.LowPart)
-               cb=This->stde.pps_size-This->offset.u.LowPart;
-       if (This->stde.pps_size < 0x1000) {
-               /* use small block reader */
-               blocknr = STORAGE_get_nth_next_small_blocknr(&This->str,This->stde.pps_sb,This->offset.u.LowPart/SMALLSIZE);
-               while (cb) {
-                       unsigned int cc;
-
-                       if (!STORAGE_get_small_block(&This->str,blocknr,block)) {
-                          WARN("small block read failed!!!\n");
-                               return E_FAIL;
-                       }
-                       cc = cb;
-                       if (cc>SMALLSIZE-(This->offset.u.LowPart&(SMALLSIZE-1)))
-                               cc=SMALLSIZE-(This->offset.u.LowPart&(SMALLSIZE-1));
-                       memcpy(pbv,block+(This->offset.u.LowPart&(SMALLSIZE-1)),cc);
-                       This->offset.u.LowPart+=cc;
-                       pbv+=cc;
-                       *bytesread+=cc;
-                       cb-=cc;
-                       blocknr = STORAGE_get_next_small_blocknr(&This->str,blocknr);
-               }
-       } else {
-               /* use big block reader */
-               blocknr = STORAGE_get_nth_next_big_blocknr(&This->str,This->stde.pps_sb,This->offset.u.LowPart/BIGSIZE);
-               while (cb) {
-                       unsigned int cc;
-
-                       if (!STORAGE_get_big_block(&This->str,blocknr,block)) {
-                               WARN("big block read failed!!!\n");
-                               return E_FAIL;
-                       }
-                       cc = cb;
-                       if (cc>BIGSIZE-(This->offset.u.LowPart&(BIGSIZE-1)))
-                               cc=BIGSIZE-(This->offset.u.LowPart&(BIGSIZE-1));
-                       memcpy(pbv,block+(This->offset.u.LowPart&(BIGSIZE-1)),cc);
-                       This->offset.u.LowPart+=cc;
-                       pbv+=cc;
-                       *bytesread+=cc;
-                       cb-=cc;
-                       blocknr=STORAGE_get_next_big_blocknr(&This->str,blocknr);
-               }
-       }
-       return S_OK;
-}
-
-/******************************************************************************
- *             IStream16_Write [STORAGE.522]
- */
-HRESULT CDECL IStream16_fnWrite(
-        IStream16* iface,const void *pv,ULONG cb,ULONG *pcbWrite
-) {
-       IStream16Impl *This = (IStream16Impl *)iface;
-       BYTE    block[BIGSIZE];
-       ULONG   *byteswritten=pcbWrite,xxwritten;
-       int     oldsize,newsize,i,curoffset=0,lastblocknr,blocknr,cc;
-       const BYTE* pbv = pv;
-
-       if (!pcbWrite) byteswritten=&xxwritten;
-       *byteswritten = 0;
-
-       TRACE_(relay)("(%p)->(%p,%d,%p)\n",This,pv,cb,pcbWrite);
-       /* do we need to junk some blocks? */
-       newsize = This->offset.u.LowPart+cb;
-       oldsize = This->stde.pps_size;
-       if (newsize < oldsize) {
-               if (oldsize < 0x1000) {
-                       /* only small blocks */
-                       blocknr=STORAGE_get_nth_next_small_blocknr(&This->str,This->stde.pps_sb,newsize/SMALLSIZE);
-
-                       assert(blocknr>=0);
-
-                       /* will set the rest of the chain to 'free' */
-                       if (!STORAGE_set_small_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-                               return E_FAIL;
-               } else {
-                       if (newsize >= 0x1000) {
-                               blocknr=STORAGE_get_nth_next_big_blocknr(&This->str,This->stde.pps_sb,newsize/BIGSIZE);
-                               assert(blocknr>=0);
-
-                               /* will set the rest of the chain to 'free' */
-                               if (!STORAGE_set_big_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-                                       return E_FAIL;
-                       } else {
-                               /* Migrate large blocks to small blocks
-                                * (we just migrate newsize bytes)
-                                */
-                               LPBYTE  curdata,data = HeapAlloc(GetProcessHeap(),0,newsize+BIGSIZE);
-                               HRESULT r = E_FAIL;
-
-                               cc      = newsize;
-                               blocknr = This->stde.pps_sb;
-                               curdata = data;
-                               while (cc>0) {
-                                       if (!STORAGE_get_big_block(&This->str,blocknr,curdata)) {
-                                               HeapFree(GetProcessHeap(),0,data);
-                                               return E_FAIL;
-                                       }
-                                       curdata += BIGSIZE;
-                                       cc      -= BIGSIZE;
-                                       blocknr  = STORAGE_get_next_big_blocknr(&This->str,blocknr);
-                               }
-                               /* frees complete chain for this stream */
-                               if (!STORAGE_set_big_chain(&This->str,This->stde.pps_sb,STORAGE_CHAINENTRY_FREE))
-                                       goto err;
-                               curdata = data;
-                               blocknr = This->stde.pps_sb = STORAGE_get_free_small_blocknr(&This->str);
-                               if (blocknr<0)
-                                       goto err;
-                               cc      = newsize;
-                               while (cc>0) {
-                                       if (!STORAGE_put_small_block(&This->str,blocknr,curdata))
-                                               goto err;
-                                       cc      -= SMALLSIZE;
-                                       if (cc<=0) {
-                                               if (!STORAGE_set_small_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-                                                       goto err;
-                                               break;
-                                       } else {
-                                               int newblocknr = STORAGE_get_free_small_blocknr(&This->str);
-                                               if (newblocknr<0)
-                                                       goto err;
-                                               if (!STORAGE_set_small_chain(&This->str,blocknr,newblocknr))
-                                                       goto err;
-                                               blocknr = newblocknr;
-                                       }
-                                       curdata += SMALLSIZE;
-                               }
-                               r = S_OK;
-                       err:
-                               HeapFree(GetProcessHeap(),0,data);
-                               if(r != S_OK)
-                                       return r;
-                       }
-               }
-               This->stde.pps_size = newsize;
-       }
-
-       if (newsize > oldsize) {
-               if (oldsize >= 0x1000) {
-                       /* should return the block right before the 'endofchain' */
-                       blocknr = STORAGE_get_nth_next_big_blocknr(&This->str,This->stde.pps_sb,This->stde.pps_size/BIGSIZE);
-                       assert(blocknr>=0);
-                       lastblocknr     = blocknr;
-                       for (i=oldsize/BIGSIZE;i<newsize/BIGSIZE;i++) {
-                               blocknr = STORAGE_get_free_big_blocknr(&This->str);
-                               if (blocknr<0)
-                                       return E_FAIL;
-                               if (!STORAGE_set_big_chain(&This->str,lastblocknr,blocknr))
-                                       return E_FAIL;
-                               lastblocknr = blocknr;
-                       }
-                       if (!STORAGE_set_big_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-                               return E_FAIL;
-               } else {
-                       if (newsize < 0x1000) {
-                               /* find startblock */
-                               if (!oldsize)
-                                       This->stde.pps_sb = blocknr = STORAGE_get_free_small_blocknr(&This->str);
-                               else
-                                       blocknr = STORAGE_get_nth_next_small_blocknr(&This->str,This->stde.pps_sb,This->stde.pps_size/SMALLSIZE);
-                               if (blocknr<0)
-                                       return E_FAIL;
-
-                               /* allocate required new small blocks */
-                               lastblocknr = blocknr;
-                               for (i=oldsize/SMALLSIZE;i<newsize/SMALLSIZE;i++) {
-                                       blocknr = STORAGE_get_free_small_blocknr(&This->str);
-                                       if (blocknr<0)
-                                               return E_FAIL;
-                                       if (!STORAGE_set_small_chain(&This->str,lastblocknr,blocknr))
-                                               return E_FAIL;
-                                       lastblocknr = blocknr;
-                               }
-                               /* and terminate the chain */
-                               if (!STORAGE_set_small_chain(&This->str,lastblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-                                       return E_FAIL;
-                       } else {
-                               if (!oldsize) {
-                                       /* no single block allocated yet */
-                                       blocknr=STORAGE_get_free_big_blocknr(&This->str);
-                                       if (blocknr<0)
-                                               return E_FAIL;
-                                       This->stde.pps_sb = blocknr;
-                               } else {
-                                       /* Migrate small blocks to big blocks */
-                                       LPBYTE  curdata,data = HeapAlloc(GetProcessHeap(),0,oldsize+BIGSIZE);
-                                       HRESULT r = E_FAIL;
-
-                                       cc      = oldsize;
-                                       blocknr = This->stde.pps_sb;
-                                       curdata = data;
-                                       /* slurp in */
-                                       while (cc>0) {
-                                               if (!STORAGE_get_small_block(&This->str,blocknr,curdata))
-                                                       goto err2;
-                                               curdata += SMALLSIZE;
-                                               cc      -= SMALLSIZE;
-                                               blocknr  = STORAGE_get_next_small_blocknr(&This->str,blocknr);
-                                       }
-                                       /* free small block chain */
-                                       if (!STORAGE_set_small_chain(&This->str,This->stde.pps_sb,STORAGE_CHAINENTRY_FREE))
-                                               goto err2;
-                                       curdata = data;
-                                       blocknr = This->stde.pps_sb = STORAGE_get_free_big_blocknr(&This->str);
-                                       if (blocknr<0)
-                                               goto err2;
-                                       /* put the data into the big blocks */
-                                       cc      = This->stde.pps_size;
-                                       while (cc>0) {
-                                               if (!STORAGE_put_big_block(&This->str,blocknr,curdata))
-                                                       goto err2;
-                                               cc      -= BIGSIZE;
-                                               if (cc<=0) {
-                                                       if (!STORAGE_set_big_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-                                                               goto err2;
-                                                       break;
-                                               } else {
-                                                       int newblocknr = STORAGE_get_free_big_blocknr(&This->str);
-                                                       if (newblocknr<0)
-                                                               goto err2;
-                                                       if (!STORAGE_set_big_chain(&This->str,blocknr,newblocknr))
-                                                               goto err2;
-                                                       blocknr = newblocknr;
-                                               }
-                                               curdata += BIGSIZE;
-                                       }
-                                       r = S_OK;
-                               err2:
-                                       HeapFree(GetProcessHeap(),0,data);
-                                       if(r != S_OK)
-                                               return r;
-                               }
-                               /* generate big blocks to fit the new data */
-                               lastblocknr     = blocknr;
-                               for (i=oldsize/BIGSIZE;i<newsize/BIGSIZE;i++) {
-                                       blocknr = STORAGE_get_free_big_blocknr(&This->str);
-                                       if (blocknr<0)
-                                               return E_FAIL;
-                                       if (!STORAGE_set_big_chain(&This->str,lastblocknr,blocknr))
-                                               return E_FAIL;
-                                       lastblocknr = blocknr;
-                               }
-                               /* terminate chain */
-                               if (!STORAGE_set_big_chain(&This->str,lastblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
-                                       return E_FAIL;
-                       }
-               }
-               This->stde.pps_size = newsize;
-       }
-
-       /* There are just some cases where we didn't modify it, we write it out
-        * everytime
-        */
-       if (!STORAGE_put_pps_entry(&This->str,This->ppsent,&(This->stde)))
-               return E_FAIL;
-
-       /* finally the write pass */
-       if (This->stde.pps_size < 0x1000) {
-               blocknr = STORAGE_get_nth_next_small_blocknr(&This->str,This->stde.pps_sb,This->offset.u.LowPart/SMALLSIZE);
-               assert(blocknr>=0);
-               while (cb>0) {
-                       /* we ensured that it is allocated above */
-                       assert(blocknr>=0);
-                       /* Read old block everytime, since we can have
-                        * overlapping data at START and END of the write
-                        */
-                       if (!STORAGE_get_small_block(&This->str,blocknr,block))
-                               return E_FAIL;
-
-                       cc = SMALLSIZE-(This->offset.u.LowPart&(SMALLSIZE-1));
-                       if (cc>cb)
-                               cc=cb;
-                       memcpy( ((LPBYTE)block)+(This->offset.u.LowPart&(SMALLSIZE-1)),
-                               pbv+curoffset,
-                               cc
-                       );
-                       if (!STORAGE_put_small_block(&This->str,blocknr,block))
-                               return E_FAIL;
-                       cb                      -= cc;
-                       curoffset               += cc;
-                       pbv                     += cc;
-                       This->offset.u.LowPart  += cc;
-                       *byteswritten           += cc;
-                       blocknr = STORAGE_get_next_small_blocknr(&This->str,blocknr);
-               }
-       } else {
-               blocknr = STORAGE_get_nth_next_big_blocknr(&This->str,This->stde.pps_sb,This->offset.u.LowPart/BIGSIZE);
-               assert(blocknr>=0);
-               while (cb>0) {
-                       /* we ensured that it is allocated above, so it better is */
-                       assert(blocknr>=0);
-                       /* read old block everytime, since we can have
-                        * overlapping data at START and END of the write
-                        */
-                       if (!STORAGE_get_big_block(&This->str,blocknr,block))
-                               return E_FAIL;
-
-                       cc = BIGSIZE-(This->offset.u.LowPart&(BIGSIZE-1));
-                       if (cc>cb)
-                               cc=cb;
-                       memcpy( ((LPBYTE)block)+(This->offset.u.LowPart&(BIGSIZE-1)),
-                               pbv+curoffset,
-                               cc
-                       );
-                       if (!STORAGE_put_big_block(&This->str,blocknr,block))
-                               return E_FAIL;
-                       cb                      -= cc;
-                       curoffset               += cc;
-                       pbv                     += cc;
-                       This->offset.u.LowPart  += cc;
-                       *byteswritten           += cc;
-                       blocknr = STORAGE_get_next_big_blocknr(&This->str,blocknr);
-               }
-       }
-       return S_OK;
-}
-
-/******************************************************************************
- *             _create_istream16       [Internal]
- */
-static void _create_istream16(LPSTREAM16 *str) {
-       IStream16Impl*  lpst;
-
-       if (!strvt16.QueryInterface) {
-               HMODULE16       wp = GetModuleHandle16("STORAGE");
-               if (wp>=32) {
-                 /* FIXME: what is This GetProcAddress16. Should the name be IStream16_QueryInterface of IStream16_fnQueryInterface */
-#define VTENT(xfn)  strvt16.xfn = (void*)GetProcAddress16(wp,"IStream16_"#xfn);assert(strvt16.xfn)
-                       VTENT(QueryInterface);
-                       VTENT(AddRef);
-                       VTENT(Release);
-                       VTENT(Read);
-                       VTENT(Write);
-                       VTENT(Seek);
-                       VTENT(SetSize);
-                       VTENT(CopyTo);
-                       VTENT(Commit);
-                       VTENT(Revert);
-                       VTENT(LockRegion);
-                       VTENT(UnlockRegion);
-                       VTENT(Stat);
-                       VTENT(Clone);
-#undef VTENT
-                       segstrvt16 = (const IStream16Vtbl*)MapLS( &strvt16 );
-               } else {
-#define VTENT(xfn) strvt16.xfn = IStream16_fn##xfn;
-                       VTENT(QueryInterface);
-                       VTENT(AddRef);
-                       VTENT(Release);
-                       VTENT(Read);
-                       VTENT(Write);
-                       VTENT(Seek);
-       /*
-                       VTENT(CopyTo);
-                       VTENT(Commit);
-                       VTENT(SetSize);
-                       VTENT(Revert);
-                       VTENT(LockRegion);
-                       VTENT(UnlockRegion);
-                       VTENT(Stat);
-                       VTENT(Clone);
-       */
-#undef VTENT
-                       segstrvt16 = &strvt16;
-               }
-       }
-       lpst = HeapAlloc( GetProcessHeap(), 0, sizeof(*lpst) );
-       lpst->lpVtbl    = segstrvt16;
-       lpst->ref       = 1;
-       lpst->thisptr   = MapLS( lpst );
-       lpst->str.hf    = NULL;
-       lpst->str.lockbytes     = 0;
-       *str = (void*)lpst->thisptr;
-}
-
-
-/* --- IStream32 implementation */
-
-typedef struct
-{
-        /* IUnknown fields */
-        const IStreamVtbl              *lpVtbl;
-        LONG                            ref;
-        /* IStream32 fields */
-        struct storage_pps_entry        stde;
-        int                             ppsent;
-        HANDLE                          hf;
-        ULARGE_INTEGER                  offset;
-} IStream32Impl;
-
-/******************************************************************************
- *             IStorage16_QueryInterface       [STORAGE.500]
- */
-HRESULT CDECL IStorage16_fnQueryInterface(
-       IStorage16* iface,REFIID refiid,LPVOID *obj
-) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-
-       TRACE_(relay)("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
-
-       if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
-               *obj = This;
-               return 0;
-       }
-       return OLE_E_ENUM_NOMORE;
-}
-
-/******************************************************************************
- * IStorage16_AddRef [STORAGE.501]
- */
-ULONG CDECL IStorage16_fnAddRef(IStorage16* iface) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-       return InterlockedIncrement(&This->ref);
-}
-
-/******************************************************************************
- * IStorage16_Release [STORAGE.502]
- */
-ULONG CDECL IStorage16_fnRelease(IStorage16* iface) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-        ULONG ref;
-        ref = InterlockedDecrement(&This->ref);
-        if (!ref)
-        {
-            UnMapLS( This->thisptr );
-            HeapFree( GetProcessHeap(), 0, This );
-        }
-        return ref;
-}
-
-/******************************************************************************
- * IStorage16_Stat [STORAGE.517]
- */
-HRESULT CDECL IStorage16_fnStat(
-        LPSTORAGE16 iface,STATSTG16 *pstatstg, DWORD grfStatFlag
-) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-        DWORD len = WideCharToMultiByte( CP_ACP, 0, This->stde.pps_rawname, -1, NULL, 0, NULL, NULL );
-        LPSTR nameA = HeapAlloc( GetProcessHeap(), 0, len );
-
-       TRACE("(%p)->(%p,0x%08x)\n",
-               This,pstatstg,grfStatFlag
-       );
-        WideCharToMultiByte( CP_ACP, 0, This->stde.pps_rawname, -1, nameA, len, NULL, NULL );
-       pstatstg->pwcsName=(LPOLESTR16)MapLS( nameA );
-       pstatstg->type = This->stde.pps_type;
-       pstatstg->cbSize.u.LowPart = This->stde.pps_size;
-       pstatstg->mtime = This->stde.pps_ft1; /* FIXME */ /* why? */
-       pstatstg->atime = This->stde.pps_ft2; /* FIXME */
-       pstatstg->ctime = This->stde.pps_ft2; /* FIXME */
-       pstatstg->grfMode       = 0; /* FIXME */
-       pstatstg->grfLocksSupported = 0; /* FIXME */
-       pstatstg->clsid         = This->stde.pps_guid;
-       pstatstg->grfStateBits  = 0; /* FIXME */
-       pstatstg->reserved      = 0;
-       return S_OK;
-}
-
-/******************************************************************************
- *             IStorage16_Commit       [STORAGE.509]
- */
-HRESULT CDECL IStorage16_fnCommit(
-        LPSTORAGE16 iface,DWORD commitflags
-) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-       FIXME("(%p)->(0x%08x),STUB!\n",
-               This,commitflags
-       );
-       return S_OK;
-}
-
-/******************************************************************************
- * IStorage16_CopyTo [STORAGE.507]
- */
-HRESULT CDECL IStorage16_fnCopyTo(LPSTORAGE16 iface,DWORD ciidExclude,const IID *rgiidExclude,SNB16 SNB16Exclude,IStorage16 *pstgDest) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-       FIXME("IStorage16(%p)->(0x%08x,%s,%p,%p),stub!\n",
-               This,ciidExclude,debugstr_guid(rgiidExclude),SNB16Exclude,pstgDest
-       );
-       return S_OK;
-}
-
-
-/******************************************************************************
- * IStorage16_CreateStorage [STORAGE.505]
- */
-HRESULT CDECL IStorage16_fnCreateStorage(
-       LPSTORAGE16 iface,LPCOLESTR16 pwcsName,DWORD grfMode,DWORD dwStgFormat,DWORD reserved2, IStorage16 **ppstg
-) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-       IStorage16Impl* lpstg;
-       int             ppsent,x;
-       struct storage_pps_entry        stde;
-       struct storage_header sth;
-       BOOL ret;
-       int      nPPSEntries;
-
-       READ_HEADER(&This->str);
-       TRACE("(%p)->(%s,0x%08x,0x%08x,0x%08x,%p)\n",
-               This,pwcsName,grfMode,dwStgFormat,reserved2,ppstg
-       );
-       if (grfMode & STGM_TRANSACTED)
-               FIXME("We do not support transacted Compound Storage. Using direct mode.\n");
-       _create_istorage16(ppstg);
-       lpstg = MapSL((SEGPTR)*ppstg);
-       if (This->str.hf) {
-           DuplicateHandle( GetCurrentProcess(), This->str.hf, GetCurrentProcess(),
-                            &lpstg->str.hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
-       } else {
-           lpstg->str.lockbytes = This->str.lockbytes;
-           _ilockbytes16_addref(This->str.lockbytes);
-       }
-
-       ppsent=STORAGE_get_free_pps_entry(&lpstg->str);
-       if (ppsent<0)
-               return E_FAIL;
-       stde=This->stde;
-       if (stde.pps_dir==-1) {
-               stde.pps_dir = ppsent;
-               x = This->ppsent;
-       } else {
-               FIXME(" use prev chain too ?\n");
-               x=stde.pps_dir;
-               if (1!=STORAGE_get_pps_entry(&lpstg->str,x,&stde))
-                       return E_FAIL;
-               while (stde.pps_next!=-1) {
-                       x=stde.pps_next;
-                       if (1!=STORAGE_get_pps_entry(&lpstg->str,x,&stde))
-                               return E_FAIL;
-               }
-               stde.pps_next = ppsent;
-       }
-       ret = STORAGE_put_pps_entry(&lpstg->str,x,&stde);
-       assert(ret);
-       nPPSEntries = STORAGE_get_pps_entry(&lpstg->str,ppsent,&(lpstg->stde));
-       assert(nPPSEntries == 1);
-        MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, lpstg->stde.pps_rawname,
-                             sizeof(lpstg->stde.pps_rawname)/sizeof(WCHAR));
-       lpstg->stde.pps_sizeofname = (strlenW(lpstg->stde.pps_rawname)+1)*sizeof(WCHAR);
-       lpstg->stde.pps_next    = -1;
-       lpstg->stde.pps_prev    = -1;
-       lpstg->stde.pps_dir     = -1;
-       lpstg->stde.pps_sb      = -1;
-       lpstg->stde.pps_size    =  0;
-       lpstg->stde.pps_type    =  1;
-       lpstg->ppsent           = ppsent;
-       /* FIXME: timestamps? */
-       if (!STORAGE_put_pps_entry(&lpstg->str,ppsent,&(lpstg->stde)))
-               return E_FAIL;
-       return S_OK;
-}
-
-/******************************************************************************
- *             IStorage16_CreateStream [STORAGE.503]
- */
-HRESULT CDECL IStorage16_fnCreateStream(
-       LPSTORAGE16 iface,LPCOLESTR16 pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2, IStream16 **ppstm
-) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-       IStream16Impl*  lpstr;
-       int             ppsent,x;
-       struct storage_pps_entry        stde;
-       BOOL ret;
-       int      nPPSEntries;
-
-       TRACE("(%p)->(%s,0x%08x,0x%08x,0x%08x,%p)\n",
-               This,pwcsName,grfMode,reserved1,reserved2,ppstm
-       );
-       if (grfMode & STGM_TRANSACTED)
-               FIXME("We do not support transacted Compound Storage. Using direct mode.\n");
-       _create_istream16(ppstm);
-       lpstr = MapSL((SEGPTR)*ppstm);
-       if (This->str.hf) {
-           DuplicateHandle( GetCurrentProcess(), This->str.hf, GetCurrentProcess(),
-                            &lpstr->str.hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
-       } else {
-           lpstr->str.lockbytes = This->str.lockbytes;
-           _ilockbytes16_addref(This->str.lockbytes);
-       }
-       lpstr->offset.u.LowPart = 0;
-       lpstr->offset.u.HighPart= 0;
-
-       ppsent=STORAGE_get_free_pps_entry(&lpstr->str);
-       if (ppsent<0)
-               return E_FAIL;
-       stde=This->stde;
-       if (stde.pps_next==-1)
-               x=This->ppsent;
-       else
-               while (stde.pps_next!=-1) {
-                       x=stde.pps_next;
-                       if (1!=STORAGE_get_pps_entry(&lpstr->str,x,&stde))
-                               return E_FAIL;
-               }
-       stde.pps_next = ppsent;
-       ret = STORAGE_put_pps_entry(&lpstr->str,x,&stde);
-       assert(ret);
-       nPPSEntries = STORAGE_get_pps_entry(&lpstr->str,ppsent,&(lpstr->stde));
-       assert(nPPSEntries == 1);
-        MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, lpstr->stde.pps_rawname,
-                             sizeof(lpstr->stde.pps_rawname)/sizeof(WCHAR));
-       lpstr->stde.pps_sizeofname = (strlenW(lpstr->stde.pps_rawname)+1) * sizeof(WCHAR);
-       lpstr->stde.pps_next    = -1;
-       lpstr->stde.pps_prev    = -1;
-       lpstr->stde.pps_dir     = -1;
-       lpstr->stde.pps_sb      = -1;
-       lpstr->stde.pps_size    =  0;
-       lpstr->stde.pps_type    =  2;
-       lpstr->ppsent           = ppsent;
-
-       /* FIXME: timestamps? */
-       if (!STORAGE_put_pps_entry(&lpstr->str,ppsent,&(lpstr->stde)))
-               return E_FAIL;
-       return S_OK;
-}
-
-/******************************************************************************
- *             IStorage16_OpenStorage  [STORAGE.506]
- */
-HRESULT CDECL IStorage16_fnOpenStorage(
-       LPSTORAGE16 iface,LPCOLESTR16 pwcsName, IStorage16 *pstgPrio, DWORD grfMode, SNB16 snbExclude, DWORD reserved, IStorage16 **ppstg
-) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-       IStream16Impl*  lpstg;
-       WCHAR           name[33];
-       int             newpps;
-
-       TRACE("(%p)->(%s,%p,0x%08x,%p,0x%08x,%p)\n",
-               This,pwcsName,pstgPrio,grfMode,snbExclude,reserved,ppstg
-       );
-       if (grfMode & STGM_TRANSACTED)
-               FIXME("We do not support transacted Compound Storage. Using direct mode.\n");
-       _create_istorage16(ppstg);
-       lpstg = MapSL((SEGPTR)*ppstg);
-       if (This->str.hf) {
-           DuplicateHandle( GetCurrentProcess(), This->str.hf, GetCurrentProcess(),
-                            &lpstg->str.hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
-       } else {
-           lpstg->str.lockbytes = This->str.lockbytes;
-           _ilockbytes16_addref(This->str.lockbytes);
-       }
-        MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, name, sizeof(name)/sizeof(WCHAR));
-       newpps = STORAGE_look_for_named_pps(&lpstg->str,This->stde.pps_dir,name);
-       if (newpps==-1) {
-               IStream16_fnRelease((IStream16*)lpstg);
-               return E_FAIL;
-       }
-
-       if (1!=STORAGE_get_pps_entry(&lpstg->str,newpps,&(lpstg->stde))) {
-               IStream16_fnRelease((IStream16*)lpstg);
-               return E_FAIL;
-       }
-       lpstg->ppsent           = newpps;
-       return S_OK;
-}
-
-/******************************************************************************
- * IStorage16_OpenStream [STORAGE.504]
- */
-HRESULT CDECL IStorage16_fnOpenStream(
-       LPSTORAGE16 iface,LPCOLESTR16 pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream16 **ppstm
-) {
-       IStorage16Impl *This = (IStorage16Impl *)iface;
-       IStream16Impl*  lpstr;
-       WCHAR           name[33];
-       int             newpps;
-
-       TRACE("(%p)->(%s,%p,0x%08x,0x%08x,%p)\n",
-               This,pwcsName,reserved1,grfMode,reserved2,ppstm
-       );
-       if (grfMode & STGM_TRANSACTED)
-               FIXME("We do not support transacted Compound Storage. Using direct mode.\n");
-       _create_istream16(ppstm);
-       lpstr = MapSL((SEGPTR)*ppstm);
-       if (This->str.hf) {
-           DuplicateHandle( GetCurrentProcess(), This->str.hf, GetCurrentProcess(),
-                            &lpstr->str.hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
-       } else {
-           lpstr->str.lockbytes = This->str.lockbytes;
-           _ilockbytes16_addref(This->str.lockbytes);
-       }
-        MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, name, sizeof(name)/sizeof(WCHAR));
-       newpps = STORAGE_look_for_named_pps(&lpstr->str,This->stde.pps_dir,name);
-       if (newpps==-1) {
-               IStream16_fnRelease((IStream16*)lpstr);
-               return E_FAIL;
-       }
-
-       if (1!=STORAGE_get_pps_entry(&lpstr->str,newpps,&(lpstr->stde))) {
-               IStream16_fnRelease((IStream16*)lpstr);
-               return E_FAIL;
-       }
-       lpstr->offset.u.LowPart         = 0;
-       lpstr->offset.u.HighPart        = 0;
-       lpstr->ppsent                   = newpps;
-       return S_OK;
-}
-
-/******************************************************************************
- * _create_istorage16 [INTERNAL]
- */
-static void _create_istorage16(LPSTORAGE16 *stg) {
-       IStorage16Impl* lpst;
-
-       if (!stvt16.QueryInterface) {
-               HMODULE16       wp = GetModuleHandle16("STORAGE");
-               if (wp>=32) {
-#define VTENT(xfn)  stvt16.xfn = (void*)GetProcAddress16(wp,"IStorage16_"#xfn);
-                       VTENT(QueryInterface)
-                       VTENT(AddRef)
-                       VTENT(Release)
-                       VTENT(CreateStream)
-                       VTENT(OpenStream)
-                       VTENT(CreateStorage)
-                       VTENT(OpenStorage)
-                       VTENT(CopyTo)
-                       VTENT(MoveElementTo)
-                       VTENT(Commit)
-                       VTENT(Revert)
-                       VTENT(EnumElements)
-                       VTENT(DestroyElement)
-                       VTENT(RenameElement)
-                       VTENT(SetElementTimes)
-                       VTENT(SetClass)
-                       VTENT(SetStateBits)
-                       VTENT(Stat)
-#undef VTENT
-                       segstvt16 = (const IStorage16Vtbl*)MapLS( &stvt16 );
-               } else {
-#define VTENT(xfn) stvt16.xfn = IStorage16_fn##xfn;
-                       VTENT(QueryInterface)
-                       VTENT(AddRef)
-                       VTENT(Release)
-                       VTENT(CreateStream)
-                       VTENT(OpenStream)
-                       VTENT(CreateStorage)
-                       VTENT(OpenStorage)
-                       VTENT(CopyTo)
-                       VTENT(Commit)
-       /*  not (yet) implemented ...
-                       VTENT(MoveElementTo)
-                       VTENT(Revert)
-                       VTENT(EnumElements)
-                       VTENT(DestroyElement)
-                       VTENT(RenameElement)
-                       VTENT(SetElementTimes)
-                       VTENT(SetClass)
-                       VTENT(SetStateBits)
-                       VTENT(Stat)
-       */
-#undef VTENT
-                       segstvt16 = &stvt16;
-               }
-       }
-       lpst = HeapAlloc( GetProcessHeap(), 0, sizeof(*lpst) );
-       lpst->lpVtbl    = segstvt16;
-       lpst->str.hf    = NULL;
-       lpst->str.lockbytes     = 0;
-       lpst->ref       = 1;
-       lpst->thisptr   = MapLS(lpst);
-       *stg = (void*)lpst->thisptr;
-}
-
-/******************************************************************************
- *     Storage API functions
- */
-
-/******************************************************************************
- *             StgCreateDocFileA       [STORAGE.1]
- */
-HRESULT WINAPI StgCreateDocFile16(
-       LPCOLESTR16 pwcsName,DWORD grfMode,DWORD reserved,IStorage16 **ppstgOpen
-) {
-       HANDLE          hf;
-       int             i,ret;
-       IStorage16Impl* lpstg;
-       struct storage_pps_entry        stde;
-
-       TRACE("(%s,0x%08x,0x%08x,%p)\n",
-               pwcsName,grfMode,reserved,ppstgOpen
-       );
-       _create_istorage16(ppstgOpen);
-       hf = CreateFileA(pwcsName,GENERIC_READ|GENERIC_WRITE,0,NULL,CREATE_NEW,0,0);
-       if (hf==INVALID_HANDLE_VALUE) {
-               WARN("couldn't open file for storage:%d\n",GetLastError());
-               return E_FAIL;
-       }
-       lpstg = MapSL((SEGPTR)*ppstgOpen);
-       lpstg->str.hf = hf;
-       lpstg->str.lockbytes = 0;
-       /* FIXME: check for existence before overwriting? */
-       if (!STORAGE_init_storage(&lpstg->str)) {
-               CloseHandle(hf);
-               return E_FAIL;
-       }
-       i=0;ret=0;
-       while (!ret) { /* neither 1 nor <0 */
-               ret=STORAGE_get_pps_entry(&lpstg->str,i,&stde);
-               if ((ret==1) && (stde.pps_type==5)) {
-                       lpstg->stde     = stde;
-                       lpstg->ppsent   = i;
-                       break;
-               }
-               i++;
-       }
-       if (ret!=1) {
-               IStorage16_fnRelease((IStorage16*)lpstg); /* will remove it */
-               return E_FAIL;
-       }
-
-       return S_OK;
-}
-
-/******************************************************************************
- * StgIsStorageFile [STORAGE.5]
- */
-HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) {
-       UNICODE_STRING strW;
-       HRESULT ret;
-
-       RtlCreateUnicodeStringFromAsciiz(&strW, fn);
-       ret = StgIsStorageFile( strW.Buffer );
-       RtlFreeUnicodeString( &strW );
-
-       return ret;
-}
-
-/******************************************************************************
- * StgOpenStorage [STORAGE.3]
- */
-HRESULT WINAPI StgOpenStorage16(
-       LPCOLESTR16 pwcsName,IStorage16 *pstgPriority,DWORD grfMode,
-       SNB16 snbExclude,DWORD reserved, IStorage16 **ppstgOpen
-) {
-       HANDLE          hf;
-       int             ret,i;
-       IStorage16Impl* lpstg;
-       struct storage_pps_entry        stde;
-
-       TRACE("(%s,%p,0x%08x,%p,%d,%p)\n",
-              pwcsName,pstgPriority,grfMode,snbExclude,reserved,ppstgOpen
-       );
-       _create_istorage16(ppstgOpen);
-       hf = CreateFileA(pwcsName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
-       if (hf==INVALID_HANDLE_VALUE) {
-               WARN("Couldn't open file for storage\n");
-               return E_FAIL;
-       }
-       lpstg = MapSL((SEGPTR)*ppstgOpen);
-       lpstg->str.hf = hf;
-
-       i=0;ret=0;
-       while (!ret) { /* neither 1 nor <0 */
-               ret=STORAGE_get_pps_entry(&lpstg->str,i,&stde);
-               if ((ret==1) && (stde.pps_type==5)) {
-                       lpstg->stde=stde;
-                       break;
-               }
-               i++;
-       }
-       if (ret!=1) {
-               IStorage16_fnRelease((IStorage16*)lpstg); /* will remove it */
-               return E_FAIL;
-       }
-       return S_OK;
-
-}
-
-/******************************************************************************
- *              StgIsStorageILockBytes        [STORAGE.6]
- *
- * Determines if the ILockBytes contains a storage object.
- */
-HRESULT WINAPI StgIsStorageILockBytes16(SEGPTR plkbyt)
-{
-  DWORD args[6];
-  HRESULT hres;
-  HANDLE16 hsig;
-  
-  args[0] = (DWORD)plkbyt;     /* iface */
-  args[1] = args[2] = 0;       /* ULARGE_INTEGER offset */
-  args[3] = WOWGlobalAllocLock16( 0, 8, &hsig ); /* sig */
-  args[4] = 8;
-  args[5] = 0;
-
-  if (!WOWCallback16Ex(
-      (DWORD)((const ILockBytes16Vtbl*)MapSL(
-                  (SEGPTR)((LPLOCKBYTES16)MapSL(plkbyt))->lpVtbl)
-      )->ReadAt,
-      WCB16_PASCAL,
-      6*sizeof(DWORD),
-      (LPVOID)args,
-      (LPDWORD)&hres
-  )) {
-      ERR("CallTo16 ILockBytes16::ReadAt() failed, hres %x\n",hres);
-      return hres;
-  }
-  if (memcmp(MapSL(args[3]), STORAGE_magic, sizeof(STORAGE_magic)) == 0) {
-    WOWGlobalUnlockFree16(args[3]);
-    return S_OK;
-  }
-  WOWGlobalUnlockFree16(args[3]);
-  return S_FALSE;
-}
-
-/******************************************************************************
- *    StgOpenStorageOnILockBytes    [STORAGE.4]
- *
- * PARAMS
- *  plkbyt  FIXME: Should probably be an ILockBytes16 *.
- */
-HRESULT WINAPI StgOpenStorageOnILockBytes16(
-       SEGPTR plkbyt,
-       IStorage16 *pstgPriority,
-       DWORD grfMode,
-       SNB16 snbExclude,
-       DWORD reserved,
-       IStorage16 **ppstgOpen)
-{
-       IStorage16Impl* lpstg;
-       int i,ret;
-       struct storage_pps_entry        stde;
-
-       FIXME("(%x, %p, 0x%08x, %d, %x, %p)\n", plkbyt, pstgPriority, grfMode, (int)snbExclude, reserved, ppstgOpen);
-       if ((plkbyt == 0) || (ppstgOpen == 0))
-               return STG_E_INVALIDPOINTER;
-
-       *ppstgOpen = 0;
-
-       _create_istorage16(ppstgOpen);
-       lpstg = MapSL((SEGPTR)*ppstgOpen);
-       lpstg->str.hf = NULL;
-       lpstg->str.lockbytes = plkbyt;
-       i=0;ret=0;
-       while (!ret) { /* neither 1 nor <0 */
-               ret=STORAGE_get_pps_entry(&lpstg->str,i,&stde);
-               if ((ret==1) && (stde.pps_type==5)) {
-                       lpstg->stde=stde;
-                       break;
-               }
-               i++;
-       }
-       if (ret!=1) {
-               IStorage16_fnRelease((IStorage16*)lpstg); /* will remove it */
-               return E_FAIL;
-       }
-       return S_OK;
-}
-
-/***********************************************************************
- *    ReadClassStg (OLE2.18)
- *
- * This method reads the CLSID previously written to a storage object with
- * the WriteClassStg.
- *
- * PARAMS
- *  pstg    [I] Segmented LPSTORAGE pointer.
- *  pclsid  [O] Pointer to where the CLSID is written
- *
- * RETURNS
- *  Success: S_OK.
- *  Failure: HRESULT code.
- */
-HRESULT WINAPI ReadClassStg16(SEGPTR pstg, CLSID *pclsid)
-{
-       STATSTG16 statstg;
-       HANDLE16 hstatstg;
-       HRESULT hres;
-       DWORD args[3];
-
-       TRACE("(%x, %p)\n", pstg, pclsid);
-
-       if(pclsid==NULL)
-               return E_POINTER;
-       /*
-        * read a STATSTG structure (contains the clsid) from the storage
-        */
-       args[0] = (DWORD)pstg;  /* iface */
-       args[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16), &hstatstg );
-       args[2] = STATFLAG_DEFAULT;
-
-       if (!WOWCallback16Ex(
-           (DWORD)((const IStorage16Vtbl*)MapSL(
-                       (SEGPTR)((LPSTORAGE16)MapSL(pstg))->lpVtbl)
-           )->Stat,
-           WCB16_PASCAL,
-           3*sizeof(DWORD),
-           (LPVOID)args,
-           (LPDWORD)&hres
-       )) {
-           WOWGlobalUnlockFree16(args[1]);
-            ERR("CallTo16 IStorage16::Stat() failed, hres %x\n",hres);
-           return hres;
-       }
-       memcpy(&statstg, MapSL(args[1]), sizeof(STATSTG16));
-       WOWGlobalUnlockFree16(args[1]);
-
-       if(SUCCEEDED(hres)) {
-               *pclsid=statstg.clsid;
-               TRACE("clsid is %s\n", debugstr_guid(&statstg.clsid));
-       }
-       return hres;
-}
-
-/***********************************************************************
- *              GetConvertStg (OLE2.82)
- */
-HRESULT WINAPI GetConvertStg16(LPSTORAGE stg) {
-    FIXME("unimplemented stub!\n");
-    return E_FAIL;
-}
diff --git a/reactos/dll/win32/ole32/storage.spec b/reactos/dll/win32/ole32/storage.spec
deleted file mode 100644 (file)
index d4933a7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# Compound Storage DLL.
-# (FIXME: some methods are commented out. Commenting them in _WILL_
-#  result in dataloss. Do it at your own risk.)
-
-1 pascal StgCreateDocFileA(str long long ptr) StgCreateDocFile16
-2 stub StgCreateDocFileOnILockBytes
-# 2 pascal StgCreateDocFileOnILockBytes(ptr long long ptr) StgCreateDocFileOnILockBytes16
-3 pascal StgOpenStorage(str ptr long ptr long ptr) StgOpenStorage16
-4 pascal StgOpenStorageOnILockBytes(segptr ptr long long long ptr) StgOpenStorageOnILockBytes16
-5 pascal StgIsStorageFile(str) StgIsStorageFile16
-6 pascal StgIsStorageILockBytes(segptr) StgIsStorageILockBytes16
-7 stub StgSetTimes
-#8 WEP
-#9 ___EXPORTEDSTUB
-103 stub DllGetClassObject
-
-# Storage Interface functions. Starting at 500
-# these are not exported in the real storage.dll, we use them
-# as 16->32 relays. They use the cdecl calling convention.
-
-# IStorage
-500 cdecl IStorage16_QueryInterface(ptr ptr ptr) IStorage16_fnQueryInterface
-501 cdecl IStorage16_AddRef(ptr) IStorage16_fnAddRef
-502 cdecl IStorage16_Release(ptr) IStorage16_fnRelease
-503 cdecl IStorage16_CreateStream(ptr str long long long ptr) IStorage16_fnCreateStream
-
-504 cdecl IStorage16_OpenStream(ptr str ptr long long ptr) IStorage16_fnOpenStream
-505 cdecl IStorage16_CreateStorage(ptr str long long long ptr) IStorage16_fnCreateStorage
-506 cdecl IStorage16_OpenStorage(ptr str ptr long ptr long ptr) IStorage16_fnOpenStorage
-507 cdecl IStorage16_CopyTo(ptr long ptr ptr ptr) IStorage16_fnCopyTo
-508 stub  IStorage16_MoveElementTo
-509 cdecl IStorage16_Commit(ptr long) IStorage16_fnCommit
-510 stub  IStorage16_Revert
-511 stub  IStorage16_EnumElements
-512 stub  IStorage16_DestroyElement
-513 stub  IStorage16_RenameElement
-514 stub  IStorage16_SetElementTimes
-515 stub  IStorage16_SetClass
-516 stub  IStorage16_SetStateBits
-517 cdecl IStorage16_Stat(ptr ptr long) IStorage16_fnStat
-
-# IStream
-518 cdecl IStream16_QueryInterface(ptr ptr ptr) IStream16_fnQueryInterface
-519 cdecl IStream16_AddRef(ptr) IStream16_fnAddRef
-520 cdecl IStream16_Release(ptr) IStream16_fnRelease
-521 cdecl IStream16_Read(ptr ptr long ptr) IStream16_fnRead
-522 cdecl IStream16_Write(ptr ptr long ptr) IStream16_fnWrite
-523 cdecl IStream16_Seek(ptr double long ptr) IStream16_fnSeek
-524 stub  IStream16_SetSize
-525 stub  IStream16_CopyTo
-526 stub  IStream16_Commit
-527 stub  IStream16_Revert
-528 stub  IStream16_LockRegion
-529 stub  IStream16_UnlockRegion
-530 stub  IStream16_Stat
-531 stub  IStream16_Clone
index 6f6eebb..a2710df 100644 (file)
@@ -486,7 +486,6 @@ static const unsigned char Lookup_224[128 * 3] = {
 
 /***********************************************************************
  *             LHashValOfNameSysA (OLEAUT32.166)
- *              LHashValOfNameSys  (TYPELIB.4)
  *
  * Produce a string hash value.
  *
diff --git a/reactos/dll/win32/olesvr32/olesvr.spec b/reactos/dll/win32/olesvr32/olesvr.spec
deleted file mode 100644 (file)
index 12056cd..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#1 WEP
-2  pascal OleRegisterServer(str ptr ptr word word) OleRegisterServer16
-3  pascal OleRevokeServer(long) OleRevokeServer16
-4  pascal OleBlockServer(long) OleBlockServer16
-5  pascal OleUnblockServer(long ptr) OleUnblockServer16
-6  pascal OleRegisterServerDoc(long str ptr ptr) OleRegisterServerDoc16
-7  pascal OleRevokeServerDoc(long) OleRevokeServerDoc16
-8  pascal OleRenameServerDoc(long str) OleRenameServerDoc16
-9  pascal OleRevertServerDoc(long) OleRevertServerDoc16
-10 pascal OleSavedServerDoc(long) OleSavedServerDoc16
-11 stub OLEREVOKEOBJECT
-12 stub OLEQUERYSERVERVERSION
-21 stub SRVRWNDPROC
-22 stub DOCWNDPROC
-23 stub ITEMWNDPROC
-24 stub SENDDATAMSG
-25 stub FINDITEMWND
-26 stub ITEMCALLBACK
-27 stub TERMINATECLIENTS
-28 stub TERMINATEDOCCLIENTS
-29 stub DELETECLIENTINFO
-30 stub SENDRENAMEMSG
-31 stub ENUMFORTERMINATE
index 3d22cb7..b48d58b 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "windef.h"
 #include "winbase.h"
-#include "wine/windef16.h"
 #include "objbase.h"
 #include "wine/debug.h"
 
@@ -132,28 +131,6 @@ typedef struct _OLESERVER
 
 static LONG OLE_current_handle;
 
-/******************************************************************************
- *             OleRegisterServer       [OLESVR.2]
- */
-OLESTATUS WINAPI OleRegisterServer16( LPCSTR name, LPOLESERVER serverStruct,
-                                      LHSERVER *hRet, HINSTANCE16 hServer,
-                                      OLE_SERVER_USE use )
-{
-    FIXME("(%s,...): stub\n",name);
-    *hRet=++OLE_current_handle;
-    /* return OLE_ERROR_MEMORY, OLE_ERROR_PROTECT_ONLY if you want it fail*/
-    return OLE_OK;
-}
-
-/******************************************************************************
- *             OleBlockServer  [OLESVR.4]
- */
-OLESTATUS WINAPI OleBlockServer16(LHSERVER hServer)
-{
-    FIXME("(%d): stub\n",hServer);
-    return OLE_OK;
-}
-
 /******************************************************************************
  *             OleBlockServer  [OLESVR32.4]
  */
@@ -163,17 +140,6 @@ OLESTATUS WINAPI OleBlockServer(LHSERVER hServer)
     return OLE_OK;
 }
 
-/******************************************************************************
- *             OleUnblockServer        [OLESVR.5]
- */
-OLESTATUS WINAPI OleUnblockServer16(LHSERVER hServer, BOOL16 *block)
-{
-    FIXME("(%d): stub\n",hServer);
-    /* no more blocked messages :) */
-    *block=FALSE;
-    return OLE_OK;
-}
-
 /******************************************************************************
  *             OleUnblockServer        [OLESVR32.5]
  */
@@ -185,27 +151,6 @@ OLESTATUS WINAPI OleUnblockServer(LHSERVER hServer, BOOL *block)
     return OLE_OK;
 }
 
-/***********************************************************************
- *             OleRegisterServerDoc    [OLESVR.6]
- */
-OLESTATUS WINAPI OleRegisterServerDoc16( LHSERVER hServer, LPCSTR docname,
-                                         LPOLESERVERDOC document,
-                                         LHSERVERDOC *hRet)
-{
-    FIXME("(%d,%s): stub\n",hServer, docname);
-    *hRet=++OLE_current_handle;
-    return OLE_OK;
-}
-
-/******************************************************************************
- *             OleRevokeServerDoc      [OLESVR.7]
- */
-OLESTATUS WINAPI OleRevokeServerDoc16(LHSERVERDOC hServerDoc)
-{
-    FIXME("%d  - stub\n",hServerDoc);
-    return OLE_OK;
-}
-
 /******************************************************************************
  *             OleRevokeServerDoc      [OLESVR32.7]
  */
@@ -215,15 +160,6 @@ OLESTATUS WINAPI OleRevokeServerDoc(LHSERVERDOC hServerDoc)
     return OLE_OK;
 }
 
-/******************************************************************************
- *             OleRevokeServer [OLESVR.3]
- */
-OLESTATUS WINAPI OleRevokeServer16(LHSERVER hServer)
-{
-    FIXME("%d - stub\n",hServer);
-    return OLE_OK;
-}
-
 /******************************************************************************
  * OleRegisterServer [OLESVR32.2]
  */
@@ -245,16 +181,6 @@ OLESTATUS WINAPI OleRegisterServerDoc( LHSERVER hServer, LPCSTR docname,
     return OLE_OK;
 }
 
-/******************************************************************************
- *             OleRenameServerDoc      [OLESVR.8]
- *
- */
-OLESTATUS WINAPI OleRenameServerDoc16(LHSERVERDOC hDoc, LPCSTR newName)
-{
-    FIXME("(%d,%s): stub.\n", hDoc, newName);
-    return OLE_OK;
-}
-
 /******************************************************************************
  *             OleRenameServerDoc      [OLESVR32.8]
  *
@@ -265,16 +191,6 @@ OLESTATUS WINAPI OleRenameServerDoc(LHSERVERDOC hDoc, LPCSTR newName)
     return OLE_OK;
 }
 
-/******************************************************************************
- *             OleRevertServerDoc      [OLESVR.9]
- *
- */
-OLESTATUS WINAPI OleRevertServerDoc16(LHSERVERDOC hDoc)
-{
-    FIXME("(%d): stub.\n", hDoc);
-    return OLE_OK;
-}
-
 /******************************************************************************
  *             OleRevertServerDoc      [OLESVR32.9]
  *
@@ -285,16 +201,6 @@ OLESTATUS WINAPI OleRevertServerDoc(LHSERVERDOC hDoc)
     return OLE_OK;
 }
 
-/******************************************************************************
- *             OleSavedServerDoc       [OLESVR.10]
- *
- */
-OLESTATUS WINAPI OleSavedServerDoc16(LHSERVERDOC hDoc)
-{
-    FIXME("(%d): stub.\n", hDoc);
-    return OLE_OK;
-}
-
 /******************************************************************************
  *             OleSavedServerDoc       [OLESVR32.10]
  *