[PATCH 2/6] ntdll: Do not write the "context" parameter of NtQueryDirectoryObject on failure.

Zebediah Figura zfigura at codeweavers.com
Mon Apr 4 20:27:23 CDT 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/ntdll/tests/om.c  | 4 ++--
 dlls/ntdll/unix/sync.c | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index f18afa05ae9..b0fea870809 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -2529,7 +2529,7 @@ static void test_query_directory(void)
     size = 0xdeadbeef;
     status = NtQueryDirectoryObject( dir, info, sizeof(buffer), TRUE, TRUE, &context, &size );
     ok( status == STATUS_NO_MORE_ENTRIES, "got %#x\n", status );
-    todo_wine ok( context == 0xdeadbeef, "got context %#x\n", context );
+    ok( context == 0xdeadbeef, "got context %#x\n", context );
     todo_wine ok( !size, "got size %u\n", size );
 
     RtlInitUnicodeString( &string, L"\\BaseNamedObjects\\winetest\\Telamon" );
@@ -2594,7 +2594,7 @@ static void test_query_directory(void)
     context = 0xdeadbeef;
     status = NtQueryDirectoryObject( dir, info, 0, TRUE, TRUE, &context, &size );
     todo_wine ok( status == STATUS_BUFFER_TOO_SMALL, "got %#x\n", status );
-    todo_wine ok( context == 0xdeadbeef, "got context %#x\n", context );
+    ok( context == 0xdeadbeef, "got context %#x\n", context );
     todo_wine ok( size == needed_size, "expected size %u, got %u\n", needed_size, size );
 
     size = 0xdeadbeef;
diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c
index 0786454dad2..373afd69b2b 100644
--- a/dlls/ntdll/unix/sync.c
+++ b/dlls/ntdll/unix/sync.c
@@ -1099,10 +1099,9 @@ NTSTATUS WINAPI NtQueryDirectoryObject( HANDLE handle, DIRECTORY_BASIC_INFORMATI
                                         ULONG size, BOOLEAN single_entry, BOOLEAN restart,
                                         ULONG *context, ULONG *ret_size )
 {
+    ULONG index = restart ? 0 : *context;
     NTSTATUS ret;
 
-    if (restart) *context = 0;
-
     if (single_entry)
     {
         if (size <= sizeof(*buffer) + 2 * sizeof(WCHAR)) return STATUS_BUFFER_OVERFLOW;
@@ -1110,7 +1109,7 @@ NTSTATUS WINAPI NtQueryDirectoryObject( HANDLE handle, DIRECTORY_BASIC_INFORMATI
         SERVER_START_REQ( get_directory_entry )
         {
             req->handle = wine_server_obj_handle( handle );
-            req->index = *context;
+            req->index = index;
             wine_server_set_reply( req, buffer + 1, size - sizeof(*buffer) - 2*sizeof(WCHAR) );
             if (!(ret = wine_server_call( req )))
             {
@@ -1125,7 +1124,7 @@ NTSTATUS WINAPI NtQueryDirectoryObject( HANDLE handle, DIRECTORY_BASIC_INFORMATI
                          buffer->ObjectTypeName.Length );
                 buffer->ObjectName.Buffer[buffer->ObjectName.Length/sizeof(WCHAR)] = 0;
                 buffer->ObjectTypeName.Buffer[buffer->ObjectTypeName.Length/sizeof(WCHAR)] = 0;
-                (*context)++;
+                *context = index + 1;
             }
         }
         SERVER_END_REQ;
-- 
2.35.1




More information about the wine-devel mailing list