Beispiel #1
0
void disassembler::OP_sY(const x86_insn *insn, unsigned size)
{
  const char *rdi, *seg;

  if (insn->as_64) {
    rdi = general_64bit_regname[rDI_REG];
  }
  else {
    if (insn->as_32)
      rdi = general_32bit_regname[rDI_REG];
    else
      rdi = general_16bit_regname[rDI_REG];
  }

  print_datasize(size);

  if (insn->is_seg_override())
    seg = segment_name[insn->seg_override];
  else
    seg = segment_name[DS_REG];

  if (intel_mode)
    dis_sprintf("%s:[%s]", seg, rdi);
  else
    dis_sprintf("%s:(%s)", seg, rdi);
}
Beispiel #2
0
void disassembler::print_memory_access16(int datasize, 
                const char *seg, const char *index, uint16 disp)
{
  print_datasize(datasize);

  if (intel_mode)
  {
    if (index == NULL)
    {
      dis_sprintf("%s:0x%x", seg, (unsigned) disp);
    }
    else
    {
      if (disp != 0)
        dis_sprintf("%s:[%s+0x%x]", seg, index, (unsigned) disp);
      else
        dis_sprintf("%s:[%s]", seg, index);
    }
  }
  else
  {
    if (index == NULL)
    {
      dis_sprintf("%s:0x%x", seg, (unsigned) disp);
    }
    else
    {
      if (disp != 0)
        dis_sprintf("%s:0x%x(%s,1)", seg, (unsigned) disp, index);
      else
        dis_sprintf("%s:(%s,1)", seg, index);
    }
  }
}
Beispiel #3
0
void disassembler::OP_Y(const x86_insn *insn, unsigned size)
{
  const char *rdi;

  if (insn->as_64) {
    rdi = general_64bit_regname[rDI_REG];
  }
  else {
    if (insn->as_32)
      rdi = general_32bit_regname[rDI_REG];
    else
      rdi = general_16bit_regname[rDI_REG];
  }

  print_datasize(size);

  if (intel_mode)
    dis_sprintf("%s:[%s]", segment_name[ES_REG], rdi);
  else
    dis_sprintf("%s:(%s)", segment_name[ES_REG], rdi);
}
Beispiel #4
0
// direct memory access
void disassembler::OP_O(const x86_insn *insn, unsigned size)
{
  const char *seg;

  if (insn->is_seg_override())
    seg = segment_name[insn->seg_override];
  else
    seg = segment_name[DS_REG];

  print_datasize(size);

  if (insn->as_64) {
    Bit64u imm64 = fetch_qword();
    dis_sprintf("%s:0x%08x%08x", seg, GET32H(imm64), GET32L(imm64));
  }
  else if (insn->as_32) {
    Bit32u imm32 = fetch_dword();
    dis_sprintf("%s:0x%08x", seg, (unsigned) imm32);
  }
  else {
    Bit16u imm16 = fetch_word();
    dis_sprintf("%s:0x%04x", seg, (unsigned) imm16);
  }
}
Beispiel #5
0
void
handle_com_port_command(unsigned char *buf)
{
    unsigned char cmd = *buf++;
    int cmdarg;
    int cmdidx;
    int is_notify = 0;
    int notify;

    cmdidx = (int) cmd;

    if (cmd >= RAS_COM_START && cmd <= RAS_COM_END) {
	cmdidx -= RAS_COM_START;
    }

    print_command(cmdidx);

    switch (cmd) {
    case RAS_COM_SIGNATURE:
    case RAS_COM_FLOWCONTROL_SUSPEND:
    case RAS_COM_FLOWCONTROL_RESUME:
	break;
    case RAS_COM_SET_BAUDRATE:
	Comport.portconfig.speed = GET_VALUE_4(buf);
	print_speed(Comport.portconfig.speed);
	break;
    case RAS_COM_SET_DATASIZE:
	Comport.portconfig.datasize = GET_VALUE_1(buf);
	print_datasize(Comport.portconfig.datasize);
	break;
    case RAS_COM_SET_PARITY:
	Comport.portconfig.parity = GET_VALUE_1(buf);
	print_parity(Comport.portconfig.parity);
	break;

    case RAS_COM_SET_STOPSIZE:
	Comport.portconfig.stopsize = GET_VALUE_1(buf);
	print_stopsize(Comport.portconfig.stopsize);
	break;

    case RAS_COM_SET_CONTROL:
	cmdarg = GET_VALUE_1(buf);
	print_setcontrol(cmdarg);
	switch (cmdarg) {
	case COM_OFLOW_NONE:
	case COM_OFLOW_SOFT:
	case COM_OFLOW_HARD:
	    Comport.portconfig.flowc = cmdarg;
	    break;
	default:
	    break;
	}

	break;

    case RAS_COM_NOTIFY_LINESTATE:
	is_notify = 1;
	cmdarg = GET_VALUE_1(buf);
	print_linestate(cmdarg);
	Comport.portstate.linestate = cmdarg;
	if (cmdarg & LINE_BREAK_ERROR) {
	    notify = NT_BREAK;
	    SET_EVENT(EV_RN, EV_RNNTFY, &notify, sizeof(int));
	}
	if (cmdarg & LINE_PARITY_ERROR) {
	    notify = NT_PARITY;
	    SET_EVENT(EV_RN, EV_RNNTFY, &notify, sizeof(int));
	}
	break;

    case RAS_COM_SET_LINESTATE_MASK:
	cmdarg = GET_VALUE_1(buf);
	print_linestate(cmdarg);
	break;

    case RAS_COM_NOTIFY_MODEMSTATE:
	is_notify = 1;
	cmdarg = GET_VALUE_1(buf);
	if ((cmdarg ^ Comport.portstate.modemstate) & MODEM_DCD) {
	    if (Comport.portstate.modemstate & MODEM_DCD) {
		notify = NT_DCDOFF;
		SET_EVENT(EV_RN, EV_RNNTFY, &notify, sizeof(int));
	    }
	    else {
		notify = NT_DCDON;
		SET_EVENT(EV_RN, EV_RNNTFY, &notify, sizeof(int));
	    }
	}
	Comport.portstate.modemstate = cmdarg;
	print_modemstate(cmdarg);
	break;

    case RAS_COM_SET_MODEMSTATE_MASK:
	cmdarg = GET_VALUE_1(buf);
	print_modemstate(cmdarg);
	break;
    case RAS_COM_PURGE_DATA:
	cmdarg = GET_VALUE_1(buf);
	print_purge(cmdarg);
	break;
    default:
	sysmessage(MSG_NOTICE, "Unnimplemented command: %d\n", cmd);
	break;
    }

    if (!is_notify) {
	if (IS_CMD_ACTIVE(cmdidx)) {
	    CLR_CMD_ACTIVE(cmdidx);	/* Synchronous operation */
	}
	else {
	    SET_EVENT(EV_RN, EV_RNCMDOK, 0, 0);
	}
    }
    print_all();
}
Beispiel #6
0
void disassembler::print_memory_access(int datasize, 
                const char *seg, const char *base, const char *index, int scale, uint32 disp)
{
  print_datasize(datasize);
  
  if (intel_mode)
  {
    if (base == NULL)
    {
      if (index == NULL)
      {
        dis_sprintf("%s:0x%x", seg, (unsigned) disp);
      }
      else
      {
        if (scale != 0)
        {
          if (disp != 0)
            dis_sprintf("%s:[%s*%d+0x%x]", seg, index, 1<<scale, (unsigned) disp);
          else
            dis_sprintf("%s:[%s*%d]", seg, index, 1<<scale);
        }
        else
        {
          if (disp != 0)
            dis_sprintf("%s:[%s+0x%x]", seg, index, (unsigned) disp);
          else
            dis_sprintf("%s:[%s]", seg, index);
        }
      }
    }
    else
    {
      if (index == NULL)
      {
        if (disp != 0)
          dis_sprintf("%s:[%s+0x%x]", seg, base, (unsigned) disp);
        else
          dis_sprintf("%s:[%s]", seg, base);
      }
      else
      {
        if (scale != 0)
        {
          if (disp != 0)
            dis_sprintf("%s:[%s+%s*%d+0x%x]", seg, base, index, 1<<scale, (unsigned) disp);
          else
            dis_sprintf("%s:[%s+%s*%d]", seg, base, index, 1<<scale);
        }
        else
        {
          if (disp != 0)
            dis_sprintf("%s:[%s+%s+0x%x]", seg, base, index, (unsigned) disp);
          else
            dis_sprintf("%s:[%s+%s]", seg, base, index);
        }
      }
    }
  }
  else
  {
    if (base == NULL)
    {
      if (index == NULL)
      {
        dis_sprintf("%s:0x%x", seg, (unsigned) disp);
      }
      else
      {
        if (disp != 0)
          dis_sprintf("%s:0x%x(,%s,%d)", seg, (unsigned) disp, index, 1<<scale);
        else
          dis_sprintf("%s:(,%s,%d)", seg, index, 1<<scale);
      }
    }
    else
    {
      if (index == NULL)
      {
        if (disp != 0)
          dis_sprintf("%s:0x%x(%s)", seg, (unsigned) disp, base);
        else
          dis_sprintf("%s:(%s)", seg, base);
      }
      else
      {
        if (disp != 0)
          dis_sprintf("%s:0x%x(%s,%s,%d)", seg, (unsigned) disp, base, index, 1<<scale);
        else
          dis_sprintf("%s:(%s,%s,%d)", seg, base, index, 1<<scale);
      }
    }
  }
}