ntoskrnl.exe: Implement ObOpenObjectByPointer.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-04-30 16:36:37 +02:00 committed by Alexandre Julliard
parent 136312e2dc
commit bfe3dfb535
4 changed files with 53 additions and 3 deletions

View File

@ -511,6 +511,40 @@ POBJECT_TYPE WINAPI ObGetObjectType( void *object )
return header->type;
}
/***********************************************************************
* ObOpenObjectByPointer (NTOSKRNL.EXE.@)
*/
NTSTATUS WINAPI ObOpenObjectByPointer( void *obj, ULONG attr, ACCESS_STATE *access_state,
ACCESS_MASK access, POBJECT_TYPE type,
KPROCESSOR_MODE mode, HANDLE *handle )
{
NTSTATUS status;
TRACE( "%p %x %p %x %p %d %p\n", obj, attr, access_state, access, type, mode, handle );
if (mode != KernelMode)
{
FIXME( "UserMode access not implemented\n" );
return STATUS_NOT_IMPLEMENTED;
}
if (attr & ~OBJ_KERNEL_HANDLE) FIXME( "access %x not supported\n", access );
if (access_state) FIXME( "access_state not implemented\n" );
if (type && ObGetObjectType( obj ) != type) return STATUS_OBJECT_TYPE_MISMATCH;
SERVER_START_REQ( get_kernel_object_handle )
{
req->manager = wine_server_obj_handle( get_device_manager() );
req->user_ptr = wine_server_client_ptr( obj );
req->access = access;
if (!(status = wine_server_call( req )))
*handle = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
return status;
}
static void *create_file_object( HANDLE handle );

View File

@ -822,7 +822,7 @@
@ stub ObLogSecurityDescriptor
@ stub ObMakeTemporaryObject
@ stub ObOpenObjectByName
@ stub ObOpenObjectByPointer
@ stdcall ObOpenObjectByPointer(ptr long ptr long ptr long ptr)
@ stdcall ObQueryNameString(ptr ptr long ptr)
@ stub ObQueryObjectAuditingByHandle
@ stdcall ObReferenceObjectByHandle(long long ptr long ptr ptr)

View File

@ -773,7 +773,7 @@ static void test_ob_reference(const WCHAR *test_path)
{
POBJECT_TYPE (WINAPI *pObGetObjectType)(void*);
OBJECT_ATTRIBUTES attr = { sizeof(attr) };
HANDLE event_handle, file_handle, file_handle2, thread_handle;
HANDLE event_handle, file_handle, file_handle2, thread_handle, handle;
DISPATCHER_HEADER *header;
FILE_OBJECT *file;
void *obj1, *obj2;
@ -878,9 +878,24 @@ static void test_ob_reference(const WCHAR *test_path)
status = wait_single(header, 0);
ok(status == 0 || status == STATUS_TIMEOUT, "got %#x\n", status);
ObDereferenceObject(obj1);
ObDereferenceObject(obj2);
status = ObOpenObjectByPointer(obj1, OBJ_KERNEL_HANDLE, NULL, 0, NULL, KernelMode, &handle);
ok(status == STATUS_SUCCESS, "ObOpenObjectByPointer failed: %#x\n", status);
status = ZwClose(handle);
ok(!status, "ZwClose failed: %#x\n", status);
status = ObReferenceObjectByHandle(thread_handle, SYNCHRONIZE, *pPsThreadType, KernelMode, &obj2, NULL);
ok(!status, "ObReferenceObjectByHandle failed: %#x\n", status);
ok(obj1 == obj2, "obj1 != obj2\n");
ObDereferenceObject(obj2);
status = ObOpenObjectByPointer(obj1, OBJ_KERNEL_HANDLE, NULL, 0, *pIoFileObjectType, KernelMode, &handle);
ok(status == STATUS_OBJECT_TYPE_MISMATCH, "ObOpenObjectByPointer returned: %#x\n", status);
ObDereferenceObject(obj1);
status = ZwClose(thread_handle);
ok(!status, "ZwClose failed: %#x\n", status);

View File

@ -130,6 +130,7 @@ typedef struct _FS_FILTER_CALLBACKS
} FS_FILTER_CALLBACKS, *PFS_FILTER_CALLBACKS;
BOOLEAN WINAPI FsRtlIsNameInExpression(PUNICODE_STRING, PUNICODE_STRING, BOOLEAN, PWCH);
NTSTATUS WINAPI ObOpenObjectByPointer(void*,ULONG,PACCESS_STATE,ACCESS_MASK,POBJECT_TYPE,KPROCESSOR_MODE,HANDLE*);
NTSTATUS WINAPI ObQueryNameString(PVOID,POBJECT_NAME_INFORMATION,ULONG,PULONG);
BOOLEAN WINAPI PsIsSystemThread(PETHREAD);
NTSTATUS WINAPI PsLookupProcessByProcessId(HANDLE,PEPROCESS*);