d3dxof: Add support for DXFILELOAD_FROMRESOURCE source.

This commit is contained in:
Christian Costa 2009-02-10 14:12:47 +01:00 committed by Alexandre Julliard
parent 279e49030a
commit 3e6d9558b8
2 changed files with 36 additions and 0 deletions

View File

@ -131,6 +131,7 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
HANDLE hFile = INVALID_HANDLE_VALUE;
HANDLE file_mapping = 0;
LPBYTE buffer = NULL;
HGLOBAL resource_data = 0;
LPBYTE file_buffer;
DWORD file_size;
@ -169,6 +170,36 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
}
file_buffer = buffer;
}
else if (dwLoadOptions == DXFILELOAD_FROMRESOURCE)
{
HRSRC resource_info;
LPDXFILELOADRESOURCE lpdxflr = pvSource;
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)
{
lpdxflm = pvSource;
@ -289,6 +320,8 @@ error:
CloseHandle(file_mapping);
if (hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile);
if (resource_data)
FreeResource(resource_data);
*ppEnumObj = NULL;
return hr;
@ -977,6 +1010,8 @@ static ULONG WINAPI IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject* i
CloseHandle(This->file_mapping);
CloseHandle(This->hFile);
}
else if (This->source == DXFILELOAD_FROMRESOURCE)
FreeResource(This->resource_data);
HeapFree(GetProcessHeap(), 0, This);
}

View File

@ -151,6 +151,7 @@ typedef struct {
HANDLE hFile;
HANDLE file_mapping;
LPBYTE buffer;
HGLOBAL resource_data;
parse_buffer buf;
IDirectXFileImpl* pDirectXFile;
ULONG nb_xobjects;