server: Moved get/set_thread_context implementation to ptrace.c.
[wine/wine-kai.git] / dlls / ole32 / stg_stream.c
blob493d588f3fa55905c59b531c1674a5b4d035ea4d
1 /*
2 * Compound Storage (32 bit version)
3 * Stream implementation
5 * This file contains the implementation of the stream interface
6 * for streams contained in a compound storage.
8 * Copyright 1999 Francis Beaudet
9 * Copyright 1999 Thuy Nguyen
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include <assert.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <string.h>
32 #define COBJMACROS
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
36 #include "windef.h"
37 #include "winbase.h"
38 #include "winerror.h"
39 #include "winreg.h"
40 #include "winternl.h"
41 #include "wine/debug.h"
43 #include "storage32.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(storage);
48 /***
49 * This is the destructor of the StgStreamImpl class.
51 * This method will clean-up all the resources used-up by the given StgStreamImpl
52 * class. The pointer passed-in to this function will be freed and will not
53 * be valid anymore.
55 static void StgStreamImpl_Destroy(StgStreamImpl* This)
57 TRACE("(%p)\n", This);
60 * Release the reference we are holding on the parent storage.
61 * IStorage_Release((IStorage*)This->parentStorage);
63 * No, don't do this. Some apps call IStorage_Release without
64 * calling IStream_Release first. If we grab a reference the
65 * file is not closed, and the app fails when it tries to
66 * reopen the file (Easy-PC, for example). Just inform the
67 * storage that we have closed the stream
70 if(This->parentStorage) {
72 StorageBaseImpl_RemoveStream(This->parentStorage, This);
76 This->parentStorage = 0;
79 * Make sure we clean-up the block chain stream objects that we were using.
81 if (This->bigBlockChain != 0)
83 BlockChainStream_Destroy(This->bigBlockChain);
84 This->bigBlockChain = 0;
87 if (This->smallBlockChain != 0)
89 SmallBlockChainStream_Destroy(This->smallBlockChain);
90 This->smallBlockChain = 0;
94 * Finally, free the memory used-up by the class.
96 HeapFree(GetProcessHeap(), 0, This);
99 /***
100 * This implements the IUnknown method QueryInterface for this
101 * class
103 static HRESULT WINAPI StgStreamImpl_QueryInterface(
104 IStream* iface,
105 REFIID riid, /* [in] */
106 void** ppvObject) /* [iid_is][out] */
108 StgStreamImpl* const This=(StgStreamImpl*)iface;
111 * Perform a sanity check on the parameters.
113 if (ppvObject==0)
114 return E_INVALIDARG;
117 * Initialize the return parameter.
119 *ppvObject = 0;
122 * Compare the riid with the interface IDs implemented by this object.
124 if (IsEqualGUID(&IID_IUnknown, riid)||
125 IsEqualGUID(&IID_IPersistStream, riid)||
126 IsEqualGUID(&IID_IStream, riid))
128 *ppvObject = (IStream*)This;
132 * Check that we obtained an interface.
134 if ((*ppvObject)==0)
135 return E_NOINTERFACE;
138 * Query Interface always increases the reference count by one when it is
139 * successful
141 IStream_AddRef(iface);
143 return S_OK;
146 /***
147 * This implements the IUnknown method AddRef for this
148 * class
150 static ULONG WINAPI StgStreamImpl_AddRef(
151 IStream* iface)
153 StgStreamImpl* const This=(StgStreamImpl*)iface;
154 return InterlockedIncrement(&This->ref);
157 /***
158 * This implements the IUnknown method Release for this
159 * class
161 static ULONG WINAPI StgStreamImpl_Release(
162 IStream* iface)
164 StgStreamImpl* const This=(StgStreamImpl*)iface;
166 ULONG ref;
168 ref = InterlockedDecrement(&This->ref);
171 * If the reference count goes down to 0, perform suicide.
173 if (ref==0)
175 StgStreamImpl_Destroy(This);
178 return ref;
181 /***
182 * This method will open the block chain pointed by the property
183 * that describes the stream.
184 * If the stream's size is null, no chain is opened.
186 static void StgStreamImpl_OpenBlockChain(
187 StgStreamImpl* This)
189 StgProperty curProperty;
190 BOOL readSucessful;
193 * Make sure no old object is left over.
195 if (This->smallBlockChain != 0)
197 SmallBlockChainStream_Destroy(This->smallBlockChain);
198 This->smallBlockChain = 0;
201 if (This->bigBlockChain != 0)
203 BlockChainStream_Destroy(This->bigBlockChain);
204 This->bigBlockChain = 0;
208 * Read the information from the property.
210 readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
211 This->ownerProperty,
212 &curProperty);
214 if (readSucessful)
216 This->streamSize = curProperty.size;
219 * This code supports only streams that are <32 bits in size.
221 assert(This->streamSize.u.HighPart == 0);
223 if(curProperty.startingBlock == BLOCK_END_OF_CHAIN)
225 assert( (This->streamSize.u.HighPart == 0) && (This->streamSize.u.LowPart == 0) );
227 else
229 if ( (This->streamSize.u.HighPart == 0) &&
230 (This->streamSize.u.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
232 This->smallBlockChain = SmallBlockChainStream_Construct(
233 This->parentStorage->ancestorStorage,
234 This->ownerProperty);
236 else
238 This->bigBlockChain = BlockChainStream_Construct(
239 This->parentStorage->ancestorStorage,
240 NULL,
241 This->ownerProperty);
247 /***
248 * This method is part of the ISequentialStream interface.
250 * It reads a block of information from the stream at the current
251 * position. It then moves the current position at the end of the
252 * read block
254 * See the documentation of ISequentialStream for more info.
256 static HRESULT WINAPI StgStreamImpl_Read(
257 IStream* iface,
258 void* pv, /* [length_is][size_is][out] */
259 ULONG cb, /* [in] */
260 ULONG* pcbRead) /* [out] */
262 StgStreamImpl* const This=(StgStreamImpl*)iface;
264 ULONG bytesReadBuffer;
265 ULONG bytesToReadFromBuffer;
266 HRESULT res;
268 TRACE("(%p, %p, %ld, %p)\n",
269 iface, pv, cb, pcbRead);
271 if (!This->parentStorage)
273 WARN("storage reverted\n");
274 return STG_E_REVERTED;
278 * If the caller is not interested in the number of bytes read,
279 * we use another buffer to avoid "if" statements in the code.
281 if (pcbRead==0)
282 pcbRead = &bytesReadBuffer;
285 * Using the known size of the stream, calculate the number of bytes
286 * to read from the block chain
288 bytesToReadFromBuffer = min( This->streamSize.u.LowPart - This->currentPosition.u.LowPart, cb);
291 * Depending on the type of chain that was opened when the stream was constructed,
292 * we delegate the work to the method that reads the block chains.
294 if (This->smallBlockChain!=0)
296 res = SmallBlockChainStream_ReadAt(This->smallBlockChain,
297 This->currentPosition,
298 bytesToReadFromBuffer,
300 pcbRead);
303 else if (This->bigBlockChain!=0)
305 BOOL success = BlockChainStream_ReadAt(This->bigBlockChain,
306 This->currentPosition,
307 bytesToReadFromBuffer,
309 pcbRead);
310 if (success)
311 res = S_OK;
312 else
313 res = STG_E_READFAULT;
315 else
318 * Small and big block chains are both NULL. This case will happen
319 * when a stream starts with BLOCK_END_OF_CHAIN and has size zero.
322 *pcbRead = 0;
323 res = S_OK;
324 goto end;
327 if (SUCCEEDED(res))
330 * We should always be able to read the proper amount of data from the
331 * chain.
333 assert(bytesToReadFromBuffer == *pcbRead);
336 * Advance the pointer for the number of positions read.
338 This->currentPosition.u.LowPart += *pcbRead;
341 end:
342 TRACE("<-- %08lx\n", res);
343 return res;
346 /***
347 * This method is part of the ISequentialStream interface.
349 * It writes a block of information to the stream at the current
350 * position. It then moves the current position at the end of the
351 * written block. If the stream is too small to fit the block,
352 * the stream is grown to fit.
354 * See the documentation of ISequentialStream for more info.
356 static HRESULT WINAPI StgStreamImpl_Write(
357 IStream* iface,
358 const void* pv, /* [size_is][in] */
359 ULONG cb, /* [in] */
360 ULONG* pcbWritten) /* [out] */
362 StgStreamImpl* const This=(StgStreamImpl*)iface;
364 ULARGE_INTEGER newSize;
365 ULONG bytesWritten = 0;
367 TRACE("(%p, %p, %ld, %p)\n",
368 iface, pv, cb, pcbWritten);
371 * Do we have permission to write to this stream?
373 switch(STGM_ACCESS_MODE(This->grfMode))
375 case STGM_WRITE:
376 case STGM_READWRITE:
377 break;
378 default:
379 WARN("access denied by flags: 0x%lx\n", STGM_ACCESS_MODE(This->grfMode));
380 return STG_E_ACCESSDENIED;
383 if (!pv)
384 return STG_E_INVALIDPOINTER;
386 if (!This->parentStorage)
388 WARN("storage reverted\n");
389 return STG_E_REVERTED;
393 * If the caller is not interested in the number of bytes written,
394 * we use another buffer to avoid "if" statements in the code.
396 if (pcbWritten == 0)
397 pcbWritten = &bytesWritten;
400 * Initialize the out parameter
402 *pcbWritten = 0;
404 if (cb == 0)
406 TRACE("<-- S_OK, written 0\n");
407 return S_OK;
409 else
411 newSize.u.HighPart = 0;
412 newSize.u.LowPart = This->currentPosition.u.LowPart + cb;
416 * Verify if we need to grow the stream
418 if (newSize.u.LowPart > This->streamSize.u.LowPart)
420 /* grow stream */
421 IStream_SetSize(iface, newSize);
425 * Depending on the type of chain that was opened when the stream was constructed,
426 * we delegate the work to the method that readwrites to the block chains.
428 if (This->smallBlockChain!=0)
430 SmallBlockChainStream_WriteAt(This->smallBlockChain,
431 This->currentPosition,
434 pcbWritten);
437 else if (This->bigBlockChain!=0)
439 BlockChainStream_WriteAt(This->bigBlockChain,
440 This->currentPosition,
443 pcbWritten);
445 else
446 assert(FALSE);
449 * Advance the position pointer for the number of positions written.
451 This->currentPosition.u.LowPart += *pcbWritten;
453 TRACE("<-- S_OK, written %lu\n", *pcbWritten);
454 return S_OK;
457 /***
458 * This method is part of the IStream interface.
460 * It will move the current stream pointer according to the parameters
461 * given.
463 * See the documentation of IStream for more info.
465 static HRESULT WINAPI StgStreamImpl_Seek(
466 IStream* iface,
467 LARGE_INTEGER dlibMove, /* [in] */
468 DWORD dwOrigin, /* [in] */
469 ULARGE_INTEGER* plibNewPosition) /* [out] */
471 StgStreamImpl* const This=(StgStreamImpl*)iface;
473 ULARGE_INTEGER newPosition;
475 TRACE("(%p, %ld, %ld, %p)\n",
476 iface, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
479 * fail if the stream has no parent (as does windows)
482 if (!This->parentStorage)
483 return STG_E_REVERTED;
486 * The caller is allowed to pass in NULL as the new position return value.
487 * If it happens, we assign it to a dynamic variable to avoid special cases
488 * in the code below.
490 if (plibNewPosition == 0)
492 plibNewPosition = &newPosition;
496 * The file pointer is moved depending on the given "function"
497 * parameter.
499 switch (dwOrigin)
501 case STREAM_SEEK_SET:
502 plibNewPosition->u.HighPart = 0;
503 plibNewPosition->u.LowPart = 0;
504 break;
505 case STREAM_SEEK_CUR:
506 *plibNewPosition = This->currentPosition;
507 break;
508 case STREAM_SEEK_END:
509 *plibNewPosition = This->streamSize;
510 break;
511 default:
512 return STG_E_INVALIDFUNCTION;
515 plibNewPosition->QuadPart = RtlLargeIntegerAdd( plibNewPosition->QuadPart, dlibMove.QuadPart );
518 * tell the caller what we calculated
520 This->currentPosition = *plibNewPosition;
522 return S_OK;
525 /***
526 * This method is part of the IStream interface.
528 * It will change the size of a stream.
530 * TODO: Switch from small blocks to big blocks and vice versa.
532 * See the documentation of IStream for more info.
534 static HRESULT WINAPI StgStreamImpl_SetSize(
535 IStream* iface,
536 ULARGE_INTEGER libNewSize) /* [in] */
538 StgStreamImpl* const This=(StgStreamImpl*)iface;
540 StgProperty curProperty;
541 BOOL Success;
543 TRACE("(%p, %ld)\n", iface, libNewSize.u.LowPart);
545 if(!This->parentStorage)
546 return STG_E_REVERTED;
549 * As documented.
551 if (libNewSize.u.HighPart != 0)
552 return STG_E_INVALIDFUNCTION;
555 * Do we have permission?
557 if (!(This->grfMode & (STGM_WRITE | STGM_READWRITE)))
558 return STG_E_ACCESSDENIED;
560 if (This->streamSize.u.LowPart == libNewSize.u.LowPart)
561 return S_OK;
564 * This will happen if we're creating a stream
566 if ((This->smallBlockChain == 0) && (This->bigBlockChain == 0))
568 if (libNewSize.u.LowPart < LIMIT_TO_USE_SMALL_BLOCK)
570 This->smallBlockChain = SmallBlockChainStream_Construct(
571 This->parentStorage->ancestorStorage,
572 This->ownerProperty);
574 else
576 This->bigBlockChain = BlockChainStream_Construct(
577 This->parentStorage->ancestorStorage,
578 NULL,
579 This->ownerProperty);
584 * Read this stream's property to see if it's small blocks or big blocks
586 Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
587 This->ownerProperty,
588 &curProperty);
590 * Determine if we have to switch from small to big blocks or vice versa
592 if ( (This->smallBlockChain!=0) &&
593 (curProperty.size.u.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
595 if (libNewSize.u.LowPart >= LIMIT_TO_USE_SMALL_BLOCK)
598 * Transform the small block chain into a big block chain
600 This->bigBlockChain = Storage32Impl_SmallBlocksToBigBlocks(
601 This->parentStorage->ancestorStorage,
602 &This->smallBlockChain);
606 if (This->smallBlockChain!=0)
608 Success = SmallBlockChainStream_SetSize(This->smallBlockChain, libNewSize);
610 else
612 Success = BlockChainStream_SetSize(This->bigBlockChain, libNewSize);
616 * Write the new information about this stream to the property
618 Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
619 This->ownerProperty,
620 &curProperty);
622 curProperty.size.u.HighPart = libNewSize.u.HighPart;
623 curProperty.size.u.LowPart = libNewSize.u.LowPart;
625 if (Success)
627 StorageImpl_WriteProperty(This->parentStorage->ancestorStorage,
628 This->ownerProperty,
629 &curProperty);
632 This->streamSize = libNewSize;
634 return S_OK;
637 /***
638 * This method is part of the IStream interface.
640 * It will copy the 'cb' Bytes to 'pstm' IStream.
642 * See the documentation of IStream for more info.
644 static HRESULT WINAPI StgStreamImpl_CopyTo(
645 IStream* iface,
646 IStream* pstm, /* [unique][in] */
647 ULARGE_INTEGER cb, /* [in] */
648 ULARGE_INTEGER* pcbRead, /* [out] */
649 ULARGE_INTEGER* pcbWritten) /* [out] */
651 StgStreamImpl* const This=(StgStreamImpl*)iface;
652 HRESULT hr = S_OK;
653 BYTE tmpBuffer[128];
654 ULONG bytesRead, bytesWritten, copySize;
655 ULARGE_INTEGER totalBytesRead;
656 ULARGE_INTEGER totalBytesWritten;
658 TRACE("(%p, %p, %ld, %p, %p)\n",
659 iface, pstm, cb.u.LowPart, pcbRead, pcbWritten);
662 * Sanity check
665 if (!This->parentStorage)
666 return STG_E_REVERTED;
668 if ( pstm == 0 )
669 return STG_E_INVALIDPOINTER;
671 totalBytesRead.u.LowPart = totalBytesRead.u.HighPart = 0;
672 totalBytesWritten.u.LowPart = totalBytesWritten.u.HighPart = 0;
675 * use stack to store data temporarily
676 * there is surely a more performant way of doing it, for now this basic
677 * implementation will do the job
679 while ( cb.u.LowPart > 0 )
681 if ( cb.u.LowPart >= 128 )
682 copySize = 128;
683 else
684 copySize = cb.u.LowPart;
686 IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
688 totalBytesRead.u.LowPart += bytesRead;
690 IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
692 totalBytesWritten.u.LowPart += bytesWritten;
695 * Check that read & write operations were successful
697 if (bytesRead != bytesWritten)
699 hr = STG_E_MEDIUMFULL;
700 break;
703 if (bytesRead!=copySize)
704 cb.u.LowPart = 0;
705 else
706 cb.u.LowPart -= bytesRead;
710 * Update number of bytes read and written
712 if (pcbRead)
714 pcbRead->u.LowPart = totalBytesRead.u.LowPart;
715 pcbRead->u.HighPart = totalBytesRead.u.HighPart;
718 if (pcbWritten)
720 pcbWritten->u.LowPart = totalBytesWritten.u.LowPart;
721 pcbWritten->u.HighPart = totalBytesWritten.u.HighPart;
723 return hr;
726 /***
727 * This method is part of the IStream interface.
729 * For streams contained in structured storages, this method
730 * does nothing. This is what the documentation tells us.
732 * See the documentation of IStream for more info.
734 static HRESULT WINAPI StgStreamImpl_Commit(
735 IStream* iface,
736 DWORD grfCommitFlags) /* [in] */
738 StgStreamImpl* const This=(StgStreamImpl*)iface;
740 if (!This->parentStorage)
741 return STG_E_REVERTED;
743 return S_OK;
746 /***
747 * This method is part of the IStream interface.
749 * For streams contained in structured storages, this method
750 * does nothing. This is what the documentation tells us.
752 * See the documentation of IStream for more info.
754 static HRESULT WINAPI StgStreamImpl_Revert(
755 IStream* iface)
757 return S_OK;
760 static HRESULT WINAPI StgStreamImpl_LockRegion(
761 IStream* iface,
762 ULARGE_INTEGER libOffset, /* [in] */
763 ULARGE_INTEGER cb, /* [in] */
764 DWORD dwLockType) /* [in] */
766 StgStreamImpl* const This=(StgStreamImpl*)iface;
768 if (!This->parentStorage)
769 return STG_E_REVERTED;
771 FIXME("not implemented!\n");
772 return E_NOTIMPL;
775 static HRESULT WINAPI StgStreamImpl_UnlockRegion(
776 IStream* iface,
777 ULARGE_INTEGER libOffset, /* [in] */
778 ULARGE_INTEGER cb, /* [in] */
779 DWORD dwLockType) /* [in] */
781 StgStreamImpl* const This=(StgStreamImpl*)iface;
783 if (!This->parentStorage)
784 return STG_E_REVERTED;
786 FIXME("not implemented!\n");
787 return E_NOTIMPL;
790 /***
791 * This method is part of the IStream interface.
793 * This method returns information about the current
794 * stream.
796 * See the documentation of IStream for more info.
798 static HRESULT WINAPI StgStreamImpl_Stat(
799 IStream* iface,
800 STATSTG* pstatstg, /* [out] */
801 DWORD grfStatFlag) /* [in] */
803 StgStreamImpl* const This=(StgStreamImpl*)iface;
805 StgProperty curProperty;
806 BOOL readSucessful;
809 * if stream has no parent, return STG_E_REVERTED
812 if (!This->parentStorage)
813 return STG_E_REVERTED;
816 * Read the information from the property.
818 readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
819 This->ownerProperty,
820 &curProperty);
822 if (readSucessful)
824 StorageUtl_CopyPropertyToSTATSTG(pstatstg,
825 &curProperty,
826 grfStatFlag);
828 pstatstg->grfMode = This->grfMode;
830 return S_OK;
833 return E_FAIL;
836 /***
837 * This method is part of the IStream interface.
839 * This method returns a clone of the interface that allows for
840 * another seek pointer
842 * See the documentation of IStream for more info.
844 * I am not totally sure what I am doing here but I presume that this
845 * should be basically as simple as creating a new stream with the same
846 * parent etc and positioning its seek cursor.
848 static HRESULT WINAPI StgStreamImpl_Clone(
849 IStream* iface,
850 IStream** ppstm) /* [out] */
852 StgStreamImpl* const This=(StgStreamImpl*)iface;
853 HRESULT hres;
854 StgStreamImpl* new_stream;
855 LARGE_INTEGER seek_pos;
858 * Sanity check
861 if (!This->parentStorage)
862 return STG_E_REVERTED;
864 if ( ppstm == 0 )
865 return STG_E_INVALIDPOINTER;
867 new_stream = StgStreamImpl_Construct (This->parentStorage, This->grfMode, This->ownerProperty);
869 if (!new_stream)
870 return STG_E_INSUFFICIENTMEMORY; /* Currently the only reason for new_stream=0 */
872 *ppstm = (IStream*) new_stream;
873 seek_pos.QuadPart = This->currentPosition.QuadPart;
875 hres=StgStreamImpl_Seek (*ppstm, seek_pos, STREAM_SEEK_SET, NULL);
877 assert (SUCCEEDED(hres));
879 return S_OK;
883 * Virtual function table for the StgStreamImpl class.
885 static const IStreamVtbl StgStreamImpl_Vtbl =
887 StgStreamImpl_QueryInterface,
888 StgStreamImpl_AddRef,
889 StgStreamImpl_Release,
890 StgStreamImpl_Read,
891 StgStreamImpl_Write,
892 StgStreamImpl_Seek,
893 StgStreamImpl_SetSize,
894 StgStreamImpl_CopyTo,
895 StgStreamImpl_Commit,
896 StgStreamImpl_Revert,
897 StgStreamImpl_LockRegion,
898 StgStreamImpl_UnlockRegion,
899 StgStreamImpl_Stat,
900 StgStreamImpl_Clone
903 /******************************************************************************
904 ** StgStreamImpl implementation
907 /***
908 * This is the constructor for the StgStreamImpl class.
910 * Params:
911 * parentStorage - Pointer to the storage that contains the stream to open
912 * ownerProperty - Index of the property that points to this stream.
914 StgStreamImpl* StgStreamImpl_Construct(
915 StorageBaseImpl* parentStorage,
916 DWORD grfMode,
917 ULONG ownerProperty)
919 StgStreamImpl* newStream;
921 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(StgStreamImpl));
923 if (newStream!=0)
926 * Set-up the virtual function table and reference count.
928 newStream->lpVtbl = &StgStreamImpl_Vtbl;
929 newStream->ref = 0;
931 newStream->parentStorage = parentStorage;
934 * We want to nail-down the reference to the storage in case the
935 * stream out-lives the storage in the client application.
937 * -- IStorage_AddRef((IStorage*)newStream->parentStorage);
939 * No, don't do this. Some apps call IStorage_Release without
940 * calling IStream_Release first. If we grab a reference the
941 * file is not closed, and the app fails when it tries to
942 * reopen the file (Easy-PC, for example)
945 newStream->grfMode = grfMode;
946 newStream->ownerProperty = ownerProperty;
949 * Start the stream at the beginning.
951 newStream->currentPosition.u.HighPart = 0;
952 newStream->currentPosition.u.LowPart = 0;
955 * Initialize the rest of the data.
957 newStream->streamSize.u.HighPart = 0;
958 newStream->streamSize.u.LowPart = 0;
959 newStream->bigBlockChain = 0;
960 newStream->smallBlockChain = 0;
963 * Read the size from the property and determine if the blocks forming
964 * this stream are large or small.
966 StgStreamImpl_OpenBlockChain(newStream);
969 return newStream;