SIMBL 和 mach_star 有何优缺点?

发布于 2024-10-10 14:07:36 字数 332 浏览 9 评论 0原文

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

SIMBL 和 mach_star 之间的方法和功能有哪些差异?我为什么要使用其中一种而不是另一种?

For writing hacks and unofficial extensions for Mac OS X apps, there seem to be two choices today: SIMBL and mach_star. I'm starting a project that will require injecting into another process, and I need to decide between these libraries.

What are the differences in approach and functionality between SIMBL and mach_star? Why would I use one over the other?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

归途 2024-10-17 14:07:36

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

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

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

SIMBL: work only on cocoa applications. (You cannot manage applications like Dock, Finder, so on). Easy to use.

mach_star: works with all kind of application and can hook flat APIs. Slightly difficult.

Which to use? Depends upon what you want to do? If just flirting around with some cocoa will do your job use SIMBL else mach_star.

时光倒影 2024-10-17 14:07:36

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 文件(如果尚未安装),并在每次应用程序加载和/或 finder 重新启动时注入 finder

:Alexey Zhuchkov 也做得非常出色 。作为 Erwan Barrier 来说明如何在您的应用程序中嵌入一些执行以下操作的代码:(

伪代码)

AppDelegate ApplicaitonDidFinishLaunching:

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

{

//具有执行权限,

如果(未安装框架)

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

使用您的捆绑代码注入 finder

}

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];
  }
}

SIMBL was built from mach_star... it contains mach_star in it's code...

SIMBL is the SIMple BundleLoader... note the caps.... it was designed to allow plugin modules to be stored in ~/Library/Application Support/SIMBL/Plugins and be injected into the finder automatically..

There is a startup script in /Library/Scripting Additions/SIMBL.osax... this script is responsible for installing the mach_inject_bundle.framework into /Library/Frameworks (i think) and inject the code into the target programs specified by the plist.

mach_star has several examples of performing mach_inject_bundle_pid commands and other nefarious mach method swapping magic.

To use SIMBL and have plugins you develop is one thing... you can make the plugin and you don't need to worry about injecting the finder every time finder wakes up or installing the mach_inject_bundle.framework.

YOU CAN USE THOSE PLUGINS IN YOU APP AUTOMATICALLY: you just have to have them installed and injected in your code each time finder restarts/starts up and/or when your app starts up

(the only way to eliminate your injections is to use an applescript like the following:

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

or we would need to complete the mach_star code and implement the uninject mach stuff... :(

To be professional and make an app that auto installs your plugin, we must do the following: there is code that can use SMJobBless to bless a program to do the installation of the mach_inject_bundle.framework file if its not already installed, as well as inject the finder each time your application loads and/or when the finder restarts.

zerodivisi0n:Alexey Zhuchkov has done a wonderful job as well as Erwan Barrier to illustrate how to embed some code in your app that does the following:

(pseudo code)

AppDelegate ApplicaitonDidFinishLaunching:

SMJobBlessGetPermission() //keeps us with permission to inject the finder each launch once the user has approved one time

{

//with executive permissions

if (framework is not installed)

install the mach_inject_bundle.framework into /Library/Frameworks

inject the finder with your bundle code

}

https://github.com/twotreeszf/FinderMenu

https://github.com/erwanb/MachInjectSample

Cited from 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];
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文