mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 14:40:56 +00:00
ole32: Update storage header saving code based on the latest MS spec.
These fields are needed for the MS storage implementation to load files that were created by Wine with a block size of 4096.
This commit is contained in:
parent
cb07a59a80
commit
7f3c92b2a0
@ -1306,6 +1306,8 @@ static HRESULT StorageImpl_CreateDirEntry(
|
||||
entryIndex,
|
||||
emptyData);
|
||||
}
|
||||
|
||||
StorageImpl_SaveFileHeader(storage);
|
||||
}
|
||||
|
||||
UpdateRawDirEntry(currentData, newData);
|
||||
@ -3465,6 +3467,7 @@ static void StorageImpl_SaveFileHeader(
|
||||
HRESULT hr;
|
||||
ULARGE_INTEGER offset;
|
||||
DWORD bytes_read, bytes_written;
|
||||
DWORD major_version, dirsectorcount;
|
||||
|
||||
/*
|
||||
* Get a pointer to the big block of data containing the header.
|
||||
@ -3475,6 +3478,16 @@ static void StorageImpl_SaveFileHeader(
|
||||
if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE)
|
||||
hr = STG_E_FILENOTFOUND;
|
||||
|
||||
if (This->bigBlockSizeBits == 0x9)
|
||||
major_version = 3;
|
||||
else if (This->bigBlockSizeBits == 0xc)
|
||||
major_version = 4;
|
||||
else
|
||||
{
|
||||
ERR("invalid big block shift 0x%x\n", This->bigBlockSizeBits);
|
||||
major_version = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the block read failed, the file is probably new.
|
||||
*/
|
||||
@ -3489,18 +3502,26 @@ static void StorageImpl_SaveFileHeader(
|
||||
* Initialize the magic number.
|
||||
*/
|
||||
memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic));
|
||||
|
||||
/*
|
||||
* And a bunch of things we don't know what they mean
|
||||
*/
|
||||
StorageUtl_WriteWord(headerBigBlock, 0x18, 0x3b);
|
||||
StorageUtl_WriteWord(headerBigBlock, 0x1a, 0x3);
|
||||
StorageUtl_WriteWord(headerBigBlock, 0x1c, (WORD)-2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the information to the header.
|
||||
*/
|
||||
StorageUtl_WriteWord(
|
||||
headerBigBlock,
|
||||
OFFSET_MINORVERSION,
|
||||
0x3e);
|
||||
|
||||
StorageUtl_WriteWord(
|
||||
headerBigBlock,
|
||||
OFFSET_MAJORVERSION,
|
||||
major_version);
|
||||
|
||||
StorageUtl_WriteWord(
|
||||
headerBigBlock,
|
||||
OFFSET_BYTEORDERMARKER,
|
||||
(WORD)-2);
|
||||
|
||||
StorageUtl_WriteWord(
|
||||
headerBigBlock,
|
||||
OFFSET_BIGBLOCKSIZEBITS,
|
||||
@ -3511,6 +3532,23 @@ static void StorageImpl_SaveFileHeader(
|
||||
OFFSET_SMALLBLOCKSIZEBITS,
|
||||
This->smallBlockSizeBits);
|
||||
|
||||
if (major_version >= 4)
|
||||
{
|
||||
if (This->rootBlockChain)
|
||||
dirsectorcount = BlockChainStream_GetCount(This->rootBlockChain);
|
||||
else
|
||||
/* This file is being created, and it will start out with one block. */
|
||||
dirsectorcount = 1;
|
||||
}
|
||||
else
|
||||
/* This field must be 0 in versions older than 4 */
|
||||
dirsectorcount = 0;
|
||||
|
||||
StorageUtl_WriteDWord(
|
||||
headerBigBlock,
|
||||
OFFSET_DIRSECTORCOUNT,
|
||||
dirsectorcount);
|
||||
|
||||
StorageUtl_WriteDWord(
|
||||
headerBigBlock,
|
||||
OFFSET_BBDEPOTCOUNT,
|
||||
|
@ -42,8 +42,12 @@
|
||||
/*
|
||||
* Definitions for the file format offsets.
|
||||
*/
|
||||
static const ULONG OFFSET_MINORVERSION = 0x00000018;
|
||||
static const ULONG OFFSET_MAJORVERSION = 0x0000001a;
|
||||
static const ULONG OFFSET_BYTEORDERMARKER = 0x0000001c;
|
||||
static const ULONG OFFSET_BIGBLOCKSIZEBITS = 0x0000001e;
|
||||
static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
|
||||
static const ULONG OFFSET_DIRSECTORCOUNT = 0x00000028;
|
||||
static const ULONG OFFSET_BBDEPOTCOUNT = 0x0000002C;
|
||||
static const ULONG OFFSET_ROOTSTARTBLOCK = 0x00000030;
|
||||
static const ULONG OFFSET_SMALLBLOCKLIMIT = 0x00000038;
|
||||
|
Loading…
Reference in New Issue
Block a user