41 lines
1.3 KiB
C
41 lines
1.3 KiB
C
#pragma once
|
|
// ob_object.h - executive object model
|
|
// Every resource the kernel tracks is a typed, reference-counted OBJECT.
|
|
// The OBJECT header must be the first member of any derived struct.
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <ntlite/status.h>
|
|
|
|
typedef enum OBJECT_TYPE {
|
|
ObjectTypeProcess = 1,
|
|
ObjectTypeThread = 2,
|
|
ObjectTypeMutex = 3,
|
|
ObjectTypeSemaphore = 4,
|
|
ObjectTypeEvent = 5,
|
|
ObjectTypeQueue = 6,
|
|
ObjectTypeFile = 7,
|
|
ObjectTypeDir = 8,
|
|
ObjectTypeAsyncIo = 9,
|
|
ObjectTypeSocket = 10,
|
|
ObjectTypeDevice = 11,
|
|
ObjectTypeDriver = 12,
|
|
ObjectTypeUsbDevice = 13,
|
|
ObjectTypeUsbPipe = 14,
|
|
} OBJECT_TYPE;
|
|
|
|
typedef struct OBJECT {
|
|
OBJECT_TYPE Type;
|
|
volatile long RefCount; // interlocked
|
|
void (*Destroy)(struct OBJECT* self);
|
|
} OBJECT;
|
|
|
|
// Increment the reference count. Call whenever ownership is shared.
|
|
__declspec(dllexport) void ObReferenceObject(OBJECT* object);
|
|
|
|
// Decrement. Calls Destroy() and frees the object when count reaches zero.
|
|
__declspec(dllexport) void ObDereferenceObject(OBJECT* object);
|
|
|
|
// Allocate a zeroed object of the given size from kernel pool.
|
|
// Caller must fill Type and Destroy before publishing the pointer.
|
|
__declspec(dllexport) OBJECT* ObAllocateObject(OBJECT_TYPE type, size_t size);
|