static void display_unmatched(deng_t * eng) { choose2(0, -1, -1, -1, -1, // position is determined by Windows eng, // pass the created function list to the window qnumber(header_unmatch),// number of columns widths_unmatch, // widths of columns sizer_unmatch, // function that returns number of lines desc_unmatch, // function that generates a line title_unmatch, // window title -1, // use the default icon for the window 1, // position the cursor on the first line NULL, // "kill" callback NULL, // "new" callback NULL, // "update" callback graph_unmatch, // "edit" callback enter_unmatch, // function to call when the user pressed Enter close_window, // function to call when the window is closed popup_unmatch, // use default popup menu items NULL); // use the same icon for all lines eng->wnum++; add_chooser_command(title_unmatch, "Set match", res_match, 0, -1, CHOOSER_POPUP_MENU | CHOOSER_MENU_EDIT); }
static void display_matched(deng_t * eng) { choose2(CH_ATTRS, -1, -1, -1, -1, // position is determined by Windows eng, // pass the created function list to the window qnumber(header_match),// number of columns widths_match, // widths of columns sizer_match, // function that returns number of lines desc_match, // function that generates a line title_match, // window title -1, // use the default icon for the window 1, // position the cursor on the first line NULL, // "kill" callback NULL, // "new" callback NULL, // "update" callback graph_match, // "edit" callback enter_match, // function to call when the user pressed Enter close_window, // function to call when the window is closed popup_match, // use default popup menu items NULL); eng->wnum++; add_chooser_command(title_match, "Unmatch", res_munmatch, 0, -1, CHOOSER_POPUP_MENU | CHOOSER_MENU_EDIT); add_chooser_command(title_match, "Set as identical", res_mtoi, 0, -1, CHOOSER_POPUP_MENU | CHOOSER_MENU_EDIT); add_chooser_command(title_match, "Flag/unflag", res_flagged, 0, -1, CHOOSER_POPUP_MENU | CHOOSER_MENU_EDIT); add_chooser_command(title_match, "Import Symbol", transfer_sym_match, 0, -1, CHOOSER_POPUP_MENU | CHOOSER_MENU_EDIT); }
//--------------------------------------------------------------------------- static bool idaapi show_window(void *) { thid_t tid = get_current_thread(); // Find and refresh existing window char title[MAXSTR]; qsnprintf(title, sizeof(title), "[%04X] - Structured exception handlers list", tid); TForm *form = find_tform(title); //lint !e64 if ( form != NULL ) { switchto_tform(form, true); //lint !e64 return true; } x86seh_ctx_t *ch = new x86seh_ctx_t(tid, title); if ( !ch->get_sehlist() ) { delete ch; return false; } int code = choose2(CH_NOBTNS, -1, -1, -1, -1, ch, qnumber(x86seh_chooser_cols), widths, ch_sizer, ch_getl, title, 144, // icon 1, NULL, NULL, ch_update, NULL, ch_enter, ch_destroy, NULL, NULL); if ( code != -1 ) hook_to_notification_point(HT_DBG, dbg_callback, ch); //lint -esym(429,ch) custodial pointer has not been freed or returned return true; }
// Get the number of possible pairwise alignments that could support // this block. Ordinarily this is (degree choose 2), but since we // don't do outgroup self-alignment, it's a bit smaller. static uint64_t numPossibleSupportingHomologies(stPinchBlock *block, Flower *flower) { uint64_t outgroupDegree = 0, ingroupDegree = 0; stPinchBlockIt segIt = stPinchBlock_getSegmentIterator(block); stPinchSegment *segment; while ((segment = stPinchBlockIt_getNext(&segIt)) != NULL) { Name capName = stPinchSegment_getName(segment); Cap *cap = flower_getCap(flower, capName); Event *event = cap_getEvent(cap); if (event_isOutgroup(event)) { outgroupDegree++; } else { ingroupDegree++; } } assert(outgroupDegree + ingroupDegree == stPinchBlock_getDegree(block)); // We do the ingroup-ingroup alignments as an all-against-all // alignment, so we can see each ingroup-ingroup homology up to // twice. return choose2(ingroupDegree) * 2 + ingroupDegree * outgroupDegree; }
void idaapi run(int arg) { //Credits to Halvar for his choose2() example code! //build the listbox object! line *obj = build_segm_obj(); choose2( CH_MODAL, -1,30, // x0=-1 for autoposition 50,70, obj, // our listbox object 3, // Number of columns NULL, // Widths of columns (may be NULL) get_item_qty,// Number of items getn_item_text, // get string of n-th item (1..n) // 0-th item if header line "DumpSeg Plugin by Dennis Elser", // menu title (includes ptr to help) 21, // number of icon to display 1, // starting item NULL, // multi-selection callback for "Delete" (may be NULL) NULL, // callback for "New" (may be NULL) NULL,// callback for "Update"(may be NULL) // update the whole list // returns the new location of item 'n' dump_seg, // callback for "Edit" (may be NULL) NULL, // callback for non-modal "Enter" (may be NULL) NULL, // callback to call when the window is closed (may be NULL) popupnames, // Default: insert, delete, edit, refresh NULL); //free and destroy listbox object free(obj); return; }
static int choose_board(choose_board_t *cbrd) { choose_board_init(cbrd); choose_t cs; cs.data = cbrd; cs.loader = choose_board_load; cs.title = choose_board_title; cs.display = choose_board_display; cs.handler = choose_board_handler; modify_user_mode(cbrd->newflag ? READNEW : READBRD); choose2(&cs); if (!cbrd->recursive) { clear(); save_zapbuf(cbrd); free(cbrd->brds); free(cbrd->zapbuf); free(cbrd->gbrds); } return 0; }
//-------------------------------------------------------------------------- // // The plugin method // // This is the main function of plugin. // void idaapi run(int /*arg*/) { char title[MAXSTR]; // Let's display the functions called from the current one // or from the selected area // First we determine the working area func_item_iterator_t fii; bool ok; ea_t ea1, ea2; if ( callui(ui_readsel, &ea1, &ea2).cnd ) // the selection is present? { callui(ui_unmarksel); // unmark selection qsnprintf(title, sizeof(title), "Functions called from %08a..%08a", ea1, ea2); ok = fii.set_range(ea1, ea2); } else // nothing is selected { func_t *pfn = get_func(get_screen_ea()); // try the current function if ( pfn == NULL ) { warning("Please position the cursor on a function or select an area"); return; } ok = fii.set(pfn); static const char str[] = "Functions called from "; char *ptr = qstpncpy(title, str, sizeof(title)); get_func_name(pfn->startEA, ptr, sizeof(title)-(ptr-title)); } // We are going to remember the call instruction addresses // in a netnode // altval(i) will contain the address of the call instruction netnode *node = new netnode; node->create(); int counter = 0; while ( ok ) { ea_t ea = fii.current(); if ( is_call_insn(ea) ) // a call instruction is found node->altset(counter++, ea);//get_first_fcref_from(ea)); ok = fii.next_code(); } // altval(-1) will contain the number of pairs node->altset(-1, counter); // now open the window choose2(0, // non-modal window -1, -1, -1, -1, // position is determined by the OS node, // pass the created netnode to the window qnumber(header), // number of columns widths, // widths of columns sizer, // function that returns number of lines desc, // function that generates a line title, // window title -1, // use the default icon for the window 0, // position the cursor on the first line NULL, // "kill" callback NULL, // "new" callback NULL, // "update" callback NULL, // "edit" callback enter_cb, // function to call when the user pressed Enter destroy_cb, // function to call when the window is closed NULL, // use default popup menu items NULL); // use the same icon for all lines }
int main() { int c1 = choose1(5,10); int c2 = choose2(0,c1); return c1+c2; }
//-------------------------------------------------------------------------- void run(int /*arg*/) { if ( !autoIsOk() && askyn_c(-1, "HIDECANCEL\n" "The autoanalysis has not finished yet.\n" "The result might be incomplete. Do you want to continue?") < 0 ) return; // gather information about the entry points entrylist_t *li = new entrylist_t; size_t n = get_entry_qty(); for ( size_t i=0; i < n; i++ ) { asize_t ord = get_entry_ordinal((int)i); ea_t ea = get_entry(ord); if ( ord == ea ) continue; qtype type, fnames; char decl[MAXSTR]; char true_name[MAXSTR]; asize_t argsize = 0; get_entry_name(ord, true_name, sizeof(true_name)); if ( get_tinfo(ea, &type, &fnames) && print_type_to_one_line( decl, sizeof(decl), idati, type.c_str(), true_name, NULL, fnames.c_str()) == T_NORMAL ) { // found type info -- calc the args size func_type_info_t fi; int a = build_funcarg_info(idati, type.c_str(), fnames.c_str(), &fi, 0); if ( a != 0 ) { for ( int k=0; k < a; k++ ) { const type_t *ptr = fi[k].type.c_str(); int s1 = (int)get_type_size(idati, ptr); s1 = qmax(s1, inf.cc.size_i); argsize += s1; } } } else if ( get_long_name(BADADDR, ea, decl, sizeof(decl)) != NULL && get_true_name(BADADDR, ea, true_name, sizeof(true_name)) != NULL && strcmp(decl, true_name) != 0 ) { // found mangled name } else { // found nothing, just show the name const char *name = get_name(BADADDR, ea, true_name, sizeof(true_name)); if ( name == NULL ) continue; qstrncpy(decl, name, sizeof(decl)); } if ( argsize == 0 ) { func_t *pfn = get_func(ea); if ( pfn != NULL ) argsize = pfn->argsize; } item_t x; x.ord = (int)ord; x.ea = ea; x.decl = decl; x.argsize = (uint32)argsize; li->push_back(x); } // now open the window choose2(false, // non-modal window -1, -1, -1, -1, // position is determined by Windows li, // pass the created array qnumber(header), // number of columns widths, // widths of columns sizer, // function that returns number of lines desc, // function that generates a line "Exported functions", // window title -1, // use the default icon for the window 0, // position the cursor on the first line NULL, // "kill" callback NULL, // "new" callback NULL, // "update" callback NULL, // "edit" callback enter_cb, // function to call when the user pressed Enter destroy_cb, // function to call when the window is closed NULL, // use default popup menu items NULL); // use the same icon for all lines }
/*la funziona che sceglie la prossima mossa da effettuare Ho seguito la filosofia KISS, ma va ottimizzata*/ unsigned int old_select_move(const int hm,const unsigned int index,const int sl) { MOVEL m; unsigned int i; switch (tree.status[Ply]) { case ST_PV_MOVE: m.move.mi = tree.old_pv[Ply].mi; /*prova la mossa della pv*/ tree.status[Ply] = ST_GEN_ALL; tree.next[Ply] = 0; tree.first_move_played[Ply].mi=0; if (1 && tree.follow_pv && m.move.mi) { if (verify_move(m.move)) { tree.next[Ply]++; tree.first_move_played[Ply].mi=m.move.mi; return m.move.mi; } tree.follow_pv = 0; } case ST_GEN_ALL: gen_all(); /*genera tutte le mosse*/ if ((tree.first_move[Ply + 1] == tree.first_move[Ply])) return 0; /* tree.next[Ply]+=tree.first_move[Ply];*/ /*Elimina la mossa PV*/ if (1 && tree.next[Ply]) { for (i = tree.first_move[Ply];i < tree.first_move[Ply + 1];i++) { /*inserisce la PV come prima mossa*/ if (tree.move_list[i].move.mi == tree.pv[0][Ply].mi) { m = tree.move_list[i]; tree.move_list[i] = tree.move_list[tree.first_move[Ply]]; tree.move_list[tree.first_move[Ply]] = m; break; } } } tree.next[Ply] += tree.first_move[Ply]; tree.status[Ply] = ST_TT_MOVE; case ST_TT_MOVE: /*Mossa tabella hash*/ if (mizar.o.use_hash && hm) { m.move=hash_table[index].slot[sl].best_move; if (m.move.mi && m.move.mi!=tree.first_move_played[Ply].mi) { for (i = tree.next[Ply]; i < tree.first_move[Ply + 1];i++) { if (tree.move_list[i].move.mi == m.move.mi) { tree.move_list[i]=tree.move_list[tree.next[Ply]]; tree.move_list[tree.next[Ply]] = m; tree.next[Ply]++; tree.status[Ply] = ST_CPT_MOV; return (m.move.mi); break; } } } } tree.status[Ply] = ST_CPT_MOV; case ST_CPT_MOV: /*Seglie tra le catture*/ if (choose(tree.next[Ply], tree.first_move[Ply + 1])) { m = tree.move_list[tree.next[Ply]]; tree.next[Ply]++; return m.move.mi; } if (tree.next[Ply] == tree.first_move[Ply + 1]) return 0; tree.status[Ply] = ST_CNT_MOV; case ST_CNT_MOV: m.move.mi = tree.c_heuristic[b256to64[tree.history[N_moves - 1].m.ms.from]][b256to64[tree.history[N_moves - 1].m.ms.to]][tree.history[N_moves - 1].m.ms.flag].mi; if (m.move.mi) for (i = tree.next[Ply];i < tree.first_move[Ply + 1];i++) { if (tree.move_list[i].move.mi == m.move.mi) { tree.move_list[i] = tree.move_list[tree.next[Ply]]; tree.next[Ply]++; tree.status[Ply] = ST_KL1_MOV; return m.move.mi; } } case ST_KL1_MOV: /*Killer Move 1*/ if (tree.k_heuristic[Ply].m1.mi) for (i = tree.next[Ply];i < tree.first_move[Ply + 1];i++) { if (tree.move_list[i].move.mi == tree.k_heuristic[Ply].m1.mi) { tree.move_list[i] = tree.move_list[tree.next[Ply]]; tree.next[Ply]++; tree.status[Ply] = ST_KL2_MOV; return tree.k_heuristic[Ply].m1.mi; } } case ST_KL2_MOV: /*Killer Move 2*/ if (tree.k_heuristic[Ply].m2.mi) for (i = tree.next[Ply];i < tree.first_move[Ply + 1];i++) { if (tree.move_list[i].move.mi == tree.k_heuristic[Ply].m1.mi) { tree.move_list[i] = tree.move_list[tree.next[Ply]]; tree.next[Ply]++; tree.status[Ply] = ST_SRT_ALL; return tree.k_heuristic[Ply].m1.mi; } } tree.status[Ply] = ST_SRT_ALL; case ST_SRT_ALL: /*Assegna un punteggio alle mosse rimanenti*/ for (i = tree.next[Ply];i < tree.first_move[Ply + 1];i++) { tree.move_list[i].scoren = tree.h_heuristic[tree.move_list[i].move.ms.from][tree.move_list[i].move.ms.to]; } tree.status[Ply] = ST_ALL_MOV; case ST_ALL_MOV: /* sceglie tra le rimanenti mosse*/ if (choose2(tree.next[Ply], tree.first_move[Ply + 1])) { m = tree.move_list[tree.next[Ply]]; tree.next[Ply]++; return m.move.mi; } break; default: puts("Unexpected tree status."); assert(0); } return 0; }