AskUsingForm_c函数
IDA SDK里面提供的UI(user interface)函数 AskUsingForm_c,该函数弹出一个对话框,而对话框的外观形式,就由此函数的第一个参数form(const char *类型)指定。
static const char *dialog = // "STARTITEM 0\n" // dont change "This is the title\n\n" // dialog title "This is static text\n" // static text "<String:A:32:32::>\n" //need char[MAXSTR] "<Decimal:D:10:10::>\n"//sval_t* "<#No leading 0x#Hex:M:8:10::>\n"//uval_t* "<Button:B::::>\n"//formcb_t "<##Radio Buttons##Radio 1:R>\n" "<Radio 2:R>>\n"//ushort* number of selected radio "<##Check Boxes##Check 1:C>\n" "<Check 2:C>>\n";//ushort* bitmask of checks
void idaapi button_func(TView *fields[], int code) { msg("The button was pressed!\n"); } void __stdcall IDP_run(int arg) { char input[MAXSTR]; sval_t dec = 0; uval_t hex = 0xdeadbeef; ushort radio = 1; ushort checkmask = 3; qstrncpy(input, "initial value", sizeof(input)); if (AskUsingForm_c(dialog, input, &dec, &hex, button_func, &radio, &checkmask) == 1) { msg("The input string was: %s\n", input); msg("Decimal: %d, Hex %x\n", dec, hex); msg("Radio button %d is selected\n", radio); for (int n = 0; checkmask; n++) { if (checkmask & 1) { msg("Checkbox %d is checked\n", n); } checkmask >>= 1; } } return; }
static const char *dialog1 = // "This is the title\n\n"// dialog title "<##Radio Buttons##Radio 1:R>\n" "<Radio 2:R>>\n"//ushort* number of selected radio "<##Radio Buttons##Radio 1:R>\n" "<Radio 2:R>>\n"//ushort* number of selected radio "<##Check Boxes##Check 1:C>\n" "<Check 2:C>>\n"//ushort* bitmask of checks "<##Check Boxes##Check 1:C>\n" "<Check 2:C>>\n";//ushort* bitmask of checks static void idaapi show_dialog1( void ) { ushort bitMask, bitMask1 =0; ushort btnIndex, bitIndex1; int ok = AskUsingForm_c( dialog1, &btnIndex, &bitIndex1, &bitMask, &bitMask1 ); }