server: Implement OBJ_PERMANENT.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-07-15 20:27:54 -05:00 committed by Alexandre Julliard
parent 26c8fb8ce7
commit c7032e9222
3 changed files with 16 additions and 8 deletions

View File

@ -2048,28 +2048,28 @@ static void test_permanence(void)
attr.Attributes = 0;
status = ZwOpenDirectoryObject( &handle, 0, &attr );
todo_wine ok(!status, "got %#x\n", status);
ok(!status, "got %#x\n", status);
status = ZwMakeTemporaryObject( handle );
ok(!status, "got %#x\n", status);
status = ZwMakeTemporaryObject( handle );
ok(!status, "got %#x\n", status);
status = ZwClose( handle );
todo_wine ok(!status, "got %#x\n", status);
ok(!status, "got %#x\n", status);
status = ZwOpenDirectoryObject( &handle, 0, &attr );
ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", status);
todo_wine ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", status);
status = ZwCreateDirectoryObject( &handle, GENERIC_ALL, &attr );
ok(!status, "got %#x\n", status);
todo_wine ok(!status, "got %#x\n", status);
attr.Attributes = OBJ_PERMANENT;
status = ZwOpenDirectoryObject( &handle2, 0, &attr );
ok(status == STATUS_SUCCESS, "got %#x\n", status);
status = ZwClose( handle2 );
ok(!status, "got %#x\n", status);
status = ZwClose( handle );
ok(!status, "got %#x\n", status);
todo_wine ok(!status, "got %#x\n", status);
attr.Attributes = 0;
status = ZwOpenDirectoryObject( &handle, 0, &attr );
ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", status);
todo_wine ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", status);
}
static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack)

View File

@ -278,7 +278,8 @@ data_size_t get_path_element( const WCHAR *name, data_size_t len )
}
static struct object *create_object( struct object *parent, const struct object_ops *ops,
const struct unicode_str *name, const struct security_descriptor *sd )
const struct unicode_str *name, unsigned int attributes,
const struct security_descriptor *sd )
{
struct object *obj;
struct object_name *name_ptr;
@ -292,6 +293,11 @@ static struct object *create_object( struct object *parent, const struct object_
name_ptr->obj = obj;
obj->name = name_ptr;
if (attributes & OBJ_PERMANENT)
{
make_object_static( obj );
grab_object( obj );
}
return obj;
failed:
@ -340,7 +346,7 @@ void *create_named_object( struct object *parent, const struct object_ops *ops,
return obj;
}
new_obj = create_object( obj, ops, &new_name, sd );
new_obj = create_object( obj, ops, &new_name, attributes, sd );
release_object( obj );
return new_obj;
}
@ -401,6 +407,7 @@ void unlink_named_object( struct object *obj )
/* mark an object as being stored statically, i.e. only released at shutdown */
void make_object_static( struct object *obj )
{
obj->is_permanent = 1;
#ifdef DEBUG_OBJECTS
list_remove( &obj->obj_list );
list_add_head( &static_object_list, &obj->obj_list );

View File

@ -105,6 +105,7 @@ struct object
struct list wait_queue;
struct object_name *name;
struct security_descriptor *sd;
unsigned int is_permanent:1;
#ifdef DEBUG_OBJECTS
struct list obj_list;
#endif