ntdll: Do not write the "context" parameter of NtQueryDirectoryObject on failure.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-04-10 23:29:49 -05:00 committed by Alexandre Julliard
parent 7a5c26f7f2
commit 07d93d9f68
2 changed files with 9 additions and 10 deletions

View File

@ -2531,14 +2531,14 @@ static void test_query_directory(void)
size = 0xdeadbeef;
status = NtQueryDirectoryObject( dir, info, 0, TRUE, TRUE, &context, &size );
todo_wine ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
todo_wine ok( context == 0xdeadbeef, "got context %#lx\n", context );
ok( context == 0xdeadbeef, "got context %#lx\n", context );
todo_wine ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
context = 0xdeadbeef;
size = 0xdeadbeef;
status = NtQueryDirectoryObject( dir, info, 0, FALSE, TRUE, &context, &size );
todo_wine ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
todo_wine ok( context == 0xdeadbeef, "got context %#lx\n", context );
ok( context == 0xdeadbeef, "got context %#lx\n", context );
todo_wine ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
context = 0xdeadbeef;
@ -2546,7 +2546,7 @@ static void test_query_directory(void)
memset( buffer, 0xcc, sizeof(buffer) );
status = NtQueryDirectoryObject( dir, info, sizeof(buffer), TRUE, TRUE, &context, &size );
ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
todo_wine ok( context == 0xdeadbeef, "got context %#lx\n", context );
ok( context == 0xdeadbeef, "got context %#lx\n", context );
todo_wine ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
if (size == sizeof(*info))
ok( !memcmp( &info[0], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
@ -2556,7 +2556,7 @@ static void test_query_directory(void)
memset( buffer, 0xcc, sizeof(buffer) );
status = NtQueryDirectoryObject( dir, info, sizeof(buffer), FALSE, TRUE, &context, &size );
todo_wine ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
todo_wine ok( context == 0xdeadbeef, "got context %#lx\n", context );
ok( context == 0xdeadbeef, "got context %#lx\n", context );
todo_wine ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
if (size == sizeof(*info))
ok( !memcmp( &info[0], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
@ -2573,7 +2573,7 @@ static void test_query_directory(void)
size = 0xdeadbeef;
status = NtQueryDirectoryObject( NULL, info, sizeof(buffer), TRUE, TRUE, &context, &size );
ok( status == STATUS_INVALID_HANDLE, "got %#lx\n", status );
todo_wine ok( context == 0xdeadbeef, "got context %#lx\n", context );
ok( context == 0xdeadbeef, "got context %#lx\n", context );
todo_wine ok( size == 0xdeadbeef || broken(!size) /* WoW64 */, "got size %lu\n", size);
size = 0xdeadbeef;
@ -2631,7 +2631,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 %#lx\n", status );
todo_wine ok( context == 0xdeadbeef, "got context %#lx\n", context );
ok( context == 0xdeadbeef, "got context %#lx\n", context );
todo_wine ok( size == needed_size, "expected size %lu, got %lu\n", needed_size, size );
size = 0xdeadbeef;

View File

@ -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;