Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Execute Dalvik Op-Codes

I would like to execute opcodes directly against the running Dalvik VM instance from within my application on Android. I'm looking for something similar to the C asm function. I have a list of opcodes for dalvik, but I am unfamiliar with how to either execute them directly, or write them out to .class files and execute them against some sort of VM CLI command like dalvikvm from within a running application.

like image 829
Heat Miser Avatar asked Jun 01 '09 14:06

Heat Miser


People also ask

What is Dalvik opcode?

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.)

What is Smali code?

Smali is intended to serve as a basis for further analysis of Android applications and security implementation techniques. Android applications are mainly written in Java. The Java source code is first compiled into a Java Virtual Machine (JVM) bytecode using a standard Java compiler called Javac.

What is the Dalvik virtual machine in Android?

The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile devices. It optimizes the virtual machine for memory, battery life and performance. Dalvik is a name of a town in Iceland. The Dalvik VM was written by Dan Bornstein.

What is Dex format?

What is a Dex file? A Dex file contains code which is ultimately executed by the Android Runtime. Every APK has a single classes. dex file, which references any classes or methods used within an app.


2 Answers

its not possible. See the Google IO 2008 presentation on youtube about Dalvik internals for details. Mobile VMs including both Java and MS .NET are not full VMs and due to memory and performance constraints thus leave out parts that allow to accomplish what you have described.

like image 190
Fred Grott Avatar answered Oct 07 '22 01:10

Fred Grott


In the past it was impossible, but now it is possible:

http://android-developers.blogspot.sg/2011/07/custom-class-loading-in-dalvik.html

Essentially you can create your customized dex file and load and execute it.

like image 22
Peter Teoh Avatar answered Oct 07 '22 02:10

Peter Teoh