Commit 7f3c92b2 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

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.
parent cb07a59a
...@@ -1306,6 +1306,8 @@ static HRESULT StorageImpl_CreateDirEntry( ...@@ -1306,6 +1306,8 @@ static HRESULT StorageImpl_CreateDirEntry(
entryIndex, entryIndex,
emptyData); emptyData);
} }
StorageImpl_SaveFileHeader(storage);
} }
UpdateRawDirEntry(currentData, newData); UpdateRawDirEntry(currentData, newData);
...@@ -3465,6 +3467,7 @@ static void StorageImpl_SaveFileHeader( ...@@ -3465,6 +3467,7 @@ static void StorageImpl_SaveFileHeader(
HRESULT hr; HRESULT hr;
ULARGE_INTEGER offset; ULARGE_INTEGER offset;
DWORD bytes_read, bytes_written; DWORD bytes_read, bytes_written;
DWORD major_version, dirsectorcount;
/* /*
* Get a pointer to the big block of data containing the header. * Get a pointer to the big block of data containing the header.
...@@ -3475,6 +3478,16 @@ static void StorageImpl_SaveFileHeader( ...@@ -3475,6 +3478,16 @@ static void StorageImpl_SaveFileHeader(
if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE) if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE)
hr = STG_E_FILENOTFOUND; 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. * If the block read failed, the file is probably new.
*/ */
...@@ -3489,13 +3502,6 @@ static void StorageImpl_SaveFileHeader( ...@@ -3489,13 +3502,6 @@ static void StorageImpl_SaveFileHeader(
* Initialize the magic number. * Initialize the magic number.
*/ */
memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic)); 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);
} }
/* /*
...@@ -3503,6 +3509,21 @@ static void StorageImpl_SaveFileHeader( ...@@ -3503,6 +3509,21 @@ static void StorageImpl_SaveFileHeader(
*/ */
StorageUtl_WriteWord( StorageUtl_WriteWord(
headerBigBlock, headerBigBlock,
OFFSET_MINORVERSION,
0x3e);
StorageUtl_WriteWord(
headerBigBlock,
OFFSET_MAJORVERSION,
major_version);
StorageUtl_WriteWord(
headerBigBlock,
OFFSET_BYTEORDERMARKER,
(WORD)-2);
StorageUtl_WriteWord(
headerBigBlock,
OFFSET_BIGBLOCKSIZEBITS, OFFSET_BIGBLOCKSIZEBITS,
This->bigBlockSizeBits); This->bigBlockSizeBits);
...@@ -3511,6 +3532,23 @@ static void StorageImpl_SaveFileHeader( ...@@ -3511,6 +3532,23 @@ static void StorageImpl_SaveFileHeader(
OFFSET_SMALLBLOCKSIZEBITS, OFFSET_SMALLBLOCKSIZEBITS,
This->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( StorageUtl_WriteDWord(
headerBigBlock, headerBigBlock,
OFFSET_BBDEPOTCOUNT, OFFSET_BBDEPOTCOUNT,
......
...@@ -42,8 +42,12 @@ ...@@ -42,8 +42,12 @@
/* /*
* Definitions for the file format offsets. * 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_BIGBLOCKSIZEBITS = 0x0000001e;
static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020; static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
static const ULONG OFFSET_DIRSECTORCOUNT = 0x00000028;
static const ULONG OFFSET_BBDEPOTCOUNT = 0x0000002C; static const ULONG OFFSET_BBDEPOTCOUNT = 0x0000002C;
static const ULONG OFFSET_ROOTSTARTBLOCK = 0x00000030; static const ULONG OFFSET_ROOTSTARTBLOCK = 0x00000030;
static const ULONG OFFSET_SMALLBLOCKLIMIT = 0x00000038; static const ULONG OFFSET_SMALLBLOCKLIMIT = 0x00000038;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment