Ejemplo n.º 1
0
//--------------------------------------------------------------------------
const char *idaapi set_idp_options(const char *keyword,int /*value_type*/,const void * /*value*/)
{
  if ( keyword != NULL ) return IDPOPT_BADKEY;
  if ( choose_ioport_device(cfgname, device, sizeof(device), NULL) )
    load_symbols();
  return IDPOPT_OK;
}
Ejemplo n.º 2
0
Archivo: reg.cpp Proyecto: nealey/vera
inline static void idaapi choose_device(TView *[] = NULL, int = 0)
{
  char cfgfile[QMAXFILE];
  get_cfg_filename(cfgfile, sizeof(cfgfile));
  if ( choose_ioport_device(cfgfile, device, sizeof(device), NULL) )
    set_device_name(device, IORESP_NONE);
}
Ejemplo n.º 3
0
Archivo: reg.cpp Proyecto: nealey/vera
inline static bool idaapi choose_device(TView *[] = NULL, int = 0)
{
    bool ok = choose_ioport_device(cfgname, device, sizeof(device), NULL);
    if ( !ok )
        qstrncpy(device, NONEPROC, sizeof(device));
    return ok;
}
Ejemplo n.º 4
0
Archivo: reg.cpp Proyecto: nealey/vera
//------------------------------------------------------------------
const char *set_idp_options(const char *keyword,int /*value_type*/,const void * /*value*/)
{
    if ( keyword != NULL ) return IDPOPT_BADKEY;
    if ( choose_ioport_device(cfgname, device, sizeof(device), parse_area_line0) )
        set_device_name(device, IORESP_PORT|IORESP_INT);
    return IDPOPT_OK;
}
Ejemplo n.º 5
0
//----------------------------------------------------------------------
static int idaapi notify(processor_t::idp_notify msgid, ...)
{
  va_list va;

  va_start(va, msgid);

  // A well behaving processor module should call invoke_callbacks()
  // in his notify() function. If this function returns 0, then
  // the processor module should process the notification itself
  // Otherwise the code should be returned to the caller:

  int code = invoke_callbacks(HT_IDP, msgid, va);

  if (code)
    return code;

  switch (msgid)
  {
    case processor_t::init:
      inf.mf = 0;
      inf.s_genflags |= INFFL_LZERO;
      helper.create("$ CR16");
    default:
      break;

    case processor_t::term:
      free_ioports(ports, numports);
      break;

    case processor_t::newfile:
      // ask for a  processor from the config file
      // use it to handle ports and registers
      {
        char cfgfile[QMAXFILE];

        get_cfg_filename(cfgfile, sizeof(cfgfile));
        if ( choose_ioport_device(cfgfile, device, sizeof(device), parse_area_line0) )
          set_device_name(device, IORESP_ALL);
      }
      break;

    case processor_t::newprc:
      {
        char buf[MAXSTR];
        if (helper.supval(-1, buf, sizeof(buf)) > 0)
          set_device_name(buf, IORESP_PORT);
      }
      break;

    case processor_t::newseg:
      {
        segment_t *s = va_arg(va, segment_t *);
        // Set default value of DS register for all segments
        set_default_dataseg(s->sel);
      }
      break;
  }
  va_end(va);
  return 1;
}
Ejemplo n.º 6
0
Archivo: reg.cpp Proyecto: nealey/vera
//--------------------------------------------------------------------------
static void choose_device(TView *[],int)
{
  if ( choose_ioport_device(cfgname, device, sizeof(device), NULL) )
  {
    load_symbols(IORESP_ALL);
    apply_symbols();
  }
}
Ejemplo n.º 7
0
//------------------------------------------------------------------
const char *idaapi set_idp_options(const char *keyword,int /*value_type*/,const void * /*value*/)
{
  if ( keyword != NULL ) return IDPOPT_BADKEY;
  char cfgfile[QMAXFILE];
  get_cfg_filename(cfgfile, sizeof(cfgfile));
  if ( choose_ioport_device(cfgfile, device, sizeof(device), parse_area_line0) )
    set_device_name(device, IORESP_NONE);
  return IDPOPT_OK;
}
Ejemplo n.º 8
0
//----------------------------------------------------------------------
static int idaapi notify(processor_t::idp_notify msgid, ...)
{
  va_list va;
  va_start(va, msgid);

  // A well behaving processor module should call invoke_callbacks()
  // in his notify() function. If this function returns 0, then
  // the processor module should process the notification itself
  // Otherwise the code should be returned to the caller:
  int code = invoke_callbacks(HT_IDP, msgid, va);
  if ( code != 0 )
    return code;

  switch ( msgid )
  {
    case processor_t::init:
      inf.mf = 0;
      inf.s_genflags |= INFFL_LZERO;
      helper.create("$ C39");
    default:
      break;

    case processor_t::term:
      free_ioports(ports, numports);
      break;

    case processor_t::newfile:
      //Выводит длг. окно процессоров, и позволяет выбрать нужный, считывает для выбраного
      //процессора информацию из cfg. По считаной информации подписывает порты и регстры
      {
        char cfgfile[QMAXFILE];
        get_cfg_filename(cfgfile, sizeof(cfgfile));
        if ( choose_ioport_device(cfgfile, device, sizeof(device), parse_area_line0) )
          set_device_name(device, IORESP_ALL);
      }
      break;

    case processor_t::newprc:
      {
        char buf[MAXSTR];
        if ( helper.supval(-1, buf, sizeof(buf)) > 0 )
          set_device_name(buf, IORESP_PORT);
      }
      break;

    case processor_t::newseg:
      {
        segment_t *s = va_arg(va, segment_t *);
        // Set default value of DS register for all segments
        set_default_dataseg(s->sel);
      }
      break;
  }
  va_end(va);
  return(1);
}
Ejemplo n.º 9
0
static int notify(processor_t::idp_notify msgid, ...) { // Various messages:
  va_list va;
  va_start(va, msgid);

// A well behaving processor module should call invoke_callbacks()
// in his notify() function. If this function returns 0, then
// the processor module should process the notification itself
// Otherwise the code should be returned to the caller:

  int code = invoke_callbacks(HT_IDP, msgid, va);
  if ( code ) return code;

  switch ( msgid )
  {
    case processor_t::init:
      helper.create("$ z80");
      break;

    case processor_t::newprc:
      {
        int np = va_arg(va, int);
        pflag = features[np];
        ph.assemblers = i8085asms;
        if ( isZ80() ) ph.assemblers = Z80asms;
        if ( is64180() ) ph.assemblers = HD64180asms;
        if ( isGB() ) ph.assemblers = GBasms;
        {
          char buf[MAXSTR];
          if ( helper.supval(-1, buf, sizeof(buf)) > 0 )
            set_device_name(buf, IORESP_NONE);
        }
      }
      break;

    case processor_t::newfile:
      if ( strcmp(inf.procName, "z180") == 0 )
      {
        char cfgfile[QMAXFILE];
        get_cfg_filename(cfgfile, sizeof(cfgfile));
        if ( choose_ioport_device(cfgfile, device, sizeof(device), parse_area_line0) )
          set_device_name(device, IORESP_AREA);
      }
      break;

    default:
      break;
  }
  va_end(va);

  return(1);
}
Ejemplo n.º 10
0
Archivo: reg.cpp Proyecto: nealey/vera
//------------------------------------------------------------------
static void setup_device(int respect_info)
{
  if ( choose_ioport_device(cfgname, device, sizeof(device), parse_area_line0) )
  {
    // we don't pass IORESP_PORT because that would rename bytes in the code segment
    // we'll handle port renaming ourselves
    if ( display_infotype_dialog(IORESP_ALL, &respect_info, cfgname) )
    {
      set_device_name(device, respect_info & ~IORESP_PORT);
      if ( (respect_info & IORESP_PORT) != 0 )
         apply_symbols();
    }
  }
}
Ejemplo n.º 11
0
Archivo: reg.cpp Proyecto: nealey/vera
//----------------------------------------------------------------------
static bool select_device(int respect_info)
{
  char cfgfile[QMAXFILE];
  get_cfg_filename(cfgfile, sizeof(cfgfile));
  if ( !choose_ioport_device(cfgfile, device, sizeof(device), NULL) )
  {
    qstrncpy(device, NONEPROC, sizeof(device));
    return false;
  }

  if ( !display_infotype_dialog(IORESP_ALL, &respect_info, cfgfile) )
    return false;

  set_device_name(device, respect_info);
  return true;
}
Ejemplo n.º 12
0
Archivo: reg.cpp Proyecto: nealey/vera
const char *idaapi set_idp_options(
    const char *keyword,
    int /*value_type*/,
    const void * /*value*/ )
{
    if ( keyword != NULL )
        return IDPOPT_BADKEY;

    char cfgfile[QMAXFILE];
    get_cfg_filename(cfgfile, sizeof(cfgfile));
    if ( !choose_ioport_device(cfgfile, device, sizeof(device), NULL)
      && strcmp(device, NONEPROC) == 0 )
    {
      warning("No devices are defined in the configuration file %s", cfgfile);
    }
    else
    {
      set_device_name(device, IORESP_NONE);
    }
    return IDPOPT_OK;
}
Ejemplo n.º 13
0
Archivo: reg.cpp Proyecto: nealey/vera
const char *set_idp_options(
    const char *keyword,
    int /*value_type*/,
    const void * /*value*/ )
{
    if ( keyword != NULL )
        return IDPOPT_BADKEY;

    if ( !choose_ioport_device(cfgname, device, sizeof(device), NULL)
      && strcmp(device, NONEPROC) == 0 )
    {
      warning("No devices are defined in the configuration file %s", cfgname);
    }
    else
    {
      char buf[MAXSTR];
      if ( helper.supval(-1, buf, sizeof(buf)) > 0 )
        set_device_name(buf, IORESP_ALL);
    }
    return IDPOPT_OK;
}
Ejemplo n.º 14
0
static void choose_device(TView *[] = NULL, int = 0) {
    if ( choose_ioport_device(cfgname, device, sizeof(device), NULL) )
        set_device_name(device, IORESP_NONE);
}
Ejemplo n.º 15
0
//--------------------------------------------------------------------------
static void choose_device(TView *[],int)
{
  if ( choose_ioport_device(cfgname, device, sizeof(device), parse_area_line0) )
    f2mc_set_device_name(device, IORESP_PORT|IORESP_INT);
}
Ejemplo n.º 16
0
static int notify(processor_t::idp_notify msgid, ...)
{
  va_list va;
  va_start(va, msgid);

// A well behaving processor module should call invoke_callbacks()
// in his notify() function. If this function returns 0, then
// the processor module should process the notification itself
// Otherwise the code should be returned to the caller:

  int code = invoke_callbacks(HT_IDP, msgid, va);
  if ( code ) return code;

  switch(msgid)
  {
    case processor_t::init:
//      __emit__(0xCC);   // debugger trap
      helper.create("$ f2mc");
      {
        char buf[MAXSTR];
        if ( helper.supval(0, buf, sizeof(buf)) > 0 )
          f2mc_set_device_name(buf, IORESP_NONE);
      }
      inf.wide_high_byte_first = 1;
      break;

    case processor_t::term:
      free_ioports(ports, numports);
    default:
      break;

    case processor_t::newfile:   // new file loaded
      set_segm_name(get_first_seg(), "CODE");
      if ( choose_ioport_device(cfgname, device, sizeof(device), parse_area_line0) )
        f2mc_set_device_name(device, IORESP_ALL);
      for ( int i = DTB; i <= rVds; i++ )
      {
        for ( segment_t *s=get_first_seg(); s != NULL; s=get_next_seg(s->startEA) )
          SetDefaultRegisterValue(s, i, 0);
      }
      break;

    case processor_t::oldfile:   // old file loaded
      idpflags = (ushort)helper.altval(-1);
      break;

    case processor_t::closebase:
    case processor_t::savebase:
      helper.altset(-1, idpflags);
      break;

    case processor_t::newprc:    // new processor type
      {
        ptype = ptypes[va_arg(va, int)];
        switch ( ptype )
        {
          case F2MC16L:
            cfgname = "f2mc16l.cfg";
            break;
          case F2MC16LX:
            cfgname = "f2mc16lx.cfg";
            break;
          default:
            error("interr: setprc");
            break;
        }
        device[0] = '\0';
        if ( get_first_seg() != NULL )
          choose_device(NULL, 0);
      }
      break;

    case processor_t::newasm:    // new assembler type
      break;

    case processor_t::newseg:    // new segment
      break;

  }
  va_end(va);
  return 1;
}
Ejemplo n.º 17
0
Archivo: reg.cpp Proyecto: nealey/vera
//------------------------------------------------------------------
static void setup_device(int respect_info)
{
  if ( choose_ioport_device(cfgname, device, sizeof(device), parse_area_line0) )
    if ( display_infotype_dialog(IORESP_ALL, &respect_info, cfgname) )
      set_device_name(device, respect_info);
}
Ejemplo n.º 18
0
//----------------------------------------------------------------------
static int idaapi notify(processor_t::idp_notify msgid, ...)
{
  va_list va;
  va_start(va, msgid);

  // A well behaving processor module should call invoke_callbacks()
  // in his notify() function. If this function returns 0, then
  // the processor module should process the notification itself
  // Otherwise the code should be returned to the caller:

  int code = invoke_callbacks(HT_IDP, msgid, va);
  if ( code )
    return code;

  switch ( msgid )
  {
    case processor_t::init:
      inf.mf = 0;
      helper.create("$ 78k0s");
    default:
      break;

    case processor_t::term:
      free_ioports(ports, numports);
      break;

    case processor_t::newfile:
      {
      //функция "выбирает" из указанного файла *.cfg все записи(процессора)
      //и отображает их в диалоговом окне, в котором пользователь может выбрать
      //нужный ему процессор. После выбора имя процессора заносится в переменную device
      //Поумолчанию в DLG выделен процессор который указан в переменной .default
      //которая распологается в начале файла *.cfg
      inf.s_genflags |= INFFL_LZERO;
      char cfgfile[QMAXFILE];
      get_cfg_filename(cfgfile, sizeof(cfgfile));
      if ( choose_ioport_device(cfgfile, device, sizeof(device), parse_area_line0) )
        //Устанавливает в ядре иды имя выбранного процессора
        //Вычитывает все "записи"(порты)  относящиеся к этому процессору
        //И подписывает в файле все байты вычитанные из *.cfg файла
        set_device_name(device, IORESP_ALL);
      } break;

    case processor_t::newprc:
      {
      char buf[MAXSTR];
      if ( helper.supval(-1, buf, sizeof(buf)) > 0 )
        set_device_name(buf, IORESP_PORT);
      } break;

    case processor_t::newseg:    // new segment
      {
      segment_t *s = va_arg(va, segment_t *);
      // Set default value of DS register for all segments
      set_default_dataseg(s->sel);
      } break;

  }
  va_end(va);
  return 1;
}
Ejemplo n.º 19
0
Archivo: reg.cpp Proyecto: nealey/vera
static int notify(processor_t::idp_notify msgid, ...)
{
    static int first_time = 1;
    va_list va;
    va_start(va, msgid);

// A well behaving processor module should call invoke_callbacks()
// in his notify() function. If this function returns 0, then
// the processor module should process the notification itself
// Otherwise the code should be returned to the caller:

    int code = invoke_callbacks(HT_IDP, msgid, va);
    if ( code ) return code;

    switch ( msgid )
    {
    case processor_t::init:
        helper.create("$ intel 8051");
        inf.mf = 1;       // Set a big endian mode of the IDA kernel
    default:
        break;

    case processor_t::term:
        free_ioports(ports, numports);
        break;

    case processor_t::newfile:
    {
        segment_t *sptr = get_first_seg();
        if ( sptr != NULL )
        {
            if ( sptr->startEA-get_segm_base(sptr) == 0 )
            {
                inf.beginEA = sptr->startEA;
                inf.startIP = 0;
                for ( int i=0; i < qnumber(entries); i++ )
                {
                    if ( entries[i].proc > ptype )
                        continue;
                    ea_t ea = inf.beginEA+entries[i].off;
                    if ( isEnabled(ea) && get_byte(ea) != 0xFF )
                    {
                        add_entry(ea, ea, entries[i].name, 1);
                        set_cmt(ea, entries[i].cmt, 1);
                    }
                }
            }
        }
        segment_t *scode = get_first_seg();
        set_segm_class(scode, "CODE");

        if ( ptype > prc_51 )
        {
            AdditionalSegment(0x10000-256-128, 256+128, "RAM");
            if ( scode != NULL )
            {
                ea_t align = (scode->endEA + 0xFFF) & ~0xFFF;
                if ( getseg(align-7) == scode )     // the code segment size is
                {   // multiple of 4K or near it
                    uchar b0 = get_byte(align-8);
                    // 251:
                    //  0  : 1-source, 0-binary mode
                    //  6,7: must be 1s
                    // 82930:
                    //  0  : 1-source, 0-binary mode
                    //  7  : must be 1s
//              uchar b1 = get_byte(align-7);
                    // 251
                    //  0: eprommap 0 - FE2000..FE4000 is mapped into 00E000..100000
                    //              1 - .............. is not mapped ...............
                    //  1: must be 1
                    //  3:
                    //  2: must be 1
                    //  4: intr 1 - upon interrupt PC,PSW are pushed into stack
                    //          0 - upon interrupt only PC is pushed into stack
                    //  5: must be 1
                    //  6: must be 1
                    //  7: must be 1
                    // 82930:
                    //  3: must be 1
                    //  5: must be 1
                    //  6: must be 1
                    //  7: must be 1
//                msg("b0=%x b1=%x\n", b0, b1);
//              if ( (b0 & 0x80) == 0x80 && (b1 & 0xEA) == 0xEA )
                    {   // the init bits are correct
                        char pname[sizeof(inf.procName)+1];
                        inf.get_proc_name(pname);
                        char ntype = (b0 & 1) ? 's' : 'b';
                        char *ptr = tail(pname)-1;
                        if ( ntype != *ptr
                                && askyn_c(1,
                                           "HIDECANCEL\n"
                                           "The input file seems to be for the %s mode of the processor. "
                                           "Do you want to change the current processor type?",
                                           ntype == 's' ? "source" : "binary") > 0 )
                        {
                            *ptr = ntype;
                            first_time = 1;
                            set_processor_type(pname, SETPROC_COMPAT);
                        }
                    }
                }
            }
        }

        // the default data segment will be INTMEM
        {
            segment_t *s = getseg(intmem);
            if ( s != NULL )
                set_default_dataseg(s->sel);
        }

        if ( choose_ioport_device(cfgname, device, sizeof(device), parse_area_line0) )
            set_device_name(device, IORESP_ALL);

        if ( get_segm_by_name("RAM") == NULL )
            AdditionalSegment(256, 0, "RAM");
        if ( get_segm_by_name("FSR") == NULL )
            AdditionalSegment(128, 128, "FSR");
        setup_data_segment_pointers();
    }
    break;

    case processor_t::oldfile:
        setup_data_segment_pointers();
        break;

    case processor_t::newseg:
        // make the default DS point to INTMEM
        // (8051 specific issue)
    {
        segment_t *newseg = va_arg(va, segment_t *);
        segment_t *intseg = getseg(intmem);
        if ( intseg != NULL )
            newseg->defsr[rVds-ph.regFirstSreg] = intseg->sel;
    }
    break;

    case processor_t::newprc:
    {
        processor_subtype_t prcnum = processor_subtype_t(va_arg(va, int));
        if ( !first_time && prcnum != ptype )
        {
            warning("Sorry, it is not possible to change" // (this is 8051 specific)
                    " the processor mode on the fly."
                    " Please reload the input file"
                    " if you want to change the processor.");
            return 0;
        }
        first_time = 0;
        ptype = prcnum;
    }
    break;

    case processor_t::newasm:    // new assembler type
    {
        char buf[MAXSTR];
        if ( helper.supval(-1, buf, sizeof(buf)) > 0 )
            set_device_name(buf, IORESP_NONE);
    }
    break;

    case processor_t::move_segm:// A segment is moved
        // Fix processor dependent address sensitive information
        // args: ea_t from - old segment address
        //       segment_t - moved segment
    {
        // ea_t from    = va_arg(va, ea_t);
        // segment_t *s = va_arg(va, segment_t *);

        // Add commands to adjust your internal variables here
        // Most of the time this callback will be empty
        //
        // If you keep information in a netnode's altval array, you can use
        //      node.altshift(from, s->startEA, s->endEA - s->startEA);
        //
        // If you have a variables pointing to somewhere in the disassembled program memory,
        // you can adjust it like this:
        //
        //      asize_t size = s->endEA - s->startEA;
        //      if ( var >= from && var < from+size )
        //        var += s->startEA - from;
    }
    break;

    case processor_t::is_sane_insn:
        // is the instruction sane for the current file type?
        // arg:  int no_crefs
        // 1: the instruction has no code refs to it.
        //    ida just tries to convert unexplored bytes
        //    to an instruction (but there is no other
        //    reason to convert them into an instruction)
        // 0: the instruction is created because
        //    of some coderef, user request or another
        //    weighty reason.
        // The instruction is in 'cmd'
        // returns: 1-ok, <=0-no, the instruction isn't
        // likely to appear in the program
    {
        int no_crefs = va_arg(va, int);
        return is_sane_insn(no_crefs);
    }
    }
    va_end(va);

    return(1);
}
Ejemplo n.º 20
0
//--------------------------------------------------------------------------
static void choose_device(TView *[],int)
{
  if ( choose_ioport_device(cfgname, device, sizeof(device), NULL) )
    load_symbols();
}
Ejemplo n.º 21
0
// The kernel event notifications
// Here you may take desired actions upon some kernel events
static int notify(processor_t::idp_notify msgid, ...)
{
    va_list va;
    va_start(va, msgid);

    // A well behavior processor module should call invoke_callbacks()
    // in his notify() function. If this function returns 0, then
    // the processor module should process the notification itself
    // Otherwise the code should be returned to the caller:

    int code = invoke_callbacks(HT_IDP, msgid, va);
    if ( code ) return code;

    switch ( msgid ) {

        case processor_t::init:
            // this processor is big endian
            inf.mf = 1;
        default:
            break;

        case processor_t::term:
            free_ioports(ports, numports);
            break;

        case processor_t::newfile:
            if ( choose_ioport_device(cfgname, device, sizeof(device), NULL) )
                set_device_name(device, IORESP_ALL);
            // default configuration
            if ( refresh_idpflags() == 0 ) {
                idpflags = 0;
                idpflags |= NETNODE_USE_INSN_SYNTHETIC;
                idpflags |= NETNODE_USE_REG_ALIASES;
            }

            // patch register names according to idpflags
            patch_regnames();
            break;

        case processor_t::newprc:
            ptype = processor_subtype_t(va_arg(va, int));
//            msg("ptype = %s\n", ptype == prc_m32r ? "m32r" : ptype == prc_m32rx ? "m32rx" : "???");
            break;

        case processor_t::oldfile:
            refresh_idpflags();
            {
              char buf[MAXSTR];
              if ( helper.supval(-1, buf, sizeof(buf)) > 0 )
                set_device_name(buf, IORESP_NONE);
            }
            // patch register names according to idpflags
            patch_regnames();
            break;

        case processor_t::savebase:
        case processor_t::closebase:
            // synchronize the database long variable with the current configuration settings
#ifdef DEBUG
            msg("Saving configuration: synthetic insn %s, aliases registers %s\n",
                use_synthetic_insn() ? "true " : "false",
                use_reg_aliases() ? "true" : "false"
            );
#endif
            helper.altset(-1, idpflags);
            helper.supset(-1, device);
            break;
    }

    va_end(va);

    return(1);
}