Fix Bug for Interface Inspector on macOS Serria

之前介绍过[如何■■ Interface Inspector] 1,近来把系统升级到最新的 macOS Serria 之后,发现 Interface Inspector 不 work 了。启动倒是正常,但每次 attach app 时,总是提示无法 attach,查看 system log,发现有这么一个 error:

从 log 中看出,root cause 是 mach_inject_bundle_stub 去 load ___pthread_set_self 时失败了,而这个函数本来应该是在 libSystem.B.dylb 这个系统库里面的。也就是说,macOS Serria 的 libSystem.B.dylb 已经不再有 ___pthread_set_self 这个函数了。于是开始 google,最后在[一条 Twitter] 2 上发现了咋回事,是的,___pthread_set_self 已经被替换成了 _pthread_set_self

明白了咋回事,开始考虑怎么解决。

方法 1:

修改 mach_inject_bundle_stub 的 load 指令,从旧版系统中 copy 一份老的 libSystem.B.dylb,然后让 mach_inject_bundle_stub 去 load 这个老的库。

方法 2:

还是修改 mach_inject_bundle_stub,把所有调用 ___pthread_set_self 的地方改成调用 _pthread_set_self

理论上这两种方法应该都可以的吧,但是考虑到自己逆向功力不够,所以就采用了如下的正向方法 XD。

方法 3:

我搜索了一下 mach_inject_bundle_stub 这个东西,发现原来是个 GitHub 上的[开源库] 3,Interface Inspector 就是用的这个库。app 会在 /Library/Frameworks/mach_inject_bundle.framework 这里安装这个库,而 mach_inject_bundle_stub 就是这个库里面的一个子 bundle。有了 source code 就好办了,只需要修改 code,然后重新编译替换掉 mach_inject_bundle_stub 这个 bundle 就好了。

步骤:

1. fork it

2. 修改 code

3. 编译签名

注意,这里有个小细节,app 在 load mach_inject_bundle_stub 这个 bundle 时,是按照 bundle id com.rentzsch.mach-inject-bundle-stub 来找的,所以需要把工程文件里的 bundle id 改成跟原来的 bundle id 一样。

4. 替换到 mach_inject_bundle.framework 里面

5. 顺便提一个 pull request,老代码已经年久失修了 XD

完成之后,重新启动 app,可以正常 work 了!

3 个赞

作者能找到解决方法,厉害~

我重新编译了mach_inject_bundle.framework,替换了原有的,但还是不行啊…求教

报错如下

楼主威武,果然好用!

mach_inject_bundle_stub 这git好像没了,还有新地址不

一样 我替换后也是不能用

奇怪了,我刚去编译了可以正常用啊。。楼上的朋友怎么不行??

从这里下载的zip包。
os: macos mojave
xcode: Version 10.1 (10B61)
Interface Inspector Version 2.2 ( 17 )
自己按照文章■■的,主要为了练手。
image

要把mach_inject_bundle.framework这个库拷贝到/Library/Frameworks目录下

请问谁能发一份现成的mach_inject_bundle.framework?我在macOS Catalina下编译,Xcode提示我i386架构已经弃用。也就是说我如果不换电脑我就没法编译……好心疼啊!

我在网上找了一份现成的frameworks,可是打开app后:

An error occured during the process.

Error: (os/kern) failure