From 0aedac346aaabfc1d78cd8c678f1cd3c48e74ace Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 6 Mar 2008 12:05:52 +0000 Subject: [PATCH] ole32: Fix CopyTo to work correctly with LARGE_INTEGERs. --- dlls/ole32/hglobalstream.c | 41 ++++++++++---------------------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c index 217521411c6..68a1527a012 100644 --- a/dlls/ole32/hglobalstream.c +++ b/dlls/ole32/hglobalstream.c @@ -467,24 +467,16 @@ static HRESULT WINAPI HGLOBALStreamImpl_CopyTo( TRACE("(%p, %p, %d, %p, %p)\n", iface, pstm, cb.u.LowPart, pcbRead, pcbWritten); - /* - * Sanity check - */ if ( pstm == 0 ) return STG_E_INVALIDPOINTER; - totalBytesRead.u.LowPart = totalBytesRead.u.HighPart = 0; - totalBytesWritten.u.LowPart = totalBytesWritten.u.HighPart = 0; + totalBytesRead.QuadPart = 0; + totalBytesWritten.QuadPart = 0; - /* - * use stack to store data temporarly - * there is surely more performant way of doing it, for now this basic - * implementation will do the job - */ - while ( cb.u.LowPart > 0 ) + while ( cb.QuadPart > 0 ) { - if ( cb.u.LowPart >= 128 ) - copySize = 128; + if ( cb.QuadPart >= sizeof(tmpBuffer) ) + copySize = sizeof(tmpBuffer); else copySize = cb.u.LowPart; @@ -492,7 +484,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_CopyTo( if (FAILED(hr)) break; - totalBytesRead.u.LowPart += bytesRead; + totalBytesRead.QuadPart += bytesRead; if (bytesRead) { @@ -500,29 +492,18 @@ static HRESULT WINAPI HGLOBALStreamImpl_CopyTo( if (FAILED(hr)) break; - totalBytesWritten.u.LowPart += bytesWritten; + totalBytesWritten.QuadPart += bytesWritten; } if (bytesRead!=copySize) - cb.u.LowPart = 0; + cb.QuadPart = 0; else - cb.u.LowPart -= bytesRead; + cb.QuadPart -= bytesRead; } - /* - * Update number of bytes read and written - */ - if (pcbRead) - { - pcbRead->u.LowPart = totalBytesRead.u.LowPart; - pcbRead->u.HighPart = totalBytesRead.u.HighPart; - } + if (pcbRead) pcbRead->QuadPart = totalBytesRead.QuadPart; + if (pcbWritten) pcbWritten->QuadPart = totalBytesWritten.QuadPart; - if (pcbWritten) - { - pcbWritten->u.LowPart = totalBytesWritten.u.LowPart; - pcbWritten->u.HighPart = totalBytesWritten.u.HighPart; - } return hr; }