Changeset 9400 for trunk/src/ole32/storage32.c
- Timestamp:
- Nov 12, 2002, 6:07:48 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/storage32.c
r8620 r9400 2321 2321 * Create the block chain abstractions. 2322 2322 */ 2323 This->rootBlockChain = 2324 BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL); 2325 2326 This->smallBlockDepotChain = BlockChainStream_Construct( 2327 This, 2328 &This->smallBlockDepotStart, 2329 PROPERTY_NULL); 2323 if(!(This->rootBlockChain = 2324 BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL))) 2325 return STG_E_READFAULT; 2326 2327 if(!(This->smallBlockDepotChain = 2328 BlockChainStream_Construct(This, &This->smallBlockDepotStart, 2329 PROPERTY_NULL))) 2330 return STG_E_READFAULT; 2330 2331 2331 2332 /* … … 2381 2382 { 2382 2383 /* TODO CLEANUP */ 2383 return E_FAIL;2384 return STG_E_READFAULT; 2384 2385 } 2385 2386 … … 2387 2388 * Create the block chain abstraction for the small block root chain. 2388 2389 */ 2389 This->smallBlockRootChain = BlockChainStream_Construct( 2390 This, 2391 NULL, 2392 This->rootPropertySetIndex); 2390 if(!(This->smallBlockRootChain = 2391 BlockChainStream_Construct(This, NULL, This->rootPropertySetIndex))) 2392 return STG_E_READFAULT; 2393 2393 2394 2394 return hr; … … 2731 2731 * blockIndex - Index of the block to retrieve the chain 2732 2732 * for. 2733 * nextBlockIndex - receives the return value. 2733 2734 * 2734 2735 * Returns: This method returns the index of the next block in the chain. … … 2745 2746 * See Windows documentation for more details on IStorage methods. 2746 2747 */ 2747 ULONGStorageImpl_GetNextBlockInChain(2748 HRESULT StorageImpl_GetNextBlockInChain( 2748 2749 StorageImpl* This, 2749 ULONG blockIndex) 2750 ULONG blockIndex, 2751 ULONG* nextBlockIndex) 2750 2752 { 2751 2753 ULONG offsetInDepot = blockIndex * sizeof (ULONG); 2752 2754 ULONG depotBlockCount = offsetInDepot / This->bigBlockSize; 2753 2755 ULONG depotBlockOffset = offsetInDepot % This->bigBlockSize; 2754 ULONG nextBlockIndex = BLOCK_SPECIAL;2755 2756 void* depotBuffer; 2756 2757 ULONG depotBlockIndexPos; 2757 2758 assert(depotBlockCount < This->bigBlockDepotCount); 2758 int index; 2759 2760 *nextBlockIndex = BLOCK_SPECIAL; 2761 2762 if(depotBlockCount >= This->bigBlockDepotCount) 2763 { 2764 WARN("depotBlockCount %ld, bigBlockDepotCount %ld\n", depotBlockCount, 2765 This->bigBlockDepotCount); 2766 return STG_E_READFAULT; 2767 } 2759 2768 2760 2769 /* … … 2779 2788 depotBuffer = StorageImpl_GetROBigBlock(This, depotBlockIndexPos); 2780 2789 2781 if (depotBuffer!=0) 2782 { 2783 int index; 2784 2785 for (index = 0; index < NUM_BLOCKS_PER_DEPOT_BLOCK; index++) 2786 { 2787 StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), &nextBlockIndex); 2788 This->blockDepotCached[index] = nextBlockIndex; 2789 } 2790 2791 StorageImpl_ReleaseBigBlock(This, depotBuffer); 2792 } 2793 } 2794 2795 nextBlockIndex = This->blockDepotCached[depotBlockOffset/sizeof(ULONG)]; 2796 2797 return nextBlockIndex; 2790 if (!depotBuffer) 2791 return STG_E_READFAULT; 2792 2793 for (index = 0; index < NUM_BLOCKS_PER_DEPOT_BLOCK; index++) 2794 { 2795 StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), nextBlockIndex); 2796 This->blockDepotCached[index] = *nextBlockIndex; 2797 } 2798 StorageImpl_ReleaseBigBlock(This, depotBuffer); 2799 } 2800 2801 *nextBlockIndex = This->blockDepotCached[depotBlockOffset/sizeof(ULONG)]; 2802 2803 return S_OK; 2798 2804 } 2799 2805 … … 3044 3050 StorageUtl_WriteWord(headerBigBlock, 0x1c, (WORD)-2); 3045 3051 StorageUtl_WriteDWord(headerBigBlock, 0x38, (DWORD)0x1000); 3046 StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001);3047 3052 } 3048 3053 … … 3050 3055 * Write the information to the header. 3051 3056 */ 3052 if (headerBigBlock!=0) 3053 { 3054 StorageUtl_WriteWord( 3055 headerBigBlock, 3056 OFFSET_BIGBLOCKSIZEBITS, 3057 This->bigBlockSizeBits); 3058 3059 StorageUtl_WriteWord( 3060 headerBigBlock, 3061 OFFSET_SMALLBLOCKSIZEBITS, 3062 This->smallBlockSizeBits); 3063 3057 StorageUtl_WriteWord( 3058 headerBigBlock, 3059 OFFSET_BIGBLOCKSIZEBITS, 3060 This->bigBlockSizeBits); 3061 3062 StorageUtl_WriteWord( 3063 headerBigBlock, 3064 OFFSET_SMALLBLOCKSIZEBITS, 3065 This->smallBlockSizeBits); 3066 3067 StorageUtl_WriteDWord( 3068 headerBigBlock, 3069 OFFSET_BBDEPOTCOUNT, 3070 This->bigBlockDepotCount); 3071 3072 StorageUtl_WriteDWord( 3073 headerBigBlock, 3074 OFFSET_ROOTSTARTBLOCK, 3075 This->rootStartBlock); 3076 3077 StorageUtl_WriteDWord( 3078 headerBigBlock, 3079 OFFSET_SBDEPOTSTART, 3080 This->smallBlockDepotStart); 3081 3082 StorageUtl_WriteDWord( 3083 headerBigBlock, 3084 OFFSET_SBDEPOTCOUNT, 3085 This->smallBlockDepotChain ? 3086 BlockChainStream_GetCount(This->smallBlockDepotChain) : 0); 3087 3088 StorageUtl_WriteDWord( 3089 headerBigBlock, 3090 OFFSET_EXTBBDEPOTSTART, 3091 This->extBigBlockDepotStart); 3092 3093 StorageUtl_WriteDWord( 3094 headerBigBlock, 3095 OFFSET_EXTBBDEPOTCOUNT, 3096 This->extBigBlockDepotCount); 3097 3098 for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++) 3099 { 3064 3100 StorageUtl_WriteDWord( 3065 3101 headerBigBlock, 3066 OFFSET_BBDEPOTCOUNT, 3067 This->bigBlockDepotCount); 3068 3069 StorageUtl_WriteDWord( 3070 headerBigBlock, 3071 OFFSET_ROOTSTARTBLOCK, 3072 This->rootStartBlock); 3073 3074 StorageUtl_WriteDWord( 3075 headerBigBlock, 3076 OFFSET_SBDEPOTSTART, 3077 This->smallBlockDepotStart); 3078 3079 StorageUtl_WriteDWord( 3080 headerBigBlock, 3081 OFFSET_EXTBBDEPOTSTART, 3082 This->extBigBlockDepotStart); 3083 3084 StorageUtl_WriteDWord( 3085 headerBigBlock, 3086 OFFSET_EXTBBDEPOTCOUNT, 3087 This->extBigBlockDepotCount); 3088 3089 for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++) 3090 { 3091 StorageUtl_WriteDWord( 3092 headerBigBlock, 3093 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index), 3094 (This->bigBlockDepotStart[index])); 3095 } 3102 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index), 3103 (This->bigBlockDepotStart[index])); 3096 3104 } 3097 3105 … … 3382 3390 &bbHeadOfChain, 3383 3391 PROPERTY_NULL); 3384 3392 if(!bbTempChain) return NULL; 3385 3393 /* 3386 3394 * Grow the big block chain. … … 4163 4171 newStream->tailIndex = blockIndex; 4164 4172 4165 blockIndex = StorageImpl_GetNextBlockInChain( 4166 parentStorage, 4167 blockIndex); 4173 if(FAILED(StorageImpl_GetNextBlockInChain( 4174 parentStorage, 4175 blockIndex, 4176 &blockIndex))) 4177 { 4178 HeapFree(GetProcessHeap(), 0, newStream); 4179 return NULL; 4180 } 4168 4181 } 4169 4182 … … 4226 4239 count++; 4227 4240 4228 blockIndex =StorageImpl_GetNextBlockInChain(4241 if(FAILED(StorageImpl_GetNextBlockInChain( 4229 4242 This->parentStorage, 4230 blockIndex); 4243 blockIndex, 4244 &blockIndex))) 4245 return 0; 4231 4246 } 4232 4247 … … 4275 4290 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4276 4291 { 4277 blockIndex = 4278 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4279 4292 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, &blockIndex))) 4293 return FALSE; 4280 4294 blockNoInSequence--; 4281 4295 } … … 4310 4324 * Step to the next big block. 4311 4325 */ 4312 blockIndex =4313 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);4326 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, &blockIndex))) 4327 return FALSE; 4314 4328 4315 4329 bufferWalker += bytesToReadInBuffer; … … 4364 4378 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4365 4379 { 4366 blockIndex =4367 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4368 4380 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, 4381 &blockIndex))) 4382 return FALSE; 4369 4383 blockNoInSequence--; 4370 4384 } … … 4399 4413 * Step to the next big block. 4400 4414 */ 4401 blockIndex =4402 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4403 4415 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, 4416 &blockIndex))) 4417 return FALSE; 4404 4418 bufferWalker += bytesToWrite; 4405 4419 size -= bytesToWrite; … … 4444 4458 while (count < numBlocks) 4445 4459 { 4446 blockIndex =4447 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4448 4460 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, 4461 &blockIndex))) 4462 return FALSE; 4449 4463 count++; 4450 4464 } 4451 4465 4452 4466 /* Get the next block before marking the new end */ 4453 extraBlock = 4454 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4467 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, 4468 &extraBlock))) 4469 return FALSE; 4455 4470 4456 4471 /* Mark the new end of chain */ … … 4468 4483 while (extraBlock != BLOCK_END_OF_CHAIN) 4469 4484 { 4470 blockIndex =4471 StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock); 4472 4485 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock, 4486 &blockIndex))) 4487 return FALSE; 4473 4488 StorageImpl_FreeBigBlock(This->parentStorage, extraBlock); 4474 4489 extraBlock = blockIndex; … … 4548 4563 currentBlock = blockIndex; 4549 4564 4550 blockIndex = 4551 StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock); 4565 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock, 4566 &blockIndex))) 4567 return FALSE; 4552 4568 } 4553 4569 … … 4736 4752 * - BLOCK_UNUSED: small block 'blockIndex' is free 4737 4753 */ 4738 ULONGSmallBlockChainStream_GetNextBlockInChain(4754 HRESULT SmallBlockChainStream_GetNextBlockInChain( 4739 4755 SmallBlockChainStream* This, 4740 ULONG blockIndex) 4756 ULONG blockIndex, 4757 ULONG* nextBlockInChain) 4741 4758 { 4742 4759 ULARGE_INTEGER offsetOfBlockInDepot; 4743 4760 DWORD buffer; 4744 ULONG nextBlockInChain = BLOCK_END_OF_CHAIN;4745 4761 ULONG bytesRead; 4746 4762 BOOL success; 4763 4764 *nextBlockInChain = BLOCK_END_OF_CHAIN; 4747 4765 4748 4766 offsetOfBlockInDepot.s.HighPart = 0; … … 4761 4779 if (success) 4762 4780 { 4763 StorageUtl_ReadDWord(&buffer, 0, &nextBlockInChain); 4764 } 4765 4766 return nextBlockInChain; 4781 StorageUtl_ReadDWord(&buffer, 0, nextBlockInChain); 4782 return S_OK; 4783 } 4784 4785 return STG_E_READFAULT; 4767 4786 } 4768 4787 … … 4869 4888 { 4870 4889 sbdIndex = nextBlock; 4871 nextBlock = 4872 StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex); 4890 StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex, &nextBlock); 4873 4891 } 4874 4892 … … 5007 5025 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 5008 5026 { 5009 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5010 5027 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, 5028 &blockIndex))) 5029 return FALSE; 5011 5030 blockNoInSequence--; 5012 5031 } … … 5049 5068 * Step to the next big block. 5050 5069 */ 5051 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5070 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex))) 5071 return FALSE; 5052 5072 bufferWalker += bytesToReadInBuffer; 5053 5073 size -= bytesToReadInBuffer; … … 5095 5115 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 5096 5116 { 5097 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);5098 5117 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex))) 5118 return FALSE; 5099 5119 blockNoInSequence--; 5100 5120 } … … 5139 5159 * Step to the next big block. 5140 5160 */ 5141 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5161 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, 5162 &blockIndex))) 5163 return FALSE; 5142 5164 bufferWalker += bytesToWriteInBuffer; 5143 5165 size -= bytesToWriteInBuffer; … … 5174 5196 while (count < numBlocks) 5175 5197 { 5176 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5198 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, 5199 &blockIndex))) 5200 return FALSE; 5177 5201 count++; 5178 5202 } … … 5204 5228 { 5205 5229 /* Get the next block before marking the new end */ 5206 extraBlock = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5230 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, 5231 &extraBlock))) 5232 return FALSE; 5207 5233 5208 5234 /* Mark the new end of chain */ … … 5218 5244 while (extraBlock != BLOCK_END_OF_CHAIN) 5219 5245 { 5220 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, extraBlock); 5246 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, extraBlock, 5247 &blockIndex))) 5248 return FALSE; 5221 5249 SmallBlockChainStream_FreeBlock(This, extraBlock); 5222 5250 extraBlock = blockIndex; … … 5281 5309 oldNumBlocks++; 5282 5310 currentBlock = blockIndex; 5283 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, currentBlock); 5311 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, currentBlock, &blockIndex))) 5312 return FALSE; 5284 5313 } 5285 5314 … … 5321 5350 count++; 5322 5351 5323 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5352 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex))) 5353 return 0; 5324 5354 } 5325 5355 … … 5744 5774 newStorage, 5745 5775 0, 5746 0,5776 0, 5747 5777 plkbyt, 5748 5778 grfMode,
Note:
See TracChangeset
for help on using the changeset viewer.