Exemple #1
0
//--------------------------------------------------------------------------
void idaapi run(int /*arg*/)
{
  HWND hwnd = NULL;
  TForm *form = create_tform("Sample graph", &hwnd);
  if ( hwnd != NULL )
  {
    // get a unique graph id
    netnode id;
    id.create("$ ugraph sample");
    graph_viewer_t *gv = create_graph_viewer(form,  id, callback, NULL, 0);
    open_tform(form, FORM_MDI|FORM_TAB|FORM_MENU);
    if ( gv != NULL )
    {
      viewer_fit_window(gv);
      viewer_add_menu_item(gv, "User function", menu_callback, gv, NULL, 0);
    }
  }
  else
  {
    close_tform(form, 0);
  }
}
// Display ctree graph for current decompiled function
static bool idaapi display_ctree_graph(void *ud)
{
	vdui_t &vu = *(vdui_t *)ud;

	// Determine the ctree item to highlight
	vu.get_current_item(USE_KEYBOARD);
	citem_t *highlight = vu.item.is_citem() ? vu.item.e : NULL;
	graph_info_t *gi = graph_info_t::create(vu.cfunc->entry_ea, highlight);

	netnode id;
	id.create();

	qstring title = gi->title;

	HWND hwnd = NULL;
	TForm *form = create_tform(title.c_str(), &hwnd);
	if (hwnd == NULL)
	{
		warning("Ctree Graph window already open. Switching to it.");
		logmsg(DEBUG, "Ctree Graph window already open. Switching to it.");
		form = find_tform(title.c_str());
		if (form != NULL)
			switchto_tform(form, true);
		return true;
	}

	if (hwnd != NULL)
	{
		gi->vu = (vdui_t *)ud;
		gi->form = form;
		gi->gv = create_graph_viewer(form, id, gr_callback, gi, 0);
		open_tform(form, FORM_TAB | FORM_MENU | FORM_QWIDGET);

		viewer_fit_window(gi->gv);
	}

	return true;
}
Exemple #3
0
static bool pgraph_create(slist_t *sl, int num)
{
	HWND hwnd = NULL;
	char form_name[512];
	char node_name[512];
	TForm *form;
	bool form_is_new = true;

	create_form_name(form_name, sl, num);
	qsnprintf(node_name, sizeof(node_name), "$ %s", form_name);
	
	form = find_tform(form_name);

	netnode id;
	bool already_existed = !id.create(node_name);
	if (form && already_existed)
	{
		form_is_new = false;
		switchto_tform(form, true);
		sl->gv = get_graph_viewer(form);
	}
	else
	{
		form = create_tform(form_name, &hwnd);
		if (hwnd)
		{
			sl->gv = create_graph_viewer(form, id, graph_callback, sl, 0);
			open_tform(form, FORM_TAB|FORM_MENU|FORM_QWIDGET);
			if (sl->gv)
			{
				viewer_fit_window(sl->gv);
				viewer_add_menu_item(sl->gv, "Jump to code", menu_callback, sl, NULL, 0);			
			}
		}
	}

	return form_is_new;
}
Exemple #4
0
//--------------------------------------------------------------------------
void idaapi run(int arg)
{
  if ( arg == -1 )
  {
    load_options();
    show_options();
    return;
  }

  func_t *pfn = get_func(get_screen_ea());
  if ( pfn == NULL )
  {
    warning("Please position the cursor in a function first!");
    return;
  }
  load_options();
  qstring title;
  graph_info_t::get_title(pfn->startEA, &title);

  HWND hwnd = NULL;
  TForm *form = create_tform(title.c_str(), &hwnd);
  if ( hwnd != NULL )
  {
    // window is new, but instance is in the list?
    graph_info_t *gi = graph_info_t::find(title.c_str());
    if ( gi != NULL )
    {
      // in that case let us "recycle" the instance
      gi->func_ea = pfn->startEA;
    }
    else
    {
      // we create a new instance
      gi = graph_info_t::create(pfn->startEA);
    }

    if ( gi != NULL )
    {
      // get a unique graph id
      netnode id;
      id.create();

      gi->mark_for_refresh();
      gi->form = form;
      gi->gv = create_graph_viewer(form, id, gr_callback, gi, 0);
      open_tform(form, FORM_MDI|FORM_TAB|FORM_MENU);
      if ( gi->gv != NULL )
      {
        viewer_fit_window(gi->gv);
        viewer_add_menu_item(gi->gv, "Options", menu_options_cb, gi, "O", 0);
        viewer_add_menu_item(gi->gv, "Goto to first node", menu_home_cb, gi, "H", 0);
        viewer_add_menu_item(gi->gv, "Refresh", menu_refresh_cb, gi, "R", 0);
        viewer_add_menu_item(gi->gv, "Search first", menu_searchfirst_cb, gi, "S", 0);
        viewer_add_menu_item(gi->gv, "Search next", menu_searchnext_cb, gi, "N", 0);
      }
      else
      {
        graph_info_t::destroy(gi);
        gi = NULL;
      }
    }
    // failed to creat a graph view?
    if ( gi == NULL )
    {
      warning("Failed to create call graph window!\n");
      return;
    }
  }
  else
  {
    graph_info_t *gi = graph_info_t::find(title.c_str());
    if ( gi != NULL )
    {
      gi->refresh();
      open_tform(gi->form, FORM_MDI|FORM_TAB|FORM_MENU);
    }
  }
}