Exemple #1
0
def get_last_error():
    thread_id = idaapi.get_current_thread()
    tib_ea = get_thread_tib(thread_id)
    if tib_ea:
        offset = m.ptr_size * 13
        return m.get_ptr(tib_ea + offset)
    return None
Exemple #2
0
def initialize():
    if m.initialized:
        return

    info = idaapi.get_inf_structure()
    if info.is_64bit():
        m.ptr_size = 8
        m.get_ptr = idc.Qword
        m.mem_fmt = "%016X"
        m.pack_fmt = "<Q"
    elif info.is_32bit():
        m.ptr_size = 4
        m.get_ptr = idc.Dword
        m.mem_fmt = "%08X"
        m.pack_fmt = "<L"

    m.cpu_name = info.procname.lower()
    m.is_be = idaapi.cvar.inf.is_be()
    m.filetype = info.filetype
    m.is_pefile = (m.filetype == idaapi.f_PE)
    m.thread_id = idaapi.get_current_thread()

    if m.cpu_name == "metapc":
        m.registers = {4: regs.x86, 8: regs.x64}[m.ptr_size]

    elif m.cpu_name.startswith("arm"):
        m.registers = {4: regs.arm, 8: regs.aarch64}[m.ptr_size]
    elif m.cpu_name.startswith("mips"):
        m.registers = regs.mips

    m.initialized = True
Exemple #3
0
 def __init__(self, callback):
     super(DbgHooks, self).__init__()
     self.from_attach = False
     self.callback = callback
     self.last_tid = idaapi.get_current_thread()
     self.timer_freq = 1000 / 4
     self.timer = None
Exemple #4
0
def set_thread_info():
    if m.is_pefile:
        current_thread_id = idaapi.get_current_thread()
        if m.thread_id != current_thread_id:
            m.thread_id  = current_thread_id
            m.stack_segm = get_stack_segment()
    elif m.filetype == idaapi.f_ELF:
        pass
Exemple #5
0
def get_stack_segment():
    thread_id = idaapi.get_current_thread()
    tib_ea = get_thread_tib(thread_id)
    if tib_ea:
        offset = m.ptr_size * 2
        stack_limit = m.get_ptr(tib_ea + offset)
        return idaapi.getseg(stack_limit)
    return None
Exemple #6
0
def GetLastErrorEx():
    tib_ea = get_thread_tib(idaapi.get_current_thread())
    if tib_ea:
        return idc.get_wide_dword(tib_ea+0x34)
    return None
Exemple #7
0
 def check_thread(self):
     tid = idaapi.get_current_thread()
     if self.last_tid != tid:
         self.notify()
         self.last_tid = tid
     return self.timer_freq