Ejemplo n.º 1
0
        internal Instruction(ref Udis86.ud u, bool keepBinary)
        {
            this.Offset   = u.insn_offset;
            this.PC       = u.pc;
            this.Mnemonic = u.mnemonic;

            // Add operands
            List <Operand> operands = new List <Operand>(4);

            if (u.operand[0].type != Udis86.ud_type.UD_NONE)
            {
                operands.Add(new Operand(u.operand[0]));
                if (u.operand[1].type != Udis86.ud_type.UD_NONE)
                {
                    operands.Add(new Operand(u.operand[1]));
                    if (u.operand[2].type != Udis86.ud_type.UD_NONE)
                    {
                        operands.Add(new Operand(u.operand[2]));
                        if (u.operand[3].type != Udis86.ud_type.UD_NONE)
                        {
                            operands.Add(new Operand(u.operand[3]));
                        }
                    }
                }
            }
            this.Operands = operands.ToArray();

            this.Length = u.inp_ctr;

            // Copy the instruction bytes
            if (keepBinary)
            {
                this.Bytes = u.inp_buf.CopyToBytes(u.inp_buf_index - this.Length, this.Length);
            }

            if (u.error > 0)
            {
                this.Error        = true;
                this.ErrorMessage = u.errorMessage;
            }
            else if (this.Mnemonic == Udis86.ud_mnemonic_code.UD_Iinvalid)
            {
                this.Error        = true;
                this.ErrorMessage = "Invalid instruction";
            }

            this.itab_entry     = u.itab_entry;
            this.dis_mode       = (ArchitectureMode)u.dis_mode;
            this.pfx_rex        = u.pfx_rex;
            this.pfx_seg        = u.pfx_seg;
            this.pfx_opr        = u.pfx_opr;
            this.pfx_adr        = u.pfx_adr;
            this.pfx_lock       = u.pfx_lock;
            this.pfx_str        = u.pfx_str;
            this.pfx_rep        = u.pfx_rep;
            this.pfx_repe       = u.pfx_repe;
            this.pfx_repne      = u.pfx_repne;
            this.opr_mode       = u.opr_mode;
            this.adr_mode       = u.adr_mode;
            this.br_far         = u.br_far;
            this.br_near        = u.br_near;
            this.have_modrm     = u.have_modrm;
            this.modrm          = u.modrm;
            this.primary_opcode = u.primary_opcode;
        }
Ejemplo n.º 2
0
        internal Instruction(ref Udis86.ud u, bool keepBinary)
        {
            this.Offset = u.insn_offset;
            this.PC = u.pc;
            this.Mnemonic = u.mnemonic;

            // Add operands
            List<Operand> operands = new List<Operand>(4);
            if (u.operand[0].type != Udis86.ud_type.UD_NONE)
            {
                operands.Add(new Operand(u.operand[0]));
                if (u.operand[1].type != Udis86.ud_type.UD_NONE)
                {
                    operands.Add(new Operand(u.operand[1]));
                    if (u.operand[2].type != Udis86.ud_type.UD_NONE)
                    {
                        operands.Add(new Operand(u.operand[2]));
                        if (u.operand[3].type != Udis86.ud_type.UD_NONE) operands.Add(new Operand(u.operand[3]));
                    }
                }
            }
            this.Operands = operands.ToArray();

            this.Length = u.inp_ctr;

            // Copy the instruction bytes
            if (keepBinary)
            {
				this.Bytes = AssemblyCode.CopyToBytes(u.inp_buf, u.inp_buf_index - this.Length, this.Length);
            }

            if (u.error > 0)
            {
                this.Error = true;
                this.ErrorMessage = u.errorMessage;
            }
            else if (this.Mnemonic == Udis86.ud_mnemonic_code.UD_Iinvalid)
            {
                this.Error = true;
                this.ErrorMessage = "Invalid instruction";
            }

            this.itab_entry = u.itab_entry;
            this.dis_mode = (ArchitectureMode) u.dis_mode;
            this.pfx_rex        = u.pfx_rex;
            this.pfx_seg        = u.pfx_seg;
            this.pfx_opr        = u.pfx_opr;
            this.pfx_adr        = u.pfx_adr;
            this.pfx_lock       = u.pfx_lock;
            this.pfx_str        = u.pfx_str;
            this.pfx_rep        = u.pfx_rep;
            this.pfx_repe       = u.pfx_repe;
            this.pfx_repne      = u.pfx_repne;
            this.opr_mode       = u.opr_mode;
            this.adr_mode       = u.adr_mode;
            this.br_far         = u.br_far;
            this.br_near        = u.br_near;
            this.have_modrm     = u.have_modrm;
            this.modrm          = u.modrm;
            this.primary_opcode = u.primary_opcode;
        }