4

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

SIMBL 和 SIMBL 在方法和功能上有何不同mach_star?为什么我要使用其中一个?

4

2 回答 2

3

SIMBL:仅适用于可可应用程序。(您无法管理 Dock、Finder 等应用程序)。便于使用。

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

使用哪个?取决于你想做什么?如果只是与一些可可调情就可以完成您的工作,请使用 SIMBL 否则 mach_star。

于 2011-07-27T13:48:42.393 回答
2

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

SIMBL 是 SIMple BundleLoader...注意大写...。它旨在允许插件模块存储在 ~/Library/Application Support/SIMBL/Plugins 中并自动注入到查找器中。

/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。

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

(消除注射的唯一方法是使用如下的applescript:

tell application "Finder" to quit
delay 2.5
tell application "Finder" activate

或者我们需要完成 mach_star 代码并实现 uninject mach 的东西...... :(

为了专业并制作一个自动安装插件的应用程序,我们必须执行以下操作:有代码可以使用 SMJobBless 来祝福程序安装 mach_inject_bundle.framework 文件(如果尚未安装),以及注入每次您的应用程序加载和/或查找程序重新启动时,查找程序。

zerodivisi0n:Alexey Zhuchkov 和 Erwan Barrier 一样出色地说明了如何在您的应用程序中嵌入一些代码,这些代码执行以下操作:

(伪代码)

AppDelegate ApplicaitonDidFinishLaunching:

SMJobBlessGetPermission() //一旦用户批准一次,我们就有权在每次启动时注入查找器

{

//具有执行权限

如果(未安装框架)

将 mach_inject_bundle.framework 安装到 /Library/Frameworks

使用您的捆绑代码注入查找器

}

https://github.com/twotreeszf/FinderMenu

https://github.com/erwanb/MachInjectSample

引用自 MachInjectSample:

- (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];
  }
}
于 2013-02-21T15:48:57.287 回答