(file_name, module, progress_bar=None)
return True
Dump the entire module structure to disk. This is done by first removing the large "nodes" attribute from the
    module. The modified module structure is then cPickle-ed, compressed and written to disk with a 4 byte size prefix.
    Next the number of nodes is calculated and written to disk as a 4 byte value. Finally, the "nodes" attribute is
    individually sliced and stored to disk through the above cPicle/compress method.

    @see: load_custom()

    @type  file_name:    String
    @param file_name:    File name to export to
    @type  module:       pida.module
    @param module:       Module to export to disk
    @type  progress_bar: String
    @param progress_bar: (Optional, Def=None) Can be one of "wx", "ascii" or None

    @rtype:  Boolean
    @return: True on success, False otherwise.
Dump the entire module structure to disk. This is done by first removing the large "nodes" attribute from the
    module. The modified module structure is then cPickle-ed, compressed and written to disk with a 4 byte size prefix.
    Next the number of nodes is calculated and written to disk as a 4 byte value. Finally, the "nodes" attribute is
    individually sliced and stored to disk through the above cPicle/compress method.
Dump the entire module structure to disk . This is done by first removing the large nodes attribute from the module . The modified module structure is then cPickle - ed compressed and written to disk with a 4 byte size prefix . Next the number of nodes is calculated and written to disk as a 4 byte value . Finally the nodes attribute is individually sliced and stored to disk through the above cPicle / compress method .
def dump_custom (file_name, module, progress_bar=None):
    '''
    Dump the entire module structure to disk. This is done by first removing the large "nodes" attribute from the
    module. The modified module structure is then cPickle-ed, compressed and written to disk with a 4 byte size prefix.
    Next the number of nodes is calculated and written to disk as a 4 byte value. Finally, the "nodes" attribute is
    individually sliced and stored to disk through the above cPicle/compress method.

    @see: load_custom()

    @type  file_name:    String
    @param file_name:    File name to export to
    @type  module:       pida.module
    @param module:       Module to export to disk
    @type  progress_bar: String
    @param progress_bar: (Optional, Def=None) Can be one of "wx", "ascii" or None

    @rtype:  Boolean
    @return: True on success, False otherwise.
    '''

    fh = open(file_name, "wb+")

    # write the version signature disk.
    fh.write(struct.pack(">L", PIDA_VERSION))

    # remove the intra-object pointers and aliases.
    module.functions = None

    for func in module.nodes.values():
        func.module       = None
        func.basic_blocks = None

        for bb in func.nodes.values():
            bb.function = None
            bb.nodes    = None

            for ins in bb.instructions.values():
                ins.basic_block = None

    # detach the (possible large) nodes data structure from the module.
    nodes = module.nodes
    module.nodes = {}

    # write the "rest" of the data structure to disk.
    rest = zlib.compress(cPickle.dumps(module, protocol=2))
    fh.write(struct.pack(">L", len(rest)))
    fh.write(rest)

    # write the node count to disk.
    num_nodes         = len(nodes)
    count             = 0
    percent_indicator = 0

    fh.write(struct.pack(">L", num_nodes))

    # create a progress bar.
    if progress_bar == "wx":
        pb = wx.ProgressDialog("Storing %s to disk" % module.name,
            "%d total nodes to process." % num_nodes,
            maximum = num_nodes,
            style   = wx.PD_CAN_ABORT | wx.PD_AUTO_HIDE | wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME)

    # slice up the nodes attribute and individually store each node to disk.
    for entry in nodes.values():
        count += 1
        node   = zlib.compress(cPickle.dumps(entry, protocol=2))

        fh.write(struct.pack(">L", len(node)))
        fh.write(node)

        if progress_bar == "wx":
            if not pb.Update(count):
                pb.Destroy()
                fh.close()
                return False

        elif progress_bar == "ascii":
            percent_complete = float(count) / float(num_nodes) * 100

            if percent_complete > 25 and percent_indicator == 0:
                print "25%",
                percent_indicator += 1
            elif percent_complete > 50 and percent_indicator == 1:
                print "50%",
                percent_indicator += 1
            elif percent_complete > 75 and percent_indicator == 2:
                print "75%",
                percent_indicator += 1

    # restore the nodes attribute.
    module.nodes = nodes

    if progress_bar == "wx":
        pb.Destroy()

    fh.close()
    return True
def dump_custom ( file_name , module , progress_bar = None ) : fh = open ( file_name , "wb+" ) # write the version signature disk. fh . write ( struct . pack ( ">L" , PIDA_VERSION ) ) # remove the intra-object pointers and aliases. module . functions = None for func in module . nodes . values ( ) : func . module = None func . basic_blocks = None for bb in func . nodes . values ( ) : bb . function = None bb . nodes = None for ins in bb . instructions . values ( ) : ins . basic_block = None # detach the (possible large) nodes data structure from the module. nodes = module . nodes module . nodes = { } # write the "rest" of the data structure to disk. rest = zlib . compress ( cPickle . dumps ( module , protocol = 2 ) ) fh . write ( struct . pack ( ">L" , len ( rest ) ) ) fh . write ( rest ) # write the node count to disk. num_nodes = len ( nodes ) count = 0 percent_indicator = 0 fh . write ( struct . pack ( ">L" , num_nodes ) ) # create a progress bar. if progress_bar == "wx" : pb = wx . ProgressDialog ( "Storing %s to disk" % module . name , "%d total nodes to process." % num_nodes , maximum = num_nodes , style = wx . PD_CAN_ABORT | wx . PD_AUTO_HIDE | wx . PD_APP_MODAL | wx . PD_ELAPSED_TIME | wx . PD_REMAINING_TIME ) # slice up the nodes attribute and individually store each node to disk. for entry in nodes . values ( ) : count += 1 node = zlib . compress ( cPickle . dumps ( entry , protocol = 2 ) ) fh . write ( struct . pack ( ">L" , len ( node ) ) ) fh . write ( node ) if progress_bar == "wx" : if not pb . Update ( count ) : pb . Destroy ( ) fh . close ( ) return False elif progress_bar == "ascii" : percent_complete = float ( count ) / float ( num_nodes ) * 100 if percent_complete > 25 and percent_indicator == 0 : print "25%" , percent_indicator += 1 elif percent_complete > 50 and percent_indicator == 1 : print "50%" , percent_indicator += 1 elif percent_complete > 75 and percent_indicator == 2 : print "75%" , percent_indicator += 1 # restore the nodes attribute. module . nodes = nodes if progress_bar == "wx" : pb . Destroy ( ) fh . close ( ) return True