From 9809b7fd06538394d951a4aa996e36571a5fbe29 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 28 Oct 2009 12:49:09 -0500 Subject: [PATCH 05/20] ole32: Use the raw directory entry functions in getFreeProperty. The meaning of the "index" argument in Read/WriteProperty will likely change in the future, but getFreeProperty must work with real indexes into the file's real directory stream. --- dlls/ole32/storage32.c | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 86c174b..b1f19f3 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -1182,20 +1182,24 @@ static ULONG getFreeProperty( { ULONG currentPropertyIndex = 0; ULONG newPropertyIndex = PROPERTY_NULL; - BOOL readSuccessful = TRUE; - StgProperty currentProperty; + HRESULT readRes = S_OK; + BYTE currentData[PROPSET_BLOCK_SIZE]; + WORD sizeOfNameString; do { - /* - * Start by reading the root property - */ - readSuccessful = StorageImpl_ReadProperty(storage->base.ancestorStorage, - currentPropertyIndex, - ¤tProperty); - if (readSuccessful) + readRes = StorageImpl_ReadRawDirEntry(storage->base.ancestorStorage, + currentPropertyIndex, + currentData); + + if (SUCCEEDED(readRes)) { - if (currentProperty.sizeOfNameString == 0) + StorageUtl_ReadWord( + currentData, + OFFSET_PS_NAMELENGTH, + &sizeOfNameString); + + if (sizeOfNameString == 0) { /* * The property existis and is available, we found it. @@ -1217,9 +1221,9 @@ static ULONG getFreeProperty( /* * grow the property chain */ - if (! readSuccessful) + if (!SUCCEEDED(readRes)) { - StgProperty emptyProperty; + BYTE emptyData[PROPSET_BLOCK_SIZE]; ULARGE_INTEGER newSize; ULONG propertyIndex; ULONG lastProperty = 0; @@ -1246,7 +1250,7 @@ static ULONG getFreeProperty( * memset the empty property in order to initialize the unused newly * created property */ - memset(&emptyProperty, 0, sizeof(StgProperty)); + memset(&emptyData, 0, PROPSET_BLOCK_SIZE); /* * initialize them @@ -1258,10 +1262,10 @@ static ULONG getFreeProperty( propertyIndex < lastProperty; propertyIndex++) { - StorageImpl_WriteProperty( + StorageImpl_WriteRawDirEntry( storage->base.ancestorStorage, propertyIndex, - &emptyProperty); + emptyData); } } -- 1.6.3.3