Skip to content
Ben Gruver edited this page Mar 3, 2021 · 34 revisions

About

smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation. The syntax is loosely based on Jasmin's/dedexer's syntax, and supports the full functionality of the dex format (annotations, debug info, line info, etc.)

The names "smali" and "baksmali" are the Icelandic equivalents of "assembler" and "disassembler" respectively. Why Icelandic you ask? Because dalvik was named for an Icelandic fishing village.

Curious what the smali format looks like? Here's a quick HelloWorld example to whet your appetite.

Got questions/comments? Need help? Come hang out in #smali on freenode.

News

2021-03-02 smali/baksmali v2.5.2 is out.

2021-03-02 smali/baksmali v2.5.1 is out.

2021-03-01 smali/baksmali v2.5.0 is out.

  • Adds support for the additional test-api hidden restriction api flag added in Android 11
  • Adds support for disassembling dex files that have identifiers with spaces, using the backtick syntax: `identifier with spaces`
  • Fixed a bug on mac where some unicode characters in file paths are treated as the same character (Thanks to tlundeen for reporting and submitting an initial fix -- even though I ended up not using it :))
  • A number of updates to the gradle build, to fix some deprecations and add support for compiling with a java 11 jdk
  • Changes

2020-02-05 smali/baksmali v2.4.0 is out.

  • Adds support for the new hidden restriction api flags introduced for framework dex files in Android 10
    • This includes a backwards-incompatible change to the Method and Field interfaces, which now have a new getHiddenApiRestrictions method.
  • Several small fixes and improvements to the rewriter functionality
  • Added a new DexBackedDexFile constructor that accepts a DexBuffer. Thanks huaxin-gg!
  • Changes

2019-09-19 smali/baksmali v2.3.3 is out.

2019-09-17 smali/baksmali v2.3.2 is out.

  • Added support for new quoted syntax for class and member names, which allows for spaces in these names
    • Support for member/class names with spaces is being added in the next dex version/api level
    • e.g. Lmy/class;->`member name with spaces`()V or Lmy/`class with spaces`;
    • The new quote syntax can be used anywhere, but spaces are only allowed when assembling with api level 30 or higher (note: api 30 is a placeholder for whatever api level the new dex format gets released in -- which will likely end up being api 30)
  • Rework the array payload element width checks to properly handle all cases
  • Changes

2019-08-29 smali/baksmali v2.3.1 is out.

  • Fix an issue with array payload width validation, thanks to melkonyan
  • Some minor api changes in DexBackedDexFile, to use the DexBacked-specific type for some sections
  • Gracefully handle a corner case involving array payload instructions with element width of 0
  • Improved some error messages related to finding embedded dex files in an oat file
  • Switched some lambdas to anonymous inner classes, to resolve some issues when running on Android P
  • Fixed an issue parsing method handle references
  • Changes

2019-08-07 smali/baksmali v2.3 is out.

  • This release adds support for the new cdex file format in Android P, and a few other changes required to support deodexing Android P images.
  • The were a few breaking changes in dexlib2's api. e.g.
    • MultiDexContainer was changed a bit, with a new DexEntry structure that is separate from the dex file it contains.
    • The indexed item specific methods in DexBackedDexFile were generalized into an IndexedSection object for each type of indexed item
    • Probably a couple of others.
  • Added support for 45cc and 4rcc immutable instruction (thanks aki-ks!)
  • Changes

2019-04-04 smali/baksmali v2.2.7 is out.

2019-01-23 smali/baksmali v2.2.6 is out

2018-08-28 smali/baksmali v2.2.5 is out

  • Support for 8.1 oat files, thanks to Albert Gorski
  • Multiple API improvements and bugfixes, thanks to Lanchon
  • Restructing of most util classes from util module to dexlib2 module
    • The util module is now mostly for utilities needed by both smali/baksmali, but aren't necessarily relevant to someone who is linking against just the dexlib2 library. E.g. command line parsing utilities, etc.
  • A fix for how 45cc instructions (invoke-polymorphic) are parsed, thanks to Albert Gorski
  • Added support for missing method handle types, thanks to Albert Gorski
  • Some code cleanup, thanks to A4Vision

2018-06-12 smali/baksmali v2.2.4 is out. This version adds support for dex versions 037, 038 and 039

2017-10-30 smali/baksmali v2.2.2 is out. This is a minor bugfix release.

2017-05-23 smali/baksmali v2.2.1 is out. This version adds support for deodexing O system images that use vdex files, and has a few other minor improvements and bug fixes.

2017-03-31 smalidea v0.05 is out. This version fixes an issue that prevented watches on registers from working in methods with switch statements.

2017-03-22

  • smali/baksmali v2.2.0 is out, which is the first non-beta release of the new v2.2 stuff. This version contains significant changes to the command line interface, so be sure to read smali help/baksmali help, and take a look at the wiki page
  • smalidea v0.04 is out. It has a few bug fixes, and most importantly, works with recent versions of IDEA.

