idapython 处理IDA错误将数据转成了汇编指令

idapython 将汇编转成 int

import idc
import ida_bytes
import ida_kernwin

def convert_data():
        align_size = ida_kernwin.ask_long(4, "align size")
        end = ida_kernwin.ask_long(4, "end Addr")
        if align_size == None:
            return
        start = idc.get_screen_ea()
        print("Align %d bytes from 0x%X - 0x%X" % (align_size, start, end))
        ret = ida_bytes.del_items(start, (end-start), ida_bytes.DELIT_EXPAND)
        # if ret == False:
        #     print("del_items error")
        #     return
        flag = None
        if align_size == 1:
            flag = ida_bytes.FF_BYTE
        elif align_size == 2:
            flag = ida_bytes.FF_WORD
        elif align_size == 4:
            flag = ida_bytes.FF_DWORD
        elif align_size == 8:
            flag = ida_bytes.FF_QWORD
        elif align_size == 16:
            flag = ida_bytes.FF_OWORD
        
        if flag == None:
            ida_kernwin.warning("align size is invalid")
            return
            
        while start < end:
            ret = ida_bytes.create_data(start, flag, align_size, ida_idaapi.BADADDR)
            # if ret == False:
            #     print("create_data error")
            #     return
            start += align_size


convert_data()            

你可能感兴趣的:(idapython)