コード例 #1
0
ファイル: out.cpp プロジェクト: trietptm/usefulres
static int out_equ(ea_t ea)
{
  char buf[MAXSTR];
  char *const end = buf + sizeof(buf);
  segment_t *s = getseg(ea);
  if ( s != NULL && s->type == SEG_IMEM && ash.a_equ != NULL)
  {
    char nbuf[MAXSTR];
    char *name = get_name(BADADDR, ea, nbuf, sizeof(nbuf));
    if ( name != NULL
      && ((ash.uflag & UAS_PBYTNODEF) == 0 || !IsPredefined(name)) )
    {
      get_colored_name(BADADDR, ea, buf, sizeof(buf));
      uchar off = uchar(ea - get_segm_base(s));
      do_out_equ(buf, ash.a_equ, off);
      if ( (ash.uflag & UAS_AUBIT) == 0 && (off & 0xF8) == off )
      {
        char *ptr = tag_on(tail(buf), end, COLOR_SYMBOL);
        APPCHAR(ptr, end, ash.uflag & UAS_NOBIT ? '_' : '.');
        APPCHAR(ptr, end, '0');
        tag_off(ptr, end, COLOR_SYMBOL);
        for ( int i=0; i < 8; i++ )
        {
          const ioport_bit_t *b = find_bit(off, i);
          char *p2 = ptr;
          if ( b == NULL || b->name == NULL )
            ptr[-1] = '0' + i;
          else
            p2 = tag_addstr(ptr-1, end, COLOR_HIDNAME, b->name);
          tag_off(p2, end, COLOR_SYMBOL);
          do_out_equ(buf, ash.a_equ, off+i);
        }
        MakeNull();
      }
    }
    else
    {
      gl_name = 0;
      MakeLine("");
    }
    return 1;
  }
  if ( ash.uflag & UAS_NODS )
  {
    if ( !isLoaded(ea) && s->type == SEG_CODE )
    {
      adiff_t org = ea - get_segm_base(s) + get_item_size(ea);
      btoa(buf, sizeof(buf), org);
      printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
      return 1;
    }
  }
  return 0;
}
コード例 #2
0
ファイル: out.cpp プロジェクト: trietptm/usefulres
static void do_out_equ(const char *name, const char *equ, uchar off)
{
  char buf[MAXSTR];
  char *ptr = buf;
  char *const end = buf + sizeof(buf);
  gl_name = 0;
  if (ash.uflag & UAS_PSAM)
  {
    ptr = tag_addstr(ptr, end, COLOR_KEYWORD, equ);
    APPCHAR(ptr, end, ' ');
    APPEND(ptr, end, name);
    ptr = tag_addchr(ptr, end, COLOR_SYMBOL, ',');
  }
  else
  {
    APPEND(ptr, end, name);
    if(ash.uflag & UAS_EQCLN)
      ptr = tag_addchr(ptr, end, COLOR_SYMBOL, ':');
    APPCHAR(ptr, end, ' ');
    ptr = tag_addstr(ptr, end, COLOR_KEYWORD, equ);
    APPCHAR(ptr, end, ' ');
  }
  ptr = tag_on(ptr, end, COLOR_NUMBER);
  ptr += btoa32(ptr, end-ptr, off);
  tag_off(ptr, end, COLOR_NUMBER);
  MakeLine(buf, 0);
}
コード例 #3
0
//--------------------------------------------------------------------------
static void out_equ(const char *name, const char *equ, uchar off)
{
  char buf[MAXSTR];
  char *const end = buf + sizeof(buf);

  char *p = tag_addstr(buf, end, COLOR_DNAME, name);
  APPCHAR(p, end, ' ');
  p = tag_addstr(p, end, COLOR_KEYWORD, equ);
  APPCHAR(p, end, ' ');
  p = tag_on(p, end, COLOR_NUMBER);
  p += btoa(p, end-p, off);
  tag_off(p, end, COLOR_NUMBER);
  MakeLine(buf, 0);
}
コード例 #4
0
ファイル: out.cpp プロジェクト: awesome-security/vera
//--------------------------------------------------------------------------
void assume(ea_t ea)
{
  segreg_t *Darea  = getSRarea(ea);
  segment_t *Sarea = getseg(ea);
  char buf[MAXSTR];
  char *const end = buf + sizeof(buf);

  if ( Sarea == NULL || Darea == NULL || !inf.s_assume ) return;

  bool show = (ea == Sarea->startEA);
  if ( show || Darea->startEA == ea )
  {
    bool used = false;
    segreg_t our = *Darea;
    segreg_t *prev = show ? NULL : getSRarea(ea-1);
    char *ptr = NULL;
    for ( int i=ph.regFirstSreg; i <= ph.regLastSreg; i++ )
    {
      if ( i == ph.regCodeSreg ) continue;
      if ( prev == NULL || prev->reg(i) != our.reg(i) )
      {
        if ( !used )
        {
          ptr = tag_on(buf, end, COLOR_AUTOCMT);
          APPEND(ptr, end, ash.cmnt);
          APPEND(ptr, end, " assume ");
        }
        else
        {
          APPCHAR(ptr, end, ',');
          APPCHAR(ptr, end, ' ');
        }
        used = true;
        APPEND (ptr, end, ph.regNames[i]);
        APPCHAR(ptr, end, ':');
        if ( our.reg(i) == BADSEL )
          APPEND(ptr, end, "nothing");
        else
          ptr += btoa(ptr, end-ptr, our.reg(i), 16);
      }
    }
    if ( used )
    {
      tag_off(ptr, end, COLOR_AUTOCMT);
      MakeLine(buf, inf.indent);
    }
  }
}
コード例 #5
0
ファイル: out.cpp プロジェクト: nealey/vera
//--------------------------------------------------------------------------
void segstart(ea_t ea)
{
  char buf[MAXSTR];
  char *const end = buf + sizeof(buf);
  segment_t *Sarea = getseg(ea);
  if ( is_spec_segm(Sarea->type) ) return;

  const char *align;
  switch ( Sarea->align )
  {
    case saAbs:        align = "at: ";   break;
    case saRelByte:    align = "byte";  break;
    case saRelWord:    align = "word";  break;
    case saRelPara:    align = "para";  break;
    case saRelPage:    align = "page";  break;
    case saRel4K:      align = "4k";    break;
    case saRel64Bytes: align = "64";    break;
    default:           align = NULL;    break;
  }
  if ( align == NULL )
  {
    gen_cmt_line("Segment alignment '%s' can not be represented in assembly",
                 get_segment_alignment(Sarea->align));
    align = "";
  }

  char sname[MAXNAMELEN];
  char sclas[MAXNAMELEN];
  get_true_segm_name(Sarea, sname, sizeof(sname));
  get_segm_class(Sarea, sclas, sizeof(sclas));

  char *ptr = buf + qsnprintf(buf, sizeof(buf),
                              SCOLOR_ON SCOLOR_ASMDIR "%-*s segment %s ",
                              inf.indent-1,
                              sname,
                              align);
  if ( Sarea->align == saAbs )
  {
    ea_t absbase = get_segm_base(Sarea);
    ptr += btoa(ptr, end-ptr, absbase);
    APPCHAR(ptr, end, ' ');
  }
  const char *comb;
  switch ( Sarea->comb )
  {
    case scPub:
    case scPub2:
    case scPub3:    comb = "";        break;
    case scCommon:  comb = "common";  break;
    default:        comb = NULL;      break;
  }
  if ( comb == NULL )
  {
    gen_cmt_line("Segment combination '%s' can not be represented in assembly",
                 get_segment_combination(Sarea->comb));
    comb = "";
  }
  ptr += qsnprintf(ptr, end-ptr, "%s '%s'", comb, sclas);
  tag_off(ptr, end, COLOR_ASMDIR);
  MakeLine(buf, 0);
}