[PATCH v2 2/2] wbemprox: Support retrieving more than one object in IEnumWbemClassObject::Next().

Hans Leidekker hans at codeweavers.com
Tue Jul 28 04:35:08 CDT 2020


From: Gijs Vermeulen <gijsvrm at gmail.com>

Patch by GitHub user pnevmoslon with some modifications.

Fixes gamepad support in Mortal Kombat 11.

v2: Release allocated objects on error.

Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/wbemprox/class.c       | 23 ++++++++++++++---------
 dlls/wbemprox/tests/query.c | 12 ++++++------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c
index ba7720b098..db6017e0c9 100644
--- a/dlls/wbemprox/class.c
+++ b/dlls/wbemprox/class.c
@@ -116,24 +116,29 @@ static HRESULT WINAPI enum_class_object_Next(
     struct table *table;
     static int once = 0;
     HRESULT hr;
+    ULONG i, j;
 
     TRACE("%p, %d, %u, %p, %p\n", iface, lTimeout, uCount, apObjects, puReturned);
 
-    if (!uCount) return WBEM_S_FALSE;
     if (!apObjects || !puReturned) return WBEM_E_INVALID_PARAMETER;
     if (lTimeout != WBEM_INFINITE && !once++) FIXME("timeout not supported\n");
 
     *puReturned = 0;
-    if (ec->index >= view->result_count) return WBEM_S_FALSE;
 
-    table = get_view_table( view, ec->index );
-    hr = create_class_object( table->name, iface, ec->index, NULL, apObjects );
-    if (hr != S_OK) return hr;
+    for (i = 0; i < uCount; i++)
+    {
+        if (ec->index >= view->result_count) return WBEM_S_FALSE;
+        table = get_view_table( view, ec->index );
+        hr = create_class_object( table->name, iface, ec->index, NULL, &apObjects[i] );
+        if (hr != S_OK)
+        {
+            for (j = 0; j < i; j++) IWbemClassObject_Release( apObjects[j] );
+            return hr;
+        }
+        ec->index++;
+        (*puReturned)++;
+    }
 
-    ec->index++;
-    *puReturned = 1;
-    if (ec->index == view->result_count && uCount > 1) return WBEM_S_FALSE;
-    if (uCount > 1) return WBEM_S_TIMEDOUT;
     return WBEM_S_NO_ERROR;
 }
 
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index e99e221c30..e48722f3bc 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -181,8 +181,8 @@ static void test_IEnumWbemClassObject_Next( IWbemServices *services )
 
     count = 2;
     hr = IEnumWbemClassObject_Next( result, 10000, 0, &obj1, &count );
-    todo_wine ok( hr == S_OK, "got %08x\n", hr );
-    todo_wine ok( count == 0, "expected 0, got %u\n", count );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( count == 0, "expected 0, got %u\n", count );
 
     for (;;)
     {
@@ -199,8 +199,8 @@ static void test_IEnumWbemClassObject_Next( IWbemServices *services )
 
     count = 0;
     hr = IEnumWbemClassObject_Next( result, 10000, num_objects, obj, &count );
-    todo_wine ok( hr == S_OK, "got %08x\n", hr );
-    todo_wine ok( count == num_objects, "expected %u, got %u\n", num_objects, count );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( count == num_objects, "expected %u, got %u\n", num_objects, count );
 
     for (i = 0; i < count; i++)
         IWbemClassObject_Release( obj[i] );
@@ -210,8 +210,8 @@ static void test_IEnumWbemClassObject_Next( IWbemServices *services )
 
     count = 0;
     hr = IEnumWbemClassObject_Next( result, 10000, num_objects + 1, obj, &count );
-    todo_wine ok( hr == S_FALSE, "got %08x\n", hr );
-    todo_wine ok( count == num_objects, "expected %u, got %u\n", num_objects, count );
+    ok( hr == S_FALSE, "got %08x\n", hr );
+    ok( count == num_objects, "expected %u, got %u\n", num_objects, count );
 
     for (i = 0; i < count; i++)
         IWbemClassObject_Release( obj[i] );
-- 
2.27.0




More information about the wine-devel mailing list