在Mach-o二进制文件中更改函数参考 [英] Changing function reference in Mach-o binary
问题描述
我需要将对mach-o二进制文件中的函数的引用更改为在我自己的dylib中定义的自定义函数.我现在要遵循的过程是
I need to change to reference of a function in a mach-o binary to a custom function defined in my own dylib. The process I am now following is,
-
将对较早功能的引用替换为新功能.例如,使用sed从
_fopen
到_mopen
.
我在 MachOView 中打开mach-o二进制文件,以找到实体的地址我想要改变.然后,我使用十六进制编辑器手动更改二进制文件中的信息.
I open the mach-o binary in MachOView to find the address of the entities I want to change. I then manually change the information in the binary using a hex editor.
有没有一种方法可以使这一过程自动化,即编写程序来读取符号,动态加载信息,然后在可执行文件中进行更改.我正在查看/usr/include/mach-o
处的mach-o头文件,但不确定如何使用它们来获取此信息.是否存在任何库-C或python可以帮助实现同样的目的?
Is there a way I can automate this process i.e write a program to read the symbols, and dynamic loading info and then change them in the executable. I was looking at the mach-o header files at /usr/include/mach-o
but am not entire sure how to use them to get this information. Do there exist any libraries present - C or python which help do the same?
推荐答案
有趣的问题,我正在尝试做与静态lib类似的事情;看看是否此帮助
interesting question, I am trying to do something similar to static lib; see if this helps
这篇关于在Mach-o二进制文件中更改函数参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!