def activate(self, ctx): hx_view = idaapi.get_tform_vdui(ctx.form) if hx_view.item.citype != idaapi.VDI_EXPR or hx_view.item.e.op != idaapi.cot_num: return ea = ctx.cur_ea c_number = hx_view.item.e.n number_value = c_number._value ordinal = GetStructureBySize.select_structure_by_size(number_value) if ordinal: number_format_old = c_number.nf number_format_new = idaapi.number_format_t() number_format_new.flags = idaapi.FF_1STRO | idaapi.FF_0STRO operand_number = number_format_old.opnum number_format_new.opnum = operand_number number_format_new.props = number_format_old.props number_format_new.type_name = idaapi.create_numbered_type_name( ordinal) c_function = hx_view.cfunc number_formats = c_function.numforms # idaapi.user_numforms_t operand_locator = idaapi.operand_locator_t( ea, ord(operand_number) if operand_number else 0) if operand_locator in number_formats: del number_formats[operand_locator] number_formats[operand_locator] = number_format_new c_function.save_user_numforms() hx_view.refresh_view(True)
def activate(self, ctx): hx_view = idaapi.get_widget_vdui(ctx.widget) if not self.check(hx_view): return ea = ctx.cur_ea c_number = hx_view.item.e number_value = c_number.numval() ordinal = _choose_structure_by_size(number_value) if ordinal: number_format_old = c_number.n.nf number_format_new = idaapi.number_format_t() number_format_new.flags = idaapi.FF_1STRO | idaapi.FF_0STRO operand_number = number_format_old.opnum number_format_new.opnum = operand_number number_format_new.props = number_format_old.props number_format_new.type_name = idaapi.create_numbered_type_name(ordinal) c_function = hx_view.cfunc number_formats = c_function.numforms # type: idaapi.user_numforms_t # print "(number) flags: {0:#010X}, type_name: {1}, opnum: {2}".format( # number_format.flags, # number_format.type_name, # number_format.opnum # ) operand_locator = idaapi.operand_locator_t(ea, ord(operand_number) if operand_number else 0) if operand_locator in number_formats: del number_formats[operand_locator] number_formats[operand_locator] = number_format_new c_function.save_user_numforms() hx_view.refresh_view(True)