7

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

Community
  • 1
  • 1
Earlence
  • 71
  • 2

2 Answers2

2

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!

danfuzz
  • 4,253
  • 24
  • 34
Jesse Wilson
  • 39,078
  • 8
  • 121
  • 128
  • yes, but loading new bytecode is different from injecting bytecode into existing dex code files. My scenario is like this: An APK is installed. When it is about to be loaded/executed/optimized, I inject some specific instructions into the existing class data. – Earlence Feb 22 '11 at 07:35
0

You can also check tools like redexer (http://www.cs.umd.edu/projects/PL/redexer/) and smali (https://code.google.com/p/smali/)