-
Notifications
You must be signed in to change notification settings - Fork 273
src_code_structure
joelpx edited this page Feb 3, 2016
·
1 revision
-
lib/_init_.py : definition of two important classes :
GlobalContextandAddrContext. The first one contains all preferences and it's in charge to load the binary. In all files, the instance is namedgctx. The second class is a context for a dump or a decompilation. It contains the start address, the flow graph, ... It's named asctx. -
lib/fileformat :
- elf.py, pe.py, raw.py : loaders for the appropriate file type.
- pefile2.py : is a wrapper to pefile with a better support of symbols.
-
binary.py : the
Binaryclass is a wrapper to all loaders. It runsc++filtto demangle symbols. There is also aSectionAbswhich is an abstraction of all sections.
- lib/database.py : all information are serialized with msgpack then compressed with zlib. Contains symbols, defined functions, ...
-
lib/disassembler.py : loads the binary class, manages the database (renaming, jumptables, ...), generates flow graphs, dump disassembly, ... Named in the code as
dis. -
lib/memory.py : The
Memoryclass contains a dictionnaryaddress -> [size, type, priv_value]. For FUNCTION and CODE,priv_valueis the function id. -
lib/analyzer.py : analyze the flow graph, operands, check if the function returns or not, ... It fills the
Memoryclass. - lib/output.py : main abstract class to print disassembly.
Architecture dependant :
-
lib/arch/NAME/utils.py : specifies which instruction is a jump (condtional or not), a call, ... Set a symbol for some instructions (example, for MIPS the
beqinstruction must be printed as ==). - lib/arch/NAME/output.py : defines how to print instructions and operands. The class inherits of lib/output.py.
-
lib/arch/NAME/process_ast.py : assign colors, replace instructions in
lifor MIPS, ... - lib/arch/NAME/_init_.py : list of functions defined in process_ast.py.
Pseudo-decompiler algorithm :
- lib/ast.py : define multiple classes to create the ast and to print it.
- lib/graph.py : contains the graph definition. The loop detection algorithm is here.
- lib/generate_ast.py : with the graph and detected loops, it creates the ast.
User-interface :
- lib/ui/console.py : this is the shell.
- lib/ui/readline.py : key press manager for the console.
-
lib/ui/window.py : abstract class to display an
Outputclass. - lib/ui/visual.py : ncurses interface, inherits from window.py.
- lib/ui/inlineed.py : inline editor. It inherits from window.py.
- lib/ui/vim.py : exports output for Vim.
Others :
- lib/custom_colors.py : here you can set your own colors.
- lib/colors.py : print strings in color.
- lib/utils.py
- lib/exceptions.py