From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 44 +++++++++++++++++++++++++++----------- dlls/dxcore/tests/dxcore.c | 3 --- 2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 3895302c1d2..d08fd1c772b 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -100,35 +100,56 @@ static BOOL STDMETHODCALLTYPE dxcore_adapter_IsPropertySupported(IDXCoreAdapter return FALSE; }
+static HRESULT dxcore_adapter_get_property_size(struct dxcore_adapter *adapter, DXCoreAdapterProperty property, + size_t *size) +{ + static const size_t property_sizes[] = + { + [InstanceLuid] = sizeof(LUID), + [HardwareID] = sizeof(DXCoreHardwareID), + }; + + switch (property) + { + case InstanceLuid: + case HardwareID: + *size = property_sizes[property]; + return S_OK; + default: + FIXME("property %u not implemented.\n", property); + return DXGI_ERROR_INVALID_CALL; + } +} + static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *iface, DXCoreAdapterProperty property, size_t buffer_size, void *buffer) { struct dxcore_adapter *adapter = impl_from_IDXCoreAdapter(iface); + size_t size; + HRESULT hr;
TRACE("iface %p, property %u, buffer_size %Iu, buffer %p\n", iface, property, buffer_size, buffer);
if (!buffer) return E_POINTER;
+ if (FAILED(hr = dxcore_adapter_get_property_size(adapter, property, &size))) + return hr; + + if (buffer_size < size) + return E_INVALIDARG; + switch (property) { case InstanceLuid: { - LUID *luid = buffer; - - if (buffer_size < sizeof(*luid)) - return E_INVALIDARG; - - *luid = adapter->identifier.adapter_luid; + *(LUID *)buffer = adapter->identifier.adapter_luid; break; } case HardwareID: { struct DXCoreHardwareID *hardware_id = buffer;
- if (buffer_size != sizeof(DXCoreHardwareID)) - return E_INVALIDARG; - hardware_id->vendorID = adapter->identifier.vendor_id; hardware_id->deviceID = adapter->identifier.device_id; hardware_id->subSysID = adapter->identifier.subsystem_id; @@ -136,10 +157,7 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *ifac break; } default: - { - FIXME("property %u not implemented.\n", property); - return DXGI_ERROR_INVALID_CALL; - } + ; }
return S_OK; diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index c4a036d0f6c..7cab5bbc55a 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -216,11 +216,8 @@ static void test_GetProperty(void)
memset(hwid, 0, sizeof(hwid)); hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]) + 1, hwid); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!!hwid[0].vendorID, "Unexpected vendorID.\n"); - todo_wine ok(!!hwid[0].deviceID, "Unexpected deviceID.\n"); ok(!hwid[1].vendorID, "Unexpected vendorID.\n"); ok(!hwid[1].deviceID, "Unexpected deviceID.\n");