Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
62e54bac
Commit
62e54bac
authored
Nov 30, 2009
by
Vincent Povirk
Committed by
Alexandre Julliard
Dec 08, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Use the storage vtable to read streams.
parent
ee39a21d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
51 deletions
+82
-51
stg_stream.c
dlls/ole32/stg_stream.c
+9
-49
storage32.c
dlls/ole32/storage32.c
+65
-2
storage32.h
dlls/ole32/storage32.h
+8
-0
No files found.
dlls/ole32/stg_stream.c
View file @
62e54bac
...
...
@@ -264,7 +264,6 @@ static HRESULT WINAPI StgStreamImpl_Read(
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
ULONG
bytesReadBuffer
;
ULONG
bytesToReadFromBuffer
;
HRESULT
res
;
TRACE
(
"(%p, %p, %d, %p)
\n
"
,
...
...
@@ -283,60 +282,21 @@ static HRESULT WINAPI StgStreamImpl_Read(
if
(
pcbRead
==
0
)
pcbRead
=
&
bytesReadBuffer
;
/*
* Using the known size of the stream, calculate the number of bytes
* to read from the block chain
*/
bytesToReadFromBuffer
=
min
(
This
->
streamSize
.
u
.
LowPart
-
This
->
currentPosition
.
u
.
LowPart
,
cb
);
/*
* Depending on the type of chain that was opened when the stream was constructed,
* we delegate the work to the method that reads the block chains.
*/
if
(
This
->
smallBlockChain
!=
0
)
{
res
=
SmallBlockChainStream_ReadAt
(
This
->
smallBlockChain
,
This
->
currentPosition
,
bytesToReadFromBuffer
,
pv
,
pcbRead
);
res
=
StorageBaseImpl_StreamReadAt
(
This
->
parentStorage
,
This
->
dirEntry
,
This
->
currentPosition
,
cb
,
pv
,
pcbRead
);
}
else
if
(
This
->
bigBlockChain
!=
0
)
{
res
=
BlockChainStream_ReadAt
(
This
->
bigBlockChain
,
This
->
currentPosition
,
bytesToReadFromBuffer
,
pv
,
pcbRead
);
}
else
if
(
SUCCEEDED
(
res
))
{
/*
* Small and big block chains are both NULL. This case will happen
* when a stream starts with BLOCK_END_OF_CHAIN and has size zero.
* Advance the pointer for the number of positions read.
*/
*
pcbRead
=
0
;
res
=
S_OK
;
goto
end
;
}
if
(
SUCCEEDED
(
res
))
{
/*
* We should always be able to read the proper amount of data from the
* chain.
*/
assert
(
bytesToReadFromBuffer
==
*
pcbRead
);
/*
* Advance the pointer for the number of positions read.
*/
This
->
currentPosition
.
u
.
LowPart
+=
*
pcbRead
;
This
->
currentPosition
.
u
.
LowPart
+=
*
pcbRead
;
}
end:
TRACE
(
"<-- %08x
\n
"
,
res
);
return
res
;
}
...
...
dlls/ole32/storage32.c
View file @
62e54bac
...
...
@@ -2192,6 +2192,60 @@ static HRESULT StorageImpl_BaseReadDirEntry(StorageBaseImpl *base,
return
StorageImpl_ReadDirEntry
(
This
,
index
,
data
);
}
static
HRESULT
StorageImpl_StreamReadAt
(
StorageBaseImpl
*
base
,
DirRef
index
,
ULARGE_INTEGER
offset
,
ULONG
size
,
void
*
buffer
,
ULONG
*
bytesRead
)
{
StorageImpl
*
This
=
(
StorageImpl
*
)
base
;
DirEntry
data
;
HRESULT
hr
;
ULONG
bytesToRead
;
hr
=
StorageImpl_ReadDirEntry
(
This
,
index
,
&
data
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
data
.
size
.
QuadPart
==
0
)
{
*
bytesRead
=
0
;
return
S_OK
;
}
if
(
offset
.
QuadPart
+
size
>
data
.
size
.
QuadPart
)
{
bytesToRead
=
data
.
size
.
QuadPart
-
offset
.
QuadPart
;
}
else
{
bytesToRead
=
size
;
}
if
(
data
.
size
.
QuadPart
<
LIMIT_TO_USE_SMALL_BLOCK
)
{
SmallBlockChainStream
*
stream
;
stream
=
SmallBlockChainStream_Construct
(
This
,
NULL
,
index
);
if
(
!
stream
)
return
E_OUTOFMEMORY
;
hr
=
SmallBlockChainStream_ReadAt
(
stream
,
offset
,
bytesToRead
,
buffer
,
bytesRead
);
SmallBlockChainStream_Destroy
(
stream
);
return
hr
;
}
else
{
BlockChainStream
*
stream
;
stream
=
BlockChainStream_Construct
(
This
,
NULL
,
index
);
if
(
!
stream
)
return
E_OUTOFMEMORY
;
hr
=
BlockChainStream_ReadAt
(
stream
,
offset
,
bytesToRead
,
buffer
,
bytesRead
);
BlockChainStream_Destroy
(
stream
);
return
hr
;
}
}
/*
* Virtual function table for the IStorage32Impl class.
*/
...
...
@@ -2223,7 +2277,8 @@ static const StorageBaseImplVtbl StorageImpl_BaseVtbl =
StorageImpl_CreateDirEntry
,
StorageImpl_BaseWriteDirEntry
,
StorageImpl_BaseReadDirEntry
,
StorageImpl_DestroyDirEntry
StorageImpl_DestroyDirEntry
,
StorageImpl_StreamReadAt
};
static
HRESULT
StorageImpl_Construct
(
...
...
@@ -3671,6 +3726,13 @@ static HRESULT StorageInternalImpl_DestroyDirEntry(StorageBaseImpl *base,
index
);
}
static
HRESULT
StorageInternalImpl_StreamReadAt
(
StorageBaseImpl
*
base
,
DirRef
index
,
ULARGE_INTEGER
offset
,
ULONG
size
,
void
*
buffer
,
ULONG
*
bytesRead
)
{
return
StorageBaseImpl_StreamReadAt
(
&
base
->
ancestorStorage
->
base
,
index
,
offset
,
size
,
buffer
,
bytesRead
);
}
/******************************************************************************
**
** Storage32InternalImpl_Commit
...
...
@@ -4117,7 +4179,8 @@ static const StorageBaseImplVtbl StorageInternalImpl_BaseVtbl =
StorageInternalImpl_CreateDirEntry
,
StorageInternalImpl_WriteDirEntry
,
StorageInternalImpl_ReadDirEntry
,
StorageInternalImpl_DestroyDirEntry
StorageInternalImpl_DestroyDirEntry
,
StorageInternalImpl_StreamReadAt
};
/******************************************************************************
...
...
dlls/ole32/storage32.h
View file @
62e54bac
...
...
@@ -252,6 +252,7 @@ struct StorageBaseImplVtbl {
HRESULT
(
*
WriteDirEntry
)(
StorageBaseImpl
*
,
DirRef
,
const
DirEntry
*
);
HRESULT
(
*
ReadDirEntry
)(
StorageBaseImpl
*
,
DirRef
,
DirEntry
*
);
HRESULT
(
*
DestroyDirEntry
)(
StorageBaseImpl
*
,
DirRef
);
HRESULT
(
*
StreamReadAt
)(
StorageBaseImpl
*
,
DirRef
,
ULARGE_INTEGER
,
ULONG
,
void
*
,
ULONG
*
);
};
static
inline
void
StorageBaseImpl_Destroy
(
StorageBaseImpl
*
This
)
...
...
@@ -283,6 +284,13 @@ static inline HRESULT StorageBaseImpl_DestroyDirEntry(StorageBaseImpl *This,
return
This
->
baseVtbl
->
DestroyDirEntry
(
This
,
index
);
}
/* Read up to size bytes from this directory entry's stream at the given offset. */
static
inline
HRESULT
StorageBaseImpl_StreamReadAt
(
StorageBaseImpl
*
This
,
DirRef
index
,
ULARGE_INTEGER
offset
,
ULONG
size
,
void
*
buffer
,
ULONG
*
bytesRead
)
{
return
This
->
baseVtbl
->
StreamReadAt
(
This
,
index
,
offset
,
size
,
buffer
,
bytesRead
);
}
/****************************************************************************
* StorageBaseImpl stream list handlers
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment