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{
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}
unsigned __int64 * PUINT64
Definition BasicTypes.h:21
_Use_decl_annotations_ UINT64 PhysicalAddressToVirtualAddress(UINT64 PhysicalAddress)
Converts Physical Address to Virtual Address.
Definition Conversion.c:22
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:368
_Use_decl_annotations_ VOID SwitchToPreviousProcess(CR3_TYPE PreviousProcess)
Switch to previous process's cr3.
Definition SwitchLayout.c:125
_Use_decl_annotations_ CR3_TYPE SwitchToProcessMemoryLayoutByCr3(CR3_TYPE TargetCr3)
Switch to another process's cr3.
Definition SwitchLayout.c:99
CR3 Structure.
Definition BasicTypes.h:130
UINT64 Flags
Definition BasicTypes.h:133
struct _CR3_TYPE::@56::@58 Fields
UINT64 PageFrameNumber
Definition BasicTypes.h:138
Page Entries.
Definition MemoryMapper.h:61
UINT64 LargePage
Definition MemoryMapper.h:86
struct _PAGE_ENTRY::@2::@4 Fields
UINT64 Present
Definition MemoryMapper.h:79
UINT64 PageFrameNumber
Definition MemoryMapper.h:89