Signed-off-by: Derek Lesho dereklesho52@Gmail.com ---
v2: Add test for ObGetObjectType.
dlls/ntoskrnl.exe/ntoskrnl.c | 5 ++--- dlls/ntoskrnl.exe/tests/driver.c | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 4ff4a75972..d84f1250c5 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2914,9 +2914,8 @@ USHORT WINAPI ObGetFilterVersion(void) */ POBJECT_TYPE WINAPI ObGetObjectType(void *object) { - FIXME("stub: %p\n", object); - - return NULL; + struct object_header *header = (struct object_header *)object - 1; + return header->type; }
/*********************************************************************** diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 73d067c2bc..faa3b763bb 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -696,10 +696,12 @@ static void WINAPI thread_proc(void *arg)
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; FILE_OBJECT *file; void *obj1, *obj2; + POBJECT_TYPE obj1_type; UNICODE_STRING pathU; IO_STATUS_BLOCK io; WCHAR *tmp_path; @@ -708,6 +710,9 @@ static void test_ob_reference(const WCHAR *test_path)
static const WCHAR tmpW[] = {'.','t','m','p',0};
+ pObGetObjectType = get_proc_address("ObGetObjectType"); + ok(!!pObGetObjectType, "ObGetObjectType not found\n"); + InitializeObjectAttributes(&attr, NULL, OBJ_KERNEL_HANDLE, NULL, NULL); status = ZwCreateEvent(&event_handle, SYNCHRONIZE, &attr, NotificationEvent, TRUE); ok(!status, "ZwCreateEvent failed: %#x\n", status); @@ -742,6 +747,9 @@ static void test_ob_reference(const WCHAR *test_path) status = ObReferenceObjectByHandle(event_handle, SYNCHRONIZE, NULL, KernelMode, &obj1, NULL); ok(!status, "ObReferenceObjectByHandle failed: %#x\n", status);
+ obj1_type = pObGetObjectType(obj1); + ok(obj1_type == *pExEventObjectType, "ObGetObjectType returned %p\n", obj1_type); + if (sizeof(void *) != 4) /* avoid dealing with fastcall */ { ObfReferenceObject(obj1);