Mercurial > paraspace
changeset 154:c659b8c7d6cb
Use right opcode formats
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 17 Aug 2011 08:36:33 +0800 |
parents | 9a1677d03417 |
children | 6570b15d12d4 |
files | paraspace/injection.py |
diffstat | 1 files changed, 46 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/injection.py Tue Aug 16 20:25:02 2011 +0800 +++ b/paraspace/injection.py Wed Aug 17 08:36:33 2011 +0800 @@ -348,7 +348,7 @@ return None - field_opcodes = set([all_opcodes.OP_IGET, + field2_opcodes = set([all_opcodes.OP_IGET, all_opcodes.OP_IGET_WIDE, all_opcodes.OP_IGET_OBJECT, all_opcodes.OP_IGET_BOOLEAN, @@ -361,26 +361,31 @@ all_opcodes.OP_IPUT_BOOLEAN, all_opcodes.OP_IPUT_BYTE, all_opcodes.OP_IPUT_CHAR, - all_opcodes.OP_IPUT_SHORT, - all_opcodes.OP_SGET, - all_opcodes.OP_SGET_WIDE, - all_opcodes.OP_SGET_OBJECT, - all_opcodes.OP_SGET_BOOLEAN, - all_opcodes.OP_SGET_BYTE, - all_opcodes.OP_SGET_CHAR, - all_opcodes.OP_SGET_SHORT, - all_opcodes.OP_SPUT, - all_opcodes.OP_SPUT_WIDE, - all_opcodes.OP_SPUT_OBJECT, - all_opcodes.OP_SPUT_BOOLEAN, - all_opcodes.OP_SPUT_BYTE, - all_opcodes.OP_SPUT_CHAR, - all_opcodes.OP_SPUT_SHORT]) + all_opcodes.OP_IPUT_SHORT]) + + field1_opcodes = set([all_opcodes.OP_SGET, + all_opcodes.OP_SGET_WIDE, + all_opcodes.OP_SGET_OBJECT, + all_opcodes.OP_SGET_BOOLEAN, + all_opcodes.OP_SGET_BYTE, + all_opcodes.OP_SGET_CHAR, + all_opcodes.OP_SGET_SHORT, + all_opcodes.OP_SPUT, + all_opcodes.OP_SPUT_WIDE, + all_opcodes.OP_SPUT_OBJECT, + all_opcodes.OP_SPUT_BOOLEAN, + all_opcodes.OP_SPUT_BYTE, + all_opcodes.OP_SPUT_CHAR, + all_opcodes.OP_SPUT_SHORT]) + def collect_fields_in_op_vector(op_vector): code, args = op_vector - if code in field_opcodes: + if code in field2_opcodes: fieldidx = args[2] return fieldidx + elif code in field1_opcodes: + fieldidx = args[1] + return fieldidx pass code_blk = DEXFile_linked.get_code_block_method(method) @@ -605,7 +610,7 @@ insns_blk = code.insns.data op_vectors = decode_insn_blk(insns_blk) - field_opcodes = set([all_opcodes.OP_IGET, + field2_opcodes = set([all_opcodes.OP_IGET, all_opcodes.OP_IGET_WIDE, all_opcodes.OP_IGET_OBJECT, all_opcodes.OP_IGET_BOOLEAN, @@ -618,21 +623,23 @@ all_opcodes.OP_IPUT_BOOLEAN, all_opcodes.OP_IPUT_BYTE, all_opcodes.OP_IPUT_CHAR, - all_opcodes.OP_IPUT_SHORT, - all_opcodes.OP_SGET, - all_opcodes.OP_SGET_WIDE, - all_opcodes.OP_SGET_OBJECT, - all_opcodes.OP_SGET_BOOLEAN, - all_opcodes.OP_SGET_BYTE, - all_opcodes.OP_SGET_CHAR, - all_opcodes.OP_SGET_SHORT, - all_opcodes.OP_SPUT, - all_opcodes.OP_SPUT_WIDE, - all_opcodes.OP_SPUT_OBJECT, - all_opcodes.OP_SPUT_BOOLEAN, - all_opcodes.OP_SPUT_BYTE, - all_opcodes.OP_SPUT_CHAR, - all_opcodes.OP_SPUT_SHORT]) + all_opcodes.OP_IPUT_SHORT]) + + field1_opcodes = set([all_opcodes.OP_SGET, + all_opcodes.OP_SGET_WIDE, + all_opcodes.OP_SGET_OBJECT, + all_opcodes.OP_SGET_BOOLEAN, + all_opcodes.OP_SGET_BYTE, + all_opcodes.OP_SGET_CHAR, + all_opcodes.OP_SGET_SHORT, + all_opcodes.OP_SPUT, + all_opcodes.OP_SPUT_WIDE, + all_opcodes.OP_SPUT_OBJECT, + all_opcodes.OP_SPUT_BOOLEAN, + all_opcodes.OP_SPUT_BYTE, + all_opcodes.OP_SPUT_CHAR, + all_opcodes.OP_SPUT_SHORT]) + def redirect(opcode, args): if opcode == all_opcodes.OP_NEW_INSTANCE: typeidx = args[1] @@ -667,11 +674,16 @@ return opcode, args return opcode, (args[0], stridxs_redir[stridx]) - elif opcode in field_opcodes: + elif opcode in field2_opcodes: fieldidx = args[2] if fieldidx not in fieldidxs_redir: return opcode, args return opcode, (args[0], args[1], fieldidxs_redir[fieldidx]) + elif opcode in field1_opcodes: + fieldidx = args[1] + if fieldidx not in fieldidxs_redir: + return opcode, args + return opcode, (args[0], fieldidxs_redir[fieldidx]) return opcode, args new_op_vectors = [redirect(opcode, args) for opcode, args in op_vectors]