Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/om.c | 16 +++++++++++++--- dlls/ntoskrnl.exe/tests/driver.c | 4 ++-- server/handle.c | 14 ++++++++++++++ server/object.c | 10 ++++++++++ server/object.h | 1 + server/protocol.def | 6 ++++++ 6 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/om.c b/dlls/ntdll/om.c index 601e6ede123..b2ea815b78f 100644 --- a/dlls/ntdll/om.c +++ b/dlls/ntdll/om.c @@ -511,8 +511,18 @@ NTSTATUS WINAPI NtAllocateUuids( ULARGE_INTEGER *time, ULONG *delta, ULONG *sequ * Success: STATUS_SUCCESS. * Failure: An NTSTATUS error code. */ -NTSTATUS WINAPI NtMakeTemporaryObject( HANDLE Handle ) +NTSTATUS WINAPI NtMakeTemporaryObject( HANDLE handle ) { - FIXME("(%p), stub.\n", Handle); - return STATUS_SUCCESS; + NTSTATUS ret; + + TRACE("%p\n", handle); + + SERVER_START_REQ( make_temporary ) + { + req->handle = wine_server_obj_handle( handle ); + ret = wine_server_call( req ); + } + SERVER_END_REQ; + + return ret; } diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 0ae63ffafb3..0671a56efc7 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -2048,13 +2048,13 @@ 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);
diff --git a/server/handle.c b/server/handle.c index a2a8bb5479c..9ae99cd0c63 100644 --- a/server/handle.c +++ b/server/handle.c @@ -833,3 +833,17 @@ DECL_HANDLER(get_system_handles) enum_processes( enum_handles, &info ); } } + +DECL_HANDLER(make_temporary) +{ + struct object *obj; + + if (!(obj = get_handle_obj( current->process, req->handle, 0, NULL ))) return; + + if (obj->is_permanent) + { + make_object_temporary( obj ); + release_object( obj ); + } + release_object( obj ); +} diff --git a/server/object.c b/server/object.c index 6c0bb9be3ab..8ec6609f69d 100644 --- a/server/object.c +++ b/server/object.c @@ -414,6 +414,16 @@ void make_object_static( struct object *obj ) #endif }
+/* mark an object as no longer static */ +void make_object_temporary( struct object *obj ) +{ + obj->is_permanent = 0; +#ifdef DEBUG_OBJECTS + list_remove( &obj->obj_list ); + list_add_head( &object_list, &obj->obj_list ); +#endif +} + /* grab an object (i.e. increment its refcount) and return the object */ struct object *grab_object( void *ptr ) { diff --git a/server/object.h b/server/object.h index fac35f0984e..1f5c4a5f061 100644 --- a/server/object.h +++ b/server/object.h @@ -144,6 +144,7 @@ extern void *open_named_object( struct object *parent, const struct object_ops * const struct unicode_str *name, unsigned int attributes ); extern void unlink_named_object( struct object *obj ); extern void make_object_static( struct object *obj ); +extern void make_object_temporary( struct object *obj ); extern struct namespace *create_namespace( unsigned int hash_size ); extern void free_kernel_objects( struct object *obj ); /* grab/release_object can take any pointer, but you better make sure */ diff --git a/server/protocol.def b/server/protocol.def index 03e567c3dd4..9c8aec6960b 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1080,6 +1080,12 @@ struct rawinput_device #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
+/* Make an object temporary */ +@REQ(make_temporary) + obj_handle_t handle; /* handle to the object */ +@END + + /* Open a handle to a process */ @REQ(open_process) process_id_t pid; /* process id to open */