Mercurial > paraspace
changeset 136:f31bfe55d9c2
Fix issue of corrupted offset list in _DEX_AnnotationSetItem after injection
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 09 Aug 2011 21:52:05 +0800 |
parents | b488ca519709 |
children | 987fead83ce3 |
files | paraspace/dexfile.py paraspace/tests/injection_test.py |
diffstat | 2 files changed, 56 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/dexfile.py Tue Aug 09 21:28:13 2011 +0800 +++ b/paraspace/dexfile.py Tue Aug 09 21:52:05 2011 +0800 @@ -1297,9 +1297,16 @@ pass +class _DEX_AnnotationSetItem_anno_item(composite): + offset = depend_off('_DEX_AnnotationItem')(uint32) + + child_names = ('offset',) + pass + + class _DEX_AnnotationSetItem(composite): size = uint32 - annotationOffs = array('size', depend_off('_DEX_AnnotationItem')(uint32)) + annotationOffs = array('size', _DEX_AnnotationSetItem_anno_item) child_names = 'size annotationOffs'.split() pass
--- a/paraspace/tests/injection_test.py Tue Aug 09 21:28:13 2011 +0800 +++ b/paraspace/tests/injection_test.py Tue Aug 09 21:52:05 2011 +0800 @@ -543,3 +543,51 @@ raise pass pass + +## \brief Test case for issue of bad offset list in _DEX_AnnotationSetItem. +# +# Values of _DEX_AnnotationSetItem.annotationOffs is corrupted after +# injection. +# \pre +# E/dalvikvm( 300): No data map entry found @ 0xf31; expected 2004 +# E/dalvikvm( 300): Trouble with item 0 @ offset 0x5c0 +# E/dalvikvm( 300): Cross-item verify of section type 1003 failed +# E/dalvikvm( 300): ERROR: Byte swap + verify failed +# E/dalvikvm( 300): Optimization failed +# +# It must be the issue that back_type of an array can not be a \ref depend. +# +def annotation_set_items_verify_test(): + from paraspace.dex_deptracker import prepare_dep_decls + from paraspace.dex_deptracker import dex_sort_sorted_arrays + from paraspace.injection import inject_redir_no_restore + + _install_dexfile_4_deptracker() + + all_dep_decls = prepare_dep_decls() + + srcdir = os.path.dirname(__file__) + datapath = os.path.join(srcdir, '..', '..', 'data') + + fake_path = os.path.join(datapath, 'fakefile.dex') + hello_path = os.path.join(datapath, 'helloworld.dex') + + fake_dex = dexfile.DEXFile.open(fake_path) + fake_linked = dexfile.DEXFile_linked.build_dependencies(fake_dex, + all_dep_decls) + + hello_dex = dexfile.DEXFile.open(hello_path) + hello_linked = dexfile.DEXFile_linked.build_dependencies(hello_dex, + all_dep_decls) + + inject_redir_no_restore(fake_linked, 'Lcom/codemud/fakefile/fakefile;', + hello_linked, 'Ljava/io/File;', all_dep_decls) + + dex_sort_sorted_arrays(hello_linked) + + for setitem in hello_linked.annotationSetItems.items: + for anno in setitem.annotationOffs.items: + assert anno.offset in hello_linked.annotationItems.items + pass + pass + pass