用自定义类替换 Java API 类?

发布于 2024-10-22 08:01:05 字数 268 浏览 1 评论 0原文

我有一个使用 android.opengl.GLSurfaceView 类的闭源 Android 程序。

我需要注入一些Java代码(注入已经完成),用我自己的GLSurfaceView类(挂钩)替换所有android.opengl.GLSurfaceView相关处理,而不对原始代码进行任何更改(无来源,不允许拆卸)。

基本上,它是一种 Win32 C 编程但在 Java/Android 中的 API 挂钩。

I have a closed source Android program that uses the android.opengl.GLSurfaceView class.

I need to inject some Java code (injection already done) which substitutes all android.opengl.GLSurfaceView related processing with my own GLSurfaceView class (hooking) with no changes to original code (no sources, no disassemble allowed).

Basically it's a sort of API hooking in terms of Win32 C programming but in Java/Android.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

要走就滚别墨迹 2024-10-29 08:01:06

您将无法使用 Java 反射来做到这一点。

最好的选择是使用字节码重写机制来修改闭源程序的字节码。如果您使用“真正的 Java”,我建议使用 BCEL。你需要处理Davlik代码,我不知道是否有Davlik的BCEL模拟。

这假设您可以以允许您在不违反安全规则的情况下修改它们的形式访问此闭源应用程序的字节码。例如,如果应用程序已签名,则更改字节码将使签名无效。

在不违反逆向工程限制的情况下做到这一点将是另一个困难。


听起来你需要放弃这个想法。

You won't be able to do this using Java reflection.

Your best bet is to use a bytecode rewriting mechanism to modify the bytecode of the closed-source program. If you were using "real Java", I'd suggest BCEL. You need to deal with Davlik code, and I don't know if there is a BCEL analog for Davlik.

This assumes that you have access to the bytecodes of this closed-source application in a form that allows you to tinker with them without violating security rules. For instance, if the application has been signed, then changing bytecodes will invalidate the signature.

And doing this without violating a restriction on reverse engineering would another difficulty.


Sounds like you need to give up on this idea.

倾其所爱 2024-10-29 08:01:06

如果您要注入代码的类不是最终类,您可以扩展该类并重新实现您需要的方法(同样,仅当该方法不是最终方法时)

If the class of you want to inject the code are not a final class, you can extends the class and reimplement the methods of you need (again, only if the method are not final method)

橘虞初梦 2024-10-29 08:01:05

你不能这样做,因为这会严重违反安全规定。例如,如果有一种机制可以做到这一点,您将能够覆盖阻止下载的 Java 应用程序在您的计算机上安装恶意软件的类。

您可以通过修改安装的字节码来执行此操作,以便 GLSurfaceView 执行不同的操作,或者修改应用程序的字节码,以便它调用替代类而不是 GLSurfaceView。

You can't do this, and the reason you can't is that it would be a huge violation of security. For example if there were a mechanism to do this, you would be able to override the classes that prevent a downloaded Java app from, say, installing malware on your computer.

You can do this by modifying the bytecode of your installation so that GLSurfaceView does something different, or by modifying the bytecode of the app so that it calls a substitute class instead of GLSurfaceView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文