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
447c97cf
Commit
447c97cf
authored
May 08, 2012
by
Christian Costa
Committed by
Alexandre Julliard
May 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dmusic: Simplify ParseDescriptor by checking DLS header first and exit if it is wrong.
parent
f9ba9999
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
142 additions
and
109 deletions
+142
-109
collection.c
dlls/dmusic/collection.c
+142
-109
No files found.
dlls/dmusic/collection.c
View file @
447c97cf
...
...
@@ -234,174 +234,207 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_SetDescripto
return
S_OK
;
}
static
HRESULT
WINAPI
IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor
(
LPDIRECTMUSICOBJECT
iface
,
LPSTREAM
pStream
,
LPDMUS_OBJECTDESC
pDesc
)
static
HRESULT
read_from_stream
(
IStream
*
stream
,
void
*
data
,
ULONG
size
)
{
ULONG
read
;
HRESULT
hr
;
hr
=
IStream_Read
(
stream
,
data
,
size
,
&
read
);
if
(
FAILED
(
hr
))
{
TRACE
(
"IStream_Read failed: %08x
\n
"
,
hr
);
return
hr
;
}
if
(
read
<
size
)
{
TRACE
(
"Didn't read full chunk: %u < %u
\n
"
,
read
,
size
);
return
E_FAIL
;
}
return
S_OK
;
}
static
HRESULT
WINAPI
IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor
(
LPDIRECTMUSICOBJECT
iface
,
LPSTREAM
stream
,
LPDMUS_OBJECTDESC
desc
)
{
ICOM_THIS_MULTI
(
IDirectMusicCollectionImpl
,
ObjectVtbl
,
iface
);
DMUS_PRIVATE_CHUNK
C
hunk
;
DMUS_PRIVATE_CHUNK
c
hunk
;
DWORD
StreamSize
,
StreamCount
,
ListSize
[
1
],
ListCount
[
1
];
LARGE_INTEGER
liMove
;
/* used when skipping chunks */
HRESULT
hr
;
TRACE
(
"(%p, %p, %p)
\n
"
,
This
,
pStream
,
pD
esc
);
TRACE
(
"(%p)->(%p, %p)
\n
"
,
This
,
stream
,
d
esc
);
/* FIXME: should this be determined from stream? */
pDesc
->
dwValidData
|=
DMUS_OBJ_CLASS
;
pDesc
->
guidClass
=
CLSID_DirectMusicCollection
;
desc
->
dwValidData
|=
DMUS_OBJ_CLASS
;
desc
->
guidClass
=
CLSID_DirectMusicCollection
;
hr
=
read_from_stream
(
stream
,
&
chunk
,
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
));
if
(
FAILED
(
hr
))
return
hr
;
TRACE_
(
dmfile
)(
": %s chunk (size = 0x%04x)"
,
debugstr_fourcc
(
chunk
.
fccID
),
chunk
.
dwSize
);
if
(
chunk
.
fccID
!=
FOURCC_RIFF
)
{
TRACE_
(
dmfile
)(
": unexpected chunk; loading failed)
\n
"
);
liMove
.
QuadPart
=
chunk
.
dwSize
;
IStream_Seek
(
stream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
/* skip the rest of the chunk */
return
DMUS_E_INVALIDFILE
;
}
hr
=
read_from_stream
(
stream
,
&
chunk
.
fccID
,
sizeof
(
FOURCC
));
if
(
FAILED
(
hr
))
return
hr
;
TRACE_
(
dmfile
)(
": RIFF chunk of type %s"
,
debugstr_fourcc
(
chunk
.
fccID
));
StreamSize
=
chunk
.
dwSize
-
sizeof
(
FOURCC
);
if
(
chunk
.
fccID
!=
mmioFOURCC
(
'D'
,
'L'
,
'S'
,
' '
))
{
TRACE_
(
dmfile
)(
": unexpected chunk; loading failed)
\n
"
);
liMove
.
QuadPart
=
StreamSize
;
IStream_Seek
(
stream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
/* skip the rest of the chunk */
return
E_FAIL
;
}
IStream_Read
(
pStream
,
&
Chunk
,
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
),
NULL
);
TRACE_
(
dmfile
)(
": %s chunk (size = 0x%04x)"
,
debugstr_fourcc
(
Chunk
.
fccID
),
Chunk
.
dwSize
);
switch
(
Chunk
.
fccID
)
{
case
FOURCC_RIFF
:
{
IStream_Read
(
pStream
,
&
Chunk
.
fccID
,
sizeof
(
FOURCC
),
NULL
);
TRACE_
(
dmfile
)(
": RIFF chunk of type %s"
,
debugstr_fourcc
(
Chunk
.
fccID
));
StreamSize
=
Chunk
.
dwSize
-
sizeof
(
FOURCC
);
StreamCount
=
0
;
if
(
Chunk
.
fccID
==
mmioFOURCC
(
'D'
,
'L'
,
'S'
,
' '
))
{
TRACE_
(
dmfile
)(
": collection form
\n
"
);
do
{
IStream_Read
(
pStream
,
&
Chunk
,
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
),
NULL
);
StreamCount
+=
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
)
+
Chunk
.
dwSize
;
TRACE_
(
dmfile
)(
": %s chunk (size = 0x%04x)"
,
debugstr_fourcc
(
Chunk
.
fccID
),
Chunk
.
dwSize
);
switch
(
Chunk
.
fccID
)
{
case
FOURCC_DLID
:
{
hr
=
read_from_stream
(
stream
,
&
chunk
,
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
));
if
(
FAILED
(
hr
))
return
hr
;
StreamCount
+=
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
)
+
chunk
.
dwSize
;
TRACE_
(
dmfile
)(
": %s chunk (size = 0x%04x)"
,
debugstr_fourcc
(
chunk
.
fccID
),
chunk
.
dwSize
);
switch
(
chunk
.
fccID
)
{
case
FOURCC_DLID
:
TRACE_
(
dmfile
)(
": GUID chunk
\n
"
);
pDesc
->
dwValidData
|=
DMUS_OBJ_OBJECT
;
IStream_Read
(
pStream
,
&
pDesc
->
guidObject
,
Chunk
.
dwSize
,
NULL
);
desc
->
dwValidData
|=
DMUS_OBJ_OBJECT
;
hr
=
read_from_stream
(
stream
,
&
desc
->
guidObject
,
chunk
.
dwSize
);
if
(
FAILED
(
hr
))
return
hr
;
break
;
}
case
DMUS_FOURCC_VERSION_CHUNK
:
{
case
DMUS_FOURCC_VERSION_CHUNK
:
TRACE_
(
dmfile
)(
": version chunk
\n
"
);
pDesc
->
dwValidData
|=
DMUS_OBJ_VERSION
;
IStream_Read
(
pStream
,
&
pDesc
->
vVersion
,
Chunk
.
dwSize
,
NULL
);
desc
->
dwValidData
|=
DMUS_OBJ_VERSION
;
hr
=
read_from_stream
(
stream
,
&
desc
->
vVersion
,
chunk
.
dwSize
);
if
(
FAILED
(
hr
))
return
hr
;
break
;
}
case
DMUS_FOURCC_CATEGORY_CHUNK
:
{
case
DMUS_FOURCC_CATEGORY_CHUNK
:
TRACE_
(
dmfile
)(
": category chunk
\n
"
);
pDesc
->
dwValidData
|=
DMUS_OBJ_CATEGORY
;
IStream_Read
(
pStream
,
pDesc
->
wszCategory
,
Chunk
.
dwSize
,
NULL
);
break
;
}
case
FOURCC_LIST
:
{
IStream_Read
(
pStream
,
&
Chunk
.
fccID
,
sizeof
(
FOURCC
),
NULL
);
TRACE_
(
dmfile
)(
": LIST chunk of type %s"
,
debugstr_fourcc
(
Chunk
.
fccID
));
ListSize
[
0
]
=
Chunk
.
dwSize
-
sizeof
(
FOURCC
);
desc
->
dwValidData
|=
DMUS_OBJ_CATEGORY
;
hr
=
read_from_stream
(
stream
,
desc
->
wszCategory
,
chunk
.
dwSize
);
if
(
FAILED
(
hr
))
return
hr
;
break
;
case
FOURCC_LIST
:
hr
=
read_from_stream
(
stream
,
&
chunk
.
fccID
,
sizeof
(
FOURCC
));
if
(
FAILED
(
hr
))
return
hr
;
TRACE_
(
dmfile
)(
": LIST chunk of type %s"
,
debugstr_fourcc
(
chunk
.
fccID
));
ListSize
[
0
]
=
chunk
.
dwSize
-
sizeof
(
FOURCC
);
ListCount
[
0
]
=
0
;
switch
(
C
hunk
.
fccID
)
{
switch
(
c
hunk
.
fccID
)
{
/* pure INFO list, such can be found in dls collections */
case
mmioFOURCC
(
'I'
,
'N'
,
'F'
,
'O'
):
{
case
mmioFOURCC
(
'I'
,
'N'
,
'F'
,
'O'
):
TRACE_
(
dmfile
)(
": INFO list
\n
"
);
do
{
IStream_Read
(
pStream
,
&
Chunk
,
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
),
NULL
);
ListCount
[
0
]
+=
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
)
+
Chunk
.
dwSize
;
TRACE_
(
dmfile
)(
": %s chunk (size = 0x%04x)"
,
debugstr_fourcc
(
Chunk
.
fccID
),
Chunk
.
dwSize
);
switch
(
Chunk
.
fccID
)
{
case
mmioFOURCC
(
'I'
,
'N'
,
'A'
,
'M'
):{
hr
=
read_from_stream
(
stream
,
&
chunk
,
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
));
if
(
FAILED
(
hr
))
return
hr
;
ListCount
[
0
]
+=
sizeof
(
FOURCC
)
+
sizeof
(
DWORD
)
+
chunk
.
dwSize
;
TRACE_
(
dmfile
)(
": %s chunk (size = 0x%04x)"
,
debugstr_fourcc
(
chunk
.
fccID
),
chunk
.
dwSize
);
switch
(
chunk
.
fccID
)
{
case
mmioFOURCC
(
'I'
,
'N'
,
'A'
,
'M'
):
{
CHAR
szName
[
DMUS_MAX_NAME
];
TRACE_
(
dmfile
)(
": name chunk
\n
"
);
pDesc
->
dwValidData
|=
DMUS_OBJ_NAME
;
IStream_Read
(
pStream
,
szName
,
Chunk
.
dwSize
,
NULL
);
MultiByteToWideChar
(
CP_ACP
,
0
,
szName
,
-
1
,
pDesc
->
wszName
,
DMUS_MAX_NAME
);
if
(
even_or_odd
(
Chunk
.
dwSize
))
{
ListCount
[
0
]
++
;
desc
->
dwValidData
|=
DMUS_OBJ_NAME
;
hr
=
read_from_stream
(
stream
,
szName
,
chunk
.
dwSize
);
if
(
FAILED
(
hr
))
return
hr
;
MultiByteToWideChar
(
CP_ACP
,
0
,
szName
,
-
1
,
desc
->
wszName
,
DMUS_MAX_NAME
);
if
(
even_or_odd
(
chunk
.
dwSize
))
{
ListCount
[
0
]
++
;
liMove
.
QuadPart
=
1
;
IStream_Seek
(
pS
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
IStream_Seek
(
s
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
}
break
;
}
case
mmioFOURCC
(
'I'
,
'A'
,
'R'
,
'T'
):
{
case
mmioFOURCC
(
'I'
,
'A'
,
'R'
,
'T'
):
TRACE_
(
dmfile
)(
": artist chunk (ignored)
\n
"
);
if
(
even_or_odd
(
C
hunk
.
dwSize
))
{
ListCount
[
0
]
++
;
C
hunk
.
dwSize
++
;
if
(
even_or_odd
(
c
hunk
.
dwSize
))
{
ListCount
[
0
]
++
;
c
hunk
.
dwSize
++
;
}
liMove
.
QuadPart
=
C
hunk
.
dwSize
;
IStream_Seek
(
pS
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
liMove
.
QuadPart
=
c
hunk
.
dwSize
;
IStream_Seek
(
s
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
}
case
mmioFOURCC
(
'I'
,
'C'
,
'O'
,
'P'
):
{
case
mmioFOURCC
(
'I'
,
'C'
,
'O'
,
'P'
):
TRACE_
(
dmfile
)(
": copyright chunk (ignored)
\n
"
);
if
(
even_or_odd
(
C
hunk
.
dwSize
))
{
ListCount
[
0
]
++
;
C
hunk
.
dwSize
++
;
if
(
even_or_odd
(
c
hunk
.
dwSize
))
{
ListCount
[
0
]
++
;
c
hunk
.
dwSize
++
;
}
liMove
.
QuadPart
=
C
hunk
.
dwSize
;
IStream_Seek
(
pS
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
liMove
.
QuadPart
=
c
hunk
.
dwSize
;
IStream_Seek
(
s
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
}
case
mmioFOURCC
(
'I'
,
'S'
,
'B'
,
'J'
):
{
case
mmioFOURCC
(
'I'
,
'S'
,
'B'
,
'J'
):
TRACE_
(
dmfile
)(
": subject chunk (ignored)
\n
"
);
if
(
even_or_odd
(
C
hunk
.
dwSize
))
{
ListCount
[
0
]
++
;
C
hunk
.
dwSize
++
;
if
(
even_or_odd
(
c
hunk
.
dwSize
))
{
ListCount
[
0
]
++
;
c
hunk
.
dwSize
++
;
}
liMove
.
QuadPart
=
C
hunk
.
dwSize
;
IStream_Seek
(
pS
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
liMove
.
QuadPart
=
c
hunk
.
dwSize
;
IStream_Seek
(
s
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
}
case
mmioFOURCC
(
'I'
,
'C'
,
'M'
,
'T'
):
{
case
mmioFOURCC
(
'I'
,
'C'
,
'M'
,
'T'
):
TRACE_
(
dmfile
)(
": comment chunk (ignored)
\n
"
);
if
(
even_or_odd
(
Chunk
.
dwSize
))
{
ListCount
[
0
]
++
;
Chunk
.
dwSize
++
;
}
liMove
.
QuadPart
=
Chunk
.
dwSize
;
IStream_Seek
(
pStream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
if
(
even_or_odd
(
chunk
.
dwSize
))
{
ListCount
[
0
]
++
;
chunk
.
dwSize
++
;
liMove
.
QuadPart
=
chunk
.
dwSize
;
IStream_Seek
(
stream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
}
default:
{
default:
TRACE_
(
dmfile
)(
": unknown chunk (irrelevant & skipping)
\n
"
);
if
(
even_or_odd
(
C
hunk
.
dwSize
))
{
if
(
even_or_odd
(
c
hunk
.
dwSize
))
{
ListCount
[
0
]
++
;
C
hunk
.
dwSize
++
;
c
hunk
.
dwSize
++
;
}
liMove
.
QuadPart
=
C
hunk
.
dwSize
;
IStream_Seek
(
pS
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
liMove
.
QuadPart
=
c
hunk
.
dwSize
;
IStream_Seek
(
s
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
}
}
TRACE_
(
dmfile
)(
": ListCount[0] = %d < ListSize[0] = %d
\n
"
,
ListCount
[
0
],
ListSize
[
0
]);
}
while
(
ListCount
[
0
]
<
ListSize
[
0
]);
break
;
}
default:
{
default:
TRACE_
(
dmfile
)(
": unknown (skipping)
\n
"
);
liMove
.
QuadPart
=
C
hunk
.
dwSize
-
sizeof
(
FOURCC
);
IStream_Seek
(
pS
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
liMove
.
QuadPart
=
c
hunk
.
dwSize
-
sizeof
(
FOURCC
);
IStream_Seek
(
s
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
}
}
break
;
}
default:
{
default:
TRACE_
(
dmfile
)(
": unknown chunk (irrelevant & skipping)
\n
"
);
liMove
.
QuadPart
=
C
hunk
.
dwSize
;
IStream_Seek
(
pS
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
liMove
.
QuadPart
=
c
hunk
.
dwSize
;
IStream_Seek
(
s
tream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
break
;
}
}
TRACE_
(
dmfile
)(
": StreamCount[0] = %d < StreamSize[0] = %d
\n
"
,
StreamCount
,
StreamSize
);
}
while
(
StreamCount
<
StreamSize
);
}
else
{
TRACE_
(
dmfile
)(
": unexpected chunk; loading failed)
\n
"
);
liMove
.
QuadPart
=
StreamSize
;
IStream_Seek
(
pStream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
/* skip the rest of the chunk */
return
E_FAIL
;
}
TRACE_
(
dmfile
)(
": reading finished
\n
"
);
break
;
}
default:
{
TRACE_
(
dmfile
)(
": unexpected chunk; loading failed)
\n
"
);
liMove
.
QuadPart
=
Chunk
.
dwSize
;
IStream_Seek
(
pStream
,
liMove
,
STREAM_SEEK_CUR
,
NULL
);
/* skip the rest of the chunk */
return
DMUS_E_INVALIDFILE
;
}
}
if
(
TRACE_ON
(
dmusic
))
{
if
(
TRACE_ON
(
dmusic
))
{
TRACE
(
"Returning descriptor:
\n
"
);
dump_DMUS_OBJECTDESC
(
pD
esc
);
dump_DMUS_OBJECTDESC
(
d
esc
);
}
return
S_OK
;
...
...
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