From 92c155d477f5487982e16ea71b6ad07527698951 Mon Sep 17 00:00:00 2001 From: MisterY52 <11368116+MisterY52@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:27:24 +0100 Subject: [PATCH] Slight optimization for dtb change Avoids reopening the same process after a dtb change --- apex_dma/memory.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apex_dma/memory.cpp b/apex_dma/memory.cpp index f57128a..b1b029b 100644 --- a/apex_dma/memory.cpp +++ b/apex_dma/memory.cpp @@ -192,17 +192,22 @@ void Memory::open_proc(const char *name) printf("Kernel initialized: %p\n", kernel.get()->container.instance.instance); } + if (lastCorrectDtbPhysicalAddress && bruteforceDtb(0x0, 0x100000)) + { + return; + } + + close_proc(); + ProcessInfo info; info.dtb2 = Address_INVALID; if (kernel.get()->process_info_by_name(name, &info)) { status = process_status::NOT_FOUND; - lastCorrectDtbPhysicalAddress = 0; return; } - close_proc(); if (kernel.get()->clone().into_process_by_info(info, &proc.hProcess)) { status = process_status::FOUND_NO_ACCESS; @@ -240,6 +245,7 @@ void Memory::close_proc() { std::lock_guard l(m); proc.hProcess.~IntoProcessInstance(); + lastCorrectDtbPhysicalAddress = 0; proc.baseaddr = 0; }