diff --git a/3rd_party/libdisasm/libdis.h b/3rd_party/libdisasm/libdis.h index 42c08a9..6d3fc98 100644 --- a/3rd_party/libdisasm/libdis.h +++ b/3rd_party/libdisasm/libdis.h @@ -288,20 +288,21 @@ struct x86_op_t{ } data; /* this is needed to make formatting operands more sane */ void * insn; /* pointer to x86_insn_t owning operand */ - size_t size() + size_t size() const { return operand_size(); } /* get size of operand data in bytes */ - size_t operand_size(); + size_t operand_size() const; /* format (sprintf) an operand into 'buf' using specified syntax */ int x86_format_operand(char *buf, int len, enum x86_asm_format format ); - bool is_address( ) { + bool is_address( ) const { return ( type == op_absolute || type == op_offset ); } - bool is_relative( ) { + bool is_relative( ) const { return ( type == op_relative_near || type == op_relative_far ); } + bool is_immediate( ) const { return ( type == op_immediate ); } int32_t getAddress() { assert(is_address()||is_relative()); @@ -634,10 +635,10 @@ public: /* convenience routine: returns count of operands matching 'type' */ size_t x86_operand_count( enum x86_op_foreach_type type ); /* accessor functions for the operands */ - x86_op_t * x86_operand_1st( ); - x86_op_t * x86_operand_2nd( ); - x86_op_t * x86_operand_3rd( ); - x86_op_t * get_dest(); + x86_op_t * operand_1st( ); + x86_op_t * operand_2nd( ); + x86_op_t * operand_3rd( ); + const x86_op_t * get_dest() const; int32_t x86_get_rel_offset( ); x86_op_t * x86_get_branch_target( ); x86_op_t * x86_get_imm( ); diff --git a/3rd_party/libdisasm/x86_disasm.cpp b/3rd_party/libdisasm/x86_disasm.cpp index f083349..66a3302 100644 --- a/3rd_party/libdisasm/x86_disasm.cpp +++ b/3rd_party/libdisasm/x86_disasm.cpp @@ -161,7 +161,7 @@ unsigned int X86_Disasm::x86_disasm_forward( unsigned char *buf, unsigned int bu } if ( follow_insn_dest(&insn) ) { - op = insn.x86_operand_1st();//x86_get_dest_operand + op = insn.operand_1st();//x86_get_dest_operand next_addr = -1; /* if caller supplied a resolver, use it to determine diff --git a/3rd_party/libdisasm/x86_format.cpp b/3rd_party/libdisasm/x86_format.cpp index 3fbd50d..cdb39b3 100644 --- a/3rd_party/libdisasm/x86_format.cpp +++ b/3rd_party/libdisasm/x86_format.cpp @@ -1052,8 +1052,8 @@ static int format_att_mnemonic( x86_insn_t *insn, char *buf, int len) { /* do long jump/call prefix */ if ( insn->type == insn_jmp || insn->type == insn_call ) { - if (! is_imm_jmp( insn->x86_operand_1st() ) || - (insn->x86_operand_1st())->datatype != op_byte ) { + if (! is_imm_jmp( insn->operand_1st() ) || + (insn->operand_1st())->datatype != op_byte ) { /* far jump/call, use "l" prefix */ STRNCAT( buf, "l", len ); } @@ -1077,11 +1077,11 @@ static int format_att_mnemonic( x86_insn_t *insn, char *buf, int len) { insn->type == insn_out )) { if ( insn->x86_operand_count( op_explicit ) > 0 && - is_memory_op( insn->x86_operand_1st() ) ){ - size = insn->x86_operand_1st()->operand_size(); + is_memory_op( insn->operand_1st() ) ){ + size = insn->operand_1st()->operand_size(); } else if ( insn->x86_operand_count( op_explicit ) > 1 && - is_memory_op( insn->x86_operand_2nd() ) ){ - size = insn->x86_operand_2nd()->operand_size(); + is_memory_op( insn->operand_2nd() ) ){ + size = insn->operand_2nd()->operand_size(); } } @@ -1223,24 +1223,24 @@ static int format_xml_insn( x86_insn_t *insn, char *buf, int len ) { len -= format_insn_eflags_str( insn->flags_tested, buf, len ); STRNCAT( buf, "\"/>\n\t\n", len ); - if ( insn->x86_operand_1st() ) { - insn->x86_operand_1st()->x86_format_operand(str, + if ( insn->operand_1st() ) { + insn->operand_1st()->x86_format_operand(str, sizeof str, xml_syntax); STRNCAT( buf, "\t\n", len ); STRNCAT( buf, str, len ); STRNCAT( buf, "\t\n", len ); } - if ( insn->x86_operand_2nd() ) { - insn->x86_operand_2nd()->x86_format_operand(str,sizeof str, + if ( insn->operand_2nd() ) { + insn->operand_2nd()->x86_format_operand(str,sizeof str, xml_syntax); STRNCAT( buf, "\t\n", len ); STRNCAT( buf, str, len ); STRNCAT( buf, "\t\n", len ); } - if ( insn->x86_operand_3rd() ) { - insn->x86_operand_3rd()->x86_format_operand(str,sizeof str, + if ( insn->operand_3rd() ) { + insn->operand_3rd()->x86_format_operand(str,sizeof str, xml_syntax); STRNCAT( buf, "\t\n", len ); STRNCAT( buf, str, len ); @@ -1342,13 +1342,13 @@ int x86_insn_t::x86_format_insn( char *buf, int len, STRNCAT( buf, "\t", len ); /* dest */ - if ( (dst = x86_operand_1st()) && !(dst->flags.op_implied) ) { + if ( (dst = operand_1st()) && !(dst->flags.op_implied) ) { dst->x86_format_operand(str, MAX_OP_STRING, format); STRNCAT( buf, str, len ); } /* src */ - if ( (src = x86_operand_2nd()) ) { + if ( (src = operand_2nd()) ) { if ( !(dst->flags.op_implied) ) { STRNCAT( buf, ", ", len ); } @@ -1357,9 +1357,9 @@ int x86_insn_t::x86_format_insn( char *buf, int len, } /* imm */ - if ( x86_operand_3rd()) { + if ( operand_3rd()) { STRNCAT( buf, ", ", len ); - x86_operand_3rd()->x86_format_operand(str, MAX_OP_STRING,format); + operand_3rd()->x86_format_operand(str, MAX_OP_STRING,format); STRNCAT( buf, str, len ); } @@ -1373,8 +1373,8 @@ int x86_insn_t::x86_format_insn( char *buf, int len, /* not sure which is correct? sometimes GNU as requires * an imm as the first operand, sometimes as the third... */ /* imm */ - if ( x86_operand_3rd() ) { - x86_operand_3rd()->x86_format_operand(str, MAX_OP_STRING,format); + if ( operand_3rd() ) { + operand_3rd()->x86_format_operand(str, MAX_OP_STRING,format); STRNCAT( buf, str, len ); /* there is always 'dest' operand if there is 'src' */ STRNCAT( buf, ", ", len ); @@ -1382,13 +1382,13 @@ int x86_insn_t::x86_format_insn( char *buf, int len, if ( (note & insn_note_nonswap ) == 0 ) { /* regular AT&T style swap */ - src = x86_operand_2nd(); - dst = x86_operand_1st(); + src = operand_2nd(); + dst = operand_1st(); } else { /* special-case instructions */ - src = x86_operand_1st(); - dst = x86_operand_2nd(); + src = operand_1st(); + dst = operand_2nd(); } /* src */ @@ -1431,20 +1431,20 @@ int x86_insn_t::x86_format_insn( char *buf, int len, /* print operands */ /* dest */ - if ( x86_operand_1st() ) { - x86_operand_1st()->x86_format_operand(str, MAX_OP_STRING,format); + if ( operand_1st() ) { + operand_1st()->x86_format_operand(str, MAX_OP_STRING,format); STRNCATF( buf, "%s\t", str, len ); } /* src */ - if ( x86_operand_2nd() ) { - x86_operand_2nd()->x86_format_operand(str, MAX_OP_STRING,format); + if ( operand_2nd() ) { + operand_2nd()->x86_format_operand(str, MAX_OP_STRING,format); STRNCATF( buf, "%s\t", str, len ); } /* imm */ - if ( x86_operand_3rd()) { - x86_operand_3rd()->x86_format_operand(str, MAX_OP_STRING,format); + if ( operand_3rd()) { + operand_3rd()->x86_format_operand(str, MAX_OP_STRING,format); STRNCAT( buf, str, len ); } } diff --git a/3rd_party/libdisasm/x86_insn.cpp b/3rd_party/libdisasm/x86_insn.cpp index 22af097..366b9b2 100644 --- a/3rd_party/libdisasm/x86_insn.cpp +++ b/3rd_party/libdisasm/x86_insn.cpp @@ -93,7 +93,7 @@ x86_op_t * x86_insn_t::x86_get_branch_target() { return NULL; } -x86_op_t * x86_insn_t::get_dest() { +const x86_op_t * x86_insn_t::get_dest() const { x86_oplist_t *op_lst; assert(this); if ( ! operands ) { @@ -169,7 +169,7 @@ uint8_t *x86_insn_t::x86_get_raw_imm() { } -size_t x86_op_t::operand_size() { +size_t x86_op_t::operand_size() const { switch (datatype ) { case op_byte: return 1; case op_word: return 2; diff --git a/3rd_party/libdisasm/x86_operand_list.cpp b/3rd_party/libdisasm/x86_operand_list.cpp index 9219dcb..a7a7cf7 100644 --- a/3rd_party/libdisasm/x86_operand_list.cpp +++ b/3rd_party/libdisasm/x86_operand_list.cpp @@ -184,7 +184,7 @@ size_t x86_insn_t::x86_operand_count( enum x86_op_foreach_type type ) { } /* accessor functions */ -x86_op_t * x86_insn_t::x86_operand_1st() { +x86_op_t * x86_insn_t::operand_1st() { if (! explicit_count ) { return NULL; } @@ -192,7 +192,7 @@ x86_op_t * x86_insn_t::x86_operand_1st() { return &(operands->op); } -x86_op_t * x86_insn_t::x86_operand_2nd( ) { +x86_op_t * x86_insn_t::operand_2nd( ) { if ( explicit_count < 2 ) { return NULL; } @@ -200,7 +200,7 @@ x86_op_t * x86_insn_t::x86_operand_2nd( ) { return &(operands->next->op); } -x86_op_t * x86_insn_t::x86_operand_3rd( ) { +x86_op_t * x86_insn_t::operand_3rd( ) { if ( explicit_count < 3 ) { return NULL; }