AndFix修补方法如何? [英] How does AndFix patch methods?

查看:96
本文介绍了AndFix修补方法如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近了解到一个Android库 AndFix ,该库允许实时方法修补。现在,据我所知,Dalvik不允许运行时操作字节码或dex。

I learned recently of an Android library AndFix which allows for live method patching. Now, as far as I know, Dalvik does not allow runtime manipulation of bytecode or dex.

有人可以很好地解释 AndFix 是否进行实时修补?

Can someone provide a good explanation on how AndFix does live patching?

推荐答案

寻找在源代码中,您可以在此处看到Dalvik的补丁程序机制。 dalvik_replaceMethod()函数正在修改内部Dalvik状态,更改 Method 结构以指向替换方法。

Looking at the sources, you can see the patch mechanism for Dalvik here. The dalvik_replaceMethod() function is modifying the internal Dalvik state, changing the Method struct to point to a replacement method.

它不会修改磁盘或内存中的DEX,只是将方法调用路由到替换方法。这种方法高度依赖版本,因为对 Method 的更改或方法的工作方式会破坏工作。自2011年中以来,Dalvik并没有太大变化,这很容易,但是如果您查看附近的 art目录,则可以看到每个主要Android版本的不同实现。

It doesn't modify the DEX on disk or in memory, just routes the method calls to a replacement method. This approach is highly version-dependent, as changes to Method or the way methods work will break things. Dalvik hasn't changed much since mid-2011, which makes it easy, but if you look at the nearby "art" directory you can see different implementations for each major version of Android.

这篇关于AndFix修补方法如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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