MCPcopy
hub / github.com/AloneMonkey/frida-ios-dump / loadAllDynamicLibrary

Function loadAllDynamicLibrary

dump.js:316–371  ·  view source on GitHub ↗
(app_path)

Source from the content-addressed store, hash-verified

314}
315
316function loadAllDynamicLibrary(app_path) {
317 var defaultManager = ObjC.classes.NSFileManager.defaultManager();
318 var errorPtr = Memory.alloc(Process.pointerSize);
319 Memory.writePointer(errorPtr, NULL);
320 var filenames = defaultManager.contentsOfDirectoryAtPath_error_(app_path, errorPtr);
321 for (var i = 0, l = filenames.count(); i < l; i++) {
322 var file_name = filenames.objectAtIndex_(i);
323 var file_path = app_path.stringByAppendingPathComponent_(file_name);
324 if (file_name.hasSuffix_(".framework")) {
325 var bundle = ObjC.classes.NSBundle.bundleWithPath_(file_path);
326 if (bundle.isLoaded()) {
327 console.log("[frida-ios-dump]: " + file_name + " has been loaded. ");
328 } else {
329 if (bundle.load()) {
330 console.log("[frida-ios-dump]: Load " + file_name + " success. ");
331 } else {
332 console.log("[frida-ios-dump]: Load " + file_name + " failed. ");
333 }
334 }
335 } else if (file_name.hasSuffix_(".bundle") ||
336 file_name.hasSuffix_(".momd") ||
337 file_name.hasSuffix_(".strings") ||
338 file_name.hasSuffix_(".appex") ||
339 file_name.hasSuffix_(".app") ||
340 file_name.hasSuffix_(".lproj") ||
341 file_name.hasSuffix_(".storyboardc")) {
342 continue;
343 } else {
344 var isDirPtr = Memory.alloc(Process.pointerSize);
345 Memory.writePointer(isDirPtr,NULL);
346 defaultManager.fileExistsAtPath_isDirectory_(file_path, isDirPtr);
347 if (Memory.readPointer(isDirPtr) == 1) {
348 loadAllDynamicLibrary(file_path);
349 } else {
350 if (file_name.hasSuffix_(".dylib")) {
351 var is_loaded = 0;
352 for (var j = 0; j < modules.length; j++) {
353 if (modules[j].path.indexOf(file_name) != -1) {
354 is_loaded = 1;
355 console.log("[frida-ios-dump]: " + file_name + " has been dlopen.");
356 break;
357 }
358 }
359
360 if (!is_loaded) {
361 if (dlopen(allocStr(file_path.UTF8String()), 9)) {
362 console.log("[frida-ios-dump]: dlopen " + file_name + " success. ");
363 } else {
364 console.log("[frida-ios-dump]: dlopen " + file_name + " failed. ");
365 }
366 }
367 }
368 }
369 }
370 }
371}
372
373function handleMessage(message) {

Callers 1

handleMessageFunction · 0.85

Calls 1

allocStrFunction · 0.85

Tested by

no test coverage detected