Commit 641200dc authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

d3dxof: Add support for DXFILELOAD_FROMMEMORY.

parent 3b30fd9d
...@@ -205,6 +205,7 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV ...@@ -205,6 +205,7 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
DWORD header[4]; DWORD header[4];
DWORD size; DWORD size;
HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE hFile = INVALID_HANDLE_VALUE;
LPDXFILELOADMEMORY lpdxflm = NULL;
TRACE("(%p/%p)->(%p,%x,%p)\n", This, iface, pvSource, dwLoadOptions, ppEnumObj); TRACE("(%p/%p)->(%p,%x,%p)\n", This, iface, pvSource, dwLoadOptions, ppEnumObj);
...@@ -233,14 +234,14 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV ...@@ -233,14 +234,14 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
hr = DXFILEERR_BADFILETYPE; hr = DXFILEERR_BADFILETYPE;
goto error; goto error;
} }
if (TRACE_ON(d3dxof))
{
char string[17];
memcpy(string, header, 16);
string[16] = 0;
TRACE("header = '%s'\n", string);
} }
else if (dwLoadOptions == DXFILELOAD_FROMMEMORY)
{
lpdxflm = (LPDXFILELOADMEMORY)pvSource;
FIXME("Source in memory at %p with size %d\n", lpdxflm->lpMemory, lpdxflm->dSize);
memcpy(header, (char*)lpdxflm->lpMemory, 16);
} }
else else
{ {
...@@ -249,6 +250,14 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV ...@@ -249,6 +250,14 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
goto error; goto error;
} }
if (TRACE_ON(d3dxof))
{
char string[17];
memcpy(string, header, 16);
string[16] = 0;
TRACE("header = '%s'\n", string);
}
if (header[0] != XOFFILE_FORMAT_MAGIC) if (header[0] != XOFFILE_FORMAT_MAGIC)
{ {
hr = DXFILEERR_BADFILETYPE; hr = DXFILEERR_BADFILETYPE;
...@@ -301,6 +310,8 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV ...@@ -301,6 +310,8 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
object->buf.token_present = FALSE; object->buf.token_present = FALSE;
object->buf.cur_subobject = 0; object->buf.cur_subobject = 0;
if (dwLoadOptions == DXFILELOAD_FROMFILE)
{
object->buf.buffer = HeapAlloc(GetProcessHeap(), 0, MAX_INPUT_SIZE+1); object->buf.buffer = HeapAlloc(GetProcessHeap(), 0, MAX_INPUT_SIZE+1);
if (!object->buf.buffer) if (!object->buf.buffer)
{ {
...@@ -317,6 +328,13 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV ...@@ -317,6 +328,13 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
hr = DXFILEERR_PARSEERROR; hr = DXFILEERR_PARSEERROR;
goto error; goto error;
} }
}
else
{
object->buf.buffer = ((LPBYTE)lpdxflm->lpMemory) + 16;
object->buf.rem_bytes = lpdxflm->dSize;
}
TRACE("Read %d bytes\n", object->buf.rem_bytes); TRACE("Read %d bytes\n", object->buf.rem_bytes);
*ppEnumObj = (LPDIRECTXFILEENUMOBJECT)object; *ppEnumObj = (LPDIRECTXFILEENUMOBJECT)object;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment