2 * Implementation of DirectX File Interfaces
4 * Copyright 2004, 2008 Christian Costa
6 * This file contains the (internal) driver registration functions,
7 * driver enumeration APIs and DirectDraw creation functions.
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.
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.
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
25 #include "wine/debug.h"
32 #include "d3dxof_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(d3dxof
);
39 #define MAKEFOUR(a,b,c,d) ((DWORD)a + ((DWORD)b << 8) + ((DWORD)c << 16) + ((DWORD)d << 24))
40 #define XOFFILE_FORMAT_MAGIC MAKEFOUR('x','o','f',' ')
41 #define XOFFILE_FORMAT_VERSION_302 MAKEFOUR('0','3','0','2')
42 #define XOFFILE_FORMAT_VERSION_303 MAKEFOUR('0','3','0','3')
43 #define XOFFILE_FORMAT_BINARY MAKEFOUR('b','i','n',' ')
44 #define XOFFILE_FORMAT_TEXT MAKEFOUR('t','x','t',' ')
45 #define XOFFILE_FORMAT_COMPRESSED MAKEFOUR('c','m','p',' ')
46 #define XOFFILE_FORMAT_FLOAT_BITS_32 MAKEFOUR('0','0','3','2')
47 #define XOFFILE_FORMAT_FLOAT_BITS_64 MAKEFOUR('0','0','6','4')
50 #define TOKEN_STRING 2
51 #define TOKEN_INTEGER 3
53 #define TOKEN_INTEGER_LIST 6
54 #define TOKEN_FLOAT_LIST 7
55 #define TOKEN_OBRACE 10
56 #define TOKEN_CBRACE 11
57 #define TOKEN_OPAREN 12
58 #define TOKEN_CPAREN 13
59 #define TOKEN_OBRACKET 14
60 #define TOKEN_CBRACKET 15
61 #define TOKEN_OANGLE 16
62 #define TOKEN_CANGLE 17
64 #define TOKEN_COMMA 19
65 #define TOKEN_SEMICOLON 20
66 #define TOKEN_TEMPLATE 31
68 #define TOKEN_DWORD 41
69 #define TOKEN_FLOAT 42
70 #define TOKEN_DOUBLE 43
72 #define TOKEN_UCHAR 45
73 #define TOKEN_SWORD 46
74 #define TOKEN_SDWORD 47
76 #define TOKEN_LPSTR 49
77 #define TOKEN_UNICODE 50
78 #define TOKEN_CSTRING 51
79 #define TOKEN_ARRAY 52
81 #define CLSIDFMT "<%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X>"
83 #define MAX_INPUT_SIZE 2000000
84 #define MAX_DATA_SIZE 200000
86 static const struct IDirectXFileVtbl IDirectXFile_Vtbl
;
87 static const struct IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl
;
88 static const struct IDirectXFileDataVtbl IDirectXFileData_Vtbl
;
89 static const struct IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl
;
90 static const struct IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl
;
91 static const struct IDirectXFileObjectVtbl IDirectXFileObject_Vtbl
;
92 static const struct IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl
;
94 static BOOL
parse_object_parts(parse_buffer
* buf
, BOOL allow_optional
);
95 static BOOL
parse_object(parse_buffer
* buf
);
96 static const char* get_primitive_string(WORD token
);
97 static WORD
check_TOKEN(parse_buffer
* buf
);
98 static BOOL
parse_template(parse_buffer
* buf
);
100 static void dump_template(xtemplate
* templates_array
, xtemplate
* ptemplate
)
105 clsid
= &ptemplate
->class_id
;
107 DPRINTF("template %s\n", ptemplate
->name
);
109 DPRINTF(CLSIDFMT
"\n", clsid
->Data1
, clsid
->Data2
, clsid
->Data3
, clsid
->Data4
[0],
110 clsid
->Data4
[1], clsid
->Data4
[2], clsid
->Data4
[3], clsid
->Data4
[4], clsid
->Data4
[5], clsid
->Data4
[6], clsid
->Data4
[7]);
111 for (j
= 0; j
< ptemplate
->nb_members
; j
++)
113 if (ptemplate
->members
[j
].nb_dims
)
115 if (ptemplate
->members
[j
].type
== TOKEN_NAME
)
116 DPRINTF("%s ", templates_array
[ptemplate
->members
[j
].idx_template
].name
);
118 DPRINTF("%s ", get_primitive_string(ptemplate
->members
[j
].type
));
119 DPRINTF("%s", ptemplate
->members
[j
].name
);
120 for (k
= 0; k
< ptemplate
->members
[j
].nb_dims
; k
++)
122 if (ptemplate
->members
[j
].dim_fixed
[k
])
123 DPRINTF("[%d]", ptemplate
->members
[j
].dim_value
[k
]);
125 DPRINTF("[%s]", ptemplate
->members
[ptemplate
->members
[j
].dim_value
[k
]].name
);
131 else if (ptemplate
->nb_childs
)
133 DPRINTF("[%s", ptemplate
->childs
[0]);
134 for (j
= 1; j
< ptemplate
->nb_childs
; j
++)
135 DPRINTF(",%s", ptemplate
->childs
[j
]);
141 HRESULT
IDirectXFileImpl_Create(IUnknown
* pUnkOuter
, LPVOID
* ppObj
)
143 IDirectXFileImpl
* object
;
145 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
147 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileImpl
));
149 object
->lpVtbl
.lpVtbl
= &IDirectXFile_Vtbl
;
157 /*** IUnknown methods ***/
158 static HRESULT WINAPI
IDirectXFileImpl_QueryInterface(IDirectXFile
* iface
, REFIID riid
, void** ppvObject
)
160 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
162 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
164 if (IsEqualGUID(riid
, &IID_IUnknown
)
165 || IsEqualGUID(riid
, &IID_IDirectXFile
))
167 IClassFactory_AddRef(iface
);
172 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
173 return E_NOINTERFACE
;
176 static ULONG WINAPI
IDirectXFileImpl_AddRef(IDirectXFile
* iface
)
178 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
179 ULONG ref
= InterlockedIncrement(&This
->ref
);
181 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
186 static ULONG WINAPI
IDirectXFileImpl_Release(IDirectXFile
* iface
)
188 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
189 ULONG ref
= InterlockedDecrement(&This
->ref
);
191 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
194 HeapFree(GetProcessHeap(), 0, This
);
199 /*** IDirectXFile methods ***/
200 static HRESULT WINAPI
IDirectXFileImpl_CreateEnumObject(IDirectXFile
* iface
, LPVOID pvSource
, DXFILELOADOPTIONS dwLoadOptions
, LPDIRECTXFILEENUMOBJECT
* ppEnumObj
)
202 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
203 IDirectXFileEnumObjectImpl
* object
;
207 HANDLE hFile
= INVALID_HANDLE_VALUE
;
208 LPDXFILELOADMEMORY lpdxflm
= NULL
;
210 TRACE("(%p/%p)->(%p,%x,%p)\n", This
, iface
, pvSource
, dwLoadOptions
, ppEnumObj
);
213 return DXFILEERR_BADVALUE
;
215 if (dwLoadOptions
== DXFILELOAD_FROMFILE
)
217 TRACE("Open source file '%s'\n", (char*)pvSource
);
219 hFile
= CreateFileA((char*)pvSource
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, NULL
);
220 if (hFile
== INVALID_HANDLE_VALUE
)
222 TRACE("File '%s' not found\n", (char*)pvSource
);
223 return DXFILEERR_FILENOTFOUND
;
226 if (!ReadFile(hFile
, header
, 16, &size
, NULL
))
228 hr
= DXFILEERR_BADVALUE
;
234 hr
= DXFILEERR_BADFILETYPE
;
238 else if (dwLoadOptions
== DXFILELOAD_FROMMEMORY
)
240 lpdxflm
= (LPDXFILELOADMEMORY
)pvSource
;
242 TRACE("Source in memory at %p with size %d\n", lpdxflm
->lpMemory
, lpdxflm
->dSize
);
244 memcpy(header
, (char*)lpdxflm
->lpMemory
, 16);
248 FIXME("Source type %d is not handled yet\n", dwLoadOptions
);
249 hr
= DXFILEERR_NOTDONEYET
;
253 if (TRACE_ON(d3dxof
))
256 memcpy(string
, header
, 16);
258 TRACE("header = '%s'\n", string
);
261 if (header
[0] != XOFFILE_FORMAT_MAGIC
)
263 hr
= DXFILEERR_BADFILETYPE
;
267 if ((header
[1] != XOFFILE_FORMAT_VERSION_302
) && (header
[1] != XOFFILE_FORMAT_VERSION_303
))
269 hr
= DXFILEERR_BADFILEVERSION
;
273 if ((header
[2] != XOFFILE_FORMAT_BINARY
) && (header
[2] != XOFFILE_FORMAT_TEXT
) && (header
[2] != XOFFILE_FORMAT_COMPRESSED
))
275 hr
= DXFILEERR_BADFILETYPE
;
279 if (header
[2] == XOFFILE_FORMAT_COMPRESSED
)
281 FIXME("Compressed formats not supported yet\n");
282 hr
= DXFILEERR_BADVALUE
;
286 if ((header
[3] != XOFFILE_FORMAT_FLOAT_BITS_32
) && (header
[3] != XOFFILE_FORMAT_FLOAT_BITS_64
))
288 hr
= DXFILEERR_BADFILEFLOATSIZE
;
292 TRACE("Header is correct\n");
294 hr
= IDirectXFileEnumObjectImpl_Create(&object
);
298 object
->source
= dwLoadOptions
;
299 object
->hFile
= hFile
;
300 object
->pDirectXFile
= This
;
301 object
->buf
.pdxf
= This
;
302 object
->buf
.txt
= (header
[2] == XOFFILE_FORMAT_TEXT
);
303 object
->buf
.token_present
= FALSE
;
304 object
->buf
.cur_subobject
= 0;
306 if (dwLoadOptions
== DXFILELOAD_FROMFILE
)
308 object
->buf
.buffer
= HeapAlloc(GetProcessHeap(), 0, MAX_INPUT_SIZE
+1);
309 if (!object
->buf
.buffer
)
311 WARN("Out of memory\n");
312 hr
= DXFILEERR_BADALLOC
;
316 ReadFile(hFile
, object
->buf
.buffer
, MAX_INPUT_SIZE
+1, &object
->buf
.rem_bytes
, NULL
);
317 if (object
->buf
.rem_bytes
> MAX_INPUT_SIZE
)
319 FIXME("File size > %d not supported yet\n", MAX_INPUT_SIZE
);
320 HeapFree(GetProcessHeap(), 0, object
->buf
.buffer
);
321 hr
= DXFILEERR_PARSEERROR
;
327 object
->buf
.buffer
= ((LPBYTE
)lpdxflm
->lpMemory
) + 16;
328 object
->buf
.rem_bytes
= lpdxflm
->dSize
;
331 TRACE("Read %d bytes\n", object
->buf
.rem_bytes
);
333 *ppEnumObj
= (LPDIRECTXFILEENUMOBJECT
)object
;
335 while (object
->buf
.rem_bytes
&& (check_TOKEN(&object
->buf
) == TOKEN_TEMPLATE
))
337 if (!parse_template(&object
->buf
))
339 TRACE("Template is not correct\n");
340 hr
= DXFILEERR_BADVALUE
;
345 TRACE("Template successfully parsed:\n");
346 if (TRACE_ON(d3dxof
))
347 dump_template(This
->xtemplates
, &This
->xtemplates
[This
->nb_xtemplates
- 1]);
351 if (TRACE_ON(d3dxof
))
354 TRACE("Registered templates (%d):\n", This
->nb_xtemplates
);
355 for (i
= 0; i
< This
->nb_xtemplates
; i
++)
356 DPRINTF("%s - %s\n", This
->xtemplates
[i
].name
, debugstr_guid(&This
->xtemplates
[i
].class_id
));
362 if (hFile
!= INVALID_HANDLE_VALUE
)
369 static HRESULT WINAPI
IDirectXFileImpl_CreateSaveObject(IDirectXFile
* iface
, LPCSTR szFileName
, DXFILEFORMAT dwFileFormat
, LPDIRECTXFILESAVEOBJECT
* ppSaveObj
)
371 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
373 FIXME("(%p/%p)->(%s,%x,%p) stub!\n", This
, iface
, szFileName
, dwFileFormat
, ppSaveObj
);
375 return DXFILEERR_BADVALUE
;
378 static BOOL
read_bytes(parse_buffer
* buf
, LPVOID data
, DWORD size
)
380 if (buf
->rem_bytes
< size
)
382 memcpy(data
, buf
->buffer
, size
);
384 buf
->rem_bytes
-= size
;
388 static void dump_TOKEN(WORD token
)
390 #define DUMP_TOKEN(t) case t: TRACE(#t "\n"); break
393 DUMP_TOKEN(TOKEN_NAME
);
394 DUMP_TOKEN(TOKEN_STRING
);
395 DUMP_TOKEN(TOKEN_INTEGER
);
396 DUMP_TOKEN(TOKEN_GUID
);
397 DUMP_TOKEN(TOKEN_INTEGER_LIST
);
398 DUMP_TOKEN(TOKEN_FLOAT_LIST
);
399 DUMP_TOKEN(TOKEN_OBRACE
);
400 DUMP_TOKEN(TOKEN_CBRACE
);
401 DUMP_TOKEN(TOKEN_OPAREN
);
402 DUMP_TOKEN(TOKEN_CPAREN
);
403 DUMP_TOKEN(TOKEN_OBRACKET
);
404 DUMP_TOKEN(TOKEN_CBRACKET
);
405 DUMP_TOKEN(TOKEN_OANGLE
);
406 DUMP_TOKEN(TOKEN_CANGLE
);
407 DUMP_TOKEN(TOKEN_DOT
);
408 DUMP_TOKEN(TOKEN_COMMA
);
409 DUMP_TOKEN(TOKEN_SEMICOLON
);
410 DUMP_TOKEN(TOKEN_TEMPLATE
);
411 DUMP_TOKEN(TOKEN_WORD
);
412 DUMP_TOKEN(TOKEN_DWORD
);
413 DUMP_TOKEN(TOKEN_FLOAT
);
414 DUMP_TOKEN(TOKEN_DOUBLE
);
415 DUMP_TOKEN(TOKEN_CHAR
);
416 DUMP_TOKEN(TOKEN_UCHAR
);
417 DUMP_TOKEN(TOKEN_SWORD
);
418 DUMP_TOKEN(TOKEN_SDWORD
);
419 DUMP_TOKEN(TOKEN_VOID
);
420 DUMP_TOKEN(TOKEN_LPSTR
);
421 DUMP_TOKEN(TOKEN_UNICODE
);
422 DUMP_TOKEN(TOKEN_CSTRING
);
423 DUMP_TOKEN(TOKEN_ARRAY
);
426 TRACE("Unknown token %d\n", token
);
432 static BOOL
is_space(char c
)
446 static BOOL
is_operator(char c
)
465 static inline BOOL
is_separator(char c
)
467 return is_space(c
) || is_operator(c
);
470 static WORD
get_operator_token(char c
)
479 return TOKEN_OBRACKET
;
481 return TOKEN_CBRACKET
;
493 return TOKEN_SEMICOLON
;
498 static BOOL
is_keyword(parse_buffer
* buf
, const char* keyword
)
500 DWORD len
= strlen(keyword
);
501 if (!strncmp((char*)buf
->buffer
, keyword
,len
) && is_separator(*(buf
->buffer
+len
)))
504 buf
->rem_bytes
-= len
;
510 static WORD
get_keyword_token(parse_buffer
* buf
)
512 if (is_keyword(buf
, "template"))
513 return TOKEN_TEMPLATE
;
514 if (is_keyword(buf
, "WORD"))
516 if (is_keyword(buf
, "DWORD"))
518 if (is_keyword(buf
, "FLOAT"))
520 if (is_keyword(buf
, "DOUBLE"))
522 if (is_keyword(buf
, "CHAR"))
524 if (is_keyword(buf
, "UCHAR"))
526 if (is_keyword(buf
, "SWORD"))
528 if (is_keyword(buf
, "SDWORD"))
530 if (is_keyword(buf
, "VOID"))
532 if (is_keyword(buf
, "STRING"))
534 if (is_keyword(buf
, "UNICODE"))
535 return TOKEN_UNICODE
;
536 if (is_keyword(buf
, "CSTRING"))
537 return TOKEN_CSTRING
;
538 if (is_keyword(buf
, "array"))
544 static BOOL
is_guid(parse_buffer
* buf
)
552 if (*buf
->buffer
!= '<')
555 while (*(buf
->buffer
+pos
) != '>')
557 tmp
[pos
] = *(buf
->buffer
+pos
);
562 if (pos
!= 38 /* <+36+> */)
564 TRACE("Wrong guid %s (%d)\n", tmp
, pos
);
568 buf
->rem_bytes
-= pos
;
570 ret
= sscanf(tmp
, CLSIDFMT
, &class_id
.Data1
, tab
, tab
+1, tab
+2, tab
+3, tab
+4, tab
+5, tab
+6, tab
+7, tab
+8, tab
+9);
573 TRACE("Wrong guid %s (%d)\n", tmp
, pos
);
576 TRACE("Found guid %s (%d)\n", tmp
, pos
);
578 class_id
.Data2
= tab
[0];
579 class_id
.Data3
= tab
[1];
580 class_id
.Data4
[0] = tab
[2];
581 class_id
.Data4
[1] = tab
[3];
582 class_id
.Data4
[2] = tab
[4];
583 class_id
.Data4
[3] = tab
[5];
584 class_id
.Data4
[4] = tab
[6];
585 class_id
.Data4
[5] = tab
[7];
586 class_id
.Data4
[6] = tab
[8];
587 class_id
.Data4
[7] = tab
[9];
589 *(GUID
*)buf
->value
= class_id
;
594 static BOOL
is_name(parse_buffer
* buf
)
600 while (!is_separator(c
= *(buf
->buffer
+pos
)))
602 if (!(((c
>= 'a') && (c
<= 'z')) || ((c
>= 'A') && (c
<= 'Z')) || ((c
>= '0') && (c
<= '9')) || (c
== '_') || (c
== '-')))
610 TRACE("Wrong name %s\n", tmp
);
615 buf
->rem_bytes
-= pos
;
617 TRACE("Found name %s\n", tmp
);
618 strcpy((char*)buf
->value
, tmp
);
623 static BOOL
is_float(parse_buffer
* buf
)
631 while (!is_separator(c
= *(buf
->buffer
+pos
)))
633 if (!((!pos
&& (c
== '-')) || ((c
>= '0') && (c
<= '9')) || (!dot
&& (c
== '.'))))
642 buf
->rem_bytes
-= pos
;
644 sscanf(tmp
, "%f", &decimal
);
646 TRACE("Found float %s - %f\n", tmp
, decimal
);
648 *(float*)buf
->value
= decimal
;
653 static BOOL
is_integer(parse_buffer
* buf
)
660 while (!is_separator(c
= *(buf
->buffer
+pos
)))
662 if (!((c
>= '0') && (c
<= '9')))
669 buf
->rem_bytes
-= pos
;
671 sscanf(tmp
, "%d", &integer
);
673 TRACE("Found integer %s - %d\n", tmp
, integer
);
675 *(DWORD
*)buf
->value
= integer
;
680 static BOOL
is_string(parse_buffer
* buf
)
687 if (*buf
->buffer
!= '"')
690 while (!is_separator(c
= *(buf
->buffer
+pos
+1)) && (pos
< 31))
703 TRACE("Wrong string %s\n", tmp
);
707 buf
->buffer
+= pos
+ 2;
708 buf
->rem_bytes
-= pos
+ 2;
710 TRACE("Found string %s\n", tmp
);
711 strcpy((char*)buf
->value
, tmp
);
716 static WORD
parse_TOKEN(parse_buffer
* buf
)
725 if (!read_bytes(buf
, &c
, 1))
727 /*TRACE("char = '%c'\n", is_space(c) ? ' ' : c);*/
728 if ((c
== '#') || (c
== '/'))
730 /* Handle comment (# or //) */
733 if (!read_bytes(buf
, &c
, 1))
741 if (!read_bytes(buf
, &c
, 1))
748 if (is_operator(c
) && (c
!= '<'))
750 token
= get_operator_token(c
);
763 if ((token
= get_keyword_token(buf
)))
773 token
= TOKEN_INTEGER
;
792 FIXME("Unrecognize element\n");
804 if (!read_bytes(buf
, &token
, 2))
807 /* Convert integer and float list into separate elements */
808 if (token
== TOKEN_INTEGER_LIST
)
810 if (!read_bytes(buf
, &nb_elem
, 4))
812 token
= TOKEN_INTEGER
;
814 TRACE("Integer list (TOKEN_INTEGER_LIST) of size %d\n", nb_elem
);
816 else if (token
== TOKEN_FLOAT_LIST
)
818 if (!read_bytes(buf
, &nb_elem
, 4))
822 TRACE("Float list (TOKEN_FLOAT_LIST) of size %d\n", nb_elem
);
828 token
= is_float
? TOKEN_FLOAT
: TOKEN_INTEGER
;
833 if (!read_bytes(buf
, &integer
, 4))
836 *(DWORD
*)buf
->value
= integer
;
849 if (!read_bytes(buf
, &count
, 4))
851 if (!read_bytes(buf
, strname
, count
))
854 /*TRACE("name = %s\n", strname);*/
856 strcpy((char*)buf
->value
, strname
);
863 if (!read_bytes(buf
, &integer
, 4))
865 /*TRACE("integer = %ld\n", integer);*/
867 *(DWORD
*)buf
->value
= integer
;
875 if (!read_bytes(buf
, &class_id
, 16))
877 sprintf(strguid
, CLSIDFMT
, class_id
.Data1
, class_id
.Data2
, class_id
.Data3
, class_id
.Data4
[0],
878 class_id
.Data4
[1], class_id
.Data4
[2], class_id
.Data4
[3], class_id
.Data4
[4], class_id
.Data4
[5],
879 class_id
.Data4
[6], class_id
.Data4
[7]);
880 /*TRACE("guid = {%s}\n", strguid);*/
882 *(GUID
*)buf
->value
= class_id
;
890 if (!read_bytes(buf
, &count
, 4))
892 if (!read_bytes(buf
, strname
, count
))
895 if (!read_bytes(buf
, &tmp_token
, 2))
897 if ((tmp_token
!= TOKEN_COMMA
) && (tmp_token
!= TOKEN_SEMICOLON
))
898 ERR("No comma or semicolon (got %d)\n", tmp_token
);
899 /*TRACE("name = %s\n", strname);*/
901 strcpy((char*)buf
->value
, strname
);
915 case TOKEN_SEMICOLON
:
941 static const char* get_primitive_string(WORD token
)
975 static WORD
get_TOKEN(parse_buffer
* buf
)
977 if (buf
->token_present
)
979 buf
->token_present
= FALSE
;
980 return buf
->current_token
;
983 buf
->current_token
= parse_TOKEN(buf
);
985 return buf
->current_token
;
988 static WORD
check_TOKEN(parse_buffer
* buf
)
990 if (buf
->token_present
)
991 return buf
->current_token
;
993 buf
->current_token
= parse_TOKEN(buf
);
994 buf
->token_present
= TRUE
;
996 return buf
->current_token
;
999 static inline BOOL
is_primitive_type(WORD token
)
1024 static BOOL
parse_template_option_info(parse_buffer
* buf
)
1026 xtemplate
* cur_template
= &buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
];
1028 if (check_TOKEN(buf
) == TOKEN_DOT
)
1031 if (get_TOKEN(buf
) != TOKEN_DOT
)
1033 if (get_TOKEN(buf
) != TOKEN_DOT
)
1035 cur_template
->open
= TRUE
;
1041 if (get_TOKEN(buf
) != TOKEN_NAME
)
1043 strcpy(cur_template
->childs
[cur_template
->nb_childs
], (char*)buf
->value
);
1044 if (check_TOKEN(buf
) == TOKEN_GUID
)
1046 cur_template
->nb_childs
++;
1047 if (check_TOKEN(buf
) != TOKEN_COMMA
)
1051 cur_template
->open
= FALSE
;
1057 static BOOL
parse_template_members_list(parse_buffer
* buf
)
1066 cur_member
= &buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].members
[idx_member
];
1068 if (check_TOKEN(buf
) == TOKEN_ARRAY
)
1074 if (check_TOKEN(buf
) == TOKEN_NAME
)
1076 cur_member
->type
= get_TOKEN(buf
);
1077 cur_member
->idx_template
= 0;
1078 while (cur_member
->idx_template
< buf
->pdxf
->nb_xtemplates
)
1080 if (!strcmp((char*)buf
->value
, buf
->pdxf
->xtemplates
[cur_member
->idx_template
].name
))
1082 cur_member
->idx_template
++;
1084 if (cur_member
->idx_template
== buf
->pdxf
->nb_xtemplates
)
1086 TRACE("Reference to a nonexistent template '%s'\n", (char*)buf
->value
);
1090 else if (is_primitive_type(check_TOKEN(buf
)))
1091 cur_member
->type
= get_TOKEN(buf
);
1095 if (get_TOKEN(buf
) != TOKEN_NAME
)
1097 strcpy(cur_member
->name
, (char*)buf
->value
);
1101 while (check_TOKEN(buf
) == TOKEN_OBRACKET
)
1103 if (nb_dims
>= MAX_ARRAY_DIM
)
1105 FIXME("Too many dimensions (%d) for multi-dimensional array\n", nb_dims
+ 1);
1109 if (check_TOKEN(buf
) == TOKEN_INTEGER
)
1112 cur_member
->dim_fixed
[nb_dims
] = TRUE
;
1113 cur_member
->dim_value
[nb_dims
] = *(DWORD
*)buf
->value
;
1118 if (get_TOKEN(buf
) != TOKEN_NAME
)
1120 for (i
= 0; i
< idx_member
; i
++)
1122 if (!strcmp((char*)buf
->value
, buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].members
[i
].name
))
1124 if (buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].members
[i
].nb_dims
)
1126 ERR("Array cannot be used to specify variable array size\n");
1129 if (buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].members
[i
].type
!= TOKEN_DWORD
)
1131 FIXME("Only DWORD supported to specify variable array size\n");
1137 if (i
== idx_member
)
1139 ERR("Reference to unknown member %s\n", (char*)buf
->value
);
1142 cur_member
->dim_fixed
[nb_dims
] = FALSE
;
1143 cur_member
->dim_value
[nb_dims
] = i
;
1145 if (get_TOKEN(buf
) != TOKEN_CBRACKET
)
1151 cur_member
->nb_dims
= nb_dims
;
1153 if (get_TOKEN(buf
) != TOKEN_SEMICOLON
)
1159 buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].nb_members
= idx_member
;
1164 static BOOL
parse_template_parts(parse_buffer
* buf
)
1166 if (!parse_template_members_list(buf
))
1168 if (check_TOKEN(buf
) == TOKEN_OBRACKET
)
1171 if (!parse_template_option_info(buf
))
1173 if (get_TOKEN(buf
) != TOKEN_CBRACKET
)
1180 static BOOL
parse_template(parse_buffer
* buf
)
1182 if (get_TOKEN(buf
) != TOKEN_TEMPLATE
)
1184 if (get_TOKEN(buf
) != TOKEN_NAME
)
1186 strcpy(buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].name
, (char*)buf
->value
);
1187 if (get_TOKEN(buf
) != TOKEN_OBRACE
)
1189 if (get_TOKEN(buf
) != TOKEN_GUID
)
1191 buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].class_id
= *(GUID
*)buf
->value
;
1192 if (!parse_template_parts(buf
))
1194 if (get_TOKEN(buf
) != TOKEN_CBRACE
)
1198 /* Go to the next template */
1199 while (buf
->rem_bytes
&& is_space(*buf
->buffer
))
1206 TRACE("%d - %s - %s\n", buf
->pdxf
->nb_xtemplates
, buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].name
, debugstr_guid(&buf
->pdxf
->xtemplates
[buf
->pdxf
->nb_xtemplates
].class_id
));
1207 buf
->pdxf
->nb_xtemplates
++;
1212 static HRESULT WINAPI
IDirectXFileImpl_RegisterTemplates(IDirectXFile
* iface
, LPVOID pvData
, DWORD cbSize
)
1214 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
1218 buf
.buffer
= (LPBYTE
)pvData
;
1219 buf
.rem_bytes
= cbSize
;
1221 buf
.token_present
= FALSE
;
1224 TRACE("(%p/%p)->(%p,%d)\n", This
, iface
, pvData
, cbSize
);
1227 return DXFILEERR_BADVALUE
;
1230 return DXFILEERR_BADFILETYPE
;
1232 if (TRACE_ON(d3dxof
))
1235 memcpy(string
, pvData
, 16);
1237 TRACE("header = '%s'\n", string
);
1240 read_bytes(&buf
, &token_header
, 4);
1242 if (token_header
!= XOFFILE_FORMAT_MAGIC
)
1243 return DXFILEERR_BADFILETYPE
;
1245 read_bytes(&buf
, &token_header
, 4);
1247 if ((token_header
!= XOFFILE_FORMAT_VERSION_302
) && (token_header
!= XOFFILE_FORMAT_VERSION_303
))
1248 return DXFILEERR_BADFILEVERSION
;
1250 read_bytes(&buf
, &token_header
, 4);
1252 if ((token_header
!= XOFFILE_FORMAT_BINARY
) && (token_header
!= XOFFILE_FORMAT_TEXT
) && (token_header
!= XOFFILE_FORMAT_COMPRESSED
))
1253 return DXFILEERR_BADFILETYPE
;
1255 if (token_header
== XOFFILE_FORMAT_TEXT
)
1260 if (token_header
== XOFFILE_FORMAT_COMPRESSED
)
1262 FIXME("Compressed formats not supported yet\n");
1263 return DXFILEERR_BADVALUE
;
1266 read_bytes(&buf
, &token_header
, 4);
1268 if ((token_header
!= XOFFILE_FORMAT_FLOAT_BITS_32
) && (token_header
!= XOFFILE_FORMAT_FLOAT_BITS_64
))
1269 return DXFILEERR_BADFILEFLOATSIZE
;
1271 TRACE("Header is correct\n");
1273 while (buf
.rem_bytes
)
1275 if (!parse_template(&buf
))
1277 TRACE("Template is not correct\n");
1278 return DXFILEERR_BADVALUE
;
1282 TRACE("Template successfully parsed:\n");
1283 if (TRACE_ON(d3dxof
))
1284 dump_template(This
->xtemplates
, &This
->xtemplates
[This
->nb_xtemplates
- 1]);
1288 if (TRACE_ON(d3dxof
))
1291 TRACE("Registered templates (%d):\n", This
->nb_xtemplates
);
1292 for (i
= 0; i
< This
->nb_xtemplates
; i
++)
1293 DPRINTF("%s - %s\n", This
->xtemplates
[i
].name
, debugstr_guid(&This
->xtemplates
[i
].class_id
));
1299 static const IDirectXFileVtbl IDirectXFile_Vtbl
=
1301 IDirectXFileImpl_QueryInterface
,
1302 IDirectXFileImpl_AddRef
,
1303 IDirectXFileImpl_Release
,
1304 IDirectXFileImpl_CreateEnumObject
,
1305 IDirectXFileImpl_CreateSaveObject
,
1306 IDirectXFileImpl_RegisterTemplates
1309 HRESULT
IDirectXFileBinaryImpl_Create(IDirectXFileBinaryImpl
** ppObj
)
1311 IDirectXFileBinaryImpl
* object
;
1313 TRACE("(%p)\n", ppObj
);
1315 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileBinaryImpl
));
1317 object
->lpVtbl
.lpVtbl
= &IDirectXFileBinary_Vtbl
;
1325 /*** IUnknown methods ***/
1326 static HRESULT WINAPI
IDirectXFileBinaryImpl_QueryInterface(IDirectXFileBinary
* iface
, REFIID riid
, void** ppvObject
)
1328 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
1330 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
1332 if (IsEqualGUID(riid
, &IID_IUnknown
)
1333 || IsEqualGUID(riid
, &IID_IDirectXFileObject
)
1334 || IsEqualGUID(riid
, &IID_IDirectXFileBinary
))
1336 IClassFactory_AddRef(iface
);
1341 /* Do not print an error for interfaces that can be queried to retrieve the type of the object */
1342 if (!IsEqualGUID(riid
, &IID_IDirectXFileData
)
1343 && !IsEqualGUID(riid
, &IID_IDirectXFileDataReference
))
1344 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1346 return E_NOINTERFACE
;
1349 static ULONG WINAPI
IDirectXFileBinaryImpl_AddRef(IDirectXFileBinary
* iface
)
1351 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
1352 ULONG ref
= InterlockedIncrement(&This
->ref
);
1354 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
1359 static ULONG WINAPI
IDirectXFileBinaryImpl_Release(IDirectXFileBinary
* iface
)
1361 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
1362 ULONG ref
= InterlockedDecrement(&This
->ref
);
1364 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
1367 HeapFree(GetProcessHeap(), 0, This
);
1372 /*** IDirectXFileObject methods ***/
1373 static HRESULT WINAPI
IDirectXFileBinaryImpl_GetName(IDirectXFileBinary
* iface
, LPSTR pstrNameBuf
, LPDWORD pdwBufLen
)
1376 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
1378 FIXME("(%p/%p)->(%p,%p) stub!\n", This
, iface
, pstrNameBuf
, pdwBufLen
);
1380 return DXFILEERR_BADVALUE
;
1383 static HRESULT WINAPI
IDirectXFileBinaryImpl_GetId(IDirectXFileBinary
* iface
, LPGUID pGuid
)
1385 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
1387 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pGuid
);
1389 return DXFILEERR_BADVALUE
;
1392 /*** IDirectXFileBinary methods ***/
1393 static HRESULT WINAPI
IDirectXFileBinaryImpl_GetSize(IDirectXFileBinary
* iface
, DWORD
* pcbSize
)
1395 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
1397 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pcbSize
);
1399 return DXFILEERR_BADVALUE
;
1402 static HRESULT WINAPI
IDirectXFileBinaryImpl_GetMimeType(IDirectXFileBinary
* iface
, LPCSTR
* pszMimeType
)
1404 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
1406 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pszMimeType
);
1408 return DXFILEERR_BADVALUE
;
1411 static HRESULT WINAPI
IDirectXFileBinaryImpl_Read(IDirectXFileBinary
* iface
, LPVOID pvData
, DWORD cbSize
, LPDWORD pcbRead
)
1413 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
1415 FIXME("(%p/%p)->(%p, %d, %p) stub!\n", This
, iface
, pvData
, cbSize
, pcbRead
);
1417 return DXFILEERR_BADVALUE
;
1420 static const IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl
=
1422 IDirectXFileBinaryImpl_QueryInterface
,
1423 IDirectXFileBinaryImpl_AddRef
,
1424 IDirectXFileBinaryImpl_Release
,
1425 IDirectXFileBinaryImpl_GetName
,
1426 IDirectXFileBinaryImpl_GetId
,
1427 IDirectXFileBinaryImpl_GetSize
,
1428 IDirectXFileBinaryImpl_GetMimeType
,
1429 IDirectXFileBinaryImpl_Read
1432 HRESULT
IDirectXFileDataImpl_Create(IDirectXFileDataImpl
** ppObj
)
1434 IDirectXFileDataImpl
* object
;
1436 TRACE("(%p)\n", ppObj
);
1438 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileDataImpl
));
1440 object
->lpVtbl
.lpVtbl
= &IDirectXFileData_Vtbl
;
1448 /*** IUnknown methods ***/
1449 static HRESULT WINAPI
IDirectXFileDataImpl_QueryInterface(IDirectXFileData
* iface
, REFIID riid
, void** ppvObject
)
1451 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1453 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
1455 if (IsEqualGUID(riid
, &IID_IUnknown
)
1456 || IsEqualGUID(riid
, &IID_IDirectXFileObject
)
1457 || IsEqualGUID(riid
, &IID_IDirectXFileData
))
1459 IClassFactory_AddRef(iface
);
1464 /* Do not print an error for interfaces that can be queried to retrieve the type of the object */
1465 if (!IsEqualGUID(riid
, &IID_IDirectXFileBinary
)
1466 && !IsEqualGUID(riid
, &IID_IDirectXFileDataReference
))
1467 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1469 return E_NOINTERFACE
;
1472 static ULONG WINAPI
IDirectXFileDataImpl_AddRef(IDirectXFileData
* iface
)
1474 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1475 ULONG ref
= InterlockedIncrement(&This
->ref
);
1477 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
1482 static ULONG WINAPI
IDirectXFileDataImpl_Release(IDirectXFileData
* iface
)
1484 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1485 ULONG ref
= InterlockedDecrement(&This
->ref
);
1487 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
1490 HeapFree(GetProcessHeap(), 0, This
);
1495 /*** IDirectXFileObject methods ***/
1496 static HRESULT WINAPI
IDirectXFileDataImpl_GetName(IDirectXFileData
* iface
, LPSTR pstrNameBuf
, LPDWORD pdwBufLen
)
1499 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1501 TRACE("(%p/%p)->(%p,%p)\n", This
, iface
, pstrNameBuf
, pdwBufLen
);
1504 return DXFILEERR_BADVALUE
;
1506 strcpy(pstrNameBuf
, This
->pobj
->name
);
1511 static HRESULT WINAPI
IDirectXFileDataImpl_GetId(IDirectXFileData
* iface
, LPGUID pGuid
)
1513 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1515 TRACE("(%p/%p)->(%p)\n", This
, iface
, pGuid
);
1518 return DXFILEERR_BADVALUE
;
1520 memcpy(pGuid
, &This
->pobj
->class_id
, 16);
1525 /*** IDirectXFileData methods ***/
1526 static HRESULT WINAPI
IDirectXFileDataImpl_GetData(IDirectXFileData
* iface
, LPCSTR szMember
, DWORD
* pcbSize
, void** ppvData
)
1528 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1530 TRACE("(%p/%p)->(%s,%p,%p)\n", This
, iface
, szMember
, pcbSize
, ppvData
);
1532 if (!pcbSize
|| !ppvData
)
1533 return DXFILEERR_BADVALUE
;
1537 FIXME("Specifying a member is not supported yet!\n");
1538 return DXFILEERR_BADVALUE
;
1541 *pcbSize
= This
->pobj
->size
;
1542 *ppvData
= This
->pobj
->pdata
;
1547 static HRESULT WINAPI
IDirectXFileDataImpl_GetType(IDirectXFileData
* iface
, const GUID
** pguid
)
1549 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1552 TRACE("(%p/%p)->(%p)\n", This
, iface
, pguid
);
1555 return DXFILEERR_BADVALUE
;
1557 memcpy(&guid
, &This
->pobj
->type
, 16);
1563 static HRESULT WINAPI
IDirectXFileDataImpl_GetNextObject(IDirectXFileData
* iface
, LPDIRECTXFILEOBJECT
* ppChildObj
)
1566 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1568 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppChildObj
);
1570 if (This
->cur_enum_object
>= This
->pobj
->nb_childs
)
1571 return DXFILEERR_NOMOREOBJECTS
;
1573 if (This
->from_ref
&& (This
->level
>= 1))
1575 /* Only 2 levels can enumerated if the object is obtained from a reference */
1576 return DXFILEERR_NOMOREOBJECTS
;
1579 if (This
->pobj
->childs
[This
->cur_enum_object
]->ptarget
)
1581 IDirectXFileDataReferenceImpl
*object
;
1583 hr
= IDirectXFileDataReferenceImpl_Create(&object
);
1585 return DXFILEERR_BADVALUE
;
1587 object
->ptarget
= This
->pobj
->childs
[This
->cur_enum_object
++]->ptarget
;
1589 *ppChildObj
= (LPDIRECTXFILEOBJECT
)object
;
1593 IDirectXFileDataImpl
*object
;
1595 hr
= IDirectXFileDataImpl_Create(&object
);
1597 return DXFILEERR_BADVALUE
;
1599 object
->pobj
= This
->pobj
->childs
[This
->cur_enum_object
++];
1600 object
->cur_enum_object
= 0;
1601 object
->from_ref
= This
->from_ref
;
1602 object
->level
= This
->level
+ 1;
1604 *ppChildObj
= (LPDIRECTXFILEOBJECT
)object
;
1610 static HRESULT WINAPI
IDirectXFileDataImpl_AddDataObject(IDirectXFileData
* iface
, LPDIRECTXFILEDATA pDataObj
)
1612 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1614 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pDataObj
);
1616 return DXFILEERR_BADVALUE
;
1619 static HRESULT WINAPI
IDirectXFileDataImpl_AddDataReference(IDirectXFileData
* iface
, LPCSTR szRef
, const GUID
* pguidRef
)
1621 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1623 FIXME("(%p/%p)->(%s,%p) stub!\n", This
, iface
, szRef
, pguidRef
);
1625 return DXFILEERR_BADVALUE
;
1628 static HRESULT WINAPI
IDirectXFileDataImpl_AddBinaryObject(IDirectXFileData
* iface
, LPCSTR szName
, const GUID
* pguid
, LPCSTR szMimeType
, LPVOID pvData
, DWORD cbSize
)
1630 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
1632 FIXME("(%p/%p)->(%s,%p,%s,%p,%d) stub!\n", This
, iface
, szName
, pguid
, szMimeType
, pvData
, cbSize
);
1634 return DXFILEERR_BADVALUE
;
1637 static const IDirectXFileDataVtbl IDirectXFileData_Vtbl
=
1639 IDirectXFileDataImpl_QueryInterface
,
1640 IDirectXFileDataImpl_AddRef
,
1641 IDirectXFileDataImpl_Release
,
1642 IDirectXFileDataImpl_GetName
,
1643 IDirectXFileDataImpl_GetId
,
1644 IDirectXFileDataImpl_GetData
,
1645 IDirectXFileDataImpl_GetType
,
1646 IDirectXFileDataImpl_GetNextObject
,
1647 IDirectXFileDataImpl_AddDataObject
,
1648 IDirectXFileDataImpl_AddDataReference
,
1649 IDirectXFileDataImpl_AddBinaryObject
1652 HRESULT
IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImpl
** ppObj
)
1654 IDirectXFileDataReferenceImpl
* object
;
1656 TRACE("(%p)\n", ppObj
);
1658 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileDataReferenceImpl
));
1660 object
->lpVtbl
.lpVtbl
= &IDirectXFileDataReference_Vtbl
;
1668 /*** IUnknown methods ***/
1669 static HRESULT WINAPI
IDirectXFileDataReferenceImpl_QueryInterface(IDirectXFileDataReference
* iface
, REFIID riid
, void** ppvObject
)
1671 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1673 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
1675 if (IsEqualGUID(riid
, &IID_IUnknown
)
1676 || IsEqualGUID(riid
, &IID_IDirectXFileObject
)
1677 || IsEqualGUID(riid
, &IID_IDirectXFileDataReference
))
1679 IClassFactory_AddRef(iface
);
1684 /* Do not print an error for interfaces that can be queried to retrieve the type of the object */
1685 if (!IsEqualGUID(riid
, &IID_IDirectXFileData
)
1686 && !IsEqualGUID(riid
, &IID_IDirectXFileBinary
))
1687 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1689 return E_NOINTERFACE
;
1692 static ULONG WINAPI
IDirectXFileDataReferenceImpl_AddRef(IDirectXFileDataReference
* iface
)
1694 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1695 ULONG ref
= InterlockedIncrement(&This
->ref
);
1697 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
1702 static ULONG WINAPI
IDirectXFileDataReferenceImpl_Release(IDirectXFileDataReference
* iface
)
1704 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1705 ULONG ref
= InterlockedDecrement(&This
->ref
);
1707 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
1710 HeapFree(GetProcessHeap(), 0, This
);
1715 /*** IDirectXFileObject methods ***/
1716 static HRESULT WINAPI
IDirectXFileDataReferenceImpl_GetName(IDirectXFileDataReference
* iface
, LPSTR pstrNameBuf
, LPDWORD pdwBufLen
)
1718 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1720 TRACE("(%p/%p)->(%p,%p)\n", This
, iface
, pstrNameBuf
, pdwBufLen
);
1723 return DXFILEERR_BADVALUE
;
1725 strcpy(pstrNameBuf
, This
->ptarget
->name
);
1727 return DXFILEERR_BADVALUE
;
1730 static HRESULT WINAPI
IDirectXFileDataReferenceImpl_GetId(IDirectXFileDataReference
* iface
, LPGUID pGuid
)
1732 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1734 TRACE("(%p/%p)->(%p)\n", This
, iface
, pGuid
);
1737 return DXFILEERR_BADVALUE
;
1739 memcpy(pGuid
, &This
->ptarget
->class_id
, 16);
1744 /*** IDirectXFileDataReference ***/
1745 static HRESULT WINAPI
IDirectXFileDataReferenceImpl_Resolve(IDirectXFileDataReference
* iface
, LPDIRECTXFILEDATA
* ppDataObj
)
1747 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1748 IDirectXFileDataImpl
*object
;
1751 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppDataObj
);
1754 return DXFILEERR_BADVALUE
;
1756 hr
= IDirectXFileDataImpl_Create(&object
);
1758 return DXFILEERR_BADVALUE
;
1760 object
->pobj
= This
->ptarget
;
1761 object
->cur_enum_object
= 0;
1763 object
->from_ref
= TRUE
;
1765 *ppDataObj
= (LPDIRECTXFILEDATA
)object
;
1770 static const IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl
=
1772 IDirectXFileDataReferenceImpl_QueryInterface
,
1773 IDirectXFileDataReferenceImpl_AddRef
,
1774 IDirectXFileDataReferenceImpl_Release
,
1775 IDirectXFileDataReferenceImpl_GetName
,
1776 IDirectXFileDataReferenceImpl_GetId
,
1777 IDirectXFileDataReferenceImpl_Resolve
1780 HRESULT
IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl
** ppObj
)
1782 IDirectXFileEnumObjectImpl
* object
;
1784 TRACE("(%p)\n", ppObj
);
1786 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileEnumObjectImpl
));
1788 object
->lpVtbl
.lpVtbl
= &IDirectXFileEnumObject_Vtbl
;
1796 /*** IUnknown methods ***/
1797 static HRESULT WINAPI
IDirectXFileEnumObjectImpl_QueryInterface(IDirectXFileEnumObject
* iface
, REFIID riid
, void** ppvObject
)
1799 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1801 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
1803 if (IsEqualGUID(riid
, &IID_IUnknown
)
1804 || IsEqualGUID(riid
, &IID_IDirectXFileEnumObject
))
1806 IClassFactory_AddRef(iface
);
1811 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1812 return E_NOINTERFACE
;
1815 static ULONG WINAPI
IDirectXFileEnumObjectImpl_AddRef(IDirectXFileEnumObject
* iface
)
1817 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1818 ULONG ref
= InterlockedIncrement(&This
->ref
);
1820 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
1825 static ULONG WINAPI
IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject
* iface
)
1827 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1828 ULONG ref
= InterlockedDecrement(&This
->ref
);
1830 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
1834 CloseHandle(This
->hFile
);
1835 HeapFree(GetProcessHeap(), 0, This
);
1841 static BOOL
parse_object_members_list(parse_buffer
* buf
)
1845 xtemplate
* pt
= buf
->pxt
[buf
->level
];
1846 DWORD last_dword
= 0;
1848 for (i
= 0; i
< pt
->nb_members
; i
++)
1853 buf
->pxo
->members
[i
].start
= buf
->cur_pdata
;
1855 for (k
= 0; k
< pt
->members
[i
].nb_dims
; k
++)
1857 if (pt
->members
[i
].dim_fixed
[k
])
1858 nb_elems
*= pt
->members
[i
].dim_value
[k
];
1860 nb_elems
*= *(DWORD
*)buf
->pxo
->members
[pt
->members
[i
].dim_value
[k
]].start
;
1863 TRACE("Elements to consider: %d\n", nb_elems
);
1865 for (k
= 0; k
< nb_elems
; k
++)
1869 token
= check_TOKEN(buf
);
1870 if (token
== TOKEN_COMMA
)
1876 /* Allow comma omission */
1877 if (!((token
== TOKEN_FLOAT
)))
1882 if (pt
->members
[i
].type
== TOKEN_NAME
)
1886 TRACE("Found sub-object %s\n", buf
->pdxf
->xtemplates
[pt
->members
[i
].idx_template
].name
);
1888 /* To do template lookup */
1889 for (j
= 0; j
< buf
->pdxf
->nb_xtemplates
; j
++)
1891 if (!strcmp(buf
->pdxf
->xtemplates
[pt
->members
[i
].idx_template
].name
, buf
->pdxf
->xtemplates
[j
].name
))
1893 buf
->pxt
[buf
->level
] = &buf
->pdxf
->xtemplates
[j
];
1897 if (j
== buf
->pdxf
->nb_xtemplates
)
1899 FIXME("Unknown template %s\n", (char*)buf
->value
);
1903 TRACE("Enter %s\n", buf
->pdxf
->xtemplates
[pt
->members
[i
].idx_template
].name
);
1904 if (!parse_object_parts(buf
, FALSE
))
1913 token
= check_TOKEN(buf
);
1914 if (token
== TOKEN_INTEGER
)
1917 last_dword
= *(DWORD
*)buf
->value
;
1918 TRACE("%s = %d\n", pt
->members
[i
].name
, *(DWORD
*)buf
->value
);
1919 /* Assume larger size */
1920 if ((buf
->cur_pdata
- buf
->pdata
+ 4) > MAX_DATA_SIZE
)
1922 FIXME("Buffer too small\n");
1925 if (pt
->members
[i
].type
== TOKEN_WORD
)
1927 *(((WORD
*)(buf
->cur_pdata
))) = (WORD
)(*(DWORD
*)buf
->value
);
1928 buf
->cur_pdata
+= 2;
1930 else if (pt
->members
[i
].type
== TOKEN_DWORD
)
1932 *(((DWORD
*)(buf
->cur_pdata
))) = (DWORD
)(*(DWORD
*)buf
->value
);
1933 buf
->cur_pdata
+= 4;
1937 FIXME("Token %d not supported\n", pt
->members
[i
].type
);
1941 else if (token
== TOKEN_FLOAT
)
1944 TRACE("%s = %f\n", pt
->members
[i
].name
, *(float*)buf
->value
);
1945 /* Assume larger size */
1946 if ((buf
->cur_pdata
- buf
->pdata
+ 4) > MAX_DATA_SIZE
)
1948 FIXME("Buffer too small\n");
1951 if (pt
->members
[i
].type
== TOKEN_FLOAT
)
1953 *(((float*)(buf
->cur_pdata
))) = (float)(*(float*)buf
->value
);
1954 buf
->cur_pdata
+= 4;
1958 FIXME("Token %d not supported\n", pt
->members
[i
].type
);
1962 else if (token
== TOKEN_LPSTR
)
1965 TRACE("%s = %s\n", pt
->members
[i
].name
, (char*)buf
->value
);
1966 /* Assume larger size */
1967 if ((buf
->cur_pdata
- buf
->pdata
+ 4) > MAX_DATA_SIZE
)
1969 FIXME("Buffer too small\n");
1972 if (pt
->members
[i
].type
== TOKEN_LPSTR
)
1974 int len
= strlen((char*)buf
->value
) + 1;
1975 if ((buf
->cur_pstrings
- buf
->pstrings
+ len
) > MAX_STRINGS_BUFFER
)
1977 FIXME("Buffer too small %p %p %d\n", buf
->cur_pstrings
, buf
->pstrings
, len
);
1980 strcpy((char*)buf
->cur_pstrings
, (char*)buf
->value
);
1981 *(((LPCSTR
*)(buf
->cur_pdata
))) = (char*)buf
->cur_pstrings
;
1982 buf
->cur_pstrings
+= len
;
1983 buf
->cur_pdata
+= 4;
1987 FIXME("Token %d not supported\n", pt
->members
[i
].type
);
1993 FIXME("Unexpected token %d\n", token
);
2001 token
= get_TOKEN(buf
);
2002 if (token
!= TOKEN_SEMICOLON
)
2004 /* Allow comma instead of semicolon in some specific cases */
2005 if (!((token
== TOKEN_COMMA
) && ((i
+1) < pt
->nb_members
) && (pt
->members
[i
].type
== pt
->members
[i
+1].type
)
2006 && (!pt
->members
[i
].nb_dims
) && (!pt
->members
[i
+1].nb_dims
)))
2015 static BOOL
parse_object_parts(parse_buffer
* buf
, BOOL allow_optional
)
2017 if (!parse_object_members_list(buf
))
2022 buf
->pxo
->size
= buf
->cur_pdata
- buf
->pxo
->pdata
;
2024 /* Skip trailing semicolon */
2025 while (check_TOKEN(buf
) == TOKEN_SEMICOLON
)
2030 if (check_TOKEN(buf
) == TOKEN_OBRACE
)
2034 if (get_TOKEN(buf
) != TOKEN_NAME
)
2036 if (get_TOKEN(buf
) != TOKEN_CBRACE
)
2038 TRACE("Found optional reference %s\n", (char*)buf
->value
);
2039 for (i
= 0; i
< buf
->nb_pxo_globals
; i
++)
2041 for (j
= 0; j
< buf
->pxo_globals
[i
*MAX_SUBOBJECTS
].nb_subobjects
; j
++)
2043 if (!strcmp(buf
->pxo_globals
[i
*MAX_SUBOBJECTS
+j
].name
, (char*)buf
->value
))
2048 if (i
== buf
->nb_pxo_globals
)
2050 ERR("Reference to unknown object %s\n", (char*)buf
->value
);
2053 buf
->pxo
->childs
[buf
->pxo
->nb_childs
] = &buf
->pxo_tab
[buf
->cur_subobject
++];
2054 buf
->pxo
->childs
[buf
->pxo
->nb_childs
]->ptarget
= &buf
->pxo_globals
[i
*MAX_SUBOBJECTS
+j
];
2055 buf
->pxo
->nb_childs
++;
2057 else if (check_TOKEN(buf
) == TOKEN_NAME
)
2059 xobject
* pxo
= buf
->pxo
;
2060 buf
->pxo
= buf
->pxo
->childs
[buf
->pxo
->nb_childs
] = &buf
->pxo_tab
[buf
->cur_subobject
++];
2062 TRACE("Enter optional %s\n", (char*)buf
->value
);
2064 if (!parse_object(buf
))
2071 buf
->pxo
->nb_childs
++;
2078 if (buf
->pxo
->nb_childs
> MAX_CHILDS
)
2080 FIXME("Too many childs %d\n", buf
->pxo
->nb_childs
);
2087 static BOOL
parse_object(parse_buffer
* buf
)
2091 buf
->pxo
->pdata
= buf
->cur_pdata
;
2092 buf
->pxo
->ptarget
= NULL
;
2094 if (get_TOKEN(buf
) != TOKEN_NAME
)
2097 /* To do template lookup */
2098 for (i
= 0; i
< buf
->pdxf
->nb_xtemplates
; i
++)
2100 if (!strcmp((char*)buf
->value
, buf
->pdxf
->xtemplates
[i
].name
))
2102 buf
->pxt
[buf
->level
] = &buf
->pdxf
->xtemplates
[i
];
2103 memcpy(&buf
->pxo
->type
, &buf
->pdxf
->xtemplates
[i
].class_id
, 16);
2107 if (i
== buf
->pdxf
->nb_xtemplates
)
2109 FIXME("Unknown template %s\n", (char*)buf
->value
);
2113 if (check_TOKEN(buf
) == TOKEN_NAME
)
2116 strcpy(buf
->pxo
->name
, (char*)buf
->value
);
2119 buf
->pxo
->name
[0] = 0;
2121 if (get_TOKEN(buf
) != TOKEN_OBRACE
)
2123 if (check_TOKEN(buf
) == TOKEN_GUID
)
2126 memcpy(&buf
->pxo
->class_id
, buf
->value
, 16);
2129 memset(&buf
->pxo
->class_id
, 0, 16);
2131 if (!parse_object_parts(buf
, TRUE
))
2133 if (get_TOKEN(buf
) != TOKEN_CBRACE
)
2138 /* Go to the next object */
2139 while (buf
->rem_bytes
&& is_space(*buf
->buffer
))
2149 /*** IDirectXFileEnumObject methods ***/
2150 static HRESULT WINAPI
IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileEnumObject
* iface
, LPDIRECTXFILEDATA
* ppDataObj
)
2152 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
2153 IDirectXFileDataImpl
* object
;
2158 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppDataObj
);
2160 if (This
->nb_xobjects
>= MAX_OBJECTS
)
2162 ERR("Too many objects\n");
2163 return DXFILEERR_NOMOREOBJECTS
;
2166 if (!This
->buf
.rem_bytes
)
2167 return DXFILEERR_NOMOREOBJECTS
;
2169 hr
= IDirectXFileDataImpl_Create(&object
);
2173 This
->buf
.pxo_globals
= &This
->xobjects
[0][0];
2174 This
->buf
.nb_pxo_globals
= This
->nb_xobjects
;
2175 This
->buf
.pxo_tab
= &This
->xobjects
[This
->nb_xobjects
][0];
2176 This
->buf
.cur_subobject
= 0;
2177 This
->buf
.pxo
= &This
->buf
.pxo_tab
[This
->buf
.cur_subobject
++];
2178 This
->buf
.level
= 0;
2180 pdata
= HeapAlloc(GetProcessHeap(), 0, MAX_DATA_SIZE
);
2183 WARN("Out of memory\n");
2184 return DXFILEERR_BADALLOC
;
2186 This
->buf
.cur_pdata
= This
->buf
.pdata
= pdata
;
2188 pstrings
= HeapAlloc(GetProcessHeap(), 0, MAX_STRINGS_BUFFER
);
2191 WARN("Out of memory\n");
2192 HeapFree(GetProcessHeap(), 0, This
->buf
.pxo
->pdata
);
2193 return DXFILEERR_BADALLOC
;
2195 This
->buf
.cur_pstrings
= This
->buf
.pstrings
= pstrings
;
2197 if (!parse_object(&This
->buf
))
2199 TRACE("Object is not correct\n");
2200 HeapFree(GetProcessHeap(), 0, This
->buf
.pxo
->pdata
);
2201 HeapFree(GetProcessHeap(), 0, This
->buf
.pstrings
);
2202 return DXFILEERR_PARSEERROR
;
2205 This
->buf
.pxo
->nb_subobjects
= This
->buf
.cur_subobject
;
2206 if (This
->buf
.cur_subobject
> MAX_SUBOBJECTS
)
2208 FIXME("Too many suobjects %d\n", This
->buf
.cur_subobject
);
2209 return DXFILEERR_BADALLOC
;
2212 object
->pstrings
= pstrings
;
2213 object
->pobj
= This
->buf
.pxo
;
2214 object
->cur_enum_object
= 0;
2216 object
->from_ref
= FALSE
;
2218 *ppDataObj
= (LPDIRECTXFILEDATA
)object
;
2220 This
->nb_xobjects
++;
2225 static HRESULT WINAPI
IDirectXFileEnumObjectImpl_GetDataObjectById(IDirectXFileEnumObject
* iface
, REFGUID rguid
, LPDIRECTXFILEDATA
* ppDataObj
)
2227 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
2229 FIXME("(%p/%p)->(%p,%p) stub!\n", This
, iface
, rguid
, ppDataObj
);
2231 return DXFILEERR_BADVALUE
;
2234 static HRESULT WINAPI
IDirectXFileEnumObjectImpl_GetDataObjectByName(IDirectXFileEnumObject
* iface
, LPCSTR szName
, LPDIRECTXFILEDATA
* ppDataObj
)
2236 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
2238 FIXME("(%p/%p)->(%s,%p) stub!\n", This
, iface
, szName
, ppDataObj
);
2240 return DXFILEERR_BADVALUE
;
2243 static const IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl
=
2245 IDirectXFileEnumObjectImpl_QueryInterface
,
2246 IDirectXFileEnumObjectImpl_AddRef
,
2247 IDirectXFileEnumObjectImpl_Release
,
2248 IDirectXFileEnumObjectImpl_GetNextDataObject
,
2249 IDirectXFileEnumObjectImpl_GetDataObjectById
,
2250 IDirectXFileEnumObjectImpl_GetDataObjectByName
2253 HRESULT
IDirectXFileObjectImpl_Create(IDirectXFileObjectImpl
** ppObj
)
2255 IDirectXFileObjectImpl
* object
;
2257 TRACE("(%p)\n", ppObj
);
2259 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileObjectImpl
));
2261 object
->lpVtbl
.lpVtbl
= &IDirectXFileObject_Vtbl
;
2269 /*** IUnknown methods ***/
2270 static HRESULT WINAPI
IDirectXFileObjectImpl_QueryInterface(IDirectXFileObject
* iface
, REFIID riid
, void** ppvObject
)
2272 IDirectXFileObjectImpl
*This
= (IDirectXFileObjectImpl
*)iface
;
2274 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
2276 if (IsEqualGUID(riid
, &IID_IUnknown
)
2277 || IsEqualGUID(riid
, &IID_IDirectXFileObject
))
2279 IClassFactory_AddRef(iface
);
2284 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
2285 return E_NOINTERFACE
;
2288 static ULONG WINAPI
IDirectXFileObjectImpl_AddRef(IDirectXFileObject
* iface
)
2290 IDirectXFileObjectImpl
*This
= (IDirectXFileObjectImpl
*)iface
;
2291 ULONG ref
= InterlockedIncrement(&This
->ref
);
2293 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
2298 static ULONG WINAPI
IDirectXFileObjectImpl_Release(IDirectXFileObject
* iface
)
2300 IDirectXFileObjectImpl
*This
= (IDirectXFileObjectImpl
*)iface
;
2301 ULONG ref
= InterlockedDecrement(&This
->ref
);
2303 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
2306 HeapFree(GetProcessHeap(), 0, This
);
2311 /*** IDirectXFileObject methods ***/
2312 static HRESULT WINAPI
IDirectXFileObjectImpl_GetName(IDirectXFileObject
* iface
, LPSTR pstrNameBuf
, LPDWORD pdwBufLen
)
2314 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
2316 FIXME("(%p/%p)->(%p,%p) stub!\n", This
, iface
, pstrNameBuf
, pdwBufLen
);
2318 return DXFILEERR_BADVALUE
;
2321 static HRESULT WINAPI
IDirectXFileObjectImpl_GetId(IDirectXFileObject
* iface
, LPGUID pGuid
)
2323 IDirectXFileObjectImpl
*This
= (IDirectXFileObjectImpl
*)iface
;
2325 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pGuid
);
2327 return DXFILEERR_BADVALUE
;
2330 static const IDirectXFileObjectVtbl IDirectXFileObject_Vtbl
=
2332 IDirectXFileObjectImpl_QueryInterface
,
2333 IDirectXFileObjectImpl_AddRef
,
2334 IDirectXFileObjectImpl_Release
,
2335 IDirectXFileObjectImpl_GetName
,
2336 IDirectXFileObjectImpl_GetId
2339 HRESULT
IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl
** ppObj
)
2341 IDirectXFileSaveObjectImpl
* object
;
2343 TRACE("(%p)\n", ppObj
);
2345 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileSaveObjectImpl
));
2347 object
->lpVtbl
.lpVtbl
= &IDirectXFileSaveObject_Vtbl
;
2355 /*** IUnknown methods ***/
2356 static HRESULT WINAPI
IDirectXFileSaveObjectImpl_QueryInterface(IDirectXFileSaveObject
* iface
, REFIID riid
, void** ppvObject
)
2358 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
2360 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
2362 if (IsEqualGUID(riid
, &IID_IUnknown
)
2363 || IsEqualGUID(riid
, &IID_IDirectXFileSaveObject
))
2365 IClassFactory_AddRef(iface
);
2370 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
2371 return E_NOINTERFACE
;
2374 static ULONG WINAPI
IDirectXFileSaveObjectImpl_AddRef(IDirectXFileSaveObject
* iface
)
2376 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
2377 ULONG ref
= InterlockedIncrement(&This
->ref
);
2379 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
2384 static ULONG WINAPI
IDirectXFileSaveObjectImpl_Release(IDirectXFileSaveObject
* iface
)
2386 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
2387 ULONG ref
= InterlockedDecrement(&This
->ref
);
2389 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
2392 HeapFree(GetProcessHeap(), 0, This
);
2397 static HRESULT WINAPI
IDirectXFileSaveObjectImpl_SaveTemplates(IDirectXFileSaveObject
* iface
, DWORD cTemplates
, const GUID
** ppguidTemplates
)
2399 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
2401 FIXME("(%p/%p)->(%d,%p) stub!\n", This
, iface
, cTemplates
, ppguidTemplates
);
2403 return DXFILEERR_BADVALUE
;
2406 static HRESULT WINAPI
IDirectXFileSaveObjectImpl_CreateDataObject(IDirectXFileSaveObject
* iface
, REFGUID rguidTemplate
, LPCSTR szName
, const GUID
* pguid
, DWORD cbSize
, LPVOID pvData
, LPDIRECTXFILEDATA
* ppDataObj
)
2408 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
2410 FIXME("(%p/%p)->(%p,%s,%p,%d,%p,%p) stub!\n", This
, iface
, rguidTemplate
, szName
, pguid
, cbSize
, pvData
, ppDataObj
);
2412 return DXFILEERR_BADVALUE
;
2415 static HRESULT WINAPI
IDirectXFileSaveObjectImpl_SaveData(IDirectXFileSaveObject
* iface
, LPDIRECTXFILEDATA ppDataObj
)
2417 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
2419 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, ppDataObj
);
2421 return DXFILEERR_BADVALUE
;
2424 static const IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl
=
2426 IDirectXFileSaveObjectImpl_QueryInterface
,
2427 IDirectXFileSaveObjectImpl_AddRef
,
2428 IDirectXFileSaveObjectImpl_Release
,
2429 IDirectXFileSaveObjectImpl_SaveTemplates
,
2430 IDirectXFileSaveObjectImpl_CreateDataObject
,
2431 IDirectXFileSaveObjectImpl_SaveData