bool GetKernelVersion(char *szBuf, int bufSize) { int major, minor, len; get_kernel_version(szBuf, bufSize); if ( qsscanf(szBuf, "%d.%n%d", &major, &len, &minor) != 2 ) return false; if ( isdigit(szBuf[len + 1]) ) gSdkVersion = 100*major + minor; else gSdkVersion = 10 * (10*major + minor); return true; }
static void run_second_instance(const char * options) { slist_t * sl; char file[QMAXPATH]; ea_t ea = BADADDR; unsigned char opt = 0; long id; unsigned int v; bool cont; char tmp[QMAXPATH*4]; qsscanf(options, "%lu:%" PRIea_t ":%u:%s", &id, &ea, &v, file); opt = (unsigned char)v; if (id) { if (ipc_init(file, 2, id)) { do { cont = ipc_recv_cmd(tmp, sizeof(tmp)); if (cont) { run_second_instance(tmp); ipc_recv_cmd_end(); } }while(cont); } } else { if (ea == BADADDR) { sl = parse_idb (); } else sl = parse_fct(ea, opt); if (!sl) return; siglist_save(sl, file); siglist_free(sl); } }
//-------------------------------------------------------------------------- bool groupman_t::parse_nodeset( psupergroup_t sg, char *grpstr) { // Find node group bounds for ( /*init*/ char *p_group_start = NULL, *p_group_end = NULL; /* cond*/(p_group_start = strchr(grpstr, '(')) != NULL && (p_group_start = skip_spaces(p_group_start+1), (p_group_end = strchr(p_group_start, ')')) != NULL); /*incr*/) { // Terminate the string with the closing parenthesis *p_group_end = '\0'; // Advance to next group grpstr = skip_spaces(p_group_end + 1); // Add a new group pnodegroup_t ng = sg->add_nodegroup(); for (/*init*/ char *saved_ptr, *p = p_group_start, *token = qstrtok(p, ",", &saved_ptr); /*cond*/ p != NULL; /*incr*/ p = qstrtok(NULL, ",", &saved_ptr)) { p = skip_spaces(p); int nid; ea_t start = 0, end = 0; if (qsscanf(p, "%d : %a : %a", &nid, &start, &end) <= 0) continue; // Create an ND nodedef_t *nd = ng->add_node(); nd->nid = nid; nd->start = start; nd->end = end; // Map this node map_nodedef(nid, nd); } } return true; }
void get_struct_key(struc_t * struc_type, const VTBL_info_t& vtbl_info, qstring &file_entry_key, bool &filtered, const std::map<ea_t, VTBL_info_t>& vtbl_map) { qstring sub_key; qstring vtables_sub_key; int vftbales_num = 0; int members_count = 0; for ( ea_t offset = get_struc_first_offset(struc_type) ; offset != BADADDR ; offset = get_struc_next_offset(struc_type, offset)) { member_t * member_info = get_member(struc_type, offset); if (member_info != NULL) { qstring member_name = get_member_name(member_info->id); asize_t member_size = get_member_size(member_info); if (member_name.find("vftbl_", 0) != -1) { ea_t vtable_addr = 0; int i; if (qsscanf(member_name.c_str(), "vftbl_%d_%" FMT_EA "x", &i, &vtable_addr) > 0) { if (vtbl_map.count(vtable_addr) != 0) { vtables_sub_key.cat_sprnt("_%d", vtbl_map.at(vtable_addr).methods); } } vftbales_num ++; } sub_key.cat_sprnt("_%d", member_size); members_count ++; } } file_entry_key.sprnt("t_%d_%d", vtbl_info.methods, vftbales_num); file_entry_key += vtables_sub_key; file_entry_key += sub_key; if (members_count < STRUCT_DUMP_MIN_MEMBER_COUNT) filtered = true; }
//-------------------------------------------------------------------------- int idaapi init(void) { // gui version? if ( callui(ui_get_hwnd).vptr == NULL && !is_idaq() ) return PLUGIN_SKIP; char buf[10]; get_kernel_version(buf, sizeof(buf)); int v1, v2; if ( qsscanf(buf, "%d.%d", &v1, &v2) != 2 || v1*10+v2 < 55 ) { warning("Sorry, the callgraph plugin required IDA v5.5 or higher\n"); return PLUGIN_SKIP; } if ( !add_menu_item(CMD_MENU "Function calls", CMD_NAME, NULL, SETMENU_APP, run_plugin, NULL) ) { msg("Failed to register menu item for <" CMD_NAME "> plugin! Please access it from the plugins submenu"); return PLUGIN_SKIP; } return PLUGIN_KEEP; }