A library for disassembling and analysing binary code.
The panopticon crate implements structures to model the in-memory representation of a program including is control flow, call graph and memory maps. The most important types and their interaction are as follows:
Project ├── Region │ └── Layer └── Program └── Function └── BasicBlock └── Mnemonic └── Statement
Panopticon models code as a collection of programs. Each
Program consists of functions. A
Function a graph with nodes representing a
sequence of instructions and edges representing jumps. These instruction sequences are
and contain a list of
Mnemonics. The meaning of each
Mnemonic is described in the [RREIL] language. Each mnemonic includes a sequence of
Statements implementing it.
Panopticon allows multiple programs per project. For example, imagine a C# application that calls into a native DLL written in C. Such an application would have two program instances. One for the CIL code of the C# part of the application and one for the AMD64 object code inside the DLL.
The in-memory layout of an executable is modeled using the
Cell types. All data is organized into
Region is an array of
Cells numbered from 0 to n. Each
Cell is an is either
undefined or has a value between 0 and 255 (both including).
Regions are read
only. Changing their contents is done by applying
Layer instance to them. A
reads part of a
Region or another
Layer and returns a new
Cell array. For example,
can decrypt parts of a
Region or replace individual
Cells with new
In normal operation there is one
Region for each memory address space, one on
Von-Neumann machines two on Harvard architectures. Other uses for
applying functions to
Cell array where the result is not equal in size to the
input (for example uncompressing parts of the executable image).
Address range with sub-byte pecision. Used to order instructions that don't occupy any space in the binary (e.g. Phi).
An uninterrupted sequence of machine code. Basic blocks cover a continuous address range.
Index of the basic block.
Iterator over basic blocks.
Memory conserving representation of IL code.
Iterator over serialized statements.
A constant value.
Binary file meta information. Starting point for disassembler routines.
The Error type.
A single function in the binary.
Result of a single disassembly operation.
Native ISA mnemonic.
Index of a mnemonic in a function. Local to a specific function.
Iterator over a range of mnemonics
A SSA variable name.
Named pointer inside a region.
A RREIL memory segment identifier.
Table mapping hashable values to and from numeric indices.
ISA used for testing. Single digits are interpreted as 32 bit constants, lower case letters as 32 bit registers or 1 bit flags depending on the context. First argument is the result. Upper case letters are opcodes.
A variable with known size.
Things that can be called.
Node in the control flow graph.
A range of
The kind of an error.
CPU the binary file is intended for.
A memory operation.
A RREIL operation.
A continuous address space. Regions are an array of cells numbered from 0. Each cell is either
A single IL statement.
A possibly compressed IL sequence.
UUIDs are used by RON to identify types, objects, events, etc.
A RREIL value.
CPU architecture and instruction set.
Convertable into a range of statements.
Additional methods for
Name table for RREIL code.
Convenient wrapper around
Segment table RREIL code.
Our string type.