Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bytecode injection on dalvik

I have asked this on android platform, but did not receive a reply. I have referred to this thread, but could not find what post he was referring to (Dynamically Generating Dalvik Bytecode into a running Dalvik/Android application)

Also, This issue was raised(http://code.google.com/p/android/issues/detail?id=6322)

So, my question is,

  1. has there been any progress in this regard?
  2. Is it possible to inject new bytecode into a class that is being loaded?
  3. if so, any pointers to the same?

Cheers. Earlence

like image 296
Earlence Avatar asked Feb 21 '11 20:02

Earlence


People also ask

What is bytecode injection?

Bytecode injection is modifying Foo. class at runtime to inject code into it right before its loaded and run.

What is Dalvik byte code?

Dalvik is a discontinued process virtual machine (VM) in Android operating system that executes applications written for Android. (Dalvik bytecode format is still used as a distribution format, but no longer at runtime in newer Android versions.)

Does Dalvik use JIT?

While Dalvik uses the JIT approach, so for mobile phones having less storage can use the Dalvik. Battery: ART increases battery performance to a large extent because of the AOT approach. While the Dalvik uses the JIT approach and this results in more battery utilization.


1 Answers

Android's Dalvik team is intending to create an API that generates dex files at runtime, but we have nothing to show at the moment.

Your best bet today is to use a Java bytecode injection framework (ASM, cglib, etc.) and to include dx.jar (that is, the guts of the dx tool) in your program to convert generated .class files into a .dex file at runtime. If that (hacky) strategy isn't sufficient, you're on your own. This problem is a good opportunity for open source!

like image 197
Jesse Wilson Avatar answered Sep 20 '22 20:09

Jesse Wilson