Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

smali structure of methods and classes

I have recently dug into some smali code and would love learning it. I have checked the dalvik bytecode reference but I couldn't find a structure reference as to when/how to use these

.locals
.local
.registers
.prologue
.line
.annotation
.parameter

Do you know other resources to explain more of the smali structure?

like image 702
Aivan Monceller Avatar asked Oct 22 '22 01:10

Aivan Monceller


1 Answers

Most of these, with the exception of .locals, .registers and .annotation, are a part of the debug information that is stored as part of a method. You can find more information about these in the debug_info_item section in the dex-format document.

For the .locals and .registers directive, these are two different ways you can specify the number of registers that are available in the method (i.e. the registers_size field of the code_item, as per the dex-format document). You can find more information about the differences between the two on the Registers wiki page on the smali googlecode site.

And finally, the .annotation directive defines an annotation. You can find more information in the dex-format document. Specifically, you'll want to look at the following items:

  • annotations_directory_item: contains references to all the class, method, field and parameter annotations for a class
  • annotation_set_ref_list: contains references to the annotations associated with the parameters for a method
  • annotation_set_item: contains a list of annotations that can be associated with a method, field or class
  • encoded_annotation: stores a single annotation
like image 94
JesusFreke Avatar answered Nov 04 '22 00:11

JesusFreke