From 4546dc743391d533382efede871aaad476214dbd Mon Sep 17 00:00:00 2001 From: ZERO-A-ONE Date: Tue, 19 Aug 2025 15:35:15 +0800 Subject: [PATCH] support IDA 9.0~9.1 The current IDA script generation will encounter API incompatibility issues in both 9.0 RC1 and 9.1, and the relevant APIs have been fixed to support the new versions. --- blutter/src/DartDumper.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) mode change 100644 => 100755 blutter/src/DartDumper.cpp diff --git a/blutter/src/DartDumper.cpp b/blutter/src/DartDumper.cpp old mode 100644 new mode 100755 index a5ef716..93e9d40 --- a/blutter/src/DartDumper.cpp +++ b/blutter/src/DartDumper.cpp @@ -125,8 +125,19 @@ void DartDumper::Dump4Ida(std::filesystem::path outDir) // use header file then adding comment is much faster auto comments = DumpStructHeaderFile((outDir / "ida_dart_struct.h").string()); of << R"CBLOCK( -import ida_struct +import idaapi +import idc +import ida_typeinf import os + +def get_struc_by_id(sid): + if sid == idc.BADADDR: + return None + tif = ida_typeinf.tinfo_t() + if tif.get_type_by_tid(sid): + return tif + return None + def create_Dart_structs(): sid1 = idc.get_struc_id("DartThread") if sid1 != idc.BADADDR: @@ -135,10 +146,18 @@ def create_Dart_structs(): idaapi.idc_parse_types(hdr_file, idc.PT_FILE) sid1 = idc.import_type(-1, "DartThread") sid2 = idc.import_type(-1, "DartObjectPool") - struc = ida_struct.get_struc(sid2) + struc = get_struc_by_id(sid2) )CBLOCK"; for (const auto& [offset, comment] : comments) { - of << "\tida_struct.set_member_cmt(ida_struct.get_member(struc, " << offset << "), '''" << comment << "''', True)\n"; + of << "\tif struc:\n"; + of << "\t\tudt_data = ida_typeinf.udt_type_data_t()\n"; + of << "\t\tif struc.get_udt_details(udt_data):\n"; + of << "\t\t\tfor i in range(udt_data.size()):\n"; + of << "\t\t\t\tudm = udt_data[i]\n"; + of << "\t\t\t\tif udm.offset == " << offset << ":\n"; + of << "\t\t\t\t\tudm.cmt = '''" << comment << "'''\n"; + of << "\t\t\t\t\tstruc.create_udt(udt_data, ida_typeinf.BTF_STRUCT)\n"; + of << "\t\t\t\t\tbreak\n"; } of << "\treturn sid1, sid2\n"; of << "thrs, pps = create_Dart_structs()\n"; @@ -512,9 +531,7 @@ std::string DartDumper::ObjectToString(dart::Object& obj, bool simpleForm, bool } return std::format("Code: {} ({:#x})", code.ToCString(), ep); } - case dart::kArrayCid: case dart::kImmutableArrayCid: { - // Note: since Dart 3.7, Ojbect Pool is mutable. so, Array is used too // Objects in Object Pool immutable, so only immutable array is used for array // Most of no type arguments in Object Pool are Argument Descriptor const auto& arr = dart::Array::Cast(obj);