[4/4] dlls/ole32: Add more traces to the storage methods.

Dmitry Timoshkov dmitry at baikal.ru
Thu Oct 29 02:41:27 CDT 2015


Without them I wouldn't be able to figure out what is going on in
the application that checks the returned STATSTG contents because
a lot of things happen after the failure is detected and before it's
being reported by the application.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/ole32/storage32.c | 113 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 102 insertions(+), 11 deletions(-)

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index f75e097..9b8daaf 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -908,6 +908,8 @@ static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
 {
   IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
 
+  TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), ppvObject);
+
   if (ppvObject==0)
     return E_INVALIDARG;
 
@@ -918,9 +920,11 @@ static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
   {
     *ppvObject = &This->IEnumSTATSTG_iface;
     IEnumSTATSTG_AddRef(&This->IEnumSTATSTG_iface);
+    TRACE("<-- %p\n", *ppvObject);
     return S_OK;
   }
 
+  TRACE("<-- E_NOINTERFACE\n");
   return E_NOINTERFACE;
 }
 
@@ -958,6 +962,8 @@ static HRESULT IEnumSTATSTGImpl_GetNextRef(
   HRESULT hr;
   WCHAR result_name[DIRENTRY_NAME_MAX_LEN];
 
+  TRACE("%p,%p\n", This, ref);
+
   hr = StorageBaseImpl_ReadDirEntry(This->parentStorage,
     This->parentStorage->storageDirEntry, &entry);
   searchNode = entry.dirRootEntry;
@@ -990,6 +996,7 @@ static HRESULT IEnumSTATSTGImpl_GetNextRef(
       memcpy(This->name, result_name, sizeof(result_name));
   }
 
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
@@ -1007,11 +1014,16 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Next(
   DirRef      currentSearchNode;
   HRESULT     hr=S_OK;
 
+  TRACE("%p,%u,%p,%p\n", iface, celt, rgelt, pceltFetched);
+
   if ( (rgelt==0) || ( (celt!=1) && (pceltFetched==0) ) )
     return E_INVALIDARG;
 
   if (This->parentStorage->reverted)
+  {
+    TRACE("<-- STG_E_REVERTED\n");
     return STG_E_REVERTED;
+  }
 
   /*
    * To avoid the special case, get another pointer to a ULONG value if
@@ -1062,6 +1074,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Next(
   if (SUCCEEDED(hr) && *pceltFetched != celt)
     hr = S_FALSE;
 
+  TRACE("<-- %08x (asked %u, got %u)\n", hr, celt, *pceltFetched);
   return hr;
 }
 
@@ -1076,8 +1089,13 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Skip(
   DirRef      currentSearchNode;
   HRESULT     hr=S_OK;
 
+  TRACE("%p,%u\n", iface, celt);
+
   if (This->parentStorage->reverted)
+  {
+    TRACE("<-- STG_E_REVERTED\n");
     return STG_E_REVERTED;
+  }
 
   while ( (objectFetched < celt) )
   {
@@ -1092,6 +1110,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Skip(
   if (SUCCEEDED(hr) && objectFetched != celt)
     return S_FALSE;
 
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
@@ -1100,8 +1119,13 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Reset(
 {
   IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
 
+  TRACE("%p\n", iface);
+
   if (This->parentStorage->reverted)
+  {
+    TRACE("<-- STG_E_REVERTED\n");
     return STG_E_REVERTED;
+  }
 
   This->name[0] = 0;
 
@@ -1117,8 +1141,13 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Clone(
   IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
   IEnumSTATSTGImpl* newClone;
 
+  TRACE("%p,%p\n", iface, ppenum);
+
   if (This->parentStorage->reverted)
+  {
+    TRACE("<-- STG_E_REVERTED\n");
     return STG_E_REVERTED;
+  }
 
   if (ppenum==0)
     return E_INVALIDARG;
@@ -1208,6 +1237,8 @@ static HRESULT WINAPI StorageBaseImpl_QueryInterface(
 {
   StorageBaseImpl *This = impl_from_IStorage(iface);
 
+  TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), ppvObject);
+
   if (!ppvObject)
     return E_INVALIDARG;
 
@@ -1228,10 +1259,13 @@ static HRESULT WINAPI StorageBaseImpl_QueryInterface(
     *ppvObject = &This->IDirectWriterLock_iface;
   }
   else
+  {
+    TRACE("<-- E_NOINTERFACE\n");
     return E_NOINTERFACE;
+  }
 
   IStorage_AddRef(iface);
-
+  TRACE("<-- %p\n", *ppvObject);
   return S_OK;
 }
 
@@ -1414,6 +1448,7 @@ static HRESULT StorageBaseImpl_CopyChildEntryTo(StorageBaseImpl *This,
     hr = StorageBaseImpl_CopyChildEntryTo( This, data.rightChild, skip_storage,
                                            skip_stream, snbExclude, pstgDest );
 
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
@@ -1421,6 +1456,8 @@ static BOOL StorageBaseImpl_IsStreamOpen(StorageBaseImpl * stg, DirRef streamEnt
 {
   StgStreamImpl *strm;
 
+  TRACE("%p,%d\n", stg, streamEntry);
+
   LIST_FOR_EACH_ENTRY(strm, &stg->strmHead, StgStreamImpl, StrmListEntry)
   {
     if (strm->dirEntry == streamEntry)
@@ -1436,6 +1473,8 @@ static BOOL StorageBaseImpl_IsStorageOpen(StorageBaseImpl * stg, DirRef storageE
 {
   StorageInternalImpl *childstg;
 
+  TRACE("%p,%d\n", stg, storageEntry);
+
   LIST_FOR_EACH_ENTRY(childstg, &stg->storageHead, StorageInternalImpl, ParentListEntry)
   {
     if (childstg->base.storageDirEntry == storageEntry)
@@ -2240,6 +2279,7 @@ static HRESULT StorageBaseImpl_CopyStorageEntryTo(StorageBaseImpl *This,
     hr = StorageBaseImpl_CopyChildEntryTo( This, data.dirRootEntry, skip_storage,
       skip_stream, snbExclude, pstgDest );
 
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
@@ -2396,6 +2436,8 @@ static HRESULT deleteStorageContents(
   HRESULT      destroyHr = S_OK;
   StorageInternalImpl *stg, *stg2;
 
+  TRACE("%p,%d\n", parentStorage, indexToDelete);
+
   /* Invalidate any open storage objects. */
   LIST_FOR_EACH_ENTRY_SAFE(stg, stg2, &parentStorage->storageHead, StorageInternalImpl, ParentListEntry)
   {
@@ -2419,6 +2461,7 @@ static HRESULT deleteStorageContents(
 
   if (hr != S_OK)
   {
+    TRACE("<-- %08x\n", hr);
     return hr;
   }
 
@@ -2429,6 +2472,7 @@ static HRESULT deleteStorageContents(
   if (FAILED(hr))
   {
     IStorage_Release(childStorage);
+    TRACE("<-- %08x\n", hr);
     return hr;
   }
 
@@ -2456,6 +2500,7 @@ static HRESULT deleteStorageContents(
   IStorage_Release(childStorage);
   IEnumSTATSTG_Release(elements);
 
+  TRACE("%08x\n", hr);
   return destroyHr;
 }
 
@@ -2495,6 +2540,7 @@ static HRESULT deleteStreamContents(
 
   if (hr!=S_OK)
   {
+    TRACE("<-- %08x\n", hr);
     return(hr);
   }
 
@@ -2505,6 +2551,7 @@ static HRESULT deleteStreamContents(
 
   if(hr != S_OK)
   {
+    TRACE("<-- %08x\n", hr);
     return hr;
   }
 
@@ -2512,7 +2559,7 @@ static HRESULT deleteStreamContents(
    * Release the stream object.
    */
   IStream_Release(pis);
-
+  TRACE("<-- %08x\n", hr);
   return S_OK;
 }
 
@@ -2558,6 +2605,7 @@ static HRESULT WINAPI StorageBaseImpl_DestroyElement(
 
   if ( entryToDeleteRef == DIRENTRY_NULL )
   {
+    TRACE("<-- STG_E_FILENOTFOUND\n");
     return STG_E_FILENOTFOUND;
   }
 
@@ -2577,7 +2625,10 @@ static HRESULT WINAPI StorageBaseImpl_DestroyElement(
   }
 
   if (hr!=S_OK)
+  {
+    TRACE("<-- %08x\n", hr);
     return hr;
+  }
 
   /*
    * Remove the entry from its parent storage
@@ -2596,6 +2647,7 @@ static HRESULT WINAPI StorageBaseImpl_DestroyElement(
   if (SUCCEEDED(hr))
     hr = StorageBaseImpl_Flush(This);
 
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
@@ -6034,6 +6086,7 @@ end:
     StorageBaseImpl_UnlockTransaction(This->transactedParent, TRUE);
   }
 
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
@@ -6140,7 +6193,11 @@ static HRESULT TransactedSnapshotImpl_WriteDirEntry(StorageBaseImpl *base,
   TRACE("%x %s l=%x r=%x d=%x\n", index, debugstr_w(data->name), data->leftChild, data->rightChild, data->dirRootEntry);
 
   hr = TransactedSnapshotImpl_EnsureReadEntry(This, index);
-  if (FAILED(hr)) return hr;
+  if (FAILED(hr))
+  {
+    TRACE("<-- %08x\n", hr);
+    return hr;
+  }
 
   memcpy(&This->entries[index].data, data, sizeof(DirEntry));
 
@@ -6162,7 +6219,7 @@ static HRESULT TransactedSnapshotImpl_WriteDirEntry(StorageBaseImpl *base,
       This->entries[index].transactedParentEntry = This->entries[index].newTransactedParentEntry = DIRENTRY_NULL;
     }
   }
-
+  TRACE("<-- S_OK\n");
   return S_OK;
 }
 
@@ -6173,7 +6230,11 @@ static HRESULT TransactedSnapshotImpl_ReadDirEntry(StorageBaseImpl *base,
   HRESULT hr;
 
   hr = TransactedSnapshotImpl_EnsureReadEntry(This, index);
-  if (FAILED(hr)) return hr;
+  if (FAILED(hr))
+  {
+    TRACE("<-- %08x\n", hr);
+    return hr;
+  }
 
   memcpy(data, &This->entries[index].data, sizeof(DirEntry));
 
@@ -6235,10 +6296,18 @@ static HRESULT TransactedSnapshotImpl_StreamWriteAt(StorageBaseImpl *base,
   HRESULT hr;
 
   hr = TransactedSnapshotImpl_EnsureReadEntry(This, index);
-  if (FAILED(hr)) return hr;
+  if (FAILED(hr))
+  {
+    TRACE("<-- %08x\n", hr);
+    return hr;
+  }
 
   hr = TransactedSnapshotImpl_MakeStreamDirty(This, index);
-  if (FAILED(hr)) return hr;
+  if (FAILED(hr))
+  {
+    TRACE("<-- %08x\n", hr);
+    return hr;
+  }
 
   hr = StorageBaseImpl_StreamWriteAt(This->scratch,
     This->entries[index].stream_entry, offset, size, buffer, bytesWritten);
@@ -6248,6 +6317,7 @@ static HRESULT TransactedSnapshotImpl_StreamWriteAt(StorageBaseImpl *base,
         This->entries[index].data.size.QuadPart,
         offset.QuadPart + size);
 
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
@@ -6258,7 +6328,11 @@ static HRESULT TransactedSnapshotImpl_StreamSetSize(StorageBaseImpl *base,
   HRESULT hr;
 
   hr = TransactedSnapshotImpl_EnsureReadEntry(This, index);
-  if (FAILED(hr)) return hr;
+  if (FAILED(hr))
+  {
+    TRACE("<-- %08x\n", hr);
+    return hr;
+  }
 
   if (This->entries[index].data.size.QuadPart == newsize.QuadPart)
     return S_OK;
@@ -6299,6 +6373,7 @@ static HRESULT TransactedSnapshotImpl_StreamSetSize(StorageBaseImpl *base,
   if (SUCCEEDED(hr))
     This->entries[index].data.size = newsize;
 
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
@@ -6310,10 +6385,18 @@ static HRESULT TransactedSnapshotImpl_StreamLink(StorageBaseImpl *base,
   TransactedDirEntry *dst_entry, *src_entry;
 
   hr = TransactedSnapshotImpl_EnsureReadEntry(This, src);
-  if (FAILED(hr)) return hr;
+  if (FAILED(hr))
+  {
+    TRACE("<-- %08x\n", hr);
+    return hr;
+  }
 
   hr = TransactedSnapshotImpl_EnsureReadEntry(This, dst);
-  if (FAILED(hr)) return hr;
+  if (FAILED(hr))
+  {
+    TRACE("<-- %08x\n", hr);
+    return hr;
+  }
 
   dst_entry = &This->entries[dst];
   src_entry = &This->entries[src];
@@ -6330,22 +6413,26 @@ static HRESULT TransactedSnapshotImpl_StreamLink(StorageBaseImpl *base,
 static HRESULT TransactedSnapshotImpl_GetTransactionSig(StorageBaseImpl *base,
   ULONG* result, BOOL refresh)
 {
+  FIXME("stub\n");
   return E_NOTIMPL;
 }
 
 static HRESULT TransactedSnapshotImpl_SetTransactionSig(StorageBaseImpl *base,
   ULONG value)
 {
+  FIXME("stub\n");
   return E_NOTIMPL;
 }
 
 static HRESULT TransactedSnapshotImpl_LockTransaction(StorageBaseImpl *base, BOOL write)
 {
+  FIXME("stub\n");
   return E_NOTIMPL;
 }
 
 static HRESULT TransactedSnapshotImpl_UnlockTransaction(StorageBaseImpl *base, BOOL write)
 {
+  FIXME("stub\n");
   return E_NOTIMPL;
 }
 
@@ -6571,22 +6658,26 @@ static HRESULT TransactedSharedImpl_StreamLink(StorageBaseImpl *base,
 static HRESULT TransactedSharedImpl_GetTransactionSig(StorageBaseImpl *base,
   ULONG* result, BOOL refresh)
 {
+  FIXME("stub\n");
   return E_NOTIMPL;
 }
 
 static HRESULT TransactedSharedImpl_SetTransactionSig(StorageBaseImpl *base,
   ULONG value)
 {
+  FIXME("stub\n");
   return E_NOTIMPL;
 }
 
 static HRESULT TransactedSharedImpl_LockTransaction(StorageBaseImpl *base, BOOL write)
 {
+  FIXME("stub\n");
   return E_NOTIMPL;
 }
 
 static HRESULT TransactedSharedImpl_UnlockTransaction(StorageBaseImpl *base, BOOL write)
 {
+  FIXME("stub\n");
   return E_NOTIMPL;
 }
 
@@ -6668,7 +6759,7 @@ static HRESULT WINAPI TransactedSharedImpl_Commit(
       This->lastTransactionSig = transactionSig+1;
     }
   }
-
+  TRACE("<-- %08x\n", hr);
   return hr;
 }
 
-- 
2.6.2




More information about the wine-patches mailing list