本文整理汇总了C#中INSTRUCTION类的典型用法代码示例。如果您正苦于以下问题:C# INSTRUCTION类的具体用法?C# INSTRUCTION怎么用?C# INSTRUCTION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
INSTRUCTION类属于命名空间,在下文中一共展示了INSTRUCTION类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: check_ext_sf_prefixes
//Checks opcode-extension prefixes (repz, repnz, opsize) are superfluous.
static void check_ext_sf_prefixes(byte[] prefixes, ref INSTRUCTION instr, ref DISASM_INOUT_PARAMS param)
{
if (prefixes[PREF_OPSIZE_INDEX] != 0xFF)
add_sf_prefix(prefixes, PREF_OPSIZE_INDEX, ref instr, ref param);
if (prefixes[PREF_REP_INDEX] != 0xFF)
add_sf_prefix(prefixes, PREF_OPSIZE_INDEX, ref instr, ref param);
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:8,代码来源:mediana.cs
示例2: post_proc_multinop
static UInt32 post_proc_multinop(ulong origin_offset, ulong offset, ref INSTRUCTION instr, INTERNAL_DATA idata, DISMODE mode)
{
instr.ops[0].flags &= (byte)~OPERAND_FLAG_PRESENT;
instr.ops[1].flags &= (byte)~OPERAND_FLAG_PRESENT;
instr.ops[2].flags &= (byte)~OPERAND_FLAG_PRESENT;
return 0;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:7,代码来源:mediana.cs
示例3: tq_1
static UInt32 tq_1(ulong origin_offset, ulong offset, ref INSTRUCTION instr, int op_index, OPERAND_SIZE opsize, INTERNAL_DATA idata, DISMODE mode)
{
instr.ops[op_index].flags |= (byte)OP_TYPE.OPERAND_TYPE_IMM;
instr.ops[op_index].size = (ushort)OP_SIZE.OPERAND_SIZE_8;
instr.ops[op_index].value.imm.imm8 = 0x1;
return 0x0;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:7,代码来源:mediana.cs
示例4: parse_prefixes
//Main function for parsing prefixes. Reads input stream until meets non-prefix byte
// or maximum instruction length is exceeded. The function checks if a prefix of the same group
// was already met and if so, replaces old prefix with a new one.
// Old prefix is added to superfluous prefixes array.
// The function also checks if a prefix is opcode-extension.
static UInt32 parse_prefixes(ulong offset, ref INSTRUCTION instr, INTERNAL_DATA idata, byte ext_table_index, byte ext_pref_index, ref DISASM_INOUT_PARAMS param)
{
byte pref_code;
byte rex_found;
byte pref_id;
byte pref_index;
UInt32 res;
UInt32 tmp;
OPCODE_DESCRIPTOR ptr;
res = 0;
rex_found = 0;
while(true)
{
//pref_code = *offset;
pref_code = assembly.ReadBytes(offset, 1)[0];
if (res > Dasmer.MAX_INSTRUCTION_LEN)
{
idata.severe_err = ERRS.ERR_TOO_LONG;//error: instruction too long.
break;
}
ptr = tables[IDX_1BYTE].opcodes[pref_code];
if ( !( ((ptr.groups & GRP_PREFIX)!=0) ||
(param.mode == DISMODE.DISASSEMBLE_MODE_64 && (pref_code >= 0x40) && (pref_code <= 0x4F) && (rex_found == 0))))
{
break;
}
else
{
if (rex_found!=0)
{
idata.severe_err = ERRS.ERR_REX_NOOPCD;//error: an opcode should follow after rex.
break;
}
if ((rex_found != 0) && (param.mode == DISMODE.DISASSEMBLE_MODE_64))
{
if ( (pref_code >= 0x40) && (pref_code <= 0x4F) )
{
idata.prefixes[PREF_REX_INDEX] = PREF_REX_ID;
instr.rex = pref_code;
rex_found = 1;
res++;
offset++;
continue;
}
}
tmp = tq_handlers[ptr.ops[0].type](0, 0, ref instr, 0, new OPERAND_SIZE(), new INTERNAL_DATA(), param.mode);
pref_index = (byte)(tmp >> 8);
pref_id = (byte)tmp;// &0xFF;
if (idata.prefixes[pref_index] != 0xFF)
{
add_sf_prefix(idata.prefixes, pref_index, ref instr, ref param);
}
idata.prefixes[pref_index] = pref_id;
//Used later for prefix table switch.
if (ptr.id == ID_66 || ptr.id == ID_REPZ || ptr.id == ID_REPNZ)
{
ext_table_index =(byte)(ptr.props);
ext_pref_index = pref_index;
}
res++;
offset++;
}
}
return res;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:81,代码来源:mediana.cs
示例5: post_proc_arpl_movsxd
/*************************
* Postprocessing routines.
**************************
*/
static UInt32 post_proc_arpl_movsxd(ulong origin_offset, ulong offset, ref INSTRUCTION instr, INTERNAL_DATA idata, DISMODE mode)
{
UInt32 res;
res = 0;
if (mode == DISMODE.DISASSEMBLE_MODE_64)
{
OPERAND_SIZE opsize = new OPERAND_SIZE();
instr.id = ID_MOVSXD;
instr.groups = GRP_GEN | GRP_CONVER;
instr.tested_flags = 0;
instr.modified_flags = 0;
instr.set_flags = 0;
instr.cleared_flags = 0;
instr.flags &= (ushort)(INSTR_FLAG_MODRM | INSTR_FLAG_SIB);
instr.mnemonic = "movsxd";
byte[] bt = assembly.ReadBytes((ulong)instr.opcode_offset + 1, 4);
res = (UInt32)(
bt[0] +
bt[1]*256 +
bt[2]*256*256 +
bt[3]*256*256*256);
offset += res;
if ((instr.flags & INSTR_FLAG_MODRM)!=0)
{
res++;
offset++;
}
if ((instr.flags & INSTR_FLAG_SIB)!=0)
{
res++;
offset++;
}
instr.ops[0].value.imm.imm64 = 0;
instr.ops[1].value.imm.imm64 = 0;
instr.ops[0].flags = OPERAND_FLAG_PRESENT;
instr.ops[1].flags = OPERAND_FLAG_PRESENT;
sq_dqp(ref opsize, ref instr, idata, mode);
res += tq_G(origin_offset, offset, ref instr, 0, opsize, idata, mode);
sq_d(ref opsize, ref instr, idata, mode);
res += tq_E(origin_offset, offset, ref instr, 1, opsize, idata, mode);
}
return res;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:52,代码来源:mediana.cs
示例6: parse_mnemonic
//Parses instruction's mnemonic. If mnemonic is simple, it is just copied to
// struct INSTRUCTION. If mnemonic contains has multi mnemonic indicator (MM_INDICATOR)
// at first character then it depends on implicit operand's size. In this case the function
// calls get_instruction_opsize and builds choses mnemonic basing on result.
static void parse_mnemonic(OPCODE_DESCRIPTOR opcode, INSTRUCTION instr, INTERNAL_DATA idata, DISMODE mode)
{
if ((opcode.mnemonic.value.Length>0) && (opcode.mnemonic.value[0] != MM_INDICATOR))
{
instr.mnemonic = opcode.mnemonic.value;
}
else
{
get_instruction_opsize(opcode.mnemonic, instr, idata, mode);
instr.mnemonic = opcode.mnemonic.values[bsr(instr.opsize) - 1];
}
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:16,代码来源:mediana.cs
示例7: parse_opcode
//Main function for parsing opcode and prefixes. First of all it parses all prefixes and then
// looks up for struct OPCODE_DESCRIPTOR. The following algorithm is used to handle instructions that
// use prefixes as opcode extension:
//
// * Have we prefix that may be opcode extension?
// No: Lookup starts from 1byte table.
// * Is instruction found?
// No: Error.
// Yes: Success.
// Yes: Lookup starts from 'ext_table_index' table.
// * Is instruction found?
// No: Lookup starts from 1byte table.
// * Is instruction found?
// No: Error.
// Yes: Success.
// Yes: Success.
static UInt32 parse_opcode(ulong offset, ref OPCODE_DESCRIPTOR opcode_descr, ref INSTRUCTION instr, INTERNAL_DATA idata, ref DISASM_INOUT_PARAMS param)
{
byte ext_table_index = 0xFF;
byte ext_prefix_index = 0;
UInt32 res;
UInt32 tmp;
res = parse_prefixes(offset, ref instr, idata, ext_table_index, ext_prefix_index, ref param);
if (idata.severe_err==0)
{
instr.opcode_offset = (byte)res;
offset += res;
if ((ext_table_index != 0xFF) && (offset == 0xF))
{
tmp = lookup_opcode(offset, ext_table_index, ref opcode_descr, idata);
if ((idata.severe_err==0) && (opcode_descr.id != ID_NULL))
{
idata.prefixes[ext_prefix_index] = 0xFF;
check_ext_sf_prefixes(idata.prefixes, ref instr, ref param);
res += tmp;
}
else
{
idata.severe_err = 0;
res += lookup_opcode(offset, IDX_1BYTE, ref opcode_descr, idata);
}
}
else
{
res += lookup_opcode(offset, IDX_1BYTE, ref opcode_descr, idata);
}
if ((idata.severe_err==0) && (opcode_descr.id == ID_NULL))
{
idata.severe_err = ERRS.ERR_BADCODE;//error: invalid opcode.
}
}
return res;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:56,代码来源:mediana.cs
示例8: create_reg_operand
//Creates OPERAND_TYPE_REG operand of given type.
static void create_reg_operand(ref INSTRUCTION instr, int op_index, REG_TYPE type, byte code, OP_SIZE size)
{
instr.ops[op_index].flags |= (byte)OP_TYPE.OPERAND_TYPE_REG;
instr.ops[op_index].value.reg.type = type;
instr.ops[op_index].value.reg.code = code;
instr.ops[op_index].size = (ushort)size;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:8,代码来源:mediana.cs
示例9: create_xmmreg_operand
static void create_xmmreg_operand(ref INSTRUCTION instr, int op_index, byte code, OP_SIZE size, byte rex, ref INTERNAL_DATA idata, DISMODE mode)
{
if ((mode == DISMODE.DISASSEMBLE_MODE_64) && (idata.prefixes[PREF_REX_INDEX] != 0xFF))
{
if ((instr.rex & rex)!=0)
{
code |= REG_CODE_64;
idata.is_rex_used = 1;
}
}
create_reg_operand(ref instr, op_index, REG_TYPE.REG_TYPE_XMM, code, size);
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:12,代码来源:mediana.cs
示例10: copy_instr_flags
//Copies instruction's flags from struct OPCODE_DESCRIPTOR to struct INSTRUCTION.
static void copy_instr_flags(ref INSTRUCTION instr, ref OPCODE_DESCRIPTOR opcode)
{
if ((opcode.props & PROP_IOPL)!=0)
instr.flags |= INSTR_FLAG_IOPL;
if ((opcode.props & PROP_RING0)!=0)
instr.flags |= INSTR_FLAG_RING0;
if ((opcode.props & PROP_SERIAL)!=0)
instr.flags |= INSTR_FLAG_SERIAL;
if ((opcode.props & PROP_UNDOC) != 0)
instr.flags |= INSTR_FLAG_UNDOC;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:12,代码来源:mediana.cs
示例11: create_genreg_operand
static void create_genreg_operand(ref INSTRUCTION instr, int op_index, byte code, OP_SIZE size, byte rex, ref INTERNAL_DATA idata, DISMODE mode)
{
if (mode == DISMODE.DISASSEMBLE_MODE_64 && idata.prefixes[PREF_REX_INDEX] != 0xFF)
{
if (code > REG_CODE_BX && size == OP_SIZE.OPERAND_SIZE_8)
{
code |= REG_CODE_64;
code += 0x4;
idata.is_rex_used = 1;
}
if ((instr.rex & rex)!=0)
{
code |= REG_CODE_64;
idata.is_rex_used = 1;
}
}
create_reg_operand(ref instr, op_index, REG_TYPE.REG_TYPE_GEN, code, size);
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:18,代码来源:mediana.cs
示例12: copy_eflags
static void copy_eflags(ref INSTRUCTION instr, ref OPCODE_DESCRIPTOR opcode)
{
instr.tested_flags = opcode.tested_flags;
instr.modified_flags = opcode.modified_flags;
instr.set_flags = opcode.set_flags;
instr.cleared_flags = opcode.cleared_flags;
instr.undefined_flags = opcode.undefined_flags;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:8,代码来源:mediana.cs
示例13: convert_prefixes
//Converts prefixes from internal to external representation.
static void convert_prefixes(INSTRUCTION instr, byte[] prefixes)
{
for (int i = 0; i < PREFIX_COUNT; i++)
{
if (prefixes[i] != 0xFF)
instr.prefixes |= pref_bits[prefixes[i]];
}
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:9,代码来源:mediana.cs
示例14: check_seg_sf_prefixes
//Checks if segment override prefix is superfluous.
static void check_seg_sf_prefixes(INSTRUCTION instr, byte[] prefixes, DISASM_INOUT_PARAMS param)
{
uint i;
bool mem_op_found = false;
if (prefixes[PREF_SEG_INDEX] != 0xFF)
{
for (i = 0; i < 3; i++)
{
if ((instr.ops[i].flags & (byte)OP_TYPE.OPERAND_TYPE_MEM)!=0)
{
if (param.mode == DISMODE.DISASSEMBLE_MODE_64)
{
if ( !((prefixes[PREF_SEG_INDEX] == PREF_FS_ID) || (prefixes[PREF_SEG_INDEX] == PREF_GS_ID)) )
{
add_sf_prefix(prefixes, PREF_SEG_INDEX, ref instr, ref param);
}
}
else
{
if ( (instr.ops[i].value.addr.mod & ADDR_MOD_BASE)==0 )
{
if (instr.ops[i].value.addr.seg == SREG_CODE_DS)
add_sf_prefix(prefixes, PREF_SEG_INDEX, ref instr, ref param);
}
else
{
if ((instr.ops[i].value.addr.bas == REG_CODE_BP) || (instr.ops[i].value.addr.bas == REG_CODE_SP))
{
if (instr.ops[i].value.addr.seg == SREG_CODE_SS)
add_sf_prefix(prefixes, PREF_SEG_INDEX, ref instr, ref param);
}
else
{
if (instr.ops[i].value.addr.seg == SREG_CODE_DS)
add_sf_prefix(prefixes, PREF_SEG_INDEX, ref instr, ref param);
}
}
}
mem_op_found = true;
}
}
if (!mem_op_found)
add_sf_prefix(prefixes, PREF_SEG_INDEX, ref instr, ref param);
}
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:49,代码来源:mediana.cs
示例15: parse_mem_operand_16
//Parses 16bit memory address operand.
static UInt32 parse_mem_operand_16(ulong origin_offset, ulong offset, ref INSTRUCTION instr, int op_index, DISMODE mode)
{
byte len;
int index;
instr.ops[op_index].value.addr.mod = (byte)(instr.modrm >> 0x6);
len = get_disp(origin_offset, offset, ref instr, op_index, mode);
index = (instr.modrm >> 0x3 & 0x18) | (instr.modrm & 0x7);
instr.ops[op_index].value.addr.seg = addrs_16bit[index].seg;
instr.ops[op_index].value.addr.mod = addrs_16bit[index].mod;
instr.ops[op_index].value.addr.bas = addrs_16bit[index].bas;
instr.ops[op_index].value.addr.index = addrs_16bit[index].index;
instr.ops[op_index].value.addr.scale = addrs_16bit[index].scale;
return len;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:17,代码来源:mediana.cs
示例16: get_address_size
//Returns address size. Address size is common for all operands.
static void get_address_size(ref INSTRUCTION instr, byte[] prefixes, DISMODE mode)
{
if (mode == DISMODE.DISASSEMBLE_MODE_64)
{
if (prefixes[PREF_ADDRSIZE_INDEX] != 0xFF)
instr.addrsize = ADDR_SIZE_32;
else
instr.addrsize = ADDR_SIZE_64;
}
else
{
if (prefixes[PREF_ADDRSIZE_INDEX] != 0xFF)
mode ^= (DISMODE.DISASSEMBLE_MODE_16 | DISMODE.DISASSEMBLE_MODE_32);
if (mode == DISMODE.DISASSEMBLE_MODE_16)
instr.addrsize = ADDR_SIZE_16;
else
instr.addrsize = ADDR_SIZE_32;
}
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:21,代码来源:mediana.cs
示例17: parse_mem_operand_32_64
//Parses 32/64bit memory address operand.
static UInt32 parse_mem_operand_32_64(ulong origin_offset, ulong offset, ref INSTRUCTION instr, int op_index, INTERNAL_DATA idata, DISMODE mode)
{
UInt32 len = 0;
if ((instr.flags & INSTR_FLAG_SIB)!=0)
{
instr.ops[op_index].value.addr.mod = (byte)(instr.modrm >> 0x6);
instr.ops[op_index].value.addr.bas = (byte)(instr.sib & 0x7);
instr.ops[op_index].value.addr.index = (byte)((instr.sib >> 3) & 0x7);
instr.ops[op_index].value.addr.scale = (byte)(1 << (instr.sib >> 0x6));
if (mode == DISMODE.DISASSEMBLE_MODE_64 && idata.prefixes[PREF_REX_INDEX] != 0xFF)
{
if ((instr.rex & PREFIX_REX_B)!=0)
{
instr.ops[op_index].value.addr.bas |= REG_CODE_64;
idata.is_rex_used = 1;
}
if ((instr.rex & PREFIX_REX_X)!=0)
{
instr.ops[op_index].value.addr.index |= REG_CODE_64;
idata.is_rex_used = 1;
}
}
len = get_disp(origin_offset, offset, ref instr, op_index, mode);
get_mod_type_sib(ref instr, op_index);
}
else
{
instr.ops[op_index].value.addr.mod = (byte)(instr.modrm >> 0x6);
instr.ops[op_index].value.addr.bas = (byte)(instr.modrm & 0x7);
if (mode == DISMODE.DISASSEMBLE_MODE_64)
{
if ((idata.prefixes[PREF_REX_INDEX] != 0xFF) && ((instr.rex & PREFIX_REX_B)!=0))
{
instr.ops[op_index].value.addr.bas |= REG_CODE_64;
idata.is_rex_used = 1;
}
if ( (instr.ops[op_index].value.addr.mod == 0x0) &&
((instr.ops[op_index].value.addr.bas == REG_CODE_BP) ||
(instr.ops[op_index].value.addr.bas == REG_CODE_R13)) )
{
instr.ops[op_index].value.addr.bas = REG_CODE_IP;
}
}
len = get_disp(origin_offset, offset, ref instr, op_index, mode);
get_mod_type_modrm(ref instr, op_index);
}
get_seg(ref instr, op_index, idata.prefixes, mode);
return len;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:55,代码来源:mediana.cs
示例18: get_disp
//Calculates displacement's size and copies it to struct DISPLACEMENT.
static byte get_disp(ulong origin_offset, ulong offset, ref INSTRUCTION instr, int op_index, DISMODE mode)
{
byte len = 0;
switch(instr.ops[op_index].value.addr.mod)
{
case 0x0:
if (instr.ops[op_index].value.addr.bas == REG_CODE_BP)
len = instr.addrsize;
else
len = 0x0;
break;
case 0x1:
len = 0x1;
break;
case 0x2:
len = instr.addrsize;
break;
}
if (len == 8)
len = 4;
instr.disp.size = len;
if (len!=0)
{
//instr.disp.value.ab = assembly.Image.ReadBytes(offset, len);
byte[] bt = assembly.ReadBytes(offset, len);
instr.disp.value.d64 = 0;
foreach (byte bb in bt.Reverse())
{
instr.disp.value.d64 <<= 8;
instr.disp.value.d64 += bb;
}
movsx(ref instr.disp.value.d64, len, 0x8);
instr.disp.offset = (byte)(offset - origin_offset);
}
return len;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:42,代码来源:mediana.cs
示例19: parse_modrm_sib
//Copies MODRM and SIB bytes to struct INSTRUCTION.
static byte parse_modrm_sib(ulong offset, ref INSTRUCTION instr, OPCODE_DESCRIPTOR opcode)
{
byte len = 0;
if ((opcode.props & PROP_MODRM)!=0)
{
len++;
instr.flags |= INSTR_FLAG_MODRM;
//instr.modrm = *offset;
instr.modrm = assembly.ReadBytes(offset, 1)[0];
if (instr.addrsize != ADDR_SIZE_16)
{
if ((instr.modrm & 0x7) == 0x4 && (instr.modrm & 0xC0) != 0xC0)
{
len++;
instr.flags |= INSTR_FLAG_SIB;
//instr.sib = offset[1];
instr.sib = instr.modrm = assembly.ReadBytes(offset, 2)[1];
}
}
}
return len;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:24,代码来源:mediana.cs
示例20: get_instruction_opsize
//Get instruction's size. Well, really this is size of implicit operand
// that influences on instruction's mnemonic.
static void get_instruction_opsize(MULTI_MNEMONIC multi_mnemonic, INSTRUCTION instr, INTERNAL_DATA idata, DISMODE mode)
{
OPERAND_SIZE opsize = new OPERAND_SIZE();
if (multi_mnemonic.size >= sq_handlers.Count())
{
idata.severe_err = ERRS.ERR_INTERNAL;
}
else
{
sq_handlers[multi_mnemonic.size](ref opsize, ref instr, idata, mode);
}
instr.opsize = (byte)opsize.size; //Possible sizes are 2/4/8.
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:17,代码来源:mediana.cs
注:本文中的INSTRUCTION类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论