Package bakmei :: Module module :: Class module |

[show private | hide private]
[frames | no frames]

## Type module

    object --+
             |
         graph --+
                 |
                module

A module is an overall container for all the information stored in a binary, whether it is an executable or a library.

Author: Cameron Hotchkies, Pedram Amini

Contact: chotchkies@tippingpoint.com

Organization: www.openrce.org

License: GNU General Public License 2.0 or later

Method Summary
| ``__init__`(self, DSN, database_id)` Initializes an instance of a PaiMei module.
bakmei.function | ``find_function`(self, ea)` Locate and return the function that contains the specified address.
bakmei.instruction | ``find_instruction`(self, ea)` Locate and return the instruction at the specified address.
[bakmei.function] | ``get_rpc_functions`(self, uuid)` Returns the list of functions that match the given RPC UUID.
| ``next_ea`(self, ea)` Return the instruction after to the one at ea.
| ``prev_ea`(self, ea)` Within the function that contains ea, return the instruction prior to the one at ea.
| ``rebase`(self, new_base)` Rebase the module and all components with the new base address.
String | ``uuid_bin_to_string`(self, uuid)` Convert the binary representation of a UUID to a human readable string.
| `__build_edges(self)`
| ``__deleteBase`(self)` destructs the base address of the module
| ``__deleteComment`(self)` destructs the comment for the module
| ``__deleteImportedFunctions`(self)` destructs the imports
| ``__deleteLibraryFunctions`(self)` destructs the imports
| ``__deleteName`(self)` destructs the name of the module
| ``__deleteNodes`(self)` destructs the nodes of the module
| ``__deleteNumFunctions`(self)` destructs the num_functions
| ``__deleteRpcUuids`(self)` destructs the RPC UUIDs
| ``__deleteSignature`(self)` destructs the signature of the module
Dword | ``__getBase`(self)` Gets the base address of the module
String | ``__getComment`(self)` The module comment.
[function] | ``__getImportedFunctions`(self)` Gets the imported functions for the module
[function] | ``__getLibraryFunctions`(self)` Gets the library functions for the module
String | ``__getName`(self)` The name of the module.
String | ``__getNodes`(self)` Gets the functions (nodes) of the module
Integer | ``__getNumFunctions`(self)` The number of functions in the module
[function] | ``__getRpcUuids`(self)` Gets the RPC UUIDs for the module
String | ``__getSignature`(self)` Gets the signature of the module
| ``__load_from_sql`(self)` Loads the information about a module from a SQL datastore.
| ``__setBase`(self, value)` Sets the base address of the module.
| ``__setComment`(self, value)` Sets the comment on the module.
| ``__setImportedFunctions`(self, value)` Sets the imported functions of the module.
| ``__setLibraryFunctions`(self, value)` Sets the imported functions of the module.
| ``__setName`(self, value)` Sets the name of the module.
| ``__setNodes`(self, value)` Sets the nodes of the module.
| ``__setNumFunctions`(self, value)` Sets the number of functions (raises an exception - READ ONLY)
| ``__setRpcUuids`(self, value)` Sets the RPC UUIDs of the module.
| ``__setSignature`(self, value)` Sets the signature of the module.
Inherited from graph
| ``add_cluster`(self, cluster)` Add a pgraph cluster to the graph.
| ``add_edge`(self, edge, prevent_dups)` Add a pgraph edge to the graph.
| ``add_graph`(self, other_graph)` Alias of graph_cat().
| ``add_node`(self, node)` Add a pgraph node to the graph.
| ``del_cluster`(self, id)` Remove a cluster from the graph.
| ``del_edge`(self, id, src, dst)` Remove an edge from the graph.
| ``del_graph`(self, other_graph)` Alias of graph_sub().
| ``del_node`(self, node_id)` Remove a node from the graph.
List | ``edges_from`(self, id)` Enumerate the edges from the specified node.
List | ``edges_to`(self, id)` Enumerate the edges to the specified node.
Mixed | ``find_cluster`(self, attribute, value)` Find and return the cluster with the specified attribute / value pair.
Mixed | ``find_cluster_by_node`(self, attribute, value)` Find and return the cluster that contains the node with the specified attribute / value pair.
Mixed | ``find_edge`(self, attribute, value)` Find and return the edge with the specified attribute / value pair.
Mixed | ``find_node`(self, attribute, value)` Find and return the node with the specified attribute / value pair.
| ``graph_cat`(self, other_graph)` Concatenate the other graph into the current one.
pgraph.graph | ``graph_down`(self, from_node_id, max_depth)` Create a new graph, looking down, from the specified node id to the specified depth.
| ``graph_intersect`(self, other_graph)` Remove all elements from the current graph that do not exist in the other graph.
pgraph.graph | ``graph_proximity`(self, center_node_id, max_depth_up, max_depth_down)` Create a proximity graph centered around the specified node.
| ``graph_sub`(self, other_graph)` Remove the elements shared between the current graph and other graph from the current graph.
pgraph.graph | ``graph_up`(self, from_node_id, max_depth)` Create a new graph, looking up, from the specified node id to the specified depth.
String | ``render_graph_gml`(self)` Render the GML graph description.
pydot.Dot | ``render_graph_graphviz`(self)` Render the graphviz graph structure.
String | ``render_graph_udraw`(self)` Render the uDraw graph description.
String | ``render_graph_udraw_update`(self)` Render the uDraw graph update description.
List | ``sorted_nodes`(self)` Return a list of the nodes within the graph, sorted by id.
| ``update_node_id`(self, current_id, new_id)` Simply updating the id attribute of a node will sever the edges to / from the given node.
Inherited from object
| ``__delattr__`(...)` x.__delattr__('name') <==> del x.name
| ``__getattribute__`(...)` x.__getattribute__('name') <==> x.name
| ``__hash__`(x)` x.__hash__() <==> hash(x)
| ``__new__`(T, S, ...)` T.__new__(S, ...) -> a new object with type S, a subtype of T
| ``__reduce__`(...)` helper for pickle
| ``__reduce_ex__`(...)` helper for pickle
| ``__repr__`(x)` x.__repr__() <==> repr(x)
| ``__setattr__`(...)` x.__setattr__('name', value) <==> x.name = value
| ``__str__`(x)` x.__str__() <==> str(x)

