(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.

        @type  new_base: Dword
        @param new_base: Address to rebase module to
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.
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 .
def 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.

        @type  new_base: Dword
        @param new_base: Address to rebase module to
        '''

        # nothing to do.
        if new_base == self.base:
            return

        # rebase each function in the module.
        for function in self.nodes.keys():
            self.nodes[function].id       = self.nodes[function].id       - self.base + new_base
            self.nodes[function].ea_start = self.nodes[function].ea_start - self.base + new_base
            self.nodes[function].ea_end   = self.nodes[function].ea_end   - self.base + new_base

            function = self.nodes[function]

            # rebase each basic block in the function.
            for bb in function.nodes.keys():
                function.nodes[bb].id       = function.nodes[bb].id       - self.base + new_base
                function.nodes[bb].ea_start = function.nodes[bb].ea_start - self.base + new_base
                function.nodes[bb].ea_end   = function.nodes[bb].ea_end   - self.base + new_base

                bb = function.nodes[bb]

                # rebase each instruction in the basic block.
                for ins in bb.instructions.keys():
                    bb.instructions[ins].ea = bb.instructions[ins].ea - self.base + new_base

                # fixup the instructions dictionary.
                old_dictionary  = bb.instructions
                bb.instructions = {}

                for key, val in old_dictionary.items():
                    bb.instructions[key - self.base + new_base] = val

            # fixup the functions dictionary.
            old_dictionary = function.nodes
            function.nodes = {}

            for key, val in old_dictionary.items():
                function.nodes[val.id] = val

            # rebase each edge between the basic blocks in the function.
            for edge in function.edges.keys():
                function.edges[edge].src =  function.edges[edge].src - self.base + new_base
                function.edges[edge].dst =  function.edges[edge].dst - self.base + new_base
                function.edges[edge].id  = (function.edges[edge].src << 32) + function.edges[edge].dst

            # fixup the edges dictionary.
            old_dictionary = function.edges
            function.edges = {}

            for key, val in old_dictionary.items():
                function.edges[val.id] = val

        # fixup the modules dictionary.
        old_dictionary = self.nodes
        self.nodes     = {}

        for key, val in old_dictionary.items():
            self.nodes[val.id] = val

        # rebase each edge between the functions in the module.
        for edge in self.edges.keys():
            self.edges[edge].src =  self.edges[edge].src - self.base + new_base
            self.edges[edge].dst =  self.edges[edge].dst - self.base + new_base
            self.edges[edge].id  = (self.edges[edge].src << 32) + self.edges[edge].dst

        # finally update the base address of the module.
        self.base = new_base
def rebase ( self , new_base ) : # nothing to do. if new_base == self . base : return # rebase each function in the module. for function in self . nodes . keys ( ) : self . nodes [ function ] . id = self . nodes [ function ] . id - self . base + new_base self . nodes [ function ] . ea_start = self . nodes [ function ] . ea_start - self . base + new_base self . nodes [ function ] . ea_end = self . nodes [ function ] . ea_end - self . base + new_base function = self . nodes [ function ] # rebase each basic block in the function. for bb in function . nodes . keys ( ) : function . nodes [ bb ] . id = function . nodes [ bb ] . id - self . base + new_base function . nodes [ bb ] . ea_start = function . nodes [ bb ] . ea_start - self . base + new_base function . nodes [ bb ] . ea_end = function . nodes [ bb ] . ea_end - self . base + new_base bb = function . nodes [ bb ] # rebase each instruction in the basic block. for ins in bb . instructions . keys ( ) : bb . instructions [ ins ] . ea = bb . instructions [ ins ] . ea - self . base + new_base # fixup the instructions dictionary. old_dictionary = bb . instructions bb . instructions = { } for key , val in old_dictionary . items ( ) : bb . instructions [ key - self . base + new_base ] = val # fixup the functions dictionary. old_dictionary = function . nodes function . nodes = { } for key , val in old_dictionary . items ( ) : function . nodes [ val . id ] = val # rebase each edge between the basic blocks in the function. for edge in function . edges . keys ( ) : function . edges [ edge ] . src = function . edges [ edge ] . src - self . base + new_base function . edges [ edge ] . dst = function . edges [ edge ] . dst - self . base + new_base function . edges [ edge ] . id = ( function . edges [ edge ] . src << 32 ) + function . edges [ edge ] . dst # fixup the edges dictionary. old_dictionary = function . edges function . edges = { } for key , val in old_dictionary . items ( ) : function . edges [ val . id ] = val # fixup the modules dictionary. old_dictionary = self . nodes self . nodes = { } for key , val in old_dictionary . items ( ) : self . nodes [ val . id ] = val # rebase each edge between the functions in the module. for edge in self . edges . keys ( ) : self . edges [ edge ] . src = self . edges [ edge ] . src - self . base + new_base self . edges [ edge ] . dst = self . edges [ edge ] . dst - self . base + new_base self . edges [ edge ] . id = ( self . edges [ edge ] . src << 32 ) + self . edges [ edge ] . dst # finally update the base address of the module. self . base = new_base