2014-02-19 87 views
1
.method public c()Ljava/lang/String; 
.locals 3 

const/4 v1, 0x0 

const-string v0, "wifi" 

invoke-virtual {p0, v0}, Lcom/genwen/looltv/start/Appstart;->getSystemService(Ljava/lang/String;)Ljava/lang/Object; 

move-result-object v0 

check-cast v0, Landroid/net/wifi/WifiManager; 

if-nez v0, :cond_1 

move-object v0, v1 

:goto_0 
if-eqz v0, :cond_2 

invoke-virtual {v0}, Landroid/net/wifi/WifiInfo;->getMacAddress()Ljava/lang/String; 

move-result-object v0 

if-eqz v0, :cond_0 

const-string v1, ":" 

const-string v2, "" 

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

move-result-object v0 

new-instance v1, Ljava/lang/StringBuilder; 

const-string v2, "8c0f" 

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

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

move-result-object v0 

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

move-result-object v0 

:cond_0 
:goto_1 
return-object v0 

:cond_1 
invoke-virtual {v0}, Landroid/net/wifi/WifiManager;->getConnectionInfo()Landroid/net/wifi/WifiInfo; 

move-result-object v0 

goto :goto_0 

:cond_2 
move-object v0, v1 

goto :goto_1 
.end method 

這是一個簡單的smali函數,它在從mac地址剝離:後從開始處返回具有'8c0f'的設備的mac地址。如何在smali函數中返回一個靜態結果

我希望它返回一個靜態MAC地址,如'8c0f0f0f0f0f0f0f'不是真正的MAC地址。我怎樣才能做到這一點?

+2

如果這是Java,我遠不如熟悉的語言比我還以爲我是。 – Rainbolt

+0

這不是java。它是小的。當它被反編譯回java時,它看起來更符合邏輯: – user3329615

+0

在java中,它看起來像這樣: http://pastebin.com/yMRngsGb – user3329615

回答

2

只是return-object v0之前,請執行下列操作

const-string v0, "8c0f0f0f0f0f0f0f" 

讓你完整的代碼會讀

const-string v0, "8c0f0f0f0f0f0f0f" 
return-object v0 

你也可以註釋掉,如果你想它使用StringBuilder的其他代碼。

0

這裏我使用apktool將java轉換爲smali。

Java代碼:

private static final String TAG = "Loop"; 

public static String getTag() 
{ 
    return TAG; 
} 

smali代碼:

# static fields 
.field private static final TAG:Ljava/lang/String; = "Loop" 

.method public static getTag()Ljava/lang/String; 
    .locals 1 

    .prologue 
    .line 35 
    const-string v0, "Loop" 

    .line 38 
    return-object v0 
.end method 
相關問題