Property Summary
| `base`: The base address of the module.
| `comment`: Notes about the module.
| `imported_functions`: The functions imported from other libraries.
| `library_functions`: The library functions compiled inline.
| `name`: The name of the module.
| `num_functions`: The number of functions in the module.
| `rpc_uuids`: All RPC UUIDs for the module.
| `signature`: The module signature.
Inherited from graph
| `nodes`: The functions in the module, keyed by the starting address.

Class Variable Summary
Integer | `dbid`: Database Identifier
String | `DSN`: Database location
`dict` | `ext` = `{}`
`NoneType` | `_module__base` = None
`bool` | `_module__cached` = `False`
`NoneType` | `_module__comment` = None
`NoneType` | `_module__name` = None
`NoneType` | `_module__nodes` = None
`NoneType` | `_module__signature` = None
Inherited from graph
`NoneType` | `clusters` = None
`NoneType` | `edges` = None
`NoneType` | `id` = None
`NoneType` | `nodes` = None

Method Details

### __init__(self, DSN, database_id=1)
(Constructor)

Initializes an instance of a PaiMei module.

  Parameters:
    `DSN` - The database file that the module is stored in.
    (type=String)
    `database_id` - (Optional) The id of the module in the database.
    (type=Integer)
  Overrides:
    `pgraph.graph.graph.__init__`

### find_function(self, ea)

Locate and return the function that contains the specified address.

  Parameters:
    `ea` - An address within the function to find
    (type=DWORD)
  Returns:
    The function that contains the given address or None if not found.
    (type=bakmei.function)

### find_instruction(self, ea)

Locate and return the instruction at the specified address.

  Parameters:
    `ea` - The address of the instruction to find
    (type=DWORD)
  Returns:
    The instruction that contains the given address or None if not found.
    (type=bakmei.instruction)

### get_rpc_functions(self, uuid=None)

Returns the list of functions that match the given RPC UUID. If no UUID is given, all RPC functions are returned.

  Parameters:
    `uuid` - (optional) The uuid to retrieve matching RPC functions for.
    (type=String)
  Returns:
    A list of functions matching the given RPC UUID. If no UUID was given, all RPC functions.
    (type=[bakmei.function])

### next_ea(self, ea=None)

Return the instruction after to the one at ea. You can call this routine without an argument after the first call. The overall structure of BAKMEI was not really designed for this kind of functionality, so this is kind of a hack.

  Parameters:
    `ea` - Address of instruction to return next instruction from or -1 if not found.
    (type=(Optional, def=Last EA) Dword)

  To Do: See if I can do this better.

### prev_ea(self, ea=None)

Within the function that contains ea, return the instruction prior to the one at ea. You can call this routine without an argument after the first call. The overall structure of BAKMEI was not really designed for this kind of functionality, so this is kind of a hack.

  Parameters:
    `ea` - Address of instruction to return previous instruction to or None if not found.
    (type=(Optional, def=Last EA) Dword)

  To Do: See if I can do this better.

### rebase(self, new_base)

Rebase the module and all components with the new base address. This routine will check if the current and requested base addresses are equivalent, so you do not have to worry about checking that yourself.

  Parameters:
    `new_base` - Address to rebase module to
    (type=Dword)

### uuid_bin_to_string(self, uuid)

Convert the binary representation of a UUID to a human readable string.

  Parameters:
    `uuid` - Raw binary bytes consisting of the UUID
    (type=Raw)
  Returns:
    Human readable string representation of UUID.
    (type=String)

### __deleteBase(self)

destructs the base address of the module

### __deleteComment(self)

destructs the comment for the module

### __deleteImportedFunctions(self)

destructs the imports

### __deleteLibraryFunctions(self)

destructs the imports

### __deleteName(self)

destructs the name of the module

### __deleteNodes(self)

destructs the nodes of the module

### __deleteNumFunctions(self)

destructs the num_functions

### __deleteRpcUuids(self)

