#ifndef _NTOBAPI_H
//
// Objects, handles
//
#if (PHNT_MODE != PHNT_MODE_KERNEL)
#if (PHNT_VERSION >= PHNT_WINDOWS_10)
/**
* Compares two object handles to determine if they refer to the same underlying kernel object.
*
* \param FirstObjectHandle The first object handle to compare.
* \param SecondObjectHandle The second object handle to compare.
* \return STATUS_SUCCESS for the same object, STATUS_NOT_SAME_OBJECT for different objects, or a handle-reference error.
* \sa https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-compareobjecthandles
* \remarks Neither handle needs a particular access mask. The comparison uses object identity,
* not handle values, names, or matching object types; distinct objects return
* STATUS_NOT_SAME_OBJECT (0xC00001AC).
*/
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCompareObjects(
_In_ HANDLE FirstObjectHandle,
_In_ HANDLE SecondObjectHandle
);
View code on GitHub#ifndef _NTZWAPI_H
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwCompareObjects(
_In_ HANDLE FirstObjectHandle,
_In_ HANDLE SecondObjectHandle
);
View code on GitHubDetermines whether two handles point to the same kernel object.
FirstObjectHandle - a handle to the first object.SecondObjectHandle - a handle to the second object.The handles do not need to grant any specific access. Any of the handles can be a pseudo-handle to the current thread (NtCurrentThread) or the current process (NtCurrentProcess).
STATUS_SUCCESS - the two handles point to the same underlying kernel object.STATUS_NOT_SAME_OBJECT - the handles point toward different objects.This function was introduced in Windows 10 TH1 (1507).