Check the safety to access the memory.
157{
162
163
164
165
166
168 {
169
170
171
173 goto Return;
174 }
175
176
177
178
180
181
182
183
184 OriginalCr3 = __readcr3();
185 __writecr3(GuestCr3.
Flags);
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
229
231 {
232
233
234
235 UINT64 ReadSize = AddressToCheck;
236
237 while (Size != 0)
238 {
240
242 {
243 ReadSize = Size;
244 }
245
247 {
248
249
250
252
253 goto RestoreCr3;
254 }
255
256
257
258
259
260
261
262
263
264
265
266 Size = (
UINT32)(Size - ReadSize);
267 TargetAddress = TargetAddress + ReadSize;
268 }
269 }
270 else
271 {
273 {
274
275
276
278
279 goto RestoreCr3;
280 }
281 }
282
283
284
285
287
288RestoreCr3:
289
290
291
292
293 __writecr3(OriginalCr3);
294
295Return:
296 return Result;
297}
BOOLEAN CheckAddressCanonicality(UINT64 VAddr, PBOOLEAN IsKernelAddress)
Checks if the address is canonical based on x86 processor's virtual address width or not.
Definition AddressCheck.c:66
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned int UINT32
Definition BasicTypes.h:48
char CHAR
Definition BasicTypes.h:31
CR3_TYPE LayoutGetCurrentProcessCr3()
Get cr3 of the target running process.
Definition Layout.c:55
_Use_decl_annotations_ BOOLEAN MemoryMapperCheckIfPageIsPresentByCr3(PVOID Va, CR3_TYPE TargetCr3)
This function checks if the page is mapped or not.
Definition MemoryMapper.c:418
CR3 Structure.
Definition BasicTypes.h:130
UINT64 Flags
Definition BasicTypes.h:133