如何使用org.jf.dexlib2在dexfile中获取指令的字节码

时间:2016-04-25 05:36:16

标签: java android dalvik dex smali

我想得到指令的字节码,但这段代码只能得到操作码的字节码。例如0x38 01 FB FF表示if-eqz v1, -0x5。我只能得到{ {1}}表示0x38,但我不知道如何获取if-eqz,这意味着0x01 FB FF

v1, -0x5

1 个答案:

答案 0 :(得分:0)

您可以使用baksmali' -D选项打印dex文件的带注释的十六进制转储。这将生成一个2列十六进制转储,其中左列包含原始字节值,右列包含有关这些字节的注释,根据dex规范。

例如:

> baksmali -N -D penroser.dump penroser.apk
> less penroser.dump

... (lots of other stuff :))

                           |[26] code_item: Lafzkl/development/mColorPicker/views/ColorPickerView;->pointToHue(F)F
0075f4: 0600               |  registers_size = 6
0075f6: 0200               |  ins_size = 2
0075f8: 0100               |  outs_size = 1
0075fa: 0000               |  tries_size = 0
0075fc: 8690 0100          |  debug_info_off = 0x19086
007600: 2100 0000          |  insns_size = 0x21
                           |  instructions:
007604: 1503 b443          |    const/high16 v3, 1135869952 # 360.000000
007608: 5441 1e00          |    iget-object v1, v4, Lafzkl/development/mColorPicker/views/ColorPickerView;->mHueRect:Landroid/graphics/RectF;
00760c: 6e10 a700 0100     |    invoke-virtual {v1}, Landroid/graphics/RectF;->height()F
007612: 0a00               |    move-result v0
007614: 5212 3b00          |    iget v2, v1, Landroid/graphics/RectF;->top:F
007618: 2e02 0502          |    cmpg-float v2, v5, v2
00761c: 3b02 0900          |    if-gez v2, +0x9
007620: 1205               |    const/4 v5, 0
007622: a802 0503          |    mul-float v2, v5, v3
007626: c902               |    div-float/2addr v2, v0
007628: a702 0302          |    sub-float v2, v3, v2
00762c: 0f02               |    return v2
00762e: 5212 3800          |    iget v2, v1, Landroid/graphics/RectF;->bottom:F
007632: 2d02 0502          |    cmpl-float v2, v5, v2
007636: 3d02 0400          |    if-lez v2, +0x4
00763a: 0105               |    move v5, v0
00763c: 28f3               |    goto -0xd
00763e: 5212 3b00          |    iget v2, v1, Landroid/graphics/RectF;->top:F
007642: c725               |    sub-float/2addr v5, v2
007644: 28ef               |    goto -0x11
007646: 0000               |