This function gets virtual address and returns its PTE of the virtual address based on the specific cr3 but without switching to the target address.
the TargetCr3 should be kernel cr3 as we will use it to translate kernel addresses so the kernel functions to translate addresses should be mapped; thus, don't pass a KPTI meltdown user cr3 to this function
30{
32 UINT64 TempCr3;
33 PUINT64 Cr3Va;
34 PUINT64 PdptVa;
35 PUINT64 PdVa;
36 PUINT64 PtVa;
39
40
41
42
44
46
47
48
49
51
53
54 if (EptPmlEntry4 != NULL)
55 {
56 if (IsLargePage)
57 {
60 }
61 else
62 {
65 }
66 }
67 else
68 {
70 }
71
72
73
74
76
77
78
79
80 if (Cr3Va == NULL)
81 {
82
83
84
86
88 }
89
90 for (SIZE_T i = 0; i < 512; i++)
91 {
92
93
95
97 {
98
99
102
103 if (EptPmlEntry4 != NULL)
104 {
105 if (IsLargePage)
106 {
109 }
110 else
111 {
114 }
115 }
116 else
117 {
119 }
120
122
123
124
125
126 if (PdptVa != NULL)
127 {
128 for (SIZE_T j = 0; j < 512; j++)
129 {
130
131
133
135 {
136
137
140
141 if (EptPmlEntry3 != NULL)
142 {
143 if (IsLargePage)
144 {
147 }
148 else
149 {
152 }
153 }
154 else
155 {
157 }
158
160 {
161 continue;
162 }
163
165
166
167
168
169 if (PdVa != NULL)
170 {
171 for (SIZE_T k = 0; k < 512; k++)
172 {
173
174
175 if (PdVa == (PUINT64)0xfffffffffffffe00)
176 {
177 continue;
178 }
179
181
183 {
184
185
188
189 if (EptPmlEntry2 != NULL)
190 {
191 if (IsLargePage)
192 {
195 }
196 else
197 {
200 }
201 }
202 else
203 {
205 }
206
208 {
209 continue;
210 }
211
213
214
215
216
217 if (PtVa != NULL)
218 {
219 for (SIZE_T l = 0; l < 512; l++)
220 {
221
222
223
224
225
226
227
228
229 }
230 }
231 }
232 }
233 }
234 }
235 }
236 }
237 }
238 }
239
240
241
242
244
246}
PVOID EptGetPml1OrPml2Entry(PVMM_EPT_PAGE_TABLE EptPageTable, SIZE_T PhysicalAddress, BOOLEAN *IsLargePage)
Get the PML1 entry for this physical address if the large page is available then large page of Pml2 i...
Definition Ept.c:394
struct _PAGE_ENTRY PAGE_ENTRY
Page Entries.
struct _PAGE_ENTRY * PPAGE_ENTRY
IMPORT_EXPORT_VMM VOID SwitchToPreviousProcess(_In_ CR3_TYPE PreviousProcess)
IMPORT_EXPORT_VMM UINT64 PhysicalAddressToVirtualAddress(_In_ UINT64 PhysicalAddress)
IMPORT_EXPORT_VMM CR3_TYPE SwitchToProcessMemoryLayoutByCr3(_In_ CR3_TYPE TargetCr3)
UINT64 Flags
Definition BasicTypes.h:239
UINT64 PageFrameNumber
Definition BasicTypes.h:244
struct _CR3_TYPE::@244034060255073137115274324157111341233214336223::@234224113264105317012146222243166211041242274101 Fields
UINT64 LargePage
Definition MemoryMapper.h:88
UINT64 Present
Definition MemoryMapper.h:81
struct _PAGE_ENTRY::@376376202121063303120064260270315140365371076130::@103064255274005116234107103217043340214273361203 Fields
UINT64 PageFrameNumber
Definition MemoryMapper.h:91