ddraw: Return the D3D identifier when GetDeviceIdentifier is called with no flags.

This commit is contained in:
Erich E. Hoover 2014-02-11 09:21:53 -07:00 committed by Alexandre Julliard
parent 2cb3aeb7b9
commit 68e3b18533
3 changed files with 55 additions and 10 deletions

View File

@ -2561,19 +2561,46 @@ static HRESULT WINAPI ddraw7_EvaluateMode(IDirectDraw7 *iface, DWORD Flags, DWOR
static HRESULT WINAPI ddraw7_GetDeviceIdentifier(IDirectDraw7 *iface,
DDDEVICEIDENTIFIER2 *DDDI, DWORD Flags)
{
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
struct wined3d_adapter_identifier adapter_id;
HRESULT hr = S_OK;
TRACE("iface %p, device_identifier %p, flags %#x.\n", iface, DDDI, Flags);
if(!DDDI)
if (!DDDI)
return DDERR_INVALIDPARAMS;
/* The DDGDI_GETHOSTIDENTIFIER returns the information about the 2D
* host adapter, if there's a secondary 3D adapter. This doesn't apply
* to any modern hardware, nor is it interesting for Wine, so ignore it.
* Size of DDDEVICEIDENTIFIER2 may be aligned to 8 bytes and thus 4
* bytes too long. So only copy the relevant part of the structure
*/
if (Flags & DDGDI_GETHOSTIDENTIFIER)
{
/* The DDGDI_GETHOSTIDENTIFIER returns the information about the 2D
* host adapter, if there's a secondary 3D adapter. This doesn't apply
* to any modern hardware, nor is it interesting for Wine, so ignore it.
* Size of DDDEVICEIDENTIFIER2 may be aligned to 8 bytes and thus 4
* bytes too long. So only copy the relevant part of the structure
*/
memcpy(DDDI, &deviceidentifier, FIELD_OFFSET(DDDEVICEIDENTIFIER2, dwWHQLLevel) + sizeof(DWORD));
memcpy(DDDI, &deviceidentifier, FIELD_OFFSET(DDDEVICEIDENTIFIER2, dwWHQLLevel) + sizeof(DWORD));
return DD_OK;
}
/* Drakan: Order of the Flame expects accurate D3D device information from ddraw */
adapter_id.driver = DDDI->szDriver;
adapter_id.driver_size = sizeof(DDDI->szDriver);
adapter_id.description = DDDI->szDescription;
adapter_id.description_size = sizeof(DDDI->szDescription);
adapter_id.device_name_size = 0;
wined3d_mutex_lock();
hr = wined3d_get_adapter_identifier(ddraw->wined3d, WINED3DADAPTER_DEFAULT, 0x0, &adapter_id);
wined3d_mutex_unlock();
if (FAILED(hr)) return hr;
DDDI->liDriverVersion = adapter_id.driver_version;
DDDI->dwVendorId = adapter_id.vendor_id;
DDDI->dwDeviceId = adapter_id.device_id;
DDDI->dwSubSysId = adapter_id.subsystem_id;
DDDI->dwRevision = adapter_id.revision;
DDDI->guidDeviceIdentifier = adapter_id.device_identifier;
DDDI->dwWHQLLevel = adapter_id.whql_level;
return DD_OK;
}

View File

@ -999,6 +999,24 @@ static void testddraw7(void)
ok(pend[1]==0xdeadbeef, "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
}
/* recheck with the DDGDI_GETHOSTIDENTIFIER flag */
pend[0] = 0xdeadbeef;
pend[1] = 0xdeadbeef;
hr = IDirectDraw7_GetDeviceIdentifier(dd7, pdddi2, DDGDI_GETHOSTIDENTIFIER);
ok(hr==DD_OK, "get device identifier failed with %08x\n", hr);
if (hr==DD_OK)
{
/* szDriver contains the name of the driver DLL */
ok(strstr(pdddi2->szDriver, ".dll")!=NULL, "szDriver does not contain DLL name\n");
/* check how strings are copied into the structure */
ok(pdddi2->szDriver[MAX_DDDEVICEID_STRING - 1]==0, "szDriver not cleared\n");
ok(pdddi2->szDescription[MAX_DDDEVICEID_STRING - 1]==0, "szDescription not cleared\n");
/* verify that 8 byte structure size alignment will not overwrite memory */
ok(pend[0]==0xdeadbeef || broken(pend[0] != 0xdeadbeef), /* win2k */
"memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
ok(pend[1]==0xdeadbeef, "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
}
IDirectDraw_Release(dd7);
HeapFree( GetProcessHeap(), 0, pdddi2 );
}

View File

@ -3413,7 +3413,7 @@ HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
const char *name = adapter->driver_info.name;
len = min(strlen(name), identifier->driver_size - 1);
memcpy(identifier->driver, name, len);
identifier->driver[len] = '\0';
memset(&identifier->driver[len], 0, identifier->driver_size - len);
}
if (identifier->description_size)
@ -3421,7 +3421,7 @@ HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
const char *description = adapter->driver_info.description;
len = min(strlen(description), identifier->description_size - 1);
memcpy(identifier->description, description, len);
identifier->description[len] = '\0';
memset(&identifier->description[len], 0, identifier->description_size - len);
}
/* Note that d3d8 doesn't supply a device name. */