comparison paraspace/injection.py @ 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
comparison
equal deleted inserted replaced
112:650dcb9c01ee 113:ee13c86d84f2
452 # 452 #
453 # \param dex is a DEXFile_linked that owns source and destinate types. 453 # \param dex is a DEXFile_linked that owns source and destinate types.
454 # \param types_redir is a map of types for redirecting types. 454 # \param types_redir is a map of types for redirecting types.
455 # \return a map of method indices. 455 # \return a map of method indices.
456 # 456 #
457 def _make_methods_redir_for_types_redir(dex, types_redir): 457 def make_methods_redir_for_types_redir(dex_src, dex_dst, types_redir):
458 methods_map = {} 458 methods_map = {}
459 for typeidx_src, typeidx_dst in types_redir.items(): 459 for typeidx_src, typeidx_dst in types_redir.items():
460 typeid_src = dex.find_typeid_idx(typeidx_src) 460 typeid_src = dex_src.find_typeid_idx(typeidx_src)
461 typeid_dst = dex.find_typeid_idx(typeidx_dst) 461 typeid_dst = dex_dst.find_typeid_idx(typeidx_dst)
462 class_methods_map = make_redir_classes_methods_map(dex, 462 class_methods_map = make_redir_classes_methods_map(dex_src,
463 typeid_src, 463 typeid_src,
464 dex, 464 dex_dst,
465 typeid_dst) 465 typeid_dst)
466 methods_map.update(class_methods_map) 466 methods_map.update(class_methods_map)
467 pass 467 pass
468 return methods_map 468 return methods_map
469 469
470 470
471 ## \biref Redirect types of all code in given DEXFile_linked. 471 ## \biref Redirect types of all code in given DEXFile_linked.
472 def dexfile_redirect_types(dex, types_redir, excludes=set([])): 472 def dexfile_redirect_types(dex, types_redir, methods_redir, excludes=set([])):
473 methods_redir = _make_methods_redir_for_types_redir(dex, types_redir)
474
475 for classdef in dex.classDefs.items: 473 for classdef in dex.classDefs.items:
476 typeid = classdef.classIdx 474 typeid = classdef.classIdx
477 idx = dex.get_idx_typeid(typeid) 475 idx = dex.get_idx_typeid(typeid)
478 if idx in excludes: 476 if idx in excludes:
479 continue 477 continue