kernel
Loading...
Searching...
No Matches
cid.c
Go to the documentation of this file.
1/*++
2
3Module Name:
4
5 cid.c
6
7Purpose:
8
9 This translation unit contains the implementation of client IDS of processes and threads. (PID/TID)
10
11Author:
12
13 slep (Matanel) 2025.
14
15Revision History:
16
17--*/
18
19#include "../../includes/ps.h"
20#include "../../includes/ob.h"
21#include "../../includes/ht.h"
22#include "../../assert.h"
23
24PHANDLE_TABLE PspCidTable = NULL; // The main table.
25
26void
28 void
29)
30
31/*++
32
33 Routine description:
34
35 Initializes the CID Table.
36
37 Arguments:
38
39 None.
40
41 Return Values:
42
43 None, on failure it bugchecks.
44
45 Notes:
46
47 This player is ban evading, check his CID (by ascendz).
48
49--*/
50
51{
54
55 // Claim the first handle, HANDLE 4 (pid) is the PID of the SystemProcess, it must not be used.
57}
58
61 IN PEPROCESS Process
62)
63
64/*++
65
66 Routine description:
67
68 Creates a PID for the specified Process.
69
70 Arguments:
71
72 [IN] PEPROCESS Process - The process to create the PID for.
73
74 Return Values:
75
76 The HANDLE (pid) for the process, or MT_INVALID_HANDLE on failure.
77
78--*/
79
80{
81 // Basically, return the handle from the PspCidTable.
82 // The PID/TID is a NULL access, it is only used to identify a process
83 // But to NOT authenticate it, routines like MtOpenProcess (future) would check the HANDLE of a process itself
84 // (e.g PspCreateProcess returns it), but not the PID, dumbo bumbo.
85 return HtCreateHandle(PspCidTable, (void*)Process, 0);
86}
87
90 IN PETHREAD Thread
91)
92
93/*++
94
95 Routine description:
96
97 Creates a TID for the specified thread.
98
99 Arguments:
100
101 [IN] PETHREAD Thread - The thread to create the TID for.
102
103 Return Values:
104
105 The HANDLE (tid) for the thread, or MT_INVALID_HANDLE on failure.
106
107--*/
108
109{
110 return HtCreateHandle(PspCidTable, (void*)Thread, 0);
111}
112
115 IN HANDLE ProcessId
116)
117
118/*++
119
120 Routine description:
121
122 Finds the process associated with the PID given.
123
124 Arguments:
125
126 [IN] HANDLE ProcessId - The PID of the process.
127
128 Return Values:
129
130 Pointer to Process associated with the PID, or NULL if none.
131
132--*/
133
134{
135 return HtGetObject(PspCidTable, ProcessId, NULL);
136}
137
140 IN HANDLE ThreadId
141)
142
143/*++
144
145 Routine description:
146
147 Finds the thread associated with the TID given.
148
149 Arguments:
150
151 [IN] HANDLE ThreadId - The TID of the thread.
152
153 Return Values:
154
155 Pointer to Thread associated with the TID, or NULL if none.
156
157--*/
158
159{
160 return HtGetObject(PspCidTable, ThreadId, NULL);
161}
162
163void
165 IN HANDLE Cid
166)
167
168/*++
169
170 Routine description:
171
172 Frees the CID (PID,TID)
173
174 Arguments:
175
176 [IN] HANDLE Cid - CID Allocated.
177
178 Return Values:
179
180 None.
181
182--*/
183
184{
186}
#define IN
Definition annotations.h:8
NORETURN void MeBugCheck(IN enum _BUGCHECK_CODES BugCheckCode)
Definition bugcheck.c:220
void PsInitializeCidTable(void)
Definition cid.c:27
PETHREAD PsLookupThreadByThreadId(IN HANDLE ThreadId)
Definition cid.c:139
HANDLE PsAllocateThreadId(IN PETHREAD Thread)
Definition cid.c:89
PHANDLE_TABLE PspCidTable
Definition cid.c:24
PEPROCESS PsLookupProcessByProcessId(IN HANDLE ProcessId)
Definition cid.c:114
HANDLE PsAllocateProcessId(IN PEPROCESS Process)
Definition cid.c:60
void PsFreeCid(IN HANDLE Cid)
Definition cid.c:164
int32_t HANDLE
Definition core.h:58
EPROCESS * PEPROCESS
Definition core.h:52
ETHREAD * PETHREAD
Definition core.h:44
PHANDLE_TABLE HtCreateHandleTable(IN PEPROCESS Process)
Definition handle.c:90
HANDLE HtCreateHandle(PHANDLE_TABLE Table, void *Object, uint32_t Access)
Definition handle.c:277
void HtDeleteHandle(PHANDLE_TABLE Table, HANDLE Handle)
Definition handle.c:342
void * HtGetObject(IN PHANDLE_TABLE Table, IN HANDLE Handle, _Out_Opt PHANDLE_TABLE_ENTRY *OutEntry)
Definition handle.c:397
struct _HANDLE_TABLE * PHANDLE_TABLE
@ CID_TABLE_NULL
Definition me.h:133
#define MT_PROCESS_ALL_ACCESS
Definition ps.h:89
EPROCESS PsInitialSystemProcess
Definition kernel.c:165