destructs the RPC UUIDs

### __deleteSignature(self)

destructs the signature of the module

### __getBase(self)

Gets the base address of the module

  Returns:
    The base address of the module
    (type=Dword)

### __getComment(self)

The module comment.

  Returns:
    The name of the module
    (type=String)

### __getImportedFunctions(self)

Gets the imported functions for the module

  Returns:
    The imported functions of the module
    (type=[function])

### __getLibraryFunctions(self)

Gets the library functions for the module

  Returns:
    The inline library functions of the module
    (type=[function])

### __getName(self)

The name of the module.

  Returns:
    The name of the module
    (type=String)

### __getNodes(self)

Gets the functions (nodes) of the module

  Returns:
    A dictionary of all the functions keyed by start addresses
    (type=String)

### __getNumFunctions(self)

The number of functions in the module

  Returns:
    The number of instructions in the function
    (type=Integer)

### __getRpcUuids(self)

Gets the RPC UUIDs for the module

  Returns:
    The imported functions of the module
    (type=[function])

### __getSignature(self)

Gets the signature of the module

  Returns:
    The signature of the module
    (type=String)

### __load_from_sql(self)

Loads the information about a module from a SQL datastore.

### __setBase(self, value)

Sets the base address of the module.

  Parameters:
    `value` - The base address of the module.
    (type=Dword)

### __setComment(self, value)

Sets the comment on the module.

  Parameters:
    `value` - The comment for the module.
    (type=String)

### __setImportedFunctions(self, value)

Sets the imported functions of the module. This will generate an error.

  Parameters:
    `value` - The signature of the module.
    (type=String)

### __setLibraryFunctions(self, value)

Sets the imported functions of the module. This will generate an error.

  Parameters:
    `value` - The signature of the module.
    (type=String)

### __setName(self, value)

Sets the name of the module.

  Parameters:
    `value` - The name of the module.
    (type=String)

### __setNodes(self, value)

Sets the nodes of the module. This will generate an error.

  Parameters:
    `value` - The signature of the module.
    (type=String)

### __setNumFunctions(self, value)

Sets the number of functions (raises an exception - READ ONLY)

  Parameters:
    `value` - The number of functions in the module
    (type=Integer)

### __setRpcUuids(self, value)

Sets the RPC UUIDs of the module. This will generate an error.

  Parameters:
    `value` - The signature of the module.
    (type=String)

### __setSignature(self, value)

Sets the signature of the module.

  Parameters:
    `value` - The signature of the module.
    (type=String)

Property Details

### base

The base address of the module.

  Get Method:
    `__getBase`(self)
  Set Method:
    `__setBase`(self, value)
  Delete Method:
    `__deleteBase`(self)

### comment

Notes about the module.

  Get Method:
    `__getComment`(self)
  Set Method:
    `__setComment`(self, value)
  Delete Method:
    `__deleteComment`(self)

### imported_functions

The functions imported from other libraries.

  Get Method:
    `__getImportedFunctions`(self)
  Set Method:
    `__setImportedFunctions`(self, value)
  Delete Method:
    `__deleteImportedFunctions`(self)

### library_functions

The library functions compiled inline.

  Get Method:
    `__getLibraryFunctions`(self)
  Set Method:
    `__setLibraryFunctions`(self, value)
  Delete Method:
    `__deleteLibraryFunctions`(self)

### name

The name of the module.

  Get Method:
    `__getName`(self)
  Set Method:
    `__setName`(self, value)
  Delete Method:
    `__deleteName`(self)

### nodes

The functions in the module, keyed by the starting address.

  Get Method:
    `__getNodes`(self)
  Set Method:
    `__setNodes`(self, value)
  Delete Method:
    `__deleteNodes`(self)

### num_functions

The number of functions in the module.

  Get Method:
    `__getNumFunctions`(self)
  Set Method:
    `__setNumFunctions`(self, value)
  Delete Method:
    `__deleteNumFunctions`(self)

### rpc_uuids

All RPC UUIDs for the module.

  Get Method:
    `__getRpcUuids`(self)
  Set Method:
    `__setRpcUuids`(self, value)
  Delete Method:
    `__deleteRpcUuids`(self)

### signature

The module signature.

  Get Method:
    `__getSignature`(self)
  Set Method:
    `__setSignature`(self, value)
  Delete Method:
    `__deleteSignature`(self)

Class Variable Details

### dbid

Database Identifier

  Type:
    Integer
  Value:

        None

### DSN

Database location

  Type:
    String
  Value:

        None

### ext

  Type:
    `dict`
  Value:

        {}

### _module__base

  Type:
    `NoneType`
  Value:

        None

### _module__cached

  Type:
    `bool`
  Value:

        False

### _module__comment

  Type:
    `NoneType`
  Value:

        None

### _module__name

  Type:
    `NoneType`
  Value:

        None

### _module__nodes

  Type:
    `NoneType`
  Value:

        None

### _module__signature

  Type:
    `NoneType`
  Value:

        None

Generated by Epydoc 2.1 on Wed Mar 14 16:32:06 2007 | http://epydoc.sf.net