diff --git a/iblessing/iblessing-core/v2/memory/memory.cpp b/iblessing/iblessing-core/v2/memory/memory.cpp index d94365b..e17b876 100644 --- a/iblessing/iblessing-core/v2/memory/memory.cpp +++ b/iblessing/iblessing-core/v2/memory/memory.cpp @@ -8,6 +8,7 @@ #include "memory.hpp" #include +#include #include #include @@ -114,6 +115,10 @@ ib_return_t Memory::loadSync() { } } macho->context->symtab->sync(); + + shared_ptr objc = Objc::create(macho, this); + this->objc = objc; + macho->context->objcRuntime = objc->getRuntime(); vm2->relocAllRegions(macho->context->symtab, macho->context->objcRuntime); return IB_SUCCESS; } diff --git a/iblessing/iblessing-core/v2/memory/memory.hpp b/iblessing/iblessing-core/v2/memory/memory.hpp index 3f01be0..a1c3c70 100644 --- a/iblessing/iblessing-core/v2/memory/memory.hpp +++ b/iblessing/iblessing-core/v2/memory/memory.hpp @@ -15,6 +15,8 @@ namespace iblessing { +class Objc; + class Memory { public: Memory(std::shared_ptr macho) : macho(macho) {} @@ -25,6 +27,7 @@ class Memory { std::shared_ptr fileMemory; std::shared_ptr virtualMemory; + std::shared_ptr objc; protected: std::shared_ptr macho; diff --git a/iblessing/iblessing-core/v2/objc/objc.cpp b/iblessing/iblessing-core/v2/objc/objc.cpp index 91c8fec..ff3c4b5 100644 --- a/iblessing/iblessing-core/v2/objc/objc.cpp +++ b/iblessing/iblessing-core/v2/objc/objc.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace iblessing; -Objc::Objc(shared_ptr macho, shared_ptr memory) { +Objc::Objc(shared_ptr macho, Memory *memory) { shared_ptr rt = make_shared(macho->context->symtab, memory->virtualMemory); this->runtime = rt; this->macho = macho; @@ -24,7 +24,7 @@ Objc::Objc(shared_ptr macho, shared_ptr memory) { rt->catlist_size = fileMemory->objc_catlist_size; } -shared_ptr Objc::create(std::shared_ptr macho, std::shared_ptr memory) { +shared_ptr Objc::create(std::shared_ptr macho, Memory *memory) { return make_shared(macho, memory); } diff --git a/iblessing/iblessing-core/v2/objc/objc.hpp b/iblessing/iblessing-core/v2/objc/objc.hpp index 8450cf3..ff59ca2 100644 --- a/iblessing/iblessing-core/v2/objc/objc.hpp +++ b/iblessing/iblessing-core/v2/objc/objc.hpp @@ -18,9 +18,9 @@ typedef std::function macho, std::shared_ptr memory); + Objc(std::shared_ptr macho, Memory *memory); - static std::shared_ptr create(std::shared_ptr macho, std::shared_ptr memory); + static std::shared_ptr create(std::shared_ptr macho, Memory *memory); ib_return_t loadClassList(); ib_return_t loadCategoryList(); @@ -30,7 +30,7 @@ class Objc { protected: std::shared_ptr runtime; std::shared_ptr macho; - std::shared_ptr memory; + Memory *memory; }; }; diff --git a/iblessing/iblessing/builtin/scanner/ObjcMethodXrefScanner.cpp b/iblessing/iblessing/builtin/scanner/ObjcMethodXrefScanner.cpp index 92a537b..f3a0517 100644 --- a/iblessing/iblessing/builtin/scanner/ObjcMethodXrefScanner.cpp +++ b/iblessing/iblessing/builtin/scanner/ObjcMethodXrefScanner.cpp @@ -1070,8 +1070,7 @@ int ObjcMethodXrefScanner::start() { printf(" [*] Status: Track C Symbols: %d, Anti Wrapper: %d, Find All Path Level: %d, Track Call Snapshots: %d\n", shouldTrackSymbols, shouldAntiWrapper, findAllPathLevel, trackingCallSnapshots); printf(" [*] Step 1. realize all app classes\n"); - shared_ptr objc = Objc::create(macho, memory); - this->objc = objc; + this->objc = memory->objc; objc->loadClassList(); vector methods; set impAddrs;