Commit ec2edc7e authored by Francis Beaudet's avatar Francis Beaudet Committed by Alexandre Julliard

Fixed a few bugs in the OLE storage implementation, added a new set of

trace statements for the OLE storage related methods and introduced a new debug channel for the storage subsystem.
parent 92ae219e
...@@ -132,39 +132,40 @@ int dbch_snoop = 120; ...@@ -132,39 +132,40 @@ int dbch_snoop = 120;
int dbch_sound = 121; int dbch_sound = 121;
int dbch_static = 122; int dbch_static = 122;
int dbch_statusbar = 123; int dbch_statusbar = 123;
int dbch_stress = 124; int dbch_storage = 124;
int dbch_string = 125; int dbch_stress = 125;
int dbch_syscolor = 126; int dbch_string = 126;
int dbch_system = 127; int dbch_syscolor = 127;
int dbch_tab = 128; int dbch_system = 128;
int dbch_tapi = 129; int dbch_tab = 129;
int dbch_task = 130; int dbch_tapi = 130;
int dbch_text = 131; int dbch_task = 131;
int dbch_thread = 132; int dbch_text = 132;
int dbch_thunk = 133; int dbch_thread = 133;
int dbch_timer = 134; int dbch_thunk = 134;
int dbch_toolbar = 135; int dbch_timer = 135;
int dbch_toolhelp = 136; int dbch_toolbar = 136;
int dbch_tooltips = 137; int dbch_toolhelp = 137;
int dbch_trackbar = 138; int dbch_tooltips = 138;
int dbch_treeview = 139; int dbch_trackbar = 139;
int dbch_ttydrv = 140; int dbch_treeview = 140;
int dbch_tweak = 141; int dbch_ttydrv = 141;
int dbch_updown = 142; int dbch_tweak = 142;
int dbch_ver = 143; int dbch_updown = 143;
int dbch_virtual = 144; int dbch_ver = 144;
int dbch_vxd = 145; int dbch_virtual = 145;
int dbch_wave = 146; int dbch_vxd = 146;
int dbch_win = 147; int dbch_wave = 147;
int dbch_win16drv = 148; int dbch_win = 148;
int dbch_win32 = 149; int dbch_win16drv = 149;
int dbch_wing = 150; int dbch_win32 = 150;
int dbch_winsock = 151; int dbch_wing = 151;
int dbch_wnet = 152; int dbch_winsock = 152;
int dbch_x11 = 153; int dbch_wnet = 153;
int dbch_x11drv = 154; int dbch_x11 = 154;
int dbch_x11drv = 155;
#define DEBUG_CHANNEL_COUNT 155 #define DEBUG_CHANNEL_COUNT 156
char debug_msg_enabled[DEBUG_CHANNEL_COUNT][DEBUG_CLASS_COUNT] = { char debug_msg_enabled[DEBUG_CHANNEL_COUNT][DEBUG_CLASS_COUNT] = {
{1, 1, 0, 0}, {1, 1, 0, 0},
...@@ -321,6 +322,7 @@ char debug_msg_enabled[DEBUG_CHANNEL_COUNT][DEBUG_CLASS_COUNT] = { ...@@ -321,6 +322,7 @@ char debug_msg_enabled[DEBUG_CHANNEL_COUNT][DEBUG_CLASS_COUNT] = {
{1, 1, 0, 0}, {1, 1, 0, 0},
{1, 1, 0, 0}, {1, 1, 0, 0},
{1, 1, 0, 0}, {1, 1, 0, 0},
{1, 1, 0, 0},
{1, 1, 0, 0} {1, 1, 0, 0}
}; };
...@@ -449,6 +451,7 @@ const char * const debug_ch_name[DEBUG_CHANNEL_COUNT] = { ...@@ -449,6 +451,7 @@ const char * const debug_ch_name[DEBUG_CHANNEL_COUNT] = {
"sound", "sound",
"static", "static",
"statusbar", "statusbar",
"storage",
"stress", "stress",
"string", "string",
"syscolor", "syscolor",
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "objbase.h" #include "objbase.h"
DEFAULT_DEBUG_CHANNEL(ole) DEFAULT_DEBUG_CHANNEL(storage)
/**************************************************************************** /****************************************************************************
* HGLOBALStreamImpl definition. * HGLOBALStreamImpl definition.
...@@ -252,6 +252,8 @@ HGLOBALStreamImpl* HGLOBALStreamImpl_Construct( ...@@ -252,6 +252,8 @@ HGLOBALStreamImpl* HGLOBALStreamImpl_Construct(
*/ */
void HGLOBALStreamImpl_Destroy(HGLOBALStreamImpl* This) void HGLOBALStreamImpl_Destroy(HGLOBALStreamImpl* This)
{ {
TRACE(storage, "(%p)\n", This);
/* /*
* Release the HGlobal if the constructor asked for that. * Release the HGlobal if the constructor asked for that.
*/ */
...@@ -376,6 +378,9 @@ HRESULT WINAPI HGLOBALStreamImpl_Read( ...@@ -376,6 +378,9 @@ HRESULT WINAPI HGLOBALStreamImpl_Read(
void* supportBuffer; void* supportBuffer;
ULONG bytesReadBuffer; ULONG bytesReadBuffer;
ULONG bytesToReadFromBuffer; ULONG bytesToReadFromBuffer;
TRACE(storage, "(%p, %p, %ld, %p)\n", iface,
pv, cb, pcbRead);
/* /*
* If the caller is not interested in the nubmer of bytes read, * If the caller is not interested in the nubmer of bytes read,
...@@ -444,6 +449,9 @@ HRESULT WINAPI HGLOBALStreamImpl_Write( ...@@ -444,6 +449,9 @@ HRESULT WINAPI HGLOBALStreamImpl_Write(
void* supportBuffer; void* supportBuffer;
ULARGE_INTEGER newSize; ULARGE_INTEGER newSize;
ULONG bytesWritten = 0; ULONG bytesWritten = 0;
TRACE(storage, "(%p, %p, %ld, %p)\n", iface,
pv, cb, pcbWritten);
/* /*
* If the caller is not interested in the number of bytes written, * If the caller is not interested in the number of bytes written,
...@@ -468,7 +476,7 @@ HRESULT WINAPI HGLOBALStreamImpl_Write( ...@@ -468,7 +476,7 @@ HRESULT WINAPI HGLOBALStreamImpl_Write(
if (newSize.LowPart > This->streamSize.LowPart) if (newSize.LowPart > This->streamSize.LowPart)
{ {
/* grow stream */ /* grow stream */
HGLOBALStreamImpl_SetSize(iface, newSize); IStream_SetSize(iface, newSize);
} }
/* /*
...@@ -514,6 +522,9 @@ HRESULT WINAPI HGLOBALStreamImpl_Seek( ...@@ -514,6 +522,9 @@ HRESULT WINAPI HGLOBALStreamImpl_Seek(
ULARGE_INTEGER newPosition; ULARGE_INTEGER newPosition;
TRACE(storage, "(%p, %ld, %ld, %p)\n", iface,
dlibMove.LowPart, dwOrigin, plibNewPosition);
/* /*
* The caller is allowed to pass in NULL as the new position return value. * The caller is allowed to pass in NULL as the new position return value.
* If it happens, we assign it to a dynamic variable to avoid special cases * If it happens, we assign it to a dynamic variable to avoid special cases
...@@ -587,6 +598,8 @@ HRESULT WINAPI HGLOBALStreamImpl_SetSize( ...@@ -587,6 +598,8 @@ HRESULT WINAPI HGLOBALStreamImpl_SetSize(
{ {
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
TRACE(storage, "(%p, %ld)\n", iface, libNewSize.LowPart);
/* /*
* As documented. * As documented.
*/ */
...@@ -628,6 +641,9 @@ HRESULT WINAPI HGLOBALStreamImpl_CopyTo( ...@@ -628,6 +641,9 @@ HRESULT WINAPI HGLOBALStreamImpl_CopyTo(
ULARGE_INTEGER totalBytesRead; ULARGE_INTEGER totalBytesRead;
ULARGE_INTEGER totalBytesWritten; ULARGE_INTEGER totalBytesWritten;
TRACE(storage, "(%p, %p, %ld, %p, %p)\n", iface, pstm,
cb.LowPart, pcbRead, pcbWritten);
/* /*
* Sanity check * Sanity check
*/ */
...@@ -649,24 +665,27 @@ HRESULT WINAPI HGLOBALStreamImpl_CopyTo( ...@@ -649,24 +665,27 @@ HRESULT WINAPI HGLOBALStreamImpl_CopyTo(
else else
copySize = cb.LowPart; copySize = cb.LowPart;
HGLOBALStreamImpl_Read(iface, tmpBuffer, 128, &bytesRead); IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
totalBytesRead.LowPart += bytesRead; totalBytesRead.LowPart += bytesRead;
HGLOBALStreamImpl_Write(pstm, tmpBuffer, bytesRead, &bytesWritten); IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
totalBytesWritten.LowPart += bytesWritten; totalBytesWritten.LowPart += bytesWritten;
/* /*
* Check that read & write operations were succesfull * Check that read & write operations were succesfull
*/ */
if ( (bytesRead != copySize) && (bytesWritten != copySize) ) if (bytesRead != bytesWritten)
{ {
hr = STG_E_MEDIUMFULL; hr = STG_E_MEDIUMFULL;
break; break;
} }
cb.LowPart = cb.LowPart - copySize; if (bytesRead!=copySize)
cb.LowPart = 0;
else
cb.LowPart -= bytesRead;
} }
/* /*
...@@ -777,6 +796,6 @@ HRESULT WINAPI HGLOBALStreamImpl_Clone( ...@@ -777,6 +796,6 @@ HRESULT WINAPI HGLOBALStreamImpl_Clone(
IStream* iface, IStream* iface,
IStream** ppstm) /* [out] */ IStream** ppstm) /* [out] */
{ {
FIXME(ole, "not implemented!\n"); FIXME(storage, "not implemented!\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "storage32.h" #include "storage32.h"
DEFAULT_DEBUG_CHANNEL(ole) DEFAULT_DEBUG_CHANNEL(storage)
/* /*
...@@ -113,6 +113,8 @@ StgStreamImpl* StgStreamImpl_Construct( ...@@ -113,6 +113,8 @@ StgStreamImpl* StgStreamImpl_Construct(
*/ */
void StgStreamImpl_Destroy(StgStreamImpl* This) void StgStreamImpl_Destroy(StgStreamImpl* This)
{ {
TRACE(storage, "(%p)\n", This);
/* /*
* Release the reference we are holding on the parent storage. * Release the reference we are holding on the parent storage.
*/ */
...@@ -314,7 +316,10 @@ HRESULT WINAPI StgStreamImpl_Read( ...@@ -314,7 +316,10 @@ HRESULT WINAPI StgStreamImpl_Read(
ULONG bytesReadBuffer; ULONG bytesReadBuffer;
ULONG bytesToReadFromBuffer; ULONG bytesToReadFromBuffer;
TRACE(storage, "(%p, %p, %ld, %p)\n",
iface, pv, cb, pcbRead);
/* /*
* If the caller is not interested in the nubmer of bytes read, * If the caller is not interested in the nubmer of bytes read,
* we use another buffer to avoid "if" statements in the code. * we use another buffer to avoid "if" statements in the code.
...@@ -394,6 +399,9 @@ HRESULT WINAPI StgStreamImpl_Write( ...@@ -394,6 +399,9 @@ HRESULT WINAPI StgStreamImpl_Write(
ULARGE_INTEGER newSize; ULARGE_INTEGER newSize;
ULONG bytesWritten = 0; ULONG bytesWritten = 0;
TRACE(storage, "(%p, %p, %ld, %p)\n",
iface, pv, cb, pcbWritten);
/* /*
* If the caller is not interested in the number of bytes written, * If the caller is not interested in the number of bytes written,
...@@ -402,6 +410,11 @@ HRESULT WINAPI StgStreamImpl_Write( ...@@ -402,6 +410,11 @@ HRESULT WINAPI StgStreamImpl_Write(
if (pcbWritten == 0) if (pcbWritten == 0)
pcbWritten = &bytesWritten; pcbWritten = &bytesWritten;
/*
* Initialize the out parameter
*/
*pcbWritten = 0;
if (cb == 0) if (cb == 0)
{ {
return S_OK; return S_OK;
...@@ -418,7 +431,7 @@ HRESULT WINAPI StgStreamImpl_Write( ...@@ -418,7 +431,7 @@ HRESULT WINAPI StgStreamImpl_Write(
if (newSize.LowPart > This->streamSize.LowPart) if (newSize.LowPart > This->streamSize.LowPart)
{ {
/* grow stream */ /* grow stream */
StgStreamImpl_SetSize(iface, newSize); IStream_SetSize(iface, newSize);
} }
/* /*
...@@ -471,6 +484,9 @@ HRESULT WINAPI StgStreamImpl_Seek( ...@@ -471,6 +484,9 @@ HRESULT WINAPI StgStreamImpl_Seek(
ULARGE_INTEGER newPosition; ULARGE_INTEGER newPosition;
TRACE(storage, "(%p, %ld, %ld, %p)\n",
iface, dlibMove.LowPart, dwOrigin, plibNewPosition);
/* /*
* The caller is allowed to pass in NULL as the new position return value. * The caller is allowed to pass in NULL as the new position return value.
* If it happens, we assign it to a dynamic variable to avoid special cases * If it happens, we assign it to a dynamic variable to avoid special cases
...@@ -547,6 +563,8 @@ HRESULT WINAPI StgStreamImpl_SetSize( ...@@ -547,6 +563,8 @@ HRESULT WINAPI StgStreamImpl_SetSize(
StgProperty curProperty; StgProperty curProperty;
BOOL Success; BOOL Success;
TRACE(storage, "(%p, %ld)\n", iface, libNewSize.LowPart);
/* /*
* As documented. * As documented.
*/ */
...@@ -584,9 +602,9 @@ HRESULT WINAPI StgStreamImpl_SetSize( ...@@ -584,9 +602,9 @@ HRESULT WINAPI StgStreamImpl_SetSize(
&curProperty); &curProperty);
/* /*
* Determine if we have to switch from small to big blocks or vice versa * Determine if we have to switch from small to big blocks or vice versa
*/ */
if ( (This->smallBlockChain!=0) &&
if (curProperty.size.LowPart < LIMIT_TO_USE_SMALL_BLOCK) (curProperty.size.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
{ {
if (libNewSize.LowPart >= LIMIT_TO_USE_SMALL_BLOCK) if (libNewSize.LowPart >= LIMIT_TO_USE_SMALL_BLOCK)
{ {
...@@ -650,6 +668,9 @@ HRESULT WINAPI StgStreamImpl_CopyTo( ...@@ -650,6 +668,9 @@ HRESULT WINAPI StgStreamImpl_CopyTo(
ULARGE_INTEGER totalBytesRead; ULARGE_INTEGER totalBytesRead;
ULARGE_INTEGER totalBytesWritten; ULARGE_INTEGER totalBytesWritten;
TRACE(storage, "(%p, %p, %ld, %p, %p)\n",
iface, pstm, cb.LowPart, pcbRead, pcbWritten);
/* /*
* Sanity check * Sanity check
*/ */
...@@ -671,24 +692,27 @@ HRESULT WINAPI StgStreamImpl_CopyTo( ...@@ -671,24 +692,27 @@ HRESULT WINAPI StgStreamImpl_CopyTo(
else else
copySize = cb.LowPart; copySize = cb.LowPart;
StgStreamImpl_Read(iface, tmpBuffer, 128, &bytesRead); IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
totalBytesRead.LowPart += bytesRead; totalBytesRead.LowPart += bytesRead;
StgStreamImpl_Write(pstm, tmpBuffer, bytesRead, &bytesWritten); IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
totalBytesWritten.LowPart += bytesWritten; totalBytesWritten.LowPart += bytesWritten;
/* /*
* Check that read & write operations were succesfull * Check that read & write operations were succesfull
*/ */
if ( (bytesRead != copySize) && (bytesWritten != copySize) ) if (bytesRead != bytesWritten)
{ {
hr = STG_E_MEDIUMFULL; hr = STG_E_MEDIUMFULL;
break; break;
} }
cb.LowPart = cb.LowPart - copySize; if (bytesRead!=copySize)
cb.LowPart = 0;
else
cb.LowPart -= bytesRead;
} }
/* /*
...@@ -743,7 +767,7 @@ HRESULT WINAPI StgStreamImpl_LockRegion( ...@@ -743,7 +767,7 @@ HRESULT WINAPI StgStreamImpl_LockRegion(
ULARGE_INTEGER cb, /* [in] */ ULARGE_INTEGER cb, /* [in] */
DWORD dwLockType) /* [in] */ DWORD dwLockType) /* [in] */
{ {
FIXME(ole, "not implemented!\n"); FIXME(storage, "not implemented!\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -753,7 +777,7 @@ HRESULT WINAPI StgStreamImpl_UnlockRegion( ...@@ -753,7 +777,7 @@ HRESULT WINAPI StgStreamImpl_UnlockRegion(
ULARGE_INTEGER cb, /* [in] */ ULARGE_INTEGER cb, /* [in] */
DWORD dwLockType) /* [in] */ DWORD dwLockType) /* [in] */
{ {
FIXME(ole, "not implemented!\n"); FIXME(storage, "not implemented!\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -798,6 +822,6 @@ HRESULT WINAPI StgStreamImpl_Clone( ...@@ -798,6 +822,6 @@ HRESULT WINAPI StgStreamImpl_Clone(
IStream* iface, IStream* iface,
IStream** ppstm) /* [out] */ IStream** ppstm) /* [out] */
{ {
FIXME(ole, "not implemented!\n"); FIXME(storage, "not implemented!\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment