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 MAKEFOUR('0','3','0','2')
42 #define XOFFILE_FORMAT_BINARY MAKEFOUR('b','i','n',' ')
43 #define XOFFILE_FORMAT_TEXT MAKEFOUR('t','x','t',' ')
44 #define XOFFILE_FORMAT_COMPRESSED MAKEFOUR('c','m','p',' ')
45 #define XOFFILE_FORMAT_FLOAT_BITS_32 MAKEFOUR('0','0','3','2')
46 #define XOFFILE_FORMAT_FLOAT_BITS_64 MAKEFOUR('0','0','6','4')
49 #define TOKEN_STRING 2
50 #define TOKEN_INTEGER 3
52 #define TOKEN_INTEGER_LIST 6
53 #define TOKEN_FLOAT_LIST 7
54 #define TOKEN_OBRACE 10
55 #define TOKEN_CBRACE 11
56 #define TOKEN_OPAREN 12
57 #define TOKEN_CPAREN 13
58 #define TOKEN_OBRACKET 14
59 #define TOKEN_CBRACKET 15
60 #define TOKEN_OANGLE 16
61 #define TOKEN_CANGLE 17
63 #define TOKEN_COMMA 19
64 #define TOKEN_SEMICOLON 20
65 #define TOKEN_TEMPLATE 31
67 #define TOKEN_DWORD 41
68 #define TOKEN_FLOAT 42
69 #define TOKEN_DOUBLE 43
71 #define TOKEN_UCHAR 45
72 #define TOKEN_SWORD 46
73 #define TOKEN_SDWORD 47
75 #define TOKEN_LPSTR 49
76 #define TOKEN_UNICODE 50
77 #define TOKEN_CSTRING 51
78 #define TOKEN_ARRAY 52
84 /* Dump template content */
91 static const struct IDirectXFileVtbl IDirectXFile_Vtbl
;
92 static const struct IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl
;
93 static const struct IDirectXFileDataVtbl IDirectXFileData_Vtbl
;
94 static const struct IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl
;
95 static const struct IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl
;
96 static const struct IDirectXFileObjectVtbl IDirectXFileObject_Vtbl
;
97 static const struct IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl
;
99 HRESULT
IDirectXFileImpl_Create(IUnknown
* pUnkOuter
, LPVOID
* ppObj
)
101 IDirectXFileImpl
* object
;
103 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
105 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileImpl
));
107 object
->lpVtbl
.lpVtbl
= &IDirectXFile_Vtbl
;
115 /*** IUnknown methods ***/
116 static HRESULT WINAPI
IDirectXFileImpl_QueryInterface(IDirectXFile
* iface
, REFIID riid
, void** ppvObject
)
118 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
120 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
122 if (IsEqualGUID(riid
, &IID_IUnknown
)
123 || IsEqualGUID(riid
, &IID_IDirectXFile
))
125 IClassFactory_AddRef(iface
);
130 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
131 return E_NOINTERFACE
;
134 static ULONG WINAPI
IDirectXFileImpl_AddRef(IDirectXFile
* iface
)
136 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
137 ULONG ref
= InterlockedIncrement(&This
->ref
);
139 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
144 static ULONG WINAPI
IDirectXFileImpl_Release(IDirectXFile
* iface
)
146 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
147 ULONG ref
= InterlockedDecrement(&This
->ref
);
149 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
152 HeapFree(GetProcessHeap(), 0, This
);
157 /*** IDirectXFile methods ***/
158 static HRESULT WINAPI
IDirectXFileImpl_CreateEnumObject(IDirectXFile
* iface
, LPVOID pvSource
, DXFILELOADOPTIONS dwLoadOptions
, LPDIRECTXFILEENUMOBJECT
* ppEnumObj
)
161 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
162 IDirectXFileEnumObjectImpl
* object
;
165 FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This
, iface
, pvSource
, dwLoadOptions
, ppEnumObj
);
167 if (dwLoadOptions
== DXFILELOAD_FROMFILE
)
170 TRACE("Open source file '%s'\n", (char*)pvSource
);
171 hFile
= CreateFileA((char*)pvSource
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, NULL
);
172 if (hFile
== INVALID_HANDLE_VALUE
)
174 TRACE("File '%s' not found\n", (char*)pvSource
);
175 return DXFILEERR_FILENOTFOUND
;
181 FIXME("Source type %d is not handled yet\n", dwLoadOptions
);
184 hr
= IDirectXFileEnumObjectImpl_Create(&object
);
188 *ppEnumObj
= (LPDIRECTXFILEENUMOBJECT
)object
;
193 static HRESULT WINAPI
IDirectXFileImpl_CreateSaveObject(IDirectXFile
* iface
, LPCSTR szFileName
, DXFILEFORMAT dwFileFormat
, LPDIRECTXFILESAVEOBJECT
* ppSaveObj
)
195 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
197 FIXME("(%p/%p)->(%s,%x,%p) stub!\n", This
, iface
, szFileName
, dwFileFormat
, ppSaveObj
);
199 return DXFILEERR_BADVALUE
;
202 static BOOL
read_bytes(parse_buffer
* buf
, LPVOID data
, DWORD size
)
204 if (buf
->rem_bytes
< size
)
206 memcpy(data
, buf
->buffer
, size
);
208 buf
->rem_bytes
-= size
;
212 static void add_string(parse_buffer
* buf
, const char * str
)
214 DWORD len
= strlen(str
);
215 if ((buf
->pos
+ len
+ 1) > buf
->size
)
217 FIXME("Dump buffer to small\n");
220 sprintf(buf
->dump
+ buf
->pos
, str
);
224 static void dump_TOKEN(WORD token
)
226 #define DUMP_TOKEN(t) case t: TRACE(#t "\n"); break
229 DUMP_TOKEN(TOKEN_NAME
);
230 DUMP_TOKEN(TOKEN_STRING
);
231 DUMP_TOKEN(TOKEN_INTEGER
);
232 DUMP_TOKEN(TOKEN_GUID
);
233 DUMP_TOKEN(TOKEN_INTEGER_LIST
);
234 DUMP_TOKEN(TOKEN_FLOAT_LIST
);
235 DUMP_TOKEN(TOKEN_OBRACE
);
236 DUMP_TOKEN(TOKEN_CBRACE
);
237 DUMP_TOKEN(TOKEN_OPAREN
);
238 DUMP_TOKEN(TOKEN_CPAREN
);
239 DUMP_TOKEN(TOKEN_OBRACKET
);
240 DUMP_TOKEN(TOKEN_CBRACKET
);
241 DUMP_TOKEN(TOKEN_OANGLE
);
242 DUMP_TOKEN(TOKEN_CANGLE
);
243 DUMP_TOKEN(TOKEN_DOT
);
244 DUMP_TOKEN(TOKEN_COMMA
);
245 DUMP_TOKEN(TOKEN_SEMICOLON
);
246 DUMP_TOKEN(TOKEN_TEMPLATE
);
247 DUMP_TOKEN(TOKEN_WORD
);
248 DUMP_TOKEN(TOKEN_DWORD
);
249 DUMP_TOKEN(TOKEN_FLOAT
);
250 DUMP_TOKEN(TOKEN_DOUBLE
);
251 DUMP_TOKEN(TOKEN_CHAR
);
252 DUMP_TOKEN(TOKEN_UCHAR
);
253 DUMP_TOKEN(TOKEN_SWORD
);
254 DUMP_TOKEN(TOKEN_SDWORD
);
255 DUMP_TOKEN(TOKEN_VOID
);
256 DUMP_TOKEN(TOKEN_LPSTR
);
257 DUMP_TOKEN(TOKEN_UNICODE
);
258 DUMP_TOKEN(TOKEN_CSTRING
);
259 DUMP_TOKEN(TOKEN_ARRAY
);
262 TRACE("Unknown token %d\n", token
);
268 static WORD
check_TOKEN(parse_buffer
* buf
)
272 if (!read_bytes(buf
, &token
, 2))
284 static WORD
parse_TOKEN(parse_buffer
* buf
)
288 if (!read_bytes(buf
, &token
, 2))
297 case TOKEN_INTEGER_LIST
:
298 case TOKEN_FLOAT_LIST
:
301 add_string(buf
, "{ ");
304 add_string(buf
, "} ");
307 add_string(buf
, "( ");
310 add_string(buf
, ") ");
313 add_string(buf
, "[ ");
316 add_string(buf
, "] ");
319 add_string(buf
, "< ");
322 add_string(buf
, "> ");
325 add_string(buf
, ".");
328 add_string(buf
, ", ");
330 case TOKEN_SEMICOLON
:
331 add_string(buf
, "; ");
334 add_string(buf
, "template ");
337 add_string(buf
, "WORD ");
340 add_string(buf
, "DWORD ");
343 add_string(buf
, "FLOAT ");
346 add_string(buf
, "DOUBLE ");
349 add_string(buf
, "CHAR ");
352 add_string(buf
, "UCHAR ");
355 add_string(buf
, "SWORD ");
358 add_string(buf
, "SDWORD ");
361 add_string(buf
, "VOID ");
364 add_string(buf
, "LPSTR ");
367 add_string(buf
, "UNICODE ");
370 add_string(buf
, "CSTRING ");
373 add_string(buf
, "array ");
385 static inline BOOL
is_primitive_type(WORD token
)
410 static BOOL
parse_name(parse_buffer
* buf
)
413 static char strname
[100];
415 if (parse_TOKEN(buf
) != TOKEN_NAME
)
417 if (!read_bytes(buf
, &count
, 4))
419 if (!read_bytes(buf
, strname
, count
))
422 /*TRACE("name = %s\n", strname);*/
423 add_string(buf
, strname
);
424 add_string(buf
, " ");
429 static BOOL
parse_class_id(parse_buffer
* buf
)
434 if (parse_TOKEN(buf
) != TOKEN_GUID
)
436 if (!read_bytes(buf
, &class_id
, 16))
438 sprintf(strguid
, "<%08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X>", class_id
.Data1
, class_id
.Data2
, class_id
.Data3
, class_id
.Data4
[0],
439 class_id
.Data4
[1], class_id
.Data4
[2], class_id
.Data4
[3], class_id
.Data4
[4], class_id
.Data4
[5], class_id
.Data4
[6], class_id
.Data4
[7]);
440 /*TRACE("guid = {%s}\n", strguid);*/
441 add_string(buf
, strguid
);
446 static BOOL
parse_integer(parse_buffer
* buf
)
450 if (parse_TOKEN(buf
) != TOKEN_INTEGER
)
452 if (!read_bytes(buf
, &integer
, 4))
454 /*TRACE("integer = %ld\n", integer);*/
455 sprintf(buf
->dump
+buf
->pos
, "%d ", integer
);
456 buf
->pos
= strlen(buf
->dump
);
461 static BOOL
parse_template_option_info(parse_buffer
* buf
)
463 if (check_TOKEN(buf
) == TOKEN_DOT
)
466 if (parse_TOKEN(buf
) != TOKEN_DOT
)
468 if (parse_TOKEN(buf
) != TOKEN_DOT
)
470 sprintf(buf
->dump
+buf
->pos
, " ");
471 buf
->pos
= strlen(buf
->dump
);
477 if (!parse_name(buf
))
479 if (check_TOKEN(buf
) == TOKEN_GUID
)
480 if (!parse_class_id(buf
))
482 if (check_TOKEN(buf
) != TOKEN_COMMA
)
490 static BOOL
parse_template_members_list(parse_buffer
* buf
)
496 if (check_TOKEN(buf
) == TOKEN_NAME
)
498 if (!parse_name(buf
))
500 if (check_TOKEN(buf
) == TOKEN_NAME
)
501 if (!parse_name(buf
))
503 if (parse_TOKEN(buf
) != TOKEN_SEMICOLON
)
506 else if (check_TOKEN(buf
) == TOKEN_ARRAY
)
511 token
= check_TOKEN(buf
);
512 if (is_primitive_type(token
))
518 if (!parse_name(buf
))
521 if (!parse_name(buf
))
524 while (check_TOKEN(buf
) == TOKEN_OBRACKET
)
527 if (check_TOKEN(buf
) == TOKEN_INTEGER
)
529 if (!parse_integer(buf
))
534 if (!parse_name(buf
))
537 if (parse_TOKEN(buf
) != TOKEN_CBRACKET
)
542 if (parse_TOKEN(buf
) != TOKEN_SEMICOLON
)
545 else if (is_primitive_type(check_TOKEN(buf
)))
548 if (check_TOKEN(buf
) == TOKEN_NAME
)
549 if (!parse_name(buf
))
551 if (parse_TOKEN(buf
) != TOKEN_SEMICOLON
)
556 add_string(buf
, "\n");
562 static BOOL
parse_template_parts(parse_buffer
* buf
)
564 if (check_TOKEN(buf
) == TOKEN_OBRACKET
)
567 if (!parse_template_option_info(buf
))
569 if (parse_TOKEN(buf
) != TOKEN_CBRACKET
)
571 add_string(buf
, "\n");
575 if (!parse_template_members_list(buf
))
577 if (check_TOKEN(buf
) == TOKEN_OBRACKET
)
580 if (!parse_template_option_info(buf
))
582 if (parse_TOKEN(buf
) != TOKEN_CBRACKET
)
584 add_string(buf
, "\n");
591 static BOOL
parse_template(parse_buffer
* buf
)
593 if (parse_TOKEN(buf
) != TOKEN_TEMPLATE
)
595 if (!parse_name(buf
))
597 add_string(buf
, "\n");
598 if (parse_TOKEN(buf
) != TOKEN_OBRACE
)
600 add_string(buf
, "\n");
601 if (!parse_class_id(buf
))
603 add_string(buf
, "\n");
604 if (!parse_template_parts(buf
))
606 if (parse_TOKEN(buf
) != TOKEN_CBRACE
)
608 add_string(buf
, "\n\n");
612 static HRESULT WINAPI
IDirectXFileImpl_RegisterTemplates(IDirectXFile
* iface
, LPVOID pvData
, DWORD cbSize
)
614 IDirectXFileImpl
*This
= (IDirectXFileImpl
*)iface
;
618 buf
.buffer
= (LPBYTE
)pvData
;
619 buf
.rem_bytes
= cbSize
;
620 buf
.dump
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, 500);
623 FIXME("(%p/%p)->(%p,%d) partial stub!\n", This
, iface
, pvData
, cbSize
);
626 return DXFILEERR_BADVALUE
;
629 return DXFILEERR_BADFILETYPE
;
631 if (TRACE_ON(d3dxof
))
634 memcpy(string
, pvData
, 16);
636 TRACE("header = '%s'\n", string
);
639 read_bytes(&buf
, &token_header
, 4);
641 if (token_header
!= XOFFILE_FORMAT_MAGIC
)
642 return DXFILEERR_BADFILETYPE
;
644 read_bytes(&buf
, &token_header
, 4);
646 if (token_header
!= XOFFILE_FORMAT_VERSION
)
647 return DXFILEERR_BADFILEVERSION
;
649 read_bytes(&buf
, &token_header
, 4);
651 if ((token_header
!= XOFFILE_FORMAT_BINARY
) && (token_header
!= XOFFILE_FORMAT_TEXT
) && (token_header
!= XOFFILE_FORMAT_COMPRESSED
))
652 return DXFILEERR_BADFILETYPE
;
654 if (token_header
== XOFFILE_FORMAT_TEXT
)
656 FIXME("Text format not supported yet");
657 return DXFILEERR_BADVALUE
;
660 if (token_header
== XOFFILE_FORMAT_COMPRESSED
)
662 FIXME("Compressed formats not supported yet");
663 return DXFILEERR_BADVALUE
;
666 read_bytes(&buf
, &token_header
, 4);
668 if ((token_header
!= XOFFILE_FORMAT_FLOAT_BITS_32
) && (token_header
!= XOFFILE_FORMAT_FLOAT_BITS_64
))
669 return DXFILEERR_BADFILEFLOATSIZE
;
671 while (buf
.rem_bytes
)
674 if (!parse_template(&buf
))
676 TRACE("Template is not correct\n");
677 return DXFILEERR_BADVALUE
;
680 TRACE("Template successfully parsed:\n");
681 if (TRACE_ON(d3dxof
))
685 HeapFree(GetProcessHeap(), 0, buf
.dump
);
690 static const IDirectXFileVtbl IDirectXFile_Vtbl
=
692 IDirectXFileImpl_QueryInterface
,
693 IDirectXFileImpl_AddRef
,
694 IDirectXFileImpl_Release
,
695 IDirectXFileImpl_CreateEnumObject
,
696 IDirectXFileImpl_CreateSaveObject
,
697 IDirectXFileImpl_RegisterTemplates
700 HRESULT
IDirectXFileBinaryImpl_Create(IDirectXFileBinaryImpl
** ppObj
)
702 IDirectXFileBinaryImpl
* object
;
704 TRACE("(%p)\n", ppObj
);
706 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileBinaryImpl
));
708 object
->lpVtbl
.lpVtbl
= &IDirectXFileBinary_Vtbl
;
716 /*** IUnknown methods ***/
717 static HRESULT WINAPI
IDirectXFileBinaryImpl_QueryInterface(IDirectXFileBinary
* iface
, REFIID riid
, void** ppvObject
)
719 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
721 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
723 if (IsEqualGUID(riid
, &IID_IUnknown
)
724 || IsEqualGUID(riid
, &IID_IDirectXFileObject
)
725 || IsEqualGUID(riid
, &IID_IDirectXFileBinary
))
727 IClassFactory_AddRef(iface
);
732 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
733 return E_NOINTERFACE
;
736 static ULONG WINAPI
IDirectXFileBinaryImpl_AddRef(IDirectXFileBinary
* iface
)
738 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
739 ULONG ref
= InterlockedIncrement(&This
->ref
);
741 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
746 static ULONG WINAPI
IDirectXFileBinaryImpl_Release(IDirectXFileBinary
* iface
)
748 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
749 ULONG ref
= InterlockedDecrement(&This
->ref
);
751 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
754 HeapFree(GetProcessHeap(), 0, This
);
759 /*** IDirectXFileObject methods ***/
760 static HRESULT WINAPI
IDirectXFileBinaryImpl_GetName(IDirectXFileBinary
* iface
, LPSTR pstrNameBuf
, LPDWORD pdwBufLen
)
763 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
765 FIXME("(%p/%p)->(%p,%p) stub!\n", This
, iface
, pstrNameBuf
, pdwBufLen
);
767 return DXFILEERR_BADVALUE
;
770 static HRESULT WINAPI
IDirectXFileBinaryImpl_GetId(IDirectXFileBinary
* iface
, LPGUID pGuid
)
772 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
774 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pGuid
);
776 return DXFILEERR_BADVALUE
;
779 /*** IDirectXFileBinary methods ***/
780 static HRESULT WINAPI
IDirectXFileBinaryImpl_GetSize(IDirectXFileBinary
* iface
, DWORD
* pcbSize
)
782 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
784 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pcbSize
);
786 return DXFILEERR_BADVALUE
;
789 static HRESULT WINAPI
IDirectXFileBinaryImpl_GetMimeType(IDirectXFileBinary
* iface
, LPCSTR
* pszMimeType
)
791 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
793 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pszMimeType
);
795 return DXFILEERR_BADVALUE
;
798 static HRESULT WINAPI
IDirectXFileBinaryImpl_Read(IDirectXFileBinary
* iface
, LPVOID pvData
, DWORD cbSize
, LPDWORD pcbRead
)
800 IDirectXFileBinaryImpl
*This
= (IDirectXFileBinaryImpl
*)iface
;
802 FIXME("(%p/%p)->(%p, %d, %p) stub!\n", This
, iface
, pvData
, cbSize
, pcbRead
);
804 return DXFILEERR_BADVALUE
;
807 static const IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl
=
809 IDirectXFileBinaryImpl_QueryInterface
,
810 IDirectXFileBinaryImpl_AddRef
,
811 IDirectXFileBinaryImpl_Release
,
812 IDirectXFileBinaryImpl_GetName
,
813 IDirectXFileBinaryImpl_GetId
,
814 IDirectXFileBinaryImpl_GetSize
,
815 IDirectXFileBinaryImpl_GetMimeType
,
816 IDirectXFileBinaryImpl_Read
819 HRESULT
IDirectXFileDataImpl_Create(IDirectXFileDataImpl
** ppObj
)
821 IDirectXFileDataImpl
* object
;
823 TRACE("(%p)\n", ppObj
);
825 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileDataImpl
));
827 object
->lpVtbl
.lpVtbl
= &IDirectXFileData_Vtbl
;
835 /*** IUnknown methods ***/
836 static HRESULT WINAPI
IDirectXFileDataImpl_QueryInterface(IDirectXFileData
* iface
, REFIID riid
, void** ppvObject
)
838 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
840 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
842 if (IsEqualGUID(riid
, &IID_IUnknown
)
843 || IsEqualGUID(riid
, &IID_IDirectXFileObject
)
844 || IsEqualGUID(riid
, &IID_IDirectXFileData
))
846 IClassFactory_AddRef(iface
);
851 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
852 return E_NOINTERFACE
;
855 static ULONG WINAPI
IDirectXFileDataImpl_AddRef(IDirectXFileData
* iface
)
857 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
858 ULONG ref
= InterlockedIncrement(&This
->ref
);
860 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
865 static ULONG WINAPI
IDirectXFileDataImpl_Release(IDirectXFileData
* iface
)
867 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
868 ULONG ref
= InterlockedDecrement(&This
->ref
);
870 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
873 HeapFree(GetProcessHeap(), 0, This
);
878 /*** IDirectXFileObject methods ***/
879 static HRESULT WINAPI
IDirectXFileDataImpl_GetName(IDirectXFileData
* iface
, LPSTR pstrNameBuf
, LPDWORD pdwBufLen
)
882 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
884 FIXME("(%p/%p)->(%p,%p) stub!\n", This
, iface
, pstrNameBuf
, pdwBufLen
);
886 return DXFILEERR_BADVALUE
;
889 static HRESULT WINAPI
IDirectXFileDataImpl_GetId(IDirectXFileData
* iface
, LPGUID pGuid
)
891 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
893 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pGuid
);
895 return DXFILEERR_BADVALUE
;
898 /*** IDirectXFileData methods ***/
899 static HRESULT WINAPI
IDirectXFileDataImpl_GetData(IDirectXFileData
* iface
, LPCSTR szMember
, DWORD
* pcbSize
, void** ppvData
)
901 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
903 FIXME("(%p/%p)->(%s,%p,%p) stub!\n", This
, iface
, szMember
, pcbSize
, ppvData
);
905 return DXFILEERR_BADVALUE
;
908 static HRESULT WINAPI
IDirectXFileDataImpl_GetType(IDirectXFileData
* iface
, const GUID
** pguid
)
910 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
912 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pguid
);
914 return DXFILEERR_BADVALUE
;
917 static HRESULT WINAPI
IDirectXFileDataImpl_GetNextObject(IDirectXFileData
* iface
, LPDIRECTXFILEOBJECT
* ppChildObj
)
919 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
921 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, ppChildObj
);
923 return DXFILEERR_BADVALUE
;
926 static HRESULT WINAPI
IDirectXFileDataImpl_AddDataObject(IDirectXFileData
* iface
, LPDIRECTXFILEDATA pDataObj
)
928 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
930 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pDataObj
);
932 return DXFILEERR_BADVALUE
;
935 static HRESULT WINAPI
IDirectXFileDataImpl_AddDataReference(IDirectXFileData
* iface
, LPCSTR szRef
, const GUID
* pguidRef
)
937 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
939 FIXME("(%p/%p)->(%s,%p) stub!\n", This
, iface
, szRef
, pguidRef
);
941 return DXFILEERR_BADVALUE
;
944 static HRESULT WINAPI
IDirectXFileDataImpl_AddBinaryObject(IDirectXFileData
* iface
, LPCSTR szName
, const GUID
* pguid
, LPCSTR szMimeType
, LPVOID pvData
, DWORD cbSize
)
946 IDirectXFileDataImpl
*This
= (IDirectXFileDataImpl
*)iface
;
948 FIXME("(%p/%p)->(%s,%p,%s,%p,%d) stub!\n", This
, iface
, szName
, pguid
, szMimeType
, pvData
, cbSize
);
950 return DXFILEERR_BADVALUE
;
953 static const IDirectXFileDataVtbl IDirectXFileData_Vtbl
=
955 IDirectXFileDataImpl_QueryInterface
,
956 IDirectXFileDataImpl_AddRef
,
957 IDirectXFileDataImpl_Release
,
958 IDirectXFileDataImpl_GetName
,
959 IDirectXFileDataImpl_GetId
,
960 IDirectXFileDataImpl_GetData
,
961 IDirectXFileDataImpl_GetType
,
962 IDirectXFileDataImpl_GetNextObject
,
963 IDirectXFileDataImpl_AddDataObject
,
964 IDirectXFileDataImpl_AddDataReference
,
965 IDirectXFileDataImpl_AddBinaryObject
968 HRESULT
IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImpl
** ppObj
)
970 IDirectXFileDataReferenceImpl
* object
;
972 TRACE("(%p)\n", ppObj
);
974 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileDataReferenceImpl
));
976 object
->lpVtbl
.lpVtbl
= &IDirectXFileDataReference_Vtbl
;
984 /*** IUnknown methods ***/
985 static HRESULT WINAPI
IDirectXFileDataReferenceImpl_QueryInterface(IDirectXFileDataReference
* iface
, REFIID riid
, void** ppvObject
)
987 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
989 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
991 if (IsEqualGUID(riid
, &IID_IUnknown
)
992 || IsEqualGUID(riid
, &IID_IDirectXFileObject
)
993 || IsEqualGUID(riid
, &IID_IDirectXFileDataReference
))
995 IClassFactory_AddRef(iface
);
1000 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1001 return E_NOINTERFACE
;
1004 static ULONG WINAPI
IDirectXFileDataReferenceImpl_AddRef(IDirectXFileDataReference
* iface
)
1006 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1007 ULONG ref
= InterlockedIncrement(&This
->ref
);
1009 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
1014 static ULONG WINAPI
IDirectXFileDataReferenceImpl_Release(IDirectXFileDataReference
* iface
)
1016 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1017 ULONG ref
= InterlockedDecrement(&This
->ref
);
1019 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
1022 HeapFree(GetProcessHeap(), 0, This
);
1027 /*** IDirectXFileObject methods ***/
1028 static HRESULT WINAPI
IDirectXFileDataReferenceImpl_GetName(IDirectXFileDataReference
* iface
, LPSTR pstrNameBuf
, LPDWORD pdwBufLen
)
1030 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1032 FIXME("(%p/%p)->(%p,%p) stub!\n", This
, iface
, pstrNameBuf
, pdwBufLen
);
1034 return DXFILEERR_BADVALUE
;
1037 static HRESULT WINAPI
IDirectXFileDataReferenceImpl_GetId(IDirectXFileDataReference
* iface
, LPGUID pGuid
)
1039 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1041 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pGuid
);
1043 return DXFILEERR_BADVALUE
;
1046 /*** IDirectXFileDataReference ***/
1047 static HRESULT WINAPI
IDirectXFileDataReferenceImpl_Resolve(IDirectXFileDataReference
* iface
, LPDIRECTXFILEDATA
* ppDataObj
)
1049 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1051 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, ppDataObj
);
1053 return DXFILEERR_BADVALUE
;
1056 static const IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl
=
1058 IDirectXFileDataReferenceImpl_QueryInterface
,
1059 IDirectXFileDataReferenceImpl_AddRef
,
1060 IDirectXFileDataReferenceImpl_Release
,
1061 IDirectXFileDataReferenceImpl_GetName
,
1062 IDirectXFileDataReferenceImpl_GetId
,
1063 IDirectXFileDataReferenceImpl_Resolve
1066 HRESULT
IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl
** ppObj
)
1068 IDirectXFileEnumObjectImpl
* object
;
1070 TRACE("(%p)\n", ppObj
);
1072 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileEnumObjectImpl
));
1074 object
->lpVtbl
.lpVtbl
= &IDirectXFileEnumObject_Vtbl
;
1082 /*** IUnknown methods ***/
1083 static HRESULT WINAPI
IDirectXFileEnumObjectImpl_QueryInterface(IDirectXFileEnumObject
* iface
, REFIID riid
, void** ppvObject
)
1085 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1087 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
1089 if (IsEqualGUID(riid
, &IID_IUnknown
)
1090 || IsEqualGUID(riid
, &IID_IDirectXFileEnumObject
))
1092 IClassFactory_AddRef(iface
);
1097 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1098 return E_NOINTERFACE
;
1101 static ULONG WINAPI
IDirectXFileEnumObjectImpl_AddRef(IDirectXFileEnumObject
* iface
)
1103 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1104 ULONG ref
= InterlockedIncrement(&This
->ref
);
1106 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
1111 static ULONG WINAPI
IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject
* iface
)
1113 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1114 ULONG ref
= InterlockedDecrement(&This
->ref
);
1116 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
1119 HeapFree(GetProcessHeap(), 0, This
);
1124 /*** IDirectXFileEnumObject methods ***/
1125 static HRESULT WINAPI
IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileEnumObject
* iface
, LPDIRECTXFILEDATA
* ppDataObj
)
1127 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1128 IDirectXFileDataImpl
* object
;
1130 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, ppDataObj
);
1132 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileDataImpl
));
1134 object
->lpVtbl
.lpVtbl
= &IDirectXFileData_Vtbl
;
1137 *ppDataObj
= (LPDIRECTXFILEDATA
)object
;
1139 return DXFILEERR_BADVALUE
;
1142 static HRESULT WINAPI
IDirectXFileEnumObjectImpl_GetDataObjectById(IDirectXFileEnumObject
* iface
, REFGUID rguid
, LPDIRECTXFILEDATA
* ppDataObj
)
1144 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1146 FIXME("(%p/%p)->(%p,%p) stub!\n", This
, iface
, rguid
, ppDataObj
);
1148 return DXFILEERR_BADVALUE
;
1151 static HRESULT WINAPI
IDirectXFileEnumObjectImpl_GetDataObjectByName(IDirectXFileEnumObject
* iface
, LPCSTR szName
, LPDIRECTXFILEDATA
* ppDataObj
)
1153 IDirectXFileEnumObjectImpl
*This
= (IDirectXFileEnumObjectImpl
*)iface
;
1155 FIXME("(%p/%p)->(%s,%p) stub!\n", This
, iface
, szName
, ppDataObj
);
1157 return DXFILEERR_BADVALUE
;
1160 static const IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl
=
1162 IDirectXFileEnumObjectImpl_QueryInterface
,
1163 IDirectXFileEnumObjectImpl_AddRef
,
1164 IDirectXFileEnumObjectImpl_Release
,
1165 IDirectXFileEnumObjectImpl_GetNextDataObject
,
1166 IDirectXFileEnumObjectImpl_GetDataObjectById
,
1167 IDirectXFileEnumObjectImpl_GetDataObjectByName
1170 HRESULT
IDirectXFileObjectImpl_Create(IDirectXFileObjectImpl
** ppObj
)
1172 IDirectXFileObjectImpl
* object
;
1174 TRACE("(%p)\n", ppObj
);
1176 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileObjectImpl
));
1178 object
->lpVtbl
.lpVtbl
= &IDirectXFileObject_Vtbl
;
1186 /*** IUnknown methods ***/
1187 static HRESULT WINAPI
IDirectXFileObjectImpl_QueryInterface(IDirectXFileObject
* iface
, REFIID riid
, void** ppvObject
)
1189 IDirectXFileObjectImpl
*This
= (IDirectXFileObjectImpl
*)iface
;
1191 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
1193 if (IsEqualGUID(riid
, &IID_IUnknown
)
1194 || IsEqualGUID(riid
, &IID_IDirectXFileObject
))
1196 IClassFactory_AddRef(iface
);
1201 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1202 return E_NOINTERFACE
;
1205 static ULONG WINAPI
IDirectXFileObjectImpl_AddRef(IDirectXFileObject
* iface
)
1207 IDirectXFileObjectImpl
*This
= (IDirectXFileObjectImpl
*)iface
;
1208 ULONG ref
= InterlockedIncrement(&This
->ref
);
1210 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
1215 static ULONG WINAPI
IDirectXFileObjectImpl_Release(IDirectXFileObject
* iface
)
1217 IDirectXFileObjectImpl
*This
= (IDirectXFileObjectImpl
*)iface
;
1218 ULONG ref
= InterlockedDecrement(&This
->ref
);
1220 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
1223 HeapFree(GetProcessHeap(), 0, This
);
1228 /*** IDirectXFileObject methods ***/
1229 static HRESULT WINAPI
IDirectXFileObjectImpl_GetName(IDirectXFileObject
* iface
, LPSTR pstrNameBuf
, LPDWORD pdwBufLen
)
1231 IDirectXFileDataReferenceImpl
*This
= (IDirectXFileDataReferenceImpl
*)iface
;
1233 FIXME("(%p/%p)->(%p,%p) stub!\n", This
, iface
, pstrNameBuf
, pdwBufLen
);
1235 return DXFILEERR_BADVALUE
;
1238 static HRESULT WINAPI
IDirectXFileObjectImpl_GetId(IDirectXFileObject
* iface
, LPGUID pGuid
)
1240 IDirectXFileObjectImpl
*This
= (IDirectXFileObjectImpl
*)iface
;
1242 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, pGuid
);
1244 return DXFILEERR_BADVALUE
;
1247 static const IDirectXFileObjectVtbl IDirectXFileObject_Vtbl
=
1249 IDirectXFileObjectImpl_QueryInterface
,
1250 IDirectXFileObjectImpl_AddRef
,
1251 IDirectXFileObjectImpl_Release
,
1252 IDirectXFileObjectImpl_GetName
,
1253 IDirectXFileObjectImpl_GetId
1256 HRESULT
IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl
** ppObj
)
1258 IDirectXFileSaveObjectImpl
* object
;
1260 TRACE("(%p)\n", ppObj
);
1262 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectXFileSaveObjectImpl
));
1264 object
->lpVtbl
.lpVtbl
= &IDirectXFileSaveObject_Vtbl
;
1272 /*** IUnknown methods ***/
1273 static HRESULT WINAPI
IDirectXFileSaveObjectImpl_QueryInterface(IDirectXFileSaveObject
* iface
, REFIID riid
, void** ppvObject
)
1275 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
1277 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
1279 if (IsEqualGUID(riid
, &IID_IUnknown
)
1280 || IsEqualGUID(riid
, &IID_IDirectXFileSaveObject
))
1282 IClassFactory_AddRef(iface
);
1287 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1288 return E_NOINTERFACE
;
1291 static ULONG WINAPI
IDirectXFileSaveObjectImpl_AddRef(IDirectXFileSaveObject
* iface
)
1293 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
1294 ULONG ref
= InterlockedIncrement(&This
->ref
);
1296 TRACE("(%p/%p): AddRef from %d\n", iface
, This
, ref
- 1);
1301 static ULONG WINAPI
IDirectXFileSaveObjectImpl_Release(IDirectXFileSaveObject
* iface
)
1303 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
1304 ULONG ref
= InterlockedDecrement(&This
->ref
);
1306 TRACE("(%p/%p): ReleaseRef to %d\n", iface
, This
, ref
);
1309 HeapFree(GetProcessHeap(), 0, This
);
1314 static HRESULT WINAPI
IDirectXFileSaveObjectImpl_SaveTemplates(IDirectXFileSaveObject
* iface
, DWORD cTemplates
, const GUID
** ppguidTemplates
)
1316 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
1318 FIXME("(%p/%p)->(%d,%p) stub!\n", This
, iface
, cTemplates
, ppguidTemplates
);
1320 return DXFILEERR_BADVALUE
;
1323 static HRESULT WINAPI
IDirectXFileSaveObjectImpl_CreateDataObject(IDirectXFileSaveObject
* iface
, REFGUID rguidTemplate
, LPCSTR szName
, const GUID
* pguid
, DWORD cbSize
, LPVOID pvData
, LPDIRECTXFILEDATA
* ppDataObj
)
1325 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
1327 FIXME("(%p/%p)->(%p,%s,%p,%d,%p,%p) stub!\n", This
, iface
, rguidTemplate
, szName
, pguid
, cbSize
, pvData
, ppDataObj
);
1329 return DXFILEERR_BADVALUE
;
1332 static HRESULT WINAPI
IDirectXFileSaveObjectImpl_SaveData(IDirectXFileSaveObject
* iface
, LPDIRECTXFILEDATA ppDataObj
)
1334 IDirectXFileSaveObjectImpl
*This
= (IDirectXFileSaveObjectImpl
*)iface
;
1336 FIXME("(%p/%p)->(%p) stub!\n", This
, iface
, ppDataObj
);
1338 return DXFILEERR_BADVALUE
;
1341 static const IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl
=
1343 IDirectXFileSaveObjectImpl_QueryInterface
,
1344 IDirectXFileSaveObjectImpl_AddRef
,
1345 IDirectXFileSaveObjectImpl_Release
,
1346 IDirectXFileSaveObjectImpl_SaveTemplates
,
1347 IDirectXFileSaveObjectImpl_CreateDataObject
,
1348 IDirectXFileSaveObjectImpl_SaveData