From: Rémi Bernon <rbernon(a)codeweavers.com>
Mafia III launcher crashes when querying video controllers when it
passes the NULL __PATH value through COM marshalling.
v2: Don't read the AdapterRAM property, it returns differently on w2008.
v3: Fix all BSTR system properties.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wbemprox/query.c | 12 ++++++++----
dlls/wbemprox/tests/query.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c
index 6ac5ad5b770..525381d88d2 100644
--- a/dlls/wbemprox/query.c
+++ b/dlls/wbemprox/query.c
@@ -946,22 +946,24 @@ static HRESULT get_system_propval( const struct view *view, UINT table_index, UI
if (type) *type = CIM_SINT32;
return S_OK;
}
- else if (!wcsicmp( name, L"__NAMESPACE" ))
+ if (!wcsicmp( name, L"__NAMESPACE" ))
{
if (ret)
{
V_VT( ret ) = VT_BSTR;
V_BSTR( ret ) = view->proplist ? NULL : build_namespace();
+ if (!V_BSTR( ret )) V_VT( ret ) = VT_NULL;
}
if (type) *type = CIM_STRING;
return S_OK;
}
- else if (!wcsicmp( name, L"__PATH" ))
+ if (!wcsicmp( name, L"__PATH" ))
{
if (ret)
{
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;
@@ -976,22 +978,24 @@ static HRESULT get_system_propval( const struct view *view, UINT table_index, UI
if (type) *type = CIM_SINT32;
return S_OK;
}
- else if (!wcsicmp( name, L"__RELPATH" ))
+ if (!wcsicmp( name, L"__RELPATH" ))
{
if (ret)
{
V_VT( ret ) = VT_BSTR;
V_BSTR( ret ) = build_relpath( view, table_index, result_index, name );
+ if (!V_BSTR( ret )) V_VT( ret ) = VT_NULL;
}
if (type) *type = CIM_STRING;
return S_OK;
}
- else if (!wcsicmp( name, L"__SERVER" ))
+ if (!wcsicmp( name, L"__SERVER" ))
{
if (ret)
{
V_VT( ret ) = VT_BSTR;
V_BSTR( ret ) = view->proplist ? NULL : build_servername();
+ 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..d1ce42d64cb 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -1414,6 +1414,13 @@ static void test_Win32_VideoController( IWbemServices *services )
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
if (hr != S_OK) break;
+ check_property( obj, L"__CLASS", VT_BSTR, CIM_STRING );
+ check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 );
+ check_property( obj, L"__NAMESPACE", VT_BSTR, CIM_STRING );
+ check_property( obj, L"__PATH", VT_BSTR, CIM_STRING );
+ check_property( obj, L"__PROPERTY_COUNT", VT_I4, CIM_SINT32 );
+ check_property( obj, L"__RELPATH", VT_BSTR, CIM_STRING );
+ check_property( obj, L"__SERVER", 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 +1439,31 @@ 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"__CLASS", VT_BSTR, CIM_STRING );
+ check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 );
+ check_property( obj, L"__NAMESPACE", VT_NULL, CIM_STRING );
+ check_property( obj, L"__PATH", VT_NULL, CIM_STRING );
+ check_property( obj, L"__PROPERTY_COUNT", VT_I4, CIM_SINT32 );
+ check_property( obj, L"__RELPATH", VT_NULL, CIM_STRING );
+ check_property( obj, L"__SERVER", VT_NULL, CIM_STRING );
+ IWbemClassObject_Release( obj );
+ }
+
IEnumWbemClassObject_Release( result );
SysFreeString( query );
SysFreeString( wql );
--
2.20.1