How do you handle smali jumps (conditions, exceptions, etc...) in big files / methods

StackOverflow https://stackoverflow.com/questions/20531653

  •  31-08-2022
  •  | 
  •  

Pergunta

Today I was modifying some rom files in a little mod I'm creating. Some of the smali methods I had to modify were huge, around 1200 lines of smali from an anonymous class. Following code with a lot of jumps was a nightmare. I tried to create some kind of schematic first but if became a real mess too. So, how do you work with big smali files? Do anybody know if there exist any kind of flow viewer for a function or something?

Thanks in advance.

Foi útil?

Solução

First thing is to make sure you have good syntax highlighting. This lists a few options: http://androidcracking.blogspot.com/search/label/syntax%20highlighting. I prefer Sublime syntax highlighting, because it helps check your syntax, and I wrote it.

If you have access to it, IDA Pro will show you control flow graphs, which can help you understand things at a high level. You can't do modifications from there and it's not free.

Rather than working entirely in Smali, consider using a decompiler. It will turn the Smali into something more high level. It will be easier to understand the code and pinpoint where you want to make changes. This will reduce the amount of Smali you'll need to ingest.

For decompilers, I recommend:

  • dex2jar + jdgui, this is what most people use and works decently
  • jadx, super clean loops, converts dex directly, but is a little verbose
  • dex2jar + luyten, fewer errors than jd-gui, less verbose than jadx
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top