Module pychrysalide.arch.operands
Interface ProxyFeeder
Interface RenameableOperand
Interface RenamedOperand
Interface TargetableOperand
Class ImmOperand
Class KnownImmOperand
Class ProxyOperand
Class RegisterOperand
Class TargetOperand
Module pychrysalide.arch.operands
Documentation
This module contains implementations for most common operand usages.
These operands are usually added to objects such as ArchInstruction
when disassembling a binary.
Interfaces
Classes
Interface ProxyFeeder
ProxyFeeder gives an interface for operands which aim to provide a dynamic content.
A typical class declaration for a new implementation looks like:
class NewImplem(GObject.Object, ProxyFeeder):
...
The following methods have to be defined for new implementations:
The object can be compared using rich methods (like <=
or !=
).
Hierarchy
gobject.GInterface ╰── pychrysalide.arch.operands.ProxyFeeder
Methods
__cmp__(self, other)
Abstract method used to compare the proxy feeder with another one. This second object is always an ProxyFeeder
instance.
This is the Python old-style comparison method, but Chrysalide provides a glue to automatically build a rich version of this function.
_print(self, line)
Abstract method used to generate content into a rendering line, which is a provided BufferLine
instance.
print(self, line)
Produce output into a rendering line.
The provided line is a BufferLine
instance.
Interface RenameableOperand
The RenameableOperand interface depicts operands which can get renamed with an alternative text.
A typical class declaration for a new implementation looks like:
class NewImplem(GObject.Object, RenameableOperand):
...
The following method has to be defined for new implementations:
Hierarchy
gobject.GInterface ╰── pychrysalide.arch.operands.RenameableOperand
Methods
_build(self, text)
Abstract method used to build a new operand with an alternative text as rendering.
The result of the call has to be an object implementing the RenamedOperand
interface.
build(self, text)
Build a new operand with an alternative text as rendering.
The result of the call is an object implementing the RenamedOperand
interface.
Interface RenamedOperand
The RenamedOperand interface depicts operands renamed with an alternative text.
A typical class declaration for a new implementation looks like:
class NewImplem(GObject.Object, RenamedOperand):
...
The following method has to be defined for new implementations:
Hierarchy
gobject.GInterface ╰── pychrysalide.arch.operands.RenamedOperand
Methods
_get_text(self)
Abstract method used to provide the alternative text for rendering.
The result of the call has to be a string.
Attributes
text
Alternative text for the operand rendering.
Interface TargetableOperand
The TargetableOperand interface depicts operands which can drive to another location.
By instance, an immediate value can target a given address into some function code.
A typical class declaration for a new implementation looks like:
class NewImplem(GObject.Object, TargetableOperand):
...
The following method has to be defined for new implementations:
Hierarchy
gobject.GInterface ╰── pychrysalide.arch.operands.TargetableOperand
Methods
_get_addr(self, src, format, proc)
Abstract method used to compute a target address from an operand.
The src
argument is the location of the instruction owning the operand, as a vmpa
instance. The format is a BinFormat
instance, providing all needed information and the processor is a ArchProcessor
instance, providing all needed information too.
The result has to be a vmpa
address or None.
get_addr(self, src, format, proc)
Compute a target address from an operand.
The following arguments are required:
- src is the location of the instruction owning the operand, as a
vmpa
instance. - format is a
BinFormat
instance, providing all needed information. - proc is a
ArchProcessor
instance, providing all needed information too.
The result is a vmpa
address or None.
Class ImmOperand
The ImmOperand deals with immediate value as operand.
There are several ways to display these values in a disassembly, the operand handles that.
Instances can be created using the following constructor:
ImmOperand(size, value)
Where size specifies the original size of the provided value, as a MemoryDataSize
.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.arch.ArchOperand ╰── pychrysalide.arch.operands.ImmOperand
Implements:
- pychrysalide.analysis.storage.SerializableObject
- pychrysalide.arch.operands.RenameableOperand
- pychrysalide.arch.operands.TargetableOperand
- pychrysalide.glibext.SingletonCandidate
Known subclass: pychrysalide.arch.operands.KnownImmOperand
Methods
__cmp__(self, other)
Implementation of the required method used to compare the operand with another one. This second object is always an ImmOperand
instance.
See the parent class for more information about this method.
_print(self, line)
Implementation of the required method used to print the operand into a rendering line, which is a provided BufferLine
instance.
See the parent class for more information about this method.
Attributes
default_display
Define of the immediate operand default textual representation.
The property is a value of type ImmOperandDisplay
.
display
Define of the immediate operand current textual representation.
The property is a value of type ImmOperandDisplay
.
size
Get or set the size of the value contained in the operand.
The property is a value of type MemoryDataSize
.
value
Value of the immediate operand, as an integer.
Constants
ImmOperandDisplay
Kind of display format for immediate operands.
0 | = 0 |
1 | = 1 |
2 | = 2 |
3 | = 3 |
4 | = 4 |
5 | = 5 |
Class KnownImmOperand
The KnownImmOperand provides replacement of ImmOperand
instances by an alternative text.
Instances can be created using the following constructor:
KnownImmOperand(imm, alt)
Where imm is an operand of type ImmOperand
and alt is a string providing the text to be rendered at object display.
The object can be compared using rich methods (like <=
or !=
).
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.arch.ArchOperand ╰── pychrysalide.arch.operands.ImmOperand ╰── pychrysalide.arch.operands.KnownImmOperand
Implements:
- pychrysalide.analysis.storage.SerializableObject
- pychrysalide.arch.operands.RenameableOperand
- pychrysalide.arch.operands.RenamedOperand
- pychrysalide.arch.operands.TargetableOperand
- pychrysalide.glibext.SingletonCandidate
Class ProxyOperand
The ProxyOperand object behaves like a proxy operand for an object which can feed the operand with content.
Instances can be created using the following constructor:
ProxyOperand(feeder)
Where feeder is an instance implementing the ProxyFeeder
interface.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.arch.ArchOperand ╰── pychrysalide.arch.operands.ProxyOperand
Implements:
Attributes
feeder
Give the proxy feeder linked to the operand.
This feeder is a ProxyFeeder
providing content for the operand.
Class RegisterOperand
The RegisterOperand object handles an operand carrying an architecture register.
Instances can be created using the following constructor:
RegisterOperand(reg)
Where reg is an architecture register defined from a subclass of ArchRegister
.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.arch.ArchOperand ╰── pychrysalide.arch.operands.RegisterOperand
Implements:
Methods
__cmp__(self, other)
Implementation of the required method used to compare the operand with another one. This second object is always a RegisterOperand
instance.
See the parent class for more information about this method.
_print(self, line)
Implementation of the required method used to print the operand into a rendering line, which is a provided BufferLine
instance.
See the parent class for more information about this method.
Attributes
register
Provide the register used by the operand, as an instance of type ArchRegister
.
Class TargetOperand
The TargetOperand object translates immediate values as symbols.
Instances can be created using the following constructor:
TargetOperand(size, addr)
Where size is a MemoryDataSize
value describing the size of memory addresses and addr is the location of a symbol to target, as a vmpa
value.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.arch.ArchOperand ╰── pychrysalide.arch.operands.TargetOperand
Implements:
- pychrysalide.analysis.storage.SerializableObject
- pychrysalide.arch.operands.TargetableOperand
- pychrysalide.glibext.SingletonCandidate
Methods
resolve(self, format, strict)
Try to resolve the value carried by the operand as the address of an existing symbol.
The provided format has to be a BinFormat
instance and the strict
argument defines if an offset is allowed between the value and the symbol's address.
The result is True if the resolution is successful, False otherwise.
Attributes
size
Provide the size of the value carried by the operand.
The result is a MemoryDataSize
value.
symbol
Give the resolved symbol linked to the operand.
The result is a BinSymbol
instance or None.