[Wine-patches] [eter-1.0.12] eterbug #6935
Alexander Morozov
amorozov на etersoft.ru
Пт Мар 4 22:18:32 MSK 2011
----------- следующая часть -----------
From e8a8239736c2a4f6ae7776b275d2c2be358d4575 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent на codeweavers.com>
Date: Wed, 10 Mar 2010 13:49:04 -0600
Subject: [PATCH 1/8] ole32: Don't treat the header as a big block in StorageImpl_LoadFileHeader.
The header is always 512 bytes, regardless of the big block size.
---
dlls/ole32/storage32.c | 17 +++++++++++------
dlls/ole32/storage32.h | 2 ++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 6e7278c..027fd63 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -3055,26 +3055,31 @@ static void StorageImpl_SetNextBlockInChain(
/******************************************************************************
* Storage32Impl_LoadFileHeader
*
- * This method will read in the file header, i.e. big block index -1.
+ * This method will read in the file header
*/
static HRESULT StorageImpl_LoadFileHeader(
StorageImpl* This)
{
- HRESULT hr = STG_E_FILENOTFOUND;
- BYTE headerBigBlock[BIG_BLOCK_SIZE];
- BOOL success;
+ HRESULT hr;
+ BYTE headerBigBlock[HEADER_SIZE];
int index;
+ ULARGE_INTEGER offset;
+ DWORD bytes_read;
TRACE("\n");
/*
* Get a pointer to the big block of data containing the header.
*/
- success = StorageImpl_ReadBigBlock(This, -1, headerBigBlock);
+ offset.u.HighPart = 0;
+ offset.u.LowPart = 0;
+ hr = StorageImpl_ReadAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_read);
+ if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE)
+ hr = STG_E_FILENOTFOUND;
/*
* Extract the information from the header.
*/
- if (success)
+ if (SUCCEEDED(hr))
{
/*
* Check for the "magic number" signature and return an error if it is not
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index 1e40b3a..abe2c7a 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -79,6 +79,8 @@ static const ULONG PROPERTY_NULL = 0xFFFFFFFF;
#define PROPSET_BLOCK_SIZE 0x00000080
+#define HEADER_SIZE 512
+
/*
* Property type of relation
*/
--
1.7.4.1
----------- следующая часть -----------
From 5e9c9bf74d7a1e01eb8f3bf7cad6f45cd62a39ea Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent на codeweavers.com>
Date: Wed, 10 Mar 2010 13:57:35 -0600
Subject: [PATCH 2/8] ole32: Don't treat the header as a big block in StorageImpl_SaveFileHeader.
---
dlls/ole32/storage32.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 027fd63..47ae5b7 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -3164,29 +3164,35 @@ static HRESULT StorageImpl_LoadFileHeader(
/******************************************************************************
* Storage32Impl_SaveFileHeader
*
- * This method will save to the file the header, i.e. big block -1.
+ * This method will save to the file the header
*/
static void StorageImpl_SaveFileHeader(
StorageImpl* This)
{
- BYTE headerBigBlock[BIG_BLOCK_SIZE];
+ BYTE headerBigBlock[HEADER_SIZE];
int index;
- BOOL success;
+ HRESULT hr;
+ ULARGE_INTEGER offset;
+ DWORD bytes_read, bytes_written;
/*
* Get a pointer to the big block of data containing the header.
*/
- success = StorageImpl_ReadBigBlock(This, -1, headerBigBlock);
+ offset.u.HighPart = 0;
+ offset.u.LowPart = 0;
+ hr = StorageImpl_ReadAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_read);
+ if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE)
+ hr = STG_E_FILENOTFOUND;
/*
* If the block read failed, the file is probably new.
*/
- if (!success)
+ if (FAILED(hr))
{
/*
* Initialize for all unknown fields.
*/
- memset(headerBigBlock, 0, BIG_BLOCK_SIZE);
+ memset(headerBigBlock, 0, HEADER_SIZE);
/*
* Initialize the magic number.
@@ -3257,7 +3263,7 @@ static void StorageImpl_SaveFileHeader(
/*
* Write the big block back to the file.
*/
- StorageImpl_WriteBigBlock(This, -1, headerBigBlock);
+ StorageImpl_WriteAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_written);
}
/******************************************************************************
--
1.7.4.1
----------- следующая часть -----------
From 331a67fc7c54b3a8e02190744acb2134c52311f8 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent на codeweavers.com>
Date: Wed, 10 Mar 2010 14:03:12 -0600
Subject: [PATCH 3/8] ole32: Fix the big block offset calculation.
Use the actual big block size from the open storage file. Also, remove a
special case that was only used for reading/writing the header.
---
dlls/ole32/storage32.c | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 47ae5b7..6ec1694 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -252,14 +252,9 @@ static INT IEnumSTATSTGImpl_FindParentProperty(IEnumSTATSTGImpl *This, ULONG chi
** Block Functions
*/
-static ULONG BLOCK_GetBigBlockOffset(ULONG index)
+static ULONG StorageImpl_GetBigBlockOffset(StorageImpl* This, ULONG index)
{
- if (index == 0xffffffff)
- index = 0;
- else
- index ++;
-
- return index * BIG_BLOCK_SIZE;
+ return (index+1) * This->bigBlockSize;
}
/************************************************************************
@@ -3464,7 +3459,7 @@ static BOOL StorageImpl_ReadBigBlock(
DWORD read;
ulOffset.u.HighPart = 0;
- ulOffset.u.LowPart = BLOCK_GetBigBlockOffset(blockIndex);
+ ulOffset.u.LowPart = StorageImpl_GetBigBlockOffset(This, blockIndex);
StorageImpl_ReadAt(This, ulOffset, buffer, This->bigBlockSize, &read);
return (read == This->bigBlockSize);
@@ -3481,7 +3476,7 @@ static BOOL StorageImpl_ReadDWordFromBigBlock(
DWORD tmp;
ulOffset.u.HighPart = 0;
- ulOffset.u.LowPart = BLOCK_GetBigBlockOffset(blockIndex);
+ ulOffset.u.LowPart = StorageImpl_GetBigBlockOffset(This, blockIndex);
ulOffset.u.LowPart += offset;
StorageImpl_ReadAt(This, ulOffset, &tmp, sizeof(DWORD), &read);
@@ -3498,7 +3493,7 @@ static BOOL StorageImpl_WriteBigBlock(
DWORD wrote;
ulOffset.u.HighPart = 0;
- ulOffset.u.LowPart = BLOCK_GetBigBlockOffset(blockIndex);
+ ulOffset.u.LowPart = StorageImpl_GetBigBlockOffset(This, blockIndex);
StorageImpl_WriteAt(This, ulOffset, buffer, This->bigBlockSize, &wrote);
return (wrote == This->bigBlockSize);
@@ -3514,7 +3509,7 @@ static BOOL StorageImpl_WriteDWordToBigBlock(
DWORD wrote;
ulOffset.u.HighPart = 0;
- ulOffset.u.LowPart = BLOCK_GetBigBlockOffset(blockIndex);
+ ulOffset.u.LowPart = StorageImpl_GetBigBlockOffset(This, blockIndex);
ulOffset.u.LowPart += offset;
value = htole32(value);
@@ -4557,7 +4552,7 @@ HRESULT BlockChainStream_ReadAt(BlockChainStream* This,
TRACE("block %i\n",blockIndex);
ulOffset.u.HighPart = 0;
- ulOffset.u.LowPart = BLOCK_GetBigBlockOffset(blockIndex) +
+ ulOffset.u.LowPart = StorageImpl_GetBigBlockOffset(This->parentStorage, blockIndex) +
offsetInBlock;
StorageImpl_ReadAt(This->parentStorage,
@@ -4654,7 +4649,7 @@ HRESULT BlockChainStream_WriteAt(BlockChainStream* This,
TRACE("block %i\n",blockIndex);
ulOffset.u.HighPart = 0;
- ulOffset.u.LowPart = BLOCK_GetBigBlockOffset(blockIndex) +
+ ulOffset.u.LowPart = StorageImpl_GetBigBlockOffset(This->parentStorage, blockIndex) +
offsetInBlock;
StorageImpl_WriteAt(This->parentStorage,
--
1.7.4.1
----------- следующая часть -----------
From 59864e0beb6483198173c0551dce6964a66cf826 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent на codeweavers.com>
Date: Wed, 10 Mar 2010 16:36:54 -0600
Subject: [PATCH 4/8] ole32: Remove the unused BlockBits structures from BigBlockFile objects.
---
dlls/ole32/stg_bigblockfile.c | 51 -----------------------------------------
1 files changed, 0 insertions(+), 51 deletions(-)
diff --git a/dlls/ole32/stg_bigblockfile.c b/dlls/ole32/stg_bigblockfile.c
index 19151b9..4aa3026 100644
--- a/dlls/ole32/stg_bigblockfile.c
+++ b/dlls/ole32/stg_bigblockfile.c
@@ -63,19 +63,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage);
/* We map in PAGE_SIZE-sized chunks. Must be a multiple of 4096. */
#define PAGE_SIZE 131072
-#define BLOCKS_PER_PAGE (PAGE_SIZE / BIG_BLOCK_SIZE)
-
/* We keep a list of recently-discarded pages. This controls the
* size of that list. */
#define MAX_VICTIM_PAGES 16
-/* This structure provides one bit for each block in a page.
- * Use BIGBLOCKFILE_{Test,Set,Clear}Bit to manipulate it. */
-typedef struct
-{
- unsigned int bits[BLOCKS_PER_PAGE / (CHAR_BIT * sizeof(unsigned int))];
-} BlockBits;
-
/***
* This structure identifies the paged that are mapped
* from the file and their position in memory. It is
@@ -96,9 +87,6 @@ struct MappedPage
DWORD mapped_bytes;
LPVOID lpBytes;
LONG refcnt;
-
- BlockBits readable_blocks;
- BlockBits writable_blocks;
};
struct BigBlockFile
@@ -123,39 +111,6 @@ struct BigBlockFile
* pass expressions with side effects. */
#define ROUND_UP(a, b) ((((a) + (b) - 1)/(b))*(b))
-/***********************************************************
- * Blockbits functions.
- */
-static inline BOOL BIGBLOCKFILE_TestBit(const BlockBits *bb,
- unsigned int index)
-{
- unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
- unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
-
- return bb->bits[array_index] & (1 << bit_index);
-}
-
-static inline void BIGBLOCKFILE_SetBit(BlockBits *bb, unsigned int index)
-{
- unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
- unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
-
- bb->bits[array_index] |= (1 << bit_index);
-}
-
-static inline void BIGBLOCKFILE_ClearBit(BlockBits *bb, unsigned int index)
-{
- unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
- unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
-
- bb->bits[array_index] &= ~(1 << bit_index);
-}
-
-static inline void BIGBLOCKFILE_Zero(BlockBits *bb)
-{
- memset(bb->bits, 0, sizeof(bb->bits));
-}
-
/******************************************************************************
* BIGBLOCKFILE_FileInit
*
@@ -302,9 +257,6 @@ static MappedPage *BIGBLOCKFILE_CreatePage(BigBlockFile *This, ULONG page_index)
return NULL;
}
- BIGBLOCKFILE_Zero(&page->readable_blocks);
- BIGBLOCKFILE_Zero(&page->writable_blocks);
-
return page;
}
@@ -328,9 +280,6 @@ static void * BIGBLOCKFILE_GetMappedView(
if (page)
{
This->num_victim_pages--;
-
- BIGBLOCKFILE_Zero(&page->readable_blocks);
- BIGBLOCKFILE_Zero(&page->writable_blocks);
}
}
--
1.7.4.1
----------- следующая часть -----------
From 9425a51a046299939666257056a66019741dd3e3 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent на codeweavers.com>
Date: Wed, 10 Mar 2010 14:46:53 -0600
Subject: [PATCH 5/8] ole32: Remove the BIG_BLOCK_SIZE define.
Big block sizes can be 512 or 4096, so we define arrays that are large
enough in either case.
---
dlls/ole32/storage32.c | 12 ++++++------
dlls/ole32/storage32.h | 4 +++-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 6ec1694..01c4eea 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -2445,7 +2445,7 @@ static HRESULT StorageImpl_Construct(
if (fileCreate)
{
ULARGE_INTEGER size;
- BYTE bigBlockBuffer[BIG_BLOCK_SIZE];
+ BYTE bigBlockBuffer[MAX_BIG_BLOCK_SIZE];
/*
* Initialize all header variables:
@@ -2613,7 +2613,7 @@ static ULONG StorageImpl_GetNextFreeBigBlock(
StorageImpl* This)
{
ULONG depotBlockIndexPos;
- BYTE depotBuffer[BIG_BLOCK_SIZE];
+ BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
BOOL success;
ULONG depotBlockOffset;
ULONG blocksPerDepot = This->bigBlockSize / sizeof(ULONG);
@@ -2748,7 +2748,7 @@ static ULONG StorageImpl_GetNextFreeBigBlock(
*/
static void Storage32Impl_AddBlockDepot(StorageImpl* This, ULONG blockIndex)
{
- BYTE blockBuffer[BIG_BLOCK_SIZE];
+ BYTE blockBuffer[MAX_BIG_BLOCK_SIZE];
/*
* Initialize blocks as free
@@ -2831,7 +2831,7 @@ static ULONG Storage32Impl_AddExtBlockDepot(StorageImpl* This)
{
ULONG numExtBlocks = This->extBigBlockDepotCount;
ULONG nextExtBlock = This->extBigBlockDepotStart;
- BYTE depotBuffer[BIG_BLOCK_SIZE];
+ BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
ULONG index = BLOCK_UNUSED;
ULONG nextBlockOffset = This->bigBlockSize - sizeof(ULONG);
ULONG blocksPerDepotBlock = This->bigBlockSize / sizeof(ULONG);
@@ -2921,7 +2921,7 @@ static HRESULT StorageImpl_GetNextBlockInChain(
ULONG offsetInDepot = blockIndex * sizeof (ULONG);
ULONG depotBlockCount = offsetInDepot / This->bigBlockSize;
ULONG depotBlockOffset = offsetInDepot % This->bigBlockSize;
- BYTE depotBuffer[BIG_BLOCK_SIZE];
+ BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
BOOL success;
ULONG depotBlockIndexPos;
int index;
@@ -5119,7 +5119,7 @@ static ULONG SmallBlockChainStream_GetNextFreeBlock(
ULONG sbdIndex = This->parentStorage->smallBlockDepotStart;
ULONG nextBlock, newsbdIndex;
- BYTE smallBlockDepot[BIG_BLOCK_SIZE];
+ BYTE smallBlockDepot[MAX_BIG_BLOCK_SIZE];
nextBlock = sbdIndex;
while (nextBlock != BLOCK_END_OF_CHAIN)
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index abe2c7a..67fda06 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -81,6 +81,9 @@ static const ULONG PROPERTY_NULL = 0xFFFFFFFF;
#define HEADER_SIZE 512
+#define MIN_BIG_BLOCK_SIZE 0x200
+#define MAX_BIG_BLOCK_SIZE 0x1000
+
/*
* Property type of relation
*/
@@ -100,7 +103,6 @@ static const ULONG PROPERTY_NULL = 0xFFFFFFFF;
* if the blocksize is different. Some changes will have to be done if it
* becomes the case.
*/
-#define BIG_BLOCK_SIZE 0x200
#define COUNT_BBDEPOTINHEADER 109
#define LIMIT_TO_USE_SMALL_BLOCK 0x1000
#define NUM_BLOCKS_PER_DEPOT_BLOCK 128
--
1.7.4.1
----------- следующая часть -----------
From 6e5a8152c9f105df68ce00de4dcdb34f6097e514 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent на codeweavers.com>
Date: Wed, 10 Mar 2010 14:51:37 -0600
Subject: [PATCH 6/8] ole32: Remove the NUM_BLOCKS_PER_DEPOT_BLOCK define.
This should always be calculated based on the big block size.
---
dlls/ole32/storage32.c | 6 ++++--
dlls/ole32/storage32.h | 8 +-------
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 01c4eea..afead73 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -2924,7 +2924,7 @@ static HRESULT StorageImpl_GetNextBlockInChain(
BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
BOOL success;
ULONG depotBlockIndexPos;
- int index;
+ int index, num_blocks;
*nextBlockIndex = BLOCK_SPECIAL;
@@ -2959,7 +2959,9 @@ static HRESULT StorageImpl_GetNextBlockInChain(
if (!success)
return STG_E_READFAULT;
- for (index = 0; index < NUM_BLOCKS_PER_DEPOT_BLOCK; index++)
+ num_blocks = This->bigBlockSize / 4;
+
+ for (index = 0; index < num_blocks; index++)
{
StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), nextBlockIndex);
This->blockDepotCached[index] = *nextBlockIndex;
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index 67fda06..53e0677 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -98,14 +98,8 @@ static const ULONG PROPERTY_NULL = 0xFFFFFFFF;
#define PROPTYPE_STREAM 0x02
#define PROPTYPE_ROOT 0x05
-/*
- * These defines assume a hardcoded blocksize. The code will assert
- * if the blocksize is different. Some changes will have to be done if it
- * becomes the case.
- */
#define COUNT_BBDEPOTINHEADER 109
#define LIMIT_TO_USE_SMALL_BLOCK 0x1000
-#define NUM_BLOCKS_PER_DEPOT_BLOCK 128
#define STGM_ACCESS_MODE(stgm) ((stgm)&0x0000f)
#define STGM_SHARE_MODE(stgm) ((stgm)&0x000f0)
@@ -277,7 +271,7 @@ struct StorageImpl
ULONG extBigBlockDepotCount;
ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
- ULONG blockDepotCached[NUM_BLOCKS_PER_DEPOT_BLOCK];
+ ULONG blockDepotCached[MAX_BIG_BLOCK_SIZE / 4];
ULONG indexBlockDepotCached;
ULONG prevFreeBlock;
--
1.7.4.1
----------- следующая часть -----------
From 4c02ae018c684f1b75ca00df6976abc1270ad2b4 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent на codeweavers.com>
Date: Wed, 10 Mar 2010 15:03:35 -0600
Subject: [PATCH 7/8] ole32: Remove knowledge of block sizes from the BigBlockFile object.
We can't determine the correct block size until we read the header, and we
can't create the BigBlockFile until we know the correct block size. To
solve this dilemma, have StorageImpl calculate the file size it needs instead
of asking the BigBlockFile to "ensure a big block exists".
---
dlls/ole32/stg_bigblockfile.c | 24 +++++-------------------
dlls/ole32/storage32.c | 5 +++--
dlls/ole32/storage32.h | 3 +--
3 files changed, 9 insertions(+), 23 deletions(-)
diff --git a/dlls/ole32/stg_bigblockfile.c b/dlls/ole32/stg_bigblockfile.c
index 4aa3026..77abbf6 100644
--- a/dlls/ole32/stg_bigblockfile.c
+++ b/dlls/ole32/stg_bigblockfile.c
@@ -93,7 +93,6 @@ struct BigBlockFile
{
BOOL fileBased;
ULARGE_INTEGER filesize;
- ULONG blocksize;
HANDLE hfile;
HANDLE hfilemap;
DWORD flProtect;
@@ -658,7 +657,7 @@ static HRESULT ImplBIGBLOCKFILE_WriteAt(
* and the blocks in use list.
*/
BigBlockFile *BIGBLOCKFILE_Construct(HANDLE hFile, ILockBytes* pLkByt, DWORD openFlags,
- ULONG blocksize, BOOL fileBased)
+ BOOL fileBased)
{
BigBlockFile *This;
@@ -669,7 +668,6 @@ BigBlockFile *BIGBLOCKFILE_Construct(HANDLE hFile, ILockBytes* pLkByt, DWORD ope
This->fileBased = fileBased;
This->flProtect = BIGBLOCKFILE_GetProtectMode(openFlags);
- This->blocksize = blocksize;
This->maplist = NULL;
This->victimhead = NULL;
@@ -812,31 +810,19 @@ static HRESULT BIGBLOCKFILE_GetSize(BigBlockFile *This, ULARGE_INTEGER *size)
}
/******************************************************************************
- * BIGBLOCKFILE_EnsureExists
+ * BIGBLOCKFILE_Expand
*
- * Grows the file if necessary to make sure the block is valid.
+ * Grows the file to the specified size if necessary.
*/
-HRESULT BIGBLOCKFILE_EnsureExists(BigBlockFile *This, ULONG index)
+HRESULT BIGBLOCKFILE_Expand(BigBlockFile *This, ULARGE_INTEGER newSize)
{
ULARGE_INTEGER size;
HRESULT hr;
- /* Block index starts at -1 translate to zero based index */
- if (index == 0xffffffff)
- index = 0;
- else
- index++;
-
hr = BIGBLOCKFILE_GetSize(This, &size);
if(FAILED(hr)) return hr;
- /* make sure that the block physically exists */
- if ((This->blocksize * (index + 1)) > size.QuadPart)
- {
- ULARGE_INTEGER newSize;
-
- newSize.QuadPart = This->blocksize * (index + 1);
+ if (newSize.QuadPart > size.QuadPart)
hr = BIGBLOCKFILE_SetSize(This, newSize);
- }
return hr;
}
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index afead73..9d99429 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -2436,7 +2436,6 @@ static HRESULT StorageImpl_Construct(
This->bigBlockFile = BIGBLOCKFILE_Construct(hFile,
pLkbyt,
openFlags,
- This->bigBlockSize,
fileBased);
if (This->bigBlockFile == 0)
@@ -2620,6 +2619,7 @@ static ULONG StorageImpl_GetNextFreeBigBlock(
ULONG nextBlockIndex = BLOCK_SPECIAL;
int depotIndex = 0;
ULONG freeBlock = BLOCK_UNUSED;
+ ULARGE_INTEGER neededSize;
depotIndex = This->prevFreeBlock / blocksPerDepot;
depotBlockOffset = (This->prevFreeBlock % blocksPerDepot) * sizeof(ULONG);
@@ -2733,7 +2733,8 @@ static ULONG StorageImpl_GetNextFreeBigBlock(
/*
* make sure that the block physically exists before using it
*/
- BIGBLOCKFILE_EnsureExists(This->bigBlockFile, freeBlock);
+ neededSize.QuadPart = StorageImpl_GetBigBlockOffset(This, freeBlock)+This->bigBlockSize;
+ BIGBLOCKFILE_Expand(This->bigBlockFile, neededSize);
This->prevFreeBlock = freeBlock;
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index 53e0677..de2a468 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -159,10 +159,9 @@ typedef struct BigBlockFile BigBlockFile,*LPBIGBLOCKFILE;
BigBlockFile* BIGBLOCKFILE_Construct(HANDLE hFile,
ILockBytes* pLkByt,
DWORD openFlags,
- ULONG blocksize,
BOOL fileBased);
void BIGBLOCKFILE_Destructor(LPBIGBLOCKFILE This);
-HRESULT BIGBLOCKFILE_EnsureExists(LPBIGBLOCKFILE This, ULONG index);
+HRESULT BIGBLOCKFILE_Expand(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize);
HRESULT BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize);
HRESULT BIGBLOCKFILE_ReadAt(LPBIGBLOCKFILE This, ULARGE_INTEGER offset,
void* buffer, ULONG size, ULONG* bytesRead);
--
1.7.4.1
----------- следующая часть -----------
From a81059a06f97f7aedd37101febd8d3e45d6db3a8 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent на codeweavers.com>
Date: Wed, 10 Mar 2010 15:08:57 -0600
Subject: [PATCH 8/8] ole32: Allow storage files with a block size of 4096 to open.
---
dlls/ole32/storage32.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 9d99429..21f8e1c 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -3146,7 +3146,7 @@ static HRESULT StorageImpl_LoadFileHeader(
* Right now, the code is making some assumptions about the size of the
* blocks, just make sure they are what we're expecting.
*/
- if (This->bigBlockSize != DEF_BIG_BLOCK_SIZE ||
+ if ((This->bigBlockSize != MIN_BIG_BLOCK_SIZE && This->bigBlockSize != MAX_BIG_BLOCK_SIZE) ||
This->smallBlockSize != DEF_SMALL_BLOCK_SIZE)
{
WARN("Broken OLE storage file\n");
--
1.7.4.1
Подробная информация о списке рассылки Wine-patches