From 7316a6935be4c7c6242ca9eff386d4915b6494ef Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 14 Oct 2015 06:22:32 -0500 Subject: [PATCH 1/6] remove smali project in preps for submodule --- brut.apktool.smali/.gitignore | 6 - brut.apktool.smali/NOTICE-SMALI | 49 - brut.apktool.smali/baksmali/build.gradle | 84 - .../Adaptors/AnnotationFormatter.java | 69 - .../jf/baksmali/Adaptors/BlankMethodItem.java | 48 - .../jf/baksmali/Adaptors/CatchMethodItem.java | 97 - .../jf/baksmali/Adaptors/ClassDefinition.java | 331 --- .../baksmali/Adaptors/CommentMethodItem.java | 55 - .../Adaptors/CommentedOutMethodItem.java | 52 - .../Adaptors/CommentingIndentingWriter.java | 48 - .../Debug/BeginEpilogueMethodItem.java | 48 - .../Adaptors/Debug/DebugMethodItem.java | 71 - .../Adaptors/Debug/EndLocalMethodItem.java | 66 - .../Adaptors/Debug/EndPrologueMethodItem.java | 48 - .../Adaptors/Debug/LineNumberMethodItem.java | 54 - .../Adaptors/Debug/LocalFormatter.java | 73 - .../Debug/RestartLocalMethodItem.java | 66 - .../Debug/SetSourceFileMethodItem.java | 61 - .../Adaptors/Debug/StartLocalMethodItem.java | 67 - .../AnnotationEncodedValueAdaptor.java | 65 - .../ArrayEncodedValueAdaptor.java | 65 - .../EncodedValue/EncodedValueAdaptor.java | 112 -- .../Adaptors/EndTryLabelMethodItem.java | 51 - .../jf/baksmali/Adaptors/FieldDefinition.java | 101 - .../Adaptors/Format/ArrayDataMethodItem.java | 81 - .../Format/InstructionMethodItem.java | 576 ------ .../Format/InstructionMethodItemFactory.java | 67 - .../OffsetInstructionFormatMethodItem.java | 85 - .../Format/PackedSwitchMethodItem.java | 130 -- .../Format/SparseSwitchMethodItem.java | 126 -- .../UnresolvedOdexInstructionMethodItem.java | 54 - .../jf/baksmali/Adaptors/LabelMethodItem.java | 102 - .../baksmali/Adaptors/MethodDefinition.java | 638 ------ .../org/jf/baksmali/Adaptors/MethodItem.java | 59 - ...PostInstructionRegisterInfoMethodItem.java | 102 - .../PreInstructionRegisterInfoMethodItem.java | 260 --- .../baksmali/Adaptors/ReferenceFormatter.java | 65 - .../baksmali/Adaptors/RegisterFormatter.java | 99 - .../SyntheticAccessCommentMethodItem.java | 121 -- .../baksmali/Renderers/BooleanRenderer.java | 43 - .../jf/baksmali/Renderers/ByteRenderer.java | 53 - .../jf/baksmali/Renderers/CharRenderer.java | 42 - .../jf/baksmali/Renderers/DoubleRenderer.java | 39 - .../jf/baksmali/Renderers/FloatRenderer.java | 40 - .../baksmali/Renderers/IntegerRenderer.java | 50 - .../jf/baksmali/Renderers/LongRenderer.java | 63 - .../jf/baksmali/Renderers/ShortRenderer.java | 47 - .../main/java/org/jf/baksmali/baksmali.java | 247 --- .../java/org/jf/baksmali/baksmaliOptions.java | 105 - .../src/main/java/org/jf/baksmali/dump.java | 73 - .../src/main/java/org/jf/baksmali/main.java | 566 ------ .../src/main/resources/baksmali.properties | 1 - .../java/org/jf/baksmali/AnalysisTest.java | 125 -- .../org/jf/baksmali/BaksmaliTestUtils.java | 119 -- .../java/org/jf/baksmali/DisassemblyTest.java | 104 - .../jf/baksmali/IdenticalRoundtripTest.java | 59 - .../jf/baksmali/ImplicitReferenceTest.java | 260 --- .../org/jf/baksmali/InterfaceOrderTest.java | 41 - .../test/java/org/jf/baksmali/LambdaTest.java | 49 - .../org/jf/baksmali/ManyRegistersTest.java | 42 - .../java/org/jf/baksmali/MultiSwitchTest.java | 42 - .../java/org/jf/baksmali/RoundtripTest.java | 95 - .../test/java/org/jf/baksmali/SwitchTest.java | 41 - .../ConstructorTest/ConstructorTest.smali | 16 - .../ConstructorTest/ConstructorTest2.smali | 25 - .../resources/ConstructorTest/classes.dex | Bin 520 -> 0 bytes .../DuplicateDirectMethods.smali | 29 - .../DuplicateDirectVirtualMethods.smali | 46 - .../DuplicateInstanceFields.smali | 13 - .../DuplicateTest/DuplicateStaticFields.smali | 13 - .../DuplicateStaticInstanceFields.smali | 22 - .../DuplicateVirtualMethods.smali | 29 - .../test/resources/DuplicateTest/classes.dex | Bin 1284 -> 0 bytes .../src/DuplicateDirectMethods.smali | 22 - .../src/DuplicateDirectVirtualMethods.smali | 32 - .../src/DuplicateInstanceFields.smali | 9 - .../src/DuplicateStaticFields.smali | 9 - .../src/DuplicateStaticInstanceFields.smali | 11 - .../src/DuplicateVirtualMethods.smali | 22 - .../test/resources/DuplicateTest/src/README | 3 - .../InterfaceOrderTest/InterfaceOrder.smali | 37 - .../LambdaTest/HelloWorldLambda.smali | 55 - .../test/resources/LocalTest/LocalTest.smali | 31 - .../src/test/resources/LocalTest/classes.dex | Bin 832 -> 0 bytes .../ManyRegistersTest/ManyRegisters.smali | 7 - .../MultiSwitchTest/MultiSwitchInput.dex | Bin 616 -> 0 bytes .../MultiSwitchTest/MultiSwitchInput.smali | 72 - .../MultiSwitchTest/MultiSwitchOutput.smali | 119 -- .../MultipleStartInstructionsTest.smali | 46 - .../MultipleStartInstructionsTest/classes.dex | Bin 568 -> 0 bytes .../RegisterEqualityOnMerge.smali | 37 - .../RegisterEqualityOnMergeTest/classes.dex | Bin 508 -> 0 bytes .../UnorderedSparseSwitchInput.smali | 35 - .../UnorderedSparseSwitchOutput.smali | 28 - .../UninitRefIdentityTest.smali | 50 - .../UninitRefIdentityTest/classes.dex | Bin 552 -> 0 bytes .../src/test/smali/baksmali_test_class.smali | 218 -- .../src/test/smali/deodex_test1/main.smali | 70 - .../test/smali/deodex_test1/randomclass.smali | 18 - .../test/smali/deodex_test1/subclass.smali | 21 - .../test/smali/deodex_test1/superclass.smali | 21 - .../smali/deodex_test2/app_classes/main.smali | 41 - .../bootclass_classes/randomclass.smali | 18 - .../bootclass_classes/subclass1.smali | 21 - .../bootclass_classes/subclass2.smali | 21 - .../bootclass_classes/superclass.smali | 21 - .../bootclass_classes/supersuperclass.smali | 21 - brut.apktool.smali/build.gradle | 116 -- .../accessorTestGenerator/build.gradle | 39 - .../org/jf/dexlib2/AccessorTestGenerator.java | 141 -- .../src/main/resources/AccessorTest.stg | 86 - brut.apktool.smali/dexlib2/build.gradle | 94 - .../java/org/jf/dexlib2/AccessorTest.java | 133 -- .../main/java/org/jf/dexlib2/AccessFlags.java | 185 -- .../org/jf/dexlib2/AnnotationVisibility.java | 65 - .../java/org/jf/dexlib2/DebugItemType.java | 51 - .../java/org/jf/dexlib2/DexFileFactory.java | 156 -- .../src/main/java/org/jf/dexlib2/Format.java | 83 - .../src/main/java/org/jf/dexlib2/Opcode.java | 436 ---- .../src/main/java/org/jf/dexlib2/Opcodes.java | 83 - .../java/org/jf/dexlib2/ReferenceType.java | 103 - .../main/java/org/jf/dexlib2/ValueType.java | 53 - .../org/jf/dexlib2/VerificationError.java | 102 - .../dexlib2/analysis/AnalysisException.java | 50 - .../dexlib2/analysis/AnalyzedInstruction.java | 332 --- .../org/jf/dexlib2/analysis/ArrayProto.java | 166 -- .../org/jf/dexlib2/analysis/ClassPath.java | 244 --- .../org/jf/dexlib2/analysis/ClassProto.java | 675 ------- .../analysis/CustomInlineMethodResolver.java | 138 -- .../org/jf/dexlib2/analysis/DumpFields.java | 180 -- .../org/jf/dexlib2/analysis/DumpVtables.java | 184 -- .../analysis/InlineMethodResolver.java | 201 -- .../jf/dexlib2/analysis/MethodAnalyzer.java | 1776 ----------------- .../OdexedFieldInstructionMapper.java | 241 --- .../jf/dexlib2/analysis/PrimitiveProto.java | 71 - .../org/jf/dexlib2/analysis/RegisterType.java | 351 ---- .../org/jf/dexlib2/analysis/TypeProto.java | 49 - .../dexlib2/analysis/UnknownClassProto.java | 81 - .../analysis/UnresolvedClassException.java | 48 - .../analysis/UnresolvedOdexInstruction.java | 59 - .../reflection/ReflectionClassDef.java | 247 --- .../reflection/ReflectionConstructor.java | 121 -- .../analysis/reflection/ReflectionField.java | 75 - .../analysis/reflection/ReflectionMethod.java | 120 -- .../reflection/util/ReflectionUtils.java | 42 - .../dexlib2/analysis/util/TypeProtoUtils.java | 97 - .../org/jf/dexlib2/base/BaseAnnotation.java | 74 - .../dexlib2/base/BaseAnnotationElement.java | 69 - .../jf/dexlib2/base/BaseExceptionHandler.java | 113 -- .../jf/dexlib2/base/BaseMethodParameter.java | 84 - .../org/jf/dexlib2/base/BaseTryBlock.java | 47 - .../base/reference/BaseFieldReference.java | 67 - .../base/reference/BaseMethodReference.java | 73 - .../base/reference/BaseStringReference.java | 62 - .../base/reference/BaseTypeReference.java | 66 - .../value/BaseAnnotationEncodedValue.java | 73 - .../base/value/BaseArrayEncodedValue.java | 64 - .../base/value/BaseBooleanEncodedValue.java | 65 - .../base/value/BaseByteEncodedValue.java | 64 - .../base/value/BaseCharEncodedValue.java | 65 - .../base/value/BaseDoubleEncodedValue.java | 66 - .../base/value/BaseEnumEncodedValue.java | 64 - .../base/value/BaseFieldEncodedValue.java | 64 - .../base/value/BaseFloatEncodedValue.java | 64 - .../base/value/BaseIntEncodedValue.java | 64 - .../base/value/BaseLongEncodedValue.java | 67 - .../base/value/BaseMethodEncodedValue.java | 64 - .../base/value/BaseNullEncodedValue.java | 59 - .../base/value/BaseShortEncodedValue.java | 65 - .../base/value/BaseStringEncodedValue.java | 64 - .../base/value/BaseTypeEncodedValue.java | 64 - .../jf/dexlib2/builder/BuilderDebugItem.java | 52 - .../builder/BuilderExceptionHandler.java | 99 - .../dexlib2/builder/BuilderInstruction.java | 70 - .../builder/BuilderOffsetInstruction.java | 67 - .../dexlib2/builder/BuilderSwitchPayload.java | 59 - .../jf/dexlib2/builder/BuilderTryBlock.java | 81 - .../java/org/jf/dexlib2/builder/Label.java | 62 - .../builder/MethodImplementationBuilder.java | 153 -- .../jf/dexlib2/builder/MethodLocation.java | 247 --- .../builder/MutableMethodImplementation.java | 978 --------- .../dexlib2/builder/SwitchLabelElement.java | 44 - .../builder/debug/BuilderEndLocal.java | 53 - .../builder/debug/BuilderEpilogueBegin.java | 43 - .../builder/debug/BuilderLineNumber.java | 48 - .../builder/debug/BuilderPrologueEnd.java | 43 - .../builder/debug/BuilderRestartLocal.java | 53 - .../builder/debug/BuilderSetSourceFile.java | 58 - .../builder/debug/BuilderStartLocal.java | 77 - .../instruction/BuilderArrayPayload.java | 62 - .../instruction/BuilderInstruction10t.java | 51 - .../instruction/BuilderInstruction10x.java | 49 - .../instruction/BuilderInstruction11n.java | 61 - .../instruction/BuilderInstruction11x.java | 56 - .../instruction/BuilderInstruction12x.java | 60 - .../instruction/BuilderInstruction20bc.java | 63 - .../instruction/BuilderInstruction20t.java | 51 - .../instruction/BuilderInstruction21c.java | 62 - .../instruction/BuilderInstruction21ih.java | 62 - .../instruction/BuilderInstruction21lh.java | 61 - .../instruction/BuilderInstruction21s.java | 61 - .../instruction/BuilderInstruction21t.java | 58 - .../instruction/BuilderInstruction22b.java | 65 - .../instruction/BuilderInstruction22c.java | 66 - .../instruction/BuilderInstruction22s.java | 65 - .../instruction/BuilderInstruction22t.java | 62 - .../instruction/BuilderInstruction22x.java | 60 - .../instruction/BuilderInstruction23x.java | 64 - .../instruction/BuilderInstruction25x.java | 82 - .../instruction/BuilderInstruction30t.java | 52 - .../instruction/BuilderInstruction31c.java | 62 - .../instruction/BuilderInstruction31i.java | 61 - .../instruction/BuilderInstruction31t.java | 59 - .../instruction/BuilderInstruction32x.java | 60 - .../instruction/BuilderInstruction35c.java | 82 - .../instruction/BuilderInstruction3rc.java | 68 - .../instruction/BuilderInstruction51l.java | 60 - .../BuilderPackedSwitchPayload.java | 69 - .../BuilderSparseSwitchPayload.java | 70 - .../instruction/BuilderSwitchElement.java | 34 - .../jf/dexlib2/dexbacked/BaseDexBuffer.java | 118 -- .../jf/dexlib2/dexbacked/BaseDexReader.java | 518 ----- .../dexbacked/DexBackedAnnotation.java | 74 - .../dexbacked/DexBackedAnnotationElement.java | 53 - .../DexBackedCatchAllExceptionHandler.java | 49 - .../dexlib2/dexbacked/DexBackedClassDef.java | 437 ---- .../dexlib2/dexbacked/DexBackedDexFile.java | 302 --- .../dexbacked/DexBackedExceptionHandler.java | 37 - .../jf/dexlib2/dexbacked/DexBackedField.java | 134 -- .../jf/dexlib2/dexbacked/DexBackedMethod.java | 227 --- .../DexBackedMethodImplementation.java | 147 -- .../dexlib2/dexbacked/DexBackedOdexFile.java | 145 -- .../dexlib2/dexbacked/DexBackedTryBlock.java | 94 - .../DexBackedTypedExceptionHandler.java | 49 - .../org/jf/dexlib2/dexbacked/DexReader.java | 40 - .../instruction/DexBackedArrayPayload.java | 117 -- .../instruction/DexBackedInstruction.java | 154 -- .../instruction/DexBackedInstruction10t.java | 48 - .../instruction/DexBackedInstruction10x.java | 46 - .../instruction/DexBackedInstruction11n.java | 59 - .../instruction/DexBackedInstruction11x.java | 48 - .../instruction/DexBackedInstruction12x.java | 57 - .../instruction/DexBackedInstruction20bc.java | 64 - .../instruction/DexBackedInstruction20t.java | 48 - .../instruction/DexBackedInstruction21c.java | 61 - .../instruction/DexBackedInstruction21ih.java | 51 - .../instruction/DexBackedInstruction21lh.java | 50 - .../instruction/DexBackedInstruction21s.java | 50 - .../instruction/DexBackedInstruction21t.java | 49 - .../instruction/DexBackedInstruction22b.java | 51 - .../instruction/DexBackedInstruction22c.java | 70 - .../instruction/DexBackedInstruction22cs.java | 62 - .../instruction/DexBackedInstruction22s.java | 60 - .../instruction/DexBackedInstruction22t.java | 59 - .../instruction/DexBackedInstruction22x.java | 49 - .../instruction/DexBackedInstruction23x.java | 50 - .../instruction/DexBackedInstruction25x.java | 83 - .../instruction/DexBackedInstruction30t.java | 48 - .../instruction/DexBackedInstruction31c.java | 62 - .../instruction/DexBackedInstruction31i.java | 50 - .../instruction/DexBackedInstruction31t.java | 49 - .../instruction/DexBackedInstruction32x.java | 49 - .../instruction/DexBackedInstruction35c.java | 90 - .../instruction/DexBackedInstruction35mi.java | 81 - .../instruction/DexBackedInstruction35ms.java | 81 - .../instruction/DexBackedInstruction3rc.java | 70 - .../instruction/DexBackedInstruction3rmi.java | 60 - .../instruction/DexBackedInstruction3rms.java | 60 - .../instruction/DexBackedInstruction51l.java | 49 - .../DexBackedPackedSwitchPayload.java | 83 - .../DexBackedSparseSwitchPayload.java | 81 - .../DexBackedUnknownInstruction.java | 54 - .../raw/AnnotationDirectoryItem.java | 119 -- .../dexlib2/dexbacked/raw/AnnotationItem.java | 90 - .../dexbacked/raw/AnnotationSetItem.java | 76 - .../dexbacked/raw/AnnotationSetRefList.java | 76 - .../dexlib2/dexbacked/raw/ClassDataItem.java | 175 -- .../dexlib2/dexbacked/raw/ClassDefItem.java | 140 -- .../jf/dexlib2/dexbacked/raw/CodeItem.java | 464 ----- .../dexlib2/dexbacked/raw/DebugInfoItem.java | 183 -- .../dexbacked/raw/EncodedArrayItem.java | 56 - .../dexlib2/dexbacked/raw/EncodedValue.java | 167 -- .../jf/dexlib2/dexbacked/raw/FieldIdItem.java | 108 - .../jf/dexlib2/dexbacked/raw/HeaderItem.java | 260 --- .../jf/dexlib2/dexbacked/raw/ItemType.java | 80 - .../org/jf/dexlib2/dexbacked/raw/MapItem.java | 103 - .../dexlib2/dexbacked/raw/MethodIdItem.java | 108 - .../dexlib2/dexbacked/raw/OdexHeaderItem.java | 90 - .../jf/dexlib2/dexbacked/raw/ProtoIdItem.java | 111 -- .../jf/dexlib2/dexbacked/raw/RawDexFile.java | 99 - .../dexbacked/raw/SectionAnnotator.java | 111 -- .../dexlib2/dexbacked/raw/StringDataItem.java | 61 - .../dexlib2/dexbacked/raw/StringIdItem.java | 118 -- .../jf/dexlib2/dexbacked/raw/TypeIdItem.java | 91 - .../dexlib2/dexbacked/raw/TypeListItem.java | 100 - .../dexbacked/raw/util/DexAnnotator.java | 177 -- .../reference/DexBackedFieldReference.java | 66 - .../reference/DexBackedMethodReference.java | 101 - .../reference/DexBackedReference.java | 56 - .../reference/DexBackedStringReference.java | 53 - .../reference/DexBackedTypeReference.java | 52 - .../dexbacked/util/AnnotationsDirectory.java | 241 --- .../jf/dexlib2/dexbacked/util/DebugInfo.java | 264 --- .../dexlib2/dexbacked/util/FixedSizeList.java | 57 - .../dexlib2/dexbacked/util/FixedSizeSet.java | 68 - .../dexbacked/util/ParameterIterator.java | 89 - .../util/StaticInitialValueIterator.java | 85 - .../util/VariableSizeCollection.java | 65 - .../dexbacked/util/VariableSizeIterator.java | 84 - .../dexbacked/util/VariableSizeList.java | 75 - .../util/VariableSizeListIterator.java | 109 - .../util/VariableSizeLookaheadIterator.java | 62 - .../dexbacked/util/VariableSizeSet.java | 65 - .../DexBackedAnnotationEncodedValue.java | 84 - .../value/DexBackedArrayEncodedValue.java | 78 - .../value/DexBackedEncodedValue.java | 154 -- .../value/DexBackedEnumEncodedValue.java | 54 - .../value/DexBackedFieldEncodedValue.java | 54 - .../value/DexBackedMethodEncodedValue.java | 54 - .../value/DexBackedStringEncodedValue.java | 52 - .../value/DexBackedTypeEncodedValue.java | 52 - .../org/jf/dexlib2/iface/Annotatable.java | 49 - .../java/org/jf/dexlib2/iface/Annotation.java | 107 - .../jf/dexlib2/iface/AnnotationElement.java | 92 - .../org/jf/dexlib2/iface/BasicAnnotation.java | 27 - .../java/org/jf/dexlib2/iface/ClassDef.java | 166 -- .../java/org/jf/dexlib2/iface/DexFile.java | 49 - .../jf/dexlib2/iface/ExceptionHandler.java | 103 - .../main/java/org/jf/dexlib2/iface/Field.java | 96 - .../java/org/jf/dexlib2/iface/Member.java | 63 - .../java/org/jf/dexlib2/iface/Method.java | 110 - .../dexlib2/iface/MethodImplementation.java | 86 - .../org/jf/dexlib2/iface/MethodParameter.java | 85 - .../java/org/jf/dexlib2/iface/TryBlock.java | 82 - .../org/jf/dexlib2/iface/debug/DebugItem.java | 54 - .../org/jf/dexlib2/iface/debug/EndLocal.java | 36 - .../jf/dexlib2/iface/debug/EpilogueBegin.java | 35 - .../jf/dexlib2/iface/debug/LineNumber.java | 42 - .../org/jf/dexlib2/iface/debug/LocalInfo.java | 40 - .../jf/dexlib2/iface/debug/PrologueEnd.java | 35 - .../jf/dexlib2/iface/debug/RestartLocal.java | 36 - .../jf/dexlib2/iface/debug/SetSourceFile.java | 41 - .../jf/dexlib2/iface/debug/StartLocal.java | 45 - .../instruction/FieldOffsetInstruction.java | 36 - .../instruction/FiveRegisterInstruction.java | 40 - .../instruction/HatLiteralInstruction.java | 39 - .../instruction/InlineIndexInstruction.java | 36 - .../iface/instruction/Instruction.java | 58 - .../LongHatLiteralInstruction.java | 35 - .../NarrowHatLiteralInstruction.java | 35 - .../instruction/NarrowLiteralInstruction.java | 36 - .../iface/instruction/OffsetInstruction.java | 36 - ...FixedFourParameterRegisterInstruction.java | 47 - .../instruction/OneRegisterInstruction.java | 36 - .../iface/instruction/PayloadInstruction.java | 38 - .../instruction/ReferenceInstruction.java | 41 - .../instruction/RegisterRangeInstruction.java | 36 - .../iface/instruction/SwitchElement.java | 37 - .../iface/instruction/SwitchPayload.java | 39 - .../instruction/ThreeRegisterInstruction.java | 36 - .../instruction/TwoRegisterInstruction.java | 36 - .../VariableRegisterInstruction.java | 36 - .../VerificationErrorInstruction.java | 36 - .../instruction/VtableIndexInstruction.java | 36 - .../instruction/WideLiteralInstruction.java | 36 - .../instruction/formats/ArrayPayload.java | 42 - .../instruction/formats/Instruction10t.java | 37 - .../instruction/formats/Instruction10x.java | 37 - .../instruction/formats/Instruction11n.java | 38 - .../instruction/formats/Instruction11x.java | 37 - .../instruction/formats/Instruction12x.java | 37 - .../instruction/formats/Instruction20bc.java | 38 - .../instruction/formats/Instruction20t.java | 37 - .../instruction/formats/Instruction21c.java | 38 - .../instruction/formats/Instruction21ih.java | 38 - .../instruction/formats/Instruction21lh.java | 38 - .../instruction/formats/Instruction21s.java | 38 - .../instruction/formats/Instruction21t.java | 38 - .../instruction/formats/Instruction22b.java | 38 - .../instruction/formats/Instruction22c.java | 38 - .../instruction/formats/Instruction22cs.java | 38 - .../instruction/formats/Instruction22s.java | 38 - .../instruction/formats/Instruction22t.java | 38 - .../instruction/formats/Instruction22x.java | 37 - .../instruction/formats/Instruction23x.java | 37 - .../instruction/formats/Instruction25x.java | 37 - .../instruction/formats/Instruction30t.java | 37 - .../instruction/formats/Instruction31c.java | 38 - .../instruction/formats/Instruction31i.java | 38 - .../instruction/formats/Instruction31t.java | 38 - .../instruction/formats/Instruction32x.java | 37 - .../instruction/formats/Instruction35c.java | 38 - .../instruction/formats/Instruction35mi.java | 38 - .../instruction/formats/Instruction35ms.java | 38 - .../instruction/formats/Instruction3rc.java | 38 - .../instruction/formats/Instruction3rmi.java | 38 - .../instruction/formats/Instruction3rms.java | 38 - .../instruction/formats/Instruction51l.java | 38 - .../formats/PackedSwitchPayload.java | 37 - .../formats/SparseSwitchPayload.java | 37 - .../formats/UnknownInstruction.java | 36 - .../iface/reference/FieldReference.java | 99 - .../iface/reference/MethodReference.java | 112 -- .../jf/dexlib2/iface/reference/Reference.java | 39 - .../iface/reference/StringReference.java | 86 - .../iface/reference/TypeReference.java | 90 - .../iface/value/AnnotationEncodedValue.java | 100 - .../iface/value/ArrayEncodedValue.java | 84 - .../iface/value/BooleanEncodedValue.java | 83 - .../dexlib2/iface/value/ByteEncodedValue.java | 82 - .../dexlib2/iface/value/CharEncodedValue.java | 82 - .../iface/value/DoubleEncodedValue.java | 89 - .../jf/dexlib2/iface/value/EncodedValue.java | 48 - .../dexlib2/iface/value/EnumEncodedValue.java | 86 - .../iface/value/FieldEncodedValue.java | 84 - .../iface/value/FloatEncodedValue.java | 88 - .../dexlib2/iface/value/IntEncodedValue.java | 82 - .../dexlib2/iface/value/LongEncodedValue.java | 83 - .../iface/value/MethodEncodedValue.java | 84 - .../dexlib2/iface/value/NullEncodedValue.java | 75 - .../iface/value/ShortEncodedValue.java | 82 - .../iface/value/StringEncodedValue.java | 82 - .../dexlib2/iface/value/TypeEncodedValue.java | 82 - .../immutable/ImmutableAnnotation.java | 98 - .../immutable/ImmutableAnnotationElement.java | 92 - .../dexlib2/immutable/ImmutableClassDef.java | 213 -- .../dexlib2/immutable/ImmutableDexFile.java | 62 - .../immutable/ImmutableExceptionHandler.java | 83 - .../jf/dexlib2/immutable/ImmutableField.java | 124 -- .../jf/dexlib2/immutable/ImmutableMethod.java | 132 -- .../ImmutableMethodImplementation.java | 93 - .../immutable/ImmutableMethodParameter.java | 103 - .../dexlib2/immutable/ImmutableTryBlock.java | 102 - .../immutable/debug/ImmutableDebugItem.java | 95 - .../immutable/debug/ImmutableEndLocal.java | 86 - .../debug/ImmutableEpilogueBegin.java | 53 - .../immutable/debug/ImmutableLineNumber.java | 61 - .../immutable/debug/ImmutablePrologueEnd.java | 53 - .../debug/ImmutableRestartLocal.java | 86 - .../debug/ImmutableSetSourceFile.java | 73 - .../immutable/debug/ImmutableStartLocal.java | 106 - .../instruction/ImmutableArrayPayload.java | 81 - .../instruction/ImmutableInstruction.java | 165 -- .../instruction/ImmutableInstruction10t.java | 63 - .../instruction/ImmutableInstruction10x.java | 55 - .../instruction/ImmutableInstruction11n.java | 70 - .../instruction/ImmutableInstruction11x.java | 64 - .../instruction/ImmutableInstruction12x.java | 69 - .../instruction/ImmutableInstruction20bc.java | 74 - .../instruction/ImmutableInstruction20t.java | 63 - .../instruction/ImmutableInstruction21c.java | 73 - .../instruction/ImmutableInstruction21ih.java | 71 - .../instruction/ImmutableInstruction21lh.java | 70 - .../instruction/ImmutableInstruction21s.java | 70 - .../instruction/ImmutableInstruction21t.java | 69 - .../instruction/ImmutableInstruction22b.java | 75 - .../instruction/ImmutableInstruction22c.java | 78 - .../instruction/ImmutableInstruction22cs.java | 74 - .../instruction/ImmutableInstruction22s.java | 75 - .../instruction/ImmutableInstruction22t.java | 74 - .../instruction/ImmutableInstruction22x.java | 69 - .../instruction/ImmutableInstruction23x.java | 74 - .../instruction/ImmutableInstruction25x.java | 97 - .../instruction/ImmutableInstruction30t.java | 63 - .../instruction/ImmutableInstruction31c.java | 73 - .../instruction/ImmutableInstruction31i.java | 70 - .../instruction/ImmutableInstruction31t.java | 70 - .../instruction/ImmutableInstruction32x.java | 69 - .../instruction/ImmutableInstruction35c.java | 98 - .../instruction/ImmutableInstruction35mi.java | 94 - .../instruction/ImmutableInstruction35ms.java | 94 - .../instruction/ImmutableInstruction3rc.java | 80 - .../instruction/ImmutableInstruction3rmi.java | 75 - .../instruction/ImmutableInstruction3rms.java | 75 - .../instruction/ImmutableInstruction51l.java | 69 - .../ImmutableInstructionFactory.java | 223 --- .../ImmutablePackedSwitchPayload.java | 75 - .../ImmutableSparseSwitchPayload.java | 74 - .../instruction/ImmutableSwitchElement.java | 83 - .../ImmutableUnknownInstruction.java | 57 - .../reference/ImmutableFieldReference.java | 66 - .../reference/ImmutableMethodReference.java | 87 - .../reference/ImmutableReference.java | 41 - .../reference/ImmutableReferenceFactory.java | 72 - .../reference/ImmutableStringReference.java | 55 - .../reference/ImmutableTypeReference.java | 78 - .../immutable/util/CharSequenceConverter.java | 62 - .../jf/dexlib2/immutable/util/ParamUtil.java | 90 - .../ImmutableAnnotationEncodedValue.java | 72 - .../value/ImmutableArrayEncodedValue.java | 61 - .../value/ImmutableBooleanEncodedValue.java | 56 - .../value/ImmutableByteEncodedValue.java | 52 - .../value/ImmutableCharEncodedValue.java | 52 - .../value/ImmutableDoubleEncodedValue.java | 52 - .../value/ImmutableEncodedValue.java | 37 - .../value/ImmutableEncodedValueFactory.java | 140 -- .../value/ImmutableEnumEncodedValue.java | 55 - .../value/ImmutableFieldEncodedValue.java | 55 - .../value/ImmutableFloatEncodedValue.java | 52 - .../value/ImmutableIntEncodedValue.java | 52 - .../value/ImmutableLongEncodedValue.java | 52 - .../value/ImmutableMethodEncodedValue.java | 55 - .../value/ImmutableNullEncodedValue.java | 40 - .../value/ImmutableShortEncodedValue.java | 52 - .../value/ImmutableStringEncodedValue.java | 54 - .../value/ImmutableTypeEncodedValue.java | 54 - .../rewriter/AnnotationElementRewriter.java | 66 - .../dexlib2/rewriter/AnnotationRewriter.java | 71 - .../jf/dexlib2/rewriter/ClassDefRewriter.java | 129 -- .../dexlib2/rewriter/DebugItemRewriter.java | 137 -- .../org/jf/dexlib2/rewriter/DexRewriter.java | 136 -- .../rewriter/EncodedValueRewriter.java | 147 -- .../rewriter/ExceptionHandlerRewriter.java | 66 - .../rewriter/FieldReferenceRewriter.java | 69 - .../jf/dexlib2/rewriter/FieldRewriter.java | 85 - .../dexlib2/rewriter/InstructionRewriter.java | 205 -- .../MethodImplementationRewriter.java | 80 - .../rewriter/MethodParameterRewriter.java | 76 - .../rewriter/MethodReferenceRewriter.java | 82 - .../jf/dexlib2/rewriter/MethodRewriter.java | 100 - .../org/jf/dexlib2/rewriter/Rewriter.java | 39 - .../jf/dexlib2/rewriter/RewriterModule.java | 103 - .../jf/dexlib2/rewriter/RewriterUtils.java | 118 -- .../org/jf/dexlib2/rewriter/Rewriters.java | 63 - .../jf/dexlib2/rewriter/TryBlockRewriter.java | 72 - .../org/jf/dexlib2/rewriter/TypeRewriter.java | 40 - .../org/jf/dexlib2/util/AnnotatedBytes.java | 339 ---- .../jf/dexlib2/util/EncodedValueUtils.java | 63 - .../java/org/jf/dexlib2/util/FieldUtil.java | 59 - .../jf/dexlib2/util/InstructionOffsetMap.java | 105 - .../org/jf/dexlib2/util/InstructionUtil.java | 42 - .../java/org/jf/dexlib2/util/MethodUtil.java | 113 -- .../org/jf/dexlib2/util/Preconditions.java | 227 --- .../org/jf/dexlib2/util/ReferenceUtil.java | 148 -- .../jf/dexlib2/util/SyntheticAccessorFSM.java | 564 ------ .../util/SyntheticAccessorResolver.java | 154 -- .../java/org/jf/dexlib2/util/TypeUtils.java | 53 - .../jf/dexlib2/writer/AnnotationSection.java | 45 - .../dexlib2/writer/AnnotationSetSection.java | 42 - .../org/jf/dexlib2/writer/ClassSection.java | 97 - .../org/jf/dexlib2/writer/DebugWriter.java | 163 -- .../org/jf/dexlib2/writer/DexDataWriter.java | 282 --- .../java/org/jf/dexlib2/writer/DexWriter.java | 1271 ------------ .../jf/dexlib2/writer/EncodedValueWriter.java | 149 -- .../org/jf/dexlib2/writer/FieldSection.java | 44 - .../org/jf/dexlib2/writer/IndexSection.java | 41 - .../jf/dexlib2/writer/InstructionFactory.java | 76 - .../jf/dexlib2/writer/InstructionWriter.java | 455 ----- .../org/jf/dexlib2/writer/MethodSection.java | 45 - .../dexlib2/writer/NullableIndexSection.java | 38 - .../dexlib2/writer/NullableOffsetSection.java | 38 - .../org/jf/dexlib2/writer/OffsetSection.java | 41 - .../org/jf/dexlib2/writer/ProtoSection.java | 41 - .../org/jf/dexlib2/writer/StringSection.java | 41 - .../jf/dexlib2/writer/TypeListSection.java | 41 - .../org/jf/dexlib2/writer/TypeSection.java | 41 - .../writer/builder/BuilderAnnotation.java | 64 - .../builder/BuilderAnnotationElement.java | 56 - .../writer/builder/BuilderAnnotationPool.java | 108 - .../writer/builder/BuilderAnnotationSet.java | 60 - .../builder/BuilderAnnotationSetPool.java | 106 - .../writer/builder/BuilderClassDef.java | 136 -- .../writer/builder/BuilderClassPool.java | 446 ----- .../writer/builder/BuilderContext.java | 175 -- .../writer/builder/BuilderEncodedValues.java | 242 --- .../builder/BuilderExceptionHandler.java | 54 - .../dexlib2/writer/builder/BuilderField.java | 80 - .../writer/builder/BuilderFieldPool.java | 107 - .../writer/builder/BuilderFieldReference.java | 72 - .../builder/BuilderMapEntryCollection.java | 89 - .../dexlib2/writer/builder/BuilderMethod.java | 73 - .../builder/BuilderMethodParameter.java | 63 - .../writer/builder/BuilderMethodPool.java | 145 -- .../builder/BuilderMethodReference.java | 76 - .../writer/builder/BuilderProtoPool.java | 145 -- .../writer/builder/BuilderProtoReference.java | 86 - .../writer/builder/BuilderReference.java | 39 - .../writer/builder/BuilderStringPool.java | 89 - .../builder/BuilderStringReference.java | 58 - .../writer/builder/BuilderTryBlock.java | 62 - .../writer/builder/BuilderTypeList.java | 66 - .../writer/builder/BuilderTypeListPool.java | 104 - .../writer/builder/BuilderTypePool.java | 95 - .../writer/builder/BuilderTypeReference.java | 58 - .../jf/dexlib2/writer/builder/DexBuilder.java | 266 --- .../writer/io/DeferredOutputStream.java | 8 - .../io/DeferredOutputStreamFactory.java | 7 - .../jf/dexlib2/writer/io/DexDataStore.java | 12 - .../jf/dexlib2/writer/io/FileDataStore.java | 28 - .../writer/io/FileDeferredOutputStream.java | 104 - .../jf/dexlib2/writer/io/MemoryDataStore.java | 105 - .../writer/io/MemoryDeferredOutputStream.java | 88 - .../dexlib2/writer/pool/AnnotationPool.java | 87 - .../writer/pool/AnnotationSetPool.java | 64 - .../jf/dexlib2/writer/pool/BaseIndexPool.java | 60 - .../writer/pool/BaseNullableOffsetPool.java | 47 - .../dexlib2/writer/pool/BaseOffsetPool.java | 60 - .../org/jf/dexlib2/writer/pool/ClassPool.java | 569 ------ .../org/jf/dexlib2/writer/pool/DexPool.java | 196 -- .../org/jf/dexlib2/writer/pool/FieldPool.java | 74 - .../jf/dexlib2/writer/pool/MethodPool.java | 80 - .../jf/dexlib2/writer/pool/PoolClassDef.java | 135 -- .../jf/dexlib2/writer/pool/PoolMethod.java | 93 - .../org/jf/dexlib2/writer/pool/ProtoPool.java | 134 -- .../jf/dexlib2/writer/pool/StringPool.java | 63 - .../writer/pool/StringTypeBasePool.java | 65 - .../jf/dexlib2/writer/pool/TypeListPool.java | 143 -- .../org/jf/dexlib2/writer/pool/TypePool.java | 69 - .../dexlib2/writer/util/TryListBuilder.java | 367 ---- .../dexlib2/src/main/ragel/Opcodes.rl | 246 --- .../src/main/ragel/SyntheticAccessorFSM.rl | 262 --- .../java/org/jf/dexlib2/AccessorTest.java | 133 -- .../analysis/CommonSuperclassTest.java | 314 --- .../analysis/CustomMethodInlineTableTest.java | 136 -- .../org/jf/dexlib2/analysis/TestUtils.java | 52 - .../analysis/util/SuperclassChainTest.java | 105 - .../org/jf/dexlib2/builder/FixGotoTest.java | 122 -- .../jf/dexlib2/builder/FixOffsetsTest.java | 140 -- .../dexlib2/builder/PayloadAlignmentTest.java | 251 --- .../dexlib2/dexbacked/BaseDexBufferTest.java | 263 --- .../dexbacked/BaseDexReaderLeb128Test.java | 269 --- .../dexbacked/BaseDexReaderSleb128Test.java | 272 --- .../dexlib2/dexbacked/BaseDexReaderTest.java | 437 ---- .../util/InstructionOffsetMapTest.java | 114 -- .../jf/dexlib2/writer/DexDataWriterTest.java | 538 ----- .../dexlib2/writer/DexWriterSleb128Test.java | 251 --- .../org/jf/dexlib2/writer/DexWriterTest.java | 136 -- .../dexlib2/writer/DexWriterUleb128Test.java | 242 --- .../writer/JumboStringConversionTest.java | 218 -- .../writer/util/TryListBuilderTest.java | 566 ------ .../src/test/resources/accessorTest.dex | Bin 28940 -> 0 bytes .../HelloWorldFunctionalInterface.smali | 8 - .../HelloWorldLambda/HelloWorldLambda.smali | 57 - brut.apktool.smali/gradle.properties | 2 - brut.apktool.smali/smali/build.gradle | 129 -- .../smali/src/main/antlr/smaliParser.g | 1145 ----------- .../smali/src/main/antlr/smaliTreeWalker.g | 1362 ------------- .../main/java/org/jf/smali/InvalidToken.java | 51 - .../org/jf/smali/LexerErrorInterface.java | 48 - .../main/java/org/jf/smali/LiteralTools.java | 417 ---- .../jf/smali/OdexedInstructionException.java | 46 - .../java/org/jf/smali/SemanticException.java | 74 - .../org/jf/smali/SmaliMethodParameter.java | 67 - .../java/org/jf/smali/SmaliTestUtils.java | 102 - .../main/java/org/jf/smali/WithRegister.java | 36 - .../src/main/java/org/jf/smali/main.java | 505 ----- .../smali/src/main/jflex/smaliLexer.jflex | 659 ------ .../smali/src/main/resources/smali.properties | 1 - .../org/jf/smali/expectedTokensTestGrammar.g | 153 -- .../smali/src/test/java/ByteLiteralTest.java | 140 -- .../src/test/java/ImplicitReferenceTest.java | 242 --- .../smali/src/test/java/IntLiteralTest.java | 144 -- .../smali/src/test/java/LexerTest.java | 219 -- .../smali/src/test/java/LongLiteralTest.java | 133 -- .../smali/src/test/java/ShortLiteralTest.java | 140 -- .../test/resources/LexerTest/.gitattributes | 2 - .../resources/LexerTest/ByteLiteralTest.smali | 47 - .../LexerTest/ByteLiteralTest.tokens | 47 - .../resources/LexerTest/CharLiteralTest.smali | 40 - .../LexerTest/CharLiteralTest.tokens | 40 - .../resources/LexerTest/CommentTest.smali | 6 - .../resources/LexerTest/CommentTest.tokens | 6 - .../resources/LexerTest/DirectiveTest.smali | 58 - .../resources/LexerTest/DirectiveTest.tokens | 66 - .../LexerTest/FloatLiteralTest.smali | 242 --- .../LexerTest/FloatLiteralTest.tokens | 241 --- .../resources/LexerTest/InstructionTest.smali | 234 --- .../LexerTest/InstructionTest.tokens | 234 --- .../LexerTest/IntegerLiteralTest.smali | 45 - .../LexerTest/IntegerLiteralTest.tokens | 45 - .../resources/LexerTest/LongLiteralTest.smali | 48 - .../LexerTest/LongLiteralTest.tokens | 48 - .../test/resources/LexerTest/MiscTest.smali | 78 - .../test/resources/LexerTest/MiscTest.tokens | 78 - .../LexerTest/RealSmaliFileTest.smali | 294 --- .../LexerTest/RealSmaliFileTest.tokens | 804 -------- .../LexerTest/ShortLiteralTest.smali | 49 - .../LexerTest/ShortLiteralTest.tokens | 49 - .../LexerTest/StringLiteralTest.smali | 43 - .../LexerTest/StringLiteralTest.tokens | 43 - .../test/resources/LexerTest/SymbolTest.smali | 19 - .../resources/LexerTest/SymbolTest.tokens | 12 - .../LexerTest/TypeAndIdentifierTest.smali | 52 - .../LexerTest/TypeAndIdentifierTest.tokens | 95 - brut.apktool.smali/util/build.gradle | 37 - .../util/AbstractForwardSequentialList.java | 118 -- .../org/jf/util/AbstractListIterator.java | 81 - .../main/java/org/jf/util/AlignmentUtils.java | 41 - .../main/java/org/jf/util/ArraySortedSet.java | 198 -- .../main/java/org/jf/util/BitSetUtils.java | 44 - .../java/org/jf/util/CharSequenceUtils.java | 51 - .../org/jf/util/ClassFileNameHandler.java | 452 ----- .../java/org/jf/util/CollectionUtils.java | 224 --- .../main/java/org/jf/util/ConsoleUtil.java | 110 - .../org/jf/util/ExceptionWithContext.java | 164 -- .../util/src/main/java/org/jf/util/Hex.java | 315 --- .../java/org/jf/util/ImmutableConverter.java | 160 -- .../main/java/org/jf/util/ImmutableUtils.java | 62 - .../java/org/jf/util/IndentingWriter.java | 244 --- .../main/java/org/jf/util/LinearSearch.java | 85 - .../jf/util/NakedByteArrayOutputStream.java | 44 - .../main/java/org/jf/util/NibbleUtils.java | 74 - .../main/java/org/jf/util/NumberUtils.java | 141 -- .../src/main/java/org/jf/util/PathUtil.java | 125 -- .../jf/util/RandomAccessFileInputStream.java | 81 - .../jf/util/RandomAccessFileOutputStream.java | 65 - .../java/org/jf/util/SmaliHelpFormatter.java | 47 - .../main/java/org/jf/util/SparseArray.java | 373 ---- .../main/java/org/jf/util/SparseIntArray.java | 268 --- .../main/java/org/jf/util/StringUtils.java | 116 -- .../main/java/org/jf/util/StringWrapper.java | 106 - .../src/main/java/org/jf/util/TextUtils.java | 82 - .../java/org/jf/util/TwoColumnOutput.java | 155 -- .../src/main/java/org/jf/util/Utf8Utils.java | 286 --- .../org/jf/util/WrappedIndentingWriter.java | 184 -- .../AbstractForwardSequentialListTest.java | 214 -- .../org/jf/util/ClassFileNameHandlerTest.java | 245 --- .../java/org/jf/util/IndentingWriterTest.java | 51 - .../java/org/jf/util/LinearSearchTest.java | 101 - .../java/org/jf/util/NumberUtilsTest.java | 128 -- .../test/java/org/jf/util/PathUtilTest.java | 269 --- .../java/org/jf/util/StringWrapperTest.java | 118 -- .../test/java/org/jf/util/TextUtilsTest.java | 53 - 723 files changed, 75739 deletions(-) delete mode 100644 brut.apktool.smali/.gitignore delete mode 100644 brut.apktool.smali/NOTICE-SMALI delete mode 100644 brut.apktool.smali/baksmali/build.gradle delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/AnnotationFormatter.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/BlankMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CatchMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentedOutMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentingIndentingWriter.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/BeginEpilogueMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/DebugMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/EndLocalMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/EndPrologueMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/LineNumberMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/LocalFormatter.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/RestartLocalMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/SetSourceFileMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/StartLocalMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/AnnotationEncodedValueAdaptor.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/ArrayEncodedValueAdaptor.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/EncodedValueAdaptor.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EndTryLabelMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/FieldDefinition.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/ArrayDataMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/PackedSwitchMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/SparseSwitchMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/UnresolvedOdexInstructionMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/LabelMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/PostInstructionRegisterInfoMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/PreInstructionRegisterInfoMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/ReferenceFormatter.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/RegisterFormatter.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/SyntheticAccessCommentMethodItem.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/BooleanRenderer.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/ByteRenderer.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/CharRenderer.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/DoubleRenderer.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/FloatRenderer.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/IntegerRenderer.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/LongRenderer.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/ShortRenderer.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmali.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmaliOptions.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/dump.java delete mode 100644 brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/main.java delete mode 100644 brut.apktool.smali/baksmali/src/main/resources/baksmali.properties delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/AnalysisTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/BaksmaliTestUtils.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/DisassemblyTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/IdenticalRoundtripTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/ImplicitReferenceTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/InterfaceOrderTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/LambdaTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/ManyRegistersTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/MultiSwitchTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/RoundtripTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/SwitchTest.java delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/ConstructorTest.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/ConstructorTest2.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/classes.dex delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateDirectMethods.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateDirectVirtualMethods.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateInstanceFields.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateStaticFields.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateStaticInstanceFields.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateVirtualMethods.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/classes.dex delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/src/DuplicateDirectMethods.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/src/DuplicateDirectVirtualMethods.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/src/DuplicateInstanceFields.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/src/DuplicateStaticFields.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/src/DuplicateStaticInstanceFields.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/src/DuplicateVirtualMethods.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/src/README delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/InterfaceOrderTest/InterfaceOrder.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/LambdaTest/HelloWorldLambda.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/LocalTest/LocalTest.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/LocalTest/classes.dex delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/ManyRegistersTest/ManyRegisters.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/MultiSwitchTest/MultiSwitchInput.dex delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/MultiSwitchTest/MultiSwitchInput.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/MultiSwitchTest/MultiSwitchOutput.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/MultipleStartInstructionsTest/MultipleStartInstructionsTest.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/MultipleStartInstructionsTest/classes.dex delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/RegisterEqualityOnMergeTest/RegisterEqualityOnMerge.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/RegisterEqualityOnMergeTest/classes.dex delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchInput.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchOutput.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/UninitRefIdentityTest/UninitRefIdentityTest.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/resources/UninitRefIdentityTest/classes.dex delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/baksmali_test_class.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test1/main.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test1/randomclass.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test1/subclass.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test1/superclass.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test2/app_classes/main.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/randomclass.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/subclass1.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/subclass2.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/superclass.smali delete mode 100644 brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/supersuperclass.smali delete mode 100644 brut.apktool.smali/build.gradle delete mode 100644 brut.apktool.smali/dexlib2/accessorTestGenerator/build.gradle delete mode 100644 brut.apktool.smali/dexlib2/accessorTestGenerator/src/main/java/org/jf/dexlib2/AccessorTestGenerator.java delete mode 100644 brut.apktool.smali/dexlib2/accessorTestGenerator/src/main/resources/AccessorTest.stg delete mode 100644 brut.apktool.smali/dexlib2/build.gradle delete mode 100644 brut.apktool.smali/dexlib2/src/accessorTest/java/org/jf/dexlib2/AccessorTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/AccessFlags.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/AnnotationVisibility.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DebugItemType.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Format.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Opcode.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/ReferenceType.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/ValueType.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/VerificationError.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/AnalysisException.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/AnalyzedInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ArrayProto.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ClassPath.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ClassProto.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/CustomInlineMethodResolver.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/DumpFields.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/DumpVtables.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/InlineMethodResolver.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/MethodAnalyzer.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/OdexedFieldInstructionMapper.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/PrimitiveProto.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/RegisterType.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/TypeProto.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnknownClassProto.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnresolvedClassException.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnresolvedOdexInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionClassDef.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionConstructor.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionField.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionMethod.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/util/ReflectionUtils.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/util/TypeProtoUtils.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseAnnotation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseAnnotationElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseExceptionHandler.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseMethodParameter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseTryBlock.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseFieldReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseMethodReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseStringReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseTypeReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseAnnotationEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseArrayEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseBooleanEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseByteEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseCharEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseDoubleEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseEnumEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseFieldEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseFloatEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseIntEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseLongEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseMethodEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseNullEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseShortEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseStringEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseTypeEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderDebugItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderExceptionHandler.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderOffsetInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderTryBlock.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/Label.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodImplementationBuilder.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodLocation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/SwitchLabelElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/debug/BuilderEndLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/debug/BuilderEpilogueBegin.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/debug/BuilderLineNumber.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/debug/BuilderPrologueEnd.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/debug/BuilderRestartLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/debug/BuilderSetSourceFile.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/debug/BuilderStartLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderArrayPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction10t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction10x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction11n.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction11x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction12x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction20bc.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction20t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction21c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction21ih.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction21lh.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction21s.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction21t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction22b.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction22c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction22s.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction22t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction22x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction23x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction25x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction30t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction31c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction31i.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction31t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction32x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction35c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction3rc.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderInstruction51l.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderPackedSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderSparseSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/instruction/BuilderSwitchElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/BaseDexBuffer.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/BaseDexReader.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedAnnotation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedAnnotationElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedCatchAllExceptionHandler.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedClassDef.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedDexFile.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedExceptionHandler.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedField.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedMethod.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedMethodImplementation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedOdexFile.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedTryBlock.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedTypedExceptionHandler.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexReader.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedArrayPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction10t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction10x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction11n.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction11x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction12x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction20bc.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction20t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction21c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction21ih.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction21lh.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction21s.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction21t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction22b.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction22c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction22cs.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction22s.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction22t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction22x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction23x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction25x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction30t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction31c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction31i.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction31t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction32x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction35c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction35mi.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction35ms.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction3rc.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction3rmi.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction3rms.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction51l.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedPackedSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedSparseSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedUnknownInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/AnnotationDirectoryItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/AnnotationItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/AnnotationSetItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/AnnotationSetRefList.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/ClassDataItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/ClassDefItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/CodeItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/DebugInfoItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/EncodedArrayItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/EncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/FieldIdItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/HeaderItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/ItemType.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/MapItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/MethodIdItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/OdexHeaderItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/ProtoIdItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/RawDexFile.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/SectionAnnotator.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/StringDataItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/StringIdItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/TypeIdItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/TypeListItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/util/DexAnnotator.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/reference/DexBackedFieldReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/reference/DexBackedMethodReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/reference/DexBackedReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/reference/DexBackedStringReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/reference/DexBackedTypeReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/AnnotationsDirectory.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/DebugInfo.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/FixedSizeList.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/FixedSizeSet.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/ParameterIterator.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/StaticInitialValueIterator.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/VariableSizeCollection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/VariableSizeIterator.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/VariableSizeList.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/VariableSizeListIterator.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/VariableSizeLookaheadIterator.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/util/VariableSizeSet.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedAnnotationEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedArrayEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedEnumEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedFieldEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedMethodEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedStringEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedTypeEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/Annotatable.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/Annotation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/AnnotationElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/BasicAnnotation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/ClassDef.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/DexFile.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/ExceptionHandler.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/Field.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/Member.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/Method.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/MethodImplementation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/MethodParameter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/TryBlock.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/DebugItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/EndLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/EpilogueBegin.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/LineNumber.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/LocalInfo.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/PrologueEnd.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/RestartLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/SetSourceFile.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/debug/StartLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/FieldOffsetInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/FiveRegisterInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/HatLiteralInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/InlineIndexInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/Instruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/LongHatLiteralInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/NarrowHatLiteralInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/NarrowLiteralInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/OffsetInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/OneFixedFourParameterRegisterInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/OneRegisterInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/PayloadInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/ReferenceInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/RegisterRangeInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/SwitchElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/SwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/ThreeRegisterInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/TwoRegisterInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/VariableRegisterInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/VerificationErrorInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/VtableIndexInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/WideLiteralInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/ArrayPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction10t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction10x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction11n.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction11x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction12x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction20bc.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction20t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction21c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction21ih.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction21lh.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction21s.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction21t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction22b.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction22c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction22cs.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction22s.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction22t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction22x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction23x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction25x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction30t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction31c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction31i.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction31t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction32x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction35c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction35mi.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction35ms.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction3rc.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction3rmi.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction3rms.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/Instruction51l.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/PackedSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/SparseSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/instruction/formats/UnknownInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/reference/FieldReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/reference/MethodReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/reference/Reference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/reference/StringReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/reference/TypeReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/AnnotationEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/ArrayEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/BooleanEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/ByteEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/CharEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/DoubleEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/EncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/EnumEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/FieldEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/FloatEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/IntEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/LongEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/MethodEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/NullEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/ShortEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/StringEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/iface/value/TypeEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableAnnotation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableAnnotationElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableClassDef.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableDexFile.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableExceptionHandler.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableField.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableMethod.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableMethodImplementation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableMethodParameter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableTryBlock.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/debug/ImmutableDebugItem.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/debug/ImmutableEndLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/debug/ImmutableEpilogueBegin.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/debug/ImmutableLineNumber.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/debug/ImmutablePrologueEnd.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/debug/ImmutableRestartLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/debug/ImmutableSetSourceFile.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/debug/ImmutableStartLocal.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableArrayPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction10t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction10x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction11n.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction11x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction12x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction20bc.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction20t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction21c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction21ih.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction21lh.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction21s.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction21t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction22b.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction22c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction22cs.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction22s.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction22t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction22x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction23x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction25x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction30t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction31c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction31i.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction31t.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction32x.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction35c.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction35mi.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction35ms.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction3rc.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction3rmi.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction3rms.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstruction51l.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableInstructionFactory.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutablePackedSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableSparseSwitchPayload.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableSwitchElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/instruction/ImmutableUnknownInstruction.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/reference/ImmutableFieldReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/reference/ImmutableMethodReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/reference/ImmutableReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/reference/ImmutableReferenceFactory.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/reference/ImmutableStringReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/reference/ImmutableTypeReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/util/CharSequenceConverter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/util/ParamUtil.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableAnnotationEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableArrayEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableBooleanEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableByteEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableCharEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableDoubleEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableEncodedValueFactory.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableEnumEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableFieldEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableFloatEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableIntEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableLongEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableMethodEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableNullEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableShortEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableStringEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableTypeEncodedValue.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/AnnotationElementRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/AnnotationRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/ClassDefRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/DebugItemRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/DexRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/EncodedValueRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/ExceptionHandlerRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/FieldReferenceRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/FieldRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/MethodImplementationRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/MethodParameterRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/MethodReferenceRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/MethodRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/Rewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/RewriterModule.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/RewriterUtils.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/Rewriters.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/TryBlockRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/TypeRewriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/AnnotatedBytes.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/EncodedValueUtils.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/FieldUtil.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/InstructionOffsetMap.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/InstructionUtil.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/MethodUtil.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/Preconditions.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/ReferenceUtil.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/SyntheticAccessorFSM.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/SyntheticAccessorResolver.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/util/TypeUtils.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/AnnotationSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/AnnotationSetSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/ClassSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/DebugWriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/DexDataWriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/EncodedValueWriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/FieldSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/IndexSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/InstructionFactory.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/InstructionWriter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/MethodSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/NullableIndexSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/NullableOffsetSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/OffsetSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/ProtoSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/StringSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/TypeListSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/TypeSection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderAnnotation.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderAnnotationElement.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderAnnotationPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderAnnotationSet.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderAnnotationSetPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderClassDef.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderClassPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderContext.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderEncodedValues.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderExceptionHandler.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderField.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderFieldPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderFieldReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderMapEntryCollection.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderMethod.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderMethodParameter.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderMethodPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderMethodReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderProtoPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderProtoReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderStringPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderStringReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderTryBlock.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderTypeList.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderTypeListPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderTypePool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderTypeReference.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/DexBuilder.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/io/DeferredOutputStream.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/io/DeferredOutputStreamFactory.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/io/DexDataStore.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/io/FileDataStore.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/io/FileDeferredOutputStream.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/io/MemoryDataStore.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/io/MemoryDeferredOutputStream.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/AnnotationPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/AnnotationSetPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/BaseIndexPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/BaseNullableOffsetPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/BaseOffsetPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/ClassPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/DexPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/FieldPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/MethodPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/PoolClassDef.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/PoolMethod.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/ProtoPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/StringPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/StringTypeBasePool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/TypeListPool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/pool/TypePool.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/writer/util/TryListBuilder.java delete mode 100644 brut.apktool.smali/dexlib2/src/main/ragel/Opcodes.rl delete mode 100644 brut.apktool.smali/dexlib2/src/main/ragel/SyntheticAccessorFSM.rl delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/AccessorTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/analysis/CommonSuperclassTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/analysis/CustomMethodInlineTableTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/analysis/TestUtils.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/analysis/util/SuperclassChainTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/builder/FixGotoTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/builder/FixOffsetsTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/builder/PayloadAlignmentTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/dexbacked/BaseDexBufferTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/dexbacked/BaseDexReaderLeb128Test.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/dexbacked/BaseDexReaderSleb128Test.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/dexbacked/BaseDexReaderTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/util/InstructionOffsetMapTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/writer/DexDataWriterTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/writer/DexWriterSleb128Test.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/writer/DexWriterTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/writer/DexWriterUleb128Test.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/writer/JumboStringConversionTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/java/org/jf/dexlib2/writer/util/TryListBuilderTest.java delete mode 100644 brut.apktool.smali/dexlib2/src/test/resources/accessorTest.dex delete mode 100644 brut.apktool.smali/examples/HelloWorldLambda/HelloWorldFunctionalInterface.smali delete mode 100644 brut.apktool.smali/examples/HelloWorldLambda/HelloWorldLambda.smali delete mode 100644 brut.apktool.smali/gradle.properties delete mode 100644 brut.apktool.smali/smali/build.gradle delete mode 100644 brut.apktool.smali/smali/src/main/antlr/smaliParser.g delete mode 100644 brut.apktool.smali/smali/src/main/antlr/smaliTreeWalker.g delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/InvalidToken.java delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/LexerErrorInterface.java delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/LiteralTools.java delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/OdexedInstructionException.java delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/SemanticException.java delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/SmaliMethodParameter.java delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/SmaliTestUtils.java delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/WithRegister.java delete mode 100644 brut.apktool.smali/smali/src/main/java/org/jf/smali/main.java delete mode 100644 brut.apktool.smali/smali/src/main/jflex/smaliLexer.jflex delete mode 100644 brut.apktool.smali/smali/src/main/resources/smali.properties delete mode 100644 brut.apktool.smali/smali/src/test/antlr/org/jf/smali/expectedTokensTestGrammar.g delete mode 100644 brut.apktool.smali/smali/src/test/java/ByteLiteralTest.java delete mode 100644 brut.apktool.smali/smali/src/test/java/ImplicitReferenceTest.java delete mode 100644 brut.apktool.smali/smali/src/test/java/IntLiteralTest.java delete mode 100644 brut.apktool.smali/smali/src/test/java/LexerTest.java delete mode 100644 brut.apktool.smali/smali/src/test/java/LongLiteralTest.java delete mode 100644 brut.apktool.smali/smali/src/test/java/ShortLiteralTest.java delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/.gitattributes delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/ByteLiteralTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/ByteLiteralTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/CharLiteralTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/CharLiteralTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/CommentTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/CommentTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/DirectiveTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/DirectiveTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/FloatLiteralTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/FloatLiteralTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/InstructionTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/InstructionTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/IntegerLiteralTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/IntegerLiteralTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/LongLiteralTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/LongLiteralTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/MiscTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/MiscTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/RealSmaliFileTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/RealSmaliFileTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/ShortLiteralTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/ShortLiteralTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/StringLiteralTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/StringLiteralTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/SymbolTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/SymbolTest.tokens delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/TypeAndIdentifierTest.smali delete mode 100644 brut.apktool.smali/smali/src/test/resources/LexerTest/TypeAndIdentifierTest.tokens delete mode 100644 brut.apktool.smali/util/build.gradle delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/AbstractForwardSequentialList.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/AbstractListIterator.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/AlignmentUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/ArraySortedSet.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/BitSetUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/CharSequenceUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/ClassFileNameHandler.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/CollectionUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/ConsoleUtil.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/ExceptionWithContext.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/Hex.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/ImmutableConverter.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/ImmutableUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/IndentingWriter.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/LinearSearch.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/NakedByteArrayOutputStream.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/NibbleUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/NumberUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/PathUtil.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/RandomAccessFileInputStream.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/RandomAccessFileOutputStream.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/SmaliHelpFormatter.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/SparseArray.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/SparseIntArray.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/StringUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/StringWrapper.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/TextUtils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/TwoColumnOutput.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/Utf8Utils.java delete mode 100644 brut.apktool.smali/util/src/main/java/org/jf/util/WrappedIndentingWriter.java delete mode 100644 brut.apktool.smali/util/src/test/java/org/jf/util/AbstractForwardSequentialListTest.java delete mode 100644 brut.apktool.smali/util/src/test/java/org/jf/util/ClassFileNameHandlerTest.java delete mode 100644 brut.apktool.smali/util/src/test/java/org/jf/util/IndentingWriterTest.java delete mode 100644 brut.apktool.smali/util/src/test/java/org/jf/util/LinearSearchTest.java delete mode 100644 brut.apktool.smali/util/src/test/java/org/jf/util/NumberUtilsTest.java delete mode 100644 brut.apktool.smali/util/src/test/java/org/jf/util/PathUtilTest.java delete mode 100644 brut.apktool.smali/util/src/test/java/org/jf/util/StringWrapperTest.java delete mode 100644 brut.apktool.smali/util/src/test/java/org/jf/util/TextUtilsTest.java diff --git a/brut.apktool.smali/.gitignore b/brut.apktool.smali/.gitignore deleted file mode 100644 index be4d8cad..00000000 --- a/brut.apktool.smali/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/baksmali/target/ -/dexlib/target/ -/maven-smali-plugin/target/ -/smali/target/ -/util/target/ -*~ diff --git a/brut.apktool.smali/NOTICE-SMALI b/brut.apktool.smali/NOTICE-SMALI deleted file mode 100644 index c0885794..00000000 --- a/brut.apktool.smali/NOTICE-SMALI +++ /dev/null @@ -1,49 +0,0 @@ -The majority of smali/baksmali is written and copyrighted by me (Ben Gruver) -and released under the following license: - -******************************************************************************* -Copyright (c) 2010 Ben Gruver (JesusFreke) -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -******************************************************************************* - - -Various portions of the code are taken from the Android Open Source Project, -and are used in accordance with the following license: - -******************************************************************************* -Copyright (C) 2007 The Android Open Source Project - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -******************************************************************************* \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/build.gradle b/brut.apktool.smali/baksmali/build.gradle deleted file mode 100644 index 0a1ad665..00000000 --- a/brut.apktool.smali/baksmali/build.gradle +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath depends.proguard_gradle - } -} - -dependencies { - compile project(':brut.apktool.smali:util') - compile project(':brut.apktool.smali:dexlib2') - compile depends.commons_cli - compile depends.guava - - testCompile depends.junit - testCompile project(':brut.apktool.smali:smali') -} - -processResources.inputs.property('version', version) -processResources.expand('version': version) - -// build a jar containing all dependencies -task fatJar (type: Jar) { - from sourceSets.main.output - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } - - manifest { - attributes('Main-Class': 'org.jf.baksmali.main') - } -} - -tasks.getByPath('build').dependsOn(fatJar) - -task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) { - def outFile = fatJar.destinationDir.getPath() + '/' + fatJar.baseName + '-' + fatJar.version + '-small' + '.' + fatJar.extension - - injars fatJar.archivePath - outjars outFile - - libraryjars "${System.properties['java.home']}/lib/rt.jar" - - dontobfuscate - dontoptimize - - keep 'public class org.jf.baksmali.main { public static void main(java.lang.String[]); }' - keepclassmembers 'enum * { public static **[] values(); public static ** valueOf(java.lang.String); }' - - dontwarn 'com.google.common.**' - dontnote 'com.google.common.**' -} - -tasks.getByPath(':release').dependsOn(proguard) diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/AnnotationFormatter.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/AnnotationFormatter.java deleted file mode 100644 index 1310f191..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/AnnotationFormatter.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.baksmali.Adaptors.EncodedValue.AnnotationEncodedValueAdaptor; -import org.jf.dexlib2.AnnotationVisibility; -import org.jf.dexlib2.iface.Annotation; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; -import java.util.Collection; - -public class AnnotationFormatter { - - public static void writeTo(@Nonnull IndentingWriter writer, - @Nonnull Collection annotations, - @Nullable String containingClass) throws IOException { - boolean first = true; - for (Annotation annotation: annotations) { - if (!first) { - writer.write('\n'); - } - first = false; - - writeTo(writer, annotation, containingClass); - } - } - - public static void writeTo(@Nonnull IndentingWriter writer, @Nonnull Annotation annotation, - @Nullable String containingClass) throws IOException { - writer.write(".annotation "); - writer.write(AnnotationVisibility.getVisibility(annotation.getVisibility())); - writer.write(' '); - writer.write(annotation.getType()); - writer.write('\n'); - - AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotation.getElements(), containingClass); - - writer.write(".end annotation\n"); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/BlankMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/BlankMethodItem.java deleted file mode 100644 index d0078493..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/BlankMethodItem.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.util.IndentingWriter; - -//a "spacer" between instructions -public class BlankMethodItem extends MethodItem { - public BlankMethodItem(int codeAddress) { - super(codeAddress); - } - - public double getSortOrder() { - return Integer.MAX_VALUE; - } - - public boolean writeTo(IndentingWriter writer) { - //we didn't technically print something, but returning true indicates that a newline should be printed - //after this method item, which is the intended functionality - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CatchMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CatchMethodItem.java deleted file mode 100644 index 6c67d4ac..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CatchMethodItem.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.baksmali.baksmaliOptions; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; - -public class CatchMethodItem extends MethodItem { - private final String exceptionType; - - private final LabelMethodItem tryStartLabel; - private final LabelMethodItem tryEndLabel; - private final LabelMethodItem handlerLabel; - - public CatchMethodItem(@Nonnull baksmaliOptions options, @Nonnull MethodDefinition.LabelCache labelCache, - int codeAddress, @Nullable String exceptionType, int startAddress, int endAddress, - int handlerAddress) { - super(codeAddress); - this.exceptionType = exceptionType; - - tryStartLabel = labelCache.internLabel(new LabelMethodItem(options, startAddress, "try_start_")); - - //use the address from the last covered instruction, but make the label - //name refer to the address of the next instruction - tryEndLabel = labelCache.internLabel(new EndTryLabelMethodItem(options, codeAddress, endAddress)); - - if (exceptionType == null) { - handlerLabel = labelCache.internLabel(new LabelMethodItem(options, handlerAddress, "catchall_")); - } else { - handlerLabel = labelCache.internLabel(new LabelMethodItem(options, handlerAddress, "catch_")); - } - } - - public LabelMethodItem getTryStartLabel() { - return tryStartLabel; - } - - public LabelMethodItem getTryEndLabel() { - return tryEndLabel; - } - - public LabelMethodItem getHandlerLabel() { - return handlerLabel; - } - - public double getSortOrder() { - //sort after instruction and end_try label - return 102; - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - if (exceptionType == null) { - writer.write(".catchall"); - } else { - writer.write(".catch "); - writer.write(exceptionType); - } - writer.write(" {"); - tryStartLabel.writeTo(writer); - writer.write(" .. "); - tryEndLabel.writeTo(writer); - writer.write("} "); - handlerLabel.writeTo(writer); - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java deleted file mode 100644 index 2529af8a..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import com.google.common.collect.Lists; -import org.jf.baksmali.baksmaliOptions; -import org.jf.dexlib2.AccessFlags; -import org.jf.dexlib2.dexbacked.DexBackedClassDef; -import org.jf.dexlib2.dexbacked.DexBackedDexFile.InvalidItemIndex; -import org.jf.dexlib2.iface.*; -import org.jf.dexlib2.iface.instruction.Instruction; -import org.jf.dexlib2.iface.instruction.formats.Instruction21c; -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.util.ReferenceUtil; -import org.jf.util.IndentingWriter; -import org.jf.util.StringUtils; - -import javax.annotation.Nonnull; -import java.io.IOException; -import java.util.*; - -public class ClassDefinition { - @Nonnull public final baksmaliOptions options; - @Nonnull public final ClassDef classDef; - @Nonnull private final HashSet fieldsSetInStaticConstructor; - - protected boolean validationErrors; - - public ClassDefinition(@Nonnull baksmaliOptions options, @Nonnull ClassDef classDef) { - this.options = options; - this.classDef = classDef; - fieldsSetInStaticConstructor = findFieldsSetInStaticConstructor(); - } - - public boolean hadValidationErrors() { - return validationErrors; - } - - @Nonnull - private HashSet findFieldsSetInStaticConstructor() { - HashSet fieldsSetInStaticConstructor = new HashSet(); - - for (Method method: classDef.getDirectMethods()) { - if (method.getName().equals("")) { - MethodImplementation impl = method.getImplementation(); - if (impl != null) { - for (Instruction instruction: impl.getInstructions()) { - switch (instruction.getOpcode()) { - case SPUT: - case SPUT_BOOLEAN: - case SPUT_BYTE: - case SPUT_CHAR: - case SPUT_OBJECT: - case SPUT_SHORT: - case SPUT_WIDE: { - Instruction21c ins = (Instruction21c)instruction; - FieldReference fieldRef = null; - try { - fieldRef = (FieldReference)ins.getReference(); - } catch (InvalidItemIndex ex) { - // just ignore it for now. We'll deal with it later, when processing the instructions - // themselves - } - if (fieldRef != null && - fieldRef.getDefiningClass().equals((classDef.getType()))) { - fieldsSetInStaticConstructor.add(ReferenceUtil.getShortFieldDescriptor(fieldRef)); - } - break; - } - } - } - } - } - } - return fieldsSetInStaticConstructor; - } - - public void writeTo(IndentingWriter writer) throws IOException { - writeClass(writer); - writeSuper(writer); - writeSourceFile(writer); - writeInterfaces(writer); - writeAnnotations(writer); - Set staticFields = writeStaticFields(writer); - writeInstanceFields(writer, staticFields); - Set directMethods = writeDirectMethods(writer); - writeVirtualMethods(writer, directMethods); - } - - private void writeClass(IndentingWriter writer) throws IOException { - writer.write(".class "); - writeAccessFlags(writer); - writer.write(classDef.getType()); - writer.write('\n'); - } - - private void writeAccessFlags(IndentingWriter writer) throws IOException { - for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForClass(classDef.getAccessFlags())) { - writer.write(accessFlag.toString()); - writer.write(' '); - } - } - - private void writeSuper(IndentingWriter writer) throws IOException { - String superClass = classDef.getSuperclass(); - if (superClass != null) { - writer.write(".super "); - writer.write(superClass); - writer.write('\n'); - } - } - - private void writeSourceFile(IndentingWriter writer) throws IOException { - String sourceFile = classDef.getSourceFile(); - if (sourceFile != null) { - writer.write(".source \""); - StringUtils.writeEscapedString(writer, sourceFile); - writer.write("\"\n"); - } - } - - private void writeInterfaces(IndentingWriter writer) throws IOException { - List interfaces = classDef.getInterfaces(); - - if (interfaces.size() != 0) { - writer.write('\n'); - writer.write("# interfaces\n"); - for (String interfaceName: interfaces) { - writer.write(".implements "); - writer.write(interfaceName); - writer.write('\n'); - } - } - } - - private void writeAnnotations(IndentingWriter writer) throws IOException { - Collection classAnnotations = classDef.getAnnotations(); - if (classAnnotations.size() != 0) { - writer.write("\n\n"); - writer.write("# annotations\n"); - - String containingClass = null; - if (options.useImplicitReferences) { - containingClass = classDef.getType(); - } - - AnnotationFormatter.writeTo(writer, classAnnotations, containingClass); - } - } - - private Set writeStaticFields(IndentingWriter writer) throws IOException { - boolean wroteHeader = false; - Set writtenFields = new HashSet(); - - Iterable staticFields; - if (classDef instanceof DexBackedClassDef) { - staticFields = ((DexBackedClassDef)classDef).getStaticFields(false); - } else { - staticFields = classDef.getStaticFields(); - } - - for (Field field: staticFields) { - if (!wroteHeader) { - writer.write("\n\n"); - writer.write("# static fields"); - wroteHeader = true; - } - writer.write('\n'); - - boolean setInStaticConstructor; - IndentingWriter fieldWriter = writer; - String fieldString = ReferenceUtil.getShortFieldDescriptor(field); - if (!writtenFields.add(fieldString)) { - writer.write("# duplicate field ignored\n"); - fieldWriter = new CommentingIndentingWriter(writer); - System.err.println(String.format("Ignoring duplicate field: %s->%s", classDef.getType(), fieldString)); - setInStaticConstructor = false; - } else { - setInStaticConstructor = fieldsSetInStaticConstructor.contains(fieldString); - } - FieldDefinition.writeTo(options, fieldWriter, field, setInStaticConstructor); - } - return writtenFields; - } - - private void writeInstanceFields(IndentingWriter writer, Set staticFields) throws IOException { - boolean wroteHeader = false; - Set writtenFields = new HashSet(); - - Iterable instanceFields; - if (classDef instanceof DexBackedClassDef) { - instanceFields = ((DexBackedClassDef)classDef).getInstanceFields(false); - } else { - instanceFields = classDef.getInstanceFields(); - } - - for (Field field: instanceFields) { - if (!wroteHeader) { - writer.write("\n\n"); - writer.write("# instance fields"); - wroteHeader = true; - } - writer.write('\n'); - - IndentingWriter fieldWriter = writer; - String fieldString = ReferenceUtil.getShortFieldDescriptor(field); - if (!writtenFields.add(fieldString)) { - writer.write("# duplicate field ignored\n"); - fieldWriter = new CommentingIndentingWriter(writer); - System.err.println(String.format("Ignoring duplicate field: %s->%s", classDef.getType(), fieldString)); - } else if (staticFields.contains(fieldString)) { - System.err.println(String.format("Duplicate static+instance field found: %s->%s", - classDef.getType(), fieldString)); - System.err.println("You will need to rename one of these fields, including all references."); - - writer.write("# There is both a static and instance field with this signature.\n" + - "# You will need to rename one of these fields, including all references.\n"); - } - FieldDefinition.writeTo(options, fieldWriter, field, false); - } - } - - private Set writeDirectMethods(IndentingWriter writer) throws IOException { - boolean wroteHeader = false; - Set writtenMethods = new HashSet(); - - Iterable directMethods; - if (classDef instanceof DexBackedClassDef) { - directMethods = ((DexBackedClassDef)classDef).getDirectMethods(false); - } else { - directMethods = classDef.getDirectMethods(); - } - - for (Method method: directMethods) { - if (!wroteHeader) { - writer.write("\n\n"); - writer.write("# direct methods"); - wroteHeader = true; - } - writer.write('\n'); - - // TODO: check for method validation errors - String methodString = ReferenceUtil.getMethodDescriptor(method, true); - - IndentingWriter methodWriter = writer; - if (!writtenMethods.add(methodString)) { - writer.write("# duplicate method ignored\n"); - methodWriter = new CommentingIndentingWriter(writer); - } - - MethodImplementation methodImpl = method.getImplementation(); - if (methodImpl == null) { - MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); - } else { - MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); - methodDefinition.writeTo(methodWriter); - } - } - return writtenMethods; - } - - private void writeVirtualMethods(IndentingWriter writer, Set directMethods) throws IOException { - boolean wroteHeader = false; - Set writtenMethods = new HashSet(); - - Iterable virtualMethods; - if (classDef instanceof DexBackedClassDef) { - virtualMethods = ((DexBackedClassDef)classDef).getVirtualMethods(false); - } else { - virtualMethods = classDef.getVirtualMethods(); - } - - for (Method method: virtualMethods) { - if (!wroteHeader) { - writer.write("\n\n"); - writer.write("# virtual methods"); - wroteHeader = true; - } - writer.write('\n'); - - // TODO: check for method validation errors - String methodString = ReferenceUtil.getMethodDescriptor(method, true); - - IndentingWriter methodWriter = writer; - if (!writtenMethods.add(methodString)) { - writer.write("# duplicate method ignored\n"); - methodWriter = new CommentingIndentingWriter(writer); - } else if (directMethods.contains(methodString)) { - writer.write("# There is both a direct and virtual method with this signature.\n" + - "# You will need to rename one of these methods, including all references.\n"); - System.err.println(String.format("Duplicate direct+virtual method found: %s->%s", - classDef.getType(), methodString)); - System.err.println("You will need to rename one of these methods, including all references."); - } - - MethodImplementation methodImpl = method.getImplementation(); - if (methodImpl == null) { - MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); - } else { - MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); - methodDefinition.writeTo(methodWriter); - } - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentMethodItem.java deleted file mode 100644 index 8ac43962..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentMethodItem.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class CommentMethodItem extends MethodItem { - //private final StringTemplate template; - private final String comment; - private final double sortOrder; - - public CommentMethodItem(String comment, int codeAddress, double sortOrder) { - super(codeAddress); - this.comment = comment; - this.sortOrder = sortOrder; - } - - public double getSortOrder() { - return sortOrder; - } - - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write('#'); - writer.write(comment); - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentedOutMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentedOutMethodItem.java deleted file mode 100644 index aaeb6a60..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentedOutMethodItem.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class CommentedOutMethodItem extends MethodItem { - private final MethodItem commentedOutMethodItem; - - public CommentedOutMethodItem(MethodItem commentedOutMethodItem) { - super(commentedOutMethodItem.getCodeAddress()); - this.commentedOutMethodItem = commentedOutMethodItem; - } - - public double getSortOrder() { - return commentedOutMethodItem.getSortOrder() + .001; - } - - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write('#'); - commentedOutMethodItem.writeTo(writer); - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentingIndentingWriter.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentingIndentingWriter.java deleted file mode 100644 index c63da1cd..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/CommentingIndentingWriter.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; -import java.io.Writer; - -public class CommentingIndentingWriter extends IndentingWriter { - public CommentingIndentingWriter(Writer writer) { - super(writer); - } - - @Override protected void writeIndent() throws IOException { - writer.write("# "); - super.writeIndent(); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/BeginEpilogueMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/BeginEpilogueMethodItem.java deleted file mode 100644 index a1294fcb..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/BeginEpilogueMethodItem.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class BeginEpilogueMethodItem extends DebugMethodItem { - public BeginEpilogueMethodItem(int codeAddress, int sortOrder) { - super(codeAddress, sortOrder); - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write(".prologue"); - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/DebugMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/DebugMethodItem.java deleted file mode 100644 index 86d30f97..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/DebugMethodItem.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.baksmali.Adaptors.MethodItem; -import org.jf.baksmali.Adaptors.RegisterFormatter; -import org.jf.dexlib2.DebugItemType; -import org.jf.dexlib2.iface.debug.*; -import org.jf.util.ExceptionWithContext; - -public abstract class DebugMethodItem extends MethodItem { - private final int sortOrder; - - protected DebugMethodItem(int codeAddress, int sortOrder) { - super(codeAddress); - this.sortOrder = sortOrder; - } - - @Override public double getSortOrder() { return sortOrder; } - - public static DebugMethodItem build(RegisterFormatter registerFormatter, DebugItem debugItem) { - int codeAddress = debugItem.getCodeAddress(); - switch (debugItem.getDebugItemType()) { - case DebugItemType.START_LOCAL: - return new StartLocalMethodItem(codeAddress, -1, registerFormatter, (StartLocal)debugItem); - case DebugItemType.END_LOCAL: - return new EndLocalMethodItem(codeAddress, -1, registerFormatter, (EndLocal)debugItem); - case DebugItemType.RESTART_LOCAL: - return new RestartLocalMethodItem(codeAddress, -1, registerFormatter, (RestartLocal)debugItem); - case DebugItemType.EPILOGUE_BEGIN: - return new BeginEpilogueMethodItem(codeAddress, -4); - case DebugItemType.PROLOGUE_END: - return new EndPrologueMethodItem(codeAddress, -4); - case DebugItemType.SET_SOURCE_FILE: - return new SetSourceFileMethodItem(codeAddress, -3, (SetSourceFile)debugItem); - case DebugItemType.LINE_NUMBER: - return new LineNumberMethodItem(codeAddress, -2, (LineNumber)debugItem); - default: - throw new ExceptionWithContext("Invalid debug item type: %d", debugItem.getDebugItemType()); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/EndLocalMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/EndLocalMethodItem.java deleted file mode 100644 index 231e0498..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/EndLocalMethodItem.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.baksmali.Adaptors.RegisterFormatter; -import org.jf.dexlib2.iface.debug.EndLocal; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; - -public class EndLocalMethodItem extends DebugMethodItem { - @Nonnull private final EndLocal endLocal; - @Nonnull private final RegisterFormatter registerFormatter; - - public EndLocalMethodItem(int codeAddress, int sortOrder, @Nonnull RegisterFormatter registerFormatter, - @Nonnull EndLocal endLocal) { - super(codeAddress, sortOrder); - this.endLocal = endLocal; - this.registerFormatter = registerFormatter; - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write(".end local "); - registerFormatter.writeTo(writer, endLocal.getRegister()); - - String name = endLocal.getName(); - String type = endLocal.getType(); - String signature = endLocal.getSignature(); - if (name != null || type != null || signature != null) { - writer.write(" # "); - LocalFormatter.writeLocal(writer, name, type, signature); - } - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/EndPrologueMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/EndPrologueMethodItem.java deleted file mode 100644 index 369c38fd..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/EndPrologueMethodItem.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class EndPrologueMethodItem extends DebugMethodItem { - public EndPrologueMethodItem(int codeAddress, int sortOrder) { - super(codeAddress, sortOrder); - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write(".prologue"); - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/LineNumberMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/LineNumberMethodItem.java deleted file mode 100644 index 91473bdc..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/LineNumberMethodItem.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.dexlib2.iface.debug.LineNumber; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; - -public class LineNumberMethodItem extends DebugMethodItem { - private final int lineNumber; - - public LineNumberMethodItem(int codeAddress, int sortOrder, @Nonnull LineNumber lineNumber) { - super(codeAddress, sortOrder); - this.lineNumber = lineNumber.getLineNumber(); - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write(".line "); - writer.printUnsignedIntAsDec(lineNumber); - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/LocalFormatter.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/LocalFormatter.java deleted file mode 100644 index 62ed9958..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/LocalFormatter.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.baksmali.Adaptors.ReferenceFormatter; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; - -public class LocalFormatter { - /** - * Writes out the given local info - * - * The written string will be something like: - * - * "localVar":Ljava/lang/String;, "SomeSignature" - * "localVar":Ljava/lang/String; - * "localVar":V, "SomeSignature" - * null:Ljava/lang/String;, "SomeSignature" - * null:V, "SomeSignature" - * - * One of name, type or signature must be non-null - */ - public static void writeLocal(@Nonnull IndentingWriter writer, @Nullable String name, @Nullable String type, - @Nullable String signature) throws IOException { - if (name != null) { - ReferenceFormatter.writeStringReference(writer, name); - } else { - writer.write("null"); - } - writer.write(':'); - if (type != null) { - writer.write(type); - } else { - writer.write("V"); - } - if (signature != null) { - writer.write(", "); - ReferenceFormatter.writeStringReference(writer, signature); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/RestartLocalMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/RestartLocalMethodItem.java deleted file mode 100644 index 44617193..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/RestartLocalMethodItem.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.baksmali.Adaptors.RegisterFormatter; -import org.jf.dexlib2.iface.debug.RestartLocal; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; - -public class RestartLocalMethodItem extends DebugMethodItem { - @Nonnull private final RestartLocal restartLocal; - @Nonnull private final RegisterFormatter registerFormatter; - - public RestartLocalMethodItem(int codeAddress, int sortOrder, @Nonnull RegisterFormatter registerFormatter, - @Nonnull RestartLocal restartLocal) { - super(codeAddress, sortOrder); - this.restartLocal = restartLocal; - this.registerFormatter = registerFormatter; - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write(".restart local "); - registerFormatter.writeTo(writer, restartLocal.getRegister()); - - String name = restartLocal.getName(); - String type = restartLocal.getType(); - String signature = restartLocal.getSignature(); - if (name != null || type != null || signature != null) { - writer.write(" # "); - LocalFormatter.writeLocal(writer, name, type, signature); - } - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/SetSourceFileMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/SetSourceFileMethodItem.java deleted file mode 100644 index faccfdf3..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/SetSourceFileMethodItem.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.dexlib2.iface.debug.SetSourceFile; -import org.jf.util.IndentingWriter; -import org.jf.util.StringUtils; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; - -public class SetSourceFileMethodItem extends DebugMethodItem { - @Nullable private final String sourceFile; - - public SetSourceFileMethodItem(int codeAddress, int sortOrder, @Nonnull SetSourceFile setSourceFile) { - super(codeAddress, sortOrder); - this.sourceFile = setSourceFile.getSourceFile(); - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write(".source"); - - if (sourceFile != null) { - writer.write(" \""); - StringUtils.writeEscapedString(writer, sourceFile); - writer.write('"'); - } - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/StartLocalMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/StartLocalMethodItem.java deleted file mode 100644 index 0cd2d2b1..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Debug/StartLocalMethodItem.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Debug; - -import org.jf.baksmali.Adaptors.RegisterFormatter; -import org.jf.dexlib2.iface.debug.StartLocal; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; - -public class StartLocalMethodItem extends DebugMethodItem { - @Nonnull private final StartLocal startLocal; - @Nonnull private final RegisterFormatter registerFormatter; - - public StartLocalMethodItem(int codeAddress, int sortOrder, @Nonnull RegisterFormatter registerFormatter, - @Nonnull StartLocal startLocal) { - super(codeAddress, sortOrder); - this.startLocal = startLocal; - this.registerFormatter = registerFormatter; - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write(".local "); - registerFormatter.writeTo(writer, startLocal.getRegister()); - - String name = startLocal.getName(); - String type = startLocal.getType(); - String signature = startLocal.getSignature(); - - if (name != null || type != null || signature != null) { - writer.write(", "); - LocalFormatter.writeLocal(writer, name, type, signature); - } - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/AnnotationEncodedValueAdaptor.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/AnnotationEncodedValueAdaptor.java deleted file mode 100644 index e8f12a29..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/AnnotationEncodedValueAdaptor.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.EncodedValue; - -import org.jf.dexlib2.iface.AnnotationElement; -import org.jf.dexlib2.iface.value.AnnotationEncodedValue; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; -import java.util.Collection; - -public abstract class AnnotationEncodedValueAdaptor { - - public static void writeTo(@Nonnull IndentingWriter writer, - @Nonnull AnnotationEncodedValue annotationEncodedValue, - @Nullable String containingClass) throws IOException { - writer.write(".subannotation "); - writer.write(annotationEncodedValue.getType()); - writer.write('\n'); - - writeElementsTo(writer, annotationEncodedValue.getElements(), containingClass); - writer.write(".end subannotation"); - } - - public static void writeElementsTo(@Nonnull IndentingWriter writer, - @Nonnull Collection annotationElements, - @Nullable String containingClass) throws IOException { - writer.indent(4); - for (AnnotationElement annotationElement: annotationElements) { - writer.write(annotationElement.getName()); - writer.write(" = "); - EncodedValueAdaptor.writeTo(writer, annotationElement.getValue(), containingClass); - writer.write('\n'); - } - writer.deindent(4); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/ArrayEncodedValueAdaptor.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/ArrayEncodedValueAdaptor.java deleted file mode 100644 index eb079b30..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/ArrayEncodedValueAdaptor.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.EncodedValue; - -import org.jf.dexlib2.iface.value.ArrayEncodedValue; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; -import java.util.Collection; - -public class ArrayEncodedValueAdaptor { - public static void writeTo(@Nonnull IndentingWriter writer, - @Nonnull ArrayEncodedValue arrayEncodedValue, - @Nullable String containingClass) throws IOException { - writer.write('{'); - Collection values = arrayEncodedValue.getValue(); - if (values.size() == 0) { - writer.write('}'); - return; - } - - writer.write('\n'); - writer.indent(4); - boolean first = true; - for (EncodedValue encodedValue: values) { - if (!first) { - writer.write(",\n"); - } - first = false; - - EncodedValueAdaptor.writeTo(writer, encodedValue, containingClass); - } - writer.deindent(4); - writer.write("\n}"); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/EncodedValueAdaptor.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/EncodedValueAdaptor.java deleted file mode 100644 index bce1ff7a..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EncodedValue/EncodedValueAdaptor.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.EncodedValue; - -import org.jf.baksmali.Adaptors.ReferenceFormatter; -import org.jf.baksmali.Renderers.*; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.*; -import org.jf.dexlib2.util.ReferenceUtil; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; - -public abstract class EncodedValueAdaptor { - public static void writeTo(@Nonnull IndentingWriter writer, @Nonnull EncodedValue encodedValue, - @Nullable String containingClass) - throws IOException { - switch (encodedValue.getValueType()) { - case ValueType.ANNOTATION: - AnnotationEncodedValueAdaptor.writeTo(writer, (AnnotationEncodedValue)encodedValue, containingClass); - return; - case ValueType.ARRAY: - ArrayEncodedValueAdaptor.writeTo(writer, (ArrayEncodedValue)encodedValue, containingClass); - return; - case ValueType.BOOLEAN: - BooleanRenderer.writeTo(writer, ((BooleanEncodedValue)encodedValue).getValue()); - return; - case ValueType.BYTE: - ByteRenderer.writeTo(writer, ((ByteEncodedValue)encodedValue).getValue()); - return; - case ValueType.CHAR: - CharRenderer.writeTo(writer, ((CharEncodedValue)encodedValue).getValue()); - return; - case ValueType.DOUBLE: - DoubleRenderer.writeTo(writer, ((DoubleEncodedValue)encodedValue).getValue()); - return; - case ValueType.ENUM: - EnumEncodedValue enumEncodedValue = (EnumEncodedValue)encodedValue; - boolean useImplicitReference = false; - if (enumEncodedValue.getValue().getDefiningClass().equals(containingClass)) { - useImplicitReference = true; - } - writer.write(".enum "); - ReferenceUtil.writeFieldDescriptor(writer, enumEncodedValue.getValue(), useImplicitReference); - return; - case ValueType.FIELD: - FieldEncodedValue fieldEncodedValue = (FieldEncodedValue)encodedValue; - useImplicitReference = false; - if (fieldEncodedValue.getValue().getDefiningClass().equals(containingClass)) { - useImplicitReference = true; - } - ReferenceUtil.writeFieldDescriptor(writer, fieldEncodedValue.getValue(), useImplicitReference); - return; - case ValueType.FLOAT: - FloatRenderer.writeTo(writer, ((FloatEncodedValue)encodedValue).getValue()); - return; - case ValueType.INT: - IntegerRenderer.writeTo(writer, ((IntEncodedValue)encodedValue).getValue()); - return; - case ValueType.LONG: - LongRenderer.writeTo(writer, ((LongEncodedValue)encodedValue).getValue()); - return; - case ValueType.METHOD: - MethodEncodedValue methodEncodedValue = (MethodEncodedValue)encodedValue; - useImplicitReference = false; - if (methodEncodedValue.getValue().getDefiningClass().equals(containingClass)) { - useImplicitReference = true; - } - ReferenceUtil.writeMethodDescriptor(writer, methodEncodedValue.getValue(), useImplicitReference); - return; - case ValueType.NULL: - writer.write("null"); - return; - case ValueType.SHORT: - ShortRenderer.writeTo(writer, ((ShortEncodedValue)encodedValue).getValue()); - return; - case ValueType.STRING: - ReferenceFormatter.writeStringReference(writer, ((StringEncodedValue)encodedValue).getValue()); - return; - case ValueType.TYPE: - writer.write(((TypeEncodedValue)encodedValue).getValue()); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EndTryLabelMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EndTryLabelMethodItem.java deleted file mode 100644 index aed315d7..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/EndTryLabelMethodItem.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.baksmali.baksmaliOptions; - -import javax.annotation.Nonnull; - -public class EndTryLabelMethodItem extends LabelMethodItem { - private int endTryAddress; - - public EndTryLabelMethodItem(@Nonnull baksmaliOptions options, int codeAddress, int endTryAddress) { - super(options, codeAddress, "try_end_"); - this.endTryAddress = endTryAddress; - } - - public double getSortOrder() { - //sort after instruction, but before catch directive - return 101; - } - - public int getLabelAddress() { - return endTryAddress; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/FieldDefinition.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/FieldDefinition.java deleted file mode 100644 index ae017914..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/FieldDefinition.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.baksmali.Adaptors.EncodedValue.EncodedValueAdaptor; -import org.jf.baksmali.baksmaliOptions; -import org.jf.dexlib2.AccessFlags; -import org.jf.dexlib2.iface.Annotation; -import org.jf.dexlib2.iface.Field; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.util.EncodedValueUtils; -import org.jf.util.IndentingWriter; - -import java.io.IOException; -import java.util.Collection; - -public class FieldDefinition { - public static void writeTo(baksmaliOptions options, IndentingWriter writer, Field field, - boolean setInStaticConstructor) throws IOException { - EncodedValue initialValue = field.getInitialValue(); - int accessFlags = field.getAccessFlags(); - - if (setInStaticConstructor && - AccessFlags.STATIC.isSet(accessFlags) && - AccessFlags.FINAL.isSet(accessFlags) && - initialValue != null) { - if (!EncodedValueUtils.isDefaultValue(initialValue)) { - writer.write("# The value of this static final field might be set in the static constructor\n"); - } else { - // don't write out the default initial value for static final fields that get set in the static - // constructor - initialValue = null; - } - } - - writer.write(".field "); - writeAccessFlags(writer, field.getAccessFlags()); - writer.write(field.getName()); - writer.write(':'); - writer.write(field.getType()); - if (initialValue != null) { - writer.write(" = "); - - String containingClass = null; - if (options.useImplicitReferences) { - containingClass = field.getDefiningClass(); - } - - EncodedValueAdaptor.writeTo(writer, initialValue, containingClass); - } - - writer.write('\n'); - - Collection annotations = field.getAnnotations(); - if (annotations.size() > 0) { - writer.indent(4); - - String containingClass = null; - if (options.useImplicitReferences) { - containingClass = field.getDefiningClass(); - } - - AnnotationFormatter.writeTo(writer, annotations, containingClass); - writer.deindent(4); - writer.write(".end field\n"); - } - } - - private static void writeAccessFlags(IndentingWriter writer, int accessFlags) throws IOException { - for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForField(accessFlags)) { - writer.write(accessFlag.toString()); - writer.write(' '); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/ArrayDataMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/ArrayDataMethodItem.java deleted file mode 100644 index 9c7b658c..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/ArrayDataMethodItem.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Format; - -import org.jf.baksmali.Adaptors.MethodDefinition; -import org.jf.baksmali.Renderers.LongRenderer; -import org.jf.dexlib2.iface.instruction.formats.ArrayPayload; -import org.jf.util.IndentingWriter; - -import java.io.IOException; -import java.util.List; - -public class ArrayDataMethodItem extends InstructionMethodItem { - public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) { - super(methodDef, codeAddress, instruction); - } - - public boolean writeTo(IndentingWriter writer) throws IOException { - int elementWidth = instruction.getElementWidth(); - - writer.write(".array-data "); - writer.printSignedIntAsDec(instruction.getElementWidth()); - writer.write('\n'); - - writer.indent(4); - - List elements = instruction.getArrayElements(); - - String suffix = ""; - switch (elementWidth) { - case 1: - suffix = "t"; - break; - case 2: - suffix = "s"; - break; - } - - for (Number number: elements) { - LongRenderer.writeSignedIntOrLongTo(writer, number.longValue()); - writer.write(suffix); - if (elementWidth == 8) { - writeCommentIfLikelyDouble(writer, number.longValue()); - } else if (elementWidth == 4) { - int value = number.intValue(); - boolean isResourceId = writeCommentIfResourceId(writer, value); - if (!isResourceId) writeCommentIfLikelyFloat(writer, value); - } - writer.write("\n"); - } - writer.deindent(4); - writer.write(".end array-data"); - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java deleted file mode 100644 index b3f9ae17..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java +++ /dev/null @@ -1,576 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Format; - -import org.jf.baksmali.Adaptors.MethodDefinition; -import org.jf.baksmali.Adaptors.MethodDefinition.InvalidSwitchPayload; -import org.jf.baksmali.Adaptors.MethodItem; -import org.jf.baksmali.Renderers.LongRenderer; -import org.jf.baksmali.baksmaliOptions; -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.ReferenceType; -import org.jf.dexlib2.VerificationError; -import org.jf.dexlib2.dexbacked.DexBackedDexFile.InvalidItemIndex; -import org.jf.dexlib2.iface.instruction.*; -import org.jf.dexlib2.iface.instruction.formats.Instruction20bc; -import org.jf.dexlib2.iface.instruction.formats.Instruction31t; -import org.jf.dexlib2.iface.instruction.formats.UnknownInstruction; -import org.jf.dexlib2.iface.reference.Reference; -import org.jf.dexlib2.util.ReferenceUtil; -import org.jf.util.ExceptionWithContext; -import org.jf.util.IndentingWriter; -import org.jf.util.NumberUtils; - -import javax.annotation.Nonnull; -import java.io.IOException; -import java.util.Map; - -public class InstructionMethodItem extends MethodItem { - @Nonnull protected final MethodDefinition methodDef; - @Nonnull protected final T instruction; - - public InstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress, @Nonnull T instruction) { - super(codeAddress); - this.methodDef = methodDef; - this.instruction = instruction; - } - - public double getSortOrder() { - //instructions should appear after everything except an "end try" label and .catch directive - return 100; - } - - private boolean isAllowedOdex(@Nonnull Opcode opcode) { - baksmaliOptions options = methodDef.classDef.options; - if (options.allowOdex) { - return true; - } - - if (methodDef.classDef.options.apiLevel >= 14) { - return false; - } - - return opcode.isOdexedInstanceVolatile() || opcode.isOdexedStaticVolatile() || - opcode == Opcode.THROW_VERIFICATION_ERROR; - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - Opcode opcode = instruction.getOpcode(); - String verificationErrorName = null; - String referenceString = null; - - boolean commentOutInstruction = false; - - if (instruction instanceof Instruction20bc) { - int verificationError = ((Instruction20bc)instruction).getVerificationError(); - verificationErrorName = VerificationError.getVerificationErrorName(verificationError); - if (verificationErrorName == null) { - writer.write("#was invalid verification error type: "); - writer.printSignedIntAsDec(verificationError); - writer.write("\n"); - verificationErrorName = "generic-error"; - } - } - - if (instruction instanceof ReferenceInstruction) { - ReferenceInstruction referenceInstruction = (ReferenceInstruction)instruction; - try { - Reference reference = referenceInstruction.getReference(); - - String classContext = null; - if (methodDef.classDef.options.useImplicitReferences) { - classContext = methodDef.method.getDefiningClass(); - } - - referenceString = ReferenceUtil.getReferenceString(reference, classContext); - assert referenceString != null; - } catch (InvalidItemIndex ex) { - writer.write("#"); - writer.write(ex.getMessage()); - writer.write("\n"); - commentOutInstruction = true; - - referenceString = String.format("%s@%d", - ReferenceType.toString(referenceInstruction.getReferenceType()), - ex.getInvalidIndex()); - } catch (ReferenceType.InvalidReferenceTypeException ex) { - writer.write("#invalid reference type: "); - writer.printSignedIntAsDec(ex.getReferenceType()); - commentOutInstruction = true; - - referenceString = "invalid_reference"; - } - } - - if (instruction instanceof Instruction31t) { - boolean validPayload = true; - - switch (instruction.getOpcode()) { - case PACKED_SWITCH: - int baseAddress = methodDef.getPackedSwitchBaseAddress( - this.codeAddress + ((Instruction31t)instruction).getCodeOffset()); - if (baseAddress == -1) { - validPayload = false; - } - break; - case SPARSE_SWITCH: - baseAddress = methodDef.getSparseSwitchBaseAddress( - this.codeAddress + ((Instruction31t)instruction).getCodeOffset()); - if (baseAddress == -1) { - validPayload = false; - } - break; - case FILL_ARRAY_DATA: - try { - methodDef.findPayloadOffset(this.codeAddress + ((Instruction31t)instruction).getCodeOffset(), - Opcode.ARRAY_PAYLOAD); - } catch (InvalidSwitchPayload ex) { - validPayload = false; - } - break; - default: - throw new ExceptionWithContext("Invalid 31t opcode: %s", instruction.getOpcode()); - } - - if (!validPayload) { - writer.write("#invalid payload reference\n"); - commentOutInstruction = true; - } - } - - if (opcode.odexOnly()) { - if (!isAllowedOdex(opcode)) { - writer.write("#disallowed odex opcode\n"); - commentOutInstruction = true; - } - } - - if (commentOutInstruction) { - writer.write("#"); - } - - switch (instruction.getOpcode().format) { - case Format10t: - writeOpcode(writer); - writer.write(' '); - writeTargetLabel(writer); - break; - case Format10x: - if (instruction instanceof UnknownInstruction) { - writer.write("#unknown opcode: 0x"); - writer.printUnsignedLongAsHex(((UnknownInstruction)instruction).getOriginalOpcode()); - writer.write('\n'); - } - writeOpcode(writer); - break; - case Format11n: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeLiteral(writer); - break; - case Format11x: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - break; - case Format12x: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeSecondRegister(writer); - break; - case Format20bc: - writeOpcode(writer); - writer.write(' '); - writer.write(verificationErrorName); - writer.write(", "); - writer.write(referenceString); - break; - case Format20t: - case Format30t: - writeOpcode(writer); - writer.write(' '); - writeTargetLabel(writer); - break; - case Format21c: - case Format31c: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writer.write(referenceString); - break; - case Format21ih: - case Format21lh: - case Format21s: - case Format31i: - case Format51l: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeLiteral(writer); - if (instruction.getOpcode().setsWideRegister()) { - writeCommentIfLikelyDouble(writer); - } else { - boolean isResourceId = writeCommentIfResourceId(writer); - if (!isResourceId) writeCommentIfLikelyFloat(writer); - } - break; - case Format21t: - case Format31t: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeTargetLabel(writer); - break; - case Format22b: - case Format22s: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeSecondRegister(writer); - writer.write(", "); - writeLiteral(writer); - break; - case Format22c: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeSecondRegister(writer); - writer.write(", "); - writer.write(referenceString); - break; - case Format22cs: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeSecondRegister(writer); - writer.write(", "); - writeFieldOffset(writer); - break; - case Format22t: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeSecondRegister(writer); - writer.write(", "); - writeTargetLabel(writer); - break; - case Format22x: - case Format32x: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeSecondRegister(writer); - break; - case Format23x: - writeOpcode(writer); - writer.write(' '); - writeFirstRegister(writer); - writer.write(", "); - writeSecondRegister(writer); - writer.write(", "); - writeThirdRegister(writer); - break; - case Format25x: - writeOpcode(writer); - writer.write(' '); - writeInvoke25xRegisters(writer); // vC, {vD, ...} - break; - case Format35c: - writeOpcode(writer); - writer.write(' '); - writeInvokeRegisters(writer); - writer.write(", "); - writer.write(referenceString); - break; - case Format35mi: - writeOpcode(writer); - writer.write(' '); - writeInvokeRegisters(writer); - writer.write(", "); - writeInlineIndex(writer); - break; - case Format35ms: - writeOpcode(writer); - writer.write(' '); - writeInvokeRegisters(writer); - writer.write(", "); - writeVtableIndex(writer); - break; - case Format3rc: - writeOpcode(writer); - writer.write(' '); - writeInvokeRangeRegisters(writer); - writer.write(", "); - writer.write(referenceString); - break; - case Format3rmi: - writeOpcode(writer); - writer.write(' '); - writeInvokeRangeRegisters(writer); - writer.write(", "); - writeInlineIndex(writer); - break; - case Format3rms: - writeOpcode(writer); - writer.write(' '); - writeInvokeRangeRegisters(writer); - writer.write(", "); - writeVtableIndex(writer); - break; - default: - assert false; - return false; - } - - if (commentOutInstruction) { - writer.write("\nnop"); - } - - return true; - } - - protected void writeOpcode(IndentingWriter writer) throws IOException { - writer.write(instruction.getOpcode().name); - } - - protected void writeTargetLabel(IndentingWriter writer) throws IOException { - //this method is overridden by OffsetInstructionMethodItem, and should only be called for the formats that - //have a target - throw new RuntimeException(); - } - - protected void writeRegister(IndentingWriter writer, int registerNumber) throws IOException { - methodDef.registerFormatter.writeTo(writer, registerNumber); - } - - protected void writeFirstRegister(IndentingWriter writer) throws IOException { - writeRegister(writer, ((OneRegisterInstruction)instruction).getRegisterA()); - } - - protected void writeSecondRegister(IndentingWriter writer) throws IOException { - writeRegister(writer, ((TwoRegisterInstruction)instruction).getRegisterB()); - } - - protected void writeThirdRegister(IndentingWriter writer) throws IOException { - writeRegister(writer, ((ThreeRegisterInstruction) instruction).getRegisterC()); - } - - protected void writeInvokeRegisters(IndentingWriter writer) throws IOException { - FiveRegisterInstruction instruction = (FiveRegisterInstruction)this.instruction; - final int regCount = instruction.getRegisterCount(); - - writer.write('{'); - switch (regCount) { - case 1: - writeRegister(writer, instruction.getRegisterC()); - break; - case 2: - writeRegister(writer, instruction.getRegisterC()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterD()); - break; - case 3: - writeRegister(writer, instruction.getRegisterC()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterD()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterE()); - break; - case 4: - writeRegister(writer, instruction.getRegisterC()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterD()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterE()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterF()); - break; - case 5: - writeRegister(writer, instruction.getRegisterC()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterD()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterE()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterF()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterG()); - break; - } - writer.write('}'); - } - - protected void writeInvoke25xRegisters(IndentingWriter writer) throws IOException { - OneFixedFourParameterRegisterInstruction instruction = - (OneFixedFourParameterRegisterInstruction)this.instruction; - final int parameterRegCount = instruction.getParameterRegisterCount(); - - writeRegister(writer, instruction.getRegisterFixedC()); // fixed register always present - - writer.write(", {"); - switch (parameterRegCount) { - case 1: - writeRegister(writer, instruction.getRegisterParameterD()); - break; - case 2: - writeRegister(writer, instruction.getRegisterParameterD()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterParameterE()); - break; - case 3: - writeRegister(writer, instruction.getRegisterParameterD()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterParameterE()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterParameterF()); - break; - case 4: - writeRegister(writer, instruction.getRegisterParameterD()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterParameterE()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterParameterF()); - writer.write(", "); - writeRegister(writer, instruction.getRegisterParameterG()); - break; - } - writer.write('}'); - } - - protected void writeInvokeRangeRegisters(IndentingWriter writer) throws IOException { - RegisterRangeInstruction instruction = (RegisterRangeInstruction)this.instruction; - - int regCount = instruction.getRegisterCount(); - if (regCount == 0) { - writer.write("{}"); - } else { - int startRegister = instruction.getStartRegister(); - methodDef.registerFormatter.writeRegisterRange(writer, startRegister, startRegister+regCount-1); - } - } - - protected void writeLiteral(IndentingWriter writer) throws IOException { - LongRenderer.writeSignedIntOrLongTo(writer, ((WideLiteralInstruction)instruction).getWideLiteral()); - } - - protected void writeCommentIfLikelyFloat(IndentingWriter writer) throws IOException { - writeCommentIfLikelyFloat(writer, ((NarrowLiteralInstruction)instruction).getNarrowLiteral()); - } - - protected void writeCommentIfLikelyFloat(IndentingWriter writer, int val) throws IOException { - if (NumberUtils.isLikelyFloat(val)) { - writer.write(" # "); - float fval = Float.intBitsToFloat(val); - if (fval == Float.POSITIVE_INFINITY) - writer.write("Float.POSITIVE_INFINITY"); - else if (fval == Float.NEGATIVE_INFINITY) - writer.write("Float.NEGATIVE_INFINITY"); - else if (fval == Float.NaN) - writer.write("Float.NaN"); - else if (fval == Float.MAX_VALUE) - writer.write("Float.MAX_VALUE"); - else if (fval == (float)Math.PI) - writer.write("(float)Math.PI"); - else if (fval == (float)Math.E) - writer.write("(float)Math.E"); - else { - writer.write(Float.toString(fval)); - writer.write('f'); - } - } - } - - protected void writeCommentIfLikelyDouble(IndentingWriter writer) throws IOException { - writeCommentIfLikelyDouble(writer, ((WideLiteralInstruction)instruction).getWideLiteral()); - } - - protected void writeCommentIfLikelyDouble(IndentingWriter writer, long val) throws IOException { - if (NumberUtils.isLikelyDouble(val)) { - writer.write(" # "); - double dval = Double.longBitsToDouble(val); - if (dval == Double.POSITIVE_INFINITY) - writer.write("Double.POSITIVE_INFINITY"); - else if (dval == Double.NEGATIVE_INFINITY) - writer.write("Double.NEGATIVE_INFINITY"); - else if (dval == Double.NaN) - writer.write("Double.NaN"); - else if (dval == Double.MAX_VALUE) - writer.write("Double.MAX_VALUE"); - else if (dval == Math.PI) - writer.write("Math.PI"); - else if (dval == Math.E) - writer.write("Math.E"); - else - writer.write(Double.toString(dval)); - } - } - - protected boolean writeCommentIfResourceId(IndentingWriter writer) throws IOException { - return writeCommentIfResourceId(writer, ((NarrowLiteralInstruction)instruction).getNarrowLiteral()); - } - - protected boolean writeCommentIfResourceId(IndentingWriter writer, int val) throws IOException { - Map resourceIds = methodDef.classDef.options.resourceIds; - String resource = resourceIds.get(Integer.valueOf(val)); - if (resource != null) { - writer.write(" # "); - writer.write(resource); - return true; - } - return false; - } - - protected void writeFieldOffset(IndentingWriter writer) throws IOException { - writer.write("field@0x"); - writer.printUnsignedLongAsHex(((FieldOffsetInstruction)instruction).getFieldOffset()); - } - - protected void writeInlineIndex(IndentingWriter writer) throws IOException { - writer.write("inline@"); - writer.printSignedIntAsDec(((InlineIndexInstruction)instruction).getInlineIndex()); - } - - protected void writeVtableIndex(IndentingWriter writer) throws IOException { - writer.write("vtable@"); - writer.printSignedIntAsDec(((VtableIndexInstruction)instruction).getVtableIndex()); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java deleted file mode 100644 index 429cb692..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Format; - -import org.jf.baksmali.Adaptors.MethodDefinition; -import org.jf.dexlib2.analysis.UnresolvedOdexInstruction; -import org.jf.dexlib2.iface.instruction.Instruction; -import org.jf.dexlib2.iface.instruction.OffsetInstruction; -import org.jf.dexlib2.iface.instruction.formats.ArrayPayload; -import org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload; -import org.jf.dexlib2.iface.instruction.formats.SparseSwitchPayload; - -public class InstructionMethodItemFactory { - private InstructionMethodItemFactory() { - } - - public static InstructionMethodItem makeInstructionFormatMethodItem( - MethodDefinition methodDef, int codeAddress, Instruction instruction) { - - if (instruction instanceof OffsetInstruction) { - return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress, - (OffsetInstruction)instruction); - } - - if (instruction instanceof UnresolvedOdexInstruction) { - return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress, - (UnresolvedOdexInstruction)instruction); - } - - switch (instruction.getOpcode().format) { - case ArrayPayload: - return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction); - case PackedSwitchPayload: - return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction); - case SparseSwitchPayload: - return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction); - default: - return new InstructionMethodItem(methodDef, codeAddress, instruction); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java deleted file mode 100644 index 3ffb4bd4..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Format; - -import org.jf.baksmali.Adaptors.LabelMethodItem; -import org.jf.baksmali.Adaptors.MethodDefinition; -import org.jf.baksmali.baksmaliOptions; -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.iface.instruction.OffsetInstruction; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; - -public class OffsetInstructionFormatMethodItem extends InstructionMethodItem { - protected LabelMethodItem label; - - public OffsetInstructionFormatMethodItem(@Nonnull baksmaliOptions options, @Nonnull MethodDefinition methodDef, - int codeAddress, OffsetInstruction instruction) { - super(methodDef, codeAddress, instruction); - - label = new LabelMethodItem(options, codeAddress + instruction.getCodeOffset(), getLabelPrefix()); - label = methodDef.getLabelCache().internLabel(label); - } - - @Override - protected void writeTargetLabel(IndentingWriter writer) throws IOException { - label.writeTo(writer); - } - - public LabelMethodItem getLabel() { - return label; - } - - private String getLabelPrefix() { - Opcode opcode = instruction.getOpcode(); - switch (opcode.format) { - case Format10t: - case Format20t: - case Format30t: - return "goto_"; - case Format21t: - case Format22t: - return "cond_"; - case Format31t: - if (opcode == Opcode.FILL_ARRAY_DATA) { - return "array_"; - } - if (opcode == Opcode.PACKED_SWITCH) { - return "pswitch_data_"; - } - // Opcode.SPARSE_SWITCH; - return "sswitch_data_"; - } - - assert false; - return null; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/PackedSwitchMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/PackedSwitchMethodItem.java deleted file mode 100644 index 30edfcd4..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/PackedSwitchMethodItem.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Format; - -import org.jf.baksmali.Adaptors.CommentingIndentingWriter; -import org.jf.baksmali.Adaptors.LabelMethodItem; -import org.jf.baksmali.Adaptors.MethodDefinition; -import org.jf.dexlib2.iface.instruction.SwitchElement; -import org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload; -import org.jf.util.IndentingWriter; -import org.jf.baksmali.Renderers.IntegerRenderer; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class PackedSwitchMethodItem extends InstructionMethodItem { - private final List targets; - private final int firstKey; - - // Whether this sparse switch instruction should be commented out because it is never referenced - private boolean commentedOut; - - public PackedSwitchMethodItem(MethodDefinition methodDef, int codeAddress, PackedSwitchPayload instruction) { - super(methodDef, codeAddress, instruction); - - int baseCodeAddress = methodDef.getPackedSwitchBaseAddress(codeAddress); - - targets = new ArrayList(); - - boolean first = true; - int firstKey = 0; - if (baseCodeAddress >= 0) { - for (SwitchElement switchElement: instruction.getSwitchElements()) { - if (first) { - firstKey = switchElement.getKey(); - first = false; - } - LabelMethodItem label = methodDef.getLabelCache().internLabel( - new LabelMethodItem(methodDef.classDef.options, baseCodeAddress + switchElement.getOffset(), - "pswitch_")); - targets.add(new PackedSwitchLabelTarget(label)); - } - } else { - commentedOut = true; - for (SwitchElement switchElement: instruction.getSwitchElements()) { - if (first) { - firstKey = switchElement.getKey(); - first = false; - } - targets.add(new PackedSwitchOffsetTarget(switchElement.getOffset())); - } - } - this.firstKey = firstKey; - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - if (commentedOut) { - writer = new CommentingIndentingWriter(writer); - } - writer.write(".packed-switch "); - IntegerRenderer.writeTo(writer, firstKey); - writer.indent(4); - writer.write('\n'); - int key = firstKey; - for (PackedSwitchTarget target: targets) { - target.writeTargetTo(writer); - writeCommentIfResourceId(writer, key); - writer.write('\n'); - key++; - } - writer.deindent(4); - writer.write(".end packed-switch"); - return true; - } - - private static abstract class PackedSwitchTarget { - public abstract void writeTargetTo(IndentingWriter writer) throws IOException; - } - - private static class PackedSwitchLabelTarget extends PackedSwitchTarget { - private final LabelMethodItem target; - public PackedSwitchLabelTarget(LabelMethodItem target) { - this.target = target; - } - public void writeTargetTo(IndentingWriter writer) throws IOException { - target.writeTo(writer); - } - } - - private static class PackedSwitchOffsetTarget extends PackedSwitchTarget { - private final int target; - public PackedSwitchOffsetTarget(int target) { - this.target = target; - } - public void writeTargetTo(IndentingWriter writer) throws IOException { - if (target >= 0) { - writer.write('+'); - } - writer.printSignedIntAsDec(target); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/SparseSwitchMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/SparseSwitchMethodItem.java deleted file mode 100644 index 68d7e92b..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/SparseSwitchMethodItem.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Format; - -import org.jf.baksmali.Adaptors.CommentingIndentingWriter; -import org.jf.baksmali.Adaptors.LabelMethodItem; -import org.jf.baksmali.Adaptors.MethodDefinition; -import org.jf.dexlib2.iface.instruction.SwitchElement; -import org.jf.dexlib2.iface.instruction.formats.SparseSwitchPayload; -import org.jf.util.IndentingWriter; -import org.jf.baksmali.Renderers.IntegerRenderer; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class SparseSwitchMethodItem extends InstructionMethodItem { - private final List targets; - - // Whether this sparse switch instruction should be commented out because it is never referenced - private boolean commentedOut; - - public SparseSwitchMethodItem(MethodDefinition methodDef, int codeAddress, SparseSwitchPayload instruction) { - super(methodDef, codeAddress, instruction); - - int baseCodeAddress = methodDef.getSparseSwitchBaseAddress(codeAddress); - - targets = new ArrayList(); - if (baseCodeAddress >= 0) { - for (SwitchElement switchElement: instruction.getSwitchElements()) { - LabelMethodItem label = methodDef.getLabelCache().internLabel( - new LabelMethodItem( methodDef.classDef.options, baseCodeAddress + switchElement.getOffset(), - "sswitch_")); - targets.add(new SparseSwitchLabelTarget(switchElement.getKey(), label)); - } - } else { - commentedOut = true; - //if we couldn't determine a base address, just use relative offsets rather than labels - for (SwitchElement switchElement: instruction.getSwitchElements()) { - targets.add(new SparseSwitchOffsetTarget(switchElement.getKey(), switchElement.getOffset())); - } - } - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - if (commentedOut) { - writer = new CommentingIndentingWriter(writer); - } - - writer.write(".sparse-switch\n"); - writer.indent(4); - for (SparseSwitchTarget target: targets) { - IntegerRenderer.writeTo(writer, target.getKey()); - writer.write(" -> "); - target.writeTargetTo(writer); - writeCommentIfResourceId(writer, target.getKey()); - writer.write('\n'); - } - writer.deindent(4); - writer.write(".end sparse-switch"); - return true; - } - - private static abstract class SparseSwitchTarget { - private final int key; - public SparseSwitchTarget(int key) { - this.key = key; - } - public int getKey() { return key; } - public abstract void writeTargetTo(IndentingWriter writer) throws IOException; - } - - private static class SparseSwitchLabelTarget extends SparseSwitchTarget { - private final LabelMethodItem target; - public SparseSwitchLabelTarget(int key, LabelMethodItem target) { - super(key); - this.target = target; - } - - public void writeTargetTo(IndentingWriter writer) throws IOException { - target.writeTo(writer); - } - } - - private static class SparseSwitchOffsetTarget extends SparseSwitchTarget { - private final int target; - public SparseSwitchOffsetTarget(int key, int target) { - super(key); - this.target = target; - } - - public void writeTargetTo(IndentingWriter writer) throws IOException { - if (target >= 0) { - writer.write('+'); - } - writer.printSignedIntAsDec(target); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/UnresolvedOdexInstructionMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/UnresolvedOdexInstructionMethodItem.java deleted file mode 100644 index a7768817..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/UnresolvedOdexInstructionMethodItem.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors.Format; - -import org.jf.baksmali.Adaptors.MethodDefinition; -import org.jf.dexlib2.analysis.UnresolvedOdexInstruction; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; - -public class UnresolvedOdexInstructionMethodItem extends InstructionMethodItem { - public UnresolvedOdexInstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress, - @Nonnull UnresolvedOdexInstruction instruction) { - super(methodDef, codeAddress, instruction); - } - - public boolean writeTo(IndentingWriter writer) throws IOException { - writeThrowTo(writer); - return true; - } - - private void writeThrowTo(IndentingWriter writer) throws IOException { - writer.write("#Replaced unresolvable odex instruction with a throw\n"); - writer.write("throw "); - writeRegister(writer, instruction.objectRegisterNum); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/LabelMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/LabelMethodItem.java deleted file mode 100644 index b152bb69..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/LabelMethodItem.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.baksmali.baksmaliOptions; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; - -public class LabelMethodItem extends MethodItem { - private final baksmaliOptions options; - private final String labelPrefix; - private int labelSequence; - - public LabelMethodItem(@Nonnull baksmaliOptions options, int codeAddress, @Nonnull String labelPrefix) { - super(codeAddress); - this.options = options; - this.labelPrefix = labelPrefix; - } - - public double getSortOrder() { - return 0; - } - - public int compareTo(MethodItem methodItem) { - int result = super.compareTo(methodItem); - - if (result == 0) { - if (methodItem instanceof LabelMethodItem) { - result = labelPrefix.compareTo(((LabelMethodItem)methodItem).labelPrefix); - } - } - return result; - } - - public int hashCode() { - //force it to call equals when two labels are at the same address - return getCodeAddress(); - } - - public boolean equals(Object o) { - if (!(o instanceof LabelMethodItem)) { - return false; - } - return this.compareTo((MethodItem)o) == 0; - } - - - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write(':'); - writer.write(labelPrefix); - if (options.useSequentialLabels) { - writer.printUnsignedLongAsHex(labelSequence); - } else { - writer.printUnsignedLongAsHex(this.getLabelAddress()); - } - return true; - } - - public String getLabelPrefix() { - return labelPrefix; - } - - public int getLabelAddress() { - return this.getCodeAddress(); - } - - public int getLabelSequence() { - return labelSequence; - } - - public void setLabelSequence(int labelSequence) { - this.labelSequence = labelSequence; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java deleted file mode 100644 index 4081a75c..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java +++ /dev/null @@ -1,638 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import org.jf.baksmali.Adaptors.Debug.DebugMethodItem; -import org.jf.baksmali.Adaptors.Format.InstructionMethodItemFactory; -import org.jf.baksmali.baksmaliOptions; -import org.jf.dexlib2.AccessFlags; -import org.jf.dexlib2.Format; -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.ReferenceType; -import org.jf.dexlib2.analysis.AnalysisException; -import org.jf.dexlib2.analysis.AnalyzedInstruction; -import org.jf.dexlib2.analysis.MethodAnalyzer; -import org.jf.dexlib2.dexbacked.DexBackedDexFile.InvalidItemIndex; -import org.jf.dexlib2.iface.*; -import org.jf.dexlib2.iface.debug.DebugItem; -import org.jf.dexlib2.iface.instruction.Instruction; -import org.jf.dexlib2.iface.instruction.OffsetInstruction; -import org.jf.dexlib2.iface.instruction.ReferenceInstruction; -import org.jf.dexlib2.iface.instruction.formats.Instruction31t; -import org.jf.dexlib2.iface.reference.MethodReference; -import org.jf.dexlib2.immutable.instruction.ImmutableInstruction31t; -import org.jf.dexlib2.util.InstructionOffsetMap; -import org.jf.dexlib2.util.InstructionOffsetMap.InvalidInstructionOffset; -import org.jf.dexlib2.util.ReferenceUtil; -import org.jf.dexlib2.util.SyntheticAccessorResolver; -import org.jf.dexlib2.util.SyntheticAccessorResolver.AccessedMember; -import org.jf.dexlib2.util.TypeUtils; -import org.jf.util.ExceptionWithContext; -import org.jf.util.IndentingWriter; -import org.jf.util.SparseIntArray; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; -import java.util.*; - -public class MethodDefinition { - @Nonnull public final ClassDefinition classDef; - @Nonnull public final Method method; - @Nonnull public final MethodImplementation methodImpl; - @Nonnull public final ImmutableList instructions; - @Nonnull public final List effectiveInstructions; - - @Nonnull public final ImmutableList methodParameters; - public RegisterFormatter registerFormatter; - - @Nonnull private final LabelCache labelCache = new LabelCache(); - - @Nonnull private final SparseIntArray packedSwitchMap; - @Nonnull private final SparseIntArray sparseSwitchMap; - @Nonnull private final InstructionOffsetMap instructionOffsetMap; - - public MethodDefinition(@Nonnull ClassDefinition classDef, @Nonnull Method method, - @Nonnull MethodImplementation methodImpl) { - this.classDef = classDef; - this.method = method; - this.methodImpl = methodImpl; - - try { - //TODO: what about try/catch blocks inside the dead code? those will need to be commented out too. ugh. - - instructions = ImmutableList.copyOf(methodImpl.getInstructions()); - methodParameters = ImmutableList.copyOf(method.getParameters()); - - effectiveInstructions = Lists.newArrayList(instructions); - - packedSwitchMap = new SparseIntArray(0); - sparseSwitchMap = new SparseIntArray(0); - instructionOffsetMap = new InstructionOffsetMap(instructions); - - int endOffset = instructionOffsetMap.getInstructionCodeOffset(instructions.size()-1) + - instructions.get(instructions.size()-1).getCodeUnits(); - - for (int i=0; i methodParameters = ImmutableList.copyOf(method.getParameters()); - for (MethodParameter parameter: methodParameters) { - writer.write(parameter.getType()); - } - writer.write(")"); - writer.write(method.getReturnType()); - writer.write('\n'); - - writer.indent(4); - writeParameters(writer, method, methodParameters, options); - - String containingClass = null; - if (options.useImplicitReferences) { - containingClass = method.getDefiningClass(); - } - AnnotationFormatter.writeTo(writer, method.getAnnotations(), containingClass); - - writer.deindent(4); - writer.write(".end method\n"); - } - - public void writeTo(IndentingWriter writer) throws IOException { - int parameterRegisterCount = 0; - if (!AccessFlags.STATIC.isSet(method.getAccessFlags())) { - parameterRegisterCount++; - } - - writer.write(".method "); - writeAccessFlags(writer, method.getAccessFlags()); - writer.write(method.getName()); - writer.write("("); - for (MethodParameter parameter: methodParameters) { - String type = parameter.getType(); - writer.write(type); - parameterRegisterCount++; - if (TypeUtils.isWideType(type)) { - parameterRegisterCount++; - } - } - writer.write(")"); - writer.write(method.getReturnType()); - writer.write('\n'); - - writer.indent(4); - if (classDef.options.useLocalsDirective) { - writer.write(".locals "); - writer.printSignedIntAsDec(methodImpl.getRegisterCount() - parameterRegisterCount); - } else { - writer.write(".registers "); - writer.printSignedIntAsDec(methodImpl.getRegisterCount()); - } - writer.write('\n'); - writeParameters(writer, method, methodParameters, classDef.options); - - if (registerFormatter == null) { - registerFormatter = new RegisterFormatter(classDef.options, methodImpl.getRegisterCount(), - parameterRegisterCount); - } - - String containingClass = null; - if (classDef.options.useImplicitReferences) { - containingClass = method.getDefiningClass(); - } - AnnotationFormatter.writeTo(writer, method.getAnnotations(), containingClass); - - writer.write('\n'); - - List methodItems = getMethodItems(); - for (MethodItem methodItem: methodItems) { - if (methodItem.writeTo(writer)) { - writer.write('\n'); - } - } - writer.deindent(4); - writer.write(".end method\n"); - } - - public Instruction findSwitchPayload(int targetOffset, Opcode type) { - int targetIndex; - try { - targetIndex = instructionOffsetMap.getInstructionIndexAtCodeOffset(targetOffset); - } catch (InvalidInstructionOffset ex) { - throw new InvalidSwitchPayload(targetOffset); - } - - //TODO: does dalvik let you pad with multiple nops? - //TODO: does dalvik let a switch instruction point to a non-payload instruction? - - Instruction instruction = instructions.get(targetIndex); - if (instruction.getOpcode() != type) { - // maybe it's pointing to a NOP padding instruction. Look at the next instruction - if (instruction.getOpcode() == Opcode.NOP) { - targetIndex += 1; - if (targetIndex < instructions.size()) { - instruction = instructions.get(targetIndex); - if (instruction.getOpcode() == type) { - return instruction; - } - } - } - throw new InvalidSwitchPayload(targetOffset); - } else { - return instruction; - } - } - - public int findPayloadOffset(int targetOffset, Opcode type) { - int targetIndex; - try { - targetIndex = instructionOffsetMap.getInstructionIndexAtCodeOffset(targetOffset); - } catch (InvalidInstructionOffset ex) { - throw new InvalidSwitchPayload(targetOffset); - } - - //TODO: does dalvik let you pad with multiple nops? - //TODO: does dalvik let a switch instruction point to a non-payload instruction? - - Instruction instruction = instructions.get(targetIndex); - if (instruction.getOpcode() != type) { - // maybe it's pointing to a NOP padding instruction. Look at the next instruction - if (instruction.getOpcode() == Opcode.NOP) { - targetIndex += 1; - if (targetIndex < instructions.size()) { - instruction = instructions.get(targetIndex); - if (instruction.getOpcode() == type) { - return instructionOffsetMap.getInstructionCodeOffset(targetIndex); - } - } - } - throw new InvalidSwitchPayload(targetOffset); - } else { - return targetOffset; - } - } - - private static void writeAccessFlags(IndentingWriter writer, int accessFlags) - throws IOException { - for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForMethod(accessFlags)) { - writer.write(accessFlag.toString()); - writer.write(' '); - } - } - - private static void writeParameters(IndentingWriter writer, Method method, - List parameters, - baksmaliOptions options) throws IOException { - boolean isStatic = AccessFlags.STATIC.isSet(method.getAccessFlags()); - int registerNumber = isStatic?0:1; - for (MethodParameter parameter: parameters) { - String parameterType = parameter.getType(); - String parameterName = parameter.getName(); - Collection annotations = parameter.getAnnotations(); - if (parameterName != null || annotations.size() != 0) { - writer.write(".param p"); - writer.printSignedIntAsDec(registerNumber); - - if (parameterName != null && options.outputDebugInfo) { - writer.write(", "); - ReferenceFormatter.writeStringReference(writer, parameterName); - } - writer.write(" # "); - writer.write(parameterType); - writer.write("\n"); - if (annotations.size() > 0) { - writer.indent(4); - - String containingClass = null; - if (options.useImplicitReferences) { - containingClass = method.getDefiningClass(); - } - AnnotationFormatter.writeTo(writer, annotations, containingClass); - writer.deindent(4); - writer.write(".end param\n"); - } - } - - registerNumber++; - if (TypeUtils.isWideType(parameterType)) { - registerNumber++; - } - } - } - - @Nonnull public LabelCache getLabelCache() { - return labelCache; - } - - public int getPackedSwitchBaseAddress(int packedSwitchPayloadCodeOffset) { - return packedSwitchMap.get(packedSwitchPayloadCodeOffset, -1); - } - - public int getSparseSwitchBaseAddress(int sparseSwitchPayloadCodeOffset) { - return sparseSwitchMap.get(sparseSwitchPayloadCodeOffset, -1); - } - - private List getMethodItems() { - ArrayList methodItems = new ArrayList(); - - if ((classDef.options.registerInfo != 0) || (classDef.options.deodex && needsAnalyzed())) { - addAnalyzedInstructionMethodItems(methodItems); - } else { - addInstructionMethodItems(methodItems); - } - - addTries(methodItems); - if (classDef.options.outputDebugInfo) { - addDebugInfo(methodItems); - } - - if (classDef.options.useSequentialLabels) { - setLabelSequentialNumbers(); - } - - for (LabelMethodItem labelMethodItem: labelCache.getLabels()) { - methodItems.add(labelMethodItem); - } - - Collections.sort(methodItems); - - return methodItems; - } - - private boolean needsAnalyzed() { - for (Instruction instruction: methodImpl.getInstructions()) { - if (instruction.getOpcode().odexOnly()) { - return true; - } - } - return false; - } - - private void addInstructionMethodItems(List methodItems) { - int currentCodeAddress = 0; - - for (int i=0; i methodItems) { - MethodAnalyzer methodAnalyzer = new MethodAnalyzer(classDef.options.classPath, method, - classDef.options.inlineResolver); - - AnalysisException analysisException = methodAnalyzer.getAnalysisException(); - if (analysisException != null) { - // TODO: need to keep track of whether any errors occurred, so we can exit with a non-zero result - methodItems.add(new CommentMethodItem( - String.format("AnalysisException: %s", analysisException.getMessage()), - analysisException.codeAddress, Integer.MIN_VALUE)); - analysisException.printStackTrace(System.err); - } - - List instructions = methodAnalyzer.getAnalyzedInstructions(); - - int currentCodeAddress = 0; - for (int i=0; i methodItems) { - List> tryBlocks = methodImpl.getTryBlocks(); - if (tryBlocks.size() == 0) { - return; - } - - int lastInstructionAddress = instructionOffsetMap.getInstructionCodeOffset(instructions.size() - 1); - int codeSize = lastInstructionAddress + instructions.get(instructions.size() - 1).getCodeUnits(); - - for (TryBlock tryBlock: tryBlocks) { - int startAddress = tryBlock.getStartCodeAddress(); - int endAddress = startAddress + tryBlock.getCodeUnitCount(); - - if (startAddress >= codeSize) { - throw new RuntimeException(String.format("Try start offset %d is past the end of the code block.", - startAddress)); - } - // Note: not >=. endAddress == codeSize is valid, when the try covers the last instruction - if (endAddress > codeSize) { - throw new RuntimeException(String.format("Try end offset %d is past the end of the code block.", - endAddress)); - } - - /** - * The end address points to the address immediately after the end of the last - * instruction that the try block covers. We want the .catch directive and end_try - * label to be associated with the last covered instruction, so we need to get - * the address for that instruction - */ - - int lastCoveredIndex = instructionOffsetMap.getInstructionIndexAtCodeOffset(endAddress - 1, false); - int lastCoveredAddress = instructionOffsetMap.getInstructionCodeOffset(lastCoveredIndex); - - for (ExceptionHandler handler: tryBlock.getExceptionHandlers()) { - int handlerAddress = handler.getHandlerCodeAddress(); - if (handlerAddress >= codeSize) { - throw new ExceptionWithContext( - "Exception handler offset %d is past the end of the code block.", handlerAddress); - } - - //use the address from the last covered instruction - CatchMethodItem catchMethodItem = new CatchMethodItem(classDef.options, labelCache, lastCoveredAddress, - handler.getExceptionType(), startAddress, endAddress, handlerAddress); - methodItems.add(catchMethodItem); - } - } - } - - private void addDebugInfo(final List methodItems) { - for (DebugItem debugItem: methodImpl.getDebugItems()) { - methodItems.add(DebugMethodItem.build(registerFormatter, debugItem)); - } - } - - private void setLabelSequentialNumbers() { - HashMap nextLabelSequenceByType = new HashMap(); - ArrayList sortedLabels = new ArrayList(labelCache.getLabels()); - - //sort the labels by their location in the method - Collections.sort(sortedLabels); - - for (LabelMethodItem labelMethodItem: sortedLabels) { - Integer labelSequence = nextLabelSequenceByType.get(labelMethodItem.getLabelPrefix()); - if (labelSequence == null) { - labelSequence = 0; - } - labelMethodItem.setLabelSequence(labelSequence); - nextLabelSequenceByType.put(labelMethodItem.getLabelPrefix(), labelSequence + 1); - } - } - - @Nullable - private String getContainingClassForImplicitReference() { - if (classDef.options.useImplicitReferences) { - return classDef.classDef.getType(); - } - return null; - } - - public static class LabelCache { - protected HashMap labels = new HashMap(); - - public LabelCache() { - } - - public LabelMethodItem internLabel(LabelMethodItem labelMethodItem) { - LabelMethodItem internedLabelMethodItem = labels.get(labelMethodItem); - if (internedLabelMethodItem != null) { - return internedLabelMethodItem; - } - labels.put(labelMethodItem, labelMethodItem); - return labelMethodItem; - } - - - public Collection getLabels() { - return labels.values(); - } - } - - public static class InvalidSwitchPayload extends ExceptionWithContext { - private final int payloadOffset; - - public InvalidSwitchPayload(int payloadOffset) { - super("No switch payload at offset: %d", payloadOffset); - this.payloadOffset = payloadOffset; - } - - public int getPayloadOffset() { - return payloadOffset; - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodItem.java deleted file mode 100644 index 60358c5d..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodItem.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public abstract class MethodItem implements Comparable { - protected final int codeAddress; - - protected MethodItem(int codeAddress) { - this.codeAddress = codeAddress; - } - - public int getCodeAddress() { - return codeAddress; - } - - //return an arbitrary double that determines how this item will be sorted with others at the same address - public abstract double getSortOrder(); - - public int compareTo(MethodItem methodItem) { - int result = ((Integer) codeAddress).compareTo(methodItem.codeAddress); - - if (result == 0){ - return ((Double)getSortOrder()).compareTo(methodItem.getSortOrder()); - } - return result; - } - - public abstract boolean writeTo(IndentingWriter writer) throws IOException; -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/PostInstructionRegisterInfoMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/PostInstructionRegisterInfoMethodItem.java deleted file mode 100644 index 812a282a..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/PostInstructionRegisterInfoMethodItem.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.baksmali.baksmaliOptions; -import org.jf.dexlib2.analysis.AnalyzedInstruction; -import org.jf.dexlib2.analysis.RegisterType; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; -import java.util.BitSet; - -public class PostInstructionRegisterInfoMethodItem extends MethodItem { - @Nonnull private final RegisterFormatter registerFormatter; - @Nonnull private final AnalyzedInstruction analyzedInstruction; - - public PostInstructionRegisterInfoMethodItem(@Nonnull RegisterFormatter registerFormatter, - @Nonnull AnalyzedInstruction analyzedInstruction, - int codeAddress) { - super(codeAddress); - this.registerFormatter = registerFormatter; - this.analyzedInstruction = analyzedInstruction; - } - - @Override - public double getSortOrder() { - return 100.1; - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - int registerInfo = registerFormatter.options.registerInfo; - int registerCount = analyzedInstruction.getRegisterCount(); - BitSet registers = new BitSet(registerCount); - - if ((registerInfo & baksmaliOptions.ALL) != 0) { - registers.set(0, registerCount); - } else { - if ((registerInfo & baksmaliOptions.ALLPOST) != 0) { - registers.set(0, registerCount); - } else if ((registerInfo & baksmaliOptions.DEST) != 0) { - addDestRegs(registers, registerCount); - } - } - - return writeRegisterInfo(writer, registers); - } - - private void addDestRegs(BitSet printPostRegister, int registerCount) { - for (int registerNum=0; registerNum= 0; registerNum = registers.nextSetBit(registerNum + 1)) { - RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum); - - registerFormatter.writeTo(writer, registerNum); - writer.write('='); - registerType.writeTo(writer); - writer.write(';'); - } - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/PreInstructionRegisterInfoMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/PreInstructionRegisterInfoMethodItem.java deleted file mode 100644 index d2811c04..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/PreInstructionRegisterInfoMethodItem.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.baksmali.baksmaliOptions; -import org.jf.dexlib2.analysis.AnalyzedInstruction; -import org.jf.dexlib2.analysis.MethodAnalyzer; -import org.jf.dexlib2.analysis.RegisterType; -import org.jf.dexlib2.iface.instruction.*; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; -import java.util.BitSet; - -public class PreInstructionRegisterInfoMethodItem extends MethodItem { - private static AnalyzedInstruction lastInstruction; - - private final int registerInfo; - @Nonnull private final MethodAnalyzer methodAnalyzer; - @Nonnull private final RegisterFormatter registerFormatter; - @Nonnull private final AnalyzedInstruction analyzedInstruction; - - public PreInstructionRegisterInfoMethodItem(int registerInfo, - @Nonnull MethodAnalyzer methodAnalyzer, - @Nonnull RegisterFormatter registerFormatter, - @Nonnull AnalyzedInstruction analyzedInstruction, - int codeAddress) { - super(codeAddress); - this.registerInfo = registerInfo; - this.methodAnalyzer = methodAnalyzer; - this.registerFormatter = registerFormatter; - this.analyzedInstruction = analyzedInstruction; - } - - @Override - public double getSortOrder() { - return 99.9; - } - - @Override - public boolean writeTo(IndentingWriter writer) throws IOException { - int registerCount = analyzedInstruction.getRegisterCount(); - BitSet registers = new BitSet(registerCount); - BitSet mergeRegisters = null; - - if ((registerInfo & baksmaliOptions.ALL) != 0) { - registers.set(0, registerCount); - } else { - if ((registerInfo & baksmaliOptions.ALLPRE) != 0) { - registers.set(0, registerCount); - } else { - if ((registerInfo & baksmaliOptions.ARGS) != 0) { - addArgsRegs(registers); - } - if ((registerInfo & baksmaliOptions.DIFFPRE) != 0) { - addDiffRegs(registers); - } - if ((registerInfo & baksmaliOptions.MERGE) != 0) { - if (analyzedInstruction.isBeginningInstruction()) { - addParamRegs(registers, registerCount); - } - mergeRegisters = new BitSet(registerCount); - addMergeRegs(mergeRegisters, registerCount); - } else if ((registerInfo & baksmaliOptions.FULLMERGE) != 0 && - (analyzedInstruction.isBeginningInstruction())) { - addParamRegs(registers, registerCount); - } - } - } - - if ((registerInfo & baksmaliOptions.FULLMERGE) != 0) { - if (mergeRegisters == null) { - mergeRegisters = new BitSet(registerCount); - addMergeRegs(mergeRegisters, registerCount); - } - registers.or(mergeRegisters); - } else if (mergeRegisters != null) { - registers.or(mergeRegisters); - mergeRegisters = null; - } - - return writeRegisterInfo(writer, registers, mergeRegisters); - } - - private void addArgsRegs(BitSet registers) { - if (analyzedInstruction.getInstruction() instanceof RegisterRangeInstruction) { - RegisterRangeInstruction instruction = (RegisterRangeInstruction)analyzedInstruction.getInstruction(); - - registers.set(instruction.getStartRegister(), - instruction.getStartRegister() + instruction.getRegisterCount()); - } else if (analyzedInstruction.getInstruction() instanceof FiveRegisterInstruction) { - FiveRegisterInstruction instruction = (FiveRegisterInstruction)analyzedInstruction.getInstruction(); - int regCount = instruction.getRegisterCount(); - switch (regCount) { - case 5: - registers.set(instruction.getRegisterG()); - //fall through - case 4: - registers.set(instruction.getRegisterF()); - //fall through - case 3: - registers.set(instruction.getRegisterE()); - //fall through - case 2: - registers.set(instruction.getRegisterD()); - //fall through - case 1: - registers.set(instruction.getRegisterC()); - } - } else if (analyzedInstruction.getInstruction() instanceof ThreeRegisterInstruction) { - ThreeRegisterInstruction instruction = (ThreeRegisterInstruction)analyzedInstruction.getInstruction(); - registers.set(instruction.getRegisterA()); - registers.set(instruction.getRegisterB()); - registers.set(instruction.getRegisterC()); - } else if (analyzedInstruction.getInstruction() instanceof TwoRegisterInstruction) { - TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.getInstruction(); - registers.set(instruction.getRegisterA()); - registers.set(instruction.getRegisterB()); - } else if (analyzedInstruction.getInstruction() instanceof OneRegisterInstruction) { - OneRegisterInstruction instruction = (OneRegisterInstruction)analyzedInstruction.getInstruction(); - registers.set(instruction.getRegisterA()); - } - } - - private void addDiffRegs(BitSet registers) { - if (! analyzedInstruction.isBeginningInstruction()) { - for (int i = 0; i < analyzedInstruction.getRegisterCount(); i++) { - if (lastInstruction.getPreInstructionRegisterType(i).category != - analyzedInstruction.getPreInstructionRegisterType(i).category) { - registers.set(i); - } - } - } - - lastInstruction = analyzedInstruction; - } - - private void addMergeRegs(BitSet registers, int registerCount) { - if (analyzedInstruction.getPredecessorCount() <= 1) { - //in the common case of an instruction that only has a single predecessor which is the previous - //instruction, the pre-instruction registers will always match the previous instruction's - //post-instruction registers - return; - } - - for (int registerNum=0; registerNum= 0; registerNum = registers.nextSetBit(registerNum + 1)) { - boolean fullMerge = fullMergeRegisters!=null && fullMergeRegisters.get(registerNum); - if (fullMerge) { - if (!firstRegister) { - writer.write('\n'); - writer.write('#'); - } - writeFullMerge(writer, registerNum); - previousWasFullMerge = true; - } else { - if (previousWasFullMerge) { - writer.write('\n'); - writer.write('#'); - previousWasFullMerge = false; - } - - RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(registerNum); - - registerFormatter.writeTo(writer, registerNum); - writer.write('='); - - registerType.writeTo(writer); - writer.write(';'); - } - - firstRegister = false; - } - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/ReferenceFormatter.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/ReferenceFormatter.java deleted file mode 100644 index 91d142a8..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/ReferenceFormatter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.dexlib2.ReferenceType; -import org.jf.dexlib2.iface.reference.*; -import org.jf.dexlib2.util.ReferenceUtil; -import org.jf.util.IndentingWriter; -import org.jf.util.StringUtils; - -import java.io.IOException; - -public class ReferenceFormatter { - public static void writeStringReference(IndentingWriter writer, String item) throws IOException { - writer.write('"'); - StringUtils.writeEscapedString(writer, item); - writer.write('"'); - } - - public static void writeReference(IndentingWriter writer, int referenceType, - Reference reference) throws IOException { - switch (referenceType) { - case ReferenceType.STRING: - writeStringReference(writer, ((StringReference)reference).getString()); - return; - case ReferenceType.TYPE: - writer.write(((TypeReference)reference).getType()); - return; - case ReferenceType.METHOD: - ReferenceUtil.writeMethodDescriptor(writer, (MethodReference)reference); - return; - case ReferenceType.FIELD: - ReferenceUtil.writeFieldDescriptor(writer, (FieldReference)reference); - return; - default: - throw new IllegalStateException("Unknown reference type"); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/RegisterFormatter.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/RegisterFormatter.java deleted file mode 100644 index bffcb385..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/RegisterFormatter.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.baksmali.baksmaliOptions; -import org.jf.util.IndentingWriter; - -import javax.annotation.Nonnull; -import java.io.IOException; - -/** - * This class contains the logic used for formatting registers - */ -public class RegisterFormatter { - @Nonnull public final baksmaliOptions options; - public final int registerCount; - public final int parameterRegisterCount; - - public RegisterFormatter(@Nonnull baksmaliOptions options, int registerCount, int parameterRegisterCount) { - this.options = options; - this.registerCount = registerCount; - this.parameterRegisterCount = parameterRegisterCount; - } - - /** - * Write out the register range value used by Format3rc. If baksmali.noParameterRegisters is true, it will always - * output the registers in the v format. But if false, then it will check if *both* registers are parameter - * registers, and if so, use the p format for both. If only the last register is a parameter register, it will - * use the v format for both, otherwise it would be confusing to have something like {v20 .. p1} - * @param writer the IndentingWriter to write to - * @param startRegister the first register in the range - * @param lastRegister the last register in the range - */ - public void writeRegisterRange(IndentingWriter writer, int startRegister, int lastRegister) throws IOException { - if (!options.noParameterRegisters) { - assert startRegister <= lastRegister; - - if (startRegister >= registerCount - parameterRegisterCount) { - writer.write("{p"); - writer.printSignedIntAsDec(startRegister - (registerCount - parameterRegisterCount)); - writer.write(" .. p"); - writer.printSignedIntAsDec(lastRegister - (registerCount - parameterRegisterCount)); - writer.write('}'); - return; - } - } - writer.write("{v"); - writer.printSignedIntAsDec(startRegister); - writer.write(" .. v"); - writer.printSignedIntAsDec(lastRegister); - writer.write('}'); - } - - /** - * Writes a register with the appropriate format. If baksmali.noParameterRegisters is true, then it will always - * output a register in the v format. If false, then it determines if the register is a parameter register, - * and if so, formats it in the p format instead. - * - * @param writer the IndentingWriter to write to - * @param register the register number - */ - public void writeTo(IndentingWriter writer, int register) throws IOException { - if (!options.noParameterRegisters) { - if (register >= registerCount - parameterRegisterCount) { - writer.write('p'); - writer.printSignedIntAsDec((register - (registerCount - parameterRegisterCount))); - return; - } - } - writer.write('v'); - writer.printSignedIntAsDec(register); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/SyntheticAccessCommentMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/SyntheticAccessCommentMethodItem.java deleted file mode 100644 index ef0abb7a..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/SyntheticAccessCommentMethodItem.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2011 Ben Gruver - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Adaptors; - -import org.jf.dexlib2.ReferenceType; -import org.jf.dexlib2.util.SyntheticAccessorResolver; -import org.jf.util.ExceptionWithContext; -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class SyntheticAccessCommentMethodItem extends MethodItem { - private final SyntheticAccessorResolver.AccessedMember accessedMember; - - public SyntheticAccessCommentMethodItem(SyntheticAccessorResolver.AccessedMember accessedMember, int codeAddress) { - super(codeAddress); - this.accessedMember = accessedMember; - } - - public double getSortOrder() { - //just before the pre-instruction register information, if any - return 99.8; - } - - public boolean writeTo(IndentingWriter writer) throws IOException { - writer.write("# "); - switch (accessedMember.accessedMemberType) { - case SyntheticAccessorResolver.METHOD: - writer.write("invokes: "); - break; - case SyntheticAccessorResolver.GETTER: - writer.write("getter for: "); - break; - case SyntheticAccessorResolver.SETTER: - writer.write("setter for: "); - break; - case SyntheticAccessorResolver.PREFIX_INCREMENT: - writer.write("++operator for: "); - break; - case SyntheticAccessorResolver.POSTFIX_INCREMENT: - writer.write("operator++ for: "); - break; - case SyntheticAccessorResolver.PREFIX_DECREMENT: - writer.write("--operator for: "); - break; - case SyntheticAccessorResolver.POSTFIX_DECREMENT: - writer.write("operator-- for: "); - break; - case SyntheticAccessorResolver.ADD_ASSIGNMENT: - writer.write("+= operator for: "); - break; - case SyntheticAccessorResolver.SUB_ASSIGNMENT: - writer.write("-= operator for: "); - break; - case SyntheticAccessorResolver.MUL_ASSIGNMENT: - writer.write("*= operator for: "); - break; - case SyntheticAccessorResolver.DIV_ASSIGNMENT: - writer.write("/= operator for: "); - break; - case SyntheticAccessorResolver.REM_ASSIGNMENT: - writer.write("%= operator for: "); - break; - case SyntheticAccessorResolver.AND_ASSIGNMENT: - writer.write("&= operator for: "); - break; - case SyntheticAccessorResolver.OR_ASSIGNMENT: - writer.write("|= operator for: "); - break; - case SyntheticAccessorResolver.XOR_ASSIGNMENT: - writer.write("^= operator for: "); - break; - case SyntheticAccessorResolver.SHL_ASSIGNMENT: - writer.write("<<= operator for: "); - break; - case SyntheticAccessorResolver.SHR_ASSIGNMENT: - writer.write(">>= operator for: "); - break; - case SyntheticAccessorResolver.USHR_ASSIGNMENT: - writer.write(">>>= operator for: "); - break; - default: - throw new ExceptionWithContext("Unknown access type: %d", accessedMember.accessedMemberType); - } - - int referenceType; - if (accessedMember.accessedMemberType == SyntheticAccessorResolver.METHOD) { - referenceType = ReferenceType.METHOD; - } else { - referenceType = ReferenceType.FIELD; - } - ReferenceFormatter.writeReference(writer, referenceType, accessedMember.accessedMember); - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/BooleanRenderer.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/BooleanRenderer.java deleted file mode 100644 index f181bb48..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/BooleanRenderer.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Renderers; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class BooleanRenderer { - public static void writeTo(IndentingWriter writer, boolean val) throws IOException { - if (val) { - writer.write("true"); - } else { - writer.write("false"); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/ByteRenderer.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/ByteRenderer.java deleted file mode 100644 index 9c060fd4..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/ByteRenderer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Renderers; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class ByteRenderer { - public static void writeTo(IndentingWriter writer, byte val) throws IOException { - if (val<0) { - writer.write("-0x"); - writer.printUnsignedLongAsHex(-val); - writer.write('t'); - } else { - writer.write("0x"); - writer.printUnsignedLongAsHex(val); - writer.write('t'); - } - } - - public static void writeUnsignedTo(IndentingWriter writer, byte val) throws IOException { - writer.write("0x"); - writer.printUnsignedLongAsHex(val & 0xFF); - writer.write('t'); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/CharRenderer.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/CharRenderer.java deleted file mode 100644 index daf76340..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/CharRenderer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Renderers; - -import org.jf.util.IndentingWriter; -import org.jf.util.StringUtils; - -import java.io.IOException; - -public class CharRenderer { - public static void writeTo(IndentingWriter writer, char val) throws IOException { - writer.write('\''); - StringUtils.writeEscapedChar(writer, val); - writer.write('\''); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/DoubleRenderer.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/DoubleRenderer.java deleted file mode 100644 index 03fff640..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/DoubleRenderer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Renderers; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class DoubleRenderer { - public static void writeTo(IndentingWriter writer, double val) throws IOException { - writer.write(Double.toString(val)); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/FloatRenderer.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/FloatRenderer.java deleted file mode 100644 index a1de2b9d..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/FloatRenderer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Renderers; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class FloatRenderer { - public static void writeTo(IndentingWriter writer, float val) throws IOException { - writer.write(Float.toString(val)); - writer.write('f'); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/IntegerRenderer.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/IntegerRenderer.java deleted file mode 100644 index 22beaacb..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/IntegerRenderer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Renderers; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class IntegerRenderer { - public static void writeTo(IndentingWriter writer, int val) throws IOException { - if (val<0) { - writer.write("-0x"); - writer.printUnsignedLongAsHex(-((long) val)); - } else { - writer.write("0x"); - writer.printUnsignedLongAsHex(val); - } - } - - public static void writeUnsignedTo(IndentingWriter writer, int val) throws IOException { - writer.write("0x"); - writer.printUnsignedLongAsHex(val & 0xFFFFFFFFL); - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/LongRenderer.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/LongRenderer.java deleted file mode 100644 index 83076e48..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/LongRenderer.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Renderers; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class LongRenderer { - public static void writeTo(IndentingWriter writer, long val) throws IOException { - if (val<0) { - writer.write("-0x"); - writer.printUnsignedLongAsHex(-val); - writer.write('L'); - } else { - writer.write("0x"); - writer.printUnsignedLongAsHex(val); - writer.write('L'); - } - } - - public static void writeSignedIntOrLongTo(IndentingWriter writer, long val) throws IOException { - if (val<0) { - writer.write("-0x"); - writer.printUnsignedLongAsHex(-val); - if (val < Integer.MIN_VALUE) { - writer.write('L'); - } - } else { - writer.write("0x"); - writer.printUnsignedLongAsHex(val); - if (val > Integer.MAX_VALUE) { - writer.write('L'); - } - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/ShortRenderer.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/ShortRenderer.java deleted file mode 100644 index 3385c6b6..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Renderers/ShortRenderer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali.Renderers; - -import org.jf.util.IndentingWriter; - -import java.io.IOException; - -public class ShortRenderer { - public static void writeTo(IndentingWriter writer, short val) throws IOException { - if (val < 0) { - writer.write("-0x"); - writer.printUnsignedLongAsHex(-val); - writer.write('s'); - } else { - writer.write("0x"); - writer.printUnsignedLongAsHex(val); - writer.write('s'); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmali.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmali.java deleted file mode 100644 index 47fa406d..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmali.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import org.jf.baksmali.Adaptors.ClassDefinition; -import org.jf.dexlib2.analysis.ClassPath; -import org.jf.dexlib2.analysis.CustomInlineMethodResolver; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.dexlib2.iface.DexFile; -import org.jf.dexlib2.util.SyntheticAccessorResolver; -import org.jf.util.ClassFileNameHandler; -import org.jf.util.IndentingWriter; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -import java.io.*; -import java.util.List; -import java.util.Map.Entry; -import java.util.concurrent.*; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.parsers.ParserConfigurationException; - -public class baksmali { - - public static boolean disassembleDexFile(DexFile dexFile, final baksmaliOptions options) { - if (options.registerInfo != 0 || options.deodex) { - try { - Iterable extraClassPathEntries; - if (options.extraClassPathEntries != null) { - extraClassPathEntries = options.extraClassPathEntries; - } else { - extraClassPathEntries = ImmutableList.of(); - } - - options.classPath = ClassPath.fromClassPath(options.bootClassPathDirs, - Iterables.concat(options.bootClassPathEntries, extraClassPathEntries), dexFile, - options.apiLevel, options.checkPackagePrivateAccess, options.experimental); - - if (options.customInlineDefinitions != null) { - options.inlineResolver = new CustomInlineMethodResolver(options.classPath, - options.customInlineDefinitions); - } - } catch (Exception ex) { - System.err.println("\n\nError occurred while loading boot class path files. Aborting."); - ex.printStackTrace(System.err); - return false; - } - } - - if (options.resourceIdFileEntries != null) { - class PublicHandler extends DefaultHandler { - String prefix = null; - public PublicHandler(String prefix) { - super(); - this.prefix = prefix; - } - - public void startElement(String uri, String localName, - String qName, Attributes attr) throws SAXException { - if (qName.equals("public")) { - String type = attr.getValue("type"); - String name = attr.getValue("name").replace('.', '_'); - Integer public_key = Integer.decode(attr.getValue("id")); - String public_val = new StringBuffer() - .append(prefix) - .append(".") - .append(type) - .append(".") - .append(name) - .toString(); - options.resourceIds.put(public_key, public_val); - } - } - }; - - for (Entry entry: options.resourceIdFileEntries.entrySet()) { - try { - SAXParser saxp = SAXParserFactory.newInstance().newSAXParser(); - String prefix = entry.getValue(); - saxp.parse(entry.getKey(), new PublicHandler(prefix)); - } catch (ParserConfigurationException e) { - continue; - } catch (SAXException e) { - continue; - } catch (IOException e) { - continue; - } - } - } - - File outputDirectoryFile = new File(options.outputDirectory); - if (!outputDirectoryFile.exists()) { - if (!outputDirectoryFile.mkdirs()) { - System.err.println("Can't create the output directory " + options.outputDirectory); - return false; - } - } - - //sort the classes, so that if we're on a case-insensitive file system and need to handle classes with file - //name collisions, then we'll use the same name for each class, if the dex file goes through multiple - //baksmali/smali cycles for some reason. If a class with a colliding name is added or removed, the filenames - //may still change of course - List classDefs = Ordering.natural().sortedCopy(dexFile.getClasses()); - - if (!options.noAccessorComments) { - options.syntheticAccessorResolver = new SyntheticAccessorResolver(classDefs); - } - - final ClassFileNameHandler fileNameHandler = new ClassFileNameHandler(outputDirectoryFile, ".smali"); - - ExecutorService executor = Executors.newFixedThreadPool(options.jobs); - List> tasks = Lists.newArrayList(); - - for (final ClassDef classDef: classDefs) { - tasks.add(executor.submit(new Callable() { - @Override public Boolean call() throws Exception { - return disassembleClass(classDef, fileNameHandler, options); - } - })); - } - - boolean errorOccurred = false; - try { - for (Future task: tasks) { - while(true) { - try { - if (!task.get()) { - errorOccurred = true; - } - } catch (InterruptedException ex) { - continue; - } catch (ExecutionException ex) { - throw new RuntimeException(ex); - } - break; - } - } - } finally { - executor.shutdown(); - } - return !errorOccurred; - } - - private static boolean disassembleClass(ClassDef classDef, ClassFileNameHandler fileNameHandler, - baksmaliOptions options) { - /** - * The path for the disassembly file is based on the package name - * The class descriptor will look something like: - * Ljava/lang/Object; - * Where the there is leading 'L' and a trailing ';', and the parts of the - * package name are separated by '/' - */ - String classDescriptor = classDef.getType(); - - //validate that the descriptor is formatted like we expect - if (classDescriptor.charAt(0) != 'L' || - classDescriptor.charAt(classDescriptor.length()-1) != ';') { - System.err.println("Unrecognized class descriptor - " + classDescriptor + " - skipping class"); - return false; - } - - File smaliFile = fileNameHandler.getUniqueFilenameForClass(classDescriptor); - - //create and initialize the top level string template - ClassDefinition classDefinition = new ClassDefinition(options, classDef); - - //write the disassembly - Writer writer = null; - try - { - File smaliParent = smaliFile.getParentFile(); - if (!smaliParent.exists()) { - if (!smaliParent.mkdirs()) { - // check again, it's likely it was created in a different thread - if (!smaliParent.exists()) { - System.err.println("Unable to create directory " + smaliParent.toString() + " - skipping class"); - return false; - } - } - } - - if (!smaliFile.exists()){ - if (!smaliFile.createNewFile()) { - System.err.println("Unable to create file " + smaliFile.toString() + " - skipping class"); - return false; - } - } - - BufferedWriter bufWriter = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(smaliFile), "UTF8")); - - writer = new IndentingWriter(bufWriter); - classDefinition.writeTo((IndentingWriter)writer); - } catch (Exception ex) { - System.err.println("\n\nError occurred while disassembling class " + classDescriptor.replace('/', '.') + " - skipping class"); - ex.printStackTrace(); - // noinspection ResultOfMethodCallIgnored - smaliFile.delete(); - return false; - } - finally - { - if (writer != null) { - try { - writer.close(); - } catch (Throwable ex) { - System.err.println("\n\nError occurred while closing file " + smaliFile.toString()); - ex.printStackTrace(); - } - } - } - return true; - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmaliOptions.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmaliOptions.java deleted file mode 100644 index 754cdf10..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmaliOptions.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import com.google.common.collect.Lists; -import org.jf.dexlib2.analysis.ClassPath; -import org.jf.dexlib2.analysis.InlineMethodResolver; -import org.jf.dexlib2.util.SyntheticAccessorResolver; - -import java.io.File; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class baksmaliOptions { - // register info values - public static final int ALL = 1; - public static final int ALLPRE = 2; - public static final int ALLPOST = 4; - public static final int ARGS = 8; - public static final int DEST = 16; - public static final int MERGE = 32; - public static final int FULLMERGE = 64; - - public static final int DIFFPRE = 128; - - public int apiLevel = 15; - public String outputDirectory = "out"; - public String dexEntry = "classes.dex"; - public List bootClassPathDirs = Lists.newArrayList(); - - public List bootClassPathEntries = Lists.newArrayList(); - public List extraClassPathEntries = Lists.newArrayList(); - - public Map resourceIdFileEntries = new HashMap(); - public Map resourceIds = new HashMap(); - - public boolean noParameterRegisters = false; - public boolean useLocalsDirective = false; - public boolean useSequentialLabels = false; - public boolean outputDebugInfo = true; - public boolean addCodeOffsets = false; - public boolean noAccessorComments = false; - public boolean allowOdex = false; - public boolean deodex = false; - public boolean experimental = false; - public boolean ignoreErrors = false; - public boolean checkPackagePrivateAccess = false; - public boolean useImplicitReferences = false; - public File customInlineDefinitions = null; - public InlineMethodResolver inlineResolver = null; - public int registerInfo = 0; - public ClassPath classPath = null; - public int jobs = -1; - - public SyntheticAccessorResolver syntheticAccessorResolver = null; - - public void setBootClassPath(String bootClassPath) { - bootClassPathEntries = Lists.newArrayList(bootClassPath.split(":")); - } - - public void addExtraClassPath(String extraClassPath) { - if (extraClassPath.startsWith(":")) { - extraClassPath = extraClassPath.substring(1); - } - extraClassPathEntries.addAll(Arrays.asList(extraClassPath.split(":"))); - } - - public void setResourceIdFiles(String resourceIdFiles) { - for (String resourceIdFile: resourceIdFiles.split(":")) { - String[] entry = resourceIdFile.split("="); - resourceIdFileEntries.put(entry[1], entry[0]); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/dump.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/dump.java deleted file mode 100644 index 1ef7df0e..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/dump.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import org.jf.dexlib2.Opcodes; -import org.jf.dexlib2.dexbacked.DexBackedDexFile; -import org.jf.dexlib2.dexbacked.raw.RawDexFile; -import org.jf.dexlib2.dexbacked.raw.util.DexAnnotator; -import org.jf.util.ConsoleUtil; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; - -public class dump { - public static void dump(DexBackedDexFile dexFile, String dumpFileName, int apiLevel, boolean experimental) throws IOException { - if (dumpFileName != null) { - Writer writer = null; - - try { - writer = new BufferedWriter(new FileWriter(dumpFileName)); - - int consoleWidth = ConsoleUtil.getConsoleWidth(); - if (consoleWidth <= 0) { - consoleWidth = 120; - } - - RawDexFile rawDexFile = new RawDexFile(new Opcodes(apiLevel, experimental), dexFile); - DexAnnotator annotator = new DexAnnotator(rawDexFile, consoleWidth); - annotator.writeAnnotations(writer); - } catch (IOException ex) { - System.err.println("There was an error while dumping the dex file to " + dumpFileName); - ex.printStackTrace(System.err); - } finally { - if (writer != null) { - try { - writer.close(); - } catch (IOException ex) { - System.err.println("There was an error while closing the dump file " + dumpFileName); - ex.printStackTrace(System.err); - } - } - } - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/main.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/main.java deleted file mode 100644 index 71598fa6..00000000 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/main.java +++ /dev/null @@ -1,566 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2010 Ben Gruver (JesusFreke) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import com.google.common.collect.Lists; -import org.apache.commons.cli.*; -import org.jf.dexlib2.DexFileFactory; -import org.jf.dexlib2.analysis.InlineMethodResolver; -import org.jf.dexlib2.dexbacked.DexBackedDexFile; -import org.jf.dexlib2.dexbacked.DexBackedOdexFile; -import org.jf.util.ConsoleUtil; -import org.jf.util.SmaliHelpFormatter; - -import javax.annotation.Nonnull; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; -import java.util.Locale; -import java.util.Properties; - -public class main { - - public static final String VERSION; - - private static final Options basicOptions; - private static final Options debugOptions; - private static final Options options; - - static { - options = new Options(); - basicOptions = new Options(); - debugOptions = new Options(); - buildOptions(); - - InputStream templateStream = baksmali.class.getClassLoader().getResourceAsStream("baksmali.properties"); - if (templateStream != null) { - Properties properties = new Properties(); - String version = "(unknown)"; - try { - properties.load(templateStream); - version = properties.getProperty("application.version"); - } catch (IOException ex) { - // ignore - } - VERSION = version; - } else { - VERSION = "[unknown version]"; - } - } - - /** - * This class is uninstantiable. - */ - private main() { - } - - /** - * Run! - */ - public static void main(String[] args) throws IOException { - Locale locale = new Locale("en", "US"); - Locale.setDefault(locale); - - CommandLineParser parser = new PosixParser(); - CommandLine commandLine; - - try { - commandLine = parser.parse(options, args); - } catch (ParseException ex) { - usage(); - return; - } - - baksmaliOptions options = new baksmaliOptions(); - - boolean disassemble = true; - boolean doDump = false; - String dumpFileName = null; - boolean setBootClassPath = false; - - String[] remainingArgs = commandLine.getArgs(); - Option[] clOptions = commandLine.getOptions(); - - for (int i=0; i 6) { - options.jobs = 6; - } - } - - String inputDexFileName = remainingArgs[0]; - - File dexFileFile = new File(inputDexFileName); - if (!dexFileFile.exists()) { - System.err.println("Can't find the file " + inputDexFileName); - System.exit(1); - } - - //Read in and parse the dex file - DexBackedDexFile dexFile = DexFileFactory.loadDexFile(dexFileFile, options.dexEntry, - options.apiLevel, options.experimental); - - if (dexFile.isOdexFile()) { - if (!options.deodex) { - System.err.println("Warning: You are disassembling an odex file without deodexing it. You"); - System.err.println("won't be able to re-assemble the results unless you deodex it with the -x"); - System.err.println("option"); - options.allowOdex = true; - } - } else { - options.deodex = false; - } - - if (!setBootClassPath && (options.deodex || options.registerInfo != 0)) { - if (dexFile instanceof DexBackedOdexFile) { - options.bootClassPathEntries = ((DexBackedOdexFile)dexFile).getDependencies(); - } else { - options.bootClassPathEntries = getDefaultBootClassPathForApi(options.apiLevel, - options.experimental); - } - } - - if (options.customInlineDefinitions == null && dexFile instanceof DexBackedOdexFile) { - options.inlineResolver = - InlineMethodResolver.createInlineMethodResolver( - ((DexBackedOdexFile)dexFile).getOdexVersion()); - } - - boolean errorOccurred = false; - if (disassemble) { - errorOccurred = !baksmali.disassembleDexFile(dexFile, options); - } - - if (doDump) { - if (dumpFileName == null) { - dumpFileName = commandLine.getOptionValue(inputDexFileName + ".dump"); - } - dump.dump(dexFile, dumpFileName, options.apiLevel, options.experimental); - } - - if (errorOccurred) { - System.exit(1); - } - } - - /** - * Prints the usage message. - */ - private static void usage(boolean printDebugOptions) { - SmaliHelpFormatter formatter = new SmaliHelpFormatter(); - int consoleWidth = ConsoleUtil.getConsoleWidth(); - if (consoleWidth <= 0) { - consoleWidth = 80; - } - - formatter.setWidth(consoleWidth); - - formatter.printHelp("java -jar baksmali.jar [options] ", - "disassembles and/or dumps a dex file", basicOptions, printDebugOptions?debugOptions:null); - } - - private static void usage() { - usage(false); - } - - /** - * Prints the version message. - */ - protected static void version() { - System.out.println("baksmali " + VERSION + " (http://smali.googlecode.com)"); - System.out.println("Copyright (C) 2010 Ben Gruver (JesusFreke@JesusFreke.com)"); - System.out.println("BSD license (http://www.opensource.org/licenses/bsd-license.php)"); - System.exit(0); - } - - @SuppressWarnings("AccessStaticViaInstance") - private static void buildOptions() { - Option versionOption = OptionBuilder.withLongOpt("version") - .withDescription("prints the version then exits") - .create("v"); - - Option helpOption = OptionBuilder.withLongOpt("help") - .withDescription("prints the help message then exits. Specify twice for debug options") - .create("?"); - - Option outputDirOption = OptionBuilder.withLongOpt("output") - .withDescription("the directory where the disassembled files will be placed. The default is out") - .hasArg() - .withArgName("DIR") - .create("o"); - - Option noParameterRegistersOption = OptionBuilder.withLongOpt("no-parameter-registers") - .withDescription("use the v syntax instead of the p syntax for registers mapped to method " + - "parameters") - .create("p"); - - Option deodexerantOption = OptionBuilder.withLongOpt("deodex") - .withDescription("deodex the given odex file. This option is ignored if the input file is not an " + - "odex file") - .create("x"); - - Option experimentalOption = OptionBuilder.withLongOpt("experimental") - .withDescription("enable experimental opcodes to be disassembled, even if they aren't necessarily supported in the Android runtime yet") - .create("X"); - - Option useLocalsOption = OptionBuilder.withLongOpt("use-locals") - .withDescription("output the .locals directive with the number of non-parameter registers, rather" + - " than the .register directive with the total number of register") - .create("l"); - - Option sequentialLabelsOption = OptionBuilder.withLongOpt("sequential-labels") - .withDescription("create label names using a sequential numbering scheme per label type, rather than " + - "using the bytecode address") - .create("s"); - - Option noDebugInfoOption = OptionBuilder.withLongOpt("no-debug-info") - .withDescription("don't write out debug info (.local, .param, .line, etc.)") - .create("b"); - - Option registerInfoOption = OptionBuilder.withLongOpt("register-info") - .hasOptionalArgs() - .withArgName("REGISTER_INFO_TYPES") - .withValueSeparator(',') - .withDescription("print the specificed type(s) of register information for each instruction. " + - "\"ARGS,DEST\" is the default if no types are specified.\nValid values are:\nALL: all " + - "pre- and post-instruction registers.\nALLPRE: all pre-instruction registers\nALLPOST: all " + - "post-instruction registers\nARGS: any pre-instruction registers used as arguments to the " + - "instruction\nDEST: the post-instruction destination register, if any\nMERGE: Any " + - "pre-instruction register has been merged from more than 1 different post-instruction " + - "register from its predecessors\nFULLMERGE: For each register that would be printed by " + - "MERGE, also show the incoming register types that were merged") - .create("r"); - - Option classPathOption = OptionBuilder.withLongOpt("bootclasspath") - .withDescription("the bootclasspath jars to use, for analysis. Defaults to " + - "core.jar:ext.jar:framework.jar:android.policy.jar:services.jar. If the value begins with a " + - ":, it will be appended to the default bootclasspath instead of replacing it") - .hasOptionalArg() - .withArgName("BOOTCLASSPATH") - .create("c"); - - Option classPathDirOption = OptionBuilder.withLongOpt("bootclasspath-dir") - .withDescription("the base folder to look for the bootclasspath files in. Defaults to the current " + - "directory") - .hasArg() - .withArgName("DIR") - .create("d"); - - Option codeOffsetOption = OptionBuilder.withLongOpt("code-offsets") - .withDescription("add comments to the disassembly containing the code offset for each address") - .create("f"); - - Option noAccessorCommentsOption = OptionBuilder.withLongOpt("no-accessor-comments") - .withDescription("don't output helper comments for synthetic accessors") - .create("m"); - - Option apiLevelOption = OptionBuilder.withLongOpt("api-level") - .withDescription("The numeric api-level of the file being disassembled. If not " + - "specified, it defaults to 15 (ICS).") - .hasArg() - .withArgName("API_LEVEL") - .create("a"); - - Option jobsOption = OptionBuilder.withLongOpt("jobs") - .withDescription("The number of threads to use. Defaults to the number of cores available, up to a " + - "maximum of 6") - .hasArg() - .withArgName("NUM_THREADS") - .create("j"); - - Option resourceIdFilesOption = OptionBuilder.withLongOpt("resource-id-files") - .withDescription("the resource ID files to use, for analysis. A colon-separated list of prefix=file " + - "pairs. For example R=res/values/public.xml:" + - "android.R=$ANDROID_HOME/platforms/android-19/data/res/values/public.xml") - .hasArg() - .withArgName("FILES") - .create("i"); - - Option noImplicitReferencesOption = OptionBuilder.withLongOpt("implicit-references") - .withDescription("Use implicit (type-less) method and field references") - .create("t"); - - Option checkPackagePrivateAccessOption = OptionBuilder.withLongOpt("check-package-private-access") - .withDescription("When deodexing, use the package-private access check when calculating vtable " + - "indexes. It should only be needed for 4.2.0 odexes. The functionality was reverted for " + - "4.2.1.") - .create("k"); - - Option dumpOption = OptionBuilder.withLongOpt("dump-to") - .withDescription("dumps the given dex file into a single annotated dump file named FILE" + - " (.dump by default), along with the normal disassembly") - .hasOptionalArg() - .withArgName("FILE") - .create("D"); - - Option ignoreErrorsOption = OptionBuilder.withLongOpt("ignore-errors") - .withDescription("ignores any non-fatal errors that occur while disassembling/deodexing," + - " ignoring the class if needed, and continuing with the next class. The default" + - " behavior is to stop disassembling and exit once an error is encountered") - .create("I"); - - Option noDisassemblyOption = OptionBuilder.withLongOpt("no-disassembly") - .withDescription("suppresses the output of the disassembly") - .create("N"); - - Option inlineTableOption = OptionBuilder.withLongOpt("inline-table") - .withDescription("specify a file containing a custom inline method table to use for deodexing") - .hasArg() - .withArgName("FILE") - .create("T"); - - Option dexEntryOption = OptionBuilder.withLongOpt("dex-file") - .withDescription("looks for dex file named DEX_FILE, defaults to classes.dex") - .withArgName("DEX_FILE") - .hasArg() - .create("e"); - - basicOptions.addOption(versionOption); - basicOptions.addOption(helpOption); - basicOptions.addOption(outputDirOption); - basicOptions.addOption(noParameterRegistersOption); - basicOptions.addOption(deodexerantOption); - basicOptions.addOption(experimentalOption); - basicOptions.addOption(useLocalsOption); - basicOptions.addOption(sequentialLabelsOption); - basicOptions.addOption(noDebugInfoOption); - basicOptions.addOption(registerInfoOption); - basicOptions.addOption(classPathOption); - basicOptions.addOption(classPathDirOption); - basicOptions.addOption(codeOffsetOption); - basicOptions.addOption(noAccessorCommentsOption); - basicOptions.addOption(apiLevelOption); - basicOptions.addOption(jobsOption); - basicOptions.addOption(resourceIdFilesOption); - basicOptions.addOption(noImplicitReferencesOption); - basicOptions.addOption(dexEntryOption); - basicOptions.addOption(checkPackagePrivateAccessOption); - - debugOptions.addOption(dumpOption); - debugOptions.addOption(ignoreErrorsOption); - debugOptions.addOption(noDisassemblyOption); - debugOptions.addOption(inlineTableOption); - - for (Object option: basicOptions.getOptions()) { - options.addOption((Option)option); - } - for (Object option: debugOptions.getOptions()) { - options.addOption((Option)option); - } - } - - @Nonnull - private static List getDefaultBootClassPathForApi(int apiLevel, boolean experimental) { - if (apiLevel < 9) { - return Lists.newArrayList( - "/system/framework/core.jar", - "/system/framework/ext.jar", - "/system/framework/framework.jar", - "/system/framework/android.policy.jar", - "/system/framework/services.jar"); - } else if (apiLevel < 12) { - return Lists.newArrayList( - "/system/framework/core.jar", - "/system/framework/bouncycastle.jar", - "/system/framework/ext.jar", - "/system/framework/framework.jar", - "/system/framework/android.policy.jar", - "/system/framework/services.jar", - "/system/framework/core-junit.jar"); - } else if (apiLevel < 14) { - return Lists.newArrayList( - "/system/framework/core.jar", - "/system/framework/apache-xml.jar", - "/system/framework/bouncycastle.jar", - "/system/framework/ext.jar", - "/system/framework/framework.jar", - "/system/framework/android.policy.jar", - "/system/framework/services.jar", - "/system/framework/core-junit.jar"); - } else if (apiLevel < 16) { - return Lists.newArrayList( - "/system/framework/core.jar", - "/system/framework/core-junit.jar", - "/system/framework/bouncycastle.jar", - "/system/framework/ext.jar", - "/system/framework/framework.jar", - "/system/framework/android.policy.jar", - "/system/framework/services.jar", - "/system/framework/apache-xml.jar", - "/system/framework/filterfw.jar"); - - } else { - // this is correct as of api 17/4.2.2 - return Lists.newArrayList( - "/system/framework/core.jar", - "/system/framework/core-junit.jar", - "/system/framework/bouncycastle.jar", - "/system/framework/ext.jar", - "/system/framework/framework.jar", - "/system/framework/telephony-common.jar", - "/system/framework/mms-common.jar", - "/system/framework/android.policy.jar", - "/system/framework/services.jar", - "/system/framework/apache-xml.jar"); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/main/resources/baksmali.properties b/brut.apktool.smali/baksmali/src/main/resources/baksmali.properties deleted file mode 100644 index df22408c..00000000 --- a/brut.apktool.smali/baksmali/src/main/resources/baksmali.properties +++ /dev/null @@ -1 +0,0 @@ -application.version=${version} \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/AnalysisTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/AnalysisTest.java deleted file mode 100644 index 725032af..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/AnalysisTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; -import junit.framework.Assert; -import org.jf.baksmali.Adaptors.ClassDefinition; -import org.jf.dexlib2.DexFileFactory; -import org.jf.dexlib2.analysis.ClassPath; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.dexlib2.iface.DexFile; -import org.jf.util.IndentingWriter; -import org.jf.util.TextUtils; -import org.junit.Test; - -import javax.annotation.Nonnull; -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; -import java.net.URISyntaxException; -import java.net.URL; - -public class AnalysisTest { - - @Test - public void ConstructorTest() throws IOException, URISyntaxException { - runTest("ConstructorTest", true); - } - - @Test - public void RegisterEqualityOnMergeTest() throws IOException, URISyntaxException { - runTest("RegisterEqualityOnMergeTest", true); - } - - @Test - public void UninitRefIdentityTest() throws IOException, URISyntaxException { - runTest("UninitRefIdentityTest", true); - } - - @Test - public void MultipleStartInstructionsTest() throws IOException, URISyntaxException { - runTest("MultipleStartInstructionsTest", true); - } - - @Test - public void DuplicateTest() throws IOException, URISyntaxException { - runTest("DuplicateTest", false); - } - - @Test - public void LocalTest() throws IOException, URISyntaxException { - runTest("LocalTest", false); - } - - public void runTest(String test, boolean registerInfo) throws IOException, URISyntaxException { - String dexFilePath = String.format("%s%sclasses.dex", test, File.separatorChar); - - DexFile dexFile = DexFileFactory.loadDexFile(findResource(dexFilePath), 15, false); - - baksmaliOptions options = new baksmaliOptions(); - if (registerInfo) { - options.registerInfo = baksmaliOptions.ALL | baksmaliOptions.FULLMERGE; - options.classPath = new ClassPath(); - } - options.useImplicitReferences = false; - - for (ClassDef classDef: dexFile.getClasses()) { - StringWriter stringWriter = new StringWriter(); - IndentingWriter writer = new IndentingWriter(stringWriter); - ClassDefinition classDefinition = new ClassDefinition(options, classDef); - classDefinition.writeTo(writer); - writer.close(); - - String className = classDef.getType(); - String smaliPath = String.format("%s%s%s.smali", test, File.separatorChar, - className.substring(1, className.length() - 1)); - String smaliContents = readResource(smaliPath); - - Assert.assertEquals(TextUtils.normalizeNewlines(smaliContents), - TextUtils.normalizeNewlines(stringWriter.toString())); - } - } - - @Nonnull - private File findResource(String resource) throws URISyntaxException { - URL resUrl = Resources.getResource(resource); - return new File(resUrl.toURI()); - } - - @Nonnull - private String readResource(String resource) throws URISyntaxException, IOException { - URL url = Resources.getResource(resource); - return Resources.toString(url, Charsets.UTF_8); - } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/BaksmaliTestUtils.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/BaksmaliTestUtils.java deleted file mode 100644 index 1c570b6c..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/BaksmaliTestUtils.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import com.google.common.io.ByteStreams; -import junit.framework.Assert; - -import org.antlr.runtime.RecognitionException; -import org.jf.baksmali.Adaptors.ClassDefinition; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.smali.SmaliTestUtils; -import org.jf.util.IndentingWriter; -import org.jf.util.TextUtils; - -import javax.annotation.Nonnull; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; - -public class BaksmaliTestUtils { - public static void assertSmaliCompiledEquals(String source, String expected, - baksmaliOptions options, boolean stripComments) throws IOException, - RecognitionException { - ClassDef classDef = SmaliTestUtils.compileSmali(source, options.apiLevel, - options.experimental); - - // Remove unnecessary whitespace and optionally strip all comments from smali file - String normalizedActual = getNormalizedSmali(classDef, options, stripComments); - String normalizedExpected = normalizeSmali(expected, stripComments); - - // Assert that normalized strings are now equal - Assert.assertEquals(normalizedExpected, normalizedActual); - } - - public static void assertSmaliCompiledEquals(String source, String expected, - baksmaliOptions options) throws IOException, RecognitionException { - assertSmaliCompiledEquals(source, expected, options, false); - } - - public static void assertSmaliCompiledEquals(String source, String expected) - throws IOException, RecognitionException { - baksmaliOptions options = new baksmaliOptions(); - assertSmaliCompiledEquals(source, expected, options); - } - - @Nonnull - public static String normalizeSmali(@Nonnull String smaliText, boolean stripComments) { - if (stripComments) { - smaliText = TextUtils.stripComments(smaliText); - } - return TextUtils.normalizeWhitespace(smaliText); - } - - @Nonnull - public static String getNormalizedSmali(@Nonnull ClassDef classDef, @Nonnull baksmaliOptions options, - boolean stripComments) - throws IOException { - StringWriter stringWriter = new StringWriter(); - IndentingWriter writer = new IndentingWriter(stringWriter); - ClassDefinition classDefinition = new ClassDefinition(options, classDef); - classDefinition.writeTo(writer); - writer.close(); - return normalizeSmali(stringWriter.toString(), stripComments); - } - - @Nonnull - public static byte[] readResourceBytesFully(@Nonnull String fileName) throws IOException { - InputStream smaliStream = RoundtripTest.class.getClassLoader(). - getResourceAsStream(fileName); - if (smaliStream == null) { - org.junit.Assert.fail("Could not load " + fileName); - } - - return ByteStreams.toByteArray(smaliStream); - } - - @Nonnull - public static String readResourceFully(@Nonnull String fileName) throws IOException { - return readResourceFully(fileName, "UTF-8"); - } - - @Nonnull - public static String readResourceFully(@Nonnull String fileName, @Nonnull String encoding) - throws IOException { - return new String(readResourceBytesFully(fileName), encoding); - } - - // Static helpers class; do not instantiate. - private BaksmaliTestUtils() { throw new AssertionError(); } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/DisassemblyTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/DisassemblyTest.java deleted file mode 100644 index 35304f7e..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/DisassemblyTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import com.google.common.collect.Iterables; -import org.jf.dexlib2.Opcodes; -import org.jf.dexlib2.dexbacked.DexBackedDexFile; -import org.jf.dexlib2.iface.ClassDef; -import org.junit.Assert; - -import javax.annotation.Nonnull; -import java.io.File; -import java.io.IOException; - -/** - * A base test class for performing a disassembly on a dex file and verifying the results - * - * The test accepts a single-class dex file as input, disassembles it, and verifies that - * the result equals a known-good output smali file. - * - * By default, the input and output files should be resources at [testDir]/[testName]Input.dex - * and [testDir]/[testName]Output.smali respectively - */ -public class DisassemblyTest { - protected final String testDir; - - protected DisassemblyTest(@Nonnull String testDir) { - this.testDir = testDir; - } - - protected DisassemblyTest() { - this.testDir = this.getClass().getSimpleName(); - } - - @Nonnull - protected String getInputFilename(@Nonnull String testName) { - return String.format("%s%s%sInput.dex", testDir, File.separatorChar, testName); - } - - @Nonnull - protected String getOutputFilename(@Nonnull String testName) { - return String.format("%s%s%sOutput.smali", testDir, File.separatorChar, testName); - } - - protected void runTest(@Nonnull String testName) { - runTest(testName, new baksmaliOptions()); - } - - protected void runTest(@Nonnull String testName, @Nonnull baksmaliOptions options) { - try { - // Load file from resources as a stream - String inputFilename = getInputFilename(testName); - byte[] inputBytes = BaksmaliTestUtils.readResourceBytesFully(getInputFilename(testName)); - - DexBackedDexFile inputDex = new DexBackedDexFile(new Opcodes(options.apiLevel, false), inputBytes); - Assert.assertEquals(1, inputDex.getClassCount()); - ClassDef inputClass = Iterables.getFirst(inputDex.getClasses(), null); - Assert.assertNotNull(inputClass); - String input = BaksmaliTestUtils.getNormalizedSmali(inputClass, options, true); - - String output; - if (getOutputFilename(testName).equals(inputFilename)) { - output = input; - } else { - output = BaksmaliTestUtils.readResourceFully(getOutputFilename(testName)); - } - output = BaksmaliTestUtils.normalizeSmali(output, true); - - // Run smali, baksmali, and then compare strings are equal (minus comments/whitespace) - Assert.assertEquals(output, input); - } catch (IOException ex) { - Assert.fail(); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/IdenticalRoundtripTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/IdenticalRoundtripTest.java deleted file mode 100644 index e636ee1e..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/IdenticalRoundtripTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import javax.annotation.Nonnull; -import java.io.File; - -/** - * A base test class for performing a roundtrip assembly/disassembly where the input and output - * should be identical. - * - * By default, the input/output file should be a resource at [testDir]/[testName].smali - */ -public abstract class IdenticalRoundtripTest extends RoundtripTest { - - public IdenticalRoundtripTest(@Nonnull String testDir) { - super(testDir); - } - - public IdenticalRoundtripTest() { - } - - @Nonnull @Override protected String getInputFilename(@Nonnull String testName) { - return String.format("%s%s%s.smali", testDir, File.separatorChar, testName); - } - - @Nonnull @Override protected String getOutputFilename(@Nonnull String testName) { - return getInputFilename(testName); - } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/ImplicitReferenceTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/ImplicitReferenceTest.java deleted file mode 100644 index 1f2ae5bf..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/ImplicitReferenceTest.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright 2014, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import org.antlr.runtime.RecognitionException; -import org.junit.Test; - -import java.io.IOException; - -public class ImplicitReferenceTest { - @Test - public void testImplicitMethodReferences() throws IOException, RecognitionException { - String source = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 1\n" + - " invoke-static {p0}, LHelloWorld;->toString()V\n" + - " invoke-static {p0}, LHelloWorld;->V()V\n" + - " invoke-static {p0}, LHelloWorld;->I()V\n" + - " return-void\n" + - ".end method"; - - String expected = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - "# direct methods\n" + - ".method public static main([Ljava/lang/String;)V\n" + - ".registers 1\n" + - "invoke-static {p0}, toString()V\n" + - "invoke-static {p0}, V()V\n" + - "invoke-static {p0}, I()V\n" + - "return-void\n" + - ".end method\n"; - - baksmaliOptions options = new baksmaliOptions(); - options.useImplicitReferences = true; - - BaksmaliTestUtils.assertSmaliCompiledEquals(source, expected, options); - } - - @Test - public void testExplicitMethodReferences() throws IOException, RecognitionException { - String source = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 1\n" + - " invoke-static {p0}, LHelloWorld;->toString()V\n" + - " invoke-static {p0}, LHelloWorld;->V()V\n" + - " invoke-static {p0}, LHelloWorld;->I()V\n" + - " return-void\n" + - ".end method"; - - String expected = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - "# direct methods\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 1\n" + - " invoke-static {p0}, LHelloWorld;->toString()V\n" + - " invoke-static {p0}, LHelloWorld;->V()V\n" + - " invoke-static {p0}, LHelloWorld;->I()V\n" + - " return-void\n" + - ".end method\n"; - - baksmaliOptions options = new baksmaliOptions(); - options.useImplicitReferences = false; - - BaksmaliTestUtils.assertSmaliCompiledEquals(source, expected, options); - } - - @Test - public void testImplicitMethodLiterals() throws IOException, RecognitionException { - String source = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".field public static field1:Ljava/lang/reflect/Method; = LHelloWorld;->toString()V\n" + - ".field public static field2:Ljava/lang/reflect/Method; = LHelloWorld;->V()V\n" + - ".field public static field3:Ljava/lang/reflect/Method; = LHelloWorld;->I()V\n" + - ".field public static field4:Ljava/lang/Class; = I"; - - String expected = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - "# static fields\n" + - ".field public static field1:Ljava/lang/reflect/Method; = toString()V\n" + - ".field public static field2:Ljava/lang/reflect/Method; = V()V\n" + - ".field public static field3:Ljava/lang/reflect/Method; = I()V\n" + - ".field public static field4:Ljava/lang/Class; = I\n"; - - baksmaliOptions options = new baksmaliOptions(); - options.useImplicitReferences = true; - - BaksmaliTestUtils.assertSmaliCompiledEquals(source, expected, options); - } - - @Test - public void testExplicitMethodLiterals() throws IOException, RecognitionException { - String source = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".field public static field1:Ljava/lang/reflect/Method; = LHelloWorld;->toString()V\n" + - ".field public static field2:Ljava/lang/reflect/Method; = LHelloWorld;->V()V\n" + - ".field public static field3:Ljava/lang/reflect/Method; = LHelloWorld;->I()V\n" + - ".field public static field4:Ljava/lang/Class; = I"; - - String expected = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - "# static fields\n" + - ".field public static field1:Ljava/lang/reflect/Method; = LHelloWorld;->toString()V\n" + - ".field public static field2:Ljava/lang/reflect/Method; = LHelloWorld;->V()V\n" + - ".field public static field3:Ljava/lang/reflect/Method; = LHelloWorld;->I()V\n" + - ".field public static field4:Ljava/lang/Class; = I\n"; - - baksmaliOptions options = new baksmaliOptions(); - options.useImplicitReferences = false; - - BaksmaliTestUtils.assertSmaliCompiledEquals(source, expected, options); - } - - @Test - public void testImplicitFieldReferences() throws IOException, RecognitionException { - String source = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 1\n" + - " sget v0, LHelloWorld;->someField:I\n" + - " sget v0, LHelloWorld;->I:I\n" + - " sget v0, LHelloWorld;->V:I\n" + - " return-void\n" + - ".end method"; - - String expected = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - "# direct methods\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 1\n" + - " sget p0, someField:I\n" + - " sget p0, I:I\n" + - " sget p0, V:I\n" + - " return-void\n" + - ".end method\n"; - - baksmaliOptions options = new baksmaliOptions(); - options.useImplicitReferences = true; - - BaksmaliTestUtils.assertSmaliCompiledEquals(source, expected, options); - } - - @Test - public void testExplicitFieldReferences() throws IOException, RecognitionException { - String source = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 1\n" + - " sget v0, LHelloWorld;->someField:I\n" + - " sget v0, LHelloWorld;->I:I\n" + - " sget v0, LHelloWorld;->V:I\n" + - " return-void\n" + - ".end method"; - - String expected = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - "# direct methods\n" + - ".method public static main([Ljava/lang/String;)V\n" + - " .registers 1\n" + - " sget p0, LHelloWorld;->someField:I\n" + - " sget p0, LHelloWorld;->I:I\n" + - " sget p0, LHelloWorld;->V:I\n" + - " return-void\n" + - ".end method\n"; - - baksmaliOptions options = new baksmaliOptions(); - options.useImplicitReferences = false; - - BaksmaliTestUtils.assertSmaliCompiledEquals(source, expected, options); - } - - @Test - public void testImplicitFieldLiterals() throws IOException, RecognitionException { - String source = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".field public static field1:Ljava/lang/reflect/Field; = LHelloWorld;->someField:I\n" + - ".field public static field2:Ljava/lang/reflect/Field; = LHelloWorld;->V:I\n" + - ".field public static field3:Ljava/lang/reflect/Field; = LHelloWorld;->I:I"; - - String expected = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - "# static fields\n" + - ".field public static field1:Ljava/lang/reflect/Field; = someField:I\n" + - ".field public static field2:Ljava/lang/reflect/Field; = V:I\n" + - ".field public static field3:Ljava/lang/reflect/Field; = I:I\n"; - - baksmaliOptions options = new baksmaliOptions(); - options.useImplicitReferences = true; - - BaksmaliTestUtils.assertSmaliCompiledEquals(source, expected, options); - } - - @Test - public void testExplicitFieldLiterals() throws IOException, RecognitionException { - String source = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - ".field public static field1:Ljava/lang/reflect/Field; = LHelloWorld;->someField:I\n" + - ".field public static field2:Ljava/lang/reflect/Field; = LHelloWorld;->V:I\n" + - ".field public static field3:Ljava/lang/reflect/Field; = LHelloWorld;->I:I"; - - String expected = "" + - ".class public LHelloWorld;\n" + - ".super Ljava/lang/Object;\n" + - "# static fields\n" + - ".field public static field1:Ljava/lang/reflect/Field; = LHelloWorld;->someField:I\n" + - ".field public static field2:Ljava/lang/reflect/Field; = LHelloWorld;->V:I\n" + - ".field public static field3:Ljava/lang/reflect/Field; = LHelloWorld;->I:I\n"; - - baksmaliOptions options = new baksmaliOptions(); - options.useImplicitReferences = false; - - BaksmaliTestUtils.assertSmaliCompiledEquals(source, expected, options); - } - -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/InterfaceOrderTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/InterfaceOrderTest.java deleted file mode 100644 index d85d7913..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/InterfaceOrderTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import org.junit.Test; - -public class InterfaceOrderTest extends IdenticalRoundtripTest { - @Test - public void testInterfaceOrder() { - runTest("InterfaceOrder", new baksmaliOptions()); - } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/LambdaTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/LambdaTest.java deleted file mode 100644 index 5431df54..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/LambdaTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import org.junit.Test; - -public class LambdaTest extends IdenticalRoundtripTest { - - private baksmaliOptions createOptions() { - baksmaliOptions options = new baksmaliOptions(); - options.apiLevel = 23; // since we need at least level 23 for lambda opcodes - options.experimental = true; // since these opcodes aren't implemented in runtime yet); - return options; - } - - @Test - public void testHelloWorldLambda() { - runTest("HelloWorldLambda", createOptions()); - } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/ManyRegistersTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/ManyRegistersTest.java deleted file mode 100644 index 5a267161..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/ManyRegistersTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import org.junit.Test; - -public class ManyRegistersTest extends IdenticalRoundtripTest { - - @Test - public void testManyRegisters() { - runTest("ManyRegisters"); - } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/MultiSwitchTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/MultiSwitchTest.java deleted file mode 100644 index cb29402f..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/MultiSwitchTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import org.junit.Test; - -public class MultiSwitchTest extends DisassemblyTest { - - @Test - public void testMultiSwitch() { - runTest("MultiSwitch"); - } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/RoundtripTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/RoundtripTest.java deleted file mode 100644 index c9ff2d4d..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/RoundtripTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import org.antlr.runtime.RecognitionException; -import org.junit.Assert; - -import javax.annotation.Nonnull; -import java.io.File; -import java.io.IOException; - -/** - * A base test class for performing a roundtrip assembly/disassembly - * - * The test accepts a smali file as input, performs a smali -> dex -> smali roundtrip, and - * verifies that the result equals a known-good output smali file. - * - * By default, the input and output files should be resources at [testDir]/[testName]Input.smali - * and [testDir]/[testName]Output.smali respectively - */ -public abstract class RoundtripTest { - protected final String testDir; - - protected RoundtripTest(@Nonnull String testDir) { - this.testDir = testDir; - } - - protected RoundtripTest() { - this.testDir = this.getClass().getSimpleName(); - } - - @Nonnull - protected String getInputFilename(@Nonnull String testName) { - return String.format("%s%s%sInput.smali", testDir, File.separatorChar, testName); - } - - @Nonnull - protected String getOutputFilename(@Nonnull String testName) { - return String.format("%s%s%sOutput.smali", testDir, File.separatorChar, testName); - } - - protected void runTest(@Nonnull String testName) { - runTest(testName, new baksmaliOptions()); - } - - protected void runTest(@Nonnull String testName, @Nonnull baksmaliOptions options) { - try { - // Load file from resources as a stream - String inputFilename = getInputFilename(testName); - String input = BaksmaliTestUtils.readResourceFully(getInputFilename(testName)); - String output; - if (getOutputFilename(testName).equals(inputFilename)) { - output = input; - } else { - output = BaksmaliTestUtils.readResourceFully(getOutputFilename(testName)); - } - - // Run smali, baksmali, and then compare strings are equal (minus comments/whitespace) - BaksmaliTestUtils.assertSmaliCompiledEquals(input, output, options, true); - } catch (IOException ex) { - Assert.fail(); - } catch (RecognitionException ex) { - Assert.fail(); - } - } -} diff --git a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/SwitchTest.java b/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/SwitchTest.java deleted file mode 100644 index 48b64b22..00000000 --- a/brut.apktool.smali/baksmali/src/test/java/org/jf/baksmali/SwitchTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.baksmali; - -import org.junit.Test; - -public class SwitchTest extends RoundtripTest { - @Test - public void testUnorderedSparseSwitch() { - runTest("UnorderedSparseSwitch"); - } -} diff --git a/brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/ConstructorTest.smali b/brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/ConstructorTest.smali deleted file mode 100644 index 88e2eb86..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/ConstructorTest.smali +++ /dev/null @@ -1,16 +0,0 @@ -.class public LConstructorTest; -.super Ljava/lang/Object; - - -# direct methods -.method public constructor ()V - .registers 4 - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(UninitThis,LConstructorTest;); - invoke-direct {p0}, Ljava/lang/Object;->()V - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LConstructorTest;); - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LConstructorTest;); - return-void - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LConstructorTest;); -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/ConstructorTest2.smali b/brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/ConstructorTest2.smali deleted file mode 100644 index a376b25b..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/ConstructorTest2.smali +++ /dev/null @@ -1,25 +0,0 @@ -.class public LConstructorTest2; -.super Ljava/lang/Object; - - -# direct methods -.method public constructor ()V - .registers 4 - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(UninitThis,LConstructorTest2;); - if-eqz p0, :cond_3 - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(UninitThis,LConstructorTest2;); - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(UninitThis,LConstructorTest2;); - nop - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(UninitThis,LConstructorTest2;); - - :cond_3 - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(UninitThis,LConstructorTest2;); - invoke-direct {p0}, Ljava/lang/Object;->()V - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LConstructorTest2;); - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LConstructorTest2;); - return-void - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LConstructorTest2;); -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/classes.dex b/brut.apktool.smali/baksmali/src/test/resources/ConstructorTest/classes.dex deleted file mode 100644 index ef6e6d938bd3454809bf04996169f15263897081..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 520 zcmZuu%}N4M82x6POkBt~PtXGtiX{kBZK|DM3mJk|<1~mSqv=hAHU>gMEe%?Uj}g5< zuTYyFp=G$sbH=$K(Z?Llx%d0M-&}>GY;nIVXGilJ_igX_;re{~eYgAg^Oln@HJ4Y$e5xJ=;X*9MqYq1I@JfpW$0Bz@S5TIyKxe^Xr4L+|^swFF@fs24mei+h@$i>&v| pcXN&jz)9)jzUk+A0i*%FZ)0bzxpNbmaooE=GbY}Xy{^OmxdLJDK)C<_ diff --git a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateDirectMethods.smali b/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateDirectMethods.smali deleted file mode 100644 index fd43b021..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateDirectMethods.smali +++ /dev/null @@ -1,29 +0,0 @@ -.class public LDuplicateDirectMethods; -.super Ljava/lang/Object; - - -# direct methods -.method private alah()V - .registers 1 - - return-void -.end method - -.method private blah()V - .registers 1 - - return-void -.end method - -# duplicate method ignored -# .method private blah()V -# .registers 1 - -# return-void -# .end method - -.method private clah()V - .registers 1 - - return-void -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateDirectVirtualMethods.smali b/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateDirectVirtualMethods.smali deleted file mode 100644 index 52865737..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateDirectVirtualMethods.smali +++ /dev/null @@ -1,46 +0,0 @@ -.class public LDuplicateDirectVirtualMethods; -.super Ljava/lang/Object; - - -# direct methods -.method private blah()V - .registers 1 - - return-void -.end method - -# duplicate method ignored -# .method private blah()V -# .registers 1 - -# return-void -# .end method - - -# virtual methods -.method public alah()V - .registers 1 - - return-void -.end method - -# There is both a direct and virtual method with this signature. -# You will need to rename one of these methods, including all references. -.method public blah()V - .registers 1 - - return-void -.end method - -# duplicate method ignored -# .method public blah()V -# .registers 1 - -# return-void -# .end method - -.method public clah()V - .registers 1 - - return-void -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateInstanceFields.smali b/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateInstanceFields.smali deleted file mode 100644 index 6efe9cf5..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateInstanceFields.smali +++ /dev/null @@ -1,13 +0,0 @@ -.class public LDuplicateInstanceFields; -.super Ljava/lang/Object; - - -# instance fields -.field public alah:I - -.field public blah:I - -# duplicate field ignored -# .field public blah:I - -.field public clah:I diff --git a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateStaticFields.smali b/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateStaticFields.smali deleted file mode 100644 index b71fbdff..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateStaticFields.smali +++ /dev/null @@ -1,13 +0,0 @@ -.class public LDuplicateStaticFields; -.super Ljava/lang/Object; - - -# static fields -.field public static alah:I - -.field public static blah:I - -# duplicate field ignored -# .field public static blah:I - -.field public static clah:I diff --git a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateStaticInstanceFields.smali b/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateStaticInstanceFields.smali deleted file mode 100644 index 9a066b8d..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateStaticInstanceFields.smali +++ /dev/null @@ -1,22 +0,0 @@ -.class public LDuplicateStaticInstanceFields; -.super Ljava/lang/Object; - - -# static fields -.field public static blah:I - -# duplicate field ignored -# .field public static blah:I - - -# instance fields -.field public alah:I - -# There is both a static and instance field with this signature. -# You will need to rename one of these fields, including all references. -.field public blah:I - -# duplicate field ignored -# .field public blah:I - -.field public clah:I diff --git a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateVirtualMethods.smali b/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateVirtualMethods.smali deleted file mode 100644 index 3c080024..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/DuplicateVirtualMethods.smali +++ /dev/null @@ -1,29 +0,0 @@ -.class public LDuplicateVirtualMethods; -.super Ljava/lang/Object; - - -# virtual methods -.method public alah()V - .registers 1 - - return-void -.end method - -.method public blah()V - .registers 1 - - return-void -.end method - -# duplicate method ignored -# .method public blah()V -# .registers 1 - -# return-void -# .end method - -.method public clah()V - .registers 1 - - return-void -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/classes.dex b/brut.apktool.smali/baksmali/src/test/resources/DuplicateTest/classes.dex deleted file mode 100644 index 687694408af7c4546c84b02c5ae4b30863e65917..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1284 zcmd^9J!@1!6uozL-o}leq%l^mm1P2cG{G(i3lRlz>rCE0vTu2=A^Rc;*a&F@sYJwL z3$e0{AXXL;EEVmv5iA6oU}NLgIkPinS>8Wz;JkC^oVj=A!QAO&o73|bE=gne>4V4T z-@p9)`p5nGk0-kay}g~}+wWgC5m^(F&Gy9^kRSJ~$T39J8^91yU?1T8ZQxmmb;Qfy zFGi#ZJgg zva)-pGgy$BrJlR%<_gzeox8r$gS8;q7V8Sv6}#fUDZghYOSJR#a>Et>DxEo8(CQCL z*H5#nc~)=}ZOQ3F_h#wJJdNI1-H|bwJXUvdOWzh|Xw~dlF>k=1a1D&LW;+q{FsbQ* zRehF-zDiU-B)*GOaYs~nUuq3)2w*UoLR1ePEL+#F$oYxfUC2*jfAAK?+eD7C uwAcgth`9~>jBiZr-T2P1<}!+Cb95)0C}I$^Cf^)E%r(CEPL1~ETlN()V - .registers 1 - return-void -.end method - -.method public close()V - .registers 1 - return-void -.end method - -.method public flush()V - .registers 1 - return-void -.end method - -.method public run()V - .registers 1 - return-void -.end method - -.method public update(Ljava/util/Observable;Ljava/lang/Object;)V - .registers 3 - return-void -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/LambdaTest/HelloWorldLambda.smali b/brut.apktool.smali/baksmali/src/test/resources/LambdaTest/HelloWorldLambda.smali deleted file mode 100644 index d70ced50..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/LambdaTest/HelloWorldLambda.smali +++ /dev/null @@ -1,55 +0,0 @@ -.class public LHelloWorldLambda; - -#Ye olde hello world application (with lambdas!) -#To assemble and run this on a phone or emulator: -# -#java -jar smali.jar -o classes.dex HelloWorldLambda.smali HelloWorldFunctionalInterface.smali -#zip HelloWorld.zip classes.dex -#adb push HelloWorld.zip /data/local -#adb shell dalvikvm -cp /data/local/HelloWorld.zip HelloWorld -# -#if you get out of memory type errors when running smali.jar, try -#java -Xmx512m -jar smali.jar HelloWorldLambda.smali -#instead - -.super Ljava/lang/Object; - -.method public static doHelloWorld(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - .registers 6 # 4 parameters, 2 locals - liberate-variable v0, p0, "helloworld" - - sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream; - invoke-virtual {v1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V - - return-void -.end method - -.method public static main([Ljava/lang/String;)V - .registers 9 # 1 parameter, 8 locals - - sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; - - const-string v1, "Hello World!" - const-string v2, "How" # vD - const-string v3, "are" # vE - const-string v4, "you" # vF - const-string v5, "doing?" # vG - - capture-variable v1, "helloworld" - - # TODO: do I need to pass the type of the lambda's functional interface here as a type id? - create-lambda v1, LHelloWorldLambda;->doHelloWorld(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - # Method descriptor is not required here, because only the single-abstract method is ever invoked. - invoke-lambda v1, {v2, v3, v4, v5} - - box-lambda v6, v1 - invoke-virtual {v6, v2, v3, v4, v5}, LHelloWorldFunctionalInterface;->applyFourStrings(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - - # FIXME: should be \HelloWorldFunctionalInterface; instead of L...; - - # TODO: do we really need the type descriptor here at all? - unbox-lambda v7, v6, LHelloWorldFunctionalInterface; - invoke-lambda v7, {v2, v3, v4, v5} - - return-void -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/LocalTest/LocalTest.smali b/brut.apktool.smali/baksmali/src/test/resources/LocalTest/LocalTest.smali deleted file mode 100644 index fe6d1adf..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/LocalTest/LocalTest.smali +++ /dev/null @@ -1,31 +0,0 @@ -.class public LLocalTest; -.super Ljava/lang/Object; - - -# direct methods -.method public static method1()V - .registers 10 - - .local v0, "blah! This local name has some spaces, a colon, even a \nnewline!":I, "some sig info:\nblah." - .local v1, "blah! This local name has some spaces, a colon, even a \nnewline!":V, "some sig info:\nblah." - .local v2, "blah! This local name has some spaces, a colon, even a \nnewline!":I - .local v3, "blah! This local name has some spaces, a colon, even a \nnewline!":V - .local v4, null:I, "some sig info:\nblah." - .local v5, null:V, "some sig info:\nblah." - .local v6, null:I - .local v7 - .local v8 - .local v9 - return-void -.end method - -.method public static method2(IJLjava/lang/String;)V - .registers 10 - .param p0, "blah! This local name has some spaces, a colon, even a \nnewline!" # I - .param p1 # J - .annotation runtime LAnnotationWithValues; - .end annotation - .end param - - return-void -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/LocalTest/classes.dex b/brut.apktool.smali/baksmali/src/test/resources/LocalTest/classes.dex deleted file mode 100644 index 5b6f026e2b07bb3bf629caaf04b81f27b25f53b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 832 zcmZ9Lv1=4T6vp4&Z0_9kFcL&8Cz3McqDB9U-gy#KuR>(1Mc z&z65**;pIC*m^mAezd%KU5iXbWH#7Z!BWYrCDMgPdk4G%Fv$ln7w*3T1%805Fa+3; z4v4^c&;z%?5Znh3z-#aZyaN<2%!jK;0G2>|flqMYJ!ty^oqi$Eh>WVW&cRsv{)PO( zI$=_X+7`7VXXBgR=cO&v+z-<-8QAQxEBbOWj`NYtc3n~SWhI{2L)*)&ANTI=P2A`| z+r9Ep>c@Ri0|^G(JF(o@%WSf0c9XO)8S@x#51dJCVTv3|F|{LCtQ%`ad6xTi;|`t2 zF7ob4mU_1;odZ`U`Tm8ua#7CIk?Gi^{$YMC;t?BlDOK&Pc1cuK9m@{OKTP;)1BWFt?F@4zQ0CxJYehoYI jV|-eT&YIhe59dKcXKYnRqu-_hI)1L_rHSQ#;3@bAY~yYL diff --git a/brut.apktool.smali/baksmali/src/test/resources/ManyRegistersTest/ManyRegisters.smali b/brut.apktool.smali/baksmali/src/test/resources/ManyRegistersTest/ManyRegisters.smali deleted file mode 100644 index 7f7c7bb1..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/ManyRegistersTest/ManyRegisters.smali +++ /dev/null @@ -1,7 +0,0 @@ -.class LManyRegisters; -.super Ljava/lang/Object; - -.method public manyRegisters()V - .registers 65535 - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/resources/MultiSwitchTest/MultiSwitchInput.dex b/brut.apktool.smali/baksmali/src/test/resources/MultiSwitchTest/MultiSwitchInput.dex deleted file mode 100644 index 6ef3d3490eb7ca9f7c95d060564f24a41f3b39d7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 616 zcmZWnu}%U(5S=|i0})Up)>Os>5R6*USy*8#Ot4;$iyVRy?obLpKx1QJVJCke!OGIY zXvq)w2eec+zIS(<5S_cXGy8Vu?d{ApoI$d(vnR9tyQ-eOe7bMr{`lc1o~W$9e-uup zO-rOJB7^#F7A~-<5?MqeoMf--UjA5 zNntGh(JTJfvqHU0kRxKlQ=7Wfr*^7#*l+vp@wMyQ&8lQ;Eq$fSZGCZ8K00kVwqKRZ z!DX+b{he)p%j@X2E2=JQ9cGof+CFz0B`?S}q}SCw&oLy :sswitch_7 - 0xf -> :sswitch_9 - 0x14 -> :sswitch_8 - 0x63 -> :sswitch_a - .end sparse-switch -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/resources/MultiSwitchTest/MultiSwitchOutput.smali b/brut.apktool.smali/baksmali/src/test/resources/MultiSwitchTest/MultiSwitchOutput.smali deleted file mode 100644 index f3aeeed5..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/MultiSwitchTest/MultiSwitchOutput.smali +++ /dev/null @@ -1,119 +0,0 @@ -.class public LMultiSwitch; -.super Ljava/lang/Object; -.source "Format31t.smali" - - -# virtual methods -.method public multi-packed-switch()V - .registers 1 - - const p0, 0xc - - packed-switch p0, :pswitch_data_14 - - goto :goto_b - - :pswitch_7 - return-void - - :pswitch_8 - return-void - - :pswitch_9 - return-void - - :pswitch_a - return-void - - :goto_b - packed-switch p0, :pswitch_data_20 - - nop - - :pswitch_f - return-void - - :pswitch_10 - return-void - - :pswitch_11 - return-void - - :pswitch_12 - return-void - - nop - - :pswitch_data_14 - .packed-switch 0xa - :pswitch_7 - :pswitch_8 - :pswitch_9 - :pswitch_a - .end packed-switch - - :pswitch_data_20 - .packed-switch 0xa - :pswitch_f - :pswitch_10 - :pswitch_11 - :pswitch_12 - .end packed-switch -.end method - -.method public multi-sparse-switch()V - .registers 1 - - const p0, 0xd - - sparse-switch p0, :sswitch_data_14 - - goto :goto_b - - :sswitch_7 - return-void - - :sswitch_8 - return-void - - :sswitch_9 - return-void - - :sswitch_a - return-void - - :goto_b - sparse-switch p0, :sswitch_data_26 - - nop - - :sswitch_f - return-void - - :sswitch_10 - return-void - - :sswitch_11 - return-void - - :sswitch_12 - return-void - - nop - - :sswitch_data_14 - .sparse-switch - 0xa -> :sswitch_7 - 0xf -> :sswitch_9 - 0x14 -> :sswitch_8 - 0x63 -> :sswitch_a - .end sparse-switch - - :sswitch_data_26 - .sparse-switch - 0xa -> :sswitch_f - 0xf -> :sswitch_11 - 0x14 -> :sswitch_10 - 0x63 -> :sswitch_12 - .end sparse-switch -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/MultipleStartInstructionsTest/MultipleStartInstructionsTest.smali b/brut.apktool.smali/baksmali/src/test/resources/MultipleStartInstructionsTest/MultipleStartInstructionsTest.smali deleted file mode 100644 index e329e6c4..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/MultipleStartInstructionsTest/MultipleStartInstructionsTest.smali +++ /dev/null @@ -1,46 +0,0 @@ -.class public LMultipleStartInstructionsTest; -.super Ljava/lang/Object; - - -# direct methods -.method public constructor (Ljava/lang/String;)V - .registers 4 - - :try_start_0 - #v0=(Uninit);v1=(Uninit);p0=(UninitThis,LMultipleStartInstructionsTest;);p1=(Reference,Ljava/lang/String;); - invoke-direct {p0}, Ljava/lang/Object;->()V - #v0=(Uninit);v1=(Uninit);p0=(Reference,LMultipleStartInstructionsTest;);p1=(Reference,Ljava/lang/String;); - - #v0=(Uninit);v1=(Uninit);p0=(Reference,LMultipleStartInstructionsTest;);p1=(Reference,Ljava/lang/String;); - const-string v0, "blah" - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);p0=(Reference,LMultipleStartInstructionsTest;);p1=(Reference,Ljava/lang/String;); - - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);p0=(Reference,LMultipleStartInstructionsTest;);p1=(Reference,Ljava/lang/String;); - return-void - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);p0=(Reference,LMultipleStartInstructionsTest;);p1=(Reference,Ljava/lang/String;); - :try_end_6 - .catchall {:try_start_0 .. :try_end_6} :catchall_6 - - :catchall_6 - :try_start_6 - #v0=(Uninit);v1=(Uninit); - #p0=(Conflicted):merge{Start:(UninitThis,LMultipleStartInstructionsTest;),0x0:(Reference,LMultipleStartInstructionsTest;)} - #p1=(Reference,Ljava/lang/String;); - invoke-static {}, LMultipleStartInstructionsTest;->blah()V - #v0=(Uninit);v1=(Uninit);p0=(Conflicted);p1=(Reference,Ljava/lang/String;); - :try_end_9 - .catchall {:try_start_6 .. :try_end_9} :catchall_9 - - :catchall_9 - #v0=(Uninit);v1=(Uninit); - #p0=(Conflicted):merge{Start:(UninitThis,LMultipleStartInstructionsTest;),0x0:(Reference,LMultipleStartInstructionsTest;),0x6:(Conflicted)} - #p1=(Reference,Ljava/lang/String;); - return-void - #v0=(Uninit);v1=(Uninit);p0=(Conflicted);p1=(Reference,Ljava/lang/String;); -.end method - -.method public static blah()V - .registers 0 - - return-void -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/MultipleStartInstructionsTest/classes.dex b/brut.apktool.smali/baksmali/src/test/resources/MultipleStartInstructionsTest/classes.dex deleted file mode 100644 index f6876c2951d9cc0d14f1f38b0b0a883fd36137bc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 568 zcmY*Wu}Z^G6umEvl~yRFI0>R(V1+6OErQ}AL>wyJ(;8|d#G1a=;-t8WgDxTpwStI~ zgI^*3f{SxMz^$J1+J|_PlY8Fb=7ij{AM~=zrB&%}ZItQ{H%o($*^9^I`*!g4^!)QW zKU#A{S|ZY`trXBqy(y7tFzPOF31Cd_0b41McL1aE33wnw^lS7@paGl$C%_eO2jDh7 ze3!liIco|auW-mrvWuhvBbn2f+w%xTxjzwHxGVDoku3C9-oa@O9yvKSE;-|p2B&Wd zmjjkD>feKQoMd-o!Q1IXI&4KjRr`tFj@vrvG<0|rxA%g!E=$2X^t*mB^5bT4w|*Ej zpsCtFxvG;eZkENVd6KS#aj4hDtw;WW`GTCExkIHgFIe&n6qfx*cAEt=uz7G-HWRx$ h=3)26Ow{6dhPkNx*pvHppwp8%2{>DykI4-4{{`|OM~46a diff --git a/brut.apktool.smali/baksmali/src/test/resources/RegisterEqualityOnMergeTest/RegisterEqualityOnMerge.smali b/brut.apktool.smali/baksmali/src/test/resources/RegisterEqualityOnMergeTest/RegisterEqualityOnMerge.smali deleted file mode 100644 index b2b9b521..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/RegisterEqualityOnMergeTest/RegisterEqualityOnMerge.smali +++ /dev/null @@ -1,37 +0,0 @@ -.class public LRegisterEqualityOnMerge; -.super Ljava/lang/Object; - - -# direct methods -.method public constructor ()V - .registers 4 - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(UninitThis,LRegisterEqualityOnMerge;); - invoke-direct {p0}, Ljava/lang/Object;->()V - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - invoke-virtual {p0}, Ljava/lang/Object;->toString()Ljava/lang/String; - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - move-result-object v0 - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - if-eqz v0, :cond_d - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - invoke-virtual {p0}, Ljava/lang/Object;->toString()Ljava/lang/String; - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - move-result-object v0 - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - - :cond_d - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); - return-void - #v0=(Reference,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LRegisterEqualityOnMerge;); -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/RegisterEqualityOnMergeTest/classes.dex b/brut.apktool.smali/baksmali/src/test/resources/RegisterEqualityOnMergeTest/classes.dex deleted file mode 100644 index 424fc203b70699f89ebe5c556938f186c022a56c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 508 zcmY*Vu}Z^G6un7fl_DW@(yfzgg<23Qb`n7%g$muHKEo?D)-*~*gt+?!;^5%u;2;iC z96E~M;nYtM^qf4O;DwWO-nn@*O%#+ zBQg|`ac`{(Dk_IJ4@KVtZU7g!18kKbo&mfnA3y*x1Mh&3fF+;-bb)O^1DwHooH+-; zDm+keX3rEm>{}Kon?~UnSL7Q-d-Q8~e>X&Y_(LpJk|c2PT$FXpu-cd9u&ZJ{%2c{_ zdKL|IcF{?8RT`_7RKtFB9@Pg?64yKXeRYtv#OX=Ilaq4s#Z0QjtSobPnSOh@eA6 diff --git a/brut.apktool.smali/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchInput.smali b/brut.apktool.smali/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchInput.smali deleted file mode 100644 index 6e3d23d4..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchInput.smali +++ /dev/null @@ -1,35 +0,0 @@ -.class public LUnorderedSparseSwitch; -.super Ljava/lang/Object; - -.method public static test_sparse-switch()V - .registers 1 - - const v0, 13 - - sparse-switch v0, :SparseSwitch - -:Label10 - return-void - -:Label20 - return-void - -:Label15 - return-void - -:Label13 - return-void - -:Label99 - return-void - -# Note: unordered keys -:SparseSwitch - .sparse-switch - 10 -> :Label10 - 20 -> :Label20 - 15 -> :Label15 - 99 -> :Label99 - 13 -> :Label13 - .end sparse-switch -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchOutput.smali b/brut.apktool.smali/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchOutput.smali deleted file mode 100644 index c4c455b6..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchOutput.smali +++ /dev/null @@ -1,28 +0,0 @@ -.class public LUnorderedSparseSwitch; -.super Ljava/lang/Object; -.method public static test_sparse-switch()V -.registers 1 -const v0, 0xd -sparse-switch v0, :sswitch_data_c -:sswitch_6 -return-void -:sswitch_7 -return-void -:sswitch_8 -return-void -:sswitch_9 -return-void -:sswitch_a -return-void -nop - -# Note: ordered keys -:sswitch_data_c -.sparse-switch -0xa -> :sswitch_6 -0xd -> :sswitch_9 -0xf -> :sswitch_8 -0x14 -> :sswitch_7 -0x63 -> :sswitch_a -.end sparse-switch -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/resources/UninitRefIdentityTest/UninitRefIdentityTest.smali b/brut.apktool.smali/baksmali/src/test/resources/UninitRefIdentityTest/UninitRefIdentityTest.smali deleted file mode 100644 index f9c43637..00000000 --- a/brut.apktool.smali/baksmali/src/test/resources/UninitRefIdentityTest/UninitRefIdentityTest.smali +++ /dev/null @@ -1,50 +0,0 @@ -.class public LUninitRefIdentityTest; -.super Ljava/lang/Object; - - -# direct methods -.method public constructor ()V - .registers 4 - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(UninitThis,LUninitRefIdentityTest;); - invoke-direct {p0}, Ljava/lang/Object;->()V - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - - #v0=(Uninit);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - new-instance v0, Ljava/lang/String; - #v0=(UninitRef,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - - #v0=(UninitRef,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - if-eqz v0, :cond_9 - #v0=(UninitRef,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - - #v0=(UninitRef,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - new-instance v0, Ljava/lang/String; - #v0=(UninitRef,Ljava/lang/String;);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - - :cond_9 - #v0=(Conflicted):merge{0x5:(UninitRef,Ljava/lang/String;),0x7:(UninitRef,Ljava/lang/String;)} - #v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - invoke-direct {v0}, Ljava/lang/String;->()V - #v0=(Unknown);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - - #v0=(Unknown);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); - return-void - #v0=(Unknown);v1=(Uninit);v2=(Uninit);p0=(Reference,LUninitRefIdentityTest;); -.end method - -.method public constructor (Ljava/lang/String;)V - .registers 2 - - #p0=(UninitThis,LUninitRefIdentityTest;);p1=(Reference,Ljava/lang/String;); - move-object p1, p0 - #p0=(UninitThis,LUninitRefIdentityTest;);p1=(UninitThis,LUninitRefIdentityTest;); - - #p0=(UninitThis,LUninitRefIdentityTest;);p1=(UninitThis,LUninitRefIdentityTest;); - invoke-direct {p0}, Ljava/lang/Object;->()V - #p0=(Reference,LUninitRefIdentityTest;);p1=(Reference,LUninitRefIdentityTest;); - - #p0=(Reference,LUninitRefIdentityTest;);p1=(Reference,LUninitRefIdentityTest;); - return-void - #p0=(Reference,LUninitRefIdentityTest;);p1=(Reference,LUninitRefIdentityTest;); -.end method diff --git a/brut.apktool.smali/baksmali/src/test/resources/UninitRefIdentityTest/classes.dex b/brut.apktool.smali/baksmali/src/test/resources/UninitRefIdentityTest/classes.dex deleted file mode 100644 index ea146cf69d3774dd3434465b241f239d7a8d6244..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 552 zcmY*Wu}T9$5S`szA}H#SMo1-Ab`ewvBm`UGK=AZzY%b;u7iBqg39%5g6ASAU7QqjY ze20}_q5gwKdJBE;E{iyK?`HPRyPaXCn+)eSHn$~cy?u8+)pG5+{IU~%jov?=j^#Nl zt!t4?M268;6)v~25~&~}?*VrJWHJJrk)HsN$}7-7FoiepZQuwP0B68GfH%LR1kZm7 z#)5}@%oEqj<#R2Mn& zT2_KXlbY1-C#SpJ#Msnc9VC~wDb=7K590cHYfieldStaticField:Ljava/lang/reflect/Field; - -.field public static methodStaticField:Ljava/lang/reflect/Method; = Lbaksmali/test/class;->teshMethod(ILjava/lang/String;)Ljava/lang/String; - -.field public static arrayStaticField:[I = {1, 2, 3, {1, 2, 3, 4}} - -.field public static enumStaticField:Lsome/enum; = .enum Lsome/enum;->someEnumValue:Lsome/enum; - -.field public static annotationStaticField:Lsome/annotation; = .subannotation Lsome/annotation; - value1 = "test" - value2 = .subannotation Lsome/annotation; - value1 = "test2" - value2 = Lsome/enum; - .end subannotation -.end subannotation - -.field public static staticFieldWithAnnotation:I - .annotation runtime La/field/annotation; - this = "is" - a = "test" - .end annotation - .annotation runtime Lorg/junit/Test; - .end annotation -.end field - -.field public instanceField:Ljava/lang/String; - - - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Ljava/lang/Object;->()V - return-void -.end method - -.method public testMethod(ILjava/lang/String;)Ljava/lang/String; - .registers 3 - .annotation runtime Lorg/junit/Test; - .end annotation - .annotation system Lyet/another/annotation; - somevalue = 1234 - anothervalue = 3.14159 - .end annotation - - const-string v0, "testing\n123" - - goto switch: - - sget v0, Lbaksmali/test/class;->staticField:I - - switch: - packed-switch v0, pswitch: - - try_start: - const/4 v0, 7 - const v0, 10 - nop - try_end: - .catch Ljava/lang/Exception; {try_start: .. try_end:} handler: - .catchall {try_start: .. try_end:} handler2: - - handler: - - Label10: - Label11: - Label12: - Label13: - return-object v0 - - - - .array-data 4 - 1 2 3 4 5 6 200 - .end array-data - - pswitch: - .packed-switch 10 - Label10: - Label11: - Label12: - Label13: - .end packed-switch - - handler2: - - return-void - -.end method - -.method public abstract testMethod2()V - .annotation runtime Lsome/annotation; - subannotation = .subannotation Lsome/other/annotation; - value = "value" - .end subannotation - .end annotation - .annotation runtime Lorg/junit/Test; - .end annotation -.end method - - -.method public tryTest()V - .registers 1 - - handler: - nop - - - try_start: - const/4 v0, 7 - const v0, 10 - nop - try_end: - .catch Ljava/lang/Exception; {try_start: .. try_end:} handler: -.end method - - -.method public debugTest(IIIII)V - .registers 10 - - .parameter "Blah" - .parameter - .parameter "BlahWithAnnotations" - .annotation runtime Lsome/annotation; - something = "some value" - somethingelse = 1234 - .end annotation - .annotation runtime La/second/annotation; - .end annotation - .end parameter - .parameter - .annotation runtime Lsome/annotation; - something = "some value" - somethingelse = 1234 - .end annotation - .end parameter - .parameter "LastParam" - - .prologue - - nop - nop - - .source "somefile.java" - .line 101 - - nop - - - .line 50 - - .local v0, aNumber:I - const v0, 1234 - .end local v0 - - .source "someotherfile.java" - .line 900 - - const-string v0, "1234" - - .restart local v0 - const v0, 6789 - .end local v0 - - .epilogue - -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/main.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/main.smali deleted file mode 100644 index db88b46c..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/main.smali +++ /dev/null @@ -1,70 +0,0 @@ -.class public Lmain; - -.super Ljava/lang/Object; - -.method public static main([Ljava/lang/String;)V - .registers 3 - - :here4 - const v0, 0 - - :here3 - - new-instance v2, Lsuperclass; - invoke-direct {v2}, Lsuperclass;->()V - - if-eqz v0, :here - - - #this is the unresolvable instruction. v0 is always null, - #and this will always throw an exception. It should be - #replaced with throw v0. - invoke-virtual {v0}, Lrandomclass;->getSuperclass()Lsuperclass; - move-result-object v1 - - - if-eqz v0, :here - - #this would normally be deodexable, except that it follows - #the above un-deodexeable instruction, which prevents the - #propagation of any register information. It can never be - #reached, and should be replaced with throw v2 - invoke-virtual {v2}, Lsuperclass;->somemethod()V - - #another odexed instruction that uses the result of the - #first unresolveable odex instruction. This should - #be replaced with throw v1 - invoke-virtual {v1}, Lsuperclass;->somemethod()V - - :here - - #and we're back to the non-dead code - invoke-virtual {v2}, Lsuperclass;->somemethod()V - - if-nez v0, :here3 - - return-void -.end method - -.method public static FirstInstructionTest(Lrandomclass;)V - .registers 1 - - :try_start - invoke-virtual/range {p0}, Lrandomclass;->getSuperclass()Lsuperclass; - return-void - :try_end - .catch Ljava/lang/Exception; {:try_start .. :try_end} :handler - :handler - :inner_try_start - #this tests that the parameter register types are correctly propagated to the exception handlers, in the - #case that the first instruction of the method can throw an exception and is in a try black - invoke-virtual/range {p0}, Lrandomclass;->getSuperclass()Lsuperclass; - return-void - :inner_try_end - .catch Ljava/lang/Exception; {:inner_try_start .. :inner_try_end} :inner_handler - :inner_handler - #this additionally tests that the register types are propagated recursively, in the case that the first - #instruction in the exception handler can also throw an exception, and is covered by a try block - invoke-virtual/range {p0}, Lrandomclass;->getSuperclass()Lsuperclass; - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/randomclass.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/randomclass.smali deleted file mode 100644 index 3c02f137..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/randomclass.smali +++ /dev/null @@ -1,18 +0,0 @@ -.class public Lrandomclass; - -.super Ljava/lang/Object; - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Ljava/lang/Object;->()V - return-void -.end method - -.method public getSuperclass()Lsuperclass; - .registers 2 - - new-instance v0, Lsuperclass; - invoke-direct {v0}, Lsuperclass;->()V - - return-object v0 -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/subclass.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/subclass.smali deleted file mode 100644 index 9ffa4de6..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/subclass.smali +++ /dev/null @@ -1,21 +0,0 @@ -.class public Lsubclass; - -.super Lsuperclass; - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Lsuperclass;->()V - return-void -.end method - -.method public somemethod()V - .registers 2 - - sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; - - const-string v1, "subclass.somemethod" - - invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V - - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/superclass.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/superclass.smali deleted file mode 100644 index 21491034..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test1/superclass.smali +++ /dev/null @@ -1,21 +0,0 @@ -.class public Lsuperclass; - -.super Ljava/lang/Object; - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Ljava/lang/Object;->()V - return-void -.end method - -.method public somemethod()V - .registers 2 - - sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; - - const-string v1, "superclass.somemethod" - - invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V - - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/app_classes/main.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/app_classes/main.smali deleted file mode 100644 index 505312c6..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/app_classes/main.smali +++ /dev/null @@ -1,41 +0,0 @@ -.class public Lmain; - -.super Ljava/lang/Object; - -.method public static main([Ljava/lang/String;)V - .registers 6 - - const v2, 0 - - - const v3, 1 - const v4, 0 - new-array v1, v3, [Lsubclass1; - new-instance v0, Lsubclass1; - invoke-direct {v0}, Lsubclass1;->()V - aput-object v0, v1, v4 - - goto :here2 - - :here - const v2, 1 - - :here2 - - #this is tricky, because it has to merge two array types, [Lsubclass1; and [Lsubclass2 - #which should result in [Lsuperclass;. However, this dex file won't have a reference - #to [Lsuperclass; - aget-object v5, v1, v4 - - invoke-virtual {v5}, Lsupersuperclass;->somemethod()V - - - new-array v1, v3, [Lsubclass2; - new-instance v0, Lsubclass2; - invoke-direct {v0}, Lsubclass2;->()V - aput-object v0, v1, v4 - - if-eqz v2, :here - - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/randomclass.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/randomclass.smali deleted file mode 100644 index 3c02f137..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/randomclass.smali +++ /dev/null @@ -1,18 +0,0 @@ -.class public Lrandomclass; - -.super Ljava/lang/Object; - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Ljava/lang/Object;->()V - return-void -.end method - -.method public getSuperclass()Lsuperclass; - .registers 2 - - new-instance v0, Lsuperclass; - invoke-direct {v0}, Lsuperclass;->()V - - return-object v0 -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/subclass1.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/subclass1.smali deleted file mode 100644 index d7b840f3..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/subclass1.smali +++ /dev/null @@ -1,21 +0,0 @@ -.class public Lsubclass1; - -.super Lsuperclass; - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Lsuperclass;->()V - return-void -.end method - -.method public somemethod()V - .registers 2 - - sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; - - const-string v1, "subclass1.somemethod" - - invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V - - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/subclass2.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/subclass2.smali deleted file mode 100644 index 605cccb7..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/subclass2.smali +++ /dev/null @@ -1,21 +0,0 @@ -.class public Lsubclass2; - -.super Lsuperclass; - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Lsuperclass;->()V - return-void -.end method - -.method public somemethod()V - .registers 2 - - sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; - - const-string v1, "subclass2.somemethod" - - invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V - - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/superclass.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/superclass.smali deleted file mode 100644 index e44a17a2..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/superclass.smali +++ /dev/null @@ -1,21 +0,0 @@ -.class public Lsuperclass; - -.super Lsupersuperclass; - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Lsupersuperclass;->()V - return-void -.end method - -.method public somemethod()V - .registers 2 - - sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; - - const-string v1, "superclass.somemethod" - - invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V - - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/supersuperclass.smali b/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/supersuperclass.smali deleted file mode 100644 index 9621e14c..00000000 --- a/brut.apktool.smali/baksmali/src/test/smali/deodex_test2/bootclass_classes/supersuperclass.smali +++ /dev/null @@ -1,21 +0,0 @@ -.class public Lsupersuperclass; - -.super Ljava/lang/Object; - -.method public constructor ()V - .registers 1 - invoke-direct {p0}, Ljava/lang/Object;->()V - return-void -.end method - -.method public somemethod()V - .registers 2 - - sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; - - const-string v1, "supersuperclass.somemethod" - - invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V - - return-void -.end method \ No newline at end of file diff --git a/brut.apktool.smali/build.gradle b/brut.apktool.smali/build.gradle deleted file mode 100644 index af1b25ec..00000000 --- a/brut.apktool.smali/build.gradle +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -apply plugin: 'idea' - -version = '2.0.8' - -def jarVersion = version - -if (!('release' in gradle.startParameter.taskNames)) { - def versionSuffix - try { - def git = org.eclipse.jgit.api.Git.open(file('../.')) - def head = git.getRepository().getRef('HEAD') - versionSuffix = head.getObjectId().abbreviate(8).name() - - if (!git.status().call().clean) { - versionSuffix += '-dirty' - } - } catch (Exception) { - // In case we can't get the commit for some reason, - // just use -dev - versionSuffix = 'dev' - } - - def baseVersion = version - version = baseVersion + '-' + versionSuffix - - // use something like module-1.2.3-dev.jar for the jar name, rather than the full - // module-1.2.3-001afe02-dirty.jar - jarVersion = baseVersion + '-dev' -} - -subprojects { - apply plugin: 'java' - apply plugin: 'idea' - - if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } - } - - version = parent.version - - ext { - depends = [guava: 'com.google.guava:guava:18.0', - findbugs: 'com.google.code.findbugs:jsr305:1.3.9', - junit: 'junit:junit:4.6', - antlr_runtime: 'org.antlr:antlr-runtime:3.5.2', - antlr: 'org.antlr:antlr:3.5.2', - stringtemplate: 'org.antlr:stringtemplate:3.2.1', - commons_cli: 'commons-cli:commons-cli:1.2', - jflex: 'de.jflex:jflex:1.4.3', - jflex_plugin: 'co.tomlee.gradle.plugins:gradle-jflex-plugin:0.0.1', - proguard_gradle: 'net.sf.proguard:proguard-gradle:5.1', - dx: 'com.google.android.tools:dx:1.7' - ] - } - - jar { - version = jarVersion - } - - repositories { - mavenCentral() - } -} - -// Note: please don't use this. This is strictly for the official releases -// that are posted on the googlecode download page. -task release { -} - -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r' - } -} - -task wrapper(type: Wrapper) { - gradleVersion = '2.3' -} diff --git a/brut.apktool.smali/dexlib2/accessorTestGenerator/build.gradle b/brut.apktool.smali/dexlib2/accessorTestGenerator/build.gradle deleted file mode 100644 index e242ae0e..00000000 --- a/brut.apktool.smali/dexlib2/accessorTestGenerator/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -dependencies { - compile project(':brut.apktool.smali:util') - compile 'com.google.code.findbugs:jsr305:1.3.9' - compile 'com.google.guava:guava:13.0.1' - compile 'org.antlr:ST4:4.0.7' - - testCompile 'junit:junit:4.6' -} \ No newline at end of file diff --git a/brut.apktool.smali/dexlib2/accessorTestGenerator/src/main/java/org/jf/dexlib2/AccessorTestGenerator.java b/brut.apktool.smali/dexlib2/accessorTestGenerator/src/main/java/org/jf/dexlib2/AccessorTestGenerator.java deleted file mode 100644 index 6540b3df..00000000 --- a/brut.apktool.smali/dexlib2/accessorTestGenerator/src/main/java/org/jf/dexlib2/AccessorTestGenerator.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -import org.stringtemplate.v4.*; - -import java.io.*; -import java.net.URL; - -public class AccessorTestGenerator { - private static class UnaryOperation { - public final String name; - public UnaryOperation(String name) { - this.name = name; - } - } - - private static class BinaryOperation { - public final String name; - public final String[] inputTypes; - public BinaryOperation(String name, String[] inputTypes) { - this.name = name; - this.inputTypes = inputTypes; - } - } - - private static class TypeDef { - public final String name; - public final UnaryOperation[] unaryOperations; - public final BinaryOperation[] binaryOperations; - public TypeDef(String name, UnaryOperation[] unaryOperations, BinaryOperation[] binaryOperations) { - this.name = name; - this.unaryOperations = unaryOperations; - this.binaryOperations = binaryOperations; - } - } - - private static final UnaryOperation[] unaryOperations = new UnaryOperation[] { - new UnaryOperation("preinc"), - new UnaryOperation("postinc"), - new UnaryOperation("predec"), - new UnaryOperation("postdec") - }; - - private static final String[] booleanInputs = new String[] {"boolean"}; - private static final String[] integralInputs = new String[] {"int", "long"}; - private static final String[] allInputs = new String[] {"int", "float", "long", "double"}; - - private static final BinaryOperation[] booleanOperations = new BinaryOperation[] { - new BinaryOperation("and", booleanInputs), - new BinaryOperation("or", booleanInputs), - new BinaryOperation("xor", booleanInputs), - }; - - private static final BinaryOperation[] floatOperations = new BinaryOperation[] { - new BinaryOperation("add", allInputs), - new BinaryOperation("sub", allInputs), - new BinaryOperation("mul", allInputs), - new BinaryOperation("div", allInputs), - new BinaryOperation("rem", allInputs), - }; - - private static final BinaryOperation[] integralOperations = new BinaryOperation[] { - new BinaryOperation("add", allInputs), - new BinaryOperation("sub", allInputs), - new BinaryOperation("mul", allInputs), - new BinaryOperation("div", allInputs), - new BinaryOperation("rem", allInputs), - new BinaryOperation("and", integralInputs), - new BinaryOperation("or", integralInputs), - new BinaryOperation("xor", integralInputs), - new BinaryOperation("shl", integralInputs), - new BinaryOperation("shr", integralInputs), - new BinaryOperation("ushr", integralInputs), - }; - - private static final TypeDef[] types = new TypeDef[] { - new TypeDef("boolean", new UnaryOperation[0], booleanOperations), - new TypeDef("byte", unaryOperations, integralOperations), - new TypeDef("char", unaryOperations, integralOperations), - new TypeDef("short", unaryOperations, integralOperations), - new TypeDef("int", unaryOperations, integralOperations), - new TypeDef("long", unaryOperations, integralOperations), - new TypeDef("float", unaryOperations, floatOperations), - new TypeDef("double", unaryOperations, floatOperations), - }; - - - public static void main(String[] args) throws IOException { - if (args.length != 1) { - System.err.println("Usage: java org.jf.dexlib2.AccessorTestGenerator "); - } - - URL stgUrl = AccessorTestGenerator.class.getClassLoader().getResource("AccessorTest.stg"); - STGroupFile stg = new STGroupFile(stgUrl, "utf-8", '<', '>'); - ST fileSt = stg.getInstanceOf("file"); - fileSt.add("types", types); - - PrintWriter w = null; - try { - w = new PrintWriter(new BufferedWriter(new FileWriter(args[0]))); - w.print(fileSt.render()); - } finally { - if (w != null) { - w.close(); - } - } - } -} - - - diff --git a/brut.apktool.smali/dexlib2/accessorTestGenerator/src/main/resources/AccessorTest.stg b/brut.apktool.smali/dexlib2/accessorTestGenerator/src/main/resources/AccessorTest.stg deleted file mode 100644 index 5c76eecd..00000000 --- a/brut.apktool.smali/dexlib2/accessorTestGenerator/src/main/resources/AccessorTest.stg +++ /dev/null @@ -1,86 +0,0 @@ -decl(type, name, value) ::= " ;" -init(v) ::= " = " - -field_decl(type) ::= "private _val;" - -preinc_template(type) ::= "++_val;" -postinc_template(type) ::= "_val++;" -predec_template(type) ::= "--_val;" -postdec_template(type) ::= "_val--;" -add_template(type) ::= "_val += val;" -sub_template(type) ::= "_val -= val;" -mul_template(type) ::= "_val *= val;" -div_template(type) ::= "_val /= val;" -rem_template(type) ::= "_val %= val;" -and_template(type) ::= "_val &= val;" -or_template(type) ::= "_val |= val;" -xor_template(type) ::= "_val ^= val;" -shl_template(type) ::= "_val \<\<= val;" -shr_template(type) ::= "_val >>= val;" -ushr_template(type) ::= "_val >>>= val;" - -operation_template_name(operation) ::= "_template" - -binary_method(input, type, binary_operation) ::= << -public void _( val) { - <(operation_template_name(binary_operation))(type)> -} ->> - -binary_methods(binary_operation, type) ::= << - ->> - -unary_method(unary_operation, type) ::= << -public void _() { - <(operation_template_name(unary_operation))(type)> -} ->> - -type_methods(type) ::= << -<[type.unaryOperations:unary_method(type), type.binaryOperations:binary_methods(type)];separator="\n\n"> ->> - - -file(types) ::= << -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -public class AccessorTypes { - - - private class Accessors { - - } -} ->> diff --git a/brut.apktool.smali/dexlib2/build.gradle b/brut.apktool.smali/dexlib2/build.gradle deleted file mode 100644 index 82b71b53..00000000 --- a/brut.apktool.smali/dexlib2/build.gradle +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -ext.testAccessorOutputDir = file("${buildDir}/generated-src/accessorTest/java") -ext.testAccessorOutputFile = file("${testAccessorOutputDir}/org/jf/dexlib2/AccessorTypes.java") - -sourceSets { - accessorTest { - java { - srcDir testAccessorOutputDir - } - } -} - -configurations { - accessorTestGenerator - dx -} - -dependencies { - compile project(':brut.apktool.smali:util') - compile depends.findbugs - compile depends.guava - - testCompile depends.junit - - accessorTestGenerator project('accessorTestGenerator') - - dx depends.dx -} - -// You must manually execute this task to regenerate SyntheticAccessorFSM.java, after modifying the ragel file -// e.g. ./gradlew ragel -task ragel(type:Exec) { - workingDir = 'src/main/ragel' - - commandLine 'ragel', '-J', '-o', file('src/main/java/org/jf/dexlib2/util/SyntheticAccessorFSM.java'), - 'SyntheticAccessorFSM.rl' -} - -task generateAccessorTestSource(type: JavaExec) { - file(testAccessorOutputFile.parent).mkdirs() - outputs.dir file(testAccessorOutputDir) - - classpath = configurations.accessorTestGenerator - main = 'org.jf.dexlib2.AccessorTestGenerator' - args testAccessorOutputFile -} -compileAccessorTestJava.dependsOn(generateAccessorTestSource) - -// You must manually execute this task to regenerate src/test/resources/accessorTest.dex -task generateAccessorTestDex(type: JavaExec, dependsOn: compileAccessorTestJava) { - def outputDex = file('src/test/resources/accessorTest.dex') - file(outputDex.parent).mkdirs() - - inputs.dir(project.sourceSets.accessorTest.output.classesDir) - outputs.file outputDex - - main 'com.android.dx.command.Main' - classpath = configurations.dx - - args '--dex' - args '--no-strict' - args "--output=${outputDex}" - args sourceSets.accessorTest.output.classesDir -} \ No newline at end of file diff --git a/brut.apktool.smali/dexlib2/src/accessorTest/java/org/jf/dexlib2/AccessorTest.java b/brut.apktool.smali/dexlib2/src/accessorTest/java/org/jf/dexlib2/AccessorTest.java deleted file mode 100644 index 924d3fd3..00000000 --- a/brut.apktool.smali/dexlib2/src/accessorTest/java/org/jf/dexlib2/AccessorTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -import com.google.common.collect.ImmutableMap; -import junit.framework.Assert; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.dexlib2.iface.DexFile; -import org.jf.dexlib2.iface.Method; -import org.jf.dexlib2.iface.MethodImplementation; -import org.jf.dexlib2.iface.instruction.Instruction; -import org.jf.dexlib2.iface.instruction.ReferenceInstruction; -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.iface.reference.MethodReference; -import org.jf.dexlib2.util.SyntheticAccessorResolver; -import org.junit.Test; - -import java.io.IOException; -import java.net.URL; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class AccessorTest { - private Pattern accessorMethodPattern = Pattern.compile("([a-zA-Z]*)_([a-zA-Z]*)"); - - private static final Map operationTypes; - - static { - ImmutableMap.Builder builder = ImmutableMap.builder(); - builder.put("postinc", SyntheticAccessorResolver.POSTFIX_INCREMENT); - builder.put("preinc", SyntheticAccessorResolver.PREFIX_INCREMENT); - builder.put("postdec", SyntheticAccessorResolver.POSTFIX_DECREMENT); - builder.put("predec", SyntheticAccessorResolver.PREFIX_DECREMENT); - builder.put("add", SyntheticAccessorResolver.ADD_ASSIGNMENT); - builder.put("sub", SyntheticAccessorResolver.SUB_ASSIGNMENT); - builder.put("mul", SyntheticAccessorResolver.MUL_ASSIGNMENT); - builder.put("div", SyntheticAccessorResolver.DIV_ASSIGNMENT); - builder.put("rem", SyntheticAccessorResolver.REM_ASSIGNMENT); - builder.put("and", SyntheticAccessorResolver.AND_ASSIGNMENT); - builder.put("or", SyntheticAccessorResolver.OR_ASSIGNMENT); - builder.put("xor", SyntheticAccessorResolver.XOR_ASSIGNMENT); - builder.put("shl", SyntheticAccessorResolver.SHL_ASSIGNMENT); - builder.put("shr", SyntheticAccessorResolver.SHR_ASSIGNMENT); - builder.put("ushr", SyntheticAccessorResolver.USHR_ASSIGNMENT); - operationTypes = builder.build(); - } - - @Test - public void testAccessors() throws IOException { - URL url = AccessorTest.class.getClassLoader().getResource("accessorTest.dex"); - Assert.assertNotNull(url); - DexFile f = DexFileFactory.loadDexFile(url.getFile(), 15, false); - - SyntheticAccessorResolver sar = new SyntheticAccessorResolver(f.getClasses()); - - ClassDef accessorTypesClass = null; - ClassDef accessorsClass = null; - - for (ClassDef classDef: f.getClasses()) { - String className = classDef.getType(); - - if (className.equals("Lorg/jf/dexlib2/AccessorTypes;")) { - accessorTypesClass = classDef; - } else if (className.equals("Lorg/jf/dexlib2/AccessorTypes$Accessors;")) { - accessorsClass = classDef; - } - } - - Assert.assertNotNull(accessorTypesClass); - Assert.assertNotNull(accessorsClass); - - for (Method method: accessorsClass.getMethods()) { - Matcher m = accessorMethodPattern.matcher(method.getName()); - if (!m.matches()) { - continue; - } - String type = m.group(1); - String operation = m.group(2); - - MethodImplementation methodImpl = method.getImplementation(); - Assert.assertNotNull(methodImpl); - - for (Instruction instruction: methodImpl.getInstructions()) { - Opcode opcode = instruction.getOpcode(); - if (opcode == Opcode.INVOKE_STATIC || opcode == Opcode.INVOKE_STATIC_RANGE) { - MethodReference accessorMethod = - (MethodReference)((ReferenceInstruction) instruction).getReference(); - - SyntheticAccessorResolver.AccessedMember accessedMember = sar.getAccessedMember(accessorMethod); - - Assert.assertNotNull(String.format("Could not resolve accessor for %s_%s", type, operation), - accessedMember); - - int operationType = operationTypes.get(operation); - Assert.assertEquals(operationType, accessedMember.accessedMemberType); - - Assert.assertEquals(String.format("%s_val", type), - ((FieldReference)accessedMember.accessedMember).getName()); - } - } - } - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/AccessFlags.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/AccessFlags.java deleted file mode 100644 index d3cf74c8..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/AccessFlags.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -import java.util.HashMap; - -public enum AccessFlags -{ - PUBLIC(0x1, "public", true, true, true), - PRIVATE(0x2, "private", true, true, true), - PROTECTED(0x4, "protected", true, true, true), - STATIC(0x8, "static", true, true, true), - FINAL(0x10, "final", true, true, true), - SYNCHRONIZED(0x20, "synchronized", false, true, false), - VOLATILE(0x40, "volatile", false, false, true), - BRIDGE(0x40, "bridge", false, true, false), - TRANSIENT(0x80, "transient", false, false, true), - VARARGS(0x80, "varargs", false, true, false), - NATIVE(0x100, "native", false, true, false), - INTERFACE(0x200, "interface", true, false, false), - ABSTRACT(0x400, "abstract", true, true, false), - STRICTFP(0x800, "strictfp", false, true, false), - SYNTHETIC(0x1000, "synthetic", true, true, true), - ANNOTATION(0x2000, "annotation", true, false, false), - ENUM(0x4000, "enum", true, false, true), - CONSTRUCTOR(0x10000, "constructor", false, true, false), - DECLARED_SYNCHRONIZED(0x20000, "declared-synchronized", false, true, false); - - private int value; - private String accessFlagName; - private boolean validForClass; - private boolean validForMethod; - private boolean validForField; - - //cache the array of all AccessFlags, because .values() allocates a new array for every call - private final static AccessFlags[] allFlags; - - private static HashMap accessFlagsByName; - - static { - allFlags = AccessFlags.values(); - - accessFlagsByName = new HashMap(); - for (AccessFlags accessFlag: allFlags) { - accessFlagsByName.put(accessFlag.accessFlagName, accessFlag); - } - } - - private AccessFlags(int value, String accessFlagName, boolean validForClass, boolean validForMethod, - boolean validForField) { - this.value = value; - this.accessFlagName = accessFlagName; - this.validForClass = validForClass; - this.validForMethod = validForMethod; - this.validForField = validForField; - } - - public boolean isSet(int accessFlags) { - return (this.value & accessFlags) != 0; - } - - public static AccessFlags[] getAccessFlagsForClass(int accessFlagValue) { - int size = 0; - for (AccessFlags accessFlag: allFlags) { - if (accessFlag.validForClass && (accessFlagValue & accessFlag.value) != 0) { - size++; - } - } - - AccessFlags[] accessFlags = new AccessFlags[size]; - int accessFlagsPosition = 0; - for (AccessFlags accessFlag: allFlags) { - if (accessFlag.validForClass && (accessFlagValue & accessFlag.value) != 0) { - accessFlags[accessFlagsPosition++] = accessFlag; - } - } - return accessFlags; - } - - private static String formatAccessFlags(AccessFlags[] accessFlags) { - int size = 0; - for (AccessFlags accessFlag: accessFlags) { - size += accessFlag.toString().length() + 1; - } - - StringBuilder sb = new StringBuilder(size); - for (AccessFlags accessFlag: accessFlags) { - sb.append(accessFlag.toString()); - sb.append(" "); - } - if (accessFlags.length > 0) { - sb.delete(sb.length() - 1, sb.length()); - } - return sb.toString(); - } - - public static String formatAccessFlagsForClass(int accessFlagValue) { - return formatAccessFlags(getAccessFlagsForClass(accessFlagValue)); - } - - public static AccessFlags[] getAccessFlagsForMethod(int accessFlagValue) { - int size = 0; - for (AccessFlags accessFlag: allFlags) { - if (accessFlag.validForMethod && (accessFlagValue & accessFlag.value) != 0) { - size++; - } - } - - AccessFlags[] accessFlags = new AccessFlags[size]; - int accessFlagsPosition = 0; - for (AccessFlags accessFlag: allFlags) { - if (accessFlag.validForMethod && (accessFlagValue & accessFlag.value) != 0) { - accessFlags[accessFlagsPosition++] = accessFlag; - } - } - return accessFlags; - } - - public static String formatAccessFlagsForMethod(int accessFlagValue) { - return formatAccessFlags(getAccessFlagsForMethod(accessFlagValue)); - } - - public static AccessFlags[] getAccessFlagsForField(int accessFlagValue) { - int size = 0; - for (AccessFlags accessFlag: allFlags) { - if (accessFlag.validForField && (accessFlagValue & accessFlag.value) != 0) { - size++; - } - } - - AccessFlags[] accessFlags = new AccessFlags[size]; - int accessFlagsPosition = 0; - for (AccessFlags accessFlag: allFlags) { - if (accessFlag.validForField && (accessFlagValue & accessFlag.value) != 0) { - accessFlags[accessFlagsPosition++] = accessFlag; - } - } - return accessFlags; - } - - public static String formatAccessFlagsForField(int accessFlagValue) { - return formatAccessFlags(getAccessFlagsForField(accessFlagValue)); - } - - public static AccessFlags getAccessFlag(String accessFlag) { - return accessFlagsByName.get(accessFlag); - } - - public int getValue() { - return value; - } - - public String toString() { - return accessFlagName; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/AnnotationVisibility.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/AnnotationVisibility.java deleted file mode 100644 index 06c4677e..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/AnnotationVisibility.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -import org.jf.util.ExceptionWithContext; - -public final class AnnotationVisibility { - public static final int BUILD = 0; - public static final int RUNTIME = 1; - public static final int SYSTEM = 2; - - private static String[] NAMES = new String[] {"build", "runtime", "system"}; - - public static String getVisibility(int visibility) { - if (visibility < 0 || visibility >= NAMES.length) { - throw new ExceptionWithContext("Invalid annotation visibility %d", visibility); - } - return NAMES[visibility]; - } - - public static int getVisibility(String visibility) { - visibility = visibility.toLowerCase(); - if (visibility.equals("build")) { - return BUILD; - } - if (visibility.equals("runtime")) { - return RUNTIME; - } - if (visibility.equals("system")) { - return SYSTEM; - } - throw new ExceptionWithContext("Invalid annotation visibility: %s", visibility); - } - - private AnnotationVisibility() {} -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DebugItemType.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DebugItemType.java deleted file mode 100644 index 7f4d8876..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DebugItemType.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -public final class DebugItemType { - // The debug items that directly correspond with one of the dexlib2.iface.debug interfaces - public static final int START_LOCAL = 0x03; - public static final int END_LOCAL = 0x05; - public static final int RESTART_LOCAL = 0x06; - public static final int PROLOGUE_END = 0x07; - public static final int EPILOGUE_BEGIN = 0x08; - public static final int SET_SOURCE_FILE = 0x09; - public static final int LINE_NUMBER = 0x0a; - - // Other items, which are typically handled internally - public static final int END_SEQUENCE = 0x00; - public static final int ADVANCE_PC = 0x01; - public static final int ADVANCE_LINE = 0x02; - public static final int START_LOCAL_EXTENDED = 0x04; - - private DebugItemType() {} -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java deleted file mode 100644 index 113b60a3..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -import com.google.common.io.ByteStreams; -import org.jf.dexlib2.dexbacked.DexBackedDexFile; -import org.jf.dexlib2.dexbacked.DexBackedOdexFile; -import org.jf.dexlib2.iface.DexFile; -import org.jf.dexlib2.writer.pool.DexPool; -import org.jf.util.ExceptionWithContext; - -import javax.annotation.Nonnull; -import java.io.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -public final class DexFileFactory { - @Nonnull - public static DexBackedDexFile loadDexFile(String path, int api) - throws IOException { - return loadDexFile(path, api, false); - } - - @Nonnull - public static DexBackedDexFile loadDexFile(String path, int api, boolean experimental) - throws IOException { - return loadDexFile(new File(path), "classes.dex", new Opcodes(api, experimental)); - } - - @Nonnull - public static DexBackedDexFile loadDexFile(File dexFile, int api) throws IOException { - return loadDexFile(dexFile, api, false); - } - - @Nonnull - public static DexBackedDexFile loadDexFile(File dexFile, int api, boolean experimental) - throws IOException { - return loadDexFile(dexFile, "classes.dex", new Opcodes(api, experimental)); - } - - @Nonnull - public static DexBackedDexFile loadDexFile(File dexFile, String dexEntry, int api, - boolean experimental) throws IOException { - return loadDexFile(dexFile, dexEntry, new Opcodes(api, experimental)); - } - - @Nonnull - public static DexBackedDexFile loadDexFile(File dexFile, String dexEntry, - @Nonnull Opcodes opcodes) throws IOException { - ZipFile zipFile = null; - boolean isZipFile = false; - try { - zipFile = new ZipFile(dexFile); - // if we get here, it's safe to assume we have a zip file - isZipFile = true; - - ZipEntry zipEntry = zipFile.getEntry(dexEntry); - if (zipEntry == null) { - throw new NoClassesDexException("zip file %s does not contain a classes.dex file", dexFile.getName()); - } - long fileLength = zipEntry.getSize(); - if (fileLength < 40) { - throw new ExceptionWithContext( - "The " + dexEntry + " file in %s is too small to be a valid dex file", dexFile.getName()); - } else if (fileLength > Integer.MAX_VALUE) { - throw new ExceptionWithContext("The " + dexEntry + " file in %s is too large to read in", dexFile.getName()); - } - byte[] dexBytes = new byte[(int)fileLength]; - ByteStreams.readFully(zipFile.getInputStream(zipEntry), dexBytes); - return new DexBackedDexFile(opcodes, dexBytes); - } catch (IOException ex) { - // don't continue on if we know it's a zip file - if (isZipFile) { - throw ex; - } - } finally { - if (zipFile != null) { - try { - zipFile.close(); - } catch (IOException ex) { - // just eat it - } - } - } - - InputStream inputStream = new BufferedInputStream(new FileInputStream(dexFile)); - try { - try { - return DexBackedDexFile.fromInputStream(opcodes, inputStream); - } catch (DexBackedDexFile.NotADexFile ex) { - // just eat it - } - - // Note: DexBackedDexFile.fromInputStream will reset inputStream back to the same position, if it fails - - try { - return DexBackedOdexFile.fromInputStream(opcodes, inputStream); - } catch (DexBackedOdexFile.NotAnOdexFile ex) { - // just eat it - } - } finally { - inputStream.close(); - } - - throw new ExceptionWithContext("%s is not an apk, dex file or odex file.", dexFile.getPath()); - } - - public static void writeDexFile(String path, DexFile dexFile) throws IOException { - DexPool.writeTo(path, dexFile); - } - - private DexFileFactory() {} - - public static class NoClassesDexException extends ExceptionWithContext { - public NoClassesDexException(Throwable cause) { - super(cause); - } - - public NoClassesDexException(Throwable cause, String message, Object... formatArgs) { - super(cause, message, formatArgs); - } - - public NoClassesDexException(String message, Object... formatArgs) { - super(message, formatArgs); - } - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Format.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Format.java deleted file mode 100644 index ee34aa50..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Format.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -public enum Format { - Format10t(2), - Format10x(2), - Format11n(2), - Format11x(2), - Format12x(2), - Format20bc(4), - Format20t(4), - Format21c(4), - Format21ih(4), - Format21lh(4), - Format21s(4), - Format21t(4), - Format22b(4), - Format22c(4), - Format22cs(4), - Format22s(4), - Format22t(4), - Format22x(4), - Format23x(4), - Format25x(4), - Format30t(6), - Format31c(6), - Format31i(6), - Format31t(6), - Format32x(6), - Format35c(6), - Format35mi(6), - Format35ms(6), - Format3rc(6), - Format3rmi(6), - Format3rms(6), - Format51l(10), - ArrayPayload(-1, true), - PackedSwitchPayload(-1, true), - SparseSwitchPayload(-1, true), - UnresolvedOdexInstruction(-1); - - public final int size; - public final boolean isPayloadFormat; - - private Format(int size) { - this(size, false); - } - - private Format(int size, boolean isPayloadFormat) { - this.size = size; - this.isPayloadFormat = isPayloadFormat; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Opcode.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Opcode.java deleted file mode 100644 index 3b082ee8..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Opcode.java +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -public enum Opcode -{ - NOP((short)0x00, "nop", ReferenceType.NONE, Format.Format10x, Opcode.CAN_CONTINUE), - MOVE((short)0x01, "move", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MOVE_FROM16((short)0x02, "move/from16", ReferenceType.NONE, Format.Format22x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MOVE_16((short)0x03, "move/16", ReferenceType.NONE, Format.Format32x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MOVE_WIDE((short)0x04, "move-wide", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - MOVE_WIDE_FROM16((short)0x05, "move-wide/from16", ReferenceType.NONE, Format.Format22x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - MOVE_WIDE_16((short)0x06, "move-wide/16", ReferenceType.NONE, Format.Format32x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - MOVE_OBJECT((short)0x07, "move-object", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MOVE_OBJECT_FROM16((short)0x08, "move-object/from16", ReferenceType.NONE, Format.Format22x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MOVE_OBJECT_16((short)0x09, "move-object/16", ReferenceType.NONE, Format.Format32x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MOVE_RESULT((short)0x0a, "move-result", ReferenceType.NONE, Format.Format11x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MOVE_RESULT_WIDE((short)0x0b, "move-result-wide", ReferenceType.NONE, Format.Format11x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - MOVE_RESULT_OBJECT((short)0x0c, "move-result-object", ReferenceType.NONE, Format.Format11x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MOVE_EXCEPTION((short)0x0d, "move-exception", ReferenceType.NONE, Format.Format11x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - RETURN_VOID((short)0x0e, "return-void", ReferenceType.NONE, Format.Format10x), - RETURN((short)0x0f, "return", ReferenceType.NONE, Format.Format11x), - RETURN_WIDE((short)0x10, "return-wide", ReferenceType.NONE, Format.Format11x), - RETURN_OBJECT((short)0x11, "return-object", ReferenceType.NONE, Format.Format11x), - CONST_4((short)0x12, "const/4", ReferenceType.NONE, Format.Format11n, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CONST_16((short)0x13, "const/16", ReferenceType.NONE, Format.Format21s, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CONST((short)0x14, "const", ReferenceType.NONE, Format.Format31i, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CONST_HIGH16((short)0x15, "const/high16", ReferenceType.NONE, Format.Format21ih, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CONST_WIDE_16((short)0x16, "const-wide/16", ReferenceType.NONE, Format.Format21s, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - CONST_WIDE_32((short)0x17, "const-wide/32", ReferenceType.NONE, Format.Format31i, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - CONST_WIDE((short)0x18, "const-wide", ReferenceType.NONE, Format.Format51l, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - CONST_WIDE_HIGH16((short)0x19, "const-wide/high16", ReferenceType.NONE, Format.Format21lh, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - CONST_STRING((short)0x1a, "const-string", ReferenceType.STRING, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER, (short)0x1b), - CONST_STRING_JUMBO((short)0x1b, "const-string/jumbo", ReferenceType.STRING, Format.Format31c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CONST_CLASS((short)0x1c, "const-class", ReferenceType.TYPE, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MONITOR_ENTER((short)0x1d, "monitor-enter", ReferenceType.NONE, Format.Format11x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - MONITOR_EXIT((short)0x1e, "monitor-exit", ReferenceType.NONE, Format.Format11x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - CHECK_CAST((short)0x1f, "check-cast", ReferenceType.TYPE, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - INSTANCE_OF((short)0x20, "instance-of", ReferenceType.TYPE, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - ARRAY_LENGTH((short)0x21, "array-length", ReferenceType.NONE, Format.Format12x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - NEW_INSTANCE((short)0x22, "new-instance", ReferenceType.TYPE, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - NEW_ARRAY((short)0x23, "new-array", ReferenceType.TYPE, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - FILLED_NEW_ARRAY((short)0x24, "filled-new-array", ReferenceType.TYPE, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - FILLED_NEW_ARRAY_RANGE((short)0x25, "filled-new-array/range", ReferenceType.TYPE, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - FILL_ARRAY_DATA((short)0x26, "fill-array-data", ReferenceType.NONE, Format.Format31t, Opcode.CAN_CONTINUE), - THROW((short)0x27, "throw", ReferenceType.NONE, Format.Format11x, Opcode.CAN_THROW), - GOTO((short)0x28, "goto", ReferenceType.NONE, Format.Format10t), - GOTO_16((short)0x29, "goto/16", ReferenceType.NONE, Format.Format20t), - GOTO_32((short)0x2a, "goto/32", ReferenceType.NONE, Format.Format30t), - PACKED_SWITCH((short)0x2b, "packed-switch", ReferenceType.NONE, Format.Format31t, Opcode.CAN_CONTINUE), - SPARSE_SWITCH((short)0x2c, "sparse-switch", ReferenceType.NONE, Format.Format31t, Opcode.CAN_CONTINUE), - CMPL_FLOAT((short)0x2d, "cmpl-float", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CMPG_FLOAT((short)0x2e, "cmpg-float", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CMPL_DOUBLE((short)0x2f, "cmpl-double", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CMPG_DOUBLE((short)0x30, "cmpg-double", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - CMP_LONG((short)0x31, "cmp-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IF_EQ((short)0x32, "if-eq", ReferenceType.NONE, Format.Format22t, Opcode.CAN_CONTINUE), - IF_NE((short)0x33, "if-ne", ReferenceType.NONE, Format.Format22t, Opcode.CAN_CONTINUE), - IF_LT((short)0x34, "if-lt", ReferenceType.NONE, Format.Format22t, Opcode.CAN_CONTINUE), - IF_GE((short)0x35, "if-ge", ReferenceType.NONE, Format.Format22t, Opcode.CAN_CONTINUE), - IF_GT((short)0x36, "if-gt", ReferenceType.NONE, Format.Format22t, Opcode.CAN_CONTINUE), - IF_LE((short)0x37, "if-le", ReferenceType.NONE, Format.Format22t, Opcode.CAN_CONTINUE), - IF_EQZ((short)0x38, "if-eqz", ReferenceType.NONE, Format.Format21t, Opcode.CAN_CONTINUE), - IF_NEZ((short)0x39, "if-nez", ReferenceType.NONE, Format.Format21t, Opcode.CAN_CONTINUE), - IF_LTZ((short)0x3a, "if-ltz", ReferenceType.NONE, Format.Format21t, Opcode.CAN_CONTINUE), - IF_GEZ((short)0x3b, "if-gez", ReferenceType.NONE, Format.Format21t, Opcode.CAN_CONTINUE), - IF_GTZ((short)0x3c, "if-gtz", ReferenceType.NONE, Format.Format21t, Opcode.CAN_CONTINUE), - IF_LEZ((short)0x3d, "if-lez", ReferenceType.NONE, Format.Format21t, Opcode.CAN_CONTINUE), - AGET((short)0x44, "aget", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AGET_WIDE((short)0x45, "aget-wide", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - AGET_OBJECT((short)0x46, "aget-object", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AGET_BOOLEAN((short)0x47, "aget-boolean", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AGET_BYTE((short)0x48, "aget-byte", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AGET_CHAR((short)0x49, "aget-char", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AGET_SHORT((short)0x4a, "aget-short", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - APUT((short)0x4b, "aput", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - APUT_WIDE((short)0x4c, "aput-wide", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - APUT_OBJECT((short)0x4d, "aput-object", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - APUT_BOOLEAN((short)0x4e, "aput-boolean", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - APUT_BYTE((short)0x4f, "aput-byte", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - APUT_CHAR((short)0x50, "aput-char", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - APUT_SHORT((short)0x51, "aput-short", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IGET((short)0x52, "iget", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_WIDE((short)0x53, "iget-wide", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - IGET_OBJECT((short)0x54, "iget-object", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_BOOLEAN((short)0x55, "iget-boolean", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_BYTE((short)0x56, "iget-byte", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_CHAR((short)0x57, "iget-char", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_SHORT((short)0x58, "iget-short", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IPUT((short)0x59, "iput", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_WIDE((short)0x5a, "iput-wide", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_OBJECT((short)0x5b, "iput-object", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_BOOLEAN((short)0x5c, "iput-boolean", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_BYTE((short)0x5d, "iput-byte", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_CHAR((short)0x5e, "iput-char", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_SHORT((short)0x5f, "iput-short", ReferenceType.FIELD, Format.Format22c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SGET((short)0x60, "sget", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_WIDE((short)0x61, "sget-wide", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SGET_OBJECT((short)0x62, "sget-object", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_BOOLEAN((short)0x63, "sget-boolean", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_BYTE((short)0x64, "sget-byte", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_CHAR((short)0x65, "sget-char", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SGET_SHORT((short)0x66, "sget-short", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SPUT((short)0x67, "sput", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_WIDE((short)0x68, "sput-wide", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_OBJECT((short)0x69, "sput-object", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_BOOLEAN((short)0x6a, "sput-boolean", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_BYTE((short)0x6b, "sput-byte", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_CHAR((short)0x6c, "sput-char", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SPUT_SHORT((short)0x6d, "sput-short", ReferenceType.FIELD, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - INVOKE_VIRTUAL((short)0x6e, "invoke-virtual", ReferenceType.METHOD, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_SUPER((short)0x6f, "invoke-super", ReferenceType.METHOD, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_DIRECT((short)0x70, "invoke-direct", ReferenceType.METHOD, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT | Opcode.CAN_INITIALIZE_REFERENCE), - INVOKE_STATIC((short)0x71, "invoke-static", ReferenceType.METHOD, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_INTERFACE((short)0x72, "invoke-interface", ReferenceType.METHOD, Format.Format35c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_VIRTUAL_RANGE((short)0x74, "invoke-virtual/range", ReferenceType.METHOD, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_SUPER_RANGE((short)0x75, "invoke-super/range", ReferenceType.METHOD, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_DIRECT_RANGE((short)0x76, "invoke-direct/range", ReferenceType.METHOD, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT | Opcode.CAN_INITIALIZE_REFERENCE), - INVOKE_STATIC_RANGE((short)0x77, "invoke-static/range", ReferenceType.METHOD, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_INTERFACE_RANGE((short)0x78, "invoke-interface/range", ReferenceType.METHOD, Format.Format3rc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - NEG_INT((short)0x7b, "neg-int", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - NOT_INT((short)0x7c, "not-int", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - NEG_LONG((short)0x7d, "neg-long", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - NOT_LONG((short)0x7e, "not-long", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - NEG_FLOAT((short)0x7f, "neg-float", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - NEG_DOUBLE((short)0x80, "neg-double", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - INT_TO_LONG((short)0x81, "int-to-long", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - INT_TO_FLOAT((short)0x82, "int-to-float", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - INT_TO_DOUBLE((short)0x83, "int-to-double", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - LONG_TO_INT((short)0x84, "long-to-int", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - LONG_TO_FLOAT((short)0x85, "long-to-float", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - LONG_TO_DOUBLE((short)0x86, "long-to-double", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - FLOAT_TO_INT((short)0x87, "float-to-int", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - FLOAT_TO_LONG((short)0x88, "float-to-long", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - FLOAT_TO_DOUBLE((short)0x89, "float-to-double", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - DOUBLE_TO_INT((short)0x8a, "double-to-int", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - DOUBLE_TO_LONG((short)0x8b, "double-to-long", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - DOUBLE_TO_FLOAT((short)0x8c, "double-to-float", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - INT_TO_BYTE((short)0x8d, "int-to-byte", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - INT_TO_CHAR((short)0x8e, "int-to-char", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - INT_TO_SHORT((short)0x8f, "int-to-short", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - ADD_INT((short)0x90, "add-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SUB_INT((short)0x91, "sub-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MUL_INT((short)0x92, "mul-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - DIV_INT((short)0x93, "div-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - REM_INT((short)0x94, "rem-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AND_INT((short)0x95, "and-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - OR_INT((short)0x96, "or-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - XOR_INT((short)0x97, "xor-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SHL_INT((short)0x98, "shl-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SHR_INT((short)0x99, "shr-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - USHR_INT((short)0x9a, "ushr-int", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - ADD_LONG((short)0x9b, "add-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SUB_LONG((short)0x9c, "sub-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - MUL_LONG((short)0x9d, "mul-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - DIV_LONG((short)0x9e, "div-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - REM_LONG((short)0x9f, "rem-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - AND_LONG((short)0xa0, "and-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - OR_LONG((short)0xa1, "or-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - XOR_LONG((short)0xa2, "xor-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SHL_LONG((short)0xa3, "shl-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SHR_LONG((short)0xa4, "shr-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - USHR_LONG((short)0xa5, "ushr-long", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - ADD_FLOAT((short)0xa6, "add-float", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SUB_FLOAT((short)0xa7, "sub-float", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MUL_FLOAT((short)0xa8, "mul-float", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - DIV_FLOAT((short)0xa9, "div-float", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - REM_FLOAT((short)0xaa, "rem-float", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - ADD_DOUBLE((short)0xab, "add-double", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SUB_DOUBLE((short)0xac, "sub-double", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - MUL_DOUBLE((short)0xad, "mul-double", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - DIV_DOUBLE((short)0xae, "div-double", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - REM_DOUBLE((short)0xaf, "rem-double", ReferenceType.NONE, Format.Format23x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - ADD_INT_2ADDR((short)0xb0, "add-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SUB_INT_2ADDR((short)0xb1, "sub-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MUL_INT_2ADDR((short)0xb2, "mul-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - DIV_INT_2ADDR((short)0xb3, "div-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - REM_INT_2ADDR((short)0xb4, "rem-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AND_INT_2ADDR((short)0xb5, "and-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - OR_INT_2ADDR((short)0xb6, "or-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - XOR_INT_2ADDR((short)0xb7, "xor-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SHL_INT_2ADDR((short)0xb8, "shl-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SHR_INT_2ADDR((short)0xb9, "shr-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - USHR_INT_2ADDR((short)0xba, "ushr-int/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - ADD_LONG_2ADDR((short)0xbb, "add-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SUB_LONG_2ADDR((short)0xbc, "sub-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - MUL_LONG_2ADDR((short)0xbd, "mul-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - DIV_LONG_2ADDR((short)0xbe, "div-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - REM_LONG_2ADDR((short)0xbf, "rem-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - AND_LONG_2ADDR((short)0xc0, "and-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - OR_LONG_2ADDR((short)0xc1, "or-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - XOR_LONG_2ADDR((short)0xc2, "xor-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SHL_LONG_2ADDR((short)0xc3, "shl-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SHR_LONG_2ADDR((short)0xc4, "shr-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - USHR_LONG_2ADDR((short)0xc5, "ushr-long/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - ADD_FLOAT_2ADDR((short)0xc6, "add-float/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SUB_FLOAT_2ADDR((short)0xc7, "sub-float/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MUL_FLOAT_2ADDR((short)0xc8, "mul-float/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - DIV_FLOAT_2ADDR((short)0xc9, "div-float/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - REM_FLOAT_2ADDR((short)0xca, "rem-float/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - ADD_DOUBLE_2ADDR((short)0xcb, "add-double/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SUB_DOUBLE_2ADDR((short)0xcc, "sub-double/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - MUL_DOUBLE_2ADDR((short)0xcd, "mul-double/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - DIV_DOUBLE_2ADDR((short)0xce, "div-double/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - REM_DOUBLE_2ADDR((short)0xcf, "rem-double/2addr", ReferenceType.NONE, Format.Format12x, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - ADD_INT_LIT16((short)0xd0, "add-int/lit16", ReferenceType.NONE, Format.Format22s, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - RSUB_INT((short)0xd1, "rsub-int", ReferenceType.NONE, Format.Format22s, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MUL_INT_LIT16((short)0xd2, "mul-int/lit16", ReferenceType.NONE, Format.Format22s, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - DIV_INT_LIT16((short)0xd3, "div-int/lit16", ReferenceType.NONE, Format.Format22s, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - REM_INT_LIT16((short)0xd4, "rem-int/lit16", ReferenceType.NONE, Format.Format22s, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AND_INT_LIT16((short)0xd5, "and-int/lit16", ReferenceType.NONE, Format.Format22s, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - OR_INT_LIT16((short)0xd6, "or-int/lit16", ReferenceType.NONE, Format.Format22s, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - XOR_INT_LIT16((short)0xd7, "xor-int/lit16", ReferenceType.NONE, Format.Format22s, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - ADD_INT_LIT8((short)0xd8, "add-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - RSUB_INT_LIT8((short)0xd9, "rsub-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - MUL_INT_LIT8((short)0xda, "mul-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - DIV_INT_LIT8((short)0xdb, "div-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - REM_INT_LIT8((short)0xdc, "rem-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - AND_INT_LIT8((short)0xdd, "and-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - OR_INT_LIT8((short)0xde, "or-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - XOR_INT_LIT8((short)0xdf, "xor-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SHL_INT_LIT8((short)0xe0, "shl-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SHR_INT_LIT8((short)0xe1, "shr-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - USHR_INT_LIT8((short)0xe2, "ushr-int/lit8", ReferenceType.NONE, Format.Format22b, Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - - IGET_VOLATILE((short)0xe3, "iget-volatile", minApi(9), ReferenceType.FIELD, Format.Format22c, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IPUT_VOLATILE((short)0xe4, "iput-volatile", minApi(9), ReferenceType.FIELD, Format.Format22c, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SGET_VOLATILE((short)0xe5, "sget-volatile", minApi(9), ReferenceType.FIELD, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SPUT_VOLATILE((short)0xe6, "sput-volatile", minApi(9), ReferenceType.FIELD, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IGET_OBJECT_VOLATILE((short)0xe7, "iget-object-volatile", minApi(9), ReferenceType.FIELD, Format.Format22c, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_WIDE_VOLATILE((short)0xe8, "iget-wide-volatile", minApi(9), ReferenceType.FIELD, Format.Format22c, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - IPUT_WIDE_VOLATILE((short)0xe9, "iput-wide-volatile", minApi(9), ReferenceType.FIELD, Format.Format22c, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SGET_WIDE_VOLATILE((short)0xea, "sget-wide-volatile", minApi(9), ReferenceType.FIELD, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - SPUT_WIDE_VOLATILE((short)0xeb, "sput-wide-volatile", minApi(9), ReferenceType.FIELD, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - - THROW_VERIFICATION_ERROR((short)0xed, "throw-verification-error", minApi(5), ReferenceType.NONE, Format.Format20bc, Opcode.ODEX_ONLY | Opcode.CAN_THROW), - EXECUTE_INLINE((short)0xee, "execute-inline", ReferenceType.NONE, Format.Format35mi, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - EXECUTE_INLINE_RANGE((short)0xef, "execute-inline/range", minApi(8), ReferenceType.NONE, Format.Format3rmi, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_DIRECT_EMPTY((short)0xf0, "invoke-direct-empty", maxApi(13), ReferenceType.METHOD, Format.Format35c, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT | Opcode.CAN_INITIALIZE_REFERENCE), - INVOKE_OBJECT_INIT_RANGE((short)0xf0, "invoke-object-init/range", minApi(14), ReferenceType.METHOD, Format.Format3rc, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT | Opcode.CAN_INITIALIZE_REFERENCE), - RETURN_VOID_BARRIER((short)0xf1, "return-void-barrier", minApi(11), ReferenceType.NONE, Format.Format10x, Opcode.ODEX_ONLY), - IGET_QUICK((short)0xf2, "iget-quick", ReferenceType.NONE, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IGET_WIDE_QUICK((short)0xf3, "iget-wide-quick", maxApi(22), ReferenceType.NONE, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER), - IGET_OBJECT_QUICK((short)0xf4, "iget-object-quick", maxApi(22), ReferenceType.NONE, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - IPUT_QUICK((short)0xf5, "iput-quick", maxApi(22), ReferenceType.NONE, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_WIDE_QUICK((short)0xf6, "iput-wide-quick", maxApi(22), ReferenceType.NONE, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - IPUT_OBJECT_QUICK((short)0xf7, "iput-object-quick", maxApi(22), ReferenceType.NONE, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - INVOKE_VIRTUAL_QUICK((short)0xf8, "invoke-virtual-quick", maxApi(22), ReferenceType.NONE, Format.Format35ms, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_VIRTUAL_QUICK_RANGE((short)0xf9, "invoke-virtual-quick/range", maxApi(22), ReferenceType.NONE, Format.Format3rms, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_SUPER_QUICK((short)0xfa, "invoke-super-quick", ReferenceType.NONE, Format.Format35ms, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - INVOKE_SUPER_QUICK_RANGE((short)0xfb, "invoke-super-quick/range", ReferenceType.NONE, Format.Format3rms, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT), - - IPUT_OBJECT_VOLATILE((short)0xfc, "iput-object-volatile", minApi(9), ReferenceType.FIELD, Format.Format22c, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - SGET_OBJECT_VOLATILE((short)0xfd, "sget-object-volatile", minApi(9), ReferenceType.FIELD, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER), - SPUT_OBJECT_VOLATILE((short)0xfe, "sput-object-volatile", minApi(9), ReferenceType.FIELD, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE), - - PACKED_SWITCH_PAYLOAD((short)0x100, "packed-switch-payload", ReferenceType.NONE, Format.PackedSwitchPayload, 0), - SPARSE_SWITCH_PAYLOAD((short)0x200, "sparse-switch-payload", ReferenceType.NONE, Format.SparseSwitchPayload, 0), - ARRAY_PAYLOAD((short)0x300, "array-payload", ReferenceType.NONE, Format.ArrayPayload, 0), - - // Reuse the deprecated f3-ff opcodes in Art: - INVOKE_LAMBDA((short)0xf3, "invoke-lambda", minApi(23), ReferenceType.NONE, Format.Format25x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT | Opcode.EXPERIMENTAL), - // TODO: What about JUMBO support if the string ID is too large? - CAPTURE_VARIABLE((short)0xf5, "capture-variable", minApi(23), ReferenceType.STRING, Format.Format21c, Opcode.EXPERIMENTAL), - CREATE_LAMBDA((short)0xf6, "create-lambda", minApi(23), ReferenceType.METHOD, Format.Format21c, Opcode.SETS_REGISTER | Opcode.EXPERIMENTAL), - // TODO: do we need a capture/liberate wide? - LIBERATE_VARIABLE((short)0xf7, "liberate-variable", minApi(23), ReferenceType.STRING, Format.Format22c, Opcode.SETS_REGISTER | Opcode.EXPERIMENTAL), - BOX_LAMBDA((short)0xf8, "box-lambda", minApi(23), ReferenceType.NONE, Format.Format22x, Opcode.SETS_REGISTER | Opcode.EXPERIMENTAL), - UNBOX_LAMBDA((short)0xf9, "unbox-lambda", minApi(23), ReferenceType.TYPE, Format.Format22c, Opcode.SETS_REGISTER | Opcode.EXPERIMENTAL); - - //if the instruction can throw an exception - public static final int CAN_THROW = 0x1; - //if the instruction is an odex only instruction - public static final int ODEX_ONLY = 0x2; - //if execution can continue to the next instruction - public static final int CAN_CONTINUE = 0x4; - //if the instruction sets the "hidden" result register - public static final int SETS_RESULT = 0x8; - //if the instruction sets the value of it's first register - public static final int SETS_REGISTER = 0x10; - //if the instruction sets the value of it's first register to a wide type - public static final int SETS_WIDE_REGISTER = 0x20; - //if the instruction is an odexed iget-quick/iput-quick instruction - public static final int ODEXED_INSTANCE_QUICK = 0x40; - //if the instruction is an odexed iget-volatile/iput-volatile instruction - public static final int ODEXED_INSTANCE_VOLATILE = 0x80; - //if the instruction is an odexed sget-volatile/sput-volatile instruction - public static final int ODEXED_STATIC_VOLATILE = 0x100; - //if the instruction is a jumbo instruction - public static final int JUMBO_OPCODE = 0x200; - //if the instruction can initialize an uninitialized object reference - public static final int CAN_INITIALIZE_REFERENCE = 0x400; - //if the instruction is experimental (not potentially supported by Android runtime yet) - public static final int EXPERIMENTAL = 0x800; - - private static final int ALL_APIS = 0xFFFF0000; - - private static int minApi(int api) { - return 0xFFFF0000 | (api & 0xFFFF); - } - - private static int maxApi(int api) { - return api << 16; - } - - public final short value; - public final String name; - // high 16-bits is the max api, low 16-bits is the min api - public final int apiConstraints; - public final int referenceType; - public final Format format; - public final int flags; - - Opcode(short opcodeValue, String opcodeName, int referenceType, Format format) { - this(opcodeValue, opcodeName, ALL_APIS, referenceType, format, 0, (short)-1); - } - - Opcode(short opcodeValue, String opcodeName, int referenceType, Format format, int flags) { - this(opcodeValue, opcodeName, ALL_APIS, referenceType, format, flags, (short)-1); - } - - Opcode(short opcodeValue, String opcodeName, int referenceType, Format format, int flags, short jumboOpcodeValue) { - this(opcodeValue, opcodeName, ALL_APIS, referenceType, format, flags, jumboOpcodeValue); - } - - Opcode(short opcodeValue, String opcodeName, int apiConstraints, int referenceType, Format format) { - this(opcodeValue, opcodeName, apiConstraints, referenceType, format, 0, (short)-1); - } - - Opcode(short opcodeValue, String opcodeName, int apiConstraints, int referenceType, Format format, int flags) { - this(opcodeValue, opcodeName, apiConstraints, referenceType, format, flags, (short)-1); - } - - Opcode(short opcodeValue, String opcodeName, int apiConstraints, int referenceType, Format format, int flags, - short jumboOpcodeValue) { - this.value = opcodeValue; - this.name = opcodeName; - this.apiConstraints = apiConstraints; - this.referenceType = referenceType; - this.format = format; - this.flags = flags; - // TODO: implement jumbo opcodes for dexlib2 and uncomment - // this.jumboOpcode = jumboOpcodeValue; - } - - /** - * @return the minimum api level that can use this opcode (inclusive) - */ - public int getMinApi() { - return apiConstraints & 0xFFFF; - } - - /** - * @return the maximum api level that can to use this opcode (inclusive) - */ - public int getMaxApi() { - return apiConstraints >>> 16; - } - - public final boolean canThrow() { - return (flags & CAN_THROW) != 0; - } - - public final boolean odexOnly() { - return (flags & ODEX_ONLY) != 0; - } - - public final boolean canContinue() { - return (flags & CAN_CONTINUE) != 0; - } - - public final boolean setsResult() { - return (flags & SETS_RESULT) != 0; - } - - public final boolean setsRegister() { - return (flags & SETS_REGISTER) != 0; - } - - public final boolean setsWideRegister() { - return (flags & SETS_WIDE_REGISTER) != 0; - } - - public final boolean isOdexedInstanceQuick() { - return (flags & ODEXED_INSTANCE_QUICK) != 0; - } - - public final boolean isOdexedInstanceVolatile() { - return (flags & ODEXED_INSTANCE_VOLATILE) != 0; - } - - public final boolean isOdexedStaticVolatile() { - return (flags & ODEXED_STATIC_VOLATILE) != 0; - } - - public final boolean isJumboOpcode() { - return (flags & JUMBO_OPCODE) != 0; - } - - public final boolean canInitializeReference() { - return (flags & CAN_INITIALIZE_REFERENCE) != 0; - } - - public final boolean isExperimental() { - return (flags & EXPERIMENTAL) != 0; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java deleted file mode 100644 index e718e275..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/Opcodes.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -import com.google.common.collect.Maps; - -import javax.annotation.Nullable; -import java.util.HashMap; - -public class Opcodes { - private final Opcode[] opcodesByValue; - private final HashMap opcodesByName; - - public Opcodes(int api) { - this(api, false); - } - - public Opcodes(int api, boolean experimental) { - opcodesByValue = new Opcode[256]; - opcodesByName = Maps.newHashMap(); - - for (Opcode opcode: Opcode.values()) { - if (!opcode.format.isPayloadFormat) { - if (api <= opcode.getMaxApi() && api >= opcode.getMinApi() && - (experimental || !opcode.isExperimental())) { - opcodesByValue[opcode.value] = opcode; - opcodesByName.put(opcode.name.toLowerCase(), opcode); - } - } - } - } - - @Nullable - public Opcode getOpcodeByName(String opcodeName) { - return opcodesByName.get(opcodeName.toLowerCase()); - } - - @Nullable - public Opcode getOpcodeByValue(int opcodeValue) { - switch (opcodeValue) { - case 0x100: - return Opcode.PACKED_SWITCH_PAYLOAD; - case 0x200: - return Opcode.SPARSE_SWITCH_PAYLOAD; - case 0x300: - return Opcode.ARRAY_PAYLOAD; - default: - if (opcodeValue >= 0 && opcodeValue < opcodesByValue.length) { - return opcodesByValue[opcodeValue]; - } - return null; - } - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/ReferenceType.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/ReferenceType.java deleted file mode 100644 index 3371f818..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/ReferenceType.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -import org.jf.dexlib2.iface.reference.*; -import org.jf.util.ExceptionWithContext; - -public final class ReferenceType { - public static final int STRING = 0; - public static final int TYPE = 1; - public static final int FIELD = 2; - public static final int METHOD = 3; - public static final int NONE = 4; - - public static String toString(int referenceType) { - switch (referenceType) { - case STRING: - return "string"; - case TYPE: - return "type"; - case FIELD: - return "field"; - case METHOD: - return "method"; - default: - throw new InvalidReferenceTypeException(referenceType); - } - } - - public static int getReferenceType(Reference reference) { - if (reference instanceof StringReference) { - return STRING; - } else if (reference instanceof TypeReference) { - return TYPE; - } else if (reference instanceof FieldReference) { - return FIELD; - } else if (reference instanceof MethodReference) { - return METHOD; - } else { - throw new IllegalStateException("Invalid reference"); - } - } - - /** - * Validate a specific reference type. Note that the NONE placeholder is specifically not considered valid here. - * - * @throws InvalidReferenceTypeException - */ - public static void validateReferenceType(int referenceType) { - if (referenceType < 0 || referenceType > 3) { - throw new InvalidReferenceTypeException(referenceType); - } - } - - public static class InvalidReferenceTypeException extends ExceptionWithContext { - private final int referenceType; - - public InvalidReferenceTypeException(int referenceType) { - super("Invalid reference type: %d", referenceType); - this.referenceType = referenceType; - } - - public InvalidReferenceTypeException(int referenceType, String message, Object... formatArgs) { - super(message, formatArgs); - this.referenceType = referenceType; - } - - public int getReferenceType() { - return referenceType; - } - } - - private ReferenceType() {} -} \ No newline at end of file diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/ValueType.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/ValueType.java deleted file mode 100644 index 08710a6b..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/ValueType.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -public final class ValueType { - public static final int BYTE = 0x00; - public static final int SHORT = 0x02; - public static final int CHAR = 0x03; - public static final int INT = 0x04; - public static final int LONG = 0x06; - public static final int FLOAT = 0x10; - public static final int DOUBLE = 0x11; - public static final int STRING = 0x17; - public static final int TYPE = 0x18; - public static final int FIELD = 0x19; - public static final int METHOD = 0x1a; - public static final int ENUM = 0x1b; - public static final int ARRAY = 0x1c; - public static final int ANNOTATION = 0x1d; - public static final int NULL = 0x1e; - public static final int BOOLEAN = 0x1f; - - private ValueType() {} -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/VerificationError.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/VerificationError.java deleted file mode 100644 index d0aa0297..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/VerificationError.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2; - -import com.google.common.collect.Maps; -import org.jf.util.ExceptionWithContext; - -import javax.annotation.Nullable; -import java.util.HashMap; - -public class VerificationError { - public static final int GENERIC = 1; - public static final int NO_SUCH_CLASS = 2; - public static final int NO_SUCH_FIELD = 3; - public static final int NO_SUCH_METHOD = 4; - public static final int ILLEGAL_CLASS_ACCESS = 5; - public static final int ILLEGAL_FIELD_ACCESS = 6; - public static final int ILLEGAL_METHOD_ACCESS = 7; - public static final int CLASS_CHANGE_ERROR = 8; - public static final int INSTANTIATION_ERROR = 9; - - private static final HashMap verificationErrorNames = Maps.newHashMap(); - - static { - verificationErrorNames.put("generic-error", GENERIC); - verificationErrorNames.put("no-such-class", NO_SUCH_CLASS); - verificationErrorNames.put("no-such-field", NO_SUCH_FIELD); - verificationErrorNames.put("no-such-method", NO_SUCH_METHOD); - verificationErrorNames.put("illegal-class-access", ILLEGAL_CLASS_ACCESS); - verificationErrorNames.put("illegal-field-access", ILLEGAL_FIELD_ACCESS); - verificationErrorNames.put("illegal-method-access", ILLEGAL_METHOD_ACCESS); - verificationErrorNames.put("class-change-error", CLASS_CHANGE_ERROR); - verificationErrorNames.put("instantiation-error", INSTANTIATION_ERROR); - } - - @Nullable - public static String getVerificationErrorName(int verificationError) { - switch (verificationError) { - case GENERIC: - return "generic-error"; - case NO_SUCH_CLASS: - return "no-such-class"; - case NO_SUCH_FIELD: - return "no-such-field"; - case NO_SUCH_METHOD: - return "no-such-method"; - case ILLEGAL_CLASS_ACCESS: - return "illegal-class-access"; - case ILLEGAL_FIELD_ACCESS: - return "illegal-field-access"; - case ILLEGAL_METHOD_ACCESS: - return "illegal-method-access"; - case CLASS_CHANGE_ERROR: - return "class-change-error"; - case INSTANTIATION_ERROR: - return "instantiation-error"; - default: - return null; - } - } - - public static int getVerificationError(String verificationError) { - Integer ret = verificationErrorNames.get(verificationError); - if (ret == null) { - throw new ExceptionWithContext("Invalid verification error: %s", verificationError); - } - return ret; - } - - public static boolean isValidVerificationError(int verificationError) { - return verificationError > 0 && verificationError < 10; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/AnalysisException.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/AnalysisException.java deleted file mode 100644 index 4ca7b138..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/AnalysisException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import org.jf.util.ExceptionWithContext; - -public class AnalysisException extends ExceptionWithContext { - public int codeAddress; - - public AnalysisException(Throwable cause) { - super(cause); - } - - public AnalysisException(Throwable cause, String message, Object... formatArgs) { - super(cause, message, formatArgs); - } - - public AnalysisException(String message, Object... formatArgs) { - super(message, formatArgs); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/AnalyzedInstruction.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/AnalyzedInstruction.java deleted file mode 100644 index 30cc9067..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/AnalyzedInstruction.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import org.jf.dexlib2.iface.instruction.*; -import org.jf.dexlib2.iface.reference.MethodReference; -import org.jf.dexlib2.iface.reference.Reference; -import org.jf.util.ExceptionWithContext; - -import javax.annotation.Nonnull; -import java.util.*; - -public class AnalyzedInstruction implements Comparable { - /** - * The actual instruction - */ - protected Instruction instruction; - - /** - * The index of the instruction, where the first instruction in the method is at index 0, and so on - */ - protected final int instructionIndex; - - /** - * Instructions that can pass on execution to this one during normal execution - */ - protected final TreeSet predecessors = new TreeSet(); - - /** - * Instructions that can execution could pass on to next during normal execution - */ - protected final LinkedList successors = new LinkedList(); - - /** - * This contains the register types *before* the instruction has executed - */ - protected final RegisterType[] preRegisterMap; - - /** - * This contains the register types *after* the instruction has executed - */ - protected final RegisterType[] postRegisterMap; - - /** - * When deodexing, we might need to deodex this instruction multiple times, when we merge in new register - * information. When this happens, we need to restore the original (odexed) instruction, so we can deodex it again - */ - protected final Instruction originalInstruction; - - public AnalyzedInstruction(Instruction instruction, int instructionIndex, int registerCount) { - this.instruction = instruction; - this.originalInstruction = instruction; - this.instructionIndex = instructionIndex; - this.postRegisterMap = new RegisterType[registerCount]; - this.preRegisterMap = new RegisterType[registerCount]; - RegisterType unknown = RegisterType.getRegisterType(RegisterType.UNKNOWN, null); - for (int i=0; i getPredecessors() { - return Collections.unmodifiableSortedSet(predecessors); - } - - protected boolean addPredecessor(AnalyzedInstruction predecessor) { - return predecessors.add(predecessor); - } - - protected void addSuccessor(AnalyzedInstruction successor) { - successors.add(successor); - } - - protected void setDeodexedInstruction(Instruction instruction) { - assert originalInstruction.getOpcode().odexOnly(); - this.instruction = instruction; - } - - protected void restoreOdexedInstruction() { - assert originalInstruction.getOpcode().odexOnly(); - instruction = originalInstruction; - } - - public int getSuccessorCount() { - return successors.size(); - } - - public List getSuccesors() { - return Collections.unmodifiableList(successors); - } - - public Instruction getInstruction() { - return instruction; - } - - public Instruction getOriginalInstruction() { - return originalInstruction; - } - - /** - * Is this instruction a "beginning instruction". A beginning instruction is defined to be an instruction - * that can be the first successfully executed instruction in the method. The first instruction is always a - * beginning instruction. If the first instruction can throw an exception, and is covered by a try block, then - * the first instruction of any exception handler for that try block is also a beginning instruction. And likewise, - * if any of those instructions can throw an exception and are covered by try blocks, the first instruction of the - * corresponding exception handler is a beginning instruction, etc. - * - * To determine this, we simply check if the first predecessor is the fake "StartOfMethod" instruction, which has - * an instruction index of -1. - * @return a boolean value indicating whether this instruction is a beginning instruction - */ - public boolean isBeginningInstruction() { - //if this instruction has no predecessors, it is either the fake "StartOfMethod" instruction or it is an - //unreachable instruction. - if (predecessors.size() == 0) { - return false; - } - - if (predecessors.first().instructionIndex == -1) { - return true; - } - return false; - } - - /* - * Merges the given register type into the specified pre-instruction register, and also sets the post-instruction - * register type accordingly if it isn't a destination register for this instruction - * @param registerNumber Which register to set - * @param registerType The register type - * @returns true If the post-instruction register type was changed. This might be false if either the specified - * register is a destination register for this instruction, or if the pre-instruction register type didn't change - * after merging in the given register type - */ - protected boolean mergeRegister(int registerNumber, RegisterType registerType, BitSet verifiedInstructions) { - assert registerNumber >= 0 && registerNumber < postRegisterMap.length; - assert registerType != null; - - RegisterType oldRegisterType = preRegisterMap[registerNumber]; - RegisterType mergedRegisterType = oldRegisterType.merge(registerType); - - if (mergedRegisterType.equals(oldRegisterType)) { - return false; - } - - preRegisterMap[registerNumber] = mergedRegisterType; - verifiedInstructions.clear(instructionIndex); - - if (!setsRegister(registerNumber)) { - postRegisterMap[registerNumber] = mergedRegisterType; - return true; - } - - return false; - } - - /** - * Iterates over the predecessors of this instruction, and merges all the post-instruction register types for the - * given register. Any dead, unreachable, or odexed predecessor is ignored - * @param registerNumber the register number - * @return The register type resulting from merging the post-instruction register types from all predecessors - */ - protected RegisterType mergePreRegisterTypeFromPredecessors(int registerNumber) { - RegisterType mergedRegisterType = null; - for (AnalyzedInstruction predecessor: predecessors) { - RegisterType predecessorRegisterType = predecessor.postRegisterMap[registerNumber]; - assert predecessorRegisterType != null; - mergedRegisterType = predecessorRegisterType.merge(mergedRegisterType); - } - return mergedRegisterType; - } - - /* - * Sets the "post-instruction" register type as indicated. - * @param registerNumber Which register to set - * @param registerType The "post-instruction" register type - * @returns true if the given register type is different than the existing post-instruction register type - */ - protected boolean setPostRegisterType(int registerNumber, RegisterType registerType) { - assert registerNumber >= 0 && registerNumber < postRegisterMap.length; - assert registerType != null; - - RegisterType oldRegisterType = postRegisterMap[registerNumber]; - if (oldRegisterType.equals(registerType)) { - return false; - } - - postRegisterMap[registerNumber] = registerType; - return true; - } - - - protected boolean isInvokeInit() { - if (instruction == null || !instruction.getOpcode().canInitializeReference()) { - return false; - } - - ReferenceInstruction instruction = (ReferenceInstruction)this.instruction; - - Reference reference = instruction.getReference(); - if (reference instanceof MethodReference) { - return ((MethodReference)reference).getName().equals(""); - } - - return false; - } - - public boolean setsRegister() { - return instruction.getOpcode().setsRegister(); - } - - public boolean setsWideRegister() { - return instruction.getOpcode().setsWideRegister(); - } - - public boolean setsRegister(int registerNumber) { - //When constructing a new object, the register type will be an uninitialized reference after the new-instance - //instruction, but becomes an initialized reference once the method is called. So even though invoke - //instructions don't normally change any registers, calling an method will change the type of its - //object register. If the uninitialized reference has been copied to other registers, they will be initialized - //as well, so we need to check for that too - if (isInvokeInit()) { - int destinationRegister; - if (instruction instanceof FiveRegisterInstruction) { - destinationRegister = ((FiveRegisterInstruction)instruction).getRegisterC(); - } else { - assert instruction instanceof RegisterRangeInstruction; - RegisterRangeInstruction rangeInstruction = (RegisterRangeInstruction)instruction; - assert rangeInstruction.getRegisterCount() > 0; - destinationRegister = rangeInstruction.getStartRegister(); - } - - if (registerNumber == destinationRegister) { - return true; - } - RegisterType preInstructionDestRegisterType = getPreInstructionRegisterType(registerNumber); - if (preInstructionDestRegisterType.category != RegisterType.UNINIT_REF && - preInstructionDestRegisterType.category != RegisterType.UNINIT_THIS) { - - return false; - } - //check if the uninit ref has been copied to another register - if (getPreInstructionRegisterType(registerNumber).equals(preInstructionDestRegisterType)) { - return true; - } - return false; - } - - if (!setsRegister()) { - return false; - } - int destinationRegister = getDestinationRegister(); - - if (registerNumber == destinationRegister) { - return true; - } - if (setsWideRegister() && registerNumber == (destinationRegister + 1)) { - return true; - } - return false; - } - - public int getDestinationRegister() { - if (!this.instruction.getOpcode().setsRegister()) { - throw new ExceptionWithContext("Cannot call getDestinationRegister() for an instruction that doesn't " + - "store a value"); - } - return ((OneRegisterInstruction)instruction).getRegisterA(); - } - - public int getRegisterCount() { - return postRegisterMap.length; - } - - @Nonnull - public RegisterType getPostInstructionRegisterType(int registerNumber) { - return postRegisterMap[registerNumber]; - } - - @Nonnull - public RegisterType getPreInstructionRegisterType(int registerNumber) { - return preRegisterMap[registerNumber]; - } - - public int compareTo(AnalyzedInstruction analyzedInstruction) { - if (instructionIndex < analyzedInstruction.instructionIndex) { - return -1; - } else if (instructionIndex == analyzedInstruction.instructionIndex) { - return 0; - } else { - return 1; - } - } -} - diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ArrayProto.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ArrayProto.java deleted file mode 100644 index 8fcfc8c5..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ArrayProto.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import com.google.common.base.Strings; -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.iface.reference.MethodReference; -import org.jf.dexlib2.immutable.reference.ImmutableFieldReference; -import org.jf.dexlib2.util.TypeUtils; -import org.jf.util.ExceptionWithContext; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class ArrayProto implements TypeProto { - protected final ClassPath classPath; - protected final int dimensions; - protected final String elementType; - - public ArrayProto(@Nonnull ClassPath classPath, @Nonnull String type) { - this.classPath = classPath; - int i=0; - while (type.charAt(i) == '[') { - i++; - if (i == type.length()) { - throw new ExceptionWithContext("Invalid array type: %s", type); - } - } - - if (i == 0) { - throw new ExceptionWithContext("Invalid array type: %s", type); - } - - dimensions = i; - elementType = type.substring(i); - } - - @Override public String toString() { return getType(); } - @Nonnull @Override public ClassPath getClassPath() { return classPath; } - @Nonnull @Override public String getType() { return makeArrayType(elementType, dimensions); } - public int getDimensions() { return dimensions; } - @Override public boolean isInterface() { return false; } - - /** - * @return The base element type of this array. E.g. This would return Ljava/lang/String; for [[Ljava/lang/String; - */ - @Nonnull public String getElementType() { return elementType; } - - /** - * @return The immediate element type of this array. E.g. This would return [Ljava/lang/String; for - * [[Ljava/lang/String; - */ - @Nonnull public String getImmediateElementType() { - if (dimensions > 1) { - return makeArrayType(elementType, dimensions-1); - } - return elementType; - } - - @Override public boolean implementsInterface(@Nonnull String iface) { - return iface.equals("Ljava/lang/Cloneable;") || iface.equals("Ljava/io/Serializable;"); - } - - @Nullable @Override - public String getSuperclass() { - return "Ljava/lang/Object;"; - } - - @Nonnull @Override - public TypeProto getCommonSuperclass(@Nonnull TypeProto other) { - if (other instanceof ArrayProto) { - if (TypeUtils.isPrimitiveType(getElementType()) || - TypeUtils.isPrimitiveType(((ArrayProto)other).getElementType())) { - if (dimensions == ((ArrayProto)other).dimensions && - getElementType().equals(((ArrayProto)other).getElementType())) { - return this; - } - return classPath.getClass("Ljava/lang/Object;"); - } - - if (dimensions == ((ArrayProto)other).dimensions) { - TypeProto thisClass = classPath.getClass(elementType); - TypeProto otherClass = classPath.getClass(((ArrayProto)other).elementType); - TypeProto mergedClass = thisClass.getCommonSuperclass(otherClass); - if (thisClass == mergedClass) { - return this; - } - if (otherClass == mergedClass) { - return other; - } - return classPath.getClass(makeArrayType(mergedClass.getType(), dimensions)); - } - - int dimensions = Math.min(this.dimensions, ((ArrayProto)other).dimensions); - return classPath.getClass(makeArrayType("Ljava/lang/Object;", dimensions)); - } - - if (other instanceof ClassProto) { - try { - if (other.isInterface()) { - if (implementsInterface(other.getType())) { - return other; - } - } - } catch (UnresolvedClassException ex) { - // ignore - } - return classPath.getClass("Ljava/lang/Object;"); - } - - // otherwise, defer to the other class' getCommonSuperclass - return other.getCommonSuperclass(this); - } - - private static final String BRACKETS = Strings.repeat("[", 256); - - @Nonnull - private static String makeArrayType(@Nonnull String elementType, int dimensions) { - return BRACKETS.substring(0, dimensions) + elementType; - } - - - @Override - @Nullable - public FieldReference getFieldByOffset(int fieldOffset) { - if (fieldOffset==8) { - return new ImmutableFieldReference(getType(), "length", "int"); - } - return null; - } - - @Override - @Nullable - public MethodReference getMethodByVtableIndex(int vtableIndex) { - return classPath.getClass("Ljava/lang/Object;").getMethodByVtableIndex(vtableIndex); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ClassPath.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ClassPath.java deleted file mode 100644 index de6a0c25..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ClassPath.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import org.jf.dexlib2.DexFileFactory; -import org.jf.dexlib2.analysis.reflection.ReflectionClassDef; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.dexlib2.iface.DexFile; -import org.jf.dexlib2.immutable.ImmutableDexFile; -import org.jf.util.ExceptionWithContext; - -import javax.annotation.Nonnull; -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class ClassPath { - public static boolean dontLoadClassPath = false; - - @Nonnull private final TypeProto unknownClass; - @Nonnull private HashMap availableClasses = Maps.newHashMap(); - private boolean checkPackagePrivateAccess; - - /** - * Creates a new ClassPath instance that can load classes from the given dex files - * - * @param classPath An array of DexFile objects. When loading a class, these dex files will be searched in order - */ - public ClassPath(DexFile... classPath) throws IOException { - this(Lists.newArrayList(classPath), 15); - } - - /** - * Creates a new ClassPath instance that can load classes from the given dex files - * - * @param classPath An iterable of DexFile objects. When loading a class, these dex files will be searched in order - * @param api API level - */ - public ClassPath(@Nonnull Iterable classPath, int api) { - this(Lists.newArrayList(classPath), api == 17); - } - - /** - * Creates a new ClassPath instance that can load classes from the given dex files - * - * @param classPath An iterable of DexFile objects. When loading a class, these dex files will be searched in order - * @param checkPackagePrivateAccess Whether checkPackagePrivateAccess is needed, enabled for ONLY early API 17 by default - */ - public ClassPath(@Nonnull Iterable classPath, boolean checkPackagePrivateAccess) { - // add fallbacks for certain special classes that must be present - Iterable dexFiles = Iterables.concat(classPath, Lists.newArrayList(getBasicClasses())); - - unknownClass = new UnknownClassProto(this); - loadedClasses.put(unknownClass.getType(), unknownClass); - this.checkPackagePrivateAccess = checkPackagePrivateAccess; - - loadPrimitiveType("Z"); - loadPrimitiveType("B"); - loadPrimitiveType("S"); - loadPrimitiveType("C"); - loadPrimitiveType("I"); - loadPrimitiveType("J"); - loadPrimitiveType("F"); - loadPrimitiveType("D"); - loadPrimitiveType("L"); - - for (DexFile dexFile: dexFiles) { - for (ClassDef classDef: dexFile.getClasses()) { - ClassDef prev = availableClasses.get(classDef.getType()); - if (prev == null) { - availableClasses.put(classDef.getType(), classDef); - } - } - } - } - - private void loadPrimitiveType(String type) { - loadedClasses.put(type, new PrimitiveProto(this, type)); - } - - private static DexFile getBasicClasses() { - // fallbacks for some special classes that we assume are present - return new ImmutableDexFile(ImmutableSet.of( - new ReflectionClassDef(Class.class), - new ReflectionClassDef(Cloneable.class), - new ReflectionClassDef(Object.class), - new ReflectionClassDef(Serializable.class), - new ReflectionClassDef(String.class), - new ReflectionClassDef(Throwable.class))); - } - - @Nonnull - public TypeProto getClass(CharSequence type) { - return loadedClasses.getUnchecked(type.toString()); - } - - private final CacheLoader classLoader = new CacheLoader() { - @Override public TypeProto load(String type) throws Exception { - if (type.charAt(0) == '[') { - return new ArrayProto(ClassPath.this, type); - } else { - return new ClassProto(ClassPath.this, type); - } - } - }; - - @Nonnull private LoadingCache loadedClasses = CacheBuilder.newBuilder().build(classLoader); - - @Nonnull - public ClassDef getClassDef(String type) { - if (dontLoadClassPath) { - throw new UnresolvedClassException("Could not resolve class %s", type); - } - - ClassDef ret = availableClasses.get(type); - if (ret == null) { - throw new UnresolvedClassException("Could not resolve class %s", type); - } - return ret; - } - - @Nonnull - public TypeProto getUnknownClass() { - return unknownClass; - } - - public boolean shouldCheckPackagePrivateAccess() { - return checkPackagePrivateAccess; - } - - @Nonnull - public static ClassPath fromClassPath(Iterable classPathDirs, Iterable classPath, DexFile dexFile, - int api, boolean experimental) { - return fromClassPath(classPathDirs, classPath, dexFile, api, api == 17, experimental); - } - - @Nonnull - public static ClassPath fromClassPath(Iterable classPathDirs, Iterable classPath, DexFile dexFile, - int api, boolean checkPackagePrivateAccess, boolean experimental) { - ArrayList dexFiles = Lists.newArrayList(); - - for (String classPathEntry: classPath) { - try { - dexFiles.add(loadClassPathEntry(classPathDirs, classPathEntry, api, experimental)); - } catch (ExceptionWithContext e){} - } - dexFiles.add(dexFile); - return new ClassPath(dexFiles, checkPackagePrivateAccess); - } - - private static final Pattern dalvikCacheOdexPattern = Pattern.compile("@([^@]+)@classes.dex$"); - - @Nonnull - private static DexFile loadClassPathEntry(@Nonnull Iterable classPathDirs, - @Nonnull String bootClassPathEntry, int api, - boolean experimental) { - File rawEntry = new File(bootClassPathEntry); - // strip off the path - we only care about the filename - String entryName = rawEntry.getName(); - - // if it's a dalvik-cache entry, grab the name of the jar/apk - if (entryName.endsWith("@classes.dex")) { - Matcher m = dalvikCacheOdexPattern.matcher(entryName); - - if (!m.find()) { - throw new ExceptionWithContext(String.format("Cannot parse dependency value %s", bootClassPathEntry)); - } - - entryName = m.group(1); - } - - int extIndex = entryName.lastIndexOf("."); - - String baseEntryName; - if (extIndex == -1) { - baseEntryName = entryName; - } else { - baseEntryName = entryName.substring(0, extIndex); - } - - for (String classPathDir: classPathDirs) { - for (String ext: new String[]{"", ".odex", ".jar", ".apk", ".zip"}) { - File file = new File(classPathDir, baseEntryName + ext); - - if (file.exists() && file.isFile()) { - if (!file.canRead()) { - System.err.println(String.format( - "warning: cannot open %s for reading. Will continue looking.", file.getPath())); - } else { - try { - return DexFileFactory.loadDexFile(file, api, experimental); - } catch (DexFileFactory.NoClassesDexException ex) { - // ignore and continue - } catch (Exception ex) { - throw ExceptionWithContext.withContext(ex, - "Error while reading boot class path entry \"%s\"", bootClassPathEntry); - } - } - } - } - } - throw new ExceptionWithContext("Cannot locate boot class path file %s", bootClassPathEntry); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ClassProto.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ClassProto.java deleted file mode 100644 index e513f23d..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/ClassProto.java +++ /dev/null @@ -1,675 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import com.google.common.base.Predicates; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import org.jf.dexlib2.AccessFlags; -import org.jf.dexlib2.analysis.util.TypeProtoUtils; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.dexlib2.iface.Field; -import org.jf.dexlib2.iface.Method; -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.iface.reference.MethodReference; -import org.jf.dexlib2.immutable.ImmutableMethod; -import org.jf.util.ExceptionWithContext; -import org.jf.util.SparseArray; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; - -/** - * A class "prototype". This contains things like the interfaces, the superclass, the vtable and the instance fields - * and their offsets. - */ -public class ClassProto implements TypeProto { - @Nonnull protected final ClassPath classPath; - @Nonnull protected final String type; - - protected boolean vtableFullyResolved = true; - protected boolean interfacesFullyResolved = true; - - public ClassProto(@Nonnull ClassPath classPath, @Nonnull String type) { - if (type.charAt(0) != 'L') { - throw new ExceptionWithContext("Cannot construct ClassProto for non reference type: %s", type); - } - this.classPath = classPath; - this.type = type; - } - - @Override public String toString() { return type; } - @Nonnull @Override public ClassPath getClassPath() { return classPath; } - @Nonnull @Override public String getType() { return type; } - - @Nonnull - public ClassDef getClassDef() { - return classDefSupplier.get(); - } - - - @Nonnull private final Supplier classDefSupplier = Suppliers.memoize(new Supplier() { - @Override public ClassDef get() { - return classPath.getClassDef(type); - } - }); - - /** - * Returns true if this class is an interface. - * - * If this class is not defined, then this will throw an UnresolvedClassException - * - * @return True if this class is an interface - */ - public boolean isInterface() { - ClassDef classDef = getClassDef(); - return (classDef.getAccessFlags() & AccessFlags.INTERFACE.getValue()) != 0; - } - - /** - * Returns the set of interfaces that this class implements as a Map. - * - * The ClassDef value will be present only for the interfaces that this class directly implements (including any - * interfaces transitively implemented), but not for any interfaces that are only implemented by a superclass of - * this class - * - * For any interfaces that are only implemented by a superclass (or the class itself, if the class is an interface), - * the value will be null. - * - * If any interface couldn't be resolved, then the interfacesFullyResolved field will be set to false upon return. - * - * @return the set of interfaces that this class implements as a Map. - */ - @Nonnull - protected LinkedHashMap getInterfaces() { - return interfacesSupplier.get(); - } - - @Nonnull - private final Supplier> interfacesSupplier = - Suppliers.memoize(new Supplier>() { - @Override public LinkedHashMap get() { - LinkedHashMap interfaces = Maps.newLinkedHashMap(); - - try { - for (String interfaceType: getClassDef().getInterfaces()) { - if (!interfaces.containsKey(interfaceType)) { - ClassDef interfaceDef; - try { - interfaceDef = classPath.getClassDef(interfaceType); - interfaces.put(interfaceType, interfaceDef); - } catch (UnresolvedClassException ex) { - interfaces.put(interfaceType, null); - interfacesFullyResolved = false; - } - - ClassProto interfaceProto = (ClassProto) classPath.getClass(interfaceType); - for (String superInterface: interfaceProto.getInterfaces().keySet()) { - if (!interfaces.containsKey(superInterface)) { - interfaces.put(superInterface, interfaceProto.getInterfaces().get(superInterface)); - } - } - if (!interfaceProto.interfacesFullyResolved) { - interfacesFullyResolved = false; - } - } - } - } catch (UnresolvedClassException ex) { - interfacesFullyResolved = false; - } - - // now add self and super class interfaces, required for common super class lookup - // we don't really need ClassDef's for that, so let's just use null - - if (isInterface() && !interfaces.containsKey(getType())) { - interfaces.put(getType(), null); - } - - try { - String superclass = getSuperclass(); - if (superclass != null) { - ClassProto superclassProto = (ClassProto) classPath.getClass(superclass); - for (String superclassInterface: superclassProto.getInterfaces().keySet()) { - if (!interfaces.containsKey(superclassInterface)) { - interfaces.put(superclassInterface, null); - } - } - if (!superclassProto.interfacesFullyResolved) { - interfacesFullyResolved = false; - } - } - } catch (UnresolvedClassException ex) { - interfacesFullyResolved = false; - } - - return interfaces; - } - }); - - /** - * Gets the interfaces directly implemented by this class, or the interfaces they transitively implement. - * - * This does not include any interfaces that are only implemented by a superclass - * - * @return An iterables of ClassDefs representing the directly or transitively implemented interfaces - * @throws UnresolvedClassException if interfaces could not be fully resolved - */ - @Nonnull - protected Iterable getDirectInterfaces() { - Iterable directInterfaces = - FluentIterable.from(getInterfaces().values()).filter(Predicates.notNull()); - - if (!interfacesFullyResolved) { - throw new UnresolvedClassException("Interfaces for class %s not fully resolved", getType()); - } - - return directInterfaces; - } - - /** - * Checks if this class implements the given interface. - * - * If the interfaces of this class cannot be fully resolved then this - * method will either return true or throw an UnresolvedClassException - * - * @param iface The interface to check for - * @return true if this class implements the given interface, otherwise false - * @throws UnresolvedClassException if the interfaces for this class could not be fully resolved, and the interface - * is not one of the interfaces that were successfully resolved - */ - @Override - public boolean implementsInterface(@Nonnull String iface) { - if (getInterfaces().containsKey(iface)) { - return true; - } - if (!interfacesFullyResolved) { - throw new UnresolvedClassException("Interfaces for class %s not fully resolved", getType()); - } - return false; - } - - @Nullable @Override - public String getSuperclass() { - return getClassDef().getSuperclass(); - } - - /** - * This is a helper method for getCommonSuperclass - * - * It checks if this class is an interface, and if so, if other implements it. - * - * If this class is undefined, we go ahead and check if it is listed in other's interfaces. If not, we throw an - * UndefinedClassException - * - * If the interfaces of other cannot be fully resolved, we check the interfaces that can be resolved. If not found, - * we throw an UndefinedClassException - * - * @param other The class to check the interfaces of - * @return true if this class is an interface (or is undefined) other implements this class - * - */ - private boolean checkInterface(@Nonnull ClassProto other) { - boolean isResolved = true; - boolean isInterface = true; - try { - isInterface = isInterface(); - } catch (UnresolvedClassException ex) { - isResolved = false; - // if we don't know if this class is an interface or not, - // we can still try to call other.implementsInterface(this) - } - if (isInterface) { - try { - if (other.implementsInterface(getType())) { - return true; - } - } catch (UnresolvedClassException ex) { - // There are 2 possibilities here, depending on whether we were able to resolve this class. - // 1. If this class is resolved, then we know it is an interface class. The other class either - // isn't defined, or its interfaces couldn't be fully resolved. - // In this case, we throw an UnresolvedClassException - // 2. If this class is not resolved, we had tried to call implementsInterface anyway. We don't - // know for sure if this class is an interface or not. We return false, and let processing - // continue in getCommonSuperclass - if (isResolved) { - throw ex; - } - } - } - return false; - } - - @Override @Nonnull - public TypeProto getCommonSuperclass(@Nonnull TypeProto other) { - // use the other type's more specific implementation - if (!(other instanceof ClassProto)) { - return other.getCommonSuperclass(this); - } - - if (this == other || getType().equals(other.getType())) { - return this; - } - - if (this.getType().equals("Ljava/lang/Object;")) { - return this; - } - - if (other.getType().equals("Ljava/lang/Object;")) { - return other; - } - - boolean gotException = false; - try { - if (checkInterface((ClassProto)other)) { - return this; - } - } catch (UnresolvedClassException ex) { - gotException = true; - } - - try { - if (((ClassProto)other).checkInterface(this)) { - return other; - } - } catch (UnresolvedClassException ex) { - gotException = true; - } - if (gotException) { - return classPath.getUnknownClass(); - } - - List thisChain = Lists.newArrayList(this); - Iterables.addAll(thisChain, TypeProtoUtils.getSuperclassChain(this)); - - List otherChain = Lists.newArrayList(other); - Iterables.addAll(otherChain, TypeProtoUtils.getSuperclassChain(other)); - - // reverse them, so that the first entry is either Ljava/lang/Object; or Ujava/lang/Object; - thisChain = Lists.reverse(thisChain); - otherChain = Lists.reverse(otherChain); - - for (int i=Math.min(thisChain.size(), otherChain.size())-1; i>=0; i--) { - TypeProto typeProto = thisChain.get(i); - if (typeProto.getType().equals(otherChain.get(i).getType())) { - return typeProto; - } - } - - return classPath.getUnknownClass(); - } - - @Override - @Nullable - public FieldReference getFieldByOffset(int fieldOffset) { - if (getInstanceFields().size() == 0) { - return null; - } - return getInstanceFields().get(fieldOffset); - } - - @Override - @Nullable - public MethodReference getMethodByVtableIndex(int vtableIndex) { - List vtable = getVtable(); - if (vtableIndex < 0 || vtableIndex >= vtable.size()) { - return null; - } - - return vtable.get(vtableIndex); - } - - @Nonnull SparseArray getInstanceFields() { - return instanceFieldsSupplier.get(); - } - - @Nonnull private final Supplier> instanceFieldsSupplier = - Suppliers.memoize(new Supplier>() { - @Override public SparseArray get() { - //This is a bit of an "involved" operation. We need to follow the same algorithm that dalvik uses to - //arrange fields, so that we end up with the same field offsets (which is needed for deodexing). - //See mydroid/dalvik/vm/oo/Class.c - computeFieldOffsets() - - final byte REFERENCE = 0; - final byte WIDE = 1; - final byte OTHER = 2; - - ArrayList fields = getSortedInstanceFields(getClassDef()); - final int fieldCount = fields.size(); - //the "type" for each field in fields. 0=reference,1=wide,2=other - byte[] fieldTypes = new byte[fields.size()]; - for (int i=0; i front) { - if (fieldTypes[back] == REFERENCE) { - swap(fieldTypes, fields, front, back--); - break; - } - back--; - } - } - - if (fieldTypes[front] != REFERENCE) { - break; - } - } - - int startFieldOffset = 8; - String superclassType = getSuperclass(); - ClassProto superclass = null; - if (superclassType != null) { - superclass = (ClassProto) classPath.getClass(superclassType); - if (superclass != null) { - startFieldOffset = superclass.getNextFieldOffset(); - } - } - - int fieldIndexMod; - if ((startFieldOffset % 8) == 0) { - fieldIndexMod = 0; - } else { - fieldIndexMod = 1; - } - - //next, we need to group all the wide fields after the reference fields. But the wide fields have to be - //8-byte aligned. If we're on an odd field index, we need to insert a 32-bit field. If the next field - //is already a 32-bit field, use that. Otherwise, find the first 32-bit field from the end and swap it in. - //If there are no 32-bit fields, do nothing for now. We'll add padding when calculating the field offsets - if (front < fieldCount && (front % 2) != fieldIndexMod) { - if (fieldTypes[front] == WIDE) { - //we need to swap in a 32-bit field, so the wide fields will be correctly aligned - back = fieldCount - 1; - while (back > front) { - if (fieldTypes[back] == OTHER) { - swap(fieldTypes, fields, front++, back); - break; - } - back--; - } - } else { - //there's already a 32-bit field here that we can use - front++; - } - } - - //do the swap thing for wide fields - back = fieldCount - 1; - for (; front front) { - if (fieldTypes[back] == WIDE) { - swap(fieldTypes, fields, front, back--); - break; - } - back--; - } - } - - if (fieldTypes[front] != WIDE) { - break; - } - } - - SparseArray superFields; - if (superclass != null) { - superFields = superclass.getInstanceFields(); - } else { - superFields = new SparseArray(); - } - int superFieldCount = superFields.size(); - - //now the fields are in the correct order. Add them to the SparseArray and lookup, and calculate the offsets - int totalFieldCount = superFieldCount + fieldCount; - SparseArray instanceFields = new SparseArray(totalFieldCount); - - int fieldOffset; - - if (superclass != null && superFieldCount > 0) { - for (int i=0; i getSortedInstanceFields(@Nonnull ClassDef classDef) { - ArrayList fields = Lists.newArrayList(classDef.getInstanceFields()); - Collections.sort(fields); - return fields; - } - - private byte getFieldType(@Nonnull FieldReference field) { - switch (field.getType().charAt(0)) { - case '[': - case 'L': - return 0; //REFERENCE - case 'J': - case 'D': - return 1; //WIDE - default: - return 2; //OTHER - } - } - - private void swap(byte[] fieldTypes, List fields, int position1, int position2) { - byte tempType = fieldTypes[position1]; - fieldTypes[position1] = fieldTypes[position2]; - fieldTypes[position2] = tempType; - - Field tempField = fields.set(position1, fields.get(position2)); - fields.set(position2, tempField); - } - }); - - private int getNextFieldOffset() { - SparseArray instanceFields = getInstanceFields(); - if (instanceFields.size() == 0) { - return 8; - } - - int lastItemIndex = instanceFields.size()-1; - int fieldOffset = instanceFields.keyAt(lastItemIndex); - FieldReference lastField = instanceFields.valueAt(lastItemIndex); - - switch (lastField.getType().charAt(0)) { - case 'J': - case 'D': - return fieldOffset + 8; - default: - return fieldOffset + 4; - } - } - - @Nonnull List getVtable() { - return vtableSupplier.get(); - } - - //TODO: check the case when we have a package private method that overrides an interface method - @Nonnull private final Supplier> vtableSupplier = Suppliers.memoize(new Supplier>() { - @Override public List get() { - List vtable = Lists.newArrayList(); - - //copy the virtual methods from the superclass - String superclassType; - try { - superclassType = getSuperclass(); - } catch (UnresolvedClassException ex) { - vtable.addAll(((ClassProto)classPath.getClass("Ljava/lang/Object;")).getVtable()); - vtableFullyResolved = false; - return vtable; - } - - if (superclassType != null) { - ClassProto superclass = (ClassProto) classPath.getClass(superclassType); - vtable.addAll(superclass.getVtable()); - - // if the superclass's vtable wasn't fully resolved, then we can't know where the new methods added by this - // class should start, so we just propagate what we can from the parent and hope for the best. - if (!superclass.vtableFullyResolved) { - vtableFullyResolved = false; - return vtable; - } - } - - //iterate over the virtual methods in the current class, and only add them when we don't already have the - //method (i.e. if it was implemented by the superclass) - if (!isInterface()) { - addToVtable(getClassDef().getVirtualMethods(), vtable, true); - - // assume that interface method is implemented in the current class, when adding it to vtable - // otherwise it looks like that method is invoked on an interface, which fails Dalvik's optimization checks - for (ClassDef interfaceDef: getDirectInterfaces()) { - List interfaceMethods = Lists.newArrayList(); - for (Method interfaceMethod: interfaceDef.getVirtualMethods()) { - ImmutableMethod method = new ImmutableMethod( - type, - interfaceMethod.getName(), - interfaceMethod.getParameters(), - interfaceMethod.getReturnType(), - interfaceMethod.getAccessFlags(), - interfaceMethod.getAnnotations(), - interfaceMethod.getImplementation()); - interfaceMethods.add(method); - } - addToVtable(interfaceMethods, vtable, false); - } - } - return vtable; - } - - private void addToVtable(@Nonnull Iterable localMethods, - @Nonnull List vtable, boolean replaceExisting) { - List methods = Lists.newArrayList(localMethods); - Collections.sort(methods); - - outer: for (Method virtualMethod: methods) { - for (int i=0; i lines = new ArrayList(); - - BufferedReader br = new BufferedReader(reader); - - try { - String line = br.readLine(); - - while (line != null) { - if (line.length() > 0) { - lines.add(line); - } - - line = br.readLine(); - } - } catch (IOException ex) { - throw new RuntimeException("Error while parsing inline table", ex); - } - - inlineMethods = new Method[lines.size()]; - - for (int i=0; i= inlineMethods.length) { - throw new RuntimeException("Invalid method index: " + methodIndex); - } - return inlineMethods[methodIndex]; - } - - private static final Pattern longMethodPattern = Pattern.compile("(L[^;]+;)->([^(]+)\\(([^)]*)\\)(.+)"); - - @Nonnull - private Method parseAndResolveInlineMethod(@Nonnull String inlineMethod) { - Matcher m = longMethodPattern.matcher(inlineMethod); - if (!m.matches()) { - assert false; - throw new RuntimeException("Invalid method descriptor: " + inlineMethod); - } - - String className = m.group(1); - String methodName = m.group(2); - Iterable methodParams = ParamUtil.parseParamString(m.group(3)); - String methodRet = m.group(4); - ImmutableMethodReference methodRef = new ImmutableMethodReference(className, methodName, methodParams, - methodRet); - - int accessFlags = 0; - - boolean resolved = false; - TypeProto typeProto = classPath.getClass(className); - if (typeProto instanceof ClassProto) { - ClassDef classDef = ((ClassProto)typeProto).getClassDef(); - for (Method method: classDef.getMethods()) { - if (method.equals(methodRef)) { - resolved = true; - accessFlags = method.getAccessFlags(); - break; - } - } - } - - if (!resolved) { - throw new RuntimeException("Cannot resolve inline method: " + inlineMethod); - } - - return new ImmutableMethod(className, methodName, methodParams, methodRet, accessFlags, null, null); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/DumpFields.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/DumpFields.java deleted file mode 100644 index 2bb3e492..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/DumpFields.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; -import org.apache.commons.cli.*; -import org.jf.dexlib2.DexFileFactory; -import org.jf.dexlib2.dexbacked.DexBackedDexFile; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.dexlib2.iface.Field; -import org.jf.dexlib2.iface.Method; -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.util.ConsoleUtil; -import org.jf.util.SparseArray; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; - -public class DumpFields { - private static final Options options; - - static { - options = new Options(); - buildOptions(); - } - - public static void main(String[] args) { - CommandLineParser parser = new PosixParser(); - CommandLine commandLine; - - try { - commandLine = parser.parse(options, args); - } catch (ParseException ex) { - usage(); - return; - } - - String[] remainingArgs = commandLine.getArgs(); - - Option[] parsedOptions = commandLine.getOptions(); - ArrayList bootClassPathDirs = Lists.newArrayList(); - String outFile = "fields.txt"; - int apiLevel = 15; - boolean experimental = false; - - for (int i=0; i bootClassPaths = Splitter.on(":").split("core.jar:ext.jar:framework.jar:android.policy.jar:services.jar"); - ClassPath classPath = ClassPath.fromClassPath(bootClassPathDirs, bootClassPaths, dexFile, apiLevel, experimental); - FileOutputStream outStream = new FileOutputStream(outFile); - - for (ClassDef classDef: dexFile.getClasses()) { - ClassProto classProto = (ClassProto) classPath.getClass(classDef); - SparseArray fields = classProto.getInstanceFields(); - String className = "Class " + classDef.getType() + " : " + fields.size() + " instance fields\n"; - outStream.write(className.getBytes()); - for (int i=0;i"); - } - - private static void buildOptions() { - Option classPathDirOption = OptionBuilder.withLongOpt("bootclasspath-dir") - .withDescription("the base folder to look for the bootclasspath files in. Defaults to the current " + - "directory") - .hasArg() - .withArgName("DIR") - .create("d"); - - Option outputFileOption = OptionBuilder.withLongOpt("out-file") - .withDescription("output file") - .hasArg() - .withArgName("FILE") - .create("o"); - - Option apiLevelOption = OptionBuilder.withLongOpt("api-level") - .withDescription("The numeric api-level of the file being disassembled. If not " + - "specified, it defaults to 15 (ICS).") - .hasArg() - .withArgName("API_LEVEL") - .create("a"); - - Option experimentalOption = OptionBuilder.withLongOpt("experimental") - .withDescription("Enable dumping experimental opcodes, that aren't necessarily " + - "supported by the android runtime yet.") - .create("X"); - - options.addOption(classPathDirOption); - options.addOption(outputFileOption); - options.addOption(apiLevelOption); - options.addOption(experimentalOption); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/DumpVtables.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/DumpVtables.java deleted file mode 100644 index 193c0d39..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/DumpVtables.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; -import org.apache.commons.cli.*; -import org.jf.dexlib2.DexFileFactory; -import org.jf.dexlib2.dexbacked.DexBackedDexFile; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.dexlib2.iface.Method; -import org.jf.util.ConsoleUtil; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class DumpVtables { - private static final Options options; - - static { - options = new Options(); - buildOptions(); - } - - public static void main(String[] args) { - CommandLineParser parser = new PosixParser(); - CommandLine commandLine; - - try { - commandLine = parser.parse(options, args); - } catch (ParseException ex) { - usage(); - return; - } - - String[] remainingArgs = commandLine.getArgs(); - - Option[] parsedOptions = commandLine.getOptions(); - ArrayList bootClassPathDirs = Lists.newArrayList(); - String outFile = "vtables.txt"; - int apiLevel = 15; - boolean experimental = false; - - for (int i=0; i bootClassPaths = Splitter.on(":").split("core.jar:ext.jar:framework.jar:android.policy.jar:services.jar"); - ClassPath classPath = ClassPath.fromClassPath(bootClassPathDirs, bootClassPaths, dexFile, apiLevel, experimental); - FileOutputStream outStream = new FileOutputStream(outFile); - - for (ClassDef classDef: dexFile.getClasses()) { - ClassProto classProto = (ClassProto) classPath.getClass(classDef); - List methods = classProto.getVtable(); - String className = "Class " + classDef.getType() + " extends " + classDef.getSuperclass() + " : " + methods.size() + " methods\n"; - outStream.write(className.getBytes()); - for (int i=0;i" + method.getName() + "("; - for (CharSequence parameter: method.getParameterTypes()) { - methodString += parameter; - } - methodString += ")" + method.getReturnType() + "\n"; - outStream.write(methodString.getBytes()); - } - outStream.write("\n".getBytes()); - } - outStream.close(); - } catch (IOException ex) { - System.out.println("IOException thrown when trying to open a dex file or write out vtables: " + ex); - } - - } - - /** - * Prints the usage message. - */ - private static void usage() { - int consoleWidth = ConsoleUtil.getConsoleWidth(); - if (consoleWidth <= 0) { - consoleWidth = 80; - } - - System.out.println("java -cp baksmali.jar org.jf.dexlib2.analysis.DumpVtables -d path/to/framework/jar/files "); - } - - private static void buildOptions() { - Option classPathDirOption = OptionBuilder.withLongOpt("bootclasspath-dir") - .withDescription("the base folder to look for the bootclasspath files in. Defaults to the current " + - "directory") - .hasArg() - .withArgName("DIR") - .create("d"); - - Option outputFileOption = OptionBuilder.withLongOpt("out-file") - .withDescription("output file") - .hasArg() - .withArgName("FILE") - .create("o"); - - Option apiLevelOption = OptionBuilder.withLongOpt("api-level") - .withDescription("The numeric api-level of the file being disassembled. If not " + - "specified, it defaults to 15 (ICS).") - .hasArg() - .withArgName("API_LEVEL") - .create("a"); - - Option experimentalOption = OptionBuilder.withLongOpt("experimental") - .withDescription("Enable dumping experimental opcodes, that aren't necessarily " + - "supported by the android runtime yet.") - .create("X"); - - options.addOption(classPathDirOption); - options.addOption(outputFileOption); - options.addOption(apiLevelOption); - options.addOption(experimentalOption); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/InlineMethodResolver.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/InlineMethodResolver.java deleted file mode 100644 index 4b2e7e64..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/InlineMethodResolver.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import com.google.common.collect.ImmutableList; -import org.jf.dexlib2.iface.Method; -import org.jf.dexlib2.iface.instruction.InlineIndexInstruction; -import org.jf.dexlib2.iface.instruction.VariableRegisterInstruction; -import org.jf.dexlib2.immutable.ImmutableMethod; -import org.jf.dexlib2.immutable.ImmutableMethodParameter; -import org.jf.dexlib2.immutable.util.ParamUtil; - -import javax.annotation.Nonnull; - -public abstract class InlineMethodResolver { - // These are the possible values for the accessFlag field on a resolved inline method - // We can't use, e.g. AccessFlags.STATIC.value, because we need them to be a constant in order to use them as cases - // in switch statements - public static final int STATIC = 0x8; // AccessFlags.STATIC.value; - public static final int VIRTUAL = 0x1; // AccessFlags.PUBLIC.value; - public static final int DIRECT = 0x2; // AccessFlags.PRIVATE.value; - - @Nonnull - public static InlineMethodResolver createInlineMethodResolver(int odexVersion) { - if (odexVersion == 35) { - return new InlineMethodResolver_version35(); - } else if (odexVersion == 36) { - return new InlineMethodResolver_version36(); - } else { - throw new RuntimeException(String.format("odex version %d is not supported yet", odexVersion)); - } - } - - protected InlineMethodResolver() { - } - - @Nonnull - private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name, - @Nonnull String params, @Nonnull String returnType) { - ImmutableList paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params)); - return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null); - } - - @Nonnull public abstract Method resolveExecuteInline(@Nonnull AnalyzedInstruction instruction); - - private static class InlineMethodResolver_version35 extends InlineMethodResolver - { - private final Method[] inlineMethods; - - public InlineMethodResolver_version35() { - inlineMethods = new Method[] { - inlineMethod(STATIC, "Lorg/apache/harmony/dalvik/NativeTestTarget;", "emptyInlineMethod", "", "V"), - inlineMethod(VIRTUAL, "Ljava/lang/String;", "charAt", "I", "C"), - inlineMethod(VIRTUAL, "Ljava/lang/String;", "compareTo", "Ljava/lang/String;", "I"), - inlineMethod(VIRTUAL, "Ljava/lang/String;", "equals", "Ljava/lang/Object;", "Z"), - inlineMethod(VIRTUAL, "Ljava/lang/String;", "length", "", "I"), - inlineMethod(STATIC, "Ljava/lang/Math;", "abs", "I", "I"), - inlineMethod(STATIC, "Ljava/lang/Math;", "abs", "J", "J"), - inlineMethod(STATIC, "Ljava/lang/Math;", "abs", "F", "F"), - inlineMethod(STATIC, "Ljava/lang/Math;", "abs", "D", "D"), - inlineMethod(STATIC, "Ljava/lang/Math;", "min", "II", "I"), - inlineMethod(STATIC, "Ljava/lang/Math;", "max", "II", "I"), - inlineMethod(STATIC, "Ljava/lang/Math;", "sqrt", "D", "D"), - inlineMethod(STATIC, "Ljava/lang/Math;", "cos", "D", "D"), - inlineMethod(STATIC, "Ljava/lang/Math;", "sin", "D", "D") - }; - } - - @Override - @Nonnull - public Method resolveExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) { - InlineIndexInstruction instruction = (InlineIndexInstruction)analyzedInstruction.instruction; - int inlineIndex = instruction.getInlineIndex(); - - if (inlineIndex < 0 || inlineIndex >= inlineMethods.length) { - throw new RuntimeException("Invalid inline index: " + inlineIndex); - } - return inlineMethods[inlineIndex]; - } - } - - private static class InlineMethodResolver_version36 extends InlineMethodResolver - { - private final Method[] inlineMethods; - private final Method indexOfIMethod; - private final Method indexOfIIMethod; - private final Method fastIndexOfMethod; - private final Method isEmptyMethod; - - public InlineMethodResolver_version36() { - //The 5th and 6th entries differ between froyo and gingerbread. We have to look at the parameters being - //passed to distinguish between them. - - //froyo - indexOfIMethod = inlineMethod(VIRTUAL, "Ljava/lang/String;", "indexOf", "I", "I"); - indexOfIIMethod = inlineMethod(VIRTUAL, "Ljava/lang/String;", "indexOf", "II", "I"); - - //gingerbread - fastIndexOfMethod = inlineMethod(DIRECT, "Ljava/lang/String;", "fastIndexOf", "II", "I"); - isEmptyMethod = inlineMethod(VIRTUAL, "Ljava/lang/String;", "isEmpty", "", "Z"); - - inlineMethods = new Method[] { - inlineMethod(STATIC, "Lorg/apache/harmony/dalvik/NativeTestTarget;", "emptyInlineMethod", "", "V"), - inlineMethod(VIRTUAL, "Ljava/lang/String;", "charAt", "I", "C"), - inlineMethod(VIRTUAL, "Ljava/lang/String;", "compareTo", "Ljava/lang/String;", "I"), - inlineMethod(VIRTUAL, "Ljava/lang/String;", "equals", "Ljava/lang/Object;", "Z"), - //froyo: deodexUtil.new InlineMethod(VIRTUAL, "Ljava/lang/String;", "indexOf", "I", "I"), - //gingerbread: deodexUtil.new InlineMethod(VIRTUAL, "Ljava/lang/String;", "fastIndexOf", "II", "I"), - null, - //froyo: deodexUtil.new InlineMethod(VIRTUAL, "Ljava/lang/String;", "indexOf", "II", "I"), - //gingerbread: deodexUtil.new InlineMethod(VIRTUAL, "Ljava/lang/String;", "isEmpty", "", "Z"), - null, - inlineMethod(VIRTUAL, "Ljava/lang/String;", "length", "", "I"), - inlineMethod(STATIC, "Ljava/lang/Math;", "abs", "I", "I"), - inlineMethod(STATIC, "Ljava/lang/Math;", "abs", "J", "J"), - inlineMethod(STATIC, "Ljava/lang/Math;", "abs", "F", "F"), - inlineMethod(STATIC, "Ljava/lang/Math;", "abs", "D", "D"), - inlineMethod(STATIC, "Ljava/lang/Math;", "min", "II", "I"), - inlineMethod(STATIC, "Ljava/lang/Math;", "max", "II", "I"), - inlineMethod(STATIC, "Ljava/lang/Math;", "sqrt", "D", "D"), - inlineMethod(STATIC, "Ljava/lang/Math;", "cos", "D", "D"), - inlineMethod(STATIC, "Ljava/lang/Math;", "sin", "D", "D"), - inlineMethod(STATIC, "Ljava/lang/Float;", "floatToIntBits", "F", "I"), - inlineMethod(STATIC, "Ljava/lang/Float;", "floatToRawIntBits", "F", "I"), - inlineMethod(STATIC, "Ljava/lang/Float;", "intBitsToFloat", "I", "F"), - inlineMethod(STATIC, "Ljava/lang/Double;", "doubleToLongBits", "D", "J"), - inlineMethod(STATIC, "Ljava/lang/Double;", "doubleToRawLongBits", "D", "J"), - inlineMethod(STATIC, "Ljava/lang/Double;", "longBitsToDouble", "J", "D"), - inlineMethod(STATIC, "Ljava/lang/StrictMath;", "abs", "I", "I"), - inlineMethod(STATIC, "Ljava/lang/StrictMath;", "abs", "J", "J"), - inlineMethod(STATIC, "Ljava/lang/StrictMath;", "abs", "F", "F"), - inlineMethod(STATIC, "Ljava/lang/StrictMath;", "abs", "D", "D"), - inlineMethod(STATIC, "Ljava/lang/StrictMath;", "min", "II", "I"), - inlineMethod(STATIC, "Ljava/lang/StrictMath;", "max", "II", "I"), - inlineMethod(STATIC, "Ljava/lang/StrictMath;", "sqrt", "D", "D"), - }; - } - - @Override - @Nonnull - public Method resolveExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) { - InlineIndexInstruction instruction = (InlineIndexInstruction)analyzedInstruction.instruction; - int inlineIndex = instruction.getInlineIndex(); - - if (inlineIndex < 0 || inlineIndex >= inlineMethods.length) { - throw new RuntimeException("Invalid method index: " + inlineIndex); - } - - if (inlineIndex == 4) { - int parameterCount = ((VariableRegisterInstruction)instruction).getRegisterCount(); - if (parameterCount == 2) { - return indexOfIMethod; - } else if (parameterCount == 3) { - return fastIndexOfMethod; - } else { - throw new RuntimeException("Could not determine the correct inline method to use"); - } - } else if (inlineIndex == 5) { - int parameterCount = ((VariableRegisterInstruction)instruction).getRegisterCount(); - if (parameterCount == 3) { - return indexOfIIMethod; - } else if (parameterCount == 1) { - return isEmptyMethod; - } else { - throw new RuntimeException("Could not determine the correct inline method to use"); - } - } - - return inlineMethods[inlineIndex]; - } - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/MethodAnalyzer.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/MethodAnalyzer.java deleted file mode 100644 index e14fdc31..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/MethodAnalyzer.java +++ /dev/null @@ -1,1776 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import org.jf.dexlib2.AccessFlags; -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.iface.*; -import org.jf.dexlib2.iface.instruction.*; -import org.jf.dexlib2.iface.instruction.formats.*; -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.iface.reference.MethodReference; -import org.jf.dexlib2.iface.reference.Reference; -import org.jf.dexlib2.iface.reference.TypeReference; -import org.jf.dexlib2.immutable.instruction.*; -import org.jf.dexlib2.immutable.reference.ImmutableFieldReference; -import org.jf.dexlib2.immutable.reference.ImmutableMethodReference; -import org.jf.dexlib2.util.MethodUtil; -import org.jf.dexlib2.util.ReferenceUtil; -import org.jf.dexlib2.util.TypeUtils; -import org.jf.util.BitSetUtils; -import org.jf.util.ExceptionWithContext; -import org.jf.util.SparseArray; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.BitSet; -import java.util.List; - -/** - * The MethodAnalyzer performs several functions. It "analyzes" the instructions and infers the register types - * for each register, it can deodex odexed instructions, and it can verify the bytecode. The analysis and verification - * are done in two separate passes, because the analysis has to process instructions multiple times in some cases, and - * there's no need to perform the verification multiple times, so we wait until the method is fully analyzed and then - * verify it. - * - * Before calling the analyze() method, you must have initialized the ClassPath by calling - * ClassPath.InitializeClassPath - */ -public class MethodAnalyzer { - @Nonnull private final Method method; - @Nonnull private final MethodImplementation methodImpl; - - private final int paramRegisterCount; - - @Nonnull private final ClassPath classPath; - @Nullable private final InlineMethodResolver inlineResolver; - - // This contains all the AnalyzedInstruction instances, keyed by the code unit address of the instruction - @Nonnull private final SparseArray analyzedInstructions = - new SparseArray(0); - - // Which instructions have been analyzed, keyed by instruction index - @Nonnull private final BitSet analyzedState; - - @Nullable private AnalysisException analysisException = null; - - //This is a dummy instruction that occurs immediately before the first real instruction. We can initialize the - //register types for this instruction to the parameter types, in order to have them propagate to all of its - //successors, e.g. the first real instruction, the first instructions in any exception handlers covering the first - //instruction, etc. - private final AnalyzedInstruction startOfMethod; - - public MethodAnalyzer(@Nonnull ClassPath classPath, @Nonnull Method method, - @Nullable InlineMethodResolver inlineResolver) { - this.classPath = classPath; - this.inlineResolver = inlineResolver; - - this.method = method; - - MethodImplementation methodImpl = method.getImplementation(); - if (methodImpl == null) { - throw new IllegalArgumentException("The method has no implementation"); - } - - this.methodImpl = methodImpl; - - //override AnalyzedInstruction and provide custom implementations of some of the methods, so that we don't - //have to handle the case this special case of instruction being null, in the main class - startOfMethod = new AnalyzedInstruction(null, -1, methodImpl.getRegisterCount()) { - public boolean setsRegister() { - return false; - } - - @Override - public boolean setsWideRegister() { - return false; - } - - @Override - public boolean setsRegister(int registerNumber) { - return false; - } - - @Override - public int getDestinationRegister() { - assert false; - return -1; - } - }; - - buildInstructionList(); - - analyzedState = new BitSet(analyzedInstructions.size()); - paramRegisterCount = MethodUtil.getParameterRegisterCount(method); - analyze(); - } - - private void analyze() { - Method method = this.method; - MethodImplementation methodImpl = this.methodImpl; - - int totalRegisters = methodImpl.getRegisterCount(); - int parameterRegisters = paramRegisterCount; - - int nonParameterRegisters = totalRegisters - parameterRegisters; - - //if this isn't a static method, determine which register is the "this" register and set the type to the - //current class - if (!MethodUtil.isStatic(method)) { - int thisRegister = totalRegisters - parameterRegisters; - - //if this is a constructor, then set the "this" register to an uninitialized reference of the current class - if (MethodUtil.isConstructor(method)) { - setPostRegisterTypeAndPropagateChanges(startOfMethod, thisRegister, - RegisterType.getRegisterType(RegisterType.UNINIT_THIS, - classPath.getClass(method.getDefiningClass()))); - } else { - setPostRegisterTypeAndPropagateChanges(startOfMethod, thisRegister, - RegisterType.getRegisterType(RegisterType.REFERENCE, - classPath.getClass(method.getDefiningClass()))); - } - - propagateParameterTypes(totalRegisters-parameterRegisters+1); - } else { - propagateParameterTypes(totalRegisters-parameterRegisters); - } - - RegisterType uninit = RegisterType.getRegisterType(RegisterType.UNINIT, null); - for (int i=0; i=0; i=instructionsToAnalyze.nextSetBit(i+1)) { - instructionsToAnalyze.clear(i); - if (analyzedState.get(i)) { - continue; - } - AnalyzedInstruction instructionToAnalyze = analyzedInstructions.valueAt(i); - try { - if (instructionToAnalyze.originalInstruction.getOpcode().odexOnly()) { - //if we had deodexed an odex instruction in a previous pass, we might have more specific - //register information now, so let's restore the original odexed instruction and - //re-deodex it - instructionToAnalyze.restoreOdexedInstruction(); - } - - if (!analyzeInstruction(instructionToAnalyze)) { - undeodexedInstructions.set(i); - continue; - } else { - didSomething = true; - undeodexedInstructions.clear(i); - } - } catch (AnalysisException ex) { - this.analysisException = ex; - int codeAddress = getInstructionAddress(instructionToAnalyze); - ex.codeAddress = codeAddress; - ex.addContext(String.format("opcode: %s", instructionToAnalyze.instruction.getOpcode().name)); - ex.addContext(String.format("code address: %d", codeAddress)); - ex.addContext(String.format("method: %s", ReferenceUtil.getReferenceString(method))); - break; - } - - analyzedState.set(instructionToAnalyze.getInstructionIndex()); - - for (AnalyzedInstruction successor: instructionToAnalyze.successors) { - instructionsToAnalyze.set(successor.getInstructionIndex()); - } - } - if (analysisException != null) { - break; - } - } - - if (!didSomething) { - break; - } - - if (!undeodexedInstructions.isEmpty()) { - for (int i=undeodexedInstructions.nextSetBit(0); i>=0; i=undeodexedInstructions.nextSetBit(i+1)) { - instructionsToAnalyze.set(i); - } - } - } while (true); - - //Now, go through and fix up any unresolvable odex instructions. These are usually odex instructions - //that operate on a null register, and thus always throw an NPE. They can also be any sort of odex instruction - //that occurs after an unresolvable odex instruction. We deodex if possible, or replace with an - //UnresolvableOdexInstruction - for (int i=0; i< analyzedInstructions.size(); i++) { - AnalyzedInstruction analyzedInstruction = analyzedInstructions.valueAt(i); - - Instruction instruction = analyzedInstruction.getInstruction(); - - if (instruction.getOpcode().odexOnly()) { - int objectRegisterNumber; - switch (instruction.getOpcode().format) { - case Format10x: - analyzeReturnVoidBarrier(analyzedInstruction, false); - continue; - case Format21c: - case Format22c: - analyzePutGetVolatile(analyzedInstruction, false); - continue; - case Format35c: - analyzeInvokeDirectEmpty(analyzedInstruction, false); - continue; - case Format3rc: - analyzeInvokeObjectInitRange(analyzedInstruction, false); - continue; - case Format22cs: - objectRegisterNumber = ((Instruction22cs)instruction).getRegisterB(); - break; - case Format35mi: - case Format35ms: - objectRegisterNumber = ((FiveRegisterInstruction)instruction).getRegisterC(); - break; - case Format3rmi: - case Format3rms: - objectRegisterNumber = ((RegisterRangeInstruction)instruction).getStartRegister(); - break; - default: - continue; - } - - analyzedInstruction.setDeodexedInstruction( - new UnresolvedOdexInstruction(instruction, objectRegisterNumber)); - } - } - } - - private void propagateParameterTypes(int parameterStartRegister) { - int i=0; - for (MethodParameter parameter: method.getParameters()) { - if (TypeUtils.isWideType(parameter)) { - setPostRegisterTypeAndPropagateChanges(startOfMethod, parameterStartRegister + i++, - RegisterType.getWideRegisterType(parameter, true)); - setPostRegisterTypeAndPropagateChanges(startOfMethod, parameterStartRegister + i++, - RegisterType.getWideRegisterType(parameter, false)); - } else { - setPostRegisterTypeAndPropagateChanges(startOfMethod, parameterStartRegister + i++, - RegisterType.getRegisterType(classPath, parameter)); - } - } - } - - public List getAnalyzedInstructions() { - return analyzedInstructions.getValues(); - } - - public List getInstructions() { - return Lists.transform(analyzedInstructions.getValues(), new Function() { - @Nullable @Override public Instruction apply(@Nullable AnalyzedInstruction input) { - if (input == null) { - return null; - } - return input.instruction; - } - }); - } - - @Nullable - public AnalysisException getAnalysisException() { - return analysisException; - } - - public int getParamRegisterCount() { - return paramRegisterCount; - } - - public int getInstructionAddress(@Nonnull AnalyzedInstruction instruction) { - return analyzedInstructions.keyAt(instruction.instructionIndex); - } - - private void setDestinationRegisterTypeAndPropagateChanges(@Nonnull AnalyzedInstruction analyzedInstruction, - @Nonnull RegisterType registerType) { - setPostRegisterTypeAndPropagateChanges(analyzedInstruction, analyzedInstruction.getDestinationRegister(), - registerType); - } - - private void setPostRegisterTypeAndPropagateChanges(@Nonnull AnalyzedInstruction analyzedInstruction, - int registerNumber, @Nonnull RegisterType registerType) { - - BitSet changedInstructions = new BitSet(analyzedInstructions.size()); - - if (!analyzedInstruction.setPostRegisterType(registerNumber, registerType)) { - return; - } - - propagateRegisterToSuccessors(analyzedInstruction, registerNumber, changedInstructions); - - //Using a for loop inside the while loop optimizes for the common case of the successors of an instruction - //occurring after the instruction. Any successors that occur prior to the instruction will be picked up on - //the next iteration of the while loop. - //This could also be done recursively, but in large methods it would likely cause very deep recursion, - //which requires the user to specify a larger stack size. This isn't really a problem, but it is slightly - //annoying. - while (!changedInstructions.isEmpty()) { - for (int instructionIndex=changedInstructions.nextSetBit(0); - instructionIndex>=0; - instructionIndex=changedInstructions.nextSetBit(instructionIndex+1)) { - - changedInstructions.clear(instructionIndex); - - propagateRegisterToSuccessors(analyzedInstructions.valueAt(instructionIndex), registerNumber, - changedInstructions); - } - } - - if (registerType.category == RegisterType.LONG_LO) { - checkWidePair(registerNumber, analyzedInstruction); - setPostRegisterTypeAndPropagateChanges(analyzedInstruction, registerNumber+1, RegisterType.LONG_HI_TYPE); - } else if (registerType.category == RegisterType.DOUBLE_LO) { - checkWidePair(registerNumber, analyzedInstruction); - setPostRegisterTypeAndPropagateChanges(analyzedInstruction, registerNumber+1, RegisterType.DOUBLE_HI_TYPE); - } - } - - private void propagateRegisterToSuccessors(@Nonnull AnalyzedInstruction instruction, int registerNumber, - @Nonnull BitSet changedInstructions) { - RegisterType postRegisterType = instruction.getPostInstructionRegisterType(registerNumber); - for (AnalyzedInstruction successor: instruction.successors) { - if (successor.mergeRegister(registerNumber, postRegisterType, analyzedState)) { - changedInstructions.set(successor.instructionIndex); - } - } - } - - private void buildInstructionList() { - int registerCount = methodImpl.getRegisterCount(); - - ImmutableList instructions = ImmutableList.copyOf(methodImpl.getInstructions()); - - analyzedInstructions.ensureCapacity(instructions.size()); - - //first, create all the instructions and populate the instructionAddresses array - int currentCodeAddress = 0; - for (int i=0; i> tries = methodImpl.getTryBlocks(); - int triesIndex = 0; - TryBlock currentTry = null; - AnalyzedInstruction[] currentExceptionHandlers = null; - AnalyzedInstruction[][] exceptionHandlers = new AnalyzedInstruction[instructions.size()][]; - - if (tries != null) { - for (int i=0; i< analyzedInstructions.size(); i++) { - AnalyzedInstruction instruction = analyzedInstructions.valueAt(i); - Opcode instructionOpcode = instruction.instruction.getOpcode(); - currentCodeAddress = getInstructionAddress(instruction); - - //check if we have gone past the end of the current try - if (currentTry != null) { - if (currentTry.getStartCodeAddress() + currentTry.getCodeUnitCount() <= currentCodeAddress) { - currentTry = null; - triesIndex++; - } - } - - //check if the next try is applicable yet - if (currentTry == null && triesIndex < tries.size()) { - TryBlock tryBlock = tries.get(triesIndex); - if (tryBlock.getStartCodeAddress() <= currentCodeAddress) { - assert(tryBlock.getStartCodeAddress() + tryBlock.getCodeUnitCount() > currentCodeAddress); - - currentTry = tryBlock; - - currentExceptionHandlers = buildExceptionHandlerArray(tryBlock); - } - } - - //if we're inside a try block, and the instruction can throw an exception, then add the exception handlers - //for the current instruction - if (currentTry != null && instructionOpcode.canThrow()) { - exceptionHandlers[i] = currentExceptionHandlers; - } - } - } - - //finally, populate the successors and predecessors for each instruction. We start at the fake "StartOfMethod" - //instruction and follow the execution path. Any unreachable code won't have any predecessors or successors, - //and no reachable code will have an unreachable predessor or successor - assert analyzedInstructions.size() > 0; - BitSet instructionsToProcess = new BitSet(instructions.size()); - - addPredecessorSuccessor(startOfMethod, analyzedInstructions.valueAt(0), exceptionHandlers, instructionsToProcess); - while (!instructionsToProcess.isEmpty()) { - int currentInstructionIndex = instructionsToProcess.nextSetBit(0); - instructionsToProcess.clear(currentInstructionIndex); - - AnalyzedInstruction instruction = analyzedInstructions.valueAt(currentInstructionIndex); - Opcode instructionOpcode = instruction.instruction.getOpcode(); - int instructionCodeAddress = getInstructionAddress(instruction); - - if (instruction.instruction.getOpcode().canContinue()) { - if (currentInstructionIndex == analyzedInstructions.size() - 1) { - throw new AnalysisException("Execution can continue past the last instruction"); - } - - AnalyzedInstruction nextInstruction = analyzedInstructions.valueAt(currentInstructionIndex+1); - addPredecessorSuccessor(instruction, nextInstruction, exceptionHandlers, instructionsToProcess); - } - - if (instruction.instruction instanceof OffsetInstruction) { - OffsetInstruction offsetInstruction = (OffsetInstruction)instruction.instruction; - - if (instructionOpcode == Opcode.PACKED_SWITCH || instructionOpcode == Opcode.SPARSE_SWITCH) { - SwitchPayload switchPayload = (SwitchPayload)analyzedInstructions.get(instructionCodeAddress + - offsetInstruction.getCodeOffset()).instruction; - for (SwitchElement switchElement: switchPayload.getSwitchElements()) { - AnalyzedInstruction targetInstruction = analyzedInstructions.get(instructionCodeAddress + - switchElement.getOffset()); - - addPredecessorSuccessor(instruction, targetInstruction, exceptionHandlers, - instructionsToProcess); - } - } else if (instructionOpcode != Opcode.FILL_ARRAY_DATA) { - int targetAddressOffset = offsetInstruction.getCodeOffset(); - AnalyzedInstruction targetInstruction = analyzedInstructions.get(instructionCodeAddress + - targetAddressOffset); - addPredecessorSuccessor(instruction, targetInstruction, exceptionHandlers, instructionsToProcess); - } - } - } - } - - private void addPredecessorSuccessor(@Nonnull AnalyzedInstruction predecessor, - @Nonnull AnalyzedInstruction successor, - @Nonnull AnalyzedInstruction[][] exceptionHandlers, - @Nonnull BitSet instructionsToProcess) { - addPredecessorSuccessor(predecessor, successor, exceptionHandlers, instructionsToProcess, false); - } - - private void addPredecessorSuccessor(@Nonnull AnalyzedInstruction predecessor, - @Nonnull AnalyzedInstruction successor, - @Nonnull AnalyzedInstruction[][] exceptionHandlers, - @Nonnull BitSet instructionsToProcess, boolean allowMoveException) { - - if (!allowMoveException && successor.instruction.getOpcode() == Opcode.MOVE_EXCEPTION) { - throw new AnalysisException("Execution can pass from the " + predecessor.instruction.getOpcode().name + - " instruction at code address 0x" + Integer.toHexString(getInstructionAddress(predecessor)) + - " to the move-exception instruction at address 0x" + - Integer.toHexString(getInstructionAddress(successor))); - } - - if (!successor.addPredecessor(predecessor)) { - return; - } - - predecessor.addSuccessor(successor); - instructionsToProcess.set(successor.getInstructionIndex()); - - - //if the successor can throw an instruction, then we need to add the exception handlers as additional - //successors to the predecessor (and then apply this same logic recursively if needed) - //Technically, we should handle the monitor-exit instruction as a special case. The exception is actually - //thrown *after* the instruction executes, instead of "before" the instruction executes, lke for any other - //instruction. But since it doesn't modify any registers, we can treat it like any other instruction. - AnalyzedInstruction[] exceptionHandlersForSuccessor = exceptionHandlers[successor.instructionIndex]; - if (exceptionHandlersForSuccessor != null) { - //the item for this instruction in exceptionHandlersForSuccessor should only be set if this instruction - //can throw an exception - assert successor.instruction.getOpcode().canThrow(); - - for (AnalyzedInstruction exceptionHandler: exceptionHandlersForSuccessor) { - addPredecessorSuccessor(predecessor, exceptionHandler, exceptionHandlers, instructionsToProcess, true); - } - } - } - - @Nonnull - private AnalyzedInstruction[] buildExceptionHandlerArray(@Nonnull TryBlock tryBlock) { - List exceptionHandlers = tryBlock.getExceptionHandlers(); - - AnalyzedInstruction[] handlerInstructions = new AnalyzedInstruction[exceptionHandlers.size()]; - for (int i=0; i tryBlock: methodImpl.getTryBlocks()) { - for (ExceptionHandler handler: tryBlock.getExceptionHandlers()) { - - if (handler.getHandlerCodeAddress() == instructionAddress) { - String type = handler.getExceptionType(); - if (type == null) { - exceptionType = RegisterType.getRegisterType(RegisterType.REFERENCE, - classPath.getClass("Ljava/lang/Throwable;")); - } else { - exceptionType = RegisterType.getRegisterType(RegisterType.REFERENCE, classPath.getClass(type)) - .merge(exceptionType); - } - } - } - } - - if (exceptionType.category == RegisterType.UNKNOWN) { - throw new AnalysisException("move-exception must be the first instruction in an exception handler block"); - } - - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, exceptionType); - } - - private void analyzeReturnVoidBarrier(AnalyzedInstruction analyzedInstruction) { - analyzeReturnVoidBarrier(analyzedInstruction, true); - } - - private void analyzeReturnVoidBarrier(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) { - Instruction10x deodexedInstruction = new ImmutableInstruction10x(Opcode.RETURN_VOID); - - analyzedInstruction.setDeodexedInstruction(deodexedInstruction); - - if (analyzeResult) { - analyzeInstruction(analyzedInstruction); - } - } - - private void analyzeConst(@Nonnull AnalyzedInstruction analyzedInstruction) { - NarrowLiteralInstruction instruction = (NarrowLiteralInstruction)analyzedInstruction.instruction; - - //we assume that the literal value is a valid value for the given instruction type, because it's impossible - //to store an invalid literal with the instruction. so we don't need to check the type of the literal - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, - RegisterType.getRegisterTypeForLiteral(instruction.getNarrowLiteral())); - } - - private void analyzeWideConst(@Nonnull AnalyzedInstruction analyzedInstruction) { - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, RegisterType.LONG_LO_TYPE); - } - - private void analyzeConstString(@Nonnull AnalyzedInstruction analyzedInstruction) { - TypeProto stringClass = classPath.getClass("Ljava/lang/String;"); - RegisterType stringType = RegisterType.getRegisterType(RegisterType.REFERENCE, stringClass); - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, stringType); - } - - private void analyzeConstClass(@Nonnull AnalyzedInstruction analyzedInstruction) { - TypeProto classClass = classPath.getClass("Ljava/lang/Class;"); - RegisterType classType = RegisterType.getRegisterType(RegisterType.REFERENCE, classClass); - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, classType); - } - - private void analyzeCheckCast(@Nonnull AnalyzedInstruction analyzedInstruction) { - ReferenceInstruction instruction = (ReferenceInstruction)analyzedInstruction.instruction; - TypeReference reference = (TypeReference)instruction.getReference(); - RegisterType castRegisterType = RegisterType.getRegisterType(classPath, reference); - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, castRegisterType); - } - - private void analyzeInstanceOf(@Nonnull AnalyzedInstruction analyzedInstruction) { - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, RegisterType.BOOLEAN_TYPE); - } - - private void analyzeArrayLength(@Nonnull AnalyzedInstruction analyzedInstruction) { - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, RegisterType.INTEGER_TYPE); - } - - private void analyzeNewInstance(@Nonnull AnalyzedInstruction analyzedInstruction) { - ReferenceInstruction instruction = (ReferenceInstruction)analyzedInstruction.instruction; - - int register = ((OneRegisterInstruction)analyzedInstruction.instruction).getRegisterA(); - RegisterType destRegisterType = analyzedInstruction.getPostInstructionRegisterType(register); - if (destRegisterType.category != RegisterType.UNKNOWN) { - //the post-instruction destination register will only be set if we have already analyzed this instruction - //at least once. If this is the case, then the uninit reference has already been propagated to all - //successors and nothing else needs to be done. - assert destRegisterType.category == RegisterType.UNINIT_REF; - return; - } - - TypeReference typeReference = (TypeReference)instruction.getReference(); - - RegisterType classType = RegisterType.getRegisterType(classPath, typeReference); - - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, - RegisterType.getRegisterType(RegisterType.UNINIT_REF, classType.type)); - } - - private void analyzeNewArray(@Nonnull AnalyzedInstruction analyzedInstruction) { - ReferenceInstruction instruction = (ReferenceInstruction)analyzedInstruction.instruction; - - TypeReference type = (TypeReference)instruction.getReference(); - if (type.getType().charAt(0) != '[') { - throw new AnalysisException("new-array used with non-array type"); - } - - RegisterType arrayType = RegisterType.getRegisterType(classPath, type); - - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, arrayType); - } - - private void analyzeFloatWideCmp(@Nonnull AnalyzedInstruction analyzedInstruction) { - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, RegisterType.BYTE_TYPE); - } - - private void analyze32BitPrimitiveAget(@Nonnull AnalyzedInstruction analyzedInstruction, - @Nonnull RegisterType registerType) { - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, registerType); - } - - private void analyzeAgetWide(@Nonnull AnalyzedInstruction analyzedInstruction) { - ThreeRegisterInstruction instruction = (ThreeRegisterInstruction)analyzedInstruction.instruction; - - RegisterType arrayRegisterType = analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterB()); - if (! ClassPath.dontLoadClassPath && arrayRegisterType.category != RegisterType.NULL) { - if (arrayRegisterType.category != RegisterType.REFERENCE || - !(arrayRegisterType.type instanceof ArrayProto)) { - throw new AnalysisException("aget-wide used with non-array register: %s", arrayRegisterType.toString()); - } - ArrayProto arrayProto = (ArrayProto)arrayRegisterType.type; - - if (arrayProto.dimensions != 1) { - throw new AnalysisException("aget-wide used with multi-dimensional array: %s", - arrayRegisterType.toString()); - } - - char arrayBaseType = arrayProto.getElementType().charAt(0); - if (arrayBaseType == 'J') { - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, RegisterType.LONG_LO_TYPE); - } else if (arrayBaseType == 'D') { - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, RegisterType.DOUBLE_LO_TYPE); - } else { - throw new AnalysisException("aget-wide used with narrow array: %s", arrayRegisterType); - } - } else { - // If the array register is null, we can assume that the destination register was meant to be a wide type. - // This is the same behavior as dalvik's verifier - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, RegisterType.LONG_LO_TYPE); - } - } - - private void analyzeAgetObject(@Nonnull AnalyzedInstruction analyzedInstruction) { - ThreeRegisterInstruction instruction = (ThreeRegisterInstruction)analyzedInstruction.instruction; - - RegisterType arrayRegisterType = analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterB()); - if (! ClassPath.dontLoadClassPath && arrayRegisterType.category != RegisterType.NULL) { - if (arrayRegisterType.category != RegisterType.REFERENCE || - !(arrayRegisterType.type instanceof ArrayProto)) { - throw new AnalysisException("aget-object used with non-array register: %s", - arrayRegisterType.toString()); - } - - ArrayProto arrayProto = (ArrayProto)arrayRegisterType.type; - - String elementType = arrayProto.getImmediateElementType(); - - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, - RegisterType.getRegisterType(RegisterType.REFERENCE, classPath.getClass(elementType))); - } else { - // If the array register is null, we can assume that the destination register was meant to be a reference - // type, so we set the destination to NULL. This is the same behavior as dalvik's verifier - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, RegisterType.NULL_TYPE); - } - } - - private void analyze32BitPrimitiveIgetSget(@Nonnull AnalyzedInstruction analyzedInstruction, - @Nonnull RegisterType registerType) { - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, registerType); - } - - private void analyzeIgetSgetWideObject(@Nonnull AnalyzedInstruction analyzedInstruction) { - ReferenceInstruction referenceInstruction = (ReferenceInstruction)analyzedInstruction.instruction; - - FieldReference fieldReference = (FieldReference)referenceInstruction.getReference(); - - RegisterType fieldType = RegisterType.getRegisterType(classPath, fieldReference.getType()); - setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, fieldType); - } - - private void analyzeInvokeDirect(@Nonnull AnalyzedInstruction analyzedInstruction) { - FiveRegisterInstruction instruction = (FiveRegisterInstruction)analyzedInstruction.instruction; - analyzeInvokeDirectCommon(analyzedInstruction, instruction.getRegisterC()); - } - - private void analyzeInvokeDirectRange(@Nonnull AnalyzedInstruction analyzedInstruction) { - RegisterRangeInstruction instruction = (RegisterRangeInstruction)analyzedInstruction.instruction; - analyzeInvokeDirectCommon(analyzedInstruction, instruction.getStartRegister()); - } - - private void analyzeInvokeDirectCommon(@Nonnull AnalyzedInstruction analyzedInstruction, int objectRegister) { - //the only time that an invoke instruction changes a register type is when using invoke-direct on a - //constructor () method, which changes the uninitialized reference (and any register that the same - //uninit reference has been copied to) to an initialized reference - - ReferenceInstruction instruction = (ReferenceInstruction)analyzedInstruction.instruction; - - MethodReference methodReference = (MethodReference)instruction.getReference(); - - if (!methodReference.getName().equals("")) { - return; - } - - RegisterType objectRegisterType = analyzedInstruction.getPreInstructionRegisterType(objectRegister); - - if (objectRegisterType.category != RegisterType.UNINIT_REF && - objectRegisterType.category != RegisterType.UNINIT_THIS) { - return; - } - - setPostRegisterTypeAndPropagateChanges(analyzedInstruction, objectRegister, - RegisterType.getRegisterType(RegisterType.REFERENCE, objectRegisterType.type)); - - for (int i=0; i 24) { - return RegisterType.POS_BYTE_TYPE; - } - if (literalShift >= 16) { - return RegisterType.CHAR_TYPE; - } - } else { - if (literalShift >= 24) { - return RegisterType.BYTE_TYPE; - } - if (literalShift >= 16) { - return RegisterType.SHORT_TYPE; - } - } - break; - case RegisterType.SHORT: - if (signedShift && literalShift >= 8) { - return RegisterType.BYTE_TYPE; - } - break; - case RegisterType.POS_SHORT: - if (literalShift >= 8) { - return RegisterType.POS_BYTE_TYPE; - } - break; - case RegisterType.CHAR: - if (literalShift > 8) { - return RegisterType.POS_BYTE_TYPE; - } - break; - case RegisterType.BYTE: - break; - case RegisterType.POS_BYTE: - return RegisterType.POS_BYTE_TYPE; - case RegisterType.NULL: - case RegisterType.ONE: - case RegisterType.BOOLEAN: - return RegisterType.NULL_TYPE; - default: - assert false; - } - - return destRegisterType; - } - - - private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) { - if (inlineResolver == null) { - throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); - } - - Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction; - Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); - - Opcode deodexedOpcode; - int acccessFlags = resolvedMethod.getAccessFlags(); - if (AccessFlags.STATIC.isSet(acccessFlags)) { - deodexedOpcode = Opcode.INVOKE_STATIC; - } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { - deodexedOpcode = Opcode.INVOKE_DIRECT; - } else { - deodexedOpcode = Opcode.INVOKE_VIRTUAL; - } - - Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(), - instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), - instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod); - - analyzedInstruction.setDeodexedInstruction(deodexedInstruction); - analyzeInstruction(analyzedInstruction); - } - - private void analyzeExecuteInlineRange(@Nonnull AnalyzedInstruction analyzedInstruction) { - if (inlineResolver == null) { - throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); - } - - Instruction3rmi instruction = (Instruction3rmi)analyzedInstruction.instruction; - Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); - - Opcode deodexedOpcode; - int acccessFlags = resolvedMethod.getAccessFlags(); - if (AccessFlags.STATIC.isSet(acccessFlags)) { - deodexedOpcode = Opcode.INVOKE_STATIC_RANGE; - } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { - deodexedOpcode = Opcode.INVOKE_DIRECT_RANGE; - } else { - deodexedOpcode = Opcode.INVOKE_VIRTUAL_RANGE; - } - - Instruction3rc deodexedInstruction = new ImmutableInstruction3rc(deodexedOpcode, instruction.getStartRegister(), - instruction.getRegisterCount(), resolvedMethod); - - analyzedInstruction.setDeodexedInstruction(deodexedInstruction); - analyzeInstruction(analyzedInstruction); - } - - private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction) { - analyzeInvokeDirectEmpty(analyzedInstruction, true); - } - - private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) { - Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction; - - Instruction35c deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT, - instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), - instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), - instruction.getReference()); - - analyzedInstruction.setDeodexedInstruction(deodexedInstruction); - - if (analyzeResult) { - analyzeInstruction(analyzedInstruction); - } - } - - private void analyzeInvokeObjectInitRange(@Nonnull AnalyzedInstruction analyzedInstruction) { - analyzeInvokeObjectInitRange(analyzedInstruction, true); - } - - private void analyzeInvokeObjectInitRange(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) { - Instruction3rc instruction = (Instruction3rc)analyzedInstruction.instruction; - - Instruction deodexedInstruction; - - int startRegister = instruction.getStartRegister(); - // hack: we should be using instruction.getRegisterCount, but some tweaked versions of dalvik appear - // to generate invoke-object-init/range instructions with an invalid register count. We know it should - // always be 1, so just use that. - int registerCount = 1; - if (startRegister < 16) { - deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT, - registerCount, startRegister, 0, 0, 0, 0, instruction.getReference()); - } else { - deodexedInstruction = new ImmutableInstruction3rc(Opcode.INVOKE_DIRECT_RANGE, - startRegister, registerCount, instruction.getReference()); - } - - analyzedInstruction.setDeodexedInstruction(deodexedInstruction); - - if (analyzeResult) { - analyzeInstruction(analyzedInstruction); - } - } - - private boolean analyzeIputIgetQuick(@Nonnull AnalyzedInstruction analyzedInstruction) { - Instruction22cs instruction = (Instruction22cs)analyzedInstruction.instruction; - - int fieldOffset = instruction.getFieldOffset(); - RegisterType objectRegisterType = getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterB(), - ReferenceOrUninitCategories); - - if (objectRegisterType.category == RegisterType.NULL) { - return false; - } - - TypeProto objectRegisterTypeProto = objectRegisterType.type; - assert objectRegisterTypeProto != null; - - TypeProto classTypeProto = classPath.getClass(objectRegisterTypeProto.getType()); - FieldReference resolvedField = classTypeProto.getFieldByOffset(fieldOffset); - - if (resolvedField == null) { - throw new AnalysisException("Could not resolve the field in class %s at offset %d", - objectRegisterType.type.getType(), fieldOffset); - } - - ClassDef thisClass = classPath.getClassDef(method.getDefiningClass()); - - if (!canAccessClass(thisClass, classPath.getClassDef(resolvedField.getDefiningClass()))) { - - // the class is not accessible. So we start looking at objectRegisterTypeProto (which may be different - // than resolvedField.getDefiningClass()), and walk up the class hierarchy. - ClassDef fieldClass = classPath.getClassDef(objectRegisterTypeProto.getType()); - while (!canAccessClass(thisClass, fieldClass)) { - String superclass = fieldClass.getSuperclass(); - if (superclass == null) { - throw new ExceptionWithContext("Couldn't find accessible class while resolving field %s", - ReferenceUtil.getShortFieldDescriptor(resolvedField)); - } - - fieldClass = classPath.getClassDef(superclass); - } - - // fieldClass is now the first accessible class found. Now. we need to make sure that the field is - // actually valid for this class - resolvedField = classPath.getClass(fieldClass.getType()).getFieldByOffset(fieldOffset); - if (resolvedField == null) { - throw new ExceptionWithContext("Couldn't find accessible class while resolving field %s", - ReferenceUtil.getShortFieldDescriptor(resolvedField)); - } - resolvedField = new ImmutableFieldReference(fieldClass.getType(), resolvedField.getName(), - resolvedField.getType()); - } - - String fieldType = resolvedField.getType(); - - Opcode opcode = OdexedFieldInstructionMapper.getAndCheckDeodexedOpcodeForOdexedOpcode(fieldType, - instruction.getOpcode()); - - Instruction22c deodexedInstruction = new ImmutableInstruction22c(opcode, (byte)instruction.getRegisterA(), - (byte)instruction.getRegisterB(), resolvedField); - analyzedInstruction.setDeodexedInstruction(deodexedInstruction); - - analyzeInstruction(analyzedInstruction); - - return true; - } - - private boolean analyzeInvokeVirtualQuick(@Nonnull AnalyzedInstruction analyzedInstruction, boolean isSuper, - boolean isRange) { - int methodIndex; - int objectRegister; - - if (isRange) { - Instruction3rms instruction = (Instruction3rms)analyzedInstruction.instruction; - methodIndex = instruction.getVtableIndex(); - objectRegister = instruction.getStartRegister(); - } else { - Instruction35ms instruction = (Instruction35ms)analyzedInstruction.instruction; - methodIndex = instruction.getVtableIndex(); - objectRegister = instruction.getRegisterC(); - } - - RegisterType objectRegisterType = getAndCheckSourceRegister(analyzedInstruction, objectRegister, - ReferenceOrUninitCategories); - TypeProto objectRegisterTypeProto = objectRegisterType.type; - - if (objectRegisterType.category == RegisterType.NULL) { - return false; - } - - assert objectRegisterTypeProto != null; - - MethodReference resolvedMethod; - if (isSuper) { - // invoke-super is only used for the same class that we're currently in - TypeProto typeProto = classPath.getClass(method.getDefiningClass()); - TypeProto superType; - - String superclassType = typeProto.getSuperclass(); - if (superclassType != null) { - superType = classPath.getClass(superclassType); - } else { - // This is either java.lang.Object, or an UnknownClassProto - superType = typeProto; - } - - resolvedMethod = superType.getMethodByVtableIndex(methodIndex); - } else{ - resolvedMethod = objectRegisterTypeProto.getMethodByVtableIndex(methodIndex); - } - - if (resolvedMethod == null) { - throw new AnalysisException("Could not resolve the method in class %s at index %d", - objectRegisterType.type.getType(), methodIndex); - } - - // no need to check class access for invoke-super. A class can obviously access its superclass. - ClassDef thisClass = classPath.getClassDef(method.getDefiningClass()); - - if (!isSuper && !canAccessClass(thisClass, classPath.getClassDef(resolvedMethod.getDefiningClass()))) { - - // the class is not accessible. So we start looking at objectRegisterTypeProto (which may be different - // than resolvedMethod.getDefiningClass()), and walk up the class hierarchy. - ClassDef methodClass = classPath.getClassDef(objectRegisterTypeProto.getType()); - while (!canAccessClass(thisClass, methodClass)) { - String superclass = methodClass.getSuperclass(); - if (superclass == null) { - throw new ExceptionWithContext("Couldn't find accessible class while resolving method %s", - ReferenceUtil.getMethodDescriptor(resolvedMethod, true)); - } - - methodClass = classPath.getClassDef(superclass); - } - - // methodClass is now the first accessible class found. Now. we need to make sure that the method is - // actually valid for this class - MethodReference newResolvedMethod = - classPath.getClass(methodClass.getType()).getMethodByVtableIndex(methodIndex); - if (newResolvedMethod == null) { - // TODO: fix NPE here - throw new ExceptionWithContext("Couldn't find accessible class while resolving method %s", - ReferenceUtil.getMethodDescriptor(resolvedMethod, true)); - } - resolvedMethod = newResolvedMethod; - resolvedMethod = new ImmutableMethodReference(methodClass.getType(), resolvedMethod.getName(), - resolvedMethod.getParameterTypes(), resolvedMethod.getReturnType()); - } - - Instruction deodexedInstruction; - if (isRange) { - Instruction3rms instruction = (Instruction3rms)analyzedInstruction.instruction; - Opcode opcode; - if (isSuper) { - opcode = Opcode.INVOKE_SUPER_RANGE; - } else { - opcode = Opcode.INVOKE_VIRTUAL_RANGE; - } - - deodexedInstruction = new ImmutableInstruction3rc(opcode, instruction.getStartRegister(), - instruction.getRegisterCount(), resolvedMethod); - } else { - Instruction35ms instruction = (Instruction35ms)analyzedInstruction.instruction; - Opcode opcode; - if (isSuper) { - opcode = Opcode.INVOKE_SUPER; - } else { - opcode = Opcode.INVOKE_VIRTUAL; - } - - deodexedInstruction = new ImmutableInstruction35c(opcode, instruction.getRegisterCount(), - instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), - instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod); - } - - analyzedInstruction.setDeodexedInstruction(deodexedInstruction); - analyzeInstruction(analyzedInstruction); - - return true; - } - - private boolean canAccessClass(@Nonnull ClassDef accessorClassDef, @Nonnull ClassDef accesseeClassDef) { - if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) { - return true; - } - - // Classes can only be public or package private. Any private or protected inner classes are actually - // package private. - return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorClassDef.getType())); - } - - private static String getPackage(String className) { - int lastSlash = className.lastIndexOf('/'); - if (lastSlash < 0) { - return ""; - } - return className.substring(1, lastSlash); - } - - private boolean analyzePutGetVolatile(@Nonnull AnalyzedInstruction analyzedInstruction) { - return analyzePutGetVolatile(analyzedInstruction, true); - } - - private boolean analyzePutGetVolatile(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) { - FieldReference field = (FieldReference)((ReferenceInstruction)analyzedInstruction.instruction).getReference(); - String fieldType = field.getType(); - - Opcode originalOpcode = analyzedInstruction.instruction.getOpcode(); - - Opcode opcode = OdexedFieldInstructionMapper.getAndCheckDeodexedOpcodeForOdexedOpcode(fieldType, - originalOpcode); - - Instruction deodexedInstruction; - - if (originalOpcode.isOdexedStaticVolatile()) { - OneRegisterInstruction instruction = (OneRegisterInstruction)analyzedInstruction.instruction; - deodexedInstruction = new ImmutableInstruction21c(opcode, instruction.getRegisterA(), field); - } else { - TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction; - - deodexedInstruction = new ImmutableInstruction22c(opcode, instruction.getRegisterA(), - instruction.getRegisterB(), field); - } - - analyzedInstruction.setDeodexedInstruction(deodexedInstruction); - - if (analyzeResult) { - analyzeInstruction(analyzedInstruction); - } - return true; - } - - @Nonnull - private static RegisterType getAndCheckSourceRegister(@Nonnull AnalyzedInstruction analyzedInstruction, - int registerNumber, BitSet validCategories) { - assert registerNumber >= 0 && registerNumber < analyzedInstruction.postRegisterMap.length; - - RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(registerNumber); - - checkRegister(registerType, registerNumber, validCategories); - - if (validCategories == WideLowCategories) { - checkRegister(registerType, registerNumber, WideLowCategories); - checkWidePair(registerNumber, analyzedInstruction); - - RegisterType secondRegisterType = analyzedInstruction.getPreInstructionRegisterType(registerNumber + 1); - checkRegister(secondRegisterType, registerNumber+1, WideHighCategories); - } - - return registerType; - } - - private static void checkRegister(RegisterType registerType, int registerNumber, BitSet validCategories) { - if (!validCategories.get(registerType.category)) { - throw new AnalysisException(String.format("Invalid register type %s for register v%d.", - registerType.toString(), registerNumber)); - } - } - - private static void checkWidePair(int registerNumber, AnalyzedInstruction analyzedInstruction) { - if (registerNumber + 1 >= analyzedInstruction.postRegisterMap.length) { - throw new AnalysisException(String.format("v%d cannot be used as the first register in a wide register" + - "pair because it is the last register.", registerNumber)); - } - } -} \ No newline at end of file diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/OdexedFieldInstructionMapper.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/OdexedFieldInstructionMapper.java deleted file mode 100644 index 49136c35..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/OdexedFieldInstructionMapper.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import org.jf.dexlib2.Opcode; - -import javax.annotation.Nonnull; - -public class OdexedFieldInstructionMapper { - private static Opcode[][][][] opcodeMap = new Opcode[][][][] { - //get opcodes - new Opcode[][][] { - //iget quick - new Opcode[][] { - //odexed - new Opcode[] { - /*Z*/ Opcode.IGET_QUICK, - /*B*/ Opcode.IGET_QUICK, - /*S*/ Opcode.IGET_QUICK, - /*C*/ Opcode.IGET_QUICK, - /*I,F*/ Opcode.IGET_QUICK, - /*J,D*/ Opcode.IGET_WIDE_QUICK, - /*L,[*/ Opcode.IGET_OBJECT_QUICK - }, - //deodexed - new Opcode[] { - /*Z*/ Opcode.IGET_BOOLEAN, - /*B*/ Opcode.IGET_BYTE, - /*S*/ Opcode.IGET_SHORT, - /*C*/ Opcode.IGET_CHAR, - /*I,F*/ Opcode.IGET, - /*J,D*/ Opcode.IGET_WIDE, - /*L,[*/ Opcode.IGET_OBJECT - } - }, - //iget volatile - new Opcode[][] { - //odexed - new Opcode[] { - /*Z*/ Opcode.IGET_VOLATILE, - /*B*/ Opcode.IGET_VOLATILE, - /*S*/ Opcode.IGET_VOLATILE, - /*C*/ Opcode.IGET_VOLATILE, - /*I,F*/ Opcode.IGET_VOLATILE, - /*J,D*/ Opcode.IGET_WIDE_VOLATILE, - /*L,[*/ Opcode.IGET_OBJECT_VOLATILE - }, - //deodexed - new Opcode[] { - /*Z*/ Opcode.IGET_BOOLEAN, - /*B*/ Opcode.IGET_BYTE, - /*S*/ Opcode.IGET_SHORT, - /*C*/ Opcode.IGET_CHAR, - /*I,F*/ Opcode.IGET, - /*J,D*/ Opcode.IGET_WIDE, - /*L,[*/ Opcode.IGET_OBJECT - } - }, - //sget volatile - new Opcode[][] { - //odexed - new Opcode[] { - /*Z*/ Opcode.SGET_VOLATILE, - /*B*/ Opcode.SGET_VOLATILE, - /*S*/ Opcode.SGET_VOLATILE, - /*C*/ Opcode.SGET_VOLATILE, - /*I,F*/ Opcode.SGET_VOLATILE, - /*J,D*/ Opcode.SGET_WIDE_VOLATILE, - /*L,[*/ Opcode.SGET_OBJECT_VOLATILE - }, - //deodexed - new Opcode[] { - /*Z*/ Opcode.SGET_BOOLEAN, - /*B*/ Opcode.SGET_BYTE, - /*S*/ Opcode.SGET_SHORT, - /*C*/ Opcode.SGET_CHAR, - /*I,F*/ Opcode.SGET, - /*J,D*/ Opcode.SGET_WIDE, - /*L,[*/ Opcode.SGET_OBJECT - } - } - }, - //put opcodes - new Opcode[][][] { - //iput quick - new Opcode[][] { - //odexed - new Opcode[] { - /*Z*/ Opcode.IPUT_QUICK, - /*B*/ Opcode.IPUT_QUICK, - /*S*/ Opcode.IPUT_QUICK, - /*C*/ Opcode.IPUT_QUICK, - /*I,F*/ Opcode.IPUT_QUICK, - /*J,D*/ Opcode.IPUT_WIDE_QUICK, - /*L,[*/ Opcode.IPUT_OBJECT_QUICK - }, - //deodexed - new Opcode[] { - /*Z*/ Opcode.IPUT_BOOLEAN, - /*B*/ Opcode.IPUT_BYTE, - /*S*/ Opcode.IPUT_SHORT, - /*C*/ Opcode.IPUT_CHAR, - /*I,F*/ Opcode.IPUT, - /*J,D*/ Opcode.IPUT_WIDE, - /*L,[*/ Opcode.IPUT_OBJECT - } - }, - //iput volatile - new Opcode[][] { - //odexed - new Opcode[] { - /*Z*/ Opcode.IPUT_VOLATILE, - /*B*/ Opcode.IPUT_VOLATILE, - /*S*/ Opcode.IPUT_VOLATILE, - /*C*/ Opcode.IPUT_VOLATILE, - /*I,F*/ Opcode.IPUT_VOLATILE, - /*J,D*/ Opcode.IPUT_WIDE_VOLATILE, - /*L,[*/ Opcode.IPUT_OBJECT_VOLATILE - }, - //deodexed - new Opcode[] { - /*Z*/ Opcode.IPUT_BOOLEAN, - /*B*/ Opcode.IPUT_BYTE, - /*S*/ Opcode.IPUT_SHORT, - /*C*/ Opcode.IPUT_CHAR, - /*I,F*/ Opcode.IPUT, - /*J,D*/ Opcode.IPUT_WIDE, - /*L,[*/ Opcode.IPUT_OBJECT - } - }, - //sput volatile - new Opcode[][] { - //odexed - new Opcode[] { - /*Z*/ Opcode.SPUT_VOLATILE, - /*B*/ Opcode.SPUT_VOLATILE, - /*S*/ Opcode.SPUT_VOLATILE, - /*C*/ Opcode.SPUT_VOLATILE, - /*I,F*/ Opcode.SPUT_VOLATILE, - /*J,D*/ Opcode.SPUT_WIDE_VOLATILE, - /*L,[*/ Opcode.SPUT_OBJECT_VOLATILE - }, - //deodexed - new Opcode[] { - /*Z*/ Opcode.SPUT_BOOLEAN, - /*B*/ Opcode.SPUT_BYTE, - /*S*/ Opcode.SPUT_SHORT, - /*C*/ Opcode.SPUT_CHAR, - /*I,F*/ Opcode.SPUT, - /*J,D*/ Opcode.SPUT_WIDE, - /*L,[*/ Opcode.SPUT_OBJECT - } - } - } - }; - - private static int getTypeIndex(char type) { - switch (type) { - case 'Z': - return 0; - case 'B': - return 1; - case 'S': - return 2; - case 'C': - return 3; - case 'I': - case 'F': - return 4; - case 'J': - case 'D': - return 5; - case 'L': - case '[': - return 6; - default: - } - throw new RuntimeException(String.format("Unknown type %s: ", type)); - } - - private static int getOpcodeSubtype(@Nonnull Opcode opcode) { - if (opcode.isOdexedInstanceQuick()) { - return 0; - } else if (opcode.isOdexedInstanceVolatile()) { - return 1; - } else if (opcode.isOdexedStaticVolatile()) { - return 2; - } - throw new RuntimeException(String.format("Not an odexed field access opcode: %s", opcode.name)); - } - - @Nonnull - static Opcode getAndCheckDeodexedOpcodeForOdexedOpcode(@Nonnull String fieldType, @Nonnull Opcode odexedOpcode) { - int opcodeType = odexedOpcode.setsRegister()?0:1; - int opcodeSubType = getOpcodeSubtype(odexedOpcode); - int typeIndex = getTypeIndex(fieldType.charAt(0)); - - Opcode correctOdexedOpcode, deodexedOpcode; - - correctOdexedOpcode = opcodeMap[opcodeType][opcodeSubType][0][typeIndex]; - deodexedOpcode = opcodeMap[opcodeType][opcodeSubType][1][typeIndex]; - - if (correctOdexedOpcode != odexedOpcode) { - throw new AnalysisException(String.format("Incorrect field type \"%s\" for %s", fieldType, - odexedOpcode.name)); - } - - return deodexedOpcode; - } -} - - diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/PrimitiveProto.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/PrimitiveProto.java deleted file mode 100644 index 06ab8e17..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/PrimitiveProto.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.iface.reference.MethodReference; -import org.jf.util.ExceptionWithContext; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class PrimitiveProto implements TypeProto { - protected final ClassPath classPath; - protected final String type; - - public PrimitiveProto(@Nonnull ClassPath classPath, @Nonnull String type) { - this.classPath = classPath; - this.type = type; - } - - @Override public String toString() { return type; } - @Nonnull @Override public ClassPath getClassPath() { return classPath; } - @Nonnull @Override public String getType() { return type; } - @Override public boolean isInterface() { return false; } - @Override public boolean implementsInterface(@Nonnull String iface) { return false; } - @Nullable @Override public String getSuperclass() { return null; } - @Nonnull @Override public TypeProto getCommonSuperclass(@Nonnull TypeProto other) { - throw new ExceptionWithContext("Cannot call getCommonSuperclass on PrimitiveProto"); - } - - @Override - @Nullable - public FieldReference getFieldByOffset(int fieldOffset) { - return null; - } - - @Override - @Nullable - public MethodReference getMethodByVtableIndex(int vtableIndex) { - return null; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/RegisterType.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/RegisterType.java deleted file mode 100644 index ba782fe6..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/RegisterType.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - - -import org.jf.util.ExceptionWithContext; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; -import java.io.Writer; - -public class RegisterType { - public final byte category; - @Nullable public final TypeProto type; - - private RegisterType(byte category, @Nullable TypeProto type) { - assert ((category == REFERENCE || category == UNINIT_REF || category == UNINIT_THIS) && type != null) || - ((category != REFERENCE && category != UNINIT_REF && category != UNINIT_THIS) && type == null); - - this.category = category; - this.type = type; - } - - @Override - public String toString() { - return "(" + CATEGORY_NAMES[category] + (type==null?"":("," + type)) + ")"; - } - - public void writeTo(Writer writer) throws IOException { - writer.write('('); - writer.write(CATEGORY_NAMES[category]); - if (type != null) { - writer.write(','); - writer.write(type.getType()); - } - writer.write(')'); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - RegisterType that = (RegisterType) o; - - if (category != that.category) { - return false; - } - - // These require strict reference equality. Every instance represents a unique - // reference that can't be merged with a different one, even if they have the same type. - if (category == UNINIT_REF || category == UNINIT_THIS) { - return false; - } - return (type != null ? type.equals(that.type) : that.type == null); - } - - @Override - public int hashCode() { - int result = category; - result = 31 * result + (type != null ? type.hashCode() : 0); - return result; - } - - // The Unknown category denotes a register type that hasn't been determined yet - public static final byte UNKNOWN = 0; - // The Uninit category is for registers that haven't been set yet. e.g. the non-parameter registers in a method - // start out as unint - public static final byte UNINIT = 1; - public static final byte NULL = 2; - public static final byte ONE = 3; - public static final byte BOOLEAN = 4; - public static final byte BYTE = 5; - public static final byte POS_BYTE = 6; - public static final byte SHORT = 7; - public static final byte POS_SHORT = 8; - public static final byte CHAR = 9; - public static final byte INTEGER = 10; - public static final byte FLOAT = 11; - public static final byte LONG_LO = 12; - public static final byte LONG_HI = 13; - public static final byte DOUBLE_LO = 14; - public static final byte DOUBLE_HI = 15; - // The UninitRef category is used after a new-instance operation, and before the corresponding is called - public static final byte UNINIT_REF = 16; - // The UninitThis category is used the "this" register inside an method, before the superclass' - // method is called - public static final byte UNINIT_THIS = 17; - public static final byte REFERENCE = 18; - // This is used when there are multiple incoming execution paths that have incompatible register types. For - // example if the register's type is an Integer on one incoming code path, but is a Reference type on another - // incomming code path. There is no register type that can hold either an Integer or a Reference. - public static final byte CONFLICTED = 19; - - public static final String[] CATEGORY_NAMES = new String[] { - "Unknown", - "Uninit", - "Null", - "One", - "Boolean", - "Byte", - "PosByte", - "Short", - "PosShort", - "Char", - "Integer", - "Float", - "LongLo", - "LongHi", - "DoubleLo", - "DoubleHi", - "UninitRef", - "UninitThis", - "Reference", - "Conflicted" - }; - - //this table is used when merging register types. For example, if a particular register can be either a BYTE - //or a Char, then the "merged" type of that register would be Integer, because it is the "smallest" type can - //could hold either type of value. - protected static byte[][] mergeTable = - { - /* UNKNOWN UNINIT NULL ONE, BOOLEAN BYTE POS_BYTE SHORT POS_SHORT CHAR INTEGER, FLOAT, LONG_LO LONG_HI DOUBLE_LO DOUBLE_HI UNINIT_REF UNINIT_THIS REFERENCE CONFLICTED*/ - /*UNKNOWN*/ {UNKNOWN, UNINIT, NULL, ONE, BOOLEAN, BYTE, POS_BYTE, SHORT, POS_SHORT, CHAR, INTEGER, FLOAT, LONG_LO, LONG_HI, DOUBLE_LO, DOUBLE_HI, UNINIT_REF, UNINIT_THIS,REFERENCE, CONFLICTED}, - /*UNINIT*/ {UNINIT, UNINIT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*NULL*/ {NULL, CONFLICTED, NULL, BOOLEAN, BOOLEAN, BYTE, POS_BYTE, SHORT, POS_SHORT, CHAR, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, REFERENCE, CONFLICTED}, - /*ONE*/ {ONE, CONFLICTED, BOOLEAN, ONE, BOOLEAN, BYTE, POS_BYTE, SHORT, POS_SHORT, CHAR, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*BOOLEAN*/ {BOOLEAN, CONFLICTED, BOOLEAN, BOOLEAN, BOOLEAN, BYTE, POS_BYTE, SHORT, POS_SHORT, CHAR, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*BYTE*/ {BYTE, CONFLICTED, BYTE, BYTE, BYTE, BYTE, BYTE, SHORT, SHORT, INTEGER, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*POS_BYTE*/ {POS_BYTE, CONFLICTED, POS_BYTE, POS_BYTE, POS_BYTE, BYTE, POS_BYTE, SHORT, POS_SHORT, CHAR, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*SHORT*/ {SHORT, CONFLICTED, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, INTEGER, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*POS_SHORT*/ {POS_SHORT, CONFLICTED, POS_SHORT, POS_SHORT, POS_SHORT, SHORT, POS_SHORT, SHORT, POS_SHORT, CHAR, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*CHAR*/ {CHAR, CONFLICTED, CHAR, CHAR, CHAR, INTEGER, CHAR, INTEGER, CHAR, CHAR, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*INTEGER*/ {INTEGER, CONFLICTED, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*FLOAT*/ {FLOAT, CONFLICTED, FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, INTEGER, FLOAT, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*LONG_LO*/ {LONG_LO, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, LONG_LO, CONFLICTED, LONG_LO, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*LONG_HI*/ {LONG_HI, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, LONG_HI, CONFLICTED, LONG_HI, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*DOUBLE_LO*/ {DOUBLE_LO, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, LONG_LO, CONFLICTED, DOUBLE_LO, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*DOUBLE_HI*/ {DOUBLE_HI, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, LONG_HI, CONFLICTED, DOUBLE_HI, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*UNINIT_REF*/ {UNINIT_REF, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED}, - /*UNINIT_THIS*/{UNINIT_THIS, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, UNINIT_THIS,CONFLICTED, CONFLICTED}, - /*REFERENCE*/ {REFERENCE, CONFLICTED, REFERENCE, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, REFERENCE, CONFLICTED}, - /*CONFLICTED*/ {CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED, CONFLICTED} - }; - - - public static final RegisterType UNKNOWN_TYPE = new RegisterType(UNKNOWN, null); - public static final RegisterType UNINIT_TYPE = new RegisterType(UNINIT, null); - public static final RegisterType NULL_TYPE = new RegisterType(NULL, null); - public static final RegisterType ONE_TYPE = new RegisterType(ONE, null); - public static final RegisterType BOOLEAN_TYPE = new RegisterType(BOOLEAN, null); - public static final RegisterType BYTE_TYPE = new RegisterType(BYTE, null); - public static final RegisterType POS_BYTE_TYPE = new RegisterType(POS_BYTE, null); - public static final RegisterType SHORT_TYPE = new RegisterType(SHORT, null); - public static final RegisterType POS_SHORT_TYPE = new RegisterType(POS_SHORT, null); - public static final RegisterType CHAR_TYPE = new RegisterType(CHAR, null); - public static final RegisterType INTEGER_TYPE = new RegisterType(INTEGER, null); - public static final RegisterType FLOAT_TYPE = new RegisterType(FLOAT, null); - public static final RegisterType LONG_LO_TYPE = new RegisterType(LONG_LO, null); - public static final RegisterType LONG_HI_TYPE = new RegisterType(LONG_HI, null); - public static final RegisterType DOUBLE_LO_TYPE = new RegisterType(DOUBLE_LO, null); - public static final RegisterType DOUBLE_HI_TYPE = new RegisterType(DOUBLE_HI, null); - public static final RegisterType CONFLICTED_TYPE = new RegisterType(CONFLICTED, null); - - @Nonnull - public static RegisterType getWideRegisterType(@Nonnull CharSequence type, boolean firstRegister) { - switch (type.charAt(0)) { - case 'J': - if (firstRegister) { - return getRegisterType(LONG_LO, null); - } else { - return getRegisterType(LONG_HI, null); - } - case 'D': - if (firstRegister) { - return getRegisterType(DOUBLE_LO, null); - } else { - return getRegisterType(DOUBLE_HI, null); - } - default: - throw new ExceptionWithContext("Cannot use this method for narrow register type: %s", type); - } - } - - @Nonnull - public static RegisterType getRegisterType(@Nonnull ClassPath classPath, @Nonnull CharSequence type) { - switch (type.charAt(0)) { - case 'Z': - return BOOLEAN_TYPE; - case 'B': - return BYTE_TYPE; - case 'S': - return SHORT_TYPE; - case 'C': - return CHAR_TYPE; - case 'I': - return INTEGER_TYPE; - case 'F': - return FLOAT_TYPE; - case 'J': - return LONG_LO_TYPE; - case 'D': - return DOUBLE_LO_TYPE; - case 'L': - case '[': - return getRegisterType(REFERENCE, classPath.getClass(type)); - default: - throw new ExceptionWithContext("Invalid type: " + type); - } - } - - @Nonnull - public static RegisterType getRegisterTypeForLiteral(int literalValue) { - if (literalValue < -32768) { - return INTEGER_TYPE; - } - if (literalValue < -128) { - return SHORT_TYPE; - } - if (literalValue < 0) { - return BYTE_TYPE; - } - if (literalValue == 0) { - return NULL_TYPE; - } - if (literalValue == 1) { - return ONE_TYPE; - } - if (literalValue < 128) { - return POS_BYTE_TYPE; - } - if (literalValue < 32768) { - return POS_SHORT_TYPE; - } - if (literalValue < 65536) { - return CHAR_TYPE; - } - return INTEGER_TYPE; - } - - @Nonnull - public RegisterType merge(@Nonnull RegisterType other) { - if (other.equals(this)) { - return this; - } - - byte mergedCategory = mergeTable[this.category][other.category]; - - TypeProto mergedType = null; - if (mergedCategory == REFERENCE) { - TypeProto type = this.type; - if (type != null) { - if (other.type != null) { - mergedType = type.getCommonSuperclass(other.type); - } else { - mergedType = type; - } - } else { - mergedType = other.type; - } - } else if (mergedCategory == UNINIT_REF || mergedCategory == UNINIT_THIS) { - if (this.category == UNKNOWN) { - return other; - } - assert other.category == UNKNOWN; - return this; - } - - if (mergedType != null) { - if (mergedType.equals(this.type)) { - return this; - } - if (mergedType.equals(other.type)) { - return other; - } - } - return RegisterType.getRegisterType(mergedCategory, mergedType); - } - - @Nonnull - public static RegisterType getRegisterType(byte category, @Nullable TypeProto typeProto) { - switch (category) { - case UNKNOWN: - return UNKNOWN_TYPE; - case UNINIT: - return UNINIT_TYPE; - case NULL: - return NULL_TYPE; - case ONE: - return ONE_TYPE; - case BOOLEAN: - return BOOLEAN_TYPE; - case BYTE: - return BYTE_TYPE; - case POS_BYTE: - return POS_BYTE_TYPE; - case SHORT: - return SHORT_TYPE; - case POS_SHORT: - return POS_SHORT_TYPE; - case CHAR: - return CHAR_TYPE; - case INTEGER: - return INTEGER_TYPE; - case FLOAT: - return FLOAT_TYPE; - case LONG_LO: - return LONG_LO_TYPE; - case LONG_HI: - return LONG_HI_TYPE; - case DOUBLE_LO: - return DOUBLE_LO_TYPE; - case DOUBLE_HI: - return DOUBLE_HI_TYPE; - case CONFLICTED: - return CONFLICTED_TYPE; - } - - return new RegisterType(category, typeProto); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/TypeProto.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/TypeProto.java deleted file mode 100644 index f6db2399..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/TypeProto.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.iface.reference.MethodReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public interface TypeProto { - @Nonnull ClassPath getClassPath(); - @Nonnull String getType(); - boolean isInterface(); - boolean implementsInterface(@Nonnull String iface); - @Nullable String getSuperclass(); - @Nonnull TypeProto getCommonSuperclass(@Nonnull TypeProto other); - @Nullable FieldReference getFieldByOffset(int fieldOffset); - @Nullable MethodReference getMethodByVtableIndex(int vtableIndex); -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnknownClassProto.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnknownClassProto.java deleted file mode 100644 index 38256fbe..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnknownClassProto.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import org.jf.dexlib2.iface.reference.FieldReference; -import org.jf.dexlib2.iface.reference.MethodReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class UnknownClassProto implements TypeProto { - @Nonnull protected final ClassPath classPath; - - public UnknownClassProto(@Nonnull ClassPath classPath) { - this.classPath = classPath; - } - - @Override public String toString() { return "Ujava/lang/Object;"; } - @Nonnull @Override public ClassPath getClassPath() { return classPath; } - @Nullable @Override public String getSuperclass() { return null; } - @Override public boolean isInterface() { return false; } - @Override public boolean implementsInterface(@Nonnull String iface) { return false; } - - @Nonnull @Override public TypeProto getCommonSuperclass(@Nonnull TypeProto other) { - if (other.getType().equals("Ljava/lang/Object;")) { - return other; - } - if (other instanceof ArrayProto) { - // if it's an array class, it's safe to assume this unknown class isn't related, and so - // java.lang.Object is the only possible superclass - return classPath.getClass("Ljava/lang/Object;"); - } - return this; - } - - @Nonnull @Override public String getType() { - // use the otherwise used U prefix for an unknown/unresolvable class - return "Ujava/lang/Object;"; - } - - @Override - @Nullable - public FieldReference getFieldByOffset(int fieldOffset) { - return classPath.getClass("Ljava/lang/Object;").getFieldByOffset(fieldOffset); - } - - @Override - @Nullable - public MethodReference getMethodByVtableIndex(int vtableIndex) { - return classPath.getClass("Ljava/lang/Object;").getMethodByVtableIndex(vtableIndex); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnresolvedClassException.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnresolvedClassException.java deleted file mode 100644 index 6ee36ca3..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnresolvedClassException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import org.jf.util.ExceptionWithContext; - -public class UnresolvedClassException extends ExceptionWithContext { - public UnresolvedClassException(Throwable cause) { - super(cause); - } - - public UnresolvedClassException(Throwable cause, String message, Object... formatArgs) { - super(cause, message, formatArgs); - } - - public UnresolvedClassException(String message, Object... formatArgs) { - super(message, formatArgs); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnresolvedOdexInstruction.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnresolvedOdexInstruction.java deleted file mode 100644 index fb201b01..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/UnresolvedOdexInstruction.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis; - -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.iface.instruction.Instruction; - -/** - * This represents a "fixed" odexed instruction, where the object register is always null and so the correct type - * can't be determined. Typically, these are replaced by an equivalent instruction that would have the same - * effect (namely, an NPE) - */ -public class UnresolvedOdexInstruction implements Instruction { - public final Instruction originalInstruction; - //the register number that holds the (null) reference type that the instruction operates on - public final int objectRegisterNum; - - public UnresolvedOdexInstruction(Instruction originalInstruction, int objectRegisterNumber) { - this.originalInstruction = originalInstruction; - this.objectRegisterNum = objectRegisterNumber; - } - - @Override public Opcode getOpcode() { - return originalInstruction.getOpcode(); - } - - @Override public int getCodeUnits() { - return originalInstruction.getCodeUnits(); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionClassDef.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionClassDef.java deleted file mode 100644 index 7e8a2829..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionClassDef.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis.reflection; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterators; -import org.jf.dexlib2.analysis.reflection.util.ReflectionUtils; -import org.jf.dexlib2.base.reference.BaseTypeReference; -import org.jf.dexlib2.iface.Annotation; -import org.jf.dexlib2.iface.ClassDef; -import org.jf.dexlib2.iface.Field; -import org.jf.dexlib2.iface.Method; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -/** - * Wraps a ClassDef around a class loaded in the current VM - * - * Only supports the basic information exposed by ClassProto - */ -public class ReflectionClassDef extends BaseTypeReference implements ClassDef { - private final Class cls; - - public ReflectionClassDef(Class cls) { - this.cls = cls; - } - - @Override public int getAccessFlags() { - // the java modifiers appear to be the same as the dex access flags - return cls.getModifiers(); - } - - @Nullable @Override public String getSuperclass() { - if (Modifier.isInterface(cls.getModifiers())) { - return "Ljava/lang/Object;"; - } - Class superClass = cls.getSuperclass(); - if (superClass == null) { - return null; - } - return ReflectionUtils.javaToDexName(superClass.getName()); - } - - @Nonnull @Override public List getInterfaces() { - return ImmutableList.copyOf(Iterators.transform(Iterators.forArray(cls.getInterfaces()), new Function() { - @Nullable - @Override - public String apply(@Nullable Class input) { - if (input == null) { - return null; - } - return ReflectionUtils.javaToDexName(input.getName()); - } - })); - } - - @Nullable @Override public String getSourceFile() { - return null; - } - - @Nonnull @Override public Set getAnnotations() { - return ImmutableSet.of(); - } - - @Nonnull @Override public Iterable getStaticFields() { - return new Iterable() { - @Nonnull @Override public Iterator iterator() { - Iterator staticFields = Iterators.filter( - Iterators.forArray(cls.getDeclaredFields()), - new Predicate() { - @Override public boolean apply(@Nullable java.lang.reflect.Field input) { - return input!=null && Modifier.isStatic(input.getModifiers()); - } - }); - - return Iterators.transform(staticFields, - new Function() { - @Nullable @Override public Field apply(@Nullable java.lang.reflect.Field input) { - return new ReflectionField(input); - } - } - ); - } - }; - } - - @Nonnull @Override public Iterable getInstanceFields() { - return new Iterable() { - @Nonnull @Override public Iterator iterator() { - Iterator staticFields = Iterators.filter( - Iterators.forArray(cls.getDeclaredFields()), - new Predicate() { - @Override public boolean apply(@Nullable java.lang.reflect.Field input) { - return input!=null && !Modifier.isStatic(input.getModifiers()); - } - }); - - return Iterators.transform(staticFields, - new Function() { - @Nullable @Override public Field apply(@Nullable java.lang.reflect.Field input) { - return new ReflectionField(input); - } - } - ); - } - }; - } - - @Nonnull @Override public Set getFields() { - return new AbstractSet() { - @Nonnull @Override public Iterator iterator() { - return Iterators.transform(Iterators.forArray(cls.getDeclaredFields()), - new Function() { - @Nullable @Override public Field apply(@Nullable java.lang.reflect.Field input) { - return new ReflectionField(input); - } - }); - } - - @Override public int size() { - return cls.getDeclaredFields().length; - } - }; - } - - private static final int DIRECT_MODIFIERS = Modifier.PRIVATE | Modifier.STATIC; - @Nonnull @Override public Iterable getDirectMethods() { - return new Iterable() { - @Nonnull @Override public Iterator iterator() { - Iterator constructorIterator = - Iterators.transform(Iterators.forArray(cls.getDeclaredConstructors()), - new Function() { - @Nullable @Override public Method apply(@Nullable Constructor input) { - return new ReflectionConstructor(input); - } - }); - - Iterator directMethods = Iterators.filter( - Iterators.forArray(cls.getDeclaredMethods()), - new Predicate() { - @Override public boolean apply(@Nullable java.lang.reflect.Method input) { - return input != null && (input.getModifiers() & DIRECT_MODIFIERS) != 0; - } - }); - - Iterator methodIterator = Iterators.transform(directMethods, - new Function() { - @Nullable @Override public Method apply(@Nullable java.lang.reflect.Method input) { - return new ReflectionMethod(input); - } - }); - return Iterators.concat(constructorIterator, methodIterator); - } - }; - } - - @Nonnull @Override public Iterable getVirtualMethods() { - return new Iterable() { - @Nonnull @Override public Iterator iterator() { - Iterator directMethods = Iterators.filter( - Iterators.forArray(cls.getDeclaredMethods()), - new Predicate() { - @Override public boolean apply(@Nullable java.lang.reflect.Method input) { - return input != null && (input.getModifiers() & DIRECT_MODIFIERS) == 0; - } - }); - - return Iterators.transform(directMethods, - new Function() { - @Nullable @Override public Method apply(@Nullable java.lang.reflect.Method input) { - return new ReflectionMethod(input); - } - }); - } - }; - } - - @Nonnull @Override public Set getMethods() { - return new AbstractSet() { - @Nonnull @Override public Iterator iterator() { - Iterator constructorIterator = - Iterators.transform(Iterators.forArray(cls.getDeclaredConstructors()), - new Function() { - @Nullable @Override public Method apply(@Nullable Constructor input) { - return new ReflectionConstructor(input); - } - }); - - Iterator methodIterator = - Iterators.transform(Iterators.forArray(cls.getDeclaredMethods()), - new Function() { - @Nullable @Override public Method apply(@Nullable java.lang.reflect.Method input) { - return new ReflectionMethod(input); - } - }); - return Iterators.concat(constructorIterator, methodIterator); - } - - @Override public int size() { - return cls.getDeclaredMethods().length + cls.getDeclaredConstructors().length; - } - }; - } - - @Nonnull @Override public String getType() { - return ReflectionUtils.javaToDexName(cls.getName()); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionConstructor.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionConstructor.java deleted file mode 100644 index 84219599..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionConstructor.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis.reflection; - -import com.google.common.collect.ImmutableSet; -import org.jf.dexlib2.analysis.reflection.util.ReflectionUtils; -import org.jf.dexlib2.base.BaseMethodParameter; -import org.jf.dexlib2.base.reference.BaseMethodReference; -import org.jf.dexlib2.iface.Annotation; -import org.jf.dexlib2.iface.Method; -import org.jf.dexlib2.iface.MethodImplementation; -import org.jf.dexlib2.iface.MethodParameter; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.lang.reflect.Constructor; -import java.util.AbstractList; -import java.util.List; -import java.util.Set; - -public class ReflectionConstructor extends BaseMethodReference implements Method { - private final Constructor constructor; - - public ReflectionConstructor(Constructor constructor) { - this.constructor = constructor; - } - - @Nonnull @Override public List getParameters() { - final Constructor method = this.constructor; - return new AbstractList() { - private final Class[] parameters = method.getParameterTypes(); - - @Override public MethodParameter get(final int index) { - return new BaseMethodParameter() { - @Nonnull @Override public Set getAnnotations() { - return ImmutableSet.of(); - } - - @Nullable @Override public String getName() { - return null; - } - - @Nonnull @Override public String getType() { - return ReflectionUtils.javaToDexName(parameters[index].getName()); - } - }; - } - - @Override public int size() { - return parameters.length; - } - }; - } - - @Override public int getAccessFlags() { - return constructor.getModifiers(); - } - - @Nonnull @Override public Set getAnnotations() { - return ImmutableSet.of(); - } - - @Nullable @Override public MethodImplementation getImplementation() { - return null; - } - - @Nonnull @Override public String getDefiningClass() { - return ReflectionUtils.javaToDexName(constructor.getDeclaringClass().getName()); - } - - @Nonnull @Override public String getName() { - return constructor.getName(); - } - - @Nonnull @Override public List getParameterTypes() { - return new AbstractList() { - private final List parameters = getParameters(); - - @Override public String get(int index) { - return parameters.get(index).getType(); - } - - @Override public int size() { - return parameters.size(); - } - }; - } - - @Nonnull @Override public String getReturnType() { - return "V"; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionField.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionField.java deleted file mode 100644 index c3a0e8c9..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionField.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis.reflection; - -import com.google.common.collect.ImmutableSet; -import org.jf.dexlib2.analysis.reflection.util.ReflectionUtils; -import org.jf.dexlib2.base.reference.BaseFieldReference; -import org.jf.dexlib2.iface.Annotation; -import org.jf.dexlib2.iface.Field; -import org.jf.dexlib2.iface.value.EncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Set; - -public class ReflectionField extends BaseFieldReference implements Field { - private final java.lang.reflect.Field field; - - public ReflectionField(java.lang.reflect.Field field) { - this.field = field; - } - - @Override public int getAccessFlags() { - return field.getModifiers(); - } - - @Nullable @Override public EncodedValue getInitialValue() { - return null; - } - - @Nonnull @Override public Set getAnnotations() { - return ImmutableSet.of(); - } - - @Nonnull @Override public String getDefiningClass() { - return ReflectionUtils.javaToDexName(field.getDeclaringClass().getName()); - } - - @Nonnull @Override public String getName() { - return field.getName(); - } - - @Nonnull @Override public String getType() { - return ReflectionUtils.javaToDexName(field.getType().getName()); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionMethod.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionMethod.java deleted file mode 100644 index b7fb4756..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/ReflectionMethod.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis.reflection; - -import com.google.common.collect.ImmutableSet; -import org.jf.dexlib2.analysis.reflection.util.ReflectionUtils; -import org.jf.dexlib2.base.BaseMethodParameter; -import org.jf.dexlib2.base.reference.BaseMethodReference; -import org.jf.dexlib2.iface.Annotation; -import org.jf.dexlib2.iface.Method; -import org.jf.dexlib2.iface.MethodImplementation; -import org.jf.dexlib2.iface.MethodParameter; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.AbstractList; -import java.util.List; -import java.util.Set; - -public class ReflectionMethod extends BaseMethodReference implements Method { - private final java.lang.reflect.Method method; - - public ReflectionMethod(java.lang.reflect.Method method) { - this.method = method; - } - - @Nonnull @Override public List getParameters() { - final java.lang.reflect.Method method = this.method; - return new AbstractList() { - private final Class[] parameters = method.getParameterTypes(); - - @Override public MethodParameter get(final int index) { - return new BaseMethodParameter() { - @Nonnull @Override public Set getAnnotations() { - return ImmutableSet.of(); - } - - @Nullable @Override public String getName() { - return null; - } - - @Nonnull @Override public String getType() { - return ReflectionUtils.javaToDexName(parameters[index].getName()); - } - }; - } - - @Override public int size() { - return parameters.length; - } - }; - } - - @Override public int getAccessFlags() { - return method.getModifiers(); - } - - @Nonnull @Override public Set getAnnotations() { - return ImmutableSet.of(); - } - - @Nullable @Override public MethodImplementation getImplementation() { - return null; - } - - @Nonnull @Override public String getDefiningClass() { - return ReflectionUtils.javaToDexName(method.getDeclaringClass().getName()); - } - - @Nonnull @Override public String getName() { - return method.getName(); - } - - @Nonnull @Override public List getParameterTypes() { - return new AbstractList() { - private final List parameters = getParameters(); - - @Override public String get(int index) { - return parameters.get(index).getType(); - } - - @Override public int size() { - return parameters.size(); - } - }; - } - - @Nonnull @Override public String getReturnType() { - return ReflectionUtils.javaToDexName(method.getReturnType().getName()); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/util/ReflectionUtils.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/util/ReflectionUtils.java deleted file mode 100644 index 4a4615a6..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/reflection/util/ReflectionUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis.reflection.util; - -public class ReflectionUtils { - public static String javaToDexName(String javaName) { - javaName = javaName.replace('.', '/'); - if (javaName.length() > 1 && javaName.charAt(javaName.length()-1) != ';') { - javaName = 'L' + javaName + ';'; - } - return javaName; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/util/TypeProtoUtils.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/util/TypeProtoUtils.java deleted file mode 100644 index 0313c7c3..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/util/TypeProtoUtils.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.analysis.util; - -import org.jf.dexlib2.analysis.TypeProto; -import org.jf.dexlib2.analysis.UnresolvedClassException; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Iterator; -import java.util.NoSuchElementException; - -public class TypeProtoUtils { - /** - * Get the chain of superclasses of the given class. The first element will be the immediate superclass followed by - * it's superclass, etc. up to java.lang.Object. - * - * Returns an empty iterable if called on java.lang.Object or a primitive. - * - * If any class in the superclass chain can't be resolved, the iterable will return Ujava/lang/Object; to represent - * the unknown class. - * - * @return An iterable containing the superclasses of this class. - */ - @Nonnull - public static Iterable getSuperclassChain(@Nonnull final TypeProto typeProto) { - return new Iterable() { - - @Override public Iterator iterator() { - return new Iterator() { - @Nullable private TypeProto type = getSuperclassAsTypeProto(typeProto); - - @Override public boolean hasNext() { - return type != null; - } - - @Override public TypeProto next() { - TypeProto type = this.type; - if (type == null) { - throw new NoSuchElementException(); - } - - this.type = getSuperclassAsTypeProto(type); - return type; - } - - @Override public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - @Nullable - public static TypeProto getSuperclassAsTypeProto(@Nonnull TypeProto type) { - try { - String next = type.getSuperclass(); - if (next != null) { - return type.getClassPath().getClass(next); - } else { - return null; - } - } catch (UnresolvedClassException ex) { - return type.getClassPath().getUnknownClass(); - } - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseAnnotation.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseAnnotation.java deleted file mode 100644 index 134f3746..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseAnnotation.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.iface.Annotation; -import org.jf.util.CollectionUtils; - -import java.util.Comparator; - -public abstract class BaseAnnotation implements Annotation { - @Override - public int hashCode() { - int hashCode = getVisibility(); - hashCode = hashCode*31 + getType().hashCode(); - return hashCode*31 + getElements().hashCode(); - } - - @Override - public boolean equals(Object o) { - if (o instanceof Annotation) { - Annotation other = (Annotation)o; - return (getVisibility() == other.getVisibility()) && - getType().equals(other.getType()) && - getElements().equals(other.getElements()); - } - return false; - } - - @Override - public int compareTo(Annotation o) { - int res = Ints.compare(getVisibility(), o.getVisibility()); - if (res != 0) return res; - res = getType().compareTo(o.getType()); - if (res != 0) return res; - return CollectionUtils.compareAsSet(getElements(), o.getElements()); - } - - public static final Comparator BY_TYPE = new Comparator() { - @Override - public int compare(Annotation annotation1, Annotation annotation2) { - return annotation1.getType().compareTo(annotation2.getType()); - } - }; -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseAnnotationElement.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseAnnotationElement.java deleted file mode 100644 index 92566cbc..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseAnnotationElement.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base; - -import org.jf.dexlib2.iface.AnnotationElement; - -import javax.annotation.Nonnull; -import java.util.Comparator; - -public abstract class BaseAnnotationElement implements AnnotationElement { - @Override - public int hashCode() { - int hashCode = getName().hashCode(); - return hashCode*31 + getValue().hashCode(); - } - - @Override - public boolean equals(Object o) { - if (o != null && o instanceof AnnotationElement) { - AnnotationElement other = (AnnotationElement)o; - return getName().equals(other.getName()) && - getValue().equals(other.getValue()); - } - return false; - } - - @Override - public int compareTo(AnnotationElement o) { - int res = getName().compareTo(o.getName()); - if (res != 0) return res; - return getValue().compareTo(o.getValue()); - } - - public static final Comparator BY_NAME = new Comparator() { - @Override - public int compare(@Nonnull AnnotationElement element1, @Nonnull AnnotationElement element2) { - return element1.getName().compareTo(element2.getName()); - } - }; -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseExceptionHandler.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseExceptionHandler.java deleted file mode 100644 index 9ad6b648..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseExceptionHandler.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base; - -import com.google.common.base.Objects; -import com.google.common.primitives.Ints; -import org.jf.dexlib2.base.reference.BaseTypeReference; -import org.jf.dexlib2.iface.ExceptionHandler; -import org.jf.dexlib2.iface.reference.TypeReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Comparator; - -public abstract class BaseExceptionHandler implements ExceptionHandler { - @Nullable @Override public TypeReference getExceptionTypeReference() { - final String exceptionType = getExceptionType(); - if (exceptionType == null) { - return null; - } - - return new BaseTypeReference() { - @Nonnull @Override public String getType() { - return exceptionType; - } - }; - } - - @Override - public int hashCode() { - String exceptionType = getExceptionType(); - int hashCode = exceptionType==null?0:exceptionType.hashCode(); - return hashCode*31 + getHandlerCodeAddress(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof ExceptionHandler) { - ExceptionHandler other = (ExceptionHandler)o; - return Objects.equal(getExceptionType(), other.getExceptionType()) && - (getHandlerCodeAddress() == other.getHandlerCodeAddress()); - } - return false; - } - - @Override - public int compareTo(@Nonnull ExceptionHandler o) { - int res; - String exceptionType = getExceptionType(); - if (exceptionType == null) { - if (o.getExceptionType() != null) { - return 1; - } - } else { - String otherExceptionType = o.getExceptionType(); - if (otherExceptionType == null) { - return -1; - } - res = exceptionType.compareTo(o.getExceptionType()); - if (res != 0) return res; - } - return Ints.compare(getHandlerCodeAddress(), o.getHandlerCodeAddress()); - } - - - - public static final Comparator BY_EXCEPTION = new Comparator() { - @Override public int compare(ExceptionHandler o1, ExceptionHandler o2) { - String exceptionType1 = o1.getExceptionType(); - if (exceptionType1 == null) { - if (o2.getExceptionType() != null) { - return 1; - } - return 0; - } else { - String exceptionType2 = o2.getExceptionType(); - if (exceptionType2 == null) { - return -1; - } - return exceptionType1.compareTo(o2.getExceptionType()); - } - } - }; -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseMethodParameter.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseMethodParameter.java deleted file mode 100644 index ecac3c96..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseMethodParameter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base; - -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.base.reference.BaseTypeReference; -import org.jf.dexlib2.iface.Annotation; -import org.jf.dexlib2.iface.AnnotationElement; -import org.jf.dexlib2.iface.MethodParameter; -import org.jf.dexlib2.iface.value.ArrayEncodedValue; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.StringEncodedValue; - -import javax.annotation.Nullable; - -public abstract class BaseMethodParameter extends BaseTypeReference implements MethodParameter { - @Nullable - @Override - public String getSignature() { - Annotation signatureAnnotation = null; - for (Annotation annotation: getAnnotations()) { - if (annotation.getType().equals("Ldalvik/annotation/Signature;")) { - signatureAnnotation = annotation; - break; - } - } - if (signatureAnnotation == null) { - return null; - } - - ArrayEncodedValue signatureValues = null; - for (AnnotationElement annotationElement: signatureAnnotation.getElements()) { - if (annotationElement.getName().equals("value")) { - EncodedValue encodedValue = annotationElement.getValue(); - if (encodedValue.getValueType() != ValueType.ARRAY) { - return null; - } - signatureValues = (ArrayEncodedValue)encodedValue; - break; - } - } - if (signatureValues == null) { - return null; - } - - StringBuilder sb = new StringBuilder(); - for (EncodedValue signatureValue: signatureValues.getValue()) { - if (signatureValue.getValueType() != ValueType.STRING) { - return null; - } - sb.append(((StringEncodedValue)signatureValue).getValue()); - } - return sb.toString(); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseTryBlock.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseTryBlock.java deleted file mode 100644 index d1afe9a4..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/BaseTryBlock.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base; - -import org.jf.dexlib2.iface.ExceptionHandler; -import org.jf.dexlib2.iface.TryBlock; - -public abstract class BaseTryBlock implements TryBlock { - @Override public boolean equals(Object o) { - if (o instanceof TryBlock) { - TryBlock other = (TryBlock)o; - return getStartCodeAddress() == other.getStartCodeAddress() && - getCodeUnitCount() == other.getCodeUnitCount() && - getExceptionHandlers().equals(other.getExceptionHandlers()); - } - return false; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseFieldReference.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseFieldReference.java deleted file mode 100644 index f056f245..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseFieldReference.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.reference; - -import org.jf.dexlib2.iface.reference.FieldReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseFieldReference implements FieldReference { - @Override - public int hashCode() { - int hashCode = getDefiningClass().hashCode(); - hashCode = hashCode*31 + getName().hashCode(); - return hashCode*31 + getType().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof FieldReference) { - FieldReference other = (FieldReference)o; - return getDefiningClass().equals(other.getDefiningClass()) && - getName().equals(other.getName()) && - getType().equals(other.getType()); - - } - return false; - } - - @Override - public int compareTo(@Nonnull FieldReference o) { - int res = getDefiningClass().compareTo(o.getDefiningClass()); - if (res != 0) return res; - res = getName().compareTo(o.getName()); - if (res != 0) return res; - return getType().compareTo(o.getType()); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseMethodReference.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseMethodReference.java deleted file mode 100644 index 3ff6f7db..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseMethodReference.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.reference; - -import com.google.common.collect.Ordering; -import org.jf.dexlib2.iface.reference.MethodReference; -import org.jf.util.CharSequenceUtils; -import org.jf.util.CollectionUtils; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseMethodReference implements MethodReference { - @Override - public int hashCode() { - int hashCode = getDefiningClass().hashCode(); - hashCode = hashCode*31 + getName().hashCode(); - hashCode = hashCode*31 + getReturnType().hashCode(); - return hashCode*31 + getParameterTypes().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o != null && o instanceof MethodReference) { - MethodReference other = (MethodReference)o; - return getDefiningClass().equals(other.getDefiningClass()) && - getName().equals(other.getName()) && - getReturnType().equals(other.getReturnType()) && - CharSequenceUtils.listEquals(getParameterTypes(), other.getParameterTypes()); - } - return false; - } - - @Override - public int compareTo(@Nonnull MethodReference o) { - int res = getDefiningClass().compareTo(o.getDefiningClass()); - if (res != 0) return res; - res = getName().compareTo(o.getName()); - if (res != 0) return res; - res = getReturnType().compareTo(o.getReturnType()); - if (res != 0) return res; - return CollectionUtils.compareAsIterable(Ordering.usingToString(), getParameterTypes(), o.getParameterTypes()); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseStringReference.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseStringReference.java deleted file mode 100644 index c6daa91e..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseStringReference.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.reference; - -import org.jf.dexlib2.iface.reference.StringReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseStringReference implements StringReference { - @Override - public int hashCode() { - return getString().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o != null && o instanceof StringReference) { - return getString().equals(((StringReference)o).getString()); - } - return false; - } - - @Override - public int compareTo(@Nonnull CharSequence o) { - return getString().compareTo(o.toString()); - } - - @Override public int length() { return getString().length(); } - @Override public char charAt(int index) { return getString().charAt(index); } - @Override public CharSequence subSequence(int start, int end) { return getString().subSequence(start, end); } - @Override public String toString() { return getString(); } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseTypeReference.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseTypeReference.java deleted file mode 100644 index 4b24d071..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/reference/BaseTypeReference.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.reference; - -import org.jf.dexlib2.iface.reference.TypeReference; - -import javax.annotation.Nonnull; - -public abstract class BaseTypeReference implements TypeReference { - @Override - public int hashCode() { - return getType().hashCode(); - } - - @Override - public boolean equals(Object o) { - if (o != null) { - if (o instanceof TypeReference) { - return getType().equals(((TypeReference)o).getType()); - } - if (o instanceof CharSequence) { - return getType().equals(o.toString()); - } - } - return false; - } - - @Override - public int compareTo(@Nonnull CharSequence o) { - return getType().compareTo(o.toString()); - } - - @Override public int length() { return getType().length(); } - @Override public char charAt(int index) { return getType().charAt(index); } - @Override public CharSequence subSequence(int start, int end) { return getType().subSequence(start, end); } - @Override @Nonnull public String toString() { return getType(); } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseAnnotationEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseAnnotationEncodedValue.java deleted file mode 100644 index 828c1eca..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseAnnotationEncodedValue.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.AnnotationEncodedValue; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.util.CollectionUtils; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseAnnotationEncodedValue implements AnnotationEncodedValue { - @Override - public int hashCode() { - int hashCode = getType().hashCode(); - return hashCode * 31 + getElements().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof AnnotationEncodedValue) { - AnnotationEncodedValue other = (AnnotationEncodedValue)o; - return getType().equals(other.getType()) && - getElements().equals(other.getElements()); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - AnnotationEncodedValue other = (AnnotationEncodedValue)o; - res = getType().compareTo(other.getType()); - if (res != 0) return res; - return CollectionUtils.compareAsSet(getElements(), other.getElements()); - } - - public int getValueType() { - return ValueType.ANNOTATION; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseArrayEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseArrayEncodedValue.java deleted file mode 100644 index 7c6efd3e..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseArrayEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.ArrayEncodedValue; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.util.CollectionUtils; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseArrayEncodedValue implements ArrayEncodedValue { - @Override - public int hashCode() { - return getValue().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof ArrayEncodedValue) { - return getValue().equals(((ArrayEncodedValue)o).getValue()); - } - return false; - } - - @Override public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return CollectionUtils.compareAsList(getValue(), ((ArrayEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.ARRAY; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseBooleanEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseBooleanEncodedValue.java deleted file mode 100644 index aeedc2c0..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseBooleanEncodedValue.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Booleans; -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.BooleanEncodedValue; -import org.jf.dexlib2.iface.value.EncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseBooleanEncodedValue implements BooleanEncodedValue { - @Override - public int hashCode() { - return getValue()?1:0; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof BooleanEncodedValue) { - return getValue() == ((BooleanEncodedValue)o).getValue(); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return Booleans.compare(getValue(), ((BooleanEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.BOOLEAN; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseByteEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseByteEncodedValue.java deleted file mode 100644 index 5ec16241..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseByteEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.ByteEncodedValue; -import org.jf.dexlib2.iface.value.EncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseByteEncodedValue implements ByteEncodedValue { - @Override - public int hashCode() { - return getValue(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof ByteEncodedValue) { - return getValue() == ((ByteEncodedValue)o).getValue(); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return Ints.compare(getValue(), ((ByteEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.BYTE; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseCharEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseCharEncodedValue.java deleted file mode 100644 index 9f076e28..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseCharEncodedValue.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Chars; -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.CharEncodedValue; -import org.jf.dexlib2.iface.value.EncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseCharEncodedValue implements CharEncodedValue { - @Override - public int hashCode() { - return getValue(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof CharEncodedValue) { - return getValue() == ((CharEncodedValue)o).getValue(); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return Chars.compare(getValue(), ((CharEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.CHAR; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseDoubleEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseDoubleEncodedValue.java deleted file mode 100644 index d8b08c36..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseDoubleEncodedValue.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.DoubleEncodedValue; -import org.jf.dexlib2.iface.value.EncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseDoubleEncodedValue implements DoubleEncodedValue { - @Override - public int hashCode() { - long v = Double.doubleToRawLongBits(getValue()); - return (int)(v^(v>>>32)); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof DoubleEncodedValue) { - return Double.doubleToRawLongBits(getValue()) == - Double.doubleToRawLongBits(((DoubleEncodedValue)o).getValue()); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return Double.compare(getValue(), ((DoubleEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.DOUBLE; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseEnumEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseEnumEncodedValue.java deleted file mode 100644 index ea2ec121..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseEnumEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.EnumEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseEnumEncodedValue implements EnumEncodedValue { - @Override - public int hashCode() { - return getValue().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof EnumEncodedValue) { - return getValue().equals(((EnumEncodedValue)o).getValue()); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return getValue().compareTo(((EnumEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.ENUM; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseFieldEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseFieldEncodedValue.java deleted file mode 100644 index 8d4f3d91..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseFieldEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.FieldEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseFieldEncodedValue implements FieldEncodedValue { - @Override - public int hashCode() { - return getValue().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof FieldEncodedValue) { - return getValue().equals(((FieldEncodedValue)o).getValue()); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return getValue().compareTo(((FieldEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.FIELD; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseFloatEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseFloatEncodedValue.java deleted file mode 100644 index 50925679..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseFloatEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.FloatEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseFloatEncodedValue implements FloatEncodedValue { - @Override - public int hashCode() { - return Float.floatToRawIntBits(getValue()); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o != null && o instanceof FloatEncodedValue) { - return Float.floatToRawIntBits(getValue()) == Float.floatToRawIntBits(((FloatEncodedValue)o).getValue()); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return Float.compare(getValue(), ((FloatEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.FLOAT; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseIntEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseIntEncodedValue.java deleted file mode 100644 index 94f7e146..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseIntEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.IntEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseIntEncodedValue implements IntEncodedValue { - @Override - public int hashCode() { - return getValue(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof IntEncodedValue) { - return getValue() == ((IntEncodedValue)o).getValue(); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return Ints.compare(getValue(), ((IntEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.INT; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseLongEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseLongEncodedValue.java deleted file mode 100644 index 8808dda6..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseLongEncodedValue.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import com.google.common.primitives.Longs; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.LongEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseLongEncodedValue implements LongEncodedValue { - @Override - public int hashCode() { - long value = getValue(); - int hashCode = (int)value; - return hashCode*31 + (int)(value>>>32); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof LongEncodedValue) { - return getValue() == ((LongEncodedValue)o).getValue(); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return Longs.compare(getValue(), ((LongEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.LONG; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseMethodEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseMethodEncodedValue.java deleted file mode 100644 index 71492147..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseMethodEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.MethodEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseMethodEncodedValue implements MethodEncodedValue { - @Override - public int hashCode() { - return getValue().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof MethodEncodedValue) { - return getValue().equals(((MethodEncodedValue)o).getValue()); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return getValue().compareTo(((MethodEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.METHOD; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseNullEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseNullEncodedValue.java deleted file mode 100644 index 923619bd..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseNullEncodedValue.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.NullEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseNullEncodedValue implements NullEncodedValue { - @Override - public int hashCode() { - return 0; - } - - @Override - public boolean equals(@Nullable Object o) { - return o instanceof NullEncodedValue; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - return Ints.compare(getValueType(), o.getValueType()); - } - - public int getValueType() { return ValueType.NULL; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseShortEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseShortEncodedValue.java deleted file mode 100644 index 88aabaa8..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseShortEncodedValue.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import com.google.common.primitives.Shorts; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.ShortEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseShortEncodedValue implements ShortEncodedValue { - @Override - public int hashCode() { - return getValue(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof ShortEncodedValue) { - return getValue() == ((ShortEncodedValue)o).getValue(); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return Shorts.compare(getValue(), ((ShortEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.SHORT; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseStringEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseStringEncodedValue.java deleted file mode 100644 index a9bd6cdd..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseStringEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.StringEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseStringEncodedValue implements StringEncodedValue { - @Override - public int hashCode() { - return getValue().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof StringEncodedValue) { - return getValue().equals(((StringEncodedValue)o).getValue()); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return getValue().compareTo(((StringEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.STRING; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseTypeEncodedValue.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseTypeEncodedValue.java deleted file mode 100644 index 80f7399d..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/base/value/BaseTypeEncodedValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.base.value; - -import com.google.common.primitives.Ints; -import org.jf.dexlib2.ValueType; -import org.jf.dexlib2.iface.value.EncodedValue; -import org.jf.dexlib2.iface.value.TypeEncodedValue; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BaseTypeEncodedValue implements TypeEncodedValue { - @Override - public int hashCode() { - return getValue().hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (o instanceof TypeEncodedValue) { - return getValue().equals(((TypeEncodedValue)o).getValue()); - } - return false; - } - - @Override - public int compareTo(@Nonnull EncodedValue o) { - int res = Ints.compare(getValueType(), o.getValueType()); - if (res != 0) return res; - return getValue().compareTo(((TypeEncodedValue)o).getValue()); - } - - public int getValueType() { return ValueType.TYPE; } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderDebugItem.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderDebugItem.java deleted file mode 100644 index 0969a9db..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderDebugItem.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import org.jf.dexlib2.iface.debug.DebugItem; - -import javax.annotation.Nullable; - -public abstract class BuilderDebugItem implements DebugItem { - @Nullable MethodLocation location; - - public BuilderDebugItem() { - } - - @Override public int getCodeAddress() { - if (location == null) { - throw new IllegalStateException("Cannot get the address of a BuilderDebugItem that isn't associated with " + - "a method."); - } - return location.getCodeAddress(); - } - -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderExceptionHandler.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderExceptionHandler.java deleted file mode 100644 index e7376df0..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderExceptionHandler.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import org.jf.dexlib2.base.BaseExceptionHandler; -import org.jf.dexlib2.iface.reference.TypeReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BuilderExceptionHandler extends BaseExceptionHandler { - @Nonnull protected final Label handler; - - private BuilderExceptionHandler(@Nonnull Label handler) { - this.handler = handler; - } - - @Nonnull - public Label getHandler() { - return handler; - } - - static BuilderExceptionHandler newExceptionHandler(@Nullable final TypeReference exceptionType, - @Nonnull Label handler) { - if (exceptionType == null) { - return newExceptionHandler(handler); - } - return new BuilderExceptionHandler(handler) { - @Nullable @Override public String getExceptionType() { - return exceptionType.getType(); - } - - @Override public int getHandlerCodeAddress() { - return handler.getCodeAddress(); - } - - @Nullable @Override public TypeReference getExceptionTypeReference() { - return exceptionType; - } - }; - } - - static BuilderExceptionHandler newExceptionHandler(@Nonnull Label handler) { - return new BuilderExceptionHandler(handler) { - @Nullable @Override public String getExceptionType() { - return null; - } - - @Override public int getHandlerCodeAddress() { - return handler.getCodeAddress(); - } - }; - } - - static BuilderExceptionHandler newExceptionHandler(@Nullable final String exceptionType, - @Nonnull Label handler) { - if (exceptionType == null) { - return newExceptionHandler(handler); - } - return new BuilderExceptionHandler(handler) { - @Nullable @Override public String getExceptionType() { - return exceptionType; - } - - @Override public int getHandlerCodeAddress() { - return handler.getCodeAddress(); - } - }; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderInstruction.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderInstruction.java deleted file mode 100644 index d06f7a8b..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderInstruction.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2012, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import org.jf.dexlib2.Format; -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.iface.instruction.Instruction; -import org.jf.dexlib2.util.Preconditions; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class BuilderInstruction implements Instruction { - @Nonnull protected final Opcode opcode; - - @Nullable MethodLocation location; - - protected BuilderInstruction(@Nonnull Opcode opcode) { - Preconditions.checkFormat(opcode, getFormat()); - this.opcode = opcode; - } - - @Nonnull public Opcode getOpcode() { - return opcode; - } - - public abstract Format getFormat(); - - public int getCodeUnits() { - return getFormat().size / 2; - } - - @Nonnull - public MethodLocation getLocation() { - if (location == null) { - throw new IllegalStateException("Cannot get the location of an instruction that hasn't been added to a " + - "method."); - } - return location; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderOffsetInstruction.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderOffsetInstruction.java deleted file mode 100644 index d75d7b67..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderOffsetInstruction.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.iface.instruction.OffsetInstruction; - -import javax.annotation.Nonnull; - -public abstract class BuilderOffsetInstruction extends BuilderInstruction implements OffsetInstruction { - @Nonnull - protected final Label target; - - public BuilderOffsetInstruction(@Nonnull Opcode opcode, - @Nonnull Label target) { - super(opcode); - this.target = target; - } - - @Override public int getCodeOffset() { - int codeOffset = internalGetCodeOffset(); - if ((this.getCodeUnits() == 1 && (codeOffset < Byte.MIN_VALUE || codeOffset > Byte.MAX_VALUE)) || - (this.getCodeUnits() == 2 && (codeOffset < Short.MIN_VALUE || codeOffset > Short.MAX_VALUE))) { - throw new IllegalStateException("Target is out of range"); - } - return codeOffset; - } - - - int internalGetCodeOffset() { - return target.getCodeAddress() - this.getLocation().getCodeAddress(); - } - - @Nonnull - public Label getTarget() { - return target; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderSwitchPayload.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderSwitchPayload.java deleted file mode 100644 index 2fd490bd..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderSwitchPayload.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.builder.instruction.BuilderSwitchElement; -import org.jf.dexlib2.iface.instruction.SwitchPayload; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.List; - -public abstract class BuilderSwitchPayload extends BuilderInstruction implements SwitchPayload { - @Nullable - MethodLocation referrer; - - protected BuilderSwitchPayload(@Nonnull Opcode opcode) { - super(opcode); - } - - @Nonnull - public MethodLocation getReferrer() { - if (referrer == null) { - throw new IllegalStateException("The referrer has not been set yet"); - } - return referrer; - } - - @Nonnull @Override public abstract List getSwitchElements(); -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderTryBlock.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderTryBlock.java deleted file mode 100644 index f2387888..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/BuilderTryBlock.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import com.google.common.collect.ImmutableList; -import org.jf.dexlib2.base.BaseTryBlock; -import org.jf.dexlib2.iface.reference.TypeReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.List; - -public class BuilderTryBlock extends BaseTryBlock { - // We only ever have one exception handler per try block. They are later merged as needed in TryListBuilder - @Nonnull public final BuilderExceptionHandler exceptionHandler; - @Nonnull public final Label start; - // The end location is exclusive, it should point to the codeAddress of the instruction immediately after the last - // covered instruction. - @Nonnull public final Label end; - - public BuilderTryBlock(@Nonnull Label start, @Nonnull Label end, @Nullable String exceptionType, - @Nonnull Label handler) { - this.start = start; - this.end = end; - this.exceptionHandler = BuilderExceptionHandler.newExceptionHandler(exceptionType, handler); - } - - public BuilderTryBlock(@Nonnull Label start, @Nonnull Label end, @Nullable TypeReference exceptionType, - @Nonnull Label handler) { - this.start = start; - this.end = end; - this.exceptionHandler = BuilderExceptionHandler.newExceptionHandler(exceptionType, handler); - } - - public BuilderTryBlock(@Nonnull Label start, @Nonnull Label end, @Nonnull Label handler) { - this.start = start; - this.end = end; - this.exceptionHandler = BuilderExceptionHandler.newExceptionHandler(handler); - } - - @Override public int getStartCodeAddress() { - return start.getCodeAddress(); - } - - @Override public int getCodeUnitCount() { - return end.getCodeAddress() - start.getCodeAddress(); - } - - @Nonnull @Override public List getExceptionHandlers() { - return ImmutableList.of(exceptionHandler); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/Label.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/Label.java deleted file mode 100644 index ef19f91c..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/Label.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class Label { - @Nullable MethodLocation location; - - Label() { - } - - Label(MethodLocation location) { - this.location = location; - } - - public int getCodeAddress() { - return getLocation().getCodeAddress(); - } - - @Nonnull - public MethodLocation getLocation() { - if (location == null) { - throw new IllegalStateException("Cannot get the location of a label that hasn't been placed yet."); - } - return location; - } - - public boolean isPlaced() { - return location != null; - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodImplementationBuilder.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodImplementationBuilder.java deleted file mode 100644 index e830b655..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodImplementationBuilder.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import org.jf.dexlib2.iface.MethodImplementation; -import org.jf.dexlib2.iface.reference.StringReference; -import org.jf.dexlib2.iface.reference.TypeReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.HashMap; - -public class MethodImplementationBuilder { - // Contains all named labels - both placed and unplaced - private final HashMap labels = new HashMap(); - - @Nonnull - private final MutableMethodImplementation impl; - - private MethodLocation currentLocation; - - public MethodImplementationBuilder(int registerCount) { - this.impl = new MutableMethodImplementation(registerCount); - this.currentLocation = impl.instructionList.get(0); - } - - public MethodImplementation getMethodImplementation() { - return impl; - } - - /** - * Adds a new named label at the current location. - * - * Any previous unplaced references to a label of this name will now refer to this label/location - * - * @param name The name of the label to add - * @return A LabelRef representing the label - */ - @Nonnull - public Label addLabel(@Nonnull String name) { - Label label = labels.get(name); - - if (label != null) { - if (label.isPlaced()) { - throw new IllegalArgumentException("There is already a label with that name."); - } else { - currentLocation.getLabels().add(label); - } - } else { - label = currentLocation.addNewLabel(); - labels.put(name, label); - } - - return label; - } - - /** - * Get a reference to a label with the given name. - * - * If a label with that name has not been added yet, a new one is created, but is left - * in an unplaced state. It is assumed that addLabel(name) will be called at a later - * point to define the location of the label. - * - * @param name The name of the label to get - * @return A LabelRef representing the label - */ - @Nonnull - public Label getLabel(@Nonnull String name) { - Label label = labels.get(name); - if (label == null) { - label = new Label(); - labels.put(name, label); - } - return label; - } - - public void addCatch(@Nullable TypeReference type, @Nonnull Label from, - @Nonnull Label to, @Nonnull Label handler) { - impl.addCatch(type, from, to, handler); - } - - public void addCatch(@Nullable String type, @Nonnull Label from, @Nonnull Label to, - @Nonnull Label handler) { - impl.addCatch(type, from, to, handler); - } - - public void addCatch(@Nonnull Label from, @Nonnull Label to, @Nonnull Label handler) { - impl.addCatch(from, to, handler); - } - - public void addLineNumber(int lineNumber) { - currentLocation.addLineNumber(lineNumber); - } - - public void addStartLocal(int registerNumber, @Nullable StringReference name, @Nullable TypeReference type, - @Nullable StringReference signature) { - currentLocation.addStartLocal(registerNumber, name, type, signature); - } - - public void addEndLocal(int registerNumber) { - currentLocation.addEndLocal(registerNumber); - } - - public void addRestartLocal(int registerNumber) { - currentLocation.addRestartLocal(registerNumber); - } - - public void addPrologue() { - currentLocation.addPrologue(); - } - - public void addEpilogue() { - currentLocation.addEpilogue(); - } - - public void addSetSourceFile(@Nullable StringReference sourceFile) { - currentLocation.addSetSourceFile(sourceFile); - } - - public void addInstruction(@Nullable BuilderInstruction instruction) { - impl.addInstruction(instruction); - currentLocation = impl.instructionList.get(impl.instructionList.size()-1); - } -} diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodLocation.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodLocation.java deleted file mode 100644 index 5a707e92..00000000 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodLocation.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.jf.dexlib2.builder; - -import com.google.common.collect.ImmutableList; -import org.jf.dexlib2.builder.debug.*; -import org.jf.dexlib2.iface.instruction.Instruction; -import org.jf.dexlib2.iface.reference.StringReference; -import org.jf.dexlib2.iface.reference.TypeReference; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.*; - -public class MethodLocation { - @Nullable BuilderInstruction instruction; - int codeAddress; - int index; - - // We end up creating and keeping around a *lot* of MethodLocation objects - // when building a new dex file, so it's worth the trouble of lazily creating - // the labels and debugItems lists only when they are needed - - @Nullable - private List