如何将代码注入现有的 Apk? [英] How to inject code into an existing Apk?

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

问题描述

我知道这可以反编译和重新编译 apk.我看到了这篇文章:将代码注入 APK之前,但我想要的不是反编译或逆向工程.

I know this is possible to decompile and recompile an apk. And I saw this post : Injecting code into APK before, But what I want is not decompiling or reverse engineering.

就我而言,我只想制作一些使用与游戏手柄兼容的触摸事件的游戏.我见过一些公司做这样的事情,让安卓游戏与他们的游戏手柄兼容.不幸的是,我没有找到将一些代码注入现有 apk 的解决方案.

In my case I just want to make some games that uses touch events compatible with gamepad. I've seen some companies that do something like this and make android games compatible with their gamepads. Unfortunately I found no solution to inject some codes into an existing apk.

所以我的问题是:

有没有办法对 apk 进行一些更改(更改游戏应用程序中的触摸和按键事件)并在其中添加一些代码而不影响真正的源代码?

Is there a way to do some changes into an apk (changing touch and key events in game application) and add some codes into that without effecting the real source code ?

推荐答案

对于这样简单的事情,您只需要 baksmali/smali.只需在程序集中向您的自定义类插入一个调用,其余部分就可以用 Java 编写.

For something simple like this, all you need is baksmali/smali. Just insert a single call into the assembly into your custom class, and you can write the rest in Java.

反编译/重新编译很少起作用,无论如何对于这种情况都是过度的.使用 smali 甚至适用于混淆的应用程序,尽管有些应用程序会计算自身的完整性检查,并且在修改后会拒绝运行.

Decompiling/recompiling rarely works and is overkill for this situation anyway. Using smali will work even for obfuscated applications, though some applications calculate integrity checks on themselves and will refuse to run if modified.

这篇关于如何将代码注入现有的 Apk?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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