diff paraspace/injection.py @ 105:f14c32108164

Test dexfile_redirect_types
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 28 Jul 2011 13:25:55 +0800
parents 61cef1662035
children 7821c6e89622
line wrap: on
line diff
--- a/paraspace/injection.py	Thu Jul 28 00:06:54 2011 +0800
+++ b/paraspace/injection.py	Thu Jul 28 13:25:55 2011 +0800
@@ -65,6 +65,9 @@
     return type_2_attr
 
 
+_saved_dex_type_2_array_attr_map = dex_type_2_array_attr_map
+
+
 ## \brief Append a object to appropriate list of a DEXFile object.
 #
 # Skip the object if found no appropriate list.
@@ -99,6 +102,8 @@
     from copy import copy
     from paraspace.dexfile import _DEX_StringDataItem, _DEX_StringId
     from paraspace.dexfile import _DEX_TypeId
+    from paraspace.dex_deptracker import _dex_tree_set_child
+    from paraspace.dex_deptracker import _dex_tree_get_child
     
     visit_log = {}
     
@@ -108,9 +113,11 @@
 
     def relink_dependencies(clone):
         rel_children = _relocatable_children(clone)
+        print clone
         for attr, value in rel_children:
             clone_value = visit_log[id(value)]
-            setattr(clone, attr, clone_value)
+            print attr, _dex_tree_get_child(clone, attr), clone_value
+            _dex_tree_set_child(clone, attr, clone_value)
             pass
         pass
 
@@ -180,6 +187,7 @@
     merge_unique_strid()
     merge_unique_typeid()
     
+    print visit_log
     for obj in visit_log.values():
         if isinstance(obj, (_DEX_StringDataItem,
                             _DEX_StringId,
@@ -234,7 +242,7 @@
             methodidx = args[2]
             methodid = dex.find_methodid_idx(methodidx)
             method_typeid = methodid.classIdx
-            method_typeidx = dex.get_idx_typeid(method_typeidx)
+            method_typeidx = dex.get_idx_typeid(method_typeid)
             if method_typeidx not in redirect_map:
                 return opcode, args
             
@@ -279,7 +287,7 @@
 def dexfile_redirect_types(dex, redirect_map, excludes=set([])):
     for classdef in dex.classDefs.items:
         typeid = classdef.classIdx
-        idx = dex.get_index_typeid(typeid)
+        idx = dex.get_idx_typeid(typeid)
         if idx in excludes:
             continue
         class_redirect_types(dex, classdef, redirect_map)