My Project
Loading...
Searching...
No Matches
ht.h
Go to the documentation of this file.
1/*++
2
3Module Name:
4
5 ht.h
6
7Purpose:
8
9 This module contains the header files & prototypes required for the Handle Table implementation of MatanelOS.
10
11Author:
12
13 slep (Matanel) 2025.
14
15Revision History:
16
17--*/
18
19#ifndef X86_MATANEL_HT_H
20#define X86_MATANEL_HT_H
21
22#include "core.h"
23#include "ms.h"
24
25// --------------- STRUCTURES ---------------
26
27typedef struct _HANDLE_TABLE_ENTRY {
28 union {
29 void* Object; // [USED IF ALLOCATED] Pointer to the Kernel Object
30 uint64_t Value; // Generic value access
31 };
32 union {
33 uint32_t GrantedAccess; // [USED IF ALLOCATED] Access Mask (Read, Write, etc.)
34 uint32_t NextFreeTableEntry; // [USED IF FREE] Index of the next empty slot
35 };
37
38#define LOW_LEVEL_ENTRIES (VirtualPageSize / sizeof(HANDLE_TABLE_ENTRY)) // 256 entries per page
39#define TABLE_LEVEL_MASK 3
40
41typedef struct _HANDLE_TABLE {
42 // Linked list of next table (if any)
45
46 // Storage
47 uint64_t TableCode; // Pointer | Level
49
50 // Free List Logic
52 uint32_t FirstFreeHandle; // Index of first free handle, or 0 if none.
54 uint32_t HandleCount;
56
57// --------------- TYPE DEFINES ---------------
58
59typedef int32_t HANDLE, * PHANDLE;
60
61// --------------- FUNCTIONS ---------------
62
63typedef uint32_t ACCESS_MASK;
64
65void*
67 PHANDLE_TABLE Table,
68 HANDLE Handle,
69 PHANDLE_TABLE_ENTRY* OutEntry
70);
71
72void
74 PHANDLE_TABLE Table,
75 HANDLE Handle
76);
77
80 PHANDLE_TABLE Table,
81 void* Object,
82 uint32_t Access
83);
84
87 IN PEPROCESS Process
88);
89
90void
92 IN PHANDLE_TABLE Table
93);
94
95#endif
#define IN
Definition annotations.h:7
EPROCESS * PEPROCESS
Definition core.h:50
struct _DOUBLY_LINKED_LIST DOUBLY_LINKED_LIST
uint32_t ACCESS_MASK
Definition ht.h:63
void * HtGetObject(PHANDLE_TABLE Table, HANDLE Handle, PHANDLE_TABLE_ENTRY *OutEntry)
Definition handle.c:389
struct _HANDLE_TABLE HANDLE_TABLE
PHANDLE_TABLE HtCreateHandleTable(IN PEPROCESS Process)
Definition handle.c:87
HANDLE HtCreateHandle(PHANDLE_TABLE Table, void *Object, uint32_t Access)
Definition handle.c:269
int32_t * PHANDLE
Definition ht.h:59
struct _HANDLE_TABLE_ENTRY * PHANDLE_TABLE_ENTRY
void HtDeleteHandle(PHANDLE_TABLE Table, HANDLE Handle)
Definition handle.c:333
struct _HANDLE_TABLE * PHANDLE_TABLE
int32_t HANDLE
Definition ht.h:59
void HtDeleteHandleTable(IN PHANDLE_TABLE Table)
Definition handle.c:434
struct _HANDLE_TABLE_ENTRY HANDLE_TABLE_ENTRY
struct _SPINLOCK SPINLOCK
uint32_t NextFreeTableEntry
Definition ht.h:34
void * Object
Definition ht.h:29
uint64_t Value
Definition ht.h:30
uint32_t GrantedAccess
Definition ht.h:33
uint32_t HandleCount
Definition ht.h:54
PHANDLE_TABLE_ENTRY LastFreeHandleEntry
Definition ht.h:51
DOUBLY_LINKED_LIST TableList
Definition ht.h:43
uint32_t NextHandleNeedingPool
Definition ht.h:53
SPINLOCK TableLock
Definition ht.h:44
uint64_t TableCode
Definition ht.h:47
PEPROCESS QuotaProcess
Definition ht.h:48
uint32_t FirstFreeHandle
Definition ht.h:52