d3dxof: Remove limitation on data buffer size.
[wine] / dlls / d3dxof / d3dxof_private.h
1 /*
2  *      DirectX File private interfaces (D3DXOF.DLL)
3  *
4  * Copyright 2004, 2008 Christian Costa
5  *
6  * This file contains the (internal) driver registration functions,
7  * driver enumeration APIs and DirectDraw creation functions.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23
24 #ifndef __D3DXOF_PRIVATE_INCLUDED__
25 #define __D3DXOF_PRIVATE_INCLUDED__
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wtypes.h"
32 #include "wingdi.h"
33 #include "winuser.h"
34 #include "dxfile.h"
35
36 #define MAX_NAME_LEN 32
37 #define MAX_ARRAY_DIM 4
38 #define MAX_MEMBERS 50
39 #define MAX_CHILDS 100
40 #define MAX_TEMPLATES 200
41 #define MAX_OBJECTS 500
42 #define MAX_SUBOBJECTS 500
43 #define MAX_STRINGS_BUFFER 10000
44
45 typedef struct {
46     DWORD type;
47     LONG idx_template;
48     char name[MAX_NAME_LEN];
49     ULONG nb_dims;
50     BOOL  dim_fixed[MAX_ARRAY_DIM]; /* fixed or variable */
51     ULONG dim_value[MAX_ARRAY_DIM]; /* fixed value or member index */
52 } member;
53
54 typedef struct {
55     char name[MAX_NAME_LEN];
56     GUID class_id;
57     BOOL open;
58     BOOL binary;
59     ULONG nb_childs;
60     char childs[MAX_CHILDS][MAX_NAME_LEN];
61     ULONG nb_members;
62     member members[MAX_MEMBERS];
63 } xtemplate;
64
65 typedef struct {
66     char* name;
67     ULONG start;
68     ULONG size;
69 } xobject_member;
70
71 struct _xobject {
72    BOOL binary;
73    struct _xobject* ptarget;
74    char name[MAX_NAME_LEN];
75    GUID class_id;
76    GUID type;
77    LPBYTE pdata;
78    ULONG pos_data;
79    DWORD size;
80    ULONG nb_members;
81    xobject_member members[MAX_MEMBERS];
82    ULONG nb_childs;
83    ULONG nb_subobjects;
84    struct _xobject * childs[MAX_CHILDS];
85    struct _xobject * root;
86 };
87
88 typedef struct _xobject xobject;
89
90 typedef struct {
91     IDirectXFile lpVtbl;
92     LONG ref;
93     ULONG nb_xtemplates;
94     xtemplate xtemplates[MAX_TEMPLATES];
95 } IDirectXFileImpl;
96
97 typedef struct {
98     IDirectXFileBinary lpVtbl;
99     LONG ref;
100 } IDirectXFileBinaryImpl;
101
102 typedef struct {
103     IDirectXFileData lpVtbl;
104     LONG ref;
105     xobject* pobj;
106     int cur_enum_object;
107     BOOL from_ref;
108     ULONG level;
109     LPBYTE pstrings;
110 } IDirectXFileDataImpl;
111
112 typedef struct {
113     IDirectXFileDataReference lpVtbl;
114     LONG ref;
115     xobject* ptarget;
116 } IDirectXFileDataReferenceImpl;
117
118 typedef struct {
119     IDirectXFileObject lpVtbl;
120     LONG ref;
121 } IDirectXFileObjectImpl;
122
123 typedef struct {
124   /* Buffer to parse */
125   LPBYTE buffer;
126   DWORD rem_bytes;
127   /* Misc info */
128   WORD current_token;
129   BOOL token_present;
130   BOOL txt;
131   ULONG cur_subobject;
132   ULONG cur_pos_data;
133   LPBYTE cur_pstrings;
134   BYTE value[100];
135   xobject** pxo_globals;
136   ULONG nb_pxo_globals;
137   xobject* pxo_tab;
138   IDirectXFileImpl* pdxf;
139   xobject* pxo;
140   xtemplate* pxt[MAX_SUBOBJECTS];
141   ULONG level;
142   LPBYTE pdata;
143   ULONG capacity;
144   LPBYTE pstrings;
145 } parse_buffer;
146
147 typedef struct {
148     IDirectXFileEnumObject lpVtbl;
149     LONG ref;
150     DXFILELOADOPTIONS source;
151     HANDLE hFile;
152     HANDLE file_mapping;
153     LPBYTE buffer;
154     HGLOBAL resource_data;
155     parse_buffer buf;
156     IDirectXFileImpl* pDirectXFile;
157     ULONG nb_xobjects;
158     xobject* xobjects[MAX_OBJECTS];
159     IDirectXFileData* pRefObjects[MAX_OBJECTS];
160 } IDirectXFileEnumObjectImpl;
161
162 typedef struct {
163     IDirectXFileSaveObject lpVtbl;
164     LONG ref;
165 } IDirectXFileSaveObjectImpl;
166
167 HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, LPVOID *ppObj);
168 HRESULT IDirectXFileFileObjectImpl_Create(IDirectXFileObjectImpl** ppObj);
169 HRESULT IDirectXFileFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj);
170
171 BOOL read_bytes(parse_buffer * buf, LPVOID data, DWORD size);
172 BOOL parse_template(parse_buffer * buf);
173 void dump_template(xtemplate* templates_array, xtemplate* ptemplate);
174 BOOL is_template_available(parse_buffer * buf);
175 BOOL parse_object(parse_buffer * buf);
176
177 #endif /* __D3DXOF_PRIVATE_INCLUDED__ */