Smali an assembler/disassembler for Android s DEX format

Source: Internet
Author: User

Typesmethodsandfields-smali-some General Information-about-types, methods and fields is represented in Dalvik byt Ecode-an Assembler/disassembler for Android ' s Dex format-google Project Hosting

Typesmethodsandfields

Some General Information-about-types, methods and fields is represented in Dalvik bytecode

Updated
Jul,
Types

Dalvik ' s bytecode has a major classes of types, primitive types and reference types. Reference types is objects and arrays, everything else is a primitive.

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

V Void-can only is used for return types
Z Boolean
B Byte
S Short
C Char
I Int
J Long (BITS)
F Float
D Double (up to bits)

Objects take the form lpackage/name/objectname; -where the leading L indicates that it's an object type, Packag E/name/is the package, the "object is", ObjectName is the name of the object, and; Denotes the end of the object name. This would is equivalent to package.name.ObjectName in Java. Or for a more concrete example, ljava/lang/string; was equivalent to java.lang.String

Arrays take the form [I -This would is 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 has is 255).

You can also has arrays of objects, [ljava/lang/string; would is an array of Strings.

Methods

Methods is 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 are required for the virtual machine to being able to find the correct method, and to being 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 is the parameters (in this case, 3 ints), and Z is the return type (BOOL).

The method parameters is 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 is

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

Fields is 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-perform static analysis on The bytecode.

They take the form

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

This should was 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.