# HG changeset patch # User Thinker K.F. Li # Date 1313541393 -28800 # Node ID c659b8c7d6cb2f9cf4276faa796107ec7208522f # Parent 9a1677d0341705adc14d0d9c48fda41f9b12d64b Use right opcode formats diff -r 9a1677d03417 -r c659b8c7d6cb paraspace/injection.py --- 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]