Die Java/Linux-Plattform Android enthält die Dalvik Virtual Machine. Die virtuelle Maschine verarbeitet Dateien im Dex File Format. Diese DEX-Dateien können mit dem vorgefertigten Tool dexdump näher untersucht werden. Das Tool kann mit Hilfe der Shell der Android Debug Bridge (adb) aufgerufen werden. Ein Beispieldump einer DEX-Datei könnte dann wie folgt aussehen:
DEX version '009'
DEX file header:
magic : 'dex
009'
checksum : 8d233641
signature : 3c8d...8111
file_size : 2364
header_size : 92
link_size : 0
link_off : 0 (0x000000)
string_ids_size : 36
string_ids_off : 92 (0x00005c)
string_objects_size : 1
class_ids_size : 9
class_ids_off : 380 (0x00017c)
field_ids_size : 3
field_ids_off : 416 (0x0001a0)
method_ids_size : 13
method_ids_off : 452 (0x0001c4)
class_defs_size : 6
class_defs_off : 608 (0x000260)
Class #0 header:
class_idx : 0
access_flags : 131073 (0x20001)
superclass_idx : 7
interfaces_off : 0 (0x000000)
sfields_off : 0 (0x000000)
ifields_off : 0 (0x000000)
dmeths_off : 800 (0x000320)
vmeths_off : 820 (0x000334)
Class #0 -
Class name : 'test/android/hello/HelloAndroid'
Access flags : 0x20001 (PUBLIC OPTIMIZED)
Superclass : 'android/app/Activity'
Interfaces -
Static fields -
Instance fields -
Direct methods -
#0 : (in test/android/hello/HelloAndroid)
name : '<init>'
type : '()V'
access : 0x0001 (PUBLIC)
code -
registers : 3
ins : 1
outs : 1
source_idx : 7
insns : 6 16-bit code units
0005fc: |[0005fc] test/android/hello/
HelloAndroid.<init>:
()V
000600: 0720 |0000: move-object v0, v2
000602: 0701 |0001: move-object v1, v0
000604: 6f01 0000 0100 |0002: invoke-direct {v1},
android/app/Activity.
<init>:()V
// method@0000
00060a: 0e00 |0005: return-void
exceptions : (none)
positions : 1
0x0000 line=7
locals : 1
0x0001 - 0x0006 reg=0 this Ltest/android/hello/
HelloAndroid;
Virtual methods -
#0 : (in test/android/hello/HelloAndroid)
name : 'onCreate'
type : '(Landroid/os/Bundle;)V'
access : 0x0001 (PUBLIC)
code -
registers : 9
ins : 2
outs : 2
source_idx : 7
insns : 29 16-bit code units
00060c: |[00060c] test/android/
hello/HelloAndroid.
onCreate:(Landroid/os/
Bundle;)V
000610: 0770 |0000: move-object v0, v7
000612: 0781 |0001: move-object v1, v8
000614: 0703 |0002: move-object v3, v0
000616: 0714 |0003: move-object v4, v1
000618: fa02 4c00 4300 |0004:
+invoke-super-quick {v3, v4},
[004c] // vtable #004c
00061e: 2103 0300 |0007: new-instance v3,
android/widget/TextView
// class@0003
000622: 0736 |0009: move-object v6, v3
000624: 0763 |000a: move-object v3, v6
000626: 0764 |000b: move-object v4, v6
000628: 0705 |000c: move-object v5, v0
00062a: 6f02 0200 5400 |000d: invoke-direct {v4, v5},
android/widget/TextView.
<init>:(Landroid/
content/Context;)V
// method@0002
000630: 0732 |0010: move-object v2, v3
000632: 0723 |0011: move-object v3, v2
000634: 1804 0000 |0012: const-string v4,
"Hello Android!" // string@0000
000638: f802 e900 4300 |0014:
+invoke-virtual-quick {v3,v4},
[00e9] // vtable #00e9
00063e: 0703 |0017: move-object v3, v0
000640: 0724 |0018: move-object v4, v2
000642: f802 6200 4300 |0019:
+invoke-virtual-quick {v3,v4},
[0062] // vtable #0062
000648: 0e00 |001c: return-void
exceptions : (none)
positions : 5
0x0000 line=11
0x0007 line=12
0x0011 line=13
0x0017 line=14
0x001c line=15
locals : 3
0x0001 - 0x001d reg=0 this Ltest/android/hello/
HelloAndroid;
0x0002 - 0x001d reg=1 icicle Landroid/os/Bundle;
0x0011 - 0x001d reg=2 tv Landroid/widget/TextView;
Class #1 header:
...Der Dalvik-Bytecode bezüglich des Code-Arrays ist im Dexdump rot markiert. Es kann festgestellt werden, dass die folgenden Abbildungen bzw. Umkehrabbildungen (Dalvik-Bytecode --> Dalvik-Assemblersprache) gelten:
0720 --> move-object v0, v2 0701 --> move-object v1, v0 6f01 0000 0100 --> invoke-direct {v1}, android/app/Activity.<init>:()V 0e00 --> return-void 0770 --> move-object v0, v7 0781 --> move-object v1, v8 0703 --> move-object v3, v0 0714 --> move-object v4, v1 fa02 4c00 4300 --> +invoke-super-quick {v3, v4}, [004c] 2103 0300 --> new-instance v3, android/widget/TextView 0736 --> move-object v6, v3 0763 --> move-object v3, v6 0764 --> move-object v4, v6 0705 --> move-object v5, v0 6f02 0200 5400 --> invoke-direct {v4, v5}, android/widget/TextView.<init>: (Landroid/content/Context;)V 0732 --> move-object v2, v3 0723 --> move-object v3, v2 1804 0000 --> const-string v4, "Hello Android!" f802 e900 4300 --> +invoke-virtual-quick {v3,v4}, [00e9]] 0703 --> move-object v3, v0 0724 --> move-object v4, v2 f802 6200 4300 --> +invoke-virtual-quick {v3,v4}, [0062] 0e00 --> return-void
Durch den Dexdump wird auch deutlich, dass die wichtige Methode onCreate als "virtuelle Methode" eingestuft ist. So, genug von Androiden für heute. ;-)
(Quelle: Android Goodies)
Keine Kommentare:
Kommentar veröffentlichen