Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/tests/om.c | 2 +- dlls/ntdll/unix/sync.c | 6 +++--- server/directory.c | 6 ++++-- server/protocol.def | 1 + 4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c index 91eb2919cb6..7d7b4b09e73 100644 --- a/dlls/ntdll/tests/om.c +++ b/dlls/ntdll/tests/om.c @@ -2638,7 +2638,7 @@ static void test_query_directory(void) memset( buffer, 0xcc, sizeof(buffer) ); status = NtQueryDirectoryObject( dir, info, needed_size - 1, TRUE, TRUE, &context, &size ); ok( status == STATUS_BUFFER_TOO_SMALL, "got %#lx\n", status ); - todo_wine ok( size == needed_size, "expected size %lu, got %lu\n", needed_size, size ); + ok( size == needed_size, "expected size %lu, got %lu\n", needed_size, size );
status = NtQueryDirectoryObject( dir, info, sizeof(buffer), TRUE, TRUE, &context, NULL ); ok( !status, "got %#lx\n", status ); diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index e1cc2d818b4..46facdd2b0e 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -1125,10 +1125,10 @@ NTSTATUS WINAPI NtQueryDirectoryObject( HANDLE handle, DIRECTORY_BASIC_INFORMATI buffer->ObjectName.Buffer[buffer->ObjectName.Length/sizeof(WCHAR)] = 0; buffer->ObjectTypeName.Buffer[buffer->ObjectTypeName.Length/sizeof(WCHAR)] = 0; *context = index + 1; - - if (ret_size) - *ret_size = buffer->ObjectName.MaximumLength + buffer->ObjectTypeName.MaximumLength + sizeof(*buffer); } + + if (ret_size && (!ret || ret == STATUS_BUFFER_TOO_SMALL)) + *ret_size = sizeof(*buffer) + reply->total_len + 2 * sizeof(WCHAR); } SERVER_END_REQ; } diff --git a/server/directory.c b/server/directory.c index caaf8c43d33..23d7eb0a2b7 100644 --- a/server/directory.c +++ b/server/directory.c @@ -546,9 +546,11 @@ DECL_HANDLER(get_directory_entry) const struct unicode_str *type_name = &obj->ops->type->name; const WCHAR *name = get_object_name( obj, &name_len );
- if (name_len + type_name->len <= get_reply_max_size()) + reply->total_len = name_len + type_name->len; + + if (reply->total_len <= get_reply_max_size()) { - void *ptr = set_reply_data_size( name_len + type_name->len ); + void *ptr = set_reply_data_size( reply->total_len ); if (ptr) { reply->name_len = name_len; diff --git a/server/protocol.def b/server/protocol.def index d9bed6855e9..9b7b99ae86a 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -3275,6 +3275,7 @@ struct handle_info obj_handle_t handle; /* handle to the directory */ unsigned int index; /* entry index */ @REPLY + data_size_t total_len; /* total length needed for strings */ data_size_t name_len; /* length of the entry name in bytes */ VARARG(name,unicode_str,name_len); /* entry name */ VARARG(type,unicode_str); /* entry type */