ntdll: Validate blocks in the heap pending free request list.
[wine.git] / dlls / dmime / dmobject.h
blobafe721dc82448743f97a256a551c4d818b714b63
1 /*
2 * Base IDirectMusicObject Implementation
3 * Keep in sync with the master in dlls/dmusic/dmobject.h
5 * Copyright (C) 2014 Michael Stefaniuc
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
24 /* RIFF stream parsing */
25 struct chunk_entry;
26 struct chunk_entry {
27 FOURCC id;
28 DWORD size;
29 FOURCC type; /* valid only for LIST and RIFF chunks */
30 ULARGE_INTEGER offset; /* chunk offset from start of stream */
31 const struct chunk_entry *parent; /* enclosing RIFF or LIST chunk */
34 HRESULT stream_get_chunk(IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN;
35 HRESULT stream_next_chunk(IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN;
36 HRESULT stream_skip_chunk(IStream *stream, const struct chunk_entry *chunk) DECLSPEC_HIDDEN;
38 HRESULT stream_chunk_get_array(IStream *stream, const struct chunk_entry *chunk, void **array,
39 unsigned int *count, DWORD elem_size) DECLSPEC_HIDDEN;
40 HRESULT stream_chunk_get_data(IStream *stream, const struct chunk_entry *chunk, void *data,
41 ULONG size) DECLSPEC_HIDDEN;
42 HRESULT stream_chunk_get_wstr(IStream *stream, const struct chunk_entry *chunk, WCHAR *str,
43 ULONG size) DECLSPEC_HIDDEN;
45 static inline HRESULT stream_reset_chunk_data(IStream *stream, const struct chunk_entry *chunk)
47 LARGE_INTEGER offset;
49 offset.QuadPart = chunk->offset.QuadPart + sizeof(FOURCC) + sizeof(DWORD);
50 if (chunk->id == FOURCC_RIFF || chunk->id == FOURCC_LIST)
51 offset.QuadPart += sizeof(FOURCC);
53 return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
56 static inline HRESULT stream_reset_chunk_start(IStream *stream, const struct chunk_entry *chunk)
58 LARGE_INTEGER offset;
60 offset.QuadPart = chunk->offset.QuadPart;
62 return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
66 /* IDirectMusicObject base object */
67 struct dmobject {
68 IDirectMusicObject IDirectMusicObject_iface;
69 IPersistStream IPersistStream_iface;
70 IUnknown *outer_unk;
71 DMUS_OBJECTDESC desc;
74 void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk) DECLSPEC_HIDDEN;
76 /* Generic IDirectMusicObject methods */
77 HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid,
78 void **ret_iface) DECLSPEC_HIDDEN;
79 ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface) DECLSPEC_HIDDEN;
80 ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface) DECLSPEC_HIDDEN;
81 HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
82 DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
83 HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
84 DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
86 /* Helper for IDirectMusicObject::ParseDescriptor */
87 HRESULT dmobj_parsedescriptor(IStream *stream, const struct chunk_entry *riff,
88 DMUS_OBJECTDESC *desc, DWORD supported) DECLSPEC_HIDDEN;
89 /* Additional supported flags for dmobj_parsedescriptor.
90 DMUS_OBJ_NAME is 'UNAM' chunk in UNFO list */
91 #define DMUS_OBJ_NAME_INAM 0x1000 /* 'INAM' chunk in UNFO list */
92 #define DMUS_OBJ_NAME_INFO 0x2000 /* 'INAM' chunk in INFO list */
94 /* 'DMRF' (reference list) helper */
95 HRESULT dmobj_parsereference(IStream *stream, const struct chunk_entry *list,
96 IDirectMusicObject **dmobj) DECLSPEC_HIDDEN;
98 /* Generic IPersistStream methods */
99 HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid,
100 void **ret_iface) DECLSPEC_HIDDEN;
101 ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface) DECLSPEC_HIDDEN;
102 ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface) DECLSPEC_HIDDEN;
103 HRESULT WINAPI dmobj_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class) DECLSPEC_HIDDEN;
105 /* IPersistStream methods not implemented in native */
106 HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface,
107 CLSID *class) DECLSPEC_HIDDEN;
108 HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface) DECLSPEC_HIDDEN;
109 HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream,
110 BOOL clear_dirty) DECLSPEC_HIDDEN;
111 HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface,
112 ULARGE_INTEGER *size) DECLSPEC_HIDDEN;
114 /* Debugging helpers */
115 const char *debugstr_chunk(const struct chunk_entry *chunk) DECLSPEC_HIDDEN;
116 const char *debugstr_dmguid(const GUID *id) DECLSPEC_HIDDEN;
117 void dump_DMUS_OBJECTDESC(DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
119 static inline const char *debugstr_fourcc(DWORD fourcc)
121 if (!fourcc) return "''";
122 return wine_dbg_sprintf("'%c%c%c%c'", (char)(fourcc), (char)(fourcc >> 8),
123 (char)(fourcc >> 16), (char)(fourcc >> 24));