AskUsingForm_c函数

IDA SDK里面提供的UI(user interface)函数 AskUsingForm_c,该函数弹出一个对话框,而对话框的外观形式,就由此函数的第一个参数form(const char *类型)指定。

  static const char *dialog = // 
  "STARTITEM 0
" // dont change
  "This is the title

" // dialog title
  "This is static text
" // static text
  "<String:A:32:32::>
"  //need char[MAXSTR]
  "<Decimal:D:10:10::>
"//sval_t*
  "<#No leading 0x#Hex:M:8:10::>
"//uval_t*
  "<Button:B::::>
"//formcb_t
  "<##Radio Buttons##Radio 1:R>
"
  "<Radio 2:R>>
"//ushort* number of selected radio
  "<##Check Boxes##Check 1:C>
"
  "<Check 2:C>>
";//ushort* bitmask of checks
void idaapi button_func(TView *fields[], int code)
{ 
  msg("The button was pressed!
");
}

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
", input);
    msg("Decimal: %d, Hex %x
", dec, hex);
    msg("Radio button %d is selected
", radio);
    for (int n = 0; checkmask; n++)
    { 
      if (checkmask & 1)
      { 
        msg("Checkbox %d is checked
", n);
      }
      checkmask >>= 1;
    }
  }

  return;
}

static const char *dialog1 = // 
  "This is the title

"// dialog title
  "<##Radio Buttons##Radio 1:R>
"
  "<Radio 2:R>>
"//ushort* number of selected radio
  "<##Radio Buttons##Radio 1:R>
"
  "<Radio 2:R>>
"//ushort* number of selected radio
  "<##Check Boxes##Check 1:C>
"
  "<Check 2:C>>
"//ushort* bitmask of checks
  "<##Check Boxes##Check 1:C>
"
  "<Check 2:C>>
";//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 );
}

原文地址:https://www.cnblogs.com/shangdawei/p/3317620.html