2016-10-16 v2.2b4 is out, which fixes a few remaining issues in 2.2

2016-10-03 v2.2b3 is out, which fixes some issues related to proguard and jcommander not getting along with each other.

2016-10-02 v2.2b1 is out!

  • A completely new CLI
  • Support for N deodexing
  • This is a beta release. If you see something wonky or not working, file bugs!
  • More info on the wiki page for v2.2

2016-07-16 v2.1.3 is out. This is another minor bugfix version.

2016-04-08 v2.1.2 is out. This has a few bugfixes, and adds initial support for the new "037" dex format, courtesy of Alex Light.

2016-01-10 v2.1.1 is out! This adds support for deodexing 64 bit oat files, as well as some fixes for a few other deodexing issues.

2015-09-30 v2.1.0 is out! This adds support for deodexing Art oat files from Marshmallow+ devices. See DeodexInstructions for more info.

2015-09-24 v2.0.8 is out! This is a bugfix release.

2015-04-30 v2.0.6 is out! Bugfixes, etc.

  • Fixes a bug with parameter annotations (credit: Jiri Hrushka)
  • Improves the build experience when dx is not on path
  • baksmali should be working correctly on windows 8.1 now
  • Fixes for the deodexerant makefile (credit: Victor Kaiser-Pendergrast)
  • Various other bugfixes, etc. (thanks to Rover12421 for a handful of small fixes)

2015-01-20 v2.0.5 is out! It fixes a multi-threading issue in baksmali in 2.0.4, and it switches the default for implicit references to no-implicit-references, for better backwards compatibility.

2015-01-20 The v2.0.4 release is faulty. The download has been removed, and a fixed v2.0.5 will be released shortly.

2015-01-20 v2.0.4 is out

  • Added optional functionality to add the resource name as a comment to likely resource accesses. See the help for the new -i/--resource-id-files option (credit: Jeff Smith/whydoubt)
  • Added comments for constants that are likely an encoded float/double (credit: Jeff Smith/whydoubt)
  • Added support for implicit method/field references within a class, which allows you to leave off the class name when referencing a field/method within the current class.
  • Changed short option for --check-package-private-access to -k (from -K) (thanks to yyjdelete for noticing/reporting a problem with an interim change related to this)
  • Added the ability to disassemble a file other than classes.dex within an apk (credit: Connor Tumbleson/iBotPeaches)
  • other misc bugfixes, etc.

2014-01-17 v2.0.3 is out

  • More bugs being slaughtered in this release. Notably, smali's memory footprint should now be reduced, although it's still a good idea to use -JXmx512m when using multiple threads.
  • We also managed to sneak in some new features as well. Thanks to whydoubt, it's now possible to add a comment with the resource name when a resource id is referenced in the bytecode as a constant, using the new -i flag.
  • As a reminder, the googlecode downloads are deprecated and downloads are now hosted at bitbucket

11-10-13 v2.0.2. Bugs are dead. Long live bugs.

10-10-13 v2.0. 2.0 is finally out of beta and ready for mass consumption. Consume away!

Administrivia:

  • The primary download location has been moved to bitbucket, per the impending deprecation of downloads on googlecode.
  • The dexlib_redesign branch in the repository has been merged into the master branch, and the dexlib_redesign branch itself is dead.
  • The old dexlib library is now gone from the repository, in favor of the new dexlib2 library.
  • The old master branch is available as the v1.4.3 tag - there was never an actual 1.4.3 release, but it contains a few changes that occurred on the master branch after the 1.4.2 release. A big thanks goes out to Izzat "TwoSheds" Bahadirov for significant effort in helping me out with the dexlib2 redesign, and to all the people who helped test and reported bugs for the 2.0 beta.

9-14-13 v2.0b6. This version has some significant reworking of how instruction rewriting is handled, as well as various other bug fixes. For people using dexlib2 directly, you'll want to take note of the new MethodImplementationBuilder and/or MutableMethodImplementation classes, which should help streamline creating new method implementations, or modifying existing method implementations.

6-15-13 v2.0b5, now with 34.2% more bug fixes! Downloads: smali/baksmali

5-12-13 v2.0b4, which fixes some new issues introduced in b3.

5-12-13 A new 2.0b3 release, which adds multithreading for baksmali.

5-7-13 A minor update to the beta (v2.0b2), that fixes a reported dexodexing issue.

5-7-13 A beta release (v2.0b1) is available for the next major of smali/baksmali. You can find more info on the wiki page. Feel free to grab the beta jars from the downloads page and give it a spin. Something doesn't work? Please file a bug report!

2-14-13 smali/baksmali v1.4.2 is out, with a handful of bugfixes.

