JesusFreke / smali

smali/baksmali
6.29k stars 1.07k forks source link

Is have any idea about replace instruction #774

Closed Lemniscate317 closed 3 years ago

Lemniscate317 commented 4 years ago

My English is not very good , so i try to write my problem clearly.

After unpack the protect apk , i can get a not full dex . The method 's instruction is extract. like this

# direct methods
.method constructor <init>(Lcom/aipao/hanmoveschool/activity/RunActivity$1;Landroid/app/AlertDialog;)V
    .locals 0

    return-void

    nop

    nop

    nop

    nop

    nop

    nop

    nop
.end method

And now i can get the instruction in byte. And i also want to find a way to write it into the dex automate. I google it , stackoverflow it . But i can't find a way to solve my problem.

If the not full dex is like the above code , i can write it back use the offset. But if the not full dex not have enough space like below code , i can't write it back directly because it will cross itself's code limit.

# direct methods
.method constructor <init>(Lcom/aipao/hanmoveschool/activity/RunActivity$1;Landroid/app/AlertDialog;)V
    .locals 0

    return-void
.end method

I need some advice , hope your reply , thank you

Lemniscate317 commented 4 years ago

I know the dexlib2/baksmali api have the rewrite method can rewrite , but it seem i need to analysis the byte code which i get one by one , i think it is difficult and hard to do it . So i want to know is there any idea to write it back