您好,我想在此Smali文件中添加一个消息,但我不了解其工作原理。我无法将Java代码转换为Smali。
我想显示我的V2变量。我尝试这样: invoke-virtual {v2},Landroid / widget / Toast;-> show()V
但是不起作用...启动时应用程序崩溃。谢谢,谢谢您!
Entery码:
.class public final Lcom/sube/subemobileclient/b/b/b/b/b/a$a;
.super Ljava/lang/Object;
# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Lcom/sube/subemobileclient/b/b/b/b/b/a;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x9
name = "a"
.end annotation
# instance fields
.field public a:B
.field public b:B
.field public c:[B
# direct methods
.method public constructor <init>()V
.locals 0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public constructor <init>(BB[B)V
.locals 0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-byte p1, p0, Lcom/sube/subemobileclient/b/b/b/b/b/a$a;->a:B
iput-byte p2, p0, Lcom/sube/subemobileclient/b/b/b/b/b/a$a;->b:B
iput-object p3, p0, Lcom/sube/subemobileclient/b/b/b/b/b/a$a;->c:[B
return-void
.end method
# virtual methods
.method public final toString()Ljava/lang/String;
.locals 3
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
new-instance v1, Ljava/lang/StringBuilder;
const-string v2, "Sector: "
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
iget-byte v2, p0, Lcom/sube/subemobileclient/b/b/b/b/b/a$a;->a:B
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, "line.separator"
invoke-static {v1}, Ljava/lang/System;->getProperty(Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
new-instance v1, Ljava/lang/StringBuilder;
const-string v2, "Key Type: "
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
iget-byte v2, p0, Lcom/sube/subemobileclient/b/b/b/b/b/a$a;->b:B
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, "line.separator"
invoke-static {v1}, Ljava/lang/System;->getProperty(Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
new-instance v1, Ljava/lang/StringBuilder;
const-string v2, "Key: "
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
iget-object v2, p0, Lcom/sube/subemobileclient/b/b/b/b/b/a$a;->c:[B
invoke-static {v2}, Ljava/util/Arrays;->toString([B)Ljava/lang/String;
**HEREHEREHERE** So message to display = "Key: ...."
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, "line.separator"
invoke-static {v1}, Ljava/lang/System;->getProperty(Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
.end method
JAVA
public final String toString() {
StringBuilder stringBuilder = new StringBuilder();
StringBuilder stringBuilder2 = new StringBuilder("Sector: ");
stringBuilder2.append(this.f892a);
stringBuilder.append(stringBuilder2.toString());
stringBuilder.append(System.getProperty("line.separator"));
stringBuilder2 = new StringBuilder("Key Type: ");
stringBuilder2.append(this.f893b);
stringBuilder.append(stringBuilder2.toString());
stringBuilder.append(System.getProperty("line.separator"));
stringBuilder2 = new StringBuilder("Key: ");
stringBuilder2.append(Arrays.toString(this.f894c));
stringBuilder.append(stringBuilder2.toString());
stringBuilder.append(System.getProperty("line.separator"));
return stringBuilder.toString();
}
答案 0 :(得分:0)
您可以像使用任何Android App一样从Java生成Smali代码。因此,您只需编写一个包含您的代码的非常小的Android应用即可。
在AndroidStudio中创建一个包含代码的简单应用。编译应用程序,然后使用apktool
反编译apk文件,然后将Java代码转换为Smali代码。
最简单的方法应该是创建一个新函数,然后将其注入现有的Smali代码中并从现有函数中调用。
或者以相同的方式,但是使用一些快捷方式:
.java-> .class-> dex-> smali
将Java编译为类文件(必须使用Java 7作为目标文件)。然后使用Android SDK中的dx
(java -jar dx.jar
)工具将代码转换为dex文件。最后使用apktool
对其进行反编译。