11-19-12 smali/baksmali v1.4.1 is out. This is mostly just a bugfix release, although it does include support for a minor change in the way odex files are generated in api 17.

9-16-12 smali/baksmali v1.4.0 is out! The primary feature in this release is that deodexing has been much simplified. This has actually been implemented for a month or two, but I'm just now getting around to doing a release. See the deodex instructions for additional information. Additionally, for the developers out there, you'll notice that the mvn build has been replaced with a gradle build. The build instructions have been updated accordingly.

6-20-12 smali/baksmali v1.3.3 is out. cleanup, bugfixes, more cleanup. Did I mention cleanup?

1-11-12 smali/baksmali v1.3.2 is out. This version has a few misc. bugfixes

11-20-11 smali/baksmali v1.3.0 is out! This version now supports Honeycomb and Ice Cream Sandwich. More details here.
Important When deodexing pre-ICS odex files, you must use the new --api-level/-a option to specify the api level

8-22-11 smali/baksmali v1.2.8 is out. This fixes a problematic bug that crept into 1.2.7

8-13-11 smali/baksmali v1.2.7 is out. This is a bugfix release, with a small additional feature (helper comments for synthetic access methods)

12-23-10 smali/baksmali v1.2.6 is out, with support for gingerbread odex files

10-31-10 smali/baksmali v1.2.5 is out. This is a minor release with a few small bugfixes

8-1-10 smali/baksmali v1.2.4 is out, with a number of bugfixes blog post

6-13-10 smali/baksmali v1.2.3, now with frozen yogurt! blog post

4-03-10 smali/baksmali v1.2.2 is out! This is again mostly a bugfix release, but it also has significant performance improvements as well. More details here

3-06-10 smali/baksmali v1.2.1 is out! This is mostly a bugfix release, with a few performance improvements and enhancements.

2-22-10 smali/baksmali v1.2 is out! As usual, more info on my blog

12-25-09 smali/baksmali v1.1 is out. More info on my blog

11-08-09 smali/baksmali v1.0 is out. More info on my blog

9-10-09 smali/baksmali v0.96 is out. baksmali now supports deodexing .odex files! For the first time you can turn those pesky .odex files into much-easier-to-use classes.dex files. Here are instructions on how this magic is performed.

NOTE deodexerant is just a helper binary that runs on the phone and talks to baksmali. It doesn't do much of anything interesting in and of itself. Unless you want to dump some vtables or something :)

8-29-09 smali/baksmali v0.95 is out. The major change in this version is a re-implemented version of dexlib, as well as changes in smali/baksmali to work with the new dexlib. Also, I've optimized baksmali, so it should run much much quicker now (up to 4x quicker). smali should also be a bit quicker, but nothing you'll probably notice.

As far as new functionality goes, baksmali will now output registers that are mapped to method parameters using a p<n> syntax, instead of the normal v<n> syntax. i.e. p0 is the first method parameter (or the "this" reference, for non-static methods), p1 is the second method parameter and so on. If you want to disable this functionality, you can use the -p command line arg.


7-27-09 smali/baksmali v0.94 is available. This is a bugfix release, a few typo fixes here and there, plus it should be compatible with java 5 now (for the Mac users out there)

7-3-09 baksmali v0.93 is available on the download tab. v0.92 had a template issue that prevented it from running.


7-2-09 smali/baksmali v0.92 has been released. This is a minor bugfix release. Thanks to Stericson and Josef Pfleger for the bug reports!


6-23-09 The first release of baksmali (v0.91) is out! Also, a new version of smali, also v0.91, with a number of improvements and fixes. Still no documentation.. I'll get there eventually.


6-7-09 After lots and lots of work, the first release of smali is out finally! You can grab it from the downloads tab. I'll try and get a wiki going with some documentation, as far as usage and syntax goes. For now, you can look at the examples and tests to see the syntax. There are tests for every opcode, so you should be able to find the syntax you need.

6-3-09 I've been whipping smali into shape the past few days. I should be getting close to a release soon! Currently, it should be able to handle all the features supported by the dex format. I still need to spend some time with the error handling, move all the tests from HelloWorld2.smali to the new junit-tests testing framework, and write more examples.


5-9-09 I've just added support for packed-switch and sparse-switch, and now smali supports the full set of dex opcodes. Woot! There's still a decent amount of work to be done though. I need to implement try blocks, annotations, debug/line info, add better exception handling in the parsing code, write a real front end, etc.



More

To see some examples of the syntax, take a look at examples. This contains examples of how various features are implemented in smali.

The lexer/parser for smali is built with ANTLR v3, and the dex file generation is done by dexlib, a library I have written to read in and write out dex files.

baksmali uses dexlib to read in dex files, and the StringTemplate library (a companion library to ANTLR) to generate the disassembly.


Developed With:
The best Java IDE