Smali injection code for commonly used Android
1. Add log information
Const-string v3, "SN"
invoke-static {v3,v0}, Landroid/util/log;->v (ljava/lang/string; ljava/lang/string;) I
2. Pop-up message box
New Alertdialog.builder (self)
. Settitle ("Normal dialog box")
. Setmessage ("Hello, android!")
. Show ();
New-instance V1,landroid/app/alertdialog$builder;
Invoke-direct {v1,p0}, landroid/app/alertdialog$builder;-><init> (Landroid/content/context;) V
. Line 29
. local V1,builder:landroid/app/alertdialog$builder;
Const-string v2, "\u666e\u901a\u5bf9\u8bdd\u6846"
invoke-virtual {v1,v2}, Landroid/app/alertdialog$builder;->settitle (ljava/lang/charsequence;) Landroid/app/ Alertdialog$builder;
. Line 31
Const-string v2, "\u4f60\u597d\uff0candroid!"
invoke-virtual {v1,v2},landroid/app/alertdialog$builder;->setmessage (ljava/lang/charsequence;) Landroid/app/ Alertdialog$builder;
. Line 52
invoke-virtual {v1},landroid/app/alertdialog$builder;->create () Landroid/app/alertdialog;
Move-result-object v2
invoke-virtual {v2},landroid/app/alertdialog;->show () V
Insert the above Smali code in front of the return-void statement of the CREATE function in Mainactivity.smali
. line command does not affect results
3. Stuck program Running
Method One:
try{
Thread.Sleep (60*1000);
}catch (Interruptedexception e) {
E.printstacktrace ();
}
. Line 69
CONST-WIDE/32 v1,0xeff0
: Try_start_0
#v1 = (Longlo); v2= (LongHi);
invoke-static {v1,v2},ljava/lang/thread;->sleep (J) V
: Try_end_0
. catch ljava/lang/interruptedexception; {: Try_start_0. Try_end_0}: Catch_0
. Line 87
: goto_0
#v0 = (conflicted);
#此后面是try后的内容
Return-void
. Line 70
: Catch_0
#v0 = (uninit);
Move-exception V0
. Line 72
. local V0, e:ljava/lang/interruptedexception;
#v0 = (Reference);
invoke-virtual {v0}, Ljava/lang/interruptedexception;->printstacktrace () V
Goto:goto_0
Method Two:
Android.os.SystemClock.sleep (60*1000);
Const-wide/32 V0, 0xea60
invoke-static {v0, v1}, Landroid/os/systemclock;->sleep (J) V
4. Stack trace (call relationship)
#new Exception ("Print Trace"). Printstacktrace ();
New-instance v0,ljava/lang/exception;
Const-string v1, "Print trace"
Invoke-direct {v0,v1}, ljava/lang/exception;-><init> (ljava/lang/string;) V
invoke-virtual {v0}, Ljava/lang/exception;->printstacktrace () V
The stack trace information records all the methods that were called during the execution of the program from Boot to Printstacktrace (). View stack trace information from bottom to top,
Find the first piece of information that begins with Com.android.stackTrace.
The stack trace information is the warn level, and the tag name is system.err by the system command. Command line: adb logcat-s system.err:v *:w
5.Method Profiling (call relationship)
#android. Os.Debug.startMethodTracing ("123"); "123" is the file name
#a ();
#android. os.Debug.stopMethodTracing ();
Android-manifest.xml add SD card Write permission
<user-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
#android. Os.Debug.startMethodTracing ("123");
Const-string V0, "123"
invoke-static {v0}, landroid/os/debug;->startmethodtracing (ljava/lang/string;) V
#android. os.Debug.stopMethodTracing ();
invoke-static {}, landroid/os/debug;->stopmethodtracing () V
The root directory of the SD card is generated 123.trace
Analysis command:
ADB pull/mnt/sdcard/123.trace
TraceView 123.trace