Process Hacker
refp.h File Reference

Go to the source code of this file.

Data Structures

struct  _PH_OBJECT_HEADER
 The object header contains object manager information including the reference count of an object and its type. More...
 
struct  _PH_OBJECT_TYPE
 An object type specifies a kind of object and its delete procedure. More...
 

Macros

#define PH_OBJECT_TYPE_TABLE_SIZE   256
 
#define PH_OBJECT_FROM_SMALL_FREE_LIST   0x1
 The object was allocated from the small free list.
 
#define PH_OBJECT_FROM_TYPE_FREE_LIST   0x2
 The object was allocated from the type free list.
 
#define PhObjectToObjectHeader(Object)   ((PPH_OBJECT_HEADER)CONTAINING_RECORD((PCHAR)(Object), PH_OBJECT_HEADER, Body))
 Gets a pointer to the object header for an object.
 
#define PhObjectHeaderToObject(ObjectHeader)   ((PVOID)&((PPH_OBJECT_HEADER)(ObjectHeader))->Body)
 Gets a pointer to an object from an object header.
 
#define PhAddObjectHeaderSize(Size)   ((Size) + FIELD_OFFSET(PH_OBJECT_HEADER, Body))
 Calculates the total size to allocate for an object.
 

Typedefs

typedef struct _PH_OBJECT_HEADER PH_OBJECT_HEADER
 The object header contains object manager information including the reference count of an object and its type.
 
typedef struct _PH_OBJECT_HEADERPPH_OBJECT_HEADER
 
typedef struct _PH_OBJECT_TYPE PH_OBJECT_TYPE
 An object type specifies a kind of object and its delete procedure.
 
typedef struct _PH_OBJECT_TYPEPPH_OBJECT_TYPE
 

Functions

 C_ASSERT (FIELD_OFFSET(PH_OBJECT_HEADER, RefCount)==0x0)
 
 C_ASSERT (FIELD_OFFSET(PH_OBJECT_HEADER, DeferDeleteListEntry)==0x0)
 
 C_ASSERT (FIELD_OFFSET(PH_OBJECT_HEADER, TypeIndex)==0x4)
 
 C_ASSERT (FIELD_OFFSET(PH_OBJECT_HEADER, Flags)==0x6)
 
 C_ASSERT (FIELD_OFFSET(PH_OBJECT_HEADER, Reserved1)==0x7)
 
 C_ASSERT (FIELD_OFFSET(PH_OBJECT_HEADER, Body)==0x8)
 
FORCEINLINE BOOLEAN PhpInterlockedIncrementSafe (_Inout_ PLONG RefCount)
 Increments a reference count, but will never increment from 0 to 1.
 
PPH_OBJECT_HEADER PhpAllocateObject (_In_ PPH_OBJECT_TYPE ObjectType, _In_ SIZE_T ObjectSize)
 Allocates storage for an object.
 
VOID PhpFreeObject (_In_ PPH_OBJECT_HEADER ObjectHeader)
 Calls the delete procedure for an object and frees its allocated storage.
 
VOID PhpDeferDeleteObject (_In_ PPH_OBJECT_HEADER ObjectHeader)
 Queues an object for deletion.
 
NTSTATUS PhpDeferDeleteObjectRoutine (_In_ PVOID Parameter)
 Removes and frees objects from the to-free list.
 

Macro Definition Documentation

#define PH_OBJECT_FROM_SMALL_FREE_LIST   0x1

The object was allocated from the small free list.

Definition at line 29 of file refp.h.

#define PH_OBJECT_FROM_TYPE_FREE_LIST   0x2

The object was allocated from the type free list.

Definition at line 31 of file refp.h.

#define PH_OBJECT_TYPE_TABLE_SIZE   256

Definition at line 26 of file refp.h.

#define PhAddObjectHeaderSize (   Size)    ((Size) + FIELD_OFFSET(PH_OBJECT_HEADER, Body))

Calculates the total size to allocate for an object.

Parameters
SizeThe size of the object to allocate.
Returns
The new size, including space for the object header.

Definition at line 112 of file refp.h.

#define PhObjectHeaderToObject (   ObjectHeader)    ((PVOID)&((PPH_OBJECT_HEADER)(ObjectHeader))->Body)

Gets a pointer to an object from an object header.

Parameters
ObjectHeaderA pointer to an object header.
Returns
A pointer to an object.

Definition at line 103 of file refp.h.

#define PhObjectToObjectHeader (   Object)    ((PPH_OBJECT_HEADER)CONTAINING_RECORD((PCHAR)(Object), PH_OBJECT_HEADER, Body))

Gets a pointer to the object header for an object.

Parameters
ObjectA pointer to an object.
Returns
A pointer to the object header of the object.

Definition at line 94 of file refp.h.

Typedef Documentation

The object header contains object manager information including the reference count of an object and its type.

An object type specifies a kind of object and its delete procedure.

typedef struct _PH_OBJECT_TYPE * PPH_OBJECT_TYPE

Function Documentation

C_ASSERT ( FIELD_OFFSET(PH_OBJECT_HEADER, RefCount)  = =0x0)
C_ASSERT ( FIELD_OFFSET(PH_OBJECT_HEADER, DeferDeleteListEntry)  = =0x0)
C_ASSERT ( FIELD_OFFSET(PH_OBJECT_HEADER, TypeIndex)  = =0x4)
C_ASSERT ( FIELD_OFFSET(PH_OBJECT_HEADER, Flags)  = =0x6)
C_ASSERT ( FIELD_OFFSET(PH_OBJECT_HEADER, Reserved1)  = =0x7)
C_ASSERT ( FIELD_OFFSET(PH_OBJECT_HEADER, Body)  = =0x8)
PPH_OBJECT_HEADER PhpAllocateObject ( _In_ PPH_OBJECT_TYPE  ObjectType,
_In_ SIZE_T  ObjectSize 
)

Allocates storage for an object.

Parameters
ObjectTypeThe type of the object.
ObjectSizeThe size of the object, excluding the header.

Definition at line 450 of file ref.c.

VOID PhpDeferDeleteObject ( _In_ PPH_OBJECT_HEADER  ObjectHeader)

Queues an object for deletion.

Parameters
ObjectHeaderA pointer to the object header of the object to delete.

Definition at line 535 of file ref.c.

NTSTATUS PhpDeferDeleteObjectRoutine ( _In_ PVOID  Parameter)

Removes and frees objects from the to-free list.

Definition at line 555 of file ref.c.

VOID PhpFreeObject ( _In_ PPH_OBJECT_HEADER  ObjectHeader)

Calls the delete procedure for an object and frees its allocated storage.

Parameters
ObjectHeaderA pointer to the object header of an allocated object.

Definition at line 487 of file ref.c.

FORCEINLINE BOOLEAN PhpInterlockedIncrementSafe ( _Inout_ PLONG  RefCount)

Increments a reference count, but will never increment from 0 to 1.

Parameters
RefCountA pointer to a reference count.

Definition at line 142 of file refp.h.