如何将LC_LOAD_DYLIB命令插入Mach-O二进制文件或将静态库加入现有二进制文件(IOS) [英] How to insert a LC_LOAD_DYLIB command into a Mach-O binary or join a static library to an existing binary (IOS)

查看:503
本文介绍了如何将LC_LOAD_DYLIB命令插入Mach-O二进制文件或将静态库加入现有二进制文件(IOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次询问stackoverflow而且我很绝望。

This is the first time I am asking on stackoverflow and I am desperate.

我的任务是加载dylib或将静态lib加入已存在的可执行文件对于IOS设备。

My task is to load a dylib or join a static lib to an already existing executable for an IOS device.

我将使用 static void __attribute __((构造函数))initialize(void)开始调酒。
这个可执行文件适用于内部企业appstore,所以我不需要通过苹果appstore(因为他们会拒绝它)。

I will be using the static void __attribute__((constructor)) initialize(void) to start the swizzling. This executable is for in house enterprise appstore so i do not need to go thru the apple appstore (since they will reject it).

这个的原因是从客户及其签名密钥中获取现有的IPA,并在不需要开发人员干预的情况下为其应用程序添加新功能。

The reason for this is to take an existing IPA from a customer and their signing keys and add a new functionality to their application without requiring a developer intervention.

有一家公司正在这样做,称为nukona 。您可以在此处观看电影: https://www.youtube.com/watch ?feature = player_embedded& v = z9rrOB6lOxY

There is one company doing that called nukona. You can watch the movie here: https://www.youtube.com/watch?feature=player_embedded&v=z9rrOB6lOxY

我可以告诉你,我试图用一个 DYLD_INSERT_LIBRARIES把LSEnvironment放在plist文件中但事实证明LSEnvironment似乎对IOS应用程序的沙箱没有任何影响。

I can tell you that i tried to put LSEnvironment inside the plist file with a DYLD_INSERT_LIBRARIES but it turns out LSEnvironment does not seem to have any effect in the sandbox of an IOS application.

我还尝试使用install_name_tool更改其中一个依赖项并将其替换为我的dylib(也具有该依赖性)。它崩溃而没有信息原因。

I also tried install_name_tool for changing one of the dependencies and replacing it with my dylib (which has that dependecy as well). It crashes without information why.

显然,如果我将dylib添加到XCode中的测试应用程序并重新编译它是完美的,这是给定的。但是,这是我不能要求的,例如,公司的管理员。重建可能会阻止客户使用此库。

Obviously, if i add the dylib to a test application in XCode and recompile it works perfectly which is a given. However, this is something i cannot ask, for example, an administrator of a company. Rebuilding may deter customers of using this lib.

这是我在堆栈溢出时发现的相关链接,但对于osx而言,我需要它用于IOS。
如何将LC_LOAD_DYLIB命令插入Mach-O二进制文件(OSX)

Here is a related link i found on stack overflow but for osx and i need it for IOS. How to insert a LC_LOAD_DYLIB command into a Mach-O binary (OSX)

我唯一可以想到的是编辑二进制加载命令一些如何,但我不确定如何以及如何考虑重新安置表等...

The only thing i can think off is to edit the binary load commands some how, but i am not sure how and how to do it taking into account the relocation tables etc...

欢迎任何替代方案。

感谢您的时间。

推荐答案

我是开源的 optool 就是这样做的(我没有在iOS上测试它但它应该可以工作。打开一个问题如果你有问题)

I open-sourced optool which does exactly this (I haven't tested it on iOS but it should work. Open up an issue if you have problems)

这篇关于如何将LC_LOAD_DYLIB命令插入Mach-O二进制文件或将静态库加入现有二进制文件(IOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