smali An assembler/disassembler for Android's dex format

TypesMethodsAndFields - smali - Some general information about how types, methods and fields are represented in dalvik bytecode - An assembler/disassembler for Android‘s dex format - Google Project Hosting

TypesMethodsAndFields

Some general information about how types, methods and fields are represented in dalvik bytecode

Updated
Jul 20, 2011

Types

dalvik‘s
bytecode has two major classes of types, primitive types and reference
types. Reference types are objects and arrays, everything else is a
primitive.

Primitives are represented by a single letter. I didn‘t
come up with these abbreviations - they are what is actually stored in
the dex file, in string form. They are specified in the dex-format.html
document (dalvik/docs/dex-format.html in the AOSP repository)

V void - can only be used for return types
Z boolean
B byte
S short
C char
I int
J long (64 bits)
F float
D double (64 bits)

Objects take the form Lpackage/name/ObjectName; - where the leading L indicates that it is an object type, package/name/ is the package that the object is in, ObjectName is the name of the object, and ; denotes the end of the object name. This would be equivalent to package.name.ObjectName in java. Or for a more concrete example, Ljava/lang/String; is equivalent to java.lang.String

Arrays take the form [I - this would be an array of ints with a single dimension. i.e. int[] in java. For arrays with multiple dimensions, you simply add more [ characters. [[I = int[][], [[[I = int[][][], etc. (Note: The maximum number of dimensions you can have is 255).

You can also have arrays of objects, [Ljava/lang/String; would be an array of Strings.

Methods

Methods
are always specified in a very verbose form that includes the type that
contains the method, the method name, the types of the parameters and
the return type. All this information is required for the virtual
machine to be able to find the correct method, and to be able to perform
static analysis on the bytecode (for verification/optimization
purposes)

They take the form

Lpackage/name/ObjectName;->MethodName(III)Z

In this example, you should recognize Lpackage/name/ObjectName; as a type. MethodName is obviously the name of the method. (III)Z is the method‘s signature. III are the parameters (in this case, 3 ints), and Z is the return type (bool).

The method parameters are listed one right after another, with no separators between them.

Here‘s a more complex example:

method(I[[IILjava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

In java, this would be

String method(int,int[][],int,String,Object[])

Fields

Fields are likewise always specified in verbose form that includes the type that contains the field, the name of the field, and the type of the field. Again, this is to allow the virtual machine to be able to find the correct field, as well as to perform static analysis on the bytecode.

They take the form

Lpackage/name/ObjectName;->FieldName:Ljava/lang/String;

This should be pretty self-explanatory - it is the package name, the field name and the type of the field respectively.

smali An assembler/disassembler for Android's dex format

时间: 2024-10-21 04:52:28

smali An assembler/disassembler for Android's dex format的相关文章

Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the

问题: Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.C:\Program Files\Java\jdk1.7.0_45\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="D:/work/Android/android-sdk\tools&

Android自定义属性,format详解

博客园 博问 闪存 首页 新随笔 联系 管理 订阅 随笔- 90  文章- 6  评论- 57 Android自定义属性,format详解 1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name = "名称"> <attr name = "background" format = "reference" /> </declare-styleable> (2

Android 分Dex (MultiDex)

需要分Dex的理由想必大家都知道了.正是在ART以前的Android系统中,Dex文件对于方法索引是用一个short类型的数据来存放的.而short的最大值是65535,因此当项目足够大包含方法数目足够多超过了65535(包括引用的外部Lib里面的所有方法),当运行App,就会得到如下的错误提示. Unable to execute dex: method ID not in [0, 0xffff]: 65536 Conversion to Dalvik format failed: Unabl

解决Android单个dex文件不能超过65535个方法问题

一.找坑:谷歌规定单个dex文件中的方法不能超过65536的限制 我们编写项目过程中在工程的lib文件夹下引用的第三方插件jar包太多或者项目过大,编译运行时就有可能报出com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536错误.看到这个错误说明你的方法加起来已经超过了65536这个数目.但是谷歌规定单个dex文件中的方法不能超过65536的限制. 如下图所示,Android Studio 中的

Android &quot;multiple dex files define&quot; 错误

在Android开发中经常看到这个错误,产生的原因还是挺值得研究的. 如果是在eclipse上出现的这个问题,基本上可以判断为同一工程中存在相同的jar包,或者是不同的jar包,但是他们之间有相同的类,所以解决办法就是干掉对方. 在eclipse中如果删除jar之后还报错的话,可能是eclipse的缓存导致的,重启eclipse基本可以解决这个问题. 但是如果事情发生在 Android Studio 上,那么就复杂了.首先要排除eclipse中的那种情况,如果问题还没有解决那就要仔细了. 如果工

【Android SDK程序逆向分析与破解系列】之二:Android可执行程序DEX分析(一)

作者:郭嘉 邮箱:[email protected] 博客:http://blog.csdn.net/allenwells github:https://github.com/AllenWells [Android SDK程序逆向分析与破解系列]章节索引 一 DEX文件数据结构 DEX使用的数据类型如下表所示: u1~u8:表示1~8字节的无符号数. sleb128.uled128和uled128pl:DEX文件特有的LEB128数据类型.每个LEB128由1~5个字节组成,所有的字节组合在一起

解决Android单个dex文件不能超过65536个方法问题

当我们的项目代码过大时,编译运行时会报Unable to execute dex: method ID not in[0, 0xffff]: 65536)错误.当出现这个错误时说明你本身自己的工程代码中含有的太多的方法,或者你的工程lib文件夹下引用的第三方插件jar包有太多的方法,这两者的方法加起来已经超过了65536这个数目.而谷歌规定单个dex文件中的方法不能超过65536的限制. 那么这个时候,我们就需要分包处理解决.一般情况下的解决方案就是把整个项目工程包括jar,区分开来分解成两个d

[Android Security] DEX文件格式分析

copy from : https://segmentfault.com/a/1190000007652937 0x00 前言 分析 dex 文件格式最好的方式是找个介绍文档,自己再写一个简单的 demo 然后用 010Editor 对照着分析.文档可以参考官方文档http://source.android.com/devices/tech/dalvik/dex-format.html,英文差的也可以找个中文的,比如说我...... 010Editor 这个工具比较好用,之前分析 elf 文件也

android多dex打包问题

将android-support-multidex.jar放到libs下然后编译,出现如下错误: Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: android/support/multidex/MultiDex.class 原因是引入了多个相同的包,但是libs下明明就只有这一个包啊,经过各种尝试,最终