# HG changeset patch # User Thinker K.F. Li # Date 1309536590 -28800 # Node ID 6d56483b56cd75d92d0351578e6a9281dc715495 # Parent 6c2efdeffa7bb6dab40d6dce6520f0ce3f60f139 Round size of encoded Dalvik instructions to 2 times. - Append '\x00's to the tail of instructions diff -r 6c2efdeffa7b -r 6d56483b56cd paraspace/dalvik_opcodes.py --- a/paraspace/dalvik_opcodes.py Sat Jul 02 00:03:17 2011 +0800 +++ b/paraspace/dalvik_opcodes.py Sat Jul 02 00:09:50 2011 +0800 @@ -1196,12 +1196,12 @@ arg_part = ''.join([encode_arg(arg, sz) for arg, sz in map(None, args, fmt_parse_cfg)]) + while encode_arg.off % 4: + arg_part = arg_part + encode_arg(0, 1) + pass + inst = chr(opcode) + arg_part - while len(inst) % 2: - encode_arg(0, 1) - pass - return inst diff -r 6c2efdeffa7b -r 6d56483b56cd paraspace/tests/dalvik_opcodes_test.py --- a/paraspace/tests/dalvik_opcodes_test.py Sat Jul 02 00:03:17 2011 +0800 +++ b/paraspace/tests/dalvik_opcodes_test.py Sat Jul 02 00:09:50 2011 +0800 @@ -14,6 +14,11 @@ opv = (0x6f, (0, 1, 0xa601, 1, 0, 0, 0)) insn = encode_inst(opv) assert insn == '\x6f\x10\x01\xa6\x01\x00' + + opv = (0, ()) + insn = encode_inst(opv) + print repr(insn) + assert insn == '\x00\x00' pass