Example #1
0
/* -------------------------------------------------------------------------- *
 * --------------- Compute the formal concepts by brute force --------------- *
 * -------------------------------------------------------------------------- */
int main(int argc, char const *argv[])
{
	for(int i = argc ; i-- ; )
		printf( "%s\n", argv[ i ] );

	char buffer[2][16];
	FILE *fout;
	fout = fopen( "concepts.txt", "w+" );
// Build concepts. It does not matter whether we traverse the space of
//  objects or the space of properties.
	for( int i = 0 ; i < ( 1 << G ) ; ++i ) {
		unsigned p = properties( i );
		unsigned o = objects( p );
// The concept is a pair (g, m) such that g. = m and .m = g. Equivalently
//  a formal concept is a pair (g, g.) such that .(g.) = g, i.e g is closed
//  in the concept matrix. I wonder if one can define a topology on this
//  discrete poset.
		if( o != i ) continue;

		display_objects( i, buffer[ 0 ] );
		display_properties( p, buffer[ 1 ] );
		// display_objects( ( ~i ) & ( ( 1 << G ) - 1 ), buffer[ 0 ] );
		fprintf( fout, "%.*s\t%.*s\n", G, buffer[ 0 ], M, buffer[ 1 ] );
	}
	fclose( fout );

	return 0;
}
//--------------------------------------------------------------------------
// This callback handles various hexrays events.
static int idaapi callback(void *, hexrays_event_t event, va_list va)
{
  switch ( event )
  {
    case hxe_right_click:
      {
        vdui_t &vu = *va_arg(va, vdui_t *);
        // add new command to the popup menu
        add_custom_viewer_popup_item(vu.ct, "Display Graph", hotkey_dg, display_graph, &vu);
		add_custom_viewer_popup_item(vu.ct, "Object Explorer", hotkey_ce, display_objects, &vu);
		add_custom_viewer_popup_item(vu.ct, "REconstruct Type", hotkey_rt, reconstruct_type, &vu);
		add_custom_viewer_popup_item(vu.ct, "Jump to Disasm", hotkey_gd, decompiled_line_to_disasm, &vu);
      }
      break;

	case hxe_keyboard:
      {
        vdui_t &vu = *va_arg(va, vdui_t *);
        int keycode = va_arg(va, int);
        // check for the hotkey
		if (keycode == hotcode_dg)
          return display_graph(&vu);
		if (keycode == hotcode_ce)
			return display_objects(&vu);
		if (keycode == hotcode_rt)
          return reconstruct_type(&vu);
		if (keycode == hotcode_gd)
			return decompiled_line_to_disasm(&vu);
      }
      break;

	case hxe_double_click:
		{
			vdui_t &vu = *va_arg(va, vdui_t *);
			decompile_func(vu);
		}
		break;
    default:
      break;
  }
  return 0;
}