kernel
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
66void*
68 IN PHANDLE_TABLE Table,
69 IN HANDLE Handle,
71);
72
75 IN HANDLE Handle
76);
77
78void
80 PHANDLE_TABLE Table,
81 HANDLE Handle
82);
83
86 PHANDLE_TABLE Table,
87 void* Object,
88 uint32_t Access
89);
90
93 IN PEPROCESS Process
94);
95
96void
98 IN PHANDLE_TABLE Table
99);
100
101#endif
#define _Out_Opt
Definition annotations.h:11
#define IN
Definition annotations.h:8
#define MUST_USE_RESULT
Definition annotations.h:42
uint32_t ACCESS_MASK
Definition core.h:59
int32_t * PHANDLE
Definition core.h:58
int32_t HANDLE
Definition core.h:58
EPROCESS * PEPROCESS
Definition core.h:52
struct _DOUBLY_LINKED_LIST DOUBLY_LINKED_LIST
struct _HANDLE_TABLE HANDLE_TABLE
PHANDLE_TABLE HtCreateHandleTable(IN PEPROCESS Process)
Definition handle.c:90
HANDLE HtCreateHandle(PHANDLE_TABLE Table, void *Object, uint32_t Access)
Definition handle.c:277
struct _HANDLE_TABLE_ENTRY * PHANDLE_TABLE_ENTRY
void HtDeleteHandle(PHANDLE_TABLE Table, HANDLE Handle)
Definition handle.c:342
MTSTATUS HtClose(IN HANDLE Handle)
Definition handle.c:536
struct _HANDLE_TABLE * PHANDLE_TABLE
MUST_USE_RESULT void * HtGetObject(IN PHANDLE_TABLE Table, IN HANDLE Handle, _Out_Opt PHANDLE_TABLE_ENTRY *OutEntry)
Definition handle.c:397
void HtDeleteHandleTable(IN PHANDLE_TABLE Table)
Definition handle.c:442
struct _HANDLE_TABLE_ENTRY HANDLE_TABLE_ENTRY
struct _PUSH_LOCK PUSH_LOCK
int32_t MTSTATUS
Definition mtstatus.h:12
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
PUSH_LOCK 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