Sweden-Number/dlls/d3dxof/d3dxof.c

1204 lines
34 KiB
C
Raw Normal View History

2004-06-03 02:03:23 +02:00
/*
* Implementation of DirectX File Interfaces
*
* Copyright 2004, 2008, 2010 Christian Costa
2004-06-03 02:03:23 +02:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
2004-06-03 02:03:23 +02:00
*/
#include "config.h"
#include "wine/debug.h"
#define COBJMACROS
2004-06-03 02:03:23 +02:00
#include "winbase.h"
#include "wingdi.h"
#include "d3dxof_private.h"
#include "dxfile.h"
#include <stdio.h>
2004-06-03 02:03:23 +02:00
WINE_DEFAULT_DEBUG_CHANNEL(d3dxof);
WINE_DECLARE_DEBUG_CHANNEL(d3dxof_dump);
2004-06-03 02:03:23 +02:00
static const struct IDirectXFileVtbl IDirectXFile_Vtbl;
static const struct IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl;
static const struct IDirectXFileDataVtbl IDirectXFileData_Vtbl;
static const struct IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl;
static const struct IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl;
static const struct IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl;
2004-06-03 02:03:23 +02:00
2008-12-04 12:47:20 +01:00
static HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImpl** ppObj);
static HRESULT IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl** ppObj);
static HRESULT IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj);
#define TOKEN_DWORD 41
#define TOKEN_FLOAT 42
HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj)
2004-06-03 02:03:23 +02:00
{
IDirectXFileImpl* object;
2004-06-03 02:03:23 +02:00
TRACE("(%p,%p)\n", pUnkOuter, ppObj);
2004-06-03 02:03:23 +02:00
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileImpl));
2008-12-14 18:55:10 +01:00
if (!object)
return DXFILEERR_BADALLOC;
2011-05-27 03:21:01 +02:00
object->IDirectXFile_iface.lpVtbl = &IDirectXFile_Vtbl;
2004-06-03 02:03:23 +02:00
object->ref = 1;
/* Reserve first template to handle the case sensitive legacy type indexColor */
object->nb_xtemplates = 1;
strcpy(object->xtemplates[0].name, "indexColor");
object->xtemplates[0].nb_members = 2;
object->xtemplates[0].members[0].type = TOKEN_DWORD;
object->xtemplates[0].members[0].nb_dims = 0;
object->xtemplates[0].members[1].type = TOKEN_FLOAT;
object->xtemplates[0].members[1].nb_dims = 1;
object->xtemplates[0].members[1].dim_fixed[0] = TRUE;
object->xtemplates[0].members[1].dim_value[0] = 4;
2011-05-27 03:21:01 +02:00
*ppObj = &object->IDirectXFile_iface;
2004-06-03 02:03:23 +02:00
return S_OK;
}
2011-05-27 03:21:01 +02:00
static inline IDirectXFileImpl *impl_from_IDirectXFile(IDirectXFile *iface)
{
return CONTAINING_RECORD(iface, IDirectXFileImpl, IDirectXFile_iface);
}
2004-06-03 02:03:23 +02:00
/*** IUnknown methods ***/
static HRESULT WINAPI IDirectXFileImpl_QueryInterface(IDirectXFile* iface, REFIID riid, void** ppvObject)
{
2011-05-27 03:21:01 +02:00
IDirectXFileImpl *This = impl_from_IDirectXFile(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
2004-06-03 02:03:23 +02:00
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirectXFile))
{
2010-03-01 09:36:37 +01:00
IUnknown_AddRef(iface);
2011-05-27 03:21:01 +02:00
*ppvObject = &This->IDirectXFile_iface;
2004-06-03 02:03:23 +02:00
return S_OK;
}
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
return E_NOINTERFACE;
}
static ULONG WINAPI IDirectXFileImpl_AddRef(IDirectXFile* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileImpl *This = impl_from_IDirectXFile(iface);
ULONG ref = InterlockedIncrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
return ref;
2004-06-03 02:03:23 +02:00
}
static ULONG WINAPI IDirectXFileImpl_Release(IDirectXFile* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileImpl *This = impl_from_IDirectXFile(iface);
ULONG ref = InterlockedDecrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
if (!ref)
2004-06-03 02:03:23 +02:00
HeapFree(GetProcessHeap(), 0, This);
return ref;
2004-06-03 02:03:23 +02:00
}
/*** IDirectXFile methods ***/
static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPVOID pvSource, DXFILELOADOPTIONS dwLoadOptions, LPDIRECTXFILEENUMOBJECT* ppEnumObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileImpl *This = impl_from_IDirectXFile(iface);
IDirectXFileEnumObjectImpl* object;
HRESULT hr;
LPBYTE file_buffer;
DWORD file_size;
DWORD bytes_written;
TRACE("(%p/%p)->(%p,%x,%p)\n", This, iface, pvSource, dwLoadOptions, ppEnumObj);
if (!ppEnumObj)
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
/* Only lowest 4 bits are relevant in DXFILELOADOPTIONS */
dwLoadOptions &= 0xF;
hr = IDirectXFileEnumObjectImpl_Create(&object);
if (FAILED(hr))
return hr;
if (dwLoadOptions == DXFILELOAD_FROMFILE)
2004-06-03 02:03:23 +02:00
{
HANDLE hFile, file_mapping;
TRACE("Open source file '%s'\n", (char*)pvSource);
hFile = CreateFileA(pvSource, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
TRACE("File '%s' not found\n", (char*)pvSource);
return DXFILEERR_FILENOTFOUND;
}
file_size = GetFileSize(hFile, NULL);
file_mapping = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
CloseHandle(hFile);
if (!file_mapping)
{
hr = DXFILEERR_BADFILETYPE;
goto error;
}
object->mapped_memory = MapViewOfFile(file_mapping, FILE_MAP_READ, 0, 0, 0);
CloseHandle(file_mapping);
if (!object->mapped_memory)
{
hr = DXFILEERR_BADFILETYPE;
goto error;
}
file_buffer = object->mapped_memory;
}
else if (dwLoadOptions == DXFILELOAD_FROMRESOURCE)
{
HRSRC resource_info;
HGLOBAL resource_data;
LPDXFILELOADRESOURCE lpdxflr = pvSource;
2014-01-22 12:25:54 +01:00
TRACE("Source in resource (module = %p, name = %s, type = %s)\n", lpdxflr->hModule, debugstr_a(lpdxflr->lpName), debugstr_a(lpdxflr->lpType));
resource_info = FindResourceA(lpdxflr->hModule, lpdxflr->lpName, lpdxflr->lpType);
if (!resource_info)
{
hr = DXFILEERR_RESOURCENOTFOUND;
goto error;
}
file_size = SizeofResource(lpdxflr->hModule, resource_info);
resource_data = LoadResource(lpdxflr->hModule, resource_info);
if (!resource_data)
{
hr = DXFILEERR_BADRESOURCE;
goto error;
}
file_buffer = LockResource(resource_data);
if (!file_buffer)
{
hr = DXFILEERR_BADRESOURCE;
goto error;
}
}
else if (dwLoadOptions == DXFILELOAD_FROMMEMORY)
{
LPDXFILELOADMEMORY lpdxflm = pvSource;
2008-11-16 19:42:38 +01:00
TRACE("Source in memory at %p with size %d\n", lpdxflm->lpMemory, lpdxflm->dSize);
file_buffer = lpdxflm->lpMemory;
file_size = lpdxflm->dSize;
}
else
{
FIXME("Source type %d is not handled yet\n", dwLoadOptions);
hr = DXFILEERR_NOTDONEYET;
goto error;
}
TRACE("File size is %d bytes\n", file_size);
if (TRACE_ON(d3dxof_dump))
{
static USHORT num;
char tmp[12];
HANDLE file;
sprintf(tmp, "file%05u.x", num++);
file = CreateFileA(tmp, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL);
if (file != INVALID_HANDLE_VALUE)
{
WriteFile(file, file_buffer, file_size, &bytes_written, NULL);
CloseHandle(file);
}
}
object->pDirectXFile = This;
object->buf.pdxf = This;
object->buf.token_present = FALSE;
object->buf.buffer = file_buffer;
object->buf.rem_bytes = file_size;
hr = parse_header(&object->buf, &object->decomp_buffer);
if (FAILED(hr))
goto error;
/* Check if there are templates defined before the object */
if (!parse_templates(&object->buf, TRUE))
{
hr = DXFILEERR_PARSEERROR;
goto error;
}
if (TRACE_ON(d3dxof))
{
ULONG i;
TRACE("Registered templates (%d):\n", This->nb_xtemplates);
for (i = 1; i < This->nb_xtemplates; i++)
TRACE("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id));
}
*ppEnumObj = &object->IDirectXFileEnumObject_iface;
2007-11-08 05:55:01 +01:00
return DXFILE_OK;
error:
IDirectXFileEnumObject_Release(&object->IDirectXFileEnumObject_iface);
*ppEnumObj = NULL;
return hr;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileImpl_CreateSaveObject(IDirectXFile* iface, LPCSTR szFileName, DXFILEFORMAT dwFileFormat, LPDIRECTXFILESAVEOBJECT* ppSaveObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileImpl *This = impl_from_IDirectXFile(iface);
IDirectXFileSaveObjectImpl *object;
HRESULT hr;
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%s,%x,%p) partial stub!\n", This, iface, szFileName, dwFileFormat, ppSaveObj);
2004-06-03 02:03:23 +02:00
if (!szFileName || !ppSaveObj)
return E_POINTER;
2011-05-27 03:21:01 +02:00
hr = IDirectXFileSaveObjectImpl_Create(&object);
if (SUCCEEDED(hr))
*ppSaveObj = &object->IDirectXFileSaveObject_iface;
return hr;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LPVOID pvData, DWORD cbSize)
{
2011-05-27 03:21:01 +02:00
IDirectXFileImpl *This = impl_from_IDirectXFile(iface);
parse_buffer buf;
HRESULT hr;
LPBYTE decomp_buffer = NULL;
DWORD bytes_written;
2004-06-03 02:03:23 +02:00
ZeroMemory(&buf, sizeof(buf));
buf.buffer = pvData;
buf.rem_bytes = cbSize;
buf.pdxf = This;
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%p,%d)\n", This, iface, pvData, cbSize);
if (!pvData)
return DXFILEERR_BADVALUE;
if (TRACE_ON(d3dxof_dump))
{
static USHORT num;
char tmp[16];
HANDLE file;
sprintf(tmp, "template%05u.x", num++);
file = CreateFileA(tmp, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL);
if (file != INVALID_HANDLE_VALUE)
{
WriteFile(file, pvData, cbSize, &bytes_written, NULL);
CloseHandle(file);
}
}
hr = parse_header(&buf, &decomp_buffer);
if (FAILED(hr))
goto cleanup;
if (!parse_templates(&buf, FALSE))
{
hr = DXFILEERR_PARSEERROR;
goto cleanup;
}
if (TRACE_ON(d3dxof))
{
ULONG i;
TRACE("Registered templates (%d):\n", This->nb_xtemplates);
for (i = 1; i < This->nb_xtemplates; i++)
TRACE("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id));
}
hr = DXFILE_OK;
cleanup:
HeapFree(GetProcessHeap(), 0, decomp_buffer);
return hr;
2004-06-03 02:03:23 +02:00
}
static const IDirectXFileVtbl IDirectXFile_Vtbl =
2004-06-03 02:03:23 +02:00
{
IDirectXFileImpl_QueryInterface,
IDirectXFileImpl_AddRef,
IDirectXFileImpl_Release,
IDirectXFileImpl_CreateEnumObject,
IDirectXFileImpl_CreateSaveObject,
IDirectXFileImpl_RegisterTemplates
};
static HRESULT IDirectXFileBinaryImpl_Create(IDirectXFileBinaryImpl** ppObj)
{
IDirectXFileBinaryImpl* object;
TRACE("(%p)\n", ppObj);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileBinaryImpl));
if (!object)
return DXFILEERR_BADALLOC;
2011-05-27 03:21:01 +02:00
object->IDirectXFileBinary_iface.lpVtbl = &IDirectXFileBinary_Vtbl;
object->ref = 1;
*ppObj = object;
return DXFILE_OK;
}
2011-05-27 03:21:01 +02:00
static inline IDirectXFileBinaryImpl *impl_from_IDirectXFileBinary(IDirectXFileBinary *iface)
{
return CONTAINING_RECORD(iface, IDirectXFileBinaryImpl, IDirectXFileBinary_iface);
}
2004-06-03 02:03:23 +02:00
/*** IUnknown methods ***/
static HRESULT WINAPI IDirectXFileBinaryImpl_QueryInterface(IDirectXFileBinary* iface, REFIID riid, void** ppvObject)
{
2011-05-27 03:21:01 +02:00
IDirectXFileBinaryImpl *This = impl_from_IDirectXFileBinary(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
2004-06-03 02:03:23 +02:00
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirectXFileObject)
2004-06-03 02:03:23 +02:00
|| IsEqualGUID(riid, &IID_IDirectXFileBinary))
{
2010-03-01 09:36:37 +01:00
IUnknown_AddRef(iface);
2011-05-27 03:21:01 +02:00
*ppvObject = &This->IDirectXFileBinary_iface;
2004-06-03 02:03:23 +02:00
return S_OK;
}
/* Do not print an error for interfaces that can be queried to retrieve the type of the object */
if (!IsEqualGUID(riid, &IID_IDirectXFileData)
&& !IsEqualGUID(riid, &IID_IDirectXFileDataReference))
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
2004-06-03 02:03:23 +02:00
return E_NOINTERFACE;
}
static ULONG WINAPI IDirectXFileBinaryImpl_AddRef(IDirectXFileBinary* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileBinaryImpl *This = impl_from_IDirectXFileBinary(iface);
ULONG ref = InterlockedIncrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
return ref;
2004-06-03 02:03:23 +02:00
}
static ULONG WINAPI IDirectXFileBinaryImpl_Release(IDirectXFileBinary* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileBinaryImpl *This = impl_from_IDirectXFileBinary(iface);
ULONG ref = InterlockedDecrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
if (!ref)
2004-06-03 02:03:23 +02:00
HeapFree(GetProcessHeap(), 0, This);
return ref;
2004-06-03 02:03:23 +02:00
}
/*** IDirectXFileObject methods ***/
static HRESULT WINAPI IDirectXFileBinaryImpl_GetName(IDirectXFileBinary* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen)
{
2011-05-27 03:21:01 +02:00
IDirectXFileBinaryImpl *This = impl_from_IDirectXFileBinary(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p,%p) stub!\n", This, iface, pstrNameBuf, pdwBufLen);
2004-06-03 02:03:23 +02:00
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileBinaryImpl_GetId(IDirectXFileBinary* iface, LPGUID pGuid)
{
2011-05-27 03:21:01 +02:00
IDirectXFileBinaryImpl *This = impl_from_IDirectXFileBinary(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p) stub!\n", This, iface, pGuid);
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
/*** IDirectXFileBinary methods ***/
static HRESULT WINAPI IDirectXFileBinaryImpl_GetSize(IDirectXFileBinary* iface, DWORD* pcbSize)
{
2011-05-27 03:21:01 +02:00
IDirectXFileBinaryImpl *This = impl_from_IDirectXFileBinary(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p) stub!\n", This, iface, pcbSize);
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileBinaryImpl_GetMimeType(IDirectXFileBinary* iface, LPCSTR* pszMimeType)
{
2011-05-27 03:21:01 +02:00
IDirectXFileBinaryImpl *This = impl_from_IDirectXFileBinary(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p) stub!\n", This, iface, pszMimeType);
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileBinaryImpl_Read(IDirectXFileBinary* iface, LPVOID pvData, DWORD cbSize, LPDWORD pcbRead)
{
2011-05-27 03:21:01 +02:00
IDirectXFileBinaryImpl *This = impl_from_IDirectXFileBinary(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p, %d, %p) stub!\n", This, iface, pvData, cbSize, pcbRead);
2004-06-03 02:03:23 +02:00
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static const IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl =
2004-06-03 02:03:23 +02:00
{
IDirectXFileBinaryImpl_QueryInterface,
IDirectXFileBinaryImpl_AddRef,
IDirectXFileBinaryImpl_Release,
IDirectXFileBinaryImpl_GetName,
IDirectXFileBinaryImpl_GetId,
IDirectXFileBinaryImpl_GetSize,
IDirectXFileBinaryImpl_GetMimeType,
IDirectXFileBinaryImpl_Read
};
2008-12-04 12:47:20 +01:00
static HRESULT IDirectXFileDataImpl_Create(IDirectXFileDataImpl** ppObj)
{
IDirectXFileDataImpl* object;
TRACE("(%p)\n", ppObj);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileDataImpl));
2008-12-14 18:55:10 +01:00
if (!object)
return DXFILEERR_BADALLOC;
2011-05-27 03:21:01 +02:00
object->IDirectXFileData_iface.lpVtbl = &IDirectXFileData_Vtbl;
object->ref = 1;
*ppObj = object;
return S_OK;
}
2011-05-27 03:21:01 +02:00
static inline IDirectXFileDataImpl *impl_from_IDirectXFileData(IDirectXFileData *iface)
{
return CONTAINING_RECORD(iface, IDirectXFileDataImpl, IDirectXFileData_iface);
}
2004-06-03 02:03:23 +02:00
/*** IUnknown methods ***/
static HRESULT WINAPI IDirectXFileDataImpl_QueryInterface(IDirectXFileData* iface, REFIID riid, void** ppvObject)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
2004-06-03 02:03:23 +02:00
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirectXFileObject)
2004-06-03 02:03:23 +02:00
|| IsEqualGUID(riid, &IID_IDirectXFileData))
{
2010-03-01 09:36:37 +01:00
IUnknown_AddRef(iface);
2011-05-27 03:21:01 +02:00
*ppvObject = &This->IDirectXFileData_iface;
2004-06-03 02:03:23 +02:00
return S_OK;
}
2008-10-10 13:44:43 +02:00
/* Do not print an error for interfaces that can be queried to retrieve the type of the object */
if (!IsEqualGUID(riid, &IID_IDirectXFileBinary)
&& !IsEqualGUID(riid, &IID_IDirectXFileDataReference))
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
2004-06-03 02:03:23 +02:00
return E_NOINTERFACE;
}
static ULONG WINAPI IDirectXFileDataImpl_AddRef(IDirectXFileData* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
ULONG ref = InterlockedIncrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
return ref;
2004-06-03 02:03:23 +02:00
}
static ULONG WINAPI IDirectXFileDataImpl_Release(IDirectXFileData* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
ULONG ref = InterlockedDecrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
if (!ref)
{
if (!This->level && !This->from_ref)
{
HeapFree(GetProcessHeap(), 0, This->pstrings);
if (This->pobj)
{
HeapFree(GetProcessHeap(), 0, This->pobj->pdata);
HeapFree(GetProcessHeap(), 0, This->pobj);
}
}
2004-06-03 02:03:23 +02:00
HeapFree(GetProcessHeap(), 0, This);
}
2004-06-03 02:03:23 +02:00
return ref;
2004-06-03 02:03:23 +02:00
}
/*** IDirectXFileObject methods ***/
static HRESULT WINAPI IDirectXFileDataImpl_GetName(IDirectXFileData* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
DWORD len;
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen);
2004-06-03 02:03:23 +02:00
if (!pdwBufLen)
return DXFILEERR_BADVALUE;
len = strlen(This->pobj->name);
if (len)
len++;
if (pstrNameBuf) {
if (*pdwBufLen < len)
return DXFILEERR_BADVALUE;
CopyMemory(pstrNameBuf, This->pobj->name, len);
/* Even if we return a size of 0, an empty string with a null byte must be returned */
if (*pdwBufLen && !len)
pstrNameBuf[0] = 0;
}
*pdwBufLen = len;
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileDataImpl_GetId(IDirectXFileData* iface, LPGUID pGuid)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%p)\n", This, iface, pGuid);
2004-06-03 02:03:23 +02:00
if (!pGuid)
return DXFILEERR_BADVALUE;
*pGuid = This->pobj->class_id;
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
/*** IDirectXFileData methods ***/
static HRESULT WINAPI IDirectXFileDataImpl_GetData(IDirectXFileData* iface, LPCSTR szMember, DWORD* pcbSize, void** ppvData)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
2004-06-03 02:03:23 +02:00
2011-09-18 19:50:11 +02:00
TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_a(szMember), pcbSize, ppvData);
2004-06-03 02:03:23 +02:00
if (!pcbSize || !ppvData)
return DXFILEERR_BADVALUE;
if (szMember)
{
ULONG i;
for (i = 0; i < This->pobj->nb_members; i++)
if (!strcmp(This->pobj->members[i].name, szMember))
break;
if (i == This->pobj->nb_members)
{
WARN("Unknown member '%s'\n", szMember);
return DXFILEERR_BADDATAREFERENCE;
}
*pcbSize = This->pobj->members[i].size;
*ppvData = This->pobj->root->pdata + This->pobj->members[i].start;
}
else
{
*pcbSize = This->pobj->size;
*ppvData = This->pobj->root->pdata + This->pobj->pos_data;
}
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileDataImpl_GetType(IDirectXFileData* iface, const GUID** pguid)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
static GUID guid;
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%p)\n", This, iface, pguid);
2004-06-03 02:03:23 +02:00
if (!pguid)
return DXFILEERR_BADVALUE;
guid = This->pobj->type;
*pguid = &guid;
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileDataImpl_GetNextObject(IDirectXFileData* iface, LPDIRECTXFILEOBJECT* ppChildObj)
{
HRESULT hr;
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%p)\n", This, iface, ppChildObj);
2004-06-03 02:03:23 +02:00
if (This->cur_enum_object >= This->pobj->nb_children)
{
*ppChildObj = NULL;
return DXFILEERR_NOMOREOBJECTS;
}
if (This->from_ref && (This->level >= 1))
{
2010-02-07 21:15:43 +01:00
/* Only 2 levels can be enumerated if the object is obtained from a reference */
*ppChildObj = NULL;
return DXFILEERR_NOMOREOBJECTS;
}
if (This->pobj->children[This->cur_enum_object]->binary)
{
IDirectXFileBinaryImpl *object;
hr = IDirectXFileBinaryImpl_Create(&object);
if (FAILED(hr))
return hr;
2011-05-27 03:21:01 +02:00
*ppChildObj = (LPDIRECTXFILEOBJECT)&object->IDirectXFileBinary_iface;
}
else if (This->pobj->children[This->cur_enum_object]->ptarget)
{
IDirectXFileDataReferenceImpl *object;
hr = IDirectXFileDataReferenceImpl_Create(&object);
2008-12-14 18:55:10 +01:00
if (FAILED(hr))
return hr;
object->ptarget = This->pobj->children[This->cur_enum_object++]->ptarget;
2011-05-27 03:21:01 +02:00
*ppChildObj = (LPDIRECTXFILEOBJECT)&object->IDirectXFileDataReference_iface;
}
else
{
IDirectXFileDataImpl *object;
hr = IDirectXFileDataImpl_Create(&object);
2008-12-14 18:55:10 +01:00
if (FAILED(hr))
return hr;
object->pobj = This->pobj->children[This->cur_enum_object++];
object->cur_enum_object = 0;
object->from_ref = This->from_ref;
object->level = This->level + 1;
2011-05-27 03:21:01 +02:00
*ppChildObj = (LPDIRECTXFILEOBJECT)&object->IDirectXFileData_iface;
}
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileDataImpl_AddDataObject(IDirectXFileData* iface, LPDIRECTXFILEDATA pDataObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p) stub!\n", This, iface, pDataObj);
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileDataImpl_AddDataReference(IDirectXFileData* iface, LPCSTR szRef, const GUID* pguidRef)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%s,%p) stub!\n", This, iface, szRef, pguidRef);
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileDataImpl_AddBinaryObject(IDirectXFileData* iface, LPCSTR szName, const GUID* pguid, LPCSTR szMimeType, LPVOID pvData, DWORD cbSize)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataImpl *This = impl_from_IDirectXFileData(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%s,%p,%s,%p,%d) stub!\n", This, iface, szName, pguid, szMimeType, pvData, cbSize);
2004-06-03 02:03:23 +02:00
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static const IDirectXFileDataVtbl IDirectXFileData_Vtbl =
2004-06-03 02:03:23 +02:00
{
IDirectXFileDataImpl_QueryInterface,
IDirectXFileDataImpl_AddRef,
IDirectXFileDataImpl_Release,
IDirectXFileDataImpl_GetName,
IDirectXFileDataImpl_GetId,
IDirectXFileDataImpl_GetData,
IDirectXFileDataImpl_GetType,
IDirectXFileDataImpl_GetNextObject,
IDirectXFileDataImpl_AddDataObject,
IDirectXFileDataImpl_AddDataReference,
IDirectXFileDataImpl_AddBinaryObject
};
2008-12-04 12:47:20 +01:00
static HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImpl** ppObj)
{
IDirectXFileDataReferenceImpl* object;
TRACE("(%p)\n", ppObj);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileDataReferenceImpl));
2008-12-14 18:55:10 +01:00
if (!object)
return DXFILEERR_BADALLOC;
2011-05-27 03:21:01 +02:00
object->IDirectXFileDataReference_iface.lpVtbl = &IDirectXFileDataReference_Vtbl;
object->ref = 1;
*ppObj = object;
return S_OK;
}
2011-05-27 03:21:01 +02:00
static inline IDirectXFileDataReferenceImpl *impl_from_IDirectXFileDataReference(IDirectXFileDataReference *iface)
{
return CONTAINING_RECORD(iface, IDirectXFileDataReferenceImpl, IDirectXFileDataReference_iface);
}
2004-06-03 02:03:23 +02:00
/*** IUnknown methods ***/
static HRESULT WINAPI IDirectXFileDataReferenceImpl_QueryInterface(IDirectXFileDataReference* iface, REFIID riid, void** ppvObject)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataReferenceImpl *This = impl_from_IDirectXFileDataReference(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
2004-06-03 02:03:23 +02:00
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirectXFileObject)
2004-06-03 02:03:23 +02:00
|| IsEqualGUID(riid, &IID_IDirectXFileDataReference))
{
2010-03-01 09:36:37 +01:00
IUnknown_AddRef(iface);
2011-05-27 03:21:01 +02:00
*ppvObject = &This->IDirectXFileDataReference_iface;
2004-06-03 02:03:23 +02:00
return S_OK;
}
2008-10-10 13:44:43 +02:00
/* Do not print an error for interfaces that can be queried to retrieve the type of the object */
if (!IsEqualGUID(riid, &IID_IDirectXFileData)
&& !IsEqualGUID(riid, &IID_IDirectXFileBinary))
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
2004-06-03 02:03:23 +02:00
return E_NOINTERFACE;
}
static ULONG WINAPI IDirectXFileDataReferenceImpl_AddRef(IDirectXFileDataReference* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataReferenceImpl *This = impl_from_IDirectXFileDataReference(iface);
ULONG ref = InterlockedIncrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
return ref;
2004-06-03 02:03:23 +02:00
}
static ULONG WINAPI IDirectXFileDataReferenceImpl_Release(IDirectXFileDataReference* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataReferenceImpl *This = impl_from_IDirectXFileDataReference(iface);
ULONG ref = InterlockedDecrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
if (!ref)
2004-06-03 02:03:23 +02:00
HeapFree(GetProcessHeap(), 0, This);
return ref;
2004-06-03 02:03:23 +02:00
}
/*** IDirectXFileObject methods ***/
static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetName(IDirectXFileDataReference* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataReferenceImpl *This = impl_from_IDirectXFileDataReference(iface);
DWORD len;
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen);
if (!pdwBufLen)
return DXFILEERR_BADVALUE;
len = strlen(This->ptarget->name);
if (len)
len++;
2004-06-03 02:03:23 +02:00
if (pstrNameBuf) {
if (*pdwBufLen < len)
return DXFILEERR_BADVALUE;
CopyMemory(pstrNameBuf, This->ptarget->name, len);
/* Even if we return a size of 0, an empty string with a null byte must be returned */
if (*pdwBufLen && !len)
pstrNameBuf[0] = 0;
}
*pdwBufLen = len;
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetId(IDirectXFileDataReference* iface, LPGUID pGuid)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataReferenceImpl *This = impl_from_IDirectXFileDataReference(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%p)\n", This, iface, pGuid);
2004-06-03 02:03:23 +02:00
if (!pGuid)
return DXFILEERR_BADVALUE;
*pGuid = This->ptarget->class_id;
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
/*** IDirectXFileDataReference ***/
static HRESULT WINAPI IDirectXFileDataReferenceImpl_Resolve(IDirectXFileDataReference* iface, LPDIRECTXFILEDATA* ppDataObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileDataReferenceImpl *This = impl_from_IDirectXFileDataReference(iface);
IDirectXFileDataImpl *object;
HRESULT hr;
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%p)\n", This, iface, ppDataObj);
2004-06-03 02:03:23 +02:00
if (!ppDataObj)
return DXFILEERR_BADVALUE;
hr = IDirectXFileDataImpl_Create(&object);
2008-12-14 18:55:10 +01:00
if (FAILED(hr))
return hr;
object->pobj = This->ptarget;
object->cur_enum_object = 0;
object->level = 0;
object->from_ref = TRUE;
*ppDataObj = &object->IDirectXFileData_iface;
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
static const IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl =
2004-06-03 02:03:23 +02:00
{
IDirectXFileDataReferenceImpl_QueryInterface,
IDirectXFileDataReferenceImpl_AddRef,
IDirectXFileDataReferenceImpl_Release,
IDirectXFileDataReferenceImpl_GetName,
IDirectXFileDataReferenceImpl_GetId,
IDirectXFileDataReferenceImpl_Resolve
};
2008-12-04 12:47:20 +01:00
static HRESULT IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl** ppObj)
{
IDirectXFileEnumObjectImpl* object;
TRACE("(%p)\n", ppObj);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileEnumObjectImpl));
2008-12-14 18:55:10 +01:00
if (!object)
return DXFILEERR_BADALLOC;
2011-05-27 03:21:01 +02:00
object->IDirectXFileEnumObject_iface.lpVtbl = &IDirectXFileEnumObject_Vtbl;
object->ref = 1;
*ppObj = object;
return S_OK;
}
2011-05-27 03:21:01 +02:00
static inline IDirectXFileEnumObjectImpl *impl_from_IDirectXFileEnumObject(IDirectXFileEnumObject *iface)
{
return CONTAINING_RECORD(iface, IDirectXFileEnumObjectImpl, IDirectXFileEnumObject_iface);
}
2004-06-03 02:03:23 +02:00
/*** IUnknown methods ***/
static HRESULT WINAPI IDirectXFileEnumObjectImpl_QueryInterface(IDirectXFileEnumObject* iface, REFIID riid, void** ppvObject)
{
2011-05-27 03:21:01 +02:00
IDirectXFileEnumObjectImpl *This = impl_from_IDirectXFileEnumObject(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
2004-06-03 02:03:23 +02:00
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirectXFileEnumObject))
{
2010-03-01 09:36:37 +01:00
IUnknown_AddRef(iface);
2011-05-27 03:21:01 +02:00
*ppvObject = &This->IDirectXFileEnumObject_iface;
2004-06-03 02:03:23 +02:00
return S_OK;
}
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
return E_NOINTERFACE;
}
static ULONG WINAPI IDirectXFileEnumObjectImpl_AddRef(IDirectXFileEnumObject* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileEnumObjectImpl *This = impl_from_IDirectXFileEnumObject(iface);
ULONG ref = InterlockedIncrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
return ref;
2004-06-03 02:03:23 +02:00
}
static ULONG WINAPI IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileEnumObjectImpl *This = impl_from_IDirectXFileEnumObject(iface);
ULONG ref = InterlockedDecrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
if (!ref)
{
ULONG i;
for (i = 0; i < This->nb_xobjects; i++)
IDirectXFileData_Release(This->pRefObjects[i]);
if (This->mapped_memory)
UnmapViewOfFile(This->mapped_memory);
HeapFree(GetProcessHeap(), 0, This->decomp_buffer);
2004-06-03 02:03:23 +02:00
HeapFree(GetProcessHeap(), 0, This);
}
2004-06-03 02:03:23 +02:00
return ref;
2004-06-03 02:03:23 +02:00
}
/*** IDirectXFileEnumObject methods ***/
static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileEnumObject* iface, LPDIRECTXFILEDATA* ppDataObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileEnumObjectImpl *This = impl_from_IDirectXFileEnumObject(iface);
2004-06-03 02:03:23 +02:00
IDirectXFileDataImpl* object;
HRESULT hr;
2008-10-16 22:22:52 +02:00
if (!ppDataObj)
return E_POINTER;
*ppDataObj = NULL;
TRACE("(%p/%p)->(%p)\n", This, iface, ppDataObj);
if (This->nb_xobjects >= MAX_OBJECTS)
{
ERR("Too many objects\n");
return DXFILEERR_NOMOREOBJECTS;
}
/* Check if there are templates defined before the object */
if (!parse_templates(&This->buf, TRUE))
return DXFILEERR_PARSEERROR;
if (!This->buf.rem_bytes)
return DXFILEERR_NOMOREOBJECTS;
hr = IDirectXFileDataImpl_Create(&object);
if (FAILED(hr))
return hr;
2004-06-03 02:03:23 +02:00
object->pobj = HeapAlloc(GetProcessHeap(), 0, sizeof(xobject)*MAX_SUBOBJECTS);
if (!object->pobj)
{
hr = DXFILEERR_BADALLOC;
goto error;
}
object->pstrings = HeapAlloc(GetProcessHeap(), 0, MAX_STRINGS_BUFFER);
if (!object->pstrings)
2008-11-09 11:11:40 +01:00
{
hr = DXFILEERR_BADALLOC;
goto error;
2008-11-09 11:11:40 +01:00
}
object->cur_enum_object = 0;
object->level = 0;
object->from_ref = FALSE;
This->buf.pxo_globals = This->xobjects;
This->buf.nb_pxo_globals = This->nb_xobjects;
This->buf.level = 0;
This->buf.pdata = NULL;
This->buf.capacity = 0;
This->buf.cur_pos_data = 0;
This->buf.cur_pstrings = This->buf.pstrings = object->pstrings;
This->buf.pxo = This->xobjects[This->nb_xobjects] = This->buf.pxo_tab = object->pobj;
This->buf.pxo->pdata = NULL;
This->buf.pxo->nb_subobjects = 1;
if (!parse_object(&This->buf))
{
WARN("Object is not correct\n");
hr = DXFILEERR_PARSEERROR;
goto error;
}
*ppDataObj = &object->IDirectXFileData_iface;
2004-06-03 02:03:23 +02:00
/* Get a reference to created object */
This->pRefObjects[This->nb_xobjects] = &object->IDirectXFileData_iface;
IDirectXFileData_AddRef(This->pRefObjects[This->nb_xobjects]);
This->nb_xobjects++;
return DXFILE_OK;
error:
IDirectXFileData_Release(&object->IDirectXFileData_iface);
return hr;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetDataObjectById(IDirectXFileEnumObject* iface, REFGUID rguid, LPDIRECTXFILEDATA* ppDataObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileEnumObjectImpl *This = impl_from_IDirectXFileEnumObject(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p,%p) stub!\n", This, iface, rguid, ppDataObj);
2004-06-03 02:03:23 +02:00
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetDataObjectByName(IDirectXFileEnumObject* iface, LPCSTR szName, LPDIRECTXFILEDATA* ppDataObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileEnumObjectImpl *This = impl_from_IDirectXFileEnumObject(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%s,%p) stub!\n", This, iface, szName, ppDataObj);
2004-06-03 02:03:23 +02:00
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static const IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl =
2004-06-03 02:03:23 +02:00
{
IDirectXFileEnumObjectImpl_QueryInterface,
IDirectXFileEnumObjectImpl_AddRef,
IDirectXFileEnumObjectImpl_Release,
IDirectXFileEnumObjectImpl_GetNextDataObject,
IDirectXFileEnumObjectImpl_GetDataObjectById,
IDirectXFileEnumObjectImpl_GetDataObjectByName
};
static HRESULT IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj)
{
IDirectXFileSaveObjectImpl* object;
TRACE("(%p)\n", ppObj);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileSaveObjectImpl));
if (!object)
return DXFILEERR_BADALLOC;
2011-05-27 03:21:01 +02:00
object->IDirectXFileSaveObject_iface.lpVtbl = &IDirectXFileSaveObject_Vtbl;
object->ref = 1;
*ppObj = object;
return S_OK;
}
2011-05-27 03:21:01 +02:00
static inline IDirectXFileSaveObjectImpl *impl_from_IDirectXFileSaveObject(IDirectXFileSaveObject *iface)
{
return CONTAINING_RECORD(iface, IDirectXFileSaveObjectImpl, IDirectXFileSaveObject_iface);
}
2004-06-03 02:03:23 +02:00
/*** IUnknown methods ***/
static HRESULT WINAPI IDirectXFileSaveObjectImpl_QueryInterface(IDirectXFileSaveObject* iface, REFIID riid, void** ppvObject)
{
2011-05-27 03:21:01 +02:00
IDirectXFileSaveObjectImpl *This = impl_from_IDirectXFileSaveObject(iface);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
2004-06-03 02:03:23 +02:00
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirectXFileSaveObject))
{
2010-03-01 09:36:37 +01:00
IUnknown_AddRef(iface);
2011-05-27 03:21:01 +02:00
*ppvObject = &This->IDirectXFileSaveObject_iface;
2004-06-03 02:03:23 +02:00
return S_OK;
}
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
return E_NOINTERFACE;
}
static ULONG WINAPI IDirectXFileSaveObjectImpl_AddRef(IDirectXFileSaveObject* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileSaveObjectImpl *This = impl_from_IDirectXFileSaveObject(iface);
ULONG ref = InterlockedIncrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
return ref;
2004-06-03 02:03:23 +02:00
}
static ULONG WINAPI IDirectXFileSaveObjectImpl_Release(IDirectXFileSaveObject* iface)
{
2011-05-27 03:21:01 +02:00
IDirectXFileSaveObjectImpl *This = impl_from_IDirectXFileSaveObject(iface);
ULONG ref = InterlockedDecrement(&This->ref);
2004-06-03 02:03:23 +02:00
TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
2004-06-03 02:03:23 +02:00
if (!ref)
2004-06-03 02:03:23 +02:00
HeapFree(GetProcessHeap(), 0, This);
return ref;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileSaveObjectImpl_SaveTemplates(IDirectXFileSaveObject* iface, DWORD cTemplates, const GUID** ppguidTemplates)
{
2011-05-27 03:21:01 +02:00
IDirectXFileSaveObjectImpl *This = impl_from_IDirectXFileSaveObject(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%d,%p) stub!\n", This, iface, cTemplates, ppguidTemplates);
2004-06-03 02:03:23 +02:00
return DXFILE_OK;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileSaveObjectImpl_CreateDataObject(IDirectXFileSaveObject* iface, REFGUID rguidTemplate, LPCSTR szName, const GUID* pguid, DWORD cbSize, LPVOID pvData, LPDIRECTXFILEDATA* ppDataObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileSaveObjectImpl *This = impl_from_IDirectXFileSaveObject(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p,%s,%p,%d,%p,%p) stub!\n", This, iface, rguidTemplate, szName, pguid, cbSize, pvData, ppDataObj);
2004-06-03 02:03:23 +02:00
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static HRESULT WINAPI IDirectXFileSaveObjectImpl_SaveData(IDirectXFileSaveObject* iface, LPDIRECTXFILEDATA ppDataObj)
{
2011-05-27 03:21:01 +02:00
IDirectXFileSaveObjectImpl *This = impl_from_IDirectXFileSaveObject(iface);
2004-06-03 02:03:23 +02:00
FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppDataObj);
2007-11-08 05:55:01 +01:00
return DXFILEERR_BADVALUE;
2004-06-03 02:03:23 +02:00
}
static const IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl =
2004-06-03 02:03:23 +02:00
{
IDirectXFileSaveObjectImpl_QueryInterface,
IDirectXFileSaveObjectImpl_AddRef,
IDirectXFileSaveObjectImpl_Release,
IDirectXFileSaveObjectImpl_SaveTemplates,
IDirectXFileSaveObjectImpl_CreateDataObject,
IDirectXFileSaveObjectImpl_SaveData
};