NtMakeTemporaryObject - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTOBAPI_H
//
// Objects, handles
//
#if (PHNT_MODE != PHNT_MODE_KERNEL)

/**
 * The NtMakeTemporaryObject routine changes the attributes of an object to make it temporary.
 *
 * @param Handle Handle to an object of any type.
 * @return NTSTATUS Successful or errant status.
 * @sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-zwmaketemporaryobject
 */
NTSYSCALLAPI
NTSTATUS
NTAPI
NtMakeTemporaryObject(
    _In_ HANDLE Handle
    );

#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwMakeTemporaryObject(
    _In_ HANDLE Handle
    );

#endif

View code on GitHub
// wdm.h

NTSYSAPI NTSTATUS ZwMakeTemporaryObject(
  [in] HANDLE Handle
);

View the official Windows Driver Kit DDI reference

NtDoc

Removes the permanent flag from the object, restoring its lifetime to be dependant on the number of handles. This function is documented in Windows Driver Kit.

Parameters

Remarks

This function undoes the effects of NtMakePermanentObject and specifying OBJ_PERMANENT in OBJECT_ATTRIBUTES.

See also

Windows Driver Kit DDI reference (nf-wdm-zwmaketemporaryobject)

Description

The ZwMakeTemporaryObject routine changes the attributes of an object to make it temporary.

Parameters

Handle [in]

Handle to an object of any type.

Return value

ZwMakeTemporaryObject returns STATUS_SUCCESS on success, or the appropriate NTSTATUS error code on failure.

Remarks

ZwMakeTemporaryObject is a generic routine that operates on any type of object.

An object is permanent if it was created with the OBJ_PERMANENT object attribute specified. (For more information about object attributes, see InitializeObjectAttributes.) A permanent object is created with a reference count of 1, so it is not deleted when a driver dereferences it.

An object is temporary if it is not permanent. ZwMakeTemporaryObject turns the specified object into a temporary object. If the object is already temporary, this routine does nothing.

A temporary object has a name only as long as its handle count is greater than zero. When the handle count reaches zero, the system deletes the object name and appropriately adjusts the object's pointer count.

If the call to this function occurs in user mode, you should use the name "NtMakeTemporaryObject" instead of "ZwMakeTemporaryObject".

For calls from kernel-mode drivers, the NtXxx and ZwXxx versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the NtXxx and ZwXxx versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.

See also

InitializeObjectAttributes

Using Nt and Zw Versions of the Native System Services Routines

ZwClose

ZwCreateDirectoryObject

ZwCreateFile


NTinternals.net (undocumented.ntinternals.net)

This function is documented in Windows Driver Kit.


(Also available in Win2000 DDK)

Function clears object's PERMANENT flag, so it's live as long as the latest HANDLE is closed.

ObjectHandle

HANDLE to object to make temporary.

Documented by

See also