Exemplo n.º 1
0
        def activate(self, ctx):
            if regFu.isHighlightedEffective():
                addr = regFu.getOffset()
                simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.getMemoryValue(0x%x)");' % addr) 
                print('effective addr 0x%x value %s' % (addr, simicsString))
                value = getHex(simicsString)
            else:
                highlighted = idaapi.get_highlighted_identifier()
                addr = getHex(highlighted)
                if addr is None:
                    print('ModMemoryHandler unable to parse hex from %s' % highlighted)
                    return
                simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.getMemoryValue(0x%x)");' % addr) 
                print('addr 0x%x value %s' % (addr, simicsString))
                value = getHex(simicsString)

            # Sample form from kernwin.hpp
            s = """Modify memory
            Address: %$
            <~E~nter value:S:32:16::>
            """
            num = Form.NumericArgument('N', value=value)
            ok = idaapi.AskUsingForm(s,
                    Form.NumericArgument('$', addr).arg,
                    num.arg)
            if ok == 1:
                print("You entered: %x" % num.value)
                simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.writeWord(0x%x, 0x%x)");' % (addr, num.value)) 
                time.sleep(1)
                idc.RefreshDebuggerMemory()
Exemplo n.º 2
0
 def registerMath(self): 
     retval = None
     if regFu.isHighlightedEffective():
         retval = regFu.getOffset()
     else:
         #regs =['eax', 'ebx', 'ecx', 'edx', 'esi', 'edi', 'ebp']
         highlighted = idaversion.getHighlight()
         retval = None
         if highlighted is not None:
             print 'highlighted is %s' % highlighted
             if self.isReg(highlighted):
                 retval = idaversion.get_reg_value(highlighted)
             else:
                 try:
                     retval = int(highlighted, 16)
                 except:
                     pass
                 if retval is None:
                     ''' TBD this is broken, manually manage register list? '''
                     for reg in self.reg_list:
                         if highlighted.startswith(reg):
                             rest = highlighted[len(reg):]
                             value = None
                             try:
                                 value = int(rest[1:])
                             except:
                                 pass
                             if value is not None:
                                 if rest.startswith('+'):
                                     regvalue = idaversion.get_reg_value(reg)
                                     retval = regvalue + value
                                 elif rest.startswith('-'):
                                     regvalue = idaversion.get_reg_value(reg)
                                     retval = regvalue - value
     return retval
Exemplo n.º 3
0
Arquivo: rev.py Projeto: wyu0hop/RESim
def registerMath():
    retval = None
    if regFu.isHighlightedEffective():
        retval = regFu.getOffset()
    else:
        #regs =['eax', 'ebx', 'ecx', 'edx', 'esi', 'edi', 'ebp']
        highlighted = idaapi.get_highlighted_identifier()
        retval = None
        if highlighted is not None:
            print 'highlighted is %s' % highlighted
            if highlighted in reg_list:
                retval = idc.GetRegValue(highlighted)
            else:
                try:
                    retval = int(highlighted, 16)
                except:
                    pass
                if retval is None:
                    for reg in reg_list:
                        if highlighted.startswith(reg):
                            rest = highlighted[len(reg):]
                            value = None
                            try:
                                value = int(rest[1:])
                            except:
                                pass
                            if value is not None:
                                if rest.startswith('+'):
                                    regvalue = idc.GetRegValue(reg)
                                    retval = regvalue + value
                                elif rest.startswith('-'):
                                    regvalue = idc.GetRegValue(reg)
                                    retval = regvalue - value
    return retval
Exemplo n.º 4
0
    def activate(self, ctx):
        if regFu.isHighlightedEffective():
            addr = regFu.getOffset()
        else:
            highlighted = idaversion.getHighlight()
            addr = getHex(highlighted)
            if addr is None:
                print('ModMemoryHandler unable to parse hex from %s' %
                      highlighted)
                return

        sas = setAddrString.SetAddrString()
        sas.Compile()
        sas.iAddr.value = addr
        val = ''
        for i in range(8):
            c = idaversion.get_wide_byte(addr + i)
            if c >= 0x20 and c <= 0x7e:
                val = val + chr(c)
            else:
                val = val + '.'
        sas.iStr1.value = val
        ok = sas.Execute()
        if ok != 1:
            return
        self.last_data_mem_set = sas.iStr1.value
        #sparm = "'%s'" % sas.iStr1.value
        sparm = "'%s'" % str(sas.iStr1.value).strip()
        dog = 'SendGDBMonitor("@cgc.writeString(0x%x, %s)");' % (
            sas.iAddr.value, sparm)
        print('dog is <%s>' % dog)
        simicsString = gdbProt.Evalx(
            'SendGDBMonitor("@cgc.writeString(0x%x, %s)");' %
            (sas.iAddr.value, sparm))
        time.sleep(2)
        self.isim.updateBookmarkView()
        self.isim.updateDataWatch()
        idaversion.refresh_debugger_memory()
        idaversion.refresh_idaview_anyway()
        idaversion.refresh_choosers()
        print(
            'Bookmarks cleared -- select origin bookmark to return to this cycle'
        )
        print(
            'Note: data watches previous to this point are retained, but associated bookmarks are deleted'
        )
Exemplo n.º 5
0
    def activate(self, ctx):
        if regFu.isHighlightedEffective():
            addr = regFu.getOffset()
            simicsString = gdbProt.Evalx(
                'SendGDBMonitor("@cgc.getMemoryValue(0x%x)");' % addr)
            print('effective addr 0x%x value %s' % (addr, simicsString))
            value = simicsString
        else:
            highlighted = idaapi.get_highlighted_identifier()
            addr = getHex(highlighted)
            if addr is None:
                print('ModMemoryHandler unable to parse hex from %s' %
                      highlighted)
                return
            simicsString = gdbProt.Evalx(
                'SendGDBMonitor("@cgc.getMemoryValue(0x%x)");' % addr)
            print('addr 0x%x value %s' % (addr, simicsString))
            value = simicsString

        # Sample form from kernwin.hpp
        s = """Modify memory
            Address: %$
            <~E~nter value:t40:80:50::>
            """
        ti = idaapi.textctrl_info_t(value)
        ok = idaapi.AskUsingForm(
            s,
            Form.NumericArgument('$', addr).arg,
            idaapi.pointer(idaapi.c_void_p.from_address(ti.clink_ptr)))
        '''
            string = Form.StringArgument(value)
            ok = idaapi.AskUsingForm(s,
                    Form.NumericArgument('$', addr).arg,
                    string.arg)
            '''
        if ok == 1:
            arg = "'%s'" % ti.text.strip()
            print("You entered: %s <%s>" % (ti.text, arg))
            cmd = "@cgc.writeString(0x%x, %s)" % (addr, arg)
            print cmd
            simicsString = gdbProt.Evalx('SendGDBMonitor("%s");' % (cmd))
            time.sleep(1)
            idc.RefreshDebuggerMemory()