Commit 0c7dcd90 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntdll: Return the required length from NtQueryDirectoryObject().

parent 967ef0bf
......@@ -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 );
......
......@@ -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;
}
......
......@@ -4646,10 +4646,10 @@ struct get_directory_entry_request
struct get_directory_entry_reply
{
struct reply_header __header;
data_size_t total_len;
data_size_t name_len;
/* VARARG(name,unicode_str,name_len); */
/* VARARG(type,unicode_str); */
char __pad_12[4];
};
......@@ -6286,7 +6286,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 749
#define SERVER_PROTOCOL_VERSION 750
/* ### protocol_version end ### */
......
......@@ -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;
......
......@@ -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 */
......
......@@ -2011,7 +2011,8 @@ C_ASSERT( sizeof(struct open_directory_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_directory_entry_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_directory_entry_request, index) == 16 );
C_ASSERT( sizeof(struct get_directory_entry_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_directory_entry_reply, name_len) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_directory_entry_reply, total_len) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_directory_entry_reply, name_len) == 12 );
C_ASSERT( sizeof(struct get_directory_entry_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_symlink_request, access) == 12 );
C_ASSERT( sizeof(struct create_symlink_request) == 16 );
......
......@@ -3978,7 +3978,8 @@ static void dump_get_directory_entry_request( const struct get_directory_entry_r
static void dump_get_directory_entry_reply( const struct get_directory_entry_reply *req )
{
fprintf( stderr, " name_len=%u", req->name_len );
fprintf( stderr, " total_len=%u", req->total_len );
fprintf( stderr, ", name_len=%u", req->name_len );
dump_varargs_unicode_str( ", name=", min(cur_size,req->name_len) );
dump_varargs_unicode_str( ", type=", cur_size );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment