Example #1
0
    def analyze(self):

        ctx = Context()

        romconfig = Config(self.filename, rom=True)
        rombank = romconfig.get(["Analysis", "FlowAnalysis-Rombank"])
        if str(hex(self.addr.virtual())) in rombank:
            print "a"
            ctx.setValue('ROMBANK',
                         Constant(rombank[str(hex(self.addr.virtual()))]))
        '''
        if self.addr.virtual() == 0x0A90:
            ctx.setValue('ROMBANK', Constant(1))
        if self.addr.virtual() == 0x3CCA:
            ctx.setValue('ROMBANK', Constant(0x15))
        if self.addr.virtual() in (0x0B34, 0x0B37, 0x0B3A, 0x0B3D):
            ctx.setValue('ROMBANK', Constant(1))
        if self.addr.virtual() in (0x0D68, 0x0E7F, 0x0EFC, 0x0EDB, 0x0C40, 0x149B, 0x15B3, 0x1732, 0x0C10):
            ctx.setValue('ROMBANK', Constant(2))
        '''

        if self.addr.inBankedSpace() and not self.addr.isAmbiguous():
            ctx.setValue('ROMBANK', Constant(self.addr.bank()))

        content = self.process(self.graph.start(), None, False, False, True)
        content = content.optimizedWithContext(ctx)
        content = content.optimizeDependencies(
            set(ALL_REGS) - set(['FZ', 'FN', 'FC', 'FH']))
        return content
Example #2
0
def make_context(params, argument, next_addr):
    ctx = Context()
    if next_addr.bank() > 0:
        ctx.setValue('ROMBANK', Constant(next_addr.bank()))
    ctx.setValue('v8', Constant(argument))
    ctx.setValue('FF00_v8', Constant(0xFF00 + argument))
    ctx.setValue('v16', Constant(argument))
    offset = argument
    if offset & 0x80:  # convert to signed offset
        offset -= 0x100
    ctx.setValue('v8_rel', Constant(next_addr.offset(offset).virtual()))
    for p in params:
        value = placeholders.get(p, params[p])
        ctx.setValue('#'+p, value)
    return ctx
Example #3
0
 def optimizedWithContext(self, ctx):
     ctx.invalidateAll()
     inner = self.inner.optimizedWithContext(Context())
     return While(inner, self.continue_label)
Example #4
0
def make_context(params, argument, next_addr):
    ctx = Context()
    if next_addr.bank() > 0:
        ctx.setValue('ROMBANK', Constant(next_addr.bank()))
    ctx.setValue('v8', Constant(argument))
    ctx.setValue('FF00_v8', Constant(0xFF00 + argument))
    ctx.setValue('v16', Constant(argument))
    offset = argument
    if offset & 0x80:  # convert to signed offset
        offset -= 0x100
    ctx.setValue('v8_rel', Constant(next_addr.offset(offset).virtual()))
    for p in params:
        value = placeholders.get(p, params[p])
        ctx.setValue('#' + p, value)
    return ctx
Example #5
0
    def analyze(self):

        ctx = Context()

        if self.addr.virtual() == 0x0A90:
            ctx.setValue('ROMBANK', Constant(1))
        if self.addr.virtual() == 0x3CCA:
            ctx.setValue('ROMBANK', Constant(0x15))
        if self.addr.virtual() in (0x0B34, 0x0B37, 0x0B3A, 0x0B3D):
            ctx.setValue('ROMBANK', Constant(1))
        if self.addr.virtual() in (0x0D68, 0x0E7F, 0x0EFC, 0x0EDB, 0x0C40, 0x149B, 0x15B3, 0x1732, 0x0C10):
            ctx.setValue('ROMBANK', Constant(2))

        if self.addr.inBankedSpace() and not self.addr.isAmbiguous():
            ctx.setValue('ROMBANK', Constant(self.addr.bank()))

        content = self.process(self.graph.start(), None, False, False, True)
        content = content.optimizedWithContext(ctx)
        content = content.optimizeDependencies(set(ALL_REGS) - set(['FZ', 'FN', 'FC', 'FH']))
        return content
Example #6
0
    def analyze(self):

        ctx = Context()

        if self.addr.virtual() == 0x0A90:
            ctx.setValue('ROMBANK', Constant(1))
        if self.addr.virtual() == 0x3CCA:
            ctx.setValue('ROMBANK', Constant(0x15))
        if self.addr.virtual() in (0x0B34, 0x0B37, 0x0B3A, 0x0B3D):
            ctx.setValue('ROMBANK', Constant(1))
        if self.addr.virtual() in (0x0D68, 0x0E7F, 0x0EFC, 0x0EDB, 0x0C40,
                                   0x149B, 0x15B3, 0x1732, 0x0C10):
            ctx.setValue('ROMBANK', Constant(2))

        if self.addr.inBankedSpace() and not self.addr.isAmbiguous():
            ctx.setValue('ROMBANK', Constant(self.addr.bank()))

        content = self.process(self.graph.start(), None, False, False, True)
        content = content.optimizedWithContext(ctx)
        content = content.optimizeDependencies(
            set(ALL_REGS) - set(['FZ', 'FN', 'FC', 'FH']))
        return content