Mafia III launcher crashes when querying video controllers after passing the NULL __PATH value through COM marshalling.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wbemprox/query.c | 1 + dlls/wbemprox/tests/query.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+)
diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c index 6ac5ad5b770..ad7150e5401 100644 --- a/dlls/wbemprox/query.c +++ b/dlls/wbemprox/query.c @@ -962,6 +962,7 @@ static HRESULT get_system_propval( const struct view *view, UINT table_index, UI { V_VT( ret ) = VT_BSTR; V_BSTR( ret ) = build_path( view, table_index, result_index, name ); + if (!V_BSTR( ret )) V_VT( ret ) = VT_NULL; } if (type) *type = CIM_STRING; return S_OK; diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index 74fdfaa9bc8..357b0a8b8e5 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -1414,6 +1414,8 @@ static void test_Win32_VideoController( IWbemServices *services ) hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); if (hr != S_OK) break;
+ check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 ); + check_property( obj, L"__PATH", VT_BSTR, CIM_STRING ); check_property( obj, L"AdapterCompatibility", VT_BSTR, CIM_STRING ); check_property( obj, L"Availability", VT_I4, CIM_UINT16 ); check_property( obj, L"ConfigManagerErrorCode", VT_I4, CIM_UINT32 ); @@ -1432,6 +1434,27 @@ static void test_Win32_VideoController( IWbemServices *services ) IWbemClassObject_Release( obj ); }
+ IEnumWbemClassObject_Release( result ); + SysFreeString( query ); + + query = SysAllocString( L"SELECT AdapterRAM FROM Win32_VideoController" ); + hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result ); + if (hr != S_OK) + { + win_skip( "Win32_VideoController not available\n" ); + return; + } + + for (;;) + { + hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); + if (hr != S_OK) break; + check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 ); + check_property( obj, L"__PATH", VT_NULL, CIM_STRING ); + check_property( obj, L"AdapterRAM", VT_I4, CIM_UINT32 ); + IWbemClassObject_Release( obj ); + } + IEnumWbemClassObject_Release( result ); SysFreeString( query ); SysFreeString( wql );
That's what Windows do apparently. Anything with more than 4GiB of VRAM would report less otherwise, confusing the VRAM detection in some games.
The Mafia III launcher is trying to open a warning popup with a 8GiB VRAM GPU for instance, as the reported value overflows to 0.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wbemprox/builtin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 43268221936..8daa55eaeb4 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -3878,8 +3878,9 @@ static enum fill_status fill_videocontroller( struct table *table, const struct hr = IDXGIAdapter_GetDesc( adapter, &desc ); if (SUCCEEDED(hr)) { - vidmem = desc.DedicatedVideoMemory; - name = desc.Description; + if (desc.DedicatedVideoMemory > UINT_MAX) vidmem = 0xfff00000; + else vidmem = desc.DedicatedVideoMemory; + name = desc.Description; }
done:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79472
Your paranoid android.
=== w2008s64 (32 bit report) ===
wbemprox: query.c:235: Test failed: 1454: unexpected variant type 0x1
=== w2008s64 (64 bit report) ===
wbemprox: query.c:235: Test failed: 1454: unexpected variant type 0x1
On 9/29/20 8:23 PM, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79472
Your paranoid android.
=== w2008s64 (32 bit report) ===
wbemprox: query.c:235: Test failed: 1454: unexpected variant type 0x1
=== w2008s64 (64 bit report) ===
wbemprox: query.c:235: Test failed: 1454: unexpected variant type 0x1
Damn, I added the AdapterRAM check late to see what Windows was reporting, and here it fails... Its results aren't even interesting on the testbot as it's always 0 with WARP.
I'll send it again without the AdapterRAM line.
Mafia III launcher crashes when querying video controllers when it passes the NULL __PATH value through COM marshalling.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
v2: Don't read the AdapterRAM property, it returns differently on w2008.
dlls/wbemprox/query.c | 1 + dlls/wbemprox/tests/query.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+)
diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c index 6ac5ad5b770..ad7150e5401 100644 --- a/dlls/wbemprox/query.c +++ b/dlls/wbemprox/query.c @@ -962,6 +962,7 @@ static HRESULT get_system_propval( const struct view *view, UINT table_index, UI { V_VT( ret ) = VT_BSTR; V_BSTR( ret ) = build_path( view, table_index, result_index, name ); + if (!V_BSTR( ret )) V_VT( ret ) = VT_NULL; } if (type) *type = CIM_STRING; return S_OK; diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index 74fdfaa9bc8..c359cfb20d4 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -1414,6 +1414,8 @@ static void test_Win32_VideoController( IWbemServices *services ) hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); if (hr != S_OK) break;
+ check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 ); + check_property( obj, L"__PATH", VT_BSTR, CIM_STRING ); check_property( obj, L"AdapterCompatibility", VT_BSTR, CIM_STRING ); check_property( obj, L"Availability", VT_I4, CIM_UINT16 ); check_property( obj, L"ConfigManagerErrorCode", VT_I4, CIM_UINT32 ); @@ -1432,6 +1434,26 @@ static void test_Win32_VideoController( IWbemServices *services ) IWbemClassObject_Release( obj ); }
+ IEnumWbemClassObject_Release( result ); + SysFreeString( query ); + + query = SysAllocString( L"SELECT AdapterRAM FROM Win32_VideoController" ); + hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result ); + if (hr != S_OK) + { + win_skip( "Win32_VideoController not available\n" ); + return; + } + + for (;;) + { + hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); + if (hr != S_OK) break; + check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 ); + check_property( obj, L"__PATH", VT_NULL, CIM_STRING ); + IWbemClassObject_Release( obj ); + } + IEnumWbemClassObject_Release( result ); SysFreeString( query ); SysFreeString( wql );
That's what Windows do apparently. Anything with more than 4GiB of VRAM would report less otherwise, confusing the VRAM detection in some games.
The Mafia III launcher is trying to open a warning popup with a 8GiB VRAM GPU for instance, as the reported value overflows to 0.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wbemprox/builtin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 43268221936..8daa55eaeb4 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -3878,8 +3878,9 @@ static enum fill_status fill_videocontroller( struct table *table, const struct hr = IDXGIAdapter_GetDesc( adapter, &desc ); if (SUCCEEDED(hr)) { - vidmem = desc.DedicatedVideoMemory; - name = desc.Description; + if (desc.DedicatedVideoMemory > UINT_MAX) vidmem = 0xfff00000; + else vidmem = desc.DedicatedVideoMemory; + name = desc.Description; }
done: