-
Notifications
You must be signed in to change notification settings - Fork 53
zh_get_page_entry
伏秋洛 edited this page Jun 14, 2023
·
2 revisions
页表项,可以表达该内存页的状态与偏移,可判断是否缺页或者获取其对应物理地址。
使用前请阅读获取MAPS
std::string packageName = "bin.mt.plus";
try {
auto pid = hak::find_process(packageName);
std::cout << "pid: " << pid << "\n";
auto process = std::make_shared<hak::process>(pid);
process->set_memory_mode(memory_mode::SYSCALL);
auto maps = process->get_maps();
do {
for (int i = 0; i < ((maps->end() - maps->start()) / getpagesize()); ++i) {
auto entry = process->get_page_entry(maps->start() + i * getpagesize());
std::cout << "present = " << entry.present << "\n";
}
} while ((maps = maps->next()));
} catch (std::exception& e) {
std::cout << "error: " << e.what() << "\n";
}
上面的代码获取了每一页的entry并打印了其present的状态。
缺页判断我们可以阅读链接中的代码。
Only through learning and communication!