Mercurial > paraspace
changeset 113:ee13c86d84f2
Let user specify redirection map for methods
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 02 Aug 2011 18:10:48 +0800 |
parents | 650dcb9c01ee |
children | 867184e01852 |
files | paraspace/injection.py paraspace/tests/injection_test.py |
diffstat | 2 files changed, 13 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/injection.py Tue Aug 02 13:49:41 2011 +0800 +++ b/paraspace/injection.py Tue Aug 02 18:10:48 2011 +0800 @@ -454,14 +454,14 @@ # \param types_redir is a map of types for redirecting types. # \return a map of method indices. # -def _make_methods_redir_for_types_redir(dex, types_redir): +def make_methods_redir_for_types_redir(dex_src, dex_dst, types_redir): methods_map = {} for typeidx_src, typeidx_dst in types_redir.items(): - typeid_src = dex.find_typeid_idx(typeidx_src) - typeid_dst = dex.find_typeid_idx(typeidx_dst) - class_methods_map = make_redir_classes_methods_map(dex, + typeid_src = dex_src.find_typeid_idx(typeidx_src) + typeid_dst = dex_dst.find_typeid_idx(typeidx_dst) + class_methods_map = make_redir_classes_methods_map(dex_src, typeid_src, - dex, + dex_dst, typeid_dst) methods_map.update(class_methods_map) pass @@ -469,9 +469,7 @@ ## \biref Redirect types of all code in given DEXFile_linked. -def dexfile_redirect_types(dex, types_redir, excludes=set([])): - methods_redir = _make_methods_redir_for_types_redir(dex, types_redir) - +def dexfile_redirect_types(dex, types_redir, methods_redir, excludes=set([])): for classdef in dex.classDefs.items: typeid = classdef.classIdx idx = dex.get_idx_typeid(typeid)
--- a/paraspace/tests/injection_test.py Tue Aug 02 13:49:41 2011 +0800 +++ b/paraspace/tests/injection_test.py Tue Aug 02 18:10:48 2011 +0800 @@ -107,6 +107,7 @@ from paraspace.dex_deptracker import prepare_dep_decls from paraspace.injection import dexfile_insert_class from paraspace.injection import dexfile_redirect_types + from paraspace.injection import make_methods_redir_for_types_redir from paraspace import dalvik_opcodes _install_dexfile_4_deptracker() @@ -149,14 +150,18 @@ clone_typeidx = helloworld_linked.get_idx_typeid(clone.classIdx) - redirect_map = {File_typeidx: clone_typeidx} + types_redir = {File_typeidx: clone_typeidx} excludes = set([clone_typeidx]) fakefile_data = clone.classDataOffRef.value fakefile_methods = fakefile_data.directMethods.items fakefile_codes = [method.codeOffRef.value for method in fakefile_methods] - dexfile_redirect_types(helloworld_linked, redirect_map, excludes) + methods_redir = make_methods_redir_for_types_redir(helloworld_linked, + helloworld_linked, + types_redir) + dexfile_redirect_types(helloworld_linked, types_redir, + methods_redir, excludes) for code in helloworld_linked.codeItems.items: op_vectors = dalvik_opcodes.decode_insn_blk(code.insns.data)