MCPcopy Create free account
hub / github.com/HoShiMin/Kernel-Bridge / IsMemoryRangePresent

Function IsMemoryRangePresent

Kernel-Bridge/API/PteUtils.cpp:294–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292
293 _IRQL_requires_max_(APC_LEVEL)
294 BOOLEAN IsMemoryRangePresent(OPTIONAL PEPROCESS Process, PVOID Address, SIZE_T Size)
295 {
296 if (!Size) return FALSE;
297
298 BOOLEAN NeedToAttach = Process && Process != PsGetCurrentProcess();
299 KAPC_STATE ApcState;
300 if (NeedToAttach)
301 KeStackAttachProcess(Process, &ApcState);
302
303 BOOLEAN IsPresent = TRUE;
304
305 PVOID Page = Address;
306 do {
307 ULONG PageSize = 0;
308 IsPresent = IsPagePresent(Address, &PageSize) && PageSize;
309 if (!IsPresent) break;
310 Page = reinterpret_cast<PVOID>(reinterpret_cast<SIZE_T>(ALIGN_DOWN_POINTER_BY(Page, PageSize)) + PageSize);
311 } while (Page < reinterpret_cast<PVOID>(reinterpret_cast<SIZE_T>(Address) + Size));
312
313 if (NeedToAttach)
314 KeUnstackDetachProcess(&ApcState);
315
316 return IsPresent;
317 }
318}

Callers 3

OperateProcessMemoryFunction · 0.70
KbFillMemoryFunction · 0.50
KbEqualMemoryFunction · 0.50

Calls 1

IsPagePresentFunction · 0.70

Tested by

no test coverage detected