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
DWORD header[4];
DWORD size;
HANDLE hFile = INVALID_HANDLE_VALUE;
LPDXFILELOADMEMORY lpdxflm = NULL;
TRACE("(%p/%p)->(%p,%x,%p)\n", This, iface, pvSource, dwLoadOptions, ppEnumObj);
......@@ -233,14 +234,14 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
hr = DXFILEERR_BADFILETYPE;
goto error;
}
}
else if (dwLoadOptions == DXFILELOAD_FROMMEMORY)
{
lpdxflm = (LPDXFILELOADMEMORY)pvSource;
if (TRACE_ON(d3dxof))
{
char string[17];
memcpy(string, header, 16);
string[16] = 0;
TRACE("header = '%s'\n", string);
}
FIXME("Source in memory at %p with size %d\n", lpdxflm->lpMemory, lpdxflm->dSize);
memcpy(header, (char*)lpdxflm->lpMemory, 16);
}
else
{
......@@ -249,6 +250,14 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
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)
{
hr = DXFILEERR_BADFILETYPE;
......@@ -301,22 +310,31 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
object->buf.token_present = FALSE;
object->buf.cur_subobject = 0;
object->buf.buffer = HeapAlloc(GetProcessHeap(), 0, MAX_INPUT_SIZE+1);
if (!object->buf.buffer)
if (dwLoadOptions == DXFILELOAD_FROMFILE)
{
WARN("Out of memory\n");
hr = DXFILEERR_BADALLOC;
goto error;
}
object->buf.buffer = HeapAlloc(GetProcessHeap(), 0, MAX_INPUT_SIZE+1);
if (!object->buf.buffer)
{
WARN("Out of memory\n");
hr = DXFILEERR_BADALLOC;
goto error;
}
ReadFile(hFile, object->buf.buffer, MAX_INPUT_SIZE+1, &object->buf.rem_bytes, NULL);
if (object->buf.rem_bytes > MAX_INPUT_SIZE)
ReadFile(hFile, object->buf.buffer, MAX_INPUT_SIZE+1, &object->buf.rem_bytes, NULL);
if (object->buf.rem_bytes > MAX_INPUT_SIZE)
{
FIXME("File size > %d not supported yet\n", MAX_INPUT_SIZE);
HeapFree(GetProcessHeap(), 0, object->buf.buffer);
hr = DXFILEERR_PARSEERROR;
goto error;
}
}
else
{
FIXME("File size > %d not supported yet\n", MAX_INPUT_SIZE);
HeapFree(GetProcessHeap(), 0, object->buf.buffer);
hr = DXFILEERR_PARSEERROR;
goto error;
object->buf.buffer = ((LPBYTE)lpdxflm->lpMemory) + 16;
object->buf.rem_bytes = lpdxflm->dSize;
}
TRACE("Read %d bytes\n", object->buf.rem_bytes);
*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