首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SIMBL和mach_star的优点和缺点是什么?

SIMBL和mach_star的优点和缺点是什么?
EN

Stack Overflow用户
提问于 2011-01-04 00:21:21
回答 2查看 1.2K关注 0票数 4

对于为Mac应用程序编写hack和非官方扩展,现在似乎有两个选择:SIMBLmach_star。我正在启动一个需要注入到另一个进程中的项目,我需要在这些库之间做出选择。

SIMBL和mach_star在方法和功能上有什么不同?为什么我要用一个而不是另一个呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-02-21 23:48:57

SIMBL是从mach_star构建的.它的代码中包含mach_star ...

SIMBL就是SIMple BundleLoader...注意大小写...它被设计为允许插件模块存储在~/Library/Application Support/SIMBL/Plugins中,并自动注入到finder中。

/Library/Scripting Additions/SIMBL.osax...中有一个启动脚本...该脚本负责将mach_inject_bundle.framework安装到/Library/Frameworks (我认为)中,并将代码注入到plist指定的目标程序中。

mach_star有几个执行mach_inject_bundle_pid命令和其他邪恶的mach方法交换魔术的示例。

使用SIMBL并拥有您开发的插件是一回事……你可以制作这个插件,而且你不需要担心每次finder唤醒时注入finder或者安装mach_inject_bundle.framework。

您可以在您的应用程序中自动使用这些插件:您只需在每次finder重启/启动和/或您的应用程序启动时将它们安装并注入到您的代码中

(消除注入的唯一方法是使用applescript,如下所示:

代码语言:javascript
复制
tell application "Finder" to quit
delay 2.5
tell application "Finder" activate

或者我们需要完成mach_star代码并实现未注入的mach内容...:(

为了专业,并使应用程序自动安装您的插件,我们必须做以下工作:有代码,可以使用SMJobBless保佑一个程序做mach_inject_bundle.framework文件的安装,如果它还没有安装,以及注入每次您的应用程序加载和/或当finder重启。

well Divisi0n:Alexey Zhuchkov和Erwan Barrier做了一项出色的工作,演示了如何将一些代码嵌入到您的应用程序中,这些代码实现了以下功能:

(伪代码)

AppDelegate ApplicaitonDidFinishLaunching:

SMJobBlessGetPermission() //允许我们在用户批准一次后,在每次启动时注入finder

{

//有执行权限

if (未安装框架)

将mach_inject_bundle.framework安装到/Library/Frameworks中

使用包代码注入查找器

}

https://github.com/twotreeszf/FinderMenu

https://github.com/erwanb/MachInjectSample

引用自MachInjectSample:

代码语言:javascript
复制
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
  NSError *error;

  // Install helper tools
  if ([DKInstaller isInstalled] == NO && [DKInstaller install:&error] == NO) {
    assert(error != nil);

    NSLog(@"Couldn't install MachInjectSample (domain: %@ code: %@)", error.domain, [NSNumber numberWithInteger:error.code]);
    NSAlert *alert = [NSAlert alertWithError:error];
    [alert runModal];
    [NSApp terminate:self];
  }

  // Inject Finder process
  if ([DKInjectorProxy inject:&error] == FALSE) {
    assert(error != nil);

    NSLog(@"Couldn't inject Finder (domain: %@ code: %@)", error.domain, [NSNumber numberWithInteger:error.code]);
    NSAlert *alert = [NSAlert alertWithError:error];
    [alert runModal];
    [NSApp terminate:self];
  }
}
票数 2
EN

Stack Overflow用户

发布于 2011-07-27 21:48:42

SIMBL:只在可可应用程序上工作。(您不能管理Dock、Finder等应用程序)。易于使用。

mach_star:适用于所有类型的应用程序,可以挂接平面API。稍微有点困难。

使用哪一个?取决于你想做什么?如果只是和可可调情就行了,那就用SIMBL,否则就用mach_star。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4586169

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档