Module pychrysalide.analysis.storage
Interface CacheContainer
Interface SerializableObject
Class ObjectCache
Class ObjectStorage
Class TypeMemory
Module pychrysalide.analysis.storage
Documentation
This module gathers all the features relative to serialization.
This serialization is used for object caching and disassembly results storage.
Interfaces
Classes
Interface CacheContainer
CacheContainer defines an interface for objects with content allowed to get cached.
A typical class declaration for a new implementation looks like:
class NewImplem(GObject.Object, CacheContainer):
...
The following methods have to be defined for new implementations:
Hierarchy
gobject.GInterface ╰── pychrysalide.analysis.storage.CacheContainer
Methods
_can_store(self)
Abstract method used to define if a container can cache its content.
This kind of operation is not wished if the content is currently in use.
The result is a boolean indicating the capacity of safely building a cache.
_lock_unlock(self, lock)
Abstract method used to lock or to unlock access to cache container internals.
The content of such a cache can then be accessed safely, without the fear of race condition while processing.
The lock
argument is a boolean value indicating the state to achieve.
can_store(self)
Define if a container can cache its content.
This kind of operation is not wished if the content is currently in use.
The result is a boolean indicating the capacity of safely building a cache.
lock_unlock(self, lock)
Lock or unlock access to cache container internals.
The content of such a cache can then be accessed safely, without the fear of race condition while processing.
The lock
argument is a boolean value indicating the state to achieve.
Interface SerializableObject
SerializableObject defines an interface used to store and load objects to and from a data buffer.
A typical class declaration for a new implementation looks like:
class NewImplem(GObject.Object, SerializableObject):
...
The following methods have to be defined for new implementations:
Hierarchy
gobject.GInterface ╰── pychrysalide.analysis.storage.SerializableObject
Direct implementations:
- pychrysalide.analysis.BinContent
- pychrysalide.analysis.DataType
- pychrysalide.arch.ArchProcessor
- pychrysalide.arch.ArchRegister
- pychrysalide.format.KnownFormat
Methods
_load(self, storage, pbuf)
Abstract method used to load an object definition from buffered data.
The storage
is a ObjectStorage
instance provided to store inner objects, if relevant, or None. The pbuf
argument points to a PackedBuffer
object containing the data to process.
The result is a boolean indicating the status of the operation.
_store(self, storage, pbuf)
Abstract method used to store an object definition into buffered data.
The storage
is a ObjectStorage
instance provided to store inner objects, if relevant, or None. The pbuf
argument points to a PackedBuffer
object containing the data to process.
The result is a boolean indicating the status of the operation.
load(self, storage, pbuf)
Load an object definition from buffered data.
The storage
is a ObjectStorage
instance provided to store inner objects, if relevant, or None. The pbuf
argument points to a PackedBuffer
object containing the data to process.
The result is a boolean indicating the status of the operation.
store(self, storage, pbuf)
Store an object definition into buffered data.
The storage
is a ObjectStorage
instance provided to store inner objects, if relevant, or None. The pbuf
argument points to a PackedBuffer
object containing the data to process.
The result is a boolean indicating the status of the operation.
Class ObjectCache
The ObjectCache object manages a cache built for reducing the overall memory footprint by releasing partial content of CacheContainer
objects.
Disassembled instructions are the typical objects targeted by this feature, through serialization.
Instances can be created using the following constructor:
ObjectCache(loaded)
Where loaded
is a LoadedContent
instance linked to the processed objects.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.analysis.cache.ObjectCache
Methods
add(self, container)
Introduce a new content to the object cache system.
The container
object must implement the CacheContainer
interface.
Class ObjectStorage
The ObjectStorage object manages the generic storage of GLib objects through serialization.
Instances can be created using the following constructor:
ObjectStorage(hash)
Where hash
should a string built from the checksum of the relative binary content linked to the storage.pychrysalide.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.analysis.storage.ObjectStorage
Methods
load(pbuf)
Construct a new storage from a buffer.
The pbuf
has to be an instance of type PackedBuffer
.
The result is a new ObjectStorage
object on success, None
otherwise.
load_object(self, name, pos)
Load an object from serialized data.
The name
is a string label for the group of target objects and pos
is an offset into the data stream indicating the start of the data to unserialize.
The result is a SerializableObject
instancet in case of success, or None in case of failure.
pack_object(self, name, object, pbuf)
Save an object as serialized data and store the location of the data intro a buffer.
The name
is a string label for the group of target objects, the processed object
has to be a SerializableObject
instance and pbuf
is expected to be a PackedBuffer
instance.
The status of the operation is returned as a boolean value: True
for success, False
for failure.
store(self, pbuf)
Save a storage into a buffer.
The pbuf
has to be an instance of type PackedBuffer
.
The result is True
on success, False
otherwise.
store_object(self, name, object)
Save an object as serialized data.
The name
is a string label for the group of target objects and the processed object
has to be a SerializableObject
instance.
The result is the position of the data for stored object, provided as an integer offset, in case of success or None in case of failure.
unpack_object(self, name, pbuf)
Load an object from a buffer with a location pointing to data.
The name
is a string label for the group of target objects and pbuf
has to be a PackedBuffer
instance.
The result is a SerializableObject
instancet in case of success, or None in case of failure.
Class TypeMemory
The TypeMemory remembers all the types of objects involved in a serialization process.
Instances can be created using the following constructor:
TypeMemory()
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.analysis.storage.TypeMemory
Methods
create_object(self, pbuf)
Create a new GLib object from serialized data.
The pbuf
parameter is a PackedBuffer
instance providing buffered data to read.
The result is a Python object linked to a native GLib object instance.
load_types(self, pbuf)
Read types from a buffer.
This operation is usually handled internally by the Chrysalide's core.
The pbuf
parameter is a PackedBuffer
instance providing buffered data to read.
The result is a boolean value indicating the status of the operation: True for success, False for failure.
store_object_gtype(self, obj, pbuf)
Create a new GLib object from serialized data.
The obj
parameter is the Python version of the GObject whose type is to process and the pbuf
parameter is a PackedBuffer
instance providing buffered data to extend.
The result is a boolean value indicating the status of the operation: True for success, False for failure.
store_types(self, pbuf)
Write types into a buffer.
This operation is usually handled internally by the Chrysalide's core.
The pbuf
parameter is a PackedBuffer
instance providing buffered data to read.
The result is a boolean value indicating the status of the operation: True for success, False for failure.