Saturday, February 19, 2011

more smali syntax and running smali files

there are some examples of smali syntax written by the author of smali/baksmali JesusFreke here: http://code.google.com/p/smali/source/browse/trunk/examples/. most are rather technical, but still illuminating.

here's one that i modified slightly that shows a basic hello world app with a standard main method. also, in the comments you will see a way to quickly compile and run a smali file. this is sometimes quite useful in testing your code:
.class public LHelloWorld;

# Ye olde hello world application
# To assemble and run this on a phone or emulator:
#
# java -jar smali.jar -o classes.dex HelloWorld.smali
# zip HelloWorld.zip classes.dex
# adb push HelloWorld.zip /data/local
# adb shell dalvikvm -cp /data/local/HelloWorld.zip HelloWorld
#
# if you get out of memory type errors when running smali.jar
# give java more memory with -Xmx512m, like this:
# java -Xmx512m -jar smali.jar HelloWorld.smali

.super Ljava/lang/Object;

.method public static main([Ljava/lang/String;)V
    .registers 2

    sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;

    const-string v1, "hello,world!"

    # combine executing with adb shell commands and console output
    # and you have a very quick way to test code
    invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V

    return-void
.end method

15 comments :

  1. Great Article..Thanks for the sharing..

    Bigo live is a GooD APK.Connect friends.
    Install the application here.....

    Bigo Live App

    ReplyDelete
  2. Great survey, I'm sure you're getting a great response. auto reply text

    ReplyDelete
  3. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. appcloner

    ReplyDelete
  4. Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. hoverwatch cost

    ReplyDelete
  5. I found your this post while searching for some related information on blog search...Its a good post..keep posting and update the information. HDfilme

    ReplyDelete
  6. What is the meaning of this line in smali
    .field public static final z:Z = false

    ReplyDelete
  7. What is the meaning of this line in smali
    .field public static final z:Z = false

    ReplyDelete
  8. I am really impressed with your blog article, such great & useful information you mentioned here. I have read all your posts and all are very informative. Thanks for sharing and keep it up like this. 토토

    ReplyDelete
  9. Hello, I’m happy to see some great articles on your site. Would you like to come to my site later? My site also has posts, comments and communities similar to yours. Please visit and take a look 토토사이트

    ReplyDelete
  10. I would like to thnkx for the efforts you have put in writing this blog. I am hoping the same high-grade blog post from you in the upcoming as well. In fact your creative writing abilities has inspired me to get my own blog now. Really the blogging is spreading its wings quickly. Your write up is a good example of it. 사설토토

    ReplyDelete
  11. I like what you guys are up too. Such clever work and reporting! Keep up the superb works guys I¦ve incorporated you guys to my blogroll. I think it’ll improve the value of my site Feel free to visit my website; 야설

    ReplyDelete
  12. I am a fan of reading to add insight to information. Thank you for this great blog. this is here, the few months I am visiting and following you. What I really like about you is that your writing style. Feel free to visit my website;
    국산야동

    ReplyDelete
  13. Feels lovely'. Is excellence an item to look and quantify, is magnificence an inclination to detect or is excellence a plan to attempt? With each conceivable response to existing inquiries we get more inquiries all things considered. Feel free to visit my website; 일본야동


    ReplyDelete
  14. Android Cracking: More Smali Syntax And Running Smali Files >>>>> Download Now

    >>>>> Download Full

    Android Cracking: More Smali Syntax And Running Smali Files >>>>> Download LINK

    >>>>> Download Now

    Android Cracking: More Smali Syntax And Running Smali Files >>>>> Download Full

    >>>>> Download LINK mH

    ReplyDelete
  15. Bon site internet : Zonahobisaya
    Bon site internet : Zonahobisaya
    Bon site internet : Zonahobisaya
    Bon site internet : Zonahobisaya
    Bon site internet : Logo
    Bon site internet : Zonahobisaya
    Bon site internet : Zonahobisaya
    Bon site internet : Profil

    ReplyDelete

Do NOT post about or link to specific apps!