ole32: Reserve the range lock sector.

This commit is contained in:
Vincent Povirk 2014-04-23 13:18:10 -05:00 committed by Alexandre Julliard
parent a00f43d7e0
commit e6c58c74ad
1 changed files with 21 additions and 4 deletions

View File

@ -111,7 +111,7 @@ static void StorageImpl_SetNextBlockInChain(StorageImpl* This, ULONG blockIndex,
static HRESULT StorageImpl_LoadFileHeader(StorageImpl* This); static HRESULT StorageImpl_LoadFileHeader(StorageImpl* This);
static void StorageImpl_SaveFileHeader(StorageImpl* This); static void StorageImpl_SaveFileHeader(StorageImpl* This);
static void Storage32Impl_AddBlockDepot(StorageImpl* This, ULONG blockIndex); static void Storage32Impl_AddBlockDepot(StorageImpl* This, ULONG blockIndex, ULONG depotIndex);
static ULONG Storage32Impl_AddExtBlockDepot(StorageImpl* This); static ULONG Storage32Impl_AddExtBlockDepot(StorageImpl* This);
static ULONG Storage32Impl_GetNextExtendedBlock(StorageImpl* This, ULONG blockIndex); static ULONG Storage32Impl_GetNextExtendedBlock(StorageImpl* This, ULONG blockIndex);
static ULONG Storage32Impl_GetExtDepotBlock(StorageImpl* This, ULONG depotIndex); static ULONG Storage32Impl_GetExtDepotBlock(StorageImpl* This, ULONG depotIndex);
@ -3111,7 +3111,7 @@ static ULONG StorageImpl_GetNextFreeBigBlock(
/* /*
* Add a block depot. * Add a block depot.
*/ */
Storage32Impl_AddBlockDepot(This, depotBlockIndexPos); Storage32Impl_AddBlockDepot(This, depotBlockIndexPos, depotIndex);
This->bigBlockDepotCount++; This->bigBlockDepotCount++;
This->bigBlockDepotStart[depotIndex] = depotBlockIndexPos; This->bigBlockDepotStart[depotIndex] = depotBlockIndexPos;
@ -3154,7 +3154,7 @@ static ULONG StorageImpl_GetNextFreeBigBlock(
/* /*
* Add a block depot and mark it in the extended block. * Add a block depot and mark it in the extended block.
*/ */
Storage32Impl_AddBlockDepot(This, depotBlockIndexPos); Storage32Impl_AddBlockDepot(This, depotBlockIndexPos, depotIndex);
This->bigBlockDepotCount++; This->bigBlockDepotCount++;
Storage32Impl_SetExtDepotBlock(This, depotIndex, depotBlockIndexPos); Storage32Impl_SetExtDepotBlock(This, depotIndex, depotBlockIndexPos);
@ -3219,14 +3219,24 @@ static ULONG StorageImpl_GetNextFreeBigBlock(
* This will create a depot block, essentially it is a block initialized * This will create a depot block, essentially it is a block initialized
* to BLOCK_UNUSEDs. * to BLOCK_UNUSEDs.
*/ */
static void Storage32Impl_AddBlockDepot(StorageImpl* This, ULONG blockIndex) static void Storage32Impl_AddBlockDepot(StorageImpl* This, ULONG blockIndex, ULONG depotIndex)
{ {
BYTE blockBuffer[MAX_BIG_BLOCK_SIZE]; BYTE blockBuffer[MAX_BIG_BLOCK_SIZE];
ULONG rangeLockIndex = 0x7fffff00 / This->bigBlockSize - 1;
ULONG blocksPerDepot = This->bigBlockSize / sizeof(ULONG);
ULONG rangeLockDepot = rangeLockIndex / blocksPerDepot;
/* /*
* Initialize blocks as free * Initialize blocks as free
*/ */
memset(blockBuffer, BLOCK_UNUSED, This->bigBlockSize); memset(blockBuffer, BLOCK_UNUSED, This->bigBlockSize);
/* Reserve the range lock sector */
if (depotIndex == rangeLockDepot)
{
((ULONG*)blockBuffer)[rangeLockIndex % blocksPerDepot] = BLOCK_END_OF_CHAIN;
}
StorageImpl_WriteBigBlock(This, blockIndex, blockBuffer); StorageImpl_WriteBigBlock(This, blockIndex, blockBuffer);
} }
@ -3523,6 +3533,13 @@ static void StorageImpl_SetNextBlockInChain(
assert(depotBlockCount < This->bigBlockDepotCount); assert(depotBlockCount < This->bigBlockDepotCount);
assert(blockIndex != nextBlock); assert(blockIndex != nextBlock);
if (blockIndex == (0x7fffff00 / This->bigBlockSize) - 1)
/* This should never happen (storage file format spec forbids it), but
* older versions of Wine may have generated broken files. We don't want to
* assert and potentially lose data, but we do want to know if this ever
* happens in a newly-created file. */
ERR("Using range lock page\n");
if (depotBlockCount < COUNT_BBDEPOTINHEADER) if (depotBlockCount < COUNT_BBDEPOTINHEADER)
{ {
depotBlockIndexPos = This->bigBlockDepotStart[depotBlockCount]; depotBlockIndexPos = This->bigBlockDepotStart[depotBlockCount];