Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeeHive的原理大概是这样子的 #139

Open
lyandy opened this issue May 31, 2019 · 0 comments
Open

BeeHive的原理大概是这样子的 #139

lyandy opened this issue May 31, 2019 · 0 comments

Comments

@lyandy
Copy link

lyandy commented May 31, 2019

section

上图展示的是通过对编译链接完成生成的可执行文件分别查看Mach-O文件结构和反编译代码的结果

BeeHive的原理简单来说分为三步:
1、为了避免无用数据在编译阶段被优化删掉,就通过 used 来修饰 并告诉编译器把数据存到Mach-O文件的Segment Data 中,就是宏定义那段
2、hook动态链接库加载,在main函数执行之前把数据从Segment Data读取出来,做好class和protocol的字典对应准备,就是注册main函数执行之前__attribute__((constructor))那段
3、当程序启动完成后,就可以从字典的中根据protocol取出对应的类,达到解耦合的目的

再附上有关文章:
https://lowlevelbits.org/parsing-mach-o-files/
http://liumh.com/2018/08/18/ios-attribute-section/#section

@lyandy lyandy changed the title BeeHive的原理大改是这样子的 BeeHive的原理大概是这样子的 May 31, 2019
@lyandy lyandy closed this as completed Jun 25, 2019
@lyandy lyandy reopened this Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant