int main(int argc, char** argv, char** envp) { if (argc != 2 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) showHelp(argv[0]); try { MachOObject* obj; std::set<std::string> deps; MachOMgr* mgr = MachOMgr::instance(); mgr->detectSysRootFromPath(argv[1]); mgr->setLoadAnyArchitecture(true); obj = new MachOObject(argv[1]); mgr->add(obj, true); std::cout << c(ANSI_COLOR_GRAY) << "Resolving dependencies of " << obj->path() << "\n\n" << c(ANSI_COLOR_RESET); resolve(obj, deps); mgr->remove(obj); } catch (const std::exception& e) { std::cerr << c(ANSI_COLOR_RED) << e.what() << c(ANSI_COLOR_RESET) << std::endl; return 1; } }
const char* dyld_image_path_containing_address(const void* addr) { MachOObject* module = MachOMgr::instance()->objectForAddress((void*) addr); if (!module) return nullptr; else return module->path().c_str(); }
int _NSGetExecutablePath(char* buf, unsigned int* size) { std::string path; MachOObject* mainModule = MachOMgr::instance()->mainModule(); if (mainModule) path = mainModule->path(); if (*size > path.length()+1) *size = path.length()+1; strncpy(buf, path.c_str(), *size); buf[(*size)-1] = 0; return 0; }