关闭

android 反编译smali 学习

249人阅读 评论(0) 收藏 举报
package com.city.list.main;


import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;




public class MainActivity extends Activity
{
	
	Button btn;


	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		getCity("", null, 1);
	}


	public static void getCity(String aa,v bb, int cc){
		y.a(aa);
		Log.e("xx", aa);
		Log.e("xx", bb+"vvvvvvvvvv");
		Log.e("xx", aa+bb);
	}
	
}

.class public Lcom/city/list/main/MainActivity;
.super Landroid/app/Activity;
.source "MainActivity.java"


# instance fields
.field btn:Landroid/widget/Button;


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 9
    invoke-direct {p0}, Landroid/app/Activity;-><init>()V

    return-void
.end method

.method public static getCity(Ljava/lang/String;Lcom/city/list/main/v;I)V
    .locals 3
    .param p0, "aa"    # Ljava/lang/String;
    .param p1, "bb"    # Lcom/city/list/main/v;
    .param p2, "cc"    # I

    .prologue
    .line 23
    invoke-static {p0}, Lcom/city/list/main/y;->a(Ljava/lang/String;)V

    .line 24
    const-string v0, "xx"

    invoke-static {v0, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 25
    const-string v0, "xx"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, "vvvvvvvvvv"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 26
    const-string v0, "xx"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-static {p0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 27
    return-void
.end method


# virtual methods
.method public onCreate(Landroid/os/Bundle;)V
    .locals 3
    .param p1, "savedInstanceState"    # Landroid/os/Bundle;

    .prologue
    .line 17
    invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V

    .line 18
    const v0, 0x7f030002

    invoke-virtual {p0, v0}, Lcom/city/list/main/MainActivity;->setContentView(I)V

    .line 19
    const-string v0, ""

    const/4 v1, 0x0

    const/4 v2, 0x1

    invoke-static {v0, v1, v2}, Lcom/city/list/main/MainActivity;->getCity(Ljava/lang/String;Lcom/city/list/main/v;I)V

    .line 20
    return-void
.end method
</pre><pre name="code" class="plain">

java文件和smali 文件的对比学习!

Smali语法简单介绍如下

       Davlik字节码中,寄存器都是32位的,能够支持任何类型,64位类型(Long/Double)用2个寄存器表示;

       Dalvik字节码有两种类型:原始类型;引用类型(包括对象和数组)

              原始类型v   void  只能用于返回值类型

                                Z   boolean

                                B   byte

                                S   short

                                C   char

                                 I    int

                                J    long(64位)

                                F   float

                                D   double(64位)

              对象类型Lpackage/name/ObjectName;  相当于java中的package.name.ObjectName;解释如下:

                                 L:表示这是一个对象类型

                                 package/name:该对象所在的包

                                 ;:表示对象名称的结束

              数组的表示形式:

                                  [I  :表示一个整形的一维数组,相当于java的int[];

                                  对于多维数组,只要增加就行了,[[I = int[][];注:每一维最多255个; 

               对象数组的表示形式:

                                   [Ljava/lang/String    表示一个String的对象数组;

  

               方法的表示形式:

                                   Lpackage/name/ObjectName;——>methodName(III)Z  详解如下:

                                   Lpackage/name/ObjectName  表示类型

                                   methodName   表示方法名

                                   III   表示参数(这里表示为3个整型参数)

                                   说明:方法的参数是一个接一个的,中间没有隔开;

                

                 字段的表示形式:

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

                                    即表示: 包名,字段名和各字段类型

 

                  有两种方式指定一个方法中有多少寄存器是可用的:

                                     .registers  指令指定了方法中寄存器的总数

                                     .locals        指令表明了方法中非参寄存器的总数,出现在方法中的第一行

 

        方法的传参:

                当一个方法被调用的时候,方法的参数被置于最后N个寄存器中;

                          例如,一个方法有2个参数,5个寄存器(v0~v4)

                                      那么,参数将置于最后2个寄存器(v3和v4)

                 非静态方法中的第一个参数总是调用该方法的对象;

                 说明:对于静态方法除了没有隐含的this参数外,其他都一样

 

          寄存器的命名方式:

                  V命名

                  P命名  第一个寄存器就是方法中的第一个参数寄存器

                  比较:使用P命名是为了防止以后如果在方法中增加寄存器,需要对参数寄存器重新进行编号的缺点

                  特别说明一下:Long和Double类型是64位的,需要2个寄存器

                           例如:对于非静态方法

                                       LMyObject——>myMethod(IJZ)V;

                                       有4个参数:LMyObject,int,long,bool;   需要5个寄存器来存储参数;

                                                            P0    this

                                                            P1    I (int)

                                                            P2,P3  J (long)

                                                            P4    Z(bool)


再分享个反编译工具!


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:947次
    • 积分:53
    • 等级:
    • 排名:千里之外
    • 原创:4篇
    • 转载:2篇
    • 译文:0篇
    • 评论:0条
    文章分类