ntoskrnl.exe: Use ObOpenObjectByPointer to get handle for kernel object.

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:48 +02:00 committed by Alexandre Julliard
parent bfe3dfb535
commit 332035fb94
3 changed files with 10 additions and 21 deletions

View file

@ -366,20 +366,6 @@ static void ObReferenceObject( void *obj )
LeaveCriticalSection( &obref_cs );
}
HANDLE kernel_object_handle( void *obj, unsigned int access )
{
HANDLE handle = NULL;
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 (!wine_server_call( req )) handle = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
return handle;
}
static const POBJECT_TYPE *known_types[] =
{
&ExEventObjectType,
@ -1870,9 +1856,12 @@ NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROP
OBJECT_NAME_INFORMATION *name = HeapAlloc(GetProcessHeap(), 0, len);
HANDLE handle;
handle = kernel_object_handle( device, 0 );
status = NtQueryObject( handle, ObjectNameInformation, name, len, &used_len );
NtClose( handle );
status = ObOpenObjectByPointer( device, OBJ_KERNEL_HANDLE, NULL, 0, NULL, KernelMode, &handle );
if (!status)
{
status = NtQueryObject( handle, ObjectNameInformation, name, len, &used_len );
NtClose( handle );
}
if (status == STATUS_SUCCESS)
{
/* Ensure room for NULL termination */

View file

@ -47,7 +47,6 @@ struct _ETHREAD
};
void *alloc_kernel_object( POBJECT_TYPE type, HANDLE handle, SIZE_T size, LONG ref ) DECLSPEC_HIDDEN;
HANDLE kernel_object_handle( void *obj, unsigned int access ) DECLSPEC_HIDDEN;
NTSTATUS kernel_object_from_handle( HANDLE handle, POBJECT_TYPE type, void **ret ) DECLSPEC_HIDDEN;
extern POBJECT_TYPE ExEventObjectType;

View file

@ -29,6 +29,7 @@
#include "winternl.h"
#include "ddk/ntddk.h"
#include "ddk/wdm.h"
#include "ddk/ntifs.h"
#include "wine/debug.h"
#include "wine/heap.h"
@ -80,7 +81,7 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
{
if (objs[i]->WaitListHead.Blink == INVALID_HANDLE_VALUE)
{
handles[i] = kernel_object_handle( objs[i], SYNCHRONIZE );
ObOpenObjectByPointer( objs[i], OBJ_KERNEL_HANDLE, NULL, SYNCHRONIZE, NULL, KernelMode, &handles[i] );
continue;
}
@ -266,7 +267,7 @@ LONG WINAPI KeSetEvent( PRKEVENT event, KPRIORITY increment, BOOLEAN wait )
}
else
{
if ((handle = kernel_object_handle( event, EVENT_MODIFY_STATE )))
if (!ObOpenObjectByPointer( event, OBJ_KERNEL_HANDLE, NULL, EVENT_MODIFY_STATE, NULL, KernelMode, &handle ))
{
NtSetEvent( handle, &ret );
NtClose( handle );
@ -297,7 +298,7 @@ LONG WINAPI KeResetEvent( PRKEVENT event )
}
else
{
if ((handle = kernel_object_handle( event, EVENT_MODIFY_STATE )))
if (!ObOpenObjectByPointer( event, OBJ_KERNEL_HANDLE, NULL, EVENT_MODIFY_STATE, NULL, KernelMode, &handle ))
{
NtResetEvent( handle, &ret );
NtClose( handle );