飘云阁

 找回密码
 加入我们

QQ登录

只需一步,快速开始

查看: 3454|回复: 2

[macOS] OSX下Loader实现--By 飘云

  [复制链接]
  • TA的每日心情
    难过
    2024-4-22 14:49
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    发表于 2014-10-25 19:48:45 | 显示全部楼层 |阅读模式
    //
    //  AppDelegate.m
    //  Loader For MacOSX
    //  Code By PiaoYun/P.Y.G
    //
    //  Created by System Administrator on 10/24/14.
    //  Copyright (c) 2014 P.Y.G All rights reserved.
    //  https://www.chinapyg.com
    //  http://www.dllhook.com

    #import "AppDelegate.h"

    ///////////////////////////////////////////////////////////////////////////////
    // 动态库名称
    #define DYLIB_NAME @"HookLib"
    // 动态库类型
    #define DYLIB_TYPE @"dylib"
    // 待破解文件路径
    #define FILE_PATH  @"/private/var/root/Desktop/Reveal.app/Contents/MacOS/Reveal"
    // BundleIdentifier
    #define BUNDLE_IDENTIFIER @"com.ittybittyapps.Reveal"
    ///////////////////////////////////////////////////////////////////////////////


    @implementation AppDelegate

    -(void)bringToFrontApplicationWithBundleIdentifier:(NSString*)inBundleIdentifier
    {
        // 目标程序置前
        NSArray* appsArray = [NSRunningApplication runningApplicationsWithBundleIdentifier:inBundleIdentifier];
        if([appsArray count] > 0)
        {
            [[appsArray objectAtIndex:0] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
        }
       
        // 自杀
        [[NSApplication sharedApplication] terminate:self];
    }

    -(void)launchApplicationWithPath:(NSString*)inPath andBundleIdentifier:(NSString*)inBundleIdentifier
    {
        if(inPath != nil)
        {
            NSString *dyldLibrary = [[NSBundle bundleForClass:[self class]] pathForResource:DYLIB_NAME ofType:DYLIB_TYPE];
            NSString *launcherString = [NSString stringWithFormat:@"DYLD_INSERT_LIBRARIES=\"%@\" \"%@\" &", dyldLibrary, inPath];
            system([launcherString UTF8String]);
            
            // Bring it to front after a delay
            [self performSelector:@selector(bringToFrontApplicationWithBundleIdentifier:) withObject:inBundleIdentifier afterDelay:1.0];
        }
    }

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
        NSString *calculatorPath = FILE_PATH;
       
        if([[NSFileManager defaultManager] fileExistsAtPath:calculatorPath])
            [self launchApplicationWithPath:calculatorPath andBundleIdentifier:BUNDLE_IDENTIFIER];
    }

    @end

    PYG19周年生日快乐!
  • TA的每日心情
    开心
    2018-9-27 19:17
  • 签到天数: 31 天

    [LV.5]常住居民I

    发表于 2014-10-25 20:14:52 | 显示全部楼层
    曲高和寡,赞一个!
    PYG19周年生日快乐!
  • TA的每日心情
    开心
    2019-3-17 22:44
  • 签到天数: 132 天

    [LV.7]常住居民III

    发表于 2014-10-26 12:29:36 | 显示全部楼层
    “曲高和寡”,道一片凄凉啊,支持!
    PYG19周年生日快乐!
    您需要登录后才可以回帖 登录 | 加入我们

    本版积分规则

    快速回复 返回顶部 返回列表