├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ └── android.yml ├── .gitignore ├── .gitmodules ├── LICENSE.md ├── README.md ├── README_CN.md ├── appveyor.yml ├── art ├── README_CN.png └── README_EN.png ├── build.gradle ├── dalvikdx ├── .gitignore ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── external │ └── com │ └── android │ ├── dex │ ├── Annotation.java │ ├── CallSiteId.java │ ├── ClassData.java │ ├── ClassDef.java │ ├── Code.java │ ├── Dex.java │ ├── DexException.java │ ├── DexFormat.java │ ├── DexIndexOverflowException.java │ ├── EncodedValue.java │ ├── EncodedValueCodec.java │ ├── EncodedValueReader.java │ ├── FieldId.java │ ├── Leb128.java │ ├── MethodHandle.java │ ├── MethodId.java │ ├── Mutf8.java │ ├── ProtoId.java │ ├── SizeOf.java │ ├── TableOfContents.java │ ├── TypeList.java │ └── util │ │ ├── ByteArrayByteInput.java │ │ ├── ByteInput.java │ │ ├── ByteOutput.java │ │ ├── ExceptionWithContext.java │ │ ├── FileUtils.java │ │ └── Unsigned.java │ ├── dx │ ├── Version.java │ ├── cf │ │ ├── attrib │ │ │ ├── AttAnnotationDefault.java │ │ │ ├── AttBootstrapMethods.java │ │ │ ├── AttCode.java │ │ │ ├── AttConstantValue.java │ │ │ ├── AttDeprecated.java │ │ │ ├── AttEnclosingMethod.java │ │ │ ├── AttExceptions.java │ │ │ ├── AttInnerClasses.java │ │ │ ├── AttLineNumberTable.java │ │ │ ├── AttLocalVariableTable.java │ │ │ ├── AttLocalVariableTypeTable.java │ │ │ ├── AttRuntimeInvisibleAnnotations.java │ │ │ ├── AttRuntimeInvisibleParameterAnnotations.java │ │ │ ├── AttRuntimeVisibleAnnotations.java │ │ │ ├── AttRuntimeVisibleParameterAnnotations.java │ │ │ ├── AttSignature.java │ │ │ ├── AttSourceDebugExtension.java │ │ │ ├── AttSourceFile.java │ │ │ ├── AttSynthetic.java │ │ │ ├── BaseAnnotations.java │ │ │ ├── BaseAttribute.java │ │ │ ├── BaseLocalVariables.java │ │ │ ├── BaseParameterAnnotations.java │ │ │ ├── InnerClassList.java │ │ │ ├── RawAttribute.java │ │ │ └── package.html │ │ ├── code │ │ │ ├── BaseMachine.java │ │ │ ├── BasicBlocker.java │ │ │ ├── BootstrapMethodArgumentsList.java │ │ │ ├── BootstrapMethodsList.java │ │ │ ├── ByteBlock.java │ │ │ ├── ByteBlockList.java │ │ │ ├── ByteCatchList.java │ │ │ ├── ByteOps.java │ │ │ ├── BytecodeArray.java │ │ │ ├── ConcreteMethod.java │ │ │ ├── ExecutionStack.java │ │ │ ├── Frame.java │ │ │ ├── LineNumberList.java │ │ │ ├── LocalVariableList.java │ │ │ ├── LocalsArray.java │ │ │ ├── LocalsArraySet.java │ │ │ ├── Machine.java │ │ │ ├── Merger.java │ │ │ ├── OneLocalsArray.java │ │ │ ├── ReturnAddress.java │ │ │ ├── Ropper.java │ │ │ ├── RopperMachine.java │ │ │ ├── SimException.java │ │ │ ├── Simulator.java │ │ │ ├── SwitchList.java │ │ │ ├── ValueAwareMachine.java │ │ │ └── package.html │ │ ├── cst │ │ │ ├── ConstantPoolParser.java │ │ │ ├── ConstantTags.java │ │ │ └── MethodHandleKind.java │ │ ├── direct │ │ │ ├── AnnotationParser.java │ │ │ ├── AttributeFactory.java │ │ │ ├── AttributeListParser.java │ │ │ ├── ClassPathOpener.java │ │ │ ├── CodeObserver.java │ │ │ ├── DirectClassFile.java │ │ │ ├── FieldListParser.java │ │ │ ├── MemberListParser.java │ │ │ ├── MethodListParser.java │ │ │ ├── StdAttributeFactory.java │ │ │ └── package.html │ │ └── iface │ │ │ ├── Attribute.java │ │ │ ├── AttributeList.java │ │ │ ├── ClassFile.java │ │ │ ├── Field.java │ │ │ ├── FieldList.java │ │ │ ├── HasAttribute.java │ │ │ ├── Member.java │ │ │ ├── Method.java │ │ │ ├── MethodList.java │ │ │ ├── ParseException.java │ │ │ ├── ParseObserver.java │ │ │ ├── StdAttributeList.java │ │ │ ├── StdField.java │ │ │ ├── StdFieldList.java │ │ │ ├── StdMember.java │ │ │ ├── StdMethod.java │ │ │ ├── StdMethodList.java │ │ │ └── package.html │ ├── command │ │ ├── Main.java │ │ ├── UsageException.java │ │ ├── annotool │ │ │ ├── AnnotationLister.java │ │ │ └── Main.java │ │ ├── dexer │ │ │ ├── DxContext.java │ │ │ └── Main.java │ │ ├── dump │ │ │ ├── Args.java │ │ │ ├── BaseDumper.java │ │ │ ├── BlockDumper.java │ │ │ ├── ClassDumper.java │ │ │ ├── DotDumper.java │ │ │ ├── Main.java │ │ │ └── SsaDumper.java │ │ ├── findusages │ │ │ ├── FindUsages.java │ │ │ └── Main.java │ │ └── grep │ │ │ ├── Grep.java │ │ │ └── Main.java │ ├── dex │ │ ├── DexOptions.java │ │ ├── cf │ │ │ ├── AttributeTranslator.java │ │ │ ├── CfOptions.java │ │ │ ├── CfTranslator.java │ │ │ ├── CodeStatistics.java │ │ │ ├── OptimizerOptions.java │ │ │ └── package.html │ │ ├── code │ │ │ ├── ArrayData.java │ │ │ ├── BlockAddresses.java │ │ │ ├── CatchBuilder.java │ │ │ ├── CatchHandlerList.java │ │ │ ├── CatchTable.java │ │ │ ├── CodeAddress.java │ │ │ ├── CstInsn.java │ │ │ ├── DalvCode.java │ │ │ ├── DalvInsn.java │ │ │ ├── DalvInsnList.java │ │ │ ├── Dop.java │ │ │ ├── Dops.java │ │ │ ├── FixedSizeInsn.java │ │ │ ├── HighRegisterPrefix.java │ │ │ ├── InsnFormat.java │ │ │ ├── LocalList.java │ │ │ ├── LocalSnapshot.java │ │ │ ├── LocalStart.java │ │ │ ├── MultiCstInsn.java │ │ │ ├── OddSpacer.java │ │ │ ├── OutputCollector.java │ │ │ ├── OutputFinisher.java │ │ │ ├── PositionList.java │ │ │ ├── RopToDop.java │ │ │ ├── RopTranslator.java │ │ │ ├── SimpleInsn.java │ │ │ ├── StdCatchBuilder.java │ │ │ ├── SwitchData.java │ │ │ ├── TargetInsn.java │ │ │ ├── VariableSizeInsn.java │ │ │ ├── ZeroSizeInsn.java │ │ │ └── form │ │ │ │ ├── Form10t.java │ │ │ │ ├── Form10x.java │ │ │ │ ├── Form11n.java │ │ │ │ ├── Form11x.java │ │ │ │ ├── Form12x.java │ │ │ │ ├── Form20t.java │ │ │ │ ├── Form21c.java │ │ │ │ ├── Form21h.java │ │ │ │ ├── Form21s.java │ │ │ │ ├── Form21t.java │ │ │ │ ├── Form22b.java │ │ │ │ ├── Form22c.java │ │ │ │ ├── Form22s.java │ │ │ │ ├── Form22t.java │ │ │ │ ├── Form22x.java │ │ │ │ ├── Form23x.java │ │ │ │ ├── Form30t.java │ │ │ │ ├── Form31c.java │ │ │ │ ├── Form31i.java │ │ │ │ ├── Form31t.java │ │ │ │ ├── Form32x.java │ │ │ │ ├── Form35c.java │ │ │ │ ├── Form3rc.java │ │ │ │ ├── Form45cc.java │ │ │ │ ├── Form4rcc.java │ │ │ │ ├── Form51l.java │ │ │ │ └── SpecialFormat.java │ │ └── file │ │ │ ├── AnnotationItem.java │ │ │ ├── AnnotationSetItem.java │ │ │ ├── AnnotationSetRefItem.java │ │ │ ├── AnnotationUtils.java │ │ │ ├── AnnotationsDirectoryItem.java │ │ │ ├── CallSiteIdItem.java │ │ │ ├── CallSiteIdsSection.java │ │ │ ├── CallSiteItem.java │ │ │ ├── CatchStructs.java │ │ │ ├── ClassDataItem.java │ │ │ ├── ClassDefItem.java │ │ │ ├── ClassDefsSection.java │ │ │ ├── CodeItem.java │ │ │ ├── DebugInfoConstants.java │ │ │ ├── DebugInfoDecoder.java │ │ │ ├── DebugInfoEncoder.java │ │ │ ├── DebugInfoItem.java │ │ │ ├── DexFile.java │ │ │ ├── EncodedArrayItem.java │ │ │ ├── EncodedField.java │ │ │ ├── EncodedMember.java │ │ │ ├── EncodedMethod.java │ │ │ ├── FieldAnnotationStruct.java │ │ │ ├── FieldIdItem.java │ │ │ ├── FieldIdsSection.java │ │ │ ├── HeaderItem.java │ │ │ ├── HeaderSection.java │ │ │ ├── IdItem.java │ │ │ ├── IndexedItem.java │ │ │ ├── Item.java │ │ │ ├── ItemType.java │ │ │ ├── MapItem.java │ │ │ ├── MemberIdItem.java │ │ │ ├── MemberIdsSection.java │ │ │ ├── MethodAnnotationStruct.java │ │ │ ├── MethodHandleItem.java │ │ │ ├── MethodHandlesSection.java │ │ │ ├── MethodIdItem.java │ │ │ ├── MethodIdsSection.java │ │ │ ├── MixedItemSection.java │ │ │ ├── OffsettedItem.java │ │ │ ├── ParameterAnnotationStruct.java │ │ │ ├── ProtoIdItem.java │ │ │ ├── ProtoIdsSection.java │ │ │ ├── Section.java │ │ │ ├── Statistics.java │ │ │ ├── StringDataItem.java │ │ │ ├── StringIdItem.java │ │ │ ├── StringIdsSection.java │ │ │ ├── TypeIdItem.java │ │ │ ├── TypeIdsSection.java │ │ │ ├── TypeListItem.java │ │ │ ├── UniformItemSection.java │ │ │ ├── UniformListItem.java │ │ │ └── ValueEncoder.java │ ├── io │ │ ├── CodeReader.java │ │ ├── DexIndexPrinter.java │ │ ├── IndexType.java │ │ ├── OpcodeInfo.java │ │ ├── Opcodes.java │ │ └── instructions │ │ │ ├── AddressMap.java │ │ │ ├── BaseCodeCursor.java │ │ │ ├── CodeCursor.java │ │ │ ├── CodeInput.java │ │ │ ├── CodeOutput.java │ │ │ ├── DecodedInstruction.java │ │ │ ├── FillArrayDataPayloadDecodedInstruction.java │ │ │ ├── FiveRegisterDecodedInstruction.java │ │ │ ├── FourRegisterDecodedInstruction.java │ │ │ ├── InstructionCodec.java │ │ │ ├── InvokePolymorphicDecodedInstruction.java │ │ │ ├── InvokePolymorphicRangeDecodedInstruction.java │ │ │ ├── OneRegisterDecodedInstruction.java │ │ │ ├── PackedSwitchPayloadDecodedInstruction.java │ │ │ ├── RegisterRangeDecodedInstruction.java │ │ │ ├── ShortArrayCodeInput.java │ │ │ ├── ShortArrayCodeOutput.java │ │ │ ├── SparseSwitchPayloadDecodedInstruction.java │ │ │ ├── ThreeRegisterDecodedInstruction.java │ │ │ ├── TwoRegisterDecodedInstruction.java │ │ │ └── ZeroRegisterDecodedInstruction.java │ ├── merge │ │ ├── CollisionPolicy.java │ │ ├── DexMerger.java │ │ ├── IndexMap.java │ │ ├── InstructionTransformer.java │ │ └── SortableType.java │ ├── rop │ │ ├── annotation │ │ │ ├── Annotation.java │ │ │ ├── AnnotationVisibility.java │ │ │ ├── Annotations.java │ │ │ ├── AnnotationsList.java │ │ │ └── NameValuePair.java │ │ ├── code │ │ │ ├── AccessFlags.java │ │ │ ├── BasicBlock.java │ │ │ ├── BasicBlockList.java │ │ │ ├── ConservativeTranslationAdvice.java │ │ │ ├── CstInsn.java │ │ │ ├── DexTranslationAdvice.java │ │ │ ├── Exceptions.java │ │ │ ├── FillArrayDataInsn.java │ │ │ ├── Insn.java │ │ │ ├── InsnList.java │ │ │ ├── InvokePolymorphicInsn.java │ │ │ ├── LocalItem.java │ │ │ ├── LocalVariableExtractor.java │ │ │ ├── LocalVariableInfo.java │ │ │ ├── PlainCstInsn.java │ │ │ ├── PlainInsn.java │ │ │ ├── RegOps.java │ │ │ ├── RegisterSpec.java │ │ │ ├── RegisterSpecList.java │ │ │ ├── RegisterSpecSet.java │ │ │ ├── Rop.java │ │ │ ├── RopMethod.java │ │ │ ├── Rops.java │ │ │ ├── SourcePosition.java │ │ │ ├── SwitchInsn.java │ │ │ ├── ThrowingCstInsn.java │ │ │ ├── ThrowingInsn.java │ │ │ ├── TranslationAdvice.java │ │ │ └── package.html │ │ ├── cst │ │ │ ├── Constant.java │ │ │ ├── ConstantPool.java │ │ │ ├── CstAnnotation.java │ │ │ ├── CstArray.java │ │ │ ├── CstBaseMethodRef.java │ │ │ ├── CstBoolean.java │ │ │ ├── CstByte.java │ │ │ ├── CstCallSite.java │ │ │ ├── CstCallSiteRef.java │ │ │ ├── CstChar.java │ │ │ ├── CstDouble.java │ │ │ ├── CstEnumRef.java │ │ │ ├── CstFieldRef.java │ │ │ ├── CstFloat.java │ │ │ ├── CstInteger.java │ │ │ ├── CstInterfaceMethodRef.java │ │ │ ├── CstInvokeDynamic.java │ │ │ ├── CstKnownNull.java │ │ │ ├── CstLiteral32.java │ │ │ ├── CstLiteral64.java │ │ │ ├── CstLiteralBits.java │ │ │ ├── CstLong.java │ │ │ ├── CstMemberRef.java │ │ │ ├── CstMethodHandle.java │ │ │ ├── CstMethodRef.java │ │ │ ├── CstNat.java │ │ │ ├── CstProtoRef.java │ │ │ ├── CstShort.java │ │ │ ├── CstString.java │ │ │ ├── CstType.java │ │ │ ├── StdConstantPool.java │ │ │ ├── TypedConstant.java │ │ │ ├── Zeroes.java │ │ │ └── package.html │ │ ├── package-info.java │ │ └── type │ │ │ ├── Prototype.java │ │ │ ├── StdTypeList.java │ │ │ ├── Type.java │ │ │ ├── TypeBearer.java │ │ │ ├── TypeList.java │ │ │ └── package.html │ ├── ssa │ │ ├── BasicRegisterMapper.java │ │ ├── ConstCollector.java │ │ ├── DeadCodeRemover.java │ │ ├── DomFront.java │ │ ├── Dominators.java │ │ ├── EscapeAnalysis.java │ │ ├── InterferenceRegisterMapper.java │ │ ├── LiteralOpUpgrader.java │ │ ├── LocalVariableExtractor.java │ │ ├── LocalVariableInfo.java │ │ ├── MoveParamCombiner.java │ │ ├── NormalSsaInsn.java │ │ ├── Optimizer.java │ │ ├── PhiInsn.java │ │ ├── PhiTypeResolver.java │ │ ├── RegisterMapper.java │ │ ├── SCCP.java │ │ ├── SetFactory.java │ │ ├── SsaBasicBlock.java │ │ ├── SsaConverter.java │ │ ├── SsaInsn.java │ │ ├── SsaMethod.java │ │ ├── SsaRenamer.java │ │ ├── back │ │ │ ├── FirstFitAllocator.java │ │ │ ├── FirstFitLocalCombiningAllocator.java │ │ │ ├── IdenticalBlockCombiner.java │ │ │ ├── InterferenceGraph.java │ │ │ ├── LivenessAnalyzer.java │ │ │ ├── NullRegisterAllocator.java │ │ │ ├── RegisterAllocator.java │ │ │ └── SsaToRop.java │ │ └── package-info.java │ └── util │ │ ├── AnnotatedOutput.java │ │ ├── BitIntSet.java │ │ ├── Bits.java │ │ ├── ByteArray.java │ │ ├── ByteArrayAnnotatedOutput.java │ │ ├── FixedSizeList.java │ │ ├── Hex.java │ │ ├── HexParser.java │ │ ├── IndentingWriter.java │ │ ├── IntIterator.java │ │ ├── IntList.java │ │ ├── IntSet.java │ │ ├── LabeledItem.java │ │ ├── LabeledList.java │ │ ├── ListIntSet.java │ │ ├── MutabilityControl.java │ │ ├── MutabilityException.java │ │ ├── Output.java │ │ ├── ToHuman.java │ │ ├── TwoColumnOutput.java │ │ ├── Warning.java │ │ ├── Writers.java │ │ └── package.html │ └── multidex │ ├── ArchivePathElement.java │ ├── ClassPathElement.java │ ├── ClassReferenceListBuilder.java │ ├── FolderPathElement.java │ ├── MainDexListBuilder.java │ └── Path.java ├── dexmaker ├── .gitignore ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── external │ └── com │ └── android │ └── dx │ ├── AnnotationId.java │ ├── AppDataDirGuesser.java │ ├── BinaryOp.java │ ├── Code.java │ ├── Comparison.java │ ├── Constants.java │ ├── DexMaker.java │ ├── FieldId.java │ ├── Label.java │ ├── Local.java │ ├── MethodId.java │ ├── TypeId.java │ ├── TypeList.java │ ├── UnaryOp.java │ └── stock │ └── ProxyBuilder.java ├── edxp-common ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── elderdrivers │ └── riru │ ├── common │ ├── KeepAll.java │ └── KeepMembers.java │ └── edxp │ ├── _hooker │ ├── impl │ │ ├── HandleBindApp.java │ │ ├── LoadedApkCstr.java │ │ ├── LoadedApkGetCL.java │ │ ├── StartBootstrapServices.java │ │ └── SystemMain.java │ └── yahfa │ │ ├── HandleBindAppHooker.java │ │ ├── LoadedApkConstructorHooker.java │ │ ├── StartBootstrapServicesHooker.java │ │ ├── StartBootstrapServicesHooker11.java │ │ └── SystemMainHooker.java │ ├── art │ ├── ClassLinker.java │ └── Heap.java │ ├── config │ ├── BaseEdxpConfig.java │ ├── BaseHookProvider.java │ └── ConfigManager.java │ ├── core │ ├── BaseEdxpImpl.java │ ├── EdxpImpl.java │ ├── Main.java │ ├── Proxy.java │ ├── ResourcesHook.java │ ├── Yahfa.java │ └── yahfa │ │ └── HookMain.java │ ├── deopt │ ├── InlinedMethodCallers.java │ └── PrebuiltMethodsDeopter.java │ ├── entry │ └── yahfa │ │ ├── AppBootstrapHookInfo.java │ │ ├── SysBootstrapHookInfo.java │ │ └── SysInnerHookInfo.java │ ├── framework │ └── Zygote.java │ ├── hooker │ ├── SliceProviderFix.java │ └── XposedInstallerHooker.java │ ├── proxy │ ├── BaseProxy.java │ ├── BaseRouter.java │ ├── NormalProxy.java │ └── Router.java │ └── util │ ├── ClassLoaderUtils.java │ ├── ClassUtils.java │ ├── DexUtils.java │ ├── FileUtils.java │ ├── Hookers.java │ ├── ProcessUtils.java │ ├── ProxyClassLoader.java │ ├── Unsafe.java │ ├── Utils.java │ └── Versions.java ├── edxp-core ├── .gitignore ├── build.gradle ├── misc │ └── EdXposedUninstaller │ │ ├── EdXposedUninstaller_rec-v3.zip │ │ └── META-INF │ │ └── com │ │ └── google │ │ └── android │ │ ├── update-binary │ │ └── updater-script ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── cpp │ │ ├── CMakeLists.txt │ │ ├── external │ │ ├── CMakeLists.txt │ │ ├── android │ │ │ ├── CMakeLists.txt │ │ │ ├── android-base │ │ │ │ ├── file.cpp │ │ │ │ ├── file.h │ │ │ │ ├── logging.cpp │ │ │ │ ├── logging.h │ │ │ │ ├── macros.h │ │ │ │ ├── off64_t.h │ │ │ │ ├── parseint.h │ │ │ │ ├── strings.cpp │ │ │ │ ├── strings.h │ │ │ │ ├── thread_annotations.h │ │ │ │ ├── threads.cpp │ │ │ │ ├── threads.h │ │ │ │ ├── unique_fd.h │ │ │ │ └── utf8.h │ │ │ ├── android │ │ │ │ └── fdsan.h │ │ │ ├── art │ │ │ │ ├── base │ │ │ │ │ └── macros.h │ │ │ │ └── runtime │ │ │ │ │ └── native │ │ │ │ │ └── native_util.h │ │ │ └── nativehelper │ │ │ │ ├── jni_macros.h │ │ │ │ ├── module_api.h │ │ │ │ ├── nativehelper_utils.h │ │ │ │ └── scoped_local_ref.h │ │ ├── xhook │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ └── xhook.h │ │ │ └── src │ │ │ │ ├── queue.h │ │ │ │ ├── tree.h │ │ │ │ ├── xh_core.c │ │ │ │ ├── xh_core.h │ │ │ │ ├── xh_elf.c │ │ │ │ ├── xh_elf.h │ │ │ │ ├── xh_errno.h │ │ │ │ ├── xh_jni.c │ │ │ │ ├── xh_log.c │ │ │ │ ├── xh_log.h │ │ │ │ ├── xh_util.c │ │ │ │ ├── xh_util.h │ │ │ │ ├── xh_version.c │ │ │ │ ├── xh_version.h │ │ │ │ ├── xhook.c │ │ │ │ └── xhook.h │ │ └── yahfa │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ ├── HookMain.h │ │ │ └── trampoline.h │ │ │ └── src │ │ │ ├── HookMain.c │ │ │ ├── common.h │ │ │ └── trampoline.c │ │ └── main │ │ ├── CMakeLists.txt │ │ ├── include │ │ ├── ByteOrder.h │ │ ├── JNIHelper.h │ │ ├── art │ │ │ └── runtime │ │ │ │ ├── art_method.h │ │ │ │ ├── class_linker.h │ │ │ │ ├── gc │ │ │ │ ├── collector │ │ │ │ │ └── gc_type.h │ │ │ │ ├── gc_cause.h │ │ │ │ └── heap.h │ │ │ │ ├── hidden_api.h │ │ │ │ ├── instrumentation.h │ │ │ │ ├── jni_env_ext.h │ │ │ │ ├── mirror │ │ │ │ └── class.h │ │ │ │ ├── reflection.h │ │ │ │ ├── runtime.h │ │ │ │ └── thread.h │ │ ├── base │ │ │ └── object.h │ │ ├── config.h │ │ ├── dl_util.h │ │ ├── framework │ │ │ └── androidfw │ │ │ │ └── ResourceTypes.h │ │ ├── logging.h │ │ ├── native_util.h │ │ └── utils.h │ │ └── src │ │ ├── config_manager.cpp │ │ ├── config_manager.h │ │ ├── edxp_context.cpp │ │ ├── edxp_context.h │ │ ├── jni │ │ ├── art_class_linker.cpp │ │ ├── art_class_linker.h │ │ ├── art_heap.cpp │ │ ├── art_heap.h │ │ ├── edxp_config_manager.cpp │ │ ├── edxp_config_manager.h │ │ ├── edxp_pending_hooks.cpp │ │ ├── edxp_pending_hooks.h │ │ ├── edxp_resources_hook.cpp │ │ ├── edxp_resources_hook.h │ │ ├── edxp_yahfa.cpp │ │ └── edxp_yahfa.h │ │ ├── main.cpp │ │ ├── native_hook.cpp │ │ ├── native_hook.h │ │ ├── resource_hook.cpp │ │ ├── resource_hook.h │ │ ├── riru_hook.cpp │ │ ├── riru_hook.h │ │ ├── rirud_socket.cpp │ │ └── rirud_socket.h ├── template_override │ ├── EdXposed.apk │ ├── META-INF │ │ └── com │ │ │ └── google │ │ │ └── android │ │ │ ├── update-binary │ │ │ └── updater-script │ ├── README.md │ ├── customize.sh │ ├── post-fs-data.sh │ ├── sepolicy.rule │ ├── service.sh │ ├── system.prop │ ├── uninstall.sh │ ├── util_functions.sh │ ├── verify.sh │ └── zh_CN.sh └── tpl │ └── module.prop.tpl ├── edxp-sandhook ├── .gitignore ├── build.gradle ├── genhookstubs.py ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ ├── elderdrivers │ └── riru │ │ └── edxp │ │ └── sandhook │ │ ├── config │ │ ├── SandHookEdxpConfig.java │ │ └── SandHookProvider.java │ │ ├── core │ │ ├── SandHookEdxpImpl.java │ │ └── SandHookRouter.java │ │ ├── entry │ │ ├── AppBootstrapHookInfo.java │ │ ├── SysBootstrapHookInfo.java │ │ └── SysInnerHookInfo.java │ │ └── hooker │ │ ├── HandleBindAppHooker.java │ │ ├── LoadedApkConstructorHooker.java │ │ ├── StartBootstrapServicesHooker.java │ │ ├── StartBootstrapServicesHooker11.java │ │ └── SystemMainHooker.java │ └── swift │ └── sandhook │ └── xposedcompat │ ├── XposedCompat.java │ ├── hookstub │ ├── CallOriginCallBack.java │ ├── HookMethodEntity.java │ ├── HookStubManager.java │ ├── MethodHookerStubs32.java │ └── MethodHookerStubs64.java │ ├── methodgen │ ├── ErrorCatch.java │ ├── HookMaker.java │ ├── HookerDexMaker.java │ ├── HookerDexMakerNew.java │ └── SandHookXposedBridge.java │ └── utils │ ├── ApplicationUtils.java │ ├── DexLog.java │ └── DexMakerUtils.java ├── edxp-service ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── elderdrivers │ └── riru │ └── edxp │ └── service │ ├── PackageReceiver.java │ └── ServiceProxy.java ├── edxp-yahfa ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── elderdrivers │ └── riru │ └── edxp │ └── yahfa │ ├── config │ ├── YahfaEdxpConfig.java │ └── YahfaHookProvider.java │ ├── core │ ├── YahfaEdxpImpl.java │ └── YahfaRouter.java │ └── dexmaker │ ├── DexLog.java │ ├── DexMakerUtils.java │ ├── DynamicBridge.java │ ├── HookerDexMaker.java │ └── MethodInfo.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── hiddenapi-stubs ├── .gitignore ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ ├── android │ ├── app │ │ ├── ActivityThread.java │ │ ├── ContextImpl.java │ │ └── LoadedApk.java │ ├── content │ │ ├── pm │ │ │ └── PackageParser.java │ │ └── res │ │ │ ├── AssetManager.java │ │ │ ├── CompatibilityInfo.java │ │ │ ├── Resources.java │ │ │ ├── ResourcesImpl.java │ │ │ └── TypedArray.java │ └── os │ │ ├── IServiceManager.java │ │ ├── SELinux.java │ │ └── ServiceManager.java │ ├── com │ └── android │ │ └── internal │ │ ├── os │ │ ├── RuntimeInit.java │ │ └── ZygoteInit.java │ │ └── util │ │ └── XmlUtils.java │ ├── dalvik │ └── system │ │ └── BaseDexClassLoader.java │ └── xposed │ └── dummy │ ├── XResourcesSuperClass.java │ └── XTypedArraySuperClass.java ├── sandhook-annotation ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── swift │ └── sandhook │ └── annotation │ ├── HookClass.java │ ├── HookMethod.java │ ├── HookMethodBackup.java │ ├── HookMode.java │ ├── HookReflectClass.java │ ├── MethodParams.java │ ├── MethodReflectParams.java │ ├── Param.java │ ├── SkipParamCheck.java │ └── ThisObject.java ├── sandhook-hooklib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── cpp │ ├── CMakeLists.txt │ ├── art │ │ ├── art_classlinker.cpp │ │ ├── art_compiler_options.cpp │ │ └── art_method.cpp │ ├── casts │ │ ├── cast_art_method.cpp │ │ └── cast_compiler_options.cpp │ ├── includes │ │ ├── arch.h │ │ ├── arch_base.h │ │ ├── art_classlinker.h │ │ ├── art_compiler_options.h │ │ ├── art_jit.h │ │ ├── art_method.h │ │ ├── art_runtime.h │ │ ├── cast.h │ │ ├── cast_art_method.h │ │ ├── cast_compiler_options.h │ │ ├── dlfcn_nougat.h │ │ ├── elf_util.h │ │ ├── hide_api.h │ │ ├── inst.h │ │ ├── log.h │ │ ├── native_hook.h │ │ ├── never_call.h │ │ ├── offset.h │ │ ├── sandhook.h │ │ ├── trampoline.h │ │ ├── trampoline_manager.h │ │ └── utils.h │ ├── inst │ │ ├── insts_arm32.cpp │ │ └── insts_arm64.cpp │ ├── nativehook │ │ └── native_hook.cpp │ ├── sandhook.cpp │ ├── trampoline │ │ ├── arch │ │ │ ├── arm32.S │ │ │ └── arm64.S │ │ ├── trampoline.cpp │ │ └── trampoline_manager.cpp │ └── utils │ │ ├── dlfcn_nougat.cpp │ │ ├── elf_util.cpp │ │ ├── hide_api.cpp │ │ ├── lock.h │ │ ├── offset.cpp │ │ └── utils.cpp │ ├── java │ └── com │ │ └── swift │ │ └── sandhook │ │ ├── ArtMethodSizeTest.java │ │ ├── ClassNeverCall.java │ │ ├── HookLog.java │ │ ├── PendingHookHandler.java │ │ ├── SandHook.java │ │ ├── SandHookConfig.java │ │ ├── SandHookMethodResolver.java │ │ ├── blacklist │ │ └── HookBlackList.java │ │ ├── utils │ │ ├── ArtDexOptimizer.java │ │ ├── ClassStatusUtils.java │ │ ├── FileUtils.java │ │ ├── ParamWrapper.java │ │ ├── ReflectionUtils.java │ │ └── Unsafe.java │ │ └── wrapper │ │ ├── HookErrorException.java │ │ ├── HookWrapper.java │ │ └── StubMethodsFactory.java │ └── res │ └── values │ └── strings.xml ├── settings.gradle └── xposed-bridge ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src └── main ├── AndroidManifest.xml ├── apacheCommonsLang ├── LICENSE.txt ├── MODIFICATIONS.txt ├── NOTICE.txt ├── RELEASE-NOTES.txt └── external │ └── org │ └── apache │ └── commons │ └── lang3 │ ├── ArrayUtils.java │ ├── CharSequenceUtils.java │ ├── CharUtils.java │ ├── ClassUtils.java │ ├── JavaVersion.java │ ├── ObjectUtils.java │ ├── StringUtils.java │ ├── SystemUtils.java │ ├── Validate.java │ ├── builder │ ├── Builder.java │ ├── CompareToBuilder.java │ ├── EqualsBuilder.java │ ├── HashCodeBuilder.java │ ├── IDKey.java │ ├── ReflectionToStringBuilder.java │ ├── ToStringBuilder.java │ ├── ToStringStyle.java │ └── package.html │ ├── exception │ ├── CloneFailedException.java │ └── package.html │ ├── mutable │ ├── Mutable.java │ ├── MutableInt.java │ └── package.html │ ├── overview.html │ ├── package.html │ ├── reflect │ ├── MemberUtils.java │ ├── MethodUtils.java │ └── package.html │ └── tuple │ ├── ImmutablePair.java │ ├── Pair.java │ └── package.html └── java ├── android ├── app │ ├── AndroidAppHelper.java │ └── package-info.java └── content │ └── res │ ├── XModuleResources.java │ ├── XResForwarder.java │ ├── XResources.java │ └── package-info.java ├── com └── elderdrivers │ └── riru │ └── edxp │ ├── config │ ├── EdXpConfigGlobal.java │ └── EdxpConfig.java │ ├── hook │ └── HookProvider.java │ └── util │ └── MetaDataReader.java ├── de └── robv │ └── android │ └── xposed │ ├── DexCreator.java │ ├── IModuleContext.java │ ├── IXposedHookCmdInit.java │ ├── IXposedHookInitPackageResources.java │ ├── IXposedHookLoadPackage.java │ ├── IXposedHookZygoteInit.java │ ├── IXposedMod.java │ ├── MethodHooker.java │ ├── PendingHooks.java │ ├── SELinuxHelper.java │ ├── XC_MethodHook.java │ ├── XC_MethodReplacement.java │ ├── XSharedPreferences.java │ ├── XposedBridge.java │ ├── XposedHelpers.java │ ├── XposedInit.java │ ├── annotation │ ├── ApiSensitive.java │ └── Level.java │ ├── callbacks │ ├── IXUnhook.java │ ├── XC_InitPackageResources.java │ ├── XC_InitZygote.java │ ├── XC_LayoutInflated.java │ ├── XC_LoadPackage.java │ ├── XCallback.java │ └── package-info.java │ ├── package-info.java │ └── services │ ├── BaseService.java │ ├── BinderService.java │ ├── DirectAccessService.java │ ├── FileResult.java │ ├── ZygoteService.java │ └── package-info.java └── pxb └── android ├── ResConst.java ├── StringItem.java ├── StringItems.java ├── arsc ├── ArscDumper.java ├── ArscParser.java ├── ArscWriter.java ├── BagValue.java ├── Config.java ├── Pkg.java ├── ResEntry.java ├── ResSpec.java ├── Type.java └── Value.java ├── axml ├── Axml.java ├── AxmlParser.java ├── AxmlReader.java ├── AxmlVisitor.java ├── AxmlWriter.java ├── DumpAdapter.java ├── NodeVisitor.java ├── Util.java └── ValueWrapper.java └── package.html /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Declare files that will always have LF line endings on checkout. 5 | META-INF/** text eol=lf 6 | *.prop text eol=lf 7 | *.sh text eol=lf 8 | *.md text eol=lf 9 | update-binary text eol=lf 10 | update-script text eol=lf 11 | 12 | # Denote all files that are truly binary and should not be modified. 13 | *.so binary 14 | *.dex binary 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: 错误反馈 / Bug report / 不使用此模板提交会被close / Your issue will be close if not following this template 4 | title: "[BUG] " 5 | labels: bug 6 | assignees: '' 7 | --- 8 | 9 | 16 | 17 | **什么情况/What happened?** 18 | 19 | 23 | 24 | **Xposed模块列表/Xposed Module List** 25 | 26 | 27 | **Magisk模块列表/Magisk Module List** 28 | 29 | 30 | **版本信息/Versions** 31 | 32 | Android: 33 | 34 | Magisk: 35 | 36 | Riru: 37 | 38 | EdXposed: 39 | 40 | **相关日志/Related Logs** 41 | 42 | 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | .idea 5 | /.idea/caches/build_file_checksums.ser 6 | /.idea/libraries 7 | /.idea/modules.xml 8 | /.idea/workspace.xml 9 | .DS_Store 10 | /build 11 | /captures 12 | /release 13 | .externalNativeBuild 14 | elf-cleaner.sh 15 | 16 | # vscode 17 | .project 18 | .classpath 19 | .settings/ 20 | .vscode/ 21 | 22 | dalvikdx/bin/ 23 | dexmaker/bin/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "edxp-core/src/main/cpp/external/Dobby"] 2 | path = edxp-core/src/main/cpp/external/Dobby 3 | url = https://github.com/jmpews/Dobby.git 4 | -------------------------------------------------------------------------------- /art/README_CN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElderDrivers/EdXposed/8f2308cdde0a8151a2b4b0151c58b203154a8c6f/art/README_CN.png -------------------------------------------------------------------------------- /art/README_EN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElderDrivers/EdXposed/8f2308cdde0a8151a2b4b0151c58b203154a8c6f/art/README_EN.png -------------------------------------------------------------------------------- /dalvikdx/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | dex 3 | -------------------------------------------------------------------------------- /dalvikdx/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | repositories { 4 | jcenter() 5 | } 6 | 7 | android { 8 | compileSdkVersion androidCompileSdkVersion.toInteger() 9 | ndkVersion androidCompileNdkVersion 10 | } 11 | 12 | afterEvaluate { 13 | android.applicationVariants.all { variant -> 14 | def variantNameCapped = variant.name.capitalize() 15 | def variantNameLowered = variant.name.toLowerCase() 16 | 17 | task("copyDex${variantNameCapped}", type: Copy) { 18 | dependsOn "assemble${variantNameCapped}" 19 | def dexOutPath = "${buildDir}/intermediates/dex/${variantNameLowered}/mergeDex${variantNameCapped}" 20 | from (dexOutPath){ 21 | rename("classes.dex", "eddalvikdx.dex") 22 | } 23 | destinationDir file(templateRootPath + "system/framework/") 24 | outputs.upToDateWhen { false } 25 | } 26 | task("makeJar${variantNameCapped}", type: Jar, dependsOn: "assemble${variantNameCapped}") { 27 | dependsOn "assemble${variantNameCapped}" 28 | from "${buildDir}/intermediates/javac/${variantNameLowered}/classes" 29 | baseName "dalvikdx" 30 | outputs.file(archivePath) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /dalvikdx/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dex/DexException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dex; 18 | 19 | import external.com.android.dex.util.ExceptionWithContext; 20 | 21 | /** 22 | * Thrown when there's a format problem reading, writing, or generally 23 | * processing a dex file. 24 | */ 25 | public class DexException extends ExceptionWithContext { 26 | public DexException(String message) { 27 | super(message); 28 | } 29 | 30 | public DexException(Throwable cause) { 31 | super(cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dex/DexIndexOverflowException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dex; 18 | 19 | /** 20 | * Thrown when there's an index overflow writing a dex file. 21 | */ 22 | public final class DexIndexOverflowException extends DexException { 23 | public DexIndexOverflowException(String message) { 24 | super(message); 25 | } 26 | 27 | public DexIndexOverflowException(Throwable cause) { 28 | super(cause); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dex/util/ByteArrayByteInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dex.util; 18 | 19 | public final class ByteArrayByteInput implements ByteInput { 20 | 21 | private final byte[] bytes; 22 | private int position; 23 | 24 | public ByteArrayByteInput(byte... bytes) { 25 | this.bytes = bytes; 26 | } 27 | 28 | @Override 29 | public byte readByte() { 30 | return bytes[position++]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dex/util/ByteInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dex.util; 18 | 19 | /** 20 | * A byte source. 21 | */ 22 | public interface ByteInput { 23 | 24 | /** 25 | * Returns a byte. 26 | * 27 | * @throws IndexOutOfBoundsException if all bytes have been read. 28 | */ 29 | byte readByte(); 30 | } 31 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dex/util/ByteOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dex.util; 18 | 19 | /** 20 | * A byte sink. 21 | */ 22 | public interface ByteOutput { 23 | 24 | /** 25 | * Writes a byte. 26 | * 27 | * @throws IndexOutOfBoundsException if all bytes have been written. 28 | */ 29 | void writeByte(int i); 30 | } 31 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dex/util/Unsigned.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dex.util; 18 | 19 | /** 20 | * Unsigned arithmetic over Java's signed types. 21 | */ 22 | public final class Unsigned { 23 | private Unsigned() {} 24 | 25 | public static int compare(short ushortA, short ushortB) { 26 | if (ushortA == ushortB) { 27 | return 0; 28 | } 29 | int a = ushortA & 0xFFFF; 30 | int b = ushortB & 0xFFFF; 31 | return a < b ? -1 : 1; 32 | } 33 | 34 | public static int compare(int uintA, int uintB) { 35 | if (uintA == uintB) { 36 | return 0; 37 | } 38 | long a = uintA & 0xFFFFFFFFL; 39 | long b = uintB & 0xFFFFFFFFL; 40 | return a < b ? -1 : 1; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx; 18 | 19 | /** 20 | * Version number for dx. 21 | */ 22 | public class Version { 23 | /** {@code non-null;} version string */ 24 | public static final String VERSION = "1.16"; 25 | } 26 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/attrib/AttDeprecated.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.attrib; 18 | 19 | /** 20 | * Attribute class for standard {@code Deprecated} attributes. 21 | */ 22 | public final class AttDeprecated extends BaseAttribute { 23 | /** {@code non-null;} attribute name for attributes of this type */ 24 | public static final String ATTRIBUTE_NAME = "Deprecated"; 25 | 26 | /** 27 | * Constructs an instance. 28 | */ 29 | public AttDeprecated() { 30 | super(ATTRIBUTE_NAME); 31 | } 32 | 33 | /** {@inheritDoc} */ 34 | @Override 35 | public int byteLength() { 36 | return 6; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/attrib/AttLocalVariableTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.attrib; 18 | 19 | import external.com.android.dx.cf.code.LocalVariableList; 20 | 21 | /** 22 | * Attribute class for standard {@code LocalVariableTable} attributes. 23 | */ 24 | public final class AttLocalVariableTable extends BaseLocalVariables { 25 | /** {@code non-null;} attribute name for attributes of this type */ 26 | public static final String ATTRIBUTE_NAME = "LocalVariableTable"; 27 | 28 | /** 29 | * Constructs an instance. 30 | * 31 | * @param localVariables {@code non-null;} list of local variable entries 32 | */ 33 | public AttLocalVariableTable(LocalVariableList localVariables) { 34 | super(ATTRIBUTE_NAME, localVariables); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/attrib/AttLocalVariableTypeTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.attrib; 18 | 19 | import external.com.android.dx.cf.code.LocalVariableList; 20 | 21 | /** 22 | * Attribute class for standard {@code LocalVariableTypeTable} attributes. 23 | */ 24 | public final class AttLocalVariableTypeTable extends BaseLocalVariables { 25 | /** {@code non-null;} attribute name for attributes of this type */ 26 | public static final String ATTRIBUTE_NAME = "LocalVariableTypeTable"; 27 | 28 | /** 29 | * Constructs an instance. 30 | * 31 | * @param localVariables {@code non-null;} list of local variable entries 32 | */ 33 | public AttLocalVariableTypeTable(LocalVariableList localVariables) { 34 | super(ATTRIBUTE_NAME, localVariables); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/attrib/AttSynthetic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.attrib; 18 | 19 | /** 20 | * Attribute class for standard {@code Synthetic} attributes. 21 | */ 22 | public final class AttSynthetic extends BaseAttribute { 23 | /** {@code non-null;} attribute name for attributes of this type */ 24 | public static final String ATTRIBUTE_NAME = "Synthetic"; 25 | 26 | /** 27 | * Constructs an instance. 28 | */ 29 | public AttSynthetic() { 30 | super(ATTRIBUTE_NAME); 31 | } 32 | 33 | /** {@inheritDoc} */ 34 | @Override 35 | public int byteLength() { 36 | return 6; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/attrib/BaseAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.attrib; 18 | 19 | import external.com.android.dx.cf.iface.Attribute; 20 | 21 | /** 22 | * Base implementation of {@link Attribute}, which directly stores 23 | * the attribute name but leaves the rest up to subclasses. 24 | */ 25 | public abstract class BaseAttribute implements Attribute { 26 | /** {@code non-null;} attribute name */ 27 | private final String name; 28 | 29 | /** 30 | * Constructs an instance. 31 | * 32 | * @param name {@code non-null;} attribute name 33 | */ 34 | public BaseAttribute(String name) { 35 | if (name == null) { 36 | throw new NullPointerException("name == null"); 37 | } 38 | 39 | this.name = name; 40 | } 41 | 42 | /** {@inheritDoc} */ 43 | @Override 44 | public String getName() { 45 | return name; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/attrib/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Implementation of containers and utilities for all the standard Java 3 | attribute types.

4 | 5 |

PACKAGES USED: 6 |

11 | 12 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/code/SimException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.code; 18 | 19 | import external.com.android.dex.util.ExceptionWithContext; 20 | 21 | /** 22 | * Exception from simulation. 23 | */ 24 | public class SimException 25 | extends ExceptionWithContext { 26 | public SimException(String message) { 27 | super(message); 28 | } 29 | 30 | public SimException(Throwable cause) { 31 | super(cause); 32 | } 33 | 34 | public SimException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/code/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Implementation of classes having to do with Java simulation, such as 3 | is needed for verification or stack-to-register conversion.

4 | 5 |

PACKAGES USED: 6 |

10 | 11 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/direct/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Implementation of cf.iface.* based on a direct representation 3 | of class files as byte[]s.

4 | 5 |

PACKAGES USED: 6 |

12 | 13 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/iface/Attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.iface; 18 | 19 | /** 20 | * Interface representing attributes of class files (directly or indirectly). 21 | */ 22 | public interface Attribute { 23 | /** 24 | * Get the name of the attribute. 25 | * 26 | * @return {@code non-null;} the name 27 | */ 28 | public String getName(); 29 | 30 | /** 31 | * Get the total length of the attribute in bytes, including the 32 | * header. Since the header is always six bytes, the result of 33 | * this method is always at least {@code 6}. 34 | * 35 | * @return {@code >= 6;} the total length, in bytes 36 | */ 37 | public int byteLength(); 38 | } 39 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/iface/Field.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.iface; 18 | 19 | import external.com.android.dx.rop.cst.TypedConstant; 20 | 21 | /** 22 | * Interface representing fields of class files. 23 | */ 24 | public interface Field 25 | extends Member { 26 | /** 27 | * Get the constant value for this field, if any. This only returns 28 | * non-{@code null} for a {@code static final} field which 29 | * includes a {@code ConstantValue} attribute. 30 | * 31 | * @return {@code null-ok;} the constant value, or {@code null} if this 32 | * field isn't a constant 33 | */ 34 | public TypedConstant getConstantValue(); 35 | } 36 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/iface/HasAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.iface; 18 | 19 | /** 20 | * An element that can have {@link Attribute} 21 | */ 22 | public interface HasAttribute { 23 | 24 | /** 25 | * Get the element {@code attributes} (along with 26 | * {@code attributes_count}). 27 | * 28 | * @return {@code non-null;} the attributes list 29 | */ 30 | public AttributeList getAttributes(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/iface/Method.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.iface; 18 | 19 | import external.com.android.dx.rop.type.Prototype; 20 | 21 | /** 22 | * Interface representing methods of class files. 23 | */ 24 | public interface Method 25 | extends Member 26 | { 27 | /** 28 | * Get the effective method descriptor, which includes, if 29 | * necessary, a first {@code this} parameter. 30 | * 31 | * @return {@code non-null;} the effective method descriptor 32 | */ 33 | public Prototype getEffectiveDescriptor(); 34 | } 35 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/iface/ParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.cf.iface; 18 | 19 | import external.com.android.dex.util.ExceptionWithContext; 20 | 21 | /** 22 | * Exception from parsing. 23 | */ 24 | public class ParseException 25 | extends ExceptionWithContext { 26 | public ParseException(String message) { 27 | super(message); 28 | } 29 | 30 | public ParseException(Throwable cause) { 31 | super(cause); 32 | } 33 | 34 | public ParseException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/cf/iface/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Interfaces and base classes for dealing with class files. This package 3 | doesn't have any parsing but does have basic container implementations.

4 | 5 |

PACKAGES USED: 6 |

10 | 11 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/command/UsageException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.command; 18 | 19 | /** 20 | * Simple exception class used to communicate that the command-line tool 21 | * should print the usage message. 22 | */ 23 | public class UsageException extends RuntimeException { 24 | // This space intentionally left blank. 25 | } 26 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/command/dexer/DxContext.java: -------------------------------------------------------------------------------- 1 | package external.com.android.dx.command.dexer; 2 | 3 | import external.com.android.dx.dex.cf.CodeStatistics; 4 | import external.com.android.dx.dex.cf.OptimizerOptions; 5 | import java.io.IOException; 6 | import java.io.OutputStream; 7 | import java.io.PrintStream; 8 | 9 | /** 10 | * State used by a single invocation of {@link Main}. 11 | */ 12 | public class DxContext { 13 | public final CodeStatistics codeStatistics = new CodeStatistics(); 14 | public final OptimizerOptions optimizerOptions = new OptimizerOptions(); 15 | public final PrintStream out; 16 | public final PrintStream err; 17 | 18 | @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") 19 | final PrintStream noop = new PrintStream(new OutputStream() { 20 | @Override 21 | public void write(int b) throws IOException { 22 | // noop; 23 | } 24 | }); 25 | 26 | public DxContext(OutputStream out, OutputStream err) { 27 | this.out = new PrintStream(out); 28 | this.err = new PrintStream(err); 29 | } 30 | 31 | public DxContext() { 32 | this(System.out, System.err); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/command/findusages/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.command.findusages; 18 | 19 | import external.com.android.dex.Dex; 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.io.PrintWriter; 23 | 24 | public final class Main { 25 | public static void main(String[] args) throws IOException { 26 | String dexFile = args[0]; 27 | String declaredBy = args[1]; 28 | String memberName = args[2]; 29 | 30 | Dex dex = new Dex(new File(dexFile)); 31 | PrintWriter out = new PrintWriter(System.out); 32 | new FindUsages(dex, declaredBy, memberName, out).findUsages(); 33 | out.flush(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/command/grep/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.command.grep; 18 | 19 | import external.com.android.dex.Dex; 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.io.PrintWriter; 23 | import java.util.regex.Pattern; 24 | 25 | public final class Main { 26 | public static void main(String[] args) throws IOException { 27 | String dexFile = args[0]; 28 | String pattern = args[1]; 29 | 30 | Dex dex = new Dex(new File(dexFile)); 31 | int count = new Grep(dex, Pattern.compile(pattern), new PrintWriter(System.out)).grep(); 32 | System.exit((count > 0) ? 0 : 1); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/dex/cf/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Classes for translating Java classfiles into Dalvik classes.

3 | 4 |

PACKAGES USED: 5 |

15 | 16 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/io/instructions/CodeInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.io.instructions; 18 | 19 | import java.io.EOFException; 20 | 21 | /** 22 | * Input stream of code units, for reading in Dalvik bytecode. 23 | */ 24 | public interface CodeInput extends CodeCursor { 25 | /** 26 | * Returns whether there are any more code units to read. This 27 | * is analogous to {@code hasNext()} on an interator. 28 | */ 29 | public boolean hasMore(); 30 | 31 | /** 32 | * Reads a code unit. 33 | */ 34 | public int read() throws EOFException; 35 | 36 | /** 37 | * Reads two code units, treating them as a little-endian {@code int}. 38 | */ 39 | public int readInt() throws EOFException; 40 | 41 | /** 42 | * Reads four code units, treating them as a little-endian {@code long}. 43 | */ 44 | public long readLong() throws EOFException; 45 | } 46 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/merge/CollisionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.merge; 18 | 19 | /** 20 | * What to do when two dex files define the same class. 21 | */ 22 | public enum CollisionPolicy { 23 | 24 | /** 25 | * Keep the class def from the first dex file and discard the def from the 26 | * second dex file. This policy is appropriate for incremental builds. 27 | */ 28 | KEEP_FIRST, 29 | 30 | /** 31 | * Forbid collisions. This policy is appropriate for merging libraries. 32 | */ 33 | FAIL 34 | } 35 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/rop/annotation/AnnotationVisibility.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.rop.annotation; 18 | 19 | import external.com.android.dx.util.ToHuman; 20 | 21 | /** 22 | * Visibility scope of an annotation. 23 | */ 24 | public enum AnnotationVisibility implements ToHuman { 25 | RUNTIME("runtime"), 26 | BUILD("build"), 27 | SYSTEM("system"), 28 | EMBEDDED("embedded"); 29 | 30 | /** {@code non-null;} the human-oriented string representation */ 31 | private final String human; 32 | 33 | /** 34 | * Constructs an instance. 35 | * 36 | * @param human {@code non-null;} the human-oriented string representation 37 | */ 38 | private AnnotationVisibility(String human) { 39 | this.human = human; 40 | } 41 | 42 | /** {@inheritDoc} */ 43 | @Override 44 | public String toHuman() { 45 | return human; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/rop/code/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Classes relating to a register-based opcode system.

3 | 4 |

PACKAGES USED: 5 |

8 | 9 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/rop/cst/CstMethodRef.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.rop.cst; 18 | 19 | /** 20 | * Constants of type {@code CONSTANT_Methodref_info}. 21 | */ 22 | public final class CstMethodRef 23 | extends CstBaseMethodRef { 24 | /** 25 | * Constructs an instance. 26 | * 27 | * @param definingClass {@code non-null;} the type of the defining class 28 | * @param nat {@code non-null;} the name-and-type 29 | */ 30 | public CstMethodRef(CstType definingClass, CstNat nat) { 31 | super(definingClass, nat); 32 | } 33 | 34 | /** {@inheritDoc} */ 35 | @Override 36 | public String typeName() { 37 | return "method"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/rop/cst/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Interfaces and implementation of things related to the constant pool.

3 | 4 |

PACKAGES USED: 5 |

9 | 10 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/rop/type/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Implementation of classes that represent types (classes or primitives).

3 | 4 |

PACKAGES USED: 5 |

8 | 9 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/util/IntIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.util; 18 | 19 | /** 20 | * An iterator for a list of ints. 21 | */ 22 | public interface IntIterator { 23 | 24 | /** 25 | * Checks to see if the iterator has a next value. 26 | * 27 | * @return true if next() will succeed 28 | */ 29 | boolean hasNext(); 30 | 31 | /** 32 | * Returns the next value in the iterator. 33 | * 34 | * @return next value 35 | * @throws java.util.NoSuchElementException if no next element exists 36 | */ 37 | int next(); 38 | } 39 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/util/LabeledItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.util; 18 | 19 | /** 20 | * An item that has an integer label. 21 | */ 22 | public interface LabeledItem { 23 | 24 | /* 25 | * Gets the label of this block. 26 | * 27 | * @return {@code >= 0;} the label 28 | */ 29 | public int getLabel(); 30 | } 31 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/util/MutabilityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.util; 18 | 19 | import external.com.android.dex.util.ExceptionWithContext; 20 | 21 | /** 22 | * Exception due to a mutability problem. 23 | */ 24 | public class MutabilityException 25 | extends ExceptionWithContext { 26 | public MutabilityException(String message) { 27 | super(message); 28 | } 29 | 30 | public MutabilityException(Throwable cause) { 31 | super(cause); 32 | } 33 | 34 | public MutabilityException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/util/ToHuman.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.util; 18 | 19 | /** 20 | * Simple interface for objects that can return a "human" (as opposed to 21 | * a complete but often hard to read) string form. 22 | */ 23 | public interface ToHuman { 24 | /** 25 | * Return the "human" string form of this instance. This is 26 | * generally less "debuggy" than {@code toString()}. 27 | * 28 | * @return {@code non-null;} the human string form 29 | */ 30 | public String toHuman(); 31 | } 32 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/util/Warning.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx.util; 18 | 19 | /** 20 | * Exception which is meant to indicate a non-fatal warning. 21 | */ 22 | public class Warning extends RuntimeException { 23 | /** 24 | * Constructs an instance. 25 | * 26 | * @param message human-oriented message 27 | */ 28 | public Warning(String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/dx/util/package.html: -------------------------------------------------------------------------------- 1 | 2 |

Utility classes for class file access/manipulation.

3 | 4 | -------------------------------------------------------------------------------- /dalvikdx/src/main/java/external/com/android/multidex/ClassPathElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.multidex; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | 22 | /** 23 | * An element of the class path in which class files can be found. 24 | */ 25 | interface ClassPathElement { 26 | 27 | char SEPARATOR_CHAR = '/'; 28 | 29 | /** 30 | * Open a "file" from this {@code ClassPathElement}. 31 | * @param path a '/' separated relative path to the wanted file. 32 | * @return an {@code InputStream} ready to read the requested file. 33 | * @throws IOException if the path can not be found or if an error occurred while opening it. 34 | */ 35 | InputStream open(String path) throws IOException; 36 | 37 | void close() throws IOException; 38 | 39 | Iterable list(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /dexmaker/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | dex 3 | -------------------------------------------------------------------------------- /dexmaker/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | description = "A utility for doing compile or runtime code generation targeting Android's Dalvik VM" 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | 9 | android { 10 | compileSdkVersion androidCompileSdkVersion.toInteger() 11 | ndkVersion androidCompileNdkVersion 12 | } 13 | 14 | dependencies { 15 | compileOnly files(project(":dalvikdx").tasks.getByName("makeJarRelease").outputs) 16 | } 17 | 18 | afterEvaluate { 19 | android.applicationVariants.all { variant -> 20 | def variantNameCapped = variant.name.capitalize() 21 | def variantNameLowered = variant.name.toLowerCase() 22 | 23 | task("copyDex${variantNameCapped}", type: Copy) { 24 | dependsOn "assemble${variantNameCapped}" 25 | def dexOutPath = "${buildDir}/intermediates/dex/${variantNameLowered}/mergeDex${variantNameCapped}" 26 | from (dexOutPath){ 27 | rename("classes.dex", "eddexmaker.dex") 28 | } 29 | destinationDir file(templateRootPath + "system/framework/") 30 | outputs.upToDateWhen { false } 31 | } 32 | task("makeJar${variantNameCapped}", type: Jar, dependsOn: "assemble${variantNameCapped}") { 33 | dependsOn "assemble${variantNameCapped}" 34 | from "${buildDir}/intermediates/javac/${variantNameLowered}/classes" 35 | baseName "dexmaker" 36 | outputs.file(archivePath) 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /dexmaker/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dexmaker/src/main/java/external/com/android/dx/UnaryOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package external.com.android.dx; 18 | 19 | import external.com.android.dx.rop.code.Rop; 20 | import external.com.android.dx.rop.code.Rops; 21 | 22 | /** 23 | * An operation on one value. 24 | */ 25 | public enum UnaryOp { 26 | 27 | /** {@code ~a}. Supports int and long. */ 28 | NOT() { 29 | @Override 30 | Rop rop(TypeId type) { 31 | return Rops.opNot(type.ropType); 32 | } 33 | }, 34 | 35 | /** {@code -a}. Supports int, long, float and double. */ 36 | NEGATE() { 37 | @Override 38 | Rop rop(TypeId type) { 39 | return Rops.opNeg(type.ropType); 40 | } 41 | }; 42 | 43 | abstract Rop rop(TypeId type); 44 | } 45 | -------------------------------------------------------------------------------- /edxp-common/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /edxp-common/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -dontobfuscate 24 | -dontoptimize 25 | -keep class de.robv.android.xposed.** {*;} 26 | -keep class android.** { *; } 27 | 28 | -keep interface com.elderdrivers.riru.common.KeepAll 29 | -keep interface com.elderdrivers.riru.common.KeepMembers 30 | 31 | -keep class * implements com.elderdrivers.riru.common.KeepAll { *; } 32 | -keepclassmembers class * implements com.elderdrivers.riru.common.KeepMembers { *; } -------------------------------------------------------------------------------- /edxp-common/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/common/KeepAll.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.common; 2 | 3 | public interface KeepAll { 4 | } 5 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/common/KeepMembers.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.common; 2 | 3 | public interface KeepMembers { 4 | } 5 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/impl/SystemMain.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp._hooker.impl; 2 | 3 | import com.elderdrivers.riru.edxp.core.Main; 4 | import com.elderdrivers.riru.edxp.deopt.PrebuiltMethodsDeopter; 5 | import com.elderdrivers.riru.edxp.util.Hookers; 6 | 7 | import de.robv.android.xposed.XC_MethodHook; 8 | import de.robv.android.xposed.XposedBridge; 9 | 10 | // system_server initialization 11 | // ed: only support sdk >= 21 for now 12 | public class SystemMain extends XC_MethodHook { 13 | 14 | public static volatile ClassLoader systemServerCL; 15 | 16 | @Override 17 | protected void afterHookedMethod(MethodHookParam param) throws Throwable { 18 | if (XposedBridge.disableHooks) { 19 | return; 20 | } 21 | Hookers.logD("ActivityThread#systemMain() starts"); 22 | try { 23 | // get system_server classLoader 24 | systemServerCL = Thread.currentThread().getContextClassLoader(); 25 | // deopt methods in SYSTEMSERVERCLASSPATH 26 | PrebuiltMethodsDeopter.deoptSystemServerMethods(systemServerCL); 27 | Main.getEdxpImpl().getRouter().startSystemServerHook(); 28 | } catch (Throwable t) { 29 | Hookers.logE("error when hooking systemMain", t); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/HandleBindAppHooker.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp._hooker.yahfa; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp._hooker.impl.HandleBindApp; 5 | 6 | import de.robv.android.xposed.XC_MethodHook; 7 | import de.robv.android.xposed.annotation.ApiSensitive; 8 | import de.robv.android.xposed.annotation.Level; 9 | 10 | @ApiSensitive(Level.LOW) 11 | public class HandleBindAppHooker implements KeepMembers { 12 | 13 | public static String className = "android.app.ActivityThread"; 14 | public static String methodName = "handleBindApplication"; 15 | public static String methodSig = "(Landroid/app/ActivityThread$AppBindData;)V"; 16 | 17 | public static void hook(final Object thiz, final Object bindData) throws Throwable { 18 | final XC_MethodHook methodHook = new HandleBindApp(); 19 | final XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); 20 | param.thisObject = thiz; 21 | param.args = new Object[]{bindData}; 22 | methodHook.callBeforeHookedMethod(param); 23 | if (!param.returnEarly) { 24 | backup(thiz, bindData); 25 | } 26 | methodHook.callAfterHookedMethod(param); 27 | } 28 | 29 | public static void backup(Object thiz, Object bindData) { 30 | } 31 | } -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/StartBootstrapServicesHooker.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp._hooker.yahfa; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp._hooker.impl.StartBootstrapServices; 5 | 6 | import de.robv.android.xposed.XC_MethodHook; 7 | 8 | public class StartBootstrapServicesHooker implements KeepMembers { 9 | public static String className = "com.android.server.SystemServer"; 10 | public static String methodName = "startBootstrapServices"; 11 | public static String methodSig = "()V"; 12 | 13 | public static void hook(Object systemServer) throws Throwable { 14 | final XC_MethodHook methodHook = new StartBootstrapServices(); 15 | final XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); 16 | param.thisObject = systemServer; 17 | param.args = new Object[]{}; 18 | methodHook.callBeforeHookedMethod(param); 19 | if (!param.returnEarly) { 20 | backup(systemServer); 21 | } 22 | methodHook.callAfterHookedMethod(param); 23 | } 24 | 25 | public static void backup(Object systemServer) { 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/StartBootstrapServicesHooker11.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp._hooker.yahfa; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp._hooker.impl.StartBootstrapServices; 5 | 6 | import de.robv.android.xposed.XC_MethodHook; 7 | import de.robv.android.xposed.annotation.ApiSensitive; 8 | import de.robv.android.xposed.annotation.Level; 9 | 10 | @ApiSensitive(Level.LOW) 11 | public class StartBootstrapServicesHooker11 implements KeepMembers { 12 | public static String className = "com.android.server.SystemServer"; 13 | public static String methodName = "startBootstrapServices"; 14 | public static String methodSig = "(Lcom/android/server/utils/TimingsTraceAndSlog;)V"; 15 | 16 | public static void hook(Object systemServer, Object traceAndSlog) throws Throwable { 17 | final XC_MethodHook methodHook = new StartBootstrapServices(); 18 | final XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); 19 | param.thisObject = systemServer; 20 | param.args = new Object[]{traceAndSlog}; 21 | methodHook.callBeforeHookedMethod(param); 22 | if (!param.returnEarly) { 23 | backup(systemServer, traceAndSlog); 24 | } 25 | methodHook.callAfterHookedMethod(param); 26 | } 27 | 28 | public static void backup(Object systemServer, Object traceAndSlog) { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/SystemMainHooker.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp._hooker.yahfa; 2 | 3 | import android.app.ActivityThread; 4 | 5 | import com.elderdrivers.riru.common.KeepMembers; 6 | import com.elderdrivers.riru.edxp._hooker.impl.SystemMain; 7 | 8 | import de.robv.android.xposed.XC_MethodHook; 9 | import de.robv.android.xposed.annotation.ApiSensitive; 10 | import de.robv.android.xposed.annotation.Level; 11 | 12 | @ApiSensitive(Level.LOW) 13 | public class SystemMainHooker implements KeepMembers { 14 | 15 | public static String className = "android.app.ActivityThread"; 16 | public static String methodName = "systemMain"; 17 | public static String methodSig = "()Landroid/app/ActivityThread;"; 18 | 19 | public static ActivityThread hook() throws Throwable { 20 | final XC_MethodHook methodHook = new SystemMain(); 21 | final XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); 22 | param.thisObject = null; 23 | param.args = new Object[]{}; 24 | methodHook.callBeforeHookedMethod(param); 25 | if (!param.returnEarly) { 26 | param.setResult(backup()); 27 | } 28 | methodHook.callAfterHookedMethod(param); 29 | return (ActivityThread) param.getResult(); 30 | } 31 | 32 | public static ActivityThread backup() { 33 | return null; 34 | } 35 | } -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/ClassLinker.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.art; 2 | 3 | import com.elderdrivers.riru.common.KeepAll; 4 | 5 | import java.lang.reflect.Member; 6 | 7 | import de.robv.android.xposed.PendingHooks; 8 | 9 | public class ClassLinker implements KeepAll { 10 | 11 | public static native void setEntryPointsToInterpreter(Member method); 12 | 13 | public static void onPostFixupStaticTrampolines(Class clazz) { 14 | // native flags will be re-set in hooking logic 15 | PendingHooks.hookPendingMethod(clazz); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/Heap.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.art; 2 | 3 | public class Heap { 4 | 5 | public static native int waitForGcToComplete(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/config/BaseEdxpConfig.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.config; 2 | 3 | import android.text.TextUtils; 4 | 5 | public class BaseEdxpConfig implements EdxpConfig { 6 | 7 | @Override 8 | public String getConfigPath(String suffix) { 9 | return ConfigManager.getConfigPath(suffix != null ? suffix : ""); 10 | } 11 | 12 | @Override 13 | public String getDataPathPrefix() { 14 | return ConfigManager.getDataPathPrefix(); 15 | } 16 | 17 | @Override 18 | public String getInstallerPackageName() { 19 | return ConfigManager.getInstallerPackageName(); 20 | } 21 | 22 | @Override 23 | public String getLibSandHookName() { 24 | return ConfigManager.getLibSandHookName(); 25 | } 26 | 27 | @Override 28 | public boolean isResourcesHookEnabled() { 29 | return ConfigManager.isResourcesHookEnabled(); 30 | } 31 | 32 | @Override 33 | public boolean isSELinuxEnforced() { 34 | return ConfigManager.isSELinuxEnforced(); 35 | } 36 | 37 | @Override 38 | public boolean isNoModuleLogEnabled() { 39 | return ConfigManager.isNoModuleLogEnabled(); 40 | } 41 | 42 | @Override 43 | public boolean isBlackWhiteListMode() { 44 | return ConfigManager.isBlackWhiteListEnabled(); 45 | } 46 | 47 | @Override 48 | public String getModulesList() { return ConfigManager.getModulesList(); } 49 | } 50 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/config/BaseHookProvider.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.config; 2 | 3 | import com.elderdrivers.riru.edxp.core.Yahfa; 4 | import com.elderdrivers.riru.edxp.deopt.PrebuiltMethodsDeopter; 5 | import com.elderdrivers.riru.edxp.hook.HookProvider; 6 | 7 | import java.lang.reflect.Member; 8 | 9 | public abstract class BaseHookProvider implements HookProvider { 10 | 11 | @Override 12 | public void unhookMethod(Member method) { 13 | 14 | } 15 | 16 | public Member findMethodNative(Member hookMethod) { 17 | return hookMethod; 18 | } 19 | 20 | public long getMethodId(Member member) { 21 | return 0; 22 | } 23 | 24 | public Object findMethodNative(Class clazz, String methodName, String methodSig) { 25 | return null; 26 | } 27 | 28 | public void deoptMethods(String packageName, ClassLoader classLoader) { 29 | PrebuiltMethodsDeopter.deoptMethods(packageName, classLoader); 30 | } 31 | 32 | @Override 33 | public void deoptMethodNative(Object method) { 34 | 35 | } 36 | 37 | @Override 38 | public boolean initXResourcesNative() { 39 | return false; 40 | } 41 | 42 | @Override 43 | public boolean methodHooked(Member target) { 44 | return Yahfa.isHooked(target); 45 | } 46 | 47 | @Override 48 | public Object invokeOriginalMethod(Member method, long methodId, Object thisObject, Object[] args) throws Throwable { 49 | return null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/BaseEdxpImpl.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.core; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import com.elderdrivers.riru.edxp.proxy.NormalProxy; 6 | import com.elderdrivers.riru.edxp.proxy.Router; 7 | 8 | public abstract class BaseEdxpImpl implements EdxpImpl { 9 | 10 | protected Proxy mNormalProxy; 11 | protected Router mRouter; 12 | 13 | protected boolean mInitialized = false; 14 | 15 | protected void setInitialized() { 16 | mInitialized = true; 17 | } 18 | 19 | @Override 20 | public boolean isInitialized() { 21 | return mInitialized; 22 | } 23 | 24 | @NonNull 25 | @Override 26 | public Proxy getNormalProxy() { 27 | if (mNormalProxy == null) { 28 | mNormalProxy = createNormalProxy(); 29 | } 30 | return mNormalProxy; 31 | } 32 | 33 | @NonNull 34 | @Override 35 | public Router getRouter() { 36 | if (mRouter == null) { 37 | mRouter = createRouter(); 38 | } 39 | return mRouter; 40 | } 41 | 42 | protected Proxy createNormalProxy() { 43 | return new NormalProxy(getRouter()); 44 | } 45 | 46 | protected abstract Router createRouter(); 47 | } 48 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/EdxpImpl.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.core; 2 | 3 | import android.support.annotation.IntDef; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.elderdrivers.riru.common.KeepAll; 7 | import com.elderdrivers.riru.edxp.proxy.Router; 8 | 9 | import java.lang.annotation.Retention; 10 | 11 | import static java.lang.annotation.RetentionPolicy.SOURCE; 12 | 13 | public interface EdxpImpl extends KeepAll { 14 | 15 | int NONE = 0; 16 | int YAHFA = 1; 17 | int SANDHOOK = 2; 18 | 19 | @NonNull 20 | Proxy getNormalProxy(); 21 | 22 | @NonNull 23 | Router getRouter(); 24 | 25 | @Variant 26 | int getVariant(); 27 | 28 | void init(); 29 | 30 | boolean isInitialized(); 31 | 32 | @Retention(SOURCE) 33 | @IntDef({NONE, YAHFA, SANDHOOK}) 34 | @interface Variant { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/Proxy.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.core; 2 | 3 | import com.elderdrivers.riru.common.KeepAll; 4 | 5 | public interface Proxy extends KeepAll { 6 | 7 | boolean init(); 8 | 9 | void forkAndSpecializePre(int uid, int gid, int[] gids, int debugFlags, 10 | int[][] rlimits, int mountExternal, String seInfo, 11 | String niceName, int[] fdsToClose, int[] fdsToIgnore, 12 | boolean startChildZygote, String instructionSet, 13 | String appDataDir); 14 | 15 | void forkAndSpecializePost(int pid, String appDataDir, String niceName); 16 | 17 | void forkSystemServerPre(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits, 18 | long permittedCapabilities, long effectiveCapabilities); 19 | 20 | void forkSystemServerPost(int pid); 21 | } 22 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/ResourcesHook.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.core; 2 | 3 | public class ResourcesHook { 4 | 5 | public static native boolean initXResourcesNative(); 6 | 7 | public static native boolean removeFinalFlagNative(Class clazz); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/Yahfa.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.core; 2 | 3 | import java.lang.reflect.Member; 4 | import java.lang.reflect.Method; 5 | 6 | public class Yahfa { 7 | 8 | public static native boolean backupAndHookNative(Object target, Method hook, Method backup); 9 | 10 | // JNI.ToReflectedMethod() could return either Method or Constructor 11 | public static native Member findMethodNative(Class targetClass, String methodName, String methodSig); 12 | 13 | public static native void init(int sdkVersion); 14 | 15 | // public static native void setMethodNonCompilable(Member member); 16 | 17 | public static native void recordHooked(Member member); 18 | 19 | public static native boolean isHooked(Member member); 20 | 21 | public static native void makeInitializedClassesVisiblyInitialized(long thread, boolean wait); 22 | } 23 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/yahfa/AppBootstrapHookInfo.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.entry.yahfa; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp._hooker.yahfa.HandleBindAppHooker; 5 | import com.elderdrivers.riru.edxp._hooker.yahfa.LoadedApkConstructorHooker; 6 | 7 | public class AppBootstrapHookInfo implements KeepMembers { 8 | public static String[] hookItemNames = { 9 | HandleBindAppHooker.class.getName(), 10 | LoadedApkConstructorHooker.class.getName(), 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/yahfa/SysBootstrapHookInfo.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.entry.yahfa; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp._hooker.yahfa.HandleBindAppHooker; 5 | import com.elderdrivers.riru.edxp._hooker.yahfa.LoadedApkConstructorHooker; 6 | import com.elderdrivers.riru.edxp._hooker.yahfa.SystemMainHooker; 7 | 8 | public class SysBootstrapHookInfo implements KeepMembers { 9 | public static String[] hookItemNames = { 10 | HandleBindAppHooker.class.getName(), 11 | SystemMainHooker.class.getName(), 12 | LoadedApkConstructorHooker.class.getName(), 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/yahfa/SysInnerHookInfo.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.entry.yahfa; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp._hooker.yahfa.StartBootstrapServicesHooker; 5 | import com.elderdrivers.riru.edxp._hooker.yahfa.StartBootstrapServicesHooker11; 6 | import com.elderdrivers.riru.edxp.util.Versions; 7 | 8 | public class SysInnerHookInfo implements KeepMembers { 9 | 10 | public static Class getSysInnerHookerClass() { 11 | return Versions.hasR() ? 12 | StartBootstrapServicesHooker11.class : 13 | StartBootstrapServicesHooker.class; 14 | } 15 | 16 | public static String[] hookItemNames = { 17 | getSysInnerHookerClass().getName() 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/Zygote.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.framework; 2 | 3 | import com.elderdrivers.riru.edxp.util.Utils; 4 | 5 | import de.robv.android.xposed.XposedHelpers; 6 | import de.robv.android.xposed.annotation.ApiSensitive; 7 | import de.robv.android.xposed.annotation.Level; 8 | 9 | @ApiSensitive(Level.LOW) 10 | public class Zygote { 11 | public static void allowFileAcrossFork(String path) { 12 | try { 13 | Class zygote = XposedHelpers.findClass("com.android.internal.os.Zygote", null); 14 | XposedHelpers.callStaticMethod(zygote, "nativeAllowFileAcrossFork", path); 15 | } catch (Throwable throwable) { 16 | Utils.logE("error when allowFileAcrossFork", throwable); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/hooker/SliceProviderFix.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.hooker; 2 | 3 | import android.os.StrictMode; 4 | 5 | import de.robv.android.xposed.XC_MethodHook; 6 | import de.robv.android.xposed.XposedHelpers; 7 | import de.robv.android.xposed.annotation.ApiSensitive; 8 | import de.robv.android.xposed.annotation.Level; 9 | 10 | @ApiSensitive(Level.LOW) 11 | public class SliceProviderFix { 12 | 13 | public static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui"; 14 | 15 | public static void hook() { 16 | XposedHelpers.findAndHookMethod(StrictMode.ThreadPolicy.Builder.class, "build", new XC_MethodHook() { 17 | @Override 18 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable { 19 | XposedHelpers.callMethod(param.thisObject, "permitAll"); 20 | } 21 | }); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/proxy/BaseProxy.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.proxy; 2 | 3 | import com.elderdrivers.riru.edxp.core.Proxy; 4 | 5 | import de.robv.android.xposed.XposedBridge; 6 | 7 | public abstract class BaseProxy implements Proxy { 8 | 9 | protected Router mRouter; 10 | 11 | public BaseProxy(Router router) { 12 | mRouter = router; 13 | } 14 | 15 | @Override 16 | public boolean init() { 17 | return true; 18 | } 19 | 20 | public static void onBlackListed() { 21 | XposedBridge.clearAllCallbacks(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/proxy/Router.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.proxy; 2 | 3 | public interface Router { 4 | 5 | void initResourcesHook(); 6 | 7 | void prepare(boolean isSystem); 8 | 9 | String parsePackageName(String appDataDir); 10 | 11 | void installBootstrapHooks(boolean isSystem); 12 | 13 | void loadModulesSafely(boolean callInitZygote); 14 | 15 | void startBootstrapHook(boolean isSystem); 16 | 17 | void startSystemServerHook(); 18 | 19 | void onEnterChildProcess(); 20 | 21 | void injectConfig(); 22 | } 23 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Hookers.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.util; 2 | 3 | import android.app.AndroidAppHelper; 4 | 5 | public class Hookers { 6 | 7 | public static void logD(String prefix) { 8 | Utils.logD(String.format("%s: pkg=%s, prc=%s", prefix, AndroidAppHelper.currentPackageName(), 9 | AndroidAppHelper.currentProcessName())); 10 | } 11 | 12 | public static void logE(String prefix, Throwable throwable) { 13 | Utils.logE(String.format("%s: pkg=%s, prc=%s", prefix, AndroidAppHelper.currentPackageName(), 14 | AndroidAppHelper.currentProcessName()), throwable); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ProxyClassLoader.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.util; 2 | 3 | public class ProxyClassLoader extends ClassLoader { 4 | 5 | private final ClassLoader mClassLoader; 6 | 7 | public ProxyClassLoader(ClassLoader parentCL, ClassLoader appCL) { 8 | super(parentCL); 9 | mClassLoader = appCL; 10 | } 11 | 12 | @Override 13 | protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { 14 | Class clazz = null; 15 | 16 | try { 17 | clazz = mClassLoader.loadClass(name); 18 | } catch (ClassNotFoundException ignored) { 19 | } 20 | 21 | if (clazz == null) { 22 | clazz = super.loadClass(name, resolve); 23 | if (clazz == null) { 24 | throw new ClassNotFoundException(); 25 | } 26 | } 27 | 28 | return clazz; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Versions.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.util; 2 | 3 | import android.os.Build; 4 | 5 | public class Versions { 6 | 7 | public static boolean hasR() { 8 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R; 9 | } 10 | 11 | public static boolean hasQ() { 12 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /edxp-core/.gitignore: -------------------------------------------------------------------------------- 1 | /.externalNativeBuild 2 | /build 3 | /libs 4 | /obj 5 | /release 6 | /template_override/module.prop 7 | /template_override/en_US.sh 8 | /template_override/system 9 | /template_override/system_x86 10 | /template_override/riru/module.prop.new 11 | *.iml 12 | /.cxx 13 | -------------------------------------------------------------------------------- /edxp-core/misc/EdXposedUninstaller/EdXposedUninstaller_rec-v3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElderDrivers/EdXposed/8f2308cdde0a8151a2b4b0151c58b203154a8c6f/edxp-core/misc/EdXposedUninstaller/EdXposedUninstaller_rec-v3.zip -------------------------------------------------------------------------------- /edxp-core/misc/EdXposedUninstaller/META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | # this is a dummy file, the magic is in update-binary -------------------------------------------------------------------------------- /edxp-core/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | link_libraries("-ffixed-x18") 4 | 5 | add_definitions(-DRIRU_MODULE) 6 | add_definitions(-DRIRU_MODULE_API_VERSION=${RIRU_MODULE_API_VERSION}) 7 | add_definitions(-DRIRU_MODULE_VERSION=${RIRU_MODULE_VERSION}) 8 | add_definitions(-DRIRU_MODULE_VERSION_NAME=${RIRU_MODULE_VERSION_NAME}) 9 | 10 | add_subdirectory(main) 11 | add_subdirectory(external) -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | add_subdirectory(xhook) 4 | add_subdirectory(yahfa) 5 | add_subdirectory(android) 6 | 7 | macro(SET_OPTION option value) 8 | set(${option} ${value} CACHE INTERNAL "" FORCE) 9 | endmacro() 10 | 11 | SET_OPTION(DOBBY_GENERATE_SHARED OFF) 12 | SET_OPTION(Plugin.Android.BionicLinkerRestriction ON) 13 | if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") 14 | SET_OPTION(DOBBY_DEBUG OFF) 15 | endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") 16 | add_subdirectory(Dobby) 17 | target_include_directories(dobby PUBLIC Dobby/include) 18 | target_include_directories(dobby PUBLIC Dobby/builtin-plugin/BionicLinkerRestriction) -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/android/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | set(SRC_LIST 4 | android-base/logging.cpp 5 | android-base/file.cpp 6 | android-base/threads.cpp 7 | android-base/strings.cpp 8 | ) 9 | add_library(android STATIC ${SRC_LIST}) 10 | 11 | target_include_directories(android PUBLIC .) -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/android/android-base/off64_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #pragma once 17 | #if defined(__APPLE__) 18 | /** Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */ 19 | typedef off_t off64_t; 20 | #endif -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/android/android-base/threads.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #if defined(__APPLE__) 20 | #include 21 | #elif defined(__linux__) && !defined(__ANDROID__) 22 | #include 23 | #elif defined(_WIN32) 24 | #include 25 | #endif 26 | namespace android { 27 | namespace base { 28 | uint64_t GetThreadId() { 29 | #if defined(__BIONIC__) 30 | return gettid(); 31 | #elif defined(__APPLE__) 32 | uint64_t tid; 33 | pthread_threadid_np(NULL, &tid); 34 | return tid; 35 | #elif defined(__linux__) 36 | return syscall(__NR_gettid); 37 | #elif defined(_WIN32) 38 | return GetCurrentThreadId(); 39 | #endif 40 | } 41 | } // namespace base 42 | } // namespace android 43 | #if defined(__GLIBC__) 44 | int tgkill(int tgid, int tid, int sig) { 45 | return syscall(__NR_tgkill, tgid, tid, sig); 46 | } 47 | #endif -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/android/android-base/threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #pragma once 17 | #include 18 | namespace android { 19 | namespace base { 20 | uint64_t GetThreadId(); 21 | } 22 | } // namespace android 23 | #if defined(__GLIBC__) 24 | // bionic has this Linux-specifix call, but glibc doesn't. 25 | extern "C" int tgkill(int tgid, int tid, int sig); 26 | #endif -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/android/nativehelper/module_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #pragma once 17 | #ifdef __cplusplus 18 | #define MODULE_API extern "C" 19 | #else 20 | #define MODULE_API 21 | #endif // __cplusplus 22 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/xhook/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -Werror -fvisibility=hidden") 4 | 5 | aux_source_directory(src SRC_LIST) 6 | add_library(xhook STATIC ${SRC_LIST}) 7 | 8 | find_library(log-lib log) 9 | target_link_libraries(xhook ${log-lib}) 10 | target_include_directories(xhook INTERFACE include) -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/xhook/src/xh_log.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-present, iQIYI, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | // 21 | 22 | // Created by caikelun on 2018-04-11. 23 | 24 | #include 25 | #include "xh_log.h" 26 | 27 | android_LogPriority xh_log_priority = ANDROID_LOG_WARN; 28 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/xhook/src/xh_version.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-present, iQIYI, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | // 21 | 22 | // Created by caikelun on 2018-04-11. 23 | 24 | #ifndef XH_VERSION_H 25 | #define XH_VERSION_H 1 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | unsigned int xh_version(); 32 | 33 | const char *xh_version_str(); 34 | 35 | const char *xh_version_str_full(); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/yahfa/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -fvisibility=hidden") 4 | 5 | aux_source_directory(src SRC_LIST) 6 | add_library(yahfa STATIC ${SRC_LIST}) 7 | 8 | find_library(log-lib log) 9 | target_link_libraries(yahfa ${log-lib}) 10 | target_include_directories(yahfa PUBLIC include) -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/yahfa/include/HookMain.h: -------------------------------------------------------------------------------- 1 | #ifndef HOOK_MAIN_H 2 | #define HOOK_MAIN_H 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void Java_lab_galaxy_yahfa_HookMain_init(JNIEnv *env, jclass clazz, jint sdkVersion); 11 | 12 | jobject Java_lab_galaxy_yahfa_HookMain_findMethodNative(JNIEnv *env, jclass clazz, 13 | jclass targetClass, jstring methodName, 14 | jstring methodSig); 15 | 16 | jboolean Java_lab_galaxy_yahfa_HookMain_backupAndHookNative(JNIEnv *env, jclass clazz, 17 | jobject target, jobject hook, 18 | jobject backup); 19 | 20 | void setNonCompilable(void *method); 21 | 22 | void *getArtMethod(JNIEnv *env, jobject jmethod); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif // HOOK_MAIN_H 29 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/yahfa/include/trampoline.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by liuruikai756 on 05/07/2017. 3 | // 4 | 5 | #ifndef YAHFA_TAMPOLINE_H 6 | #define YAHFA_TAMPOLINE_H 7 | 8 | extern int SDKVersion; 9 | extern int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; 10 | 11 | extern unsigned int hookCap; // capacity for trampolines 12 | extern unsigned int hookCount; // current count of used trampolines 13 | 14 | extern unsigned char trampoline[]; 15 | 16 | int doInitHookCap(unsigned int cap); 17 | void setupTrampoline(); 18 | void *genTrampoline(void *hookMethod); 19 | 20 | #define DEFAULT_CAP 1 //size of each trampoline area would be no more than 4k Bytes(one page) 21 | 22 | #endif //YAHFA_TAMPOLINE_H 23 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/external/yahfa/src/common.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by liuruikai756 on 05/07/2017. 3 | // 4 | #include 5 | 6 | #ifndef YAHFA_COMMON_H 7 | #define YAHFA_COMMON_H 8 | 9 | //#define DEBUG 10 | //#define LOG_DISABLED 11 | 12 | #ifdef LOG_DISABLED 13 | #define LOGI(...) 14 | #define LOGW(...) 15 | #define LOGE(...) 16 | #else 17 | #define LOG_TAG "EdXposed" 18 | #ifndef NDEBUG 19 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) 20 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__) 21 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) 22 | #else 23 | #define LOGI(...) 24 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__) 25 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) 26 | #endif // DEBUG 27 | #endif // LOG_DISABLED 28 | 29 | #define pointer_size sizeof(void*) 30 | #define roundUpToPtrSize(v) (v + pointer_size - 1 - ((v + pointer_size - 1) & (pointer_size - 1))) 31 | 32 | #endif //YAHFA_COMMON_H 33 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | set(CMAKE_ANDROID_STL_TYPE c++_static) 4 | 5 | aux_source_directory(src SRC_LIST) 6 | aux_source_directory(src/jni SRC_JNI_LIST) 7 | include_directories(include src) 8 | add_library(riru_edxp SHARED ${SRC_LIST} ${SRC_JNI_LIST}) 9 | 10 | find_package(riru REQUIRED CONFIG) 11 | find_library(log-lib log) 12 | target_link_libraries(riru_edxp yahfa riru::riru xhook android dobby ${log-lib}) -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/ByteOrder.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by solo on 2019/3/24. 3 | // 4 | 5 | #ifndef EDXPOSED_TEMP_BYTEORDER_H 6 | #define EDXPOSED_TEMP_BYTEORDER_H 7 | 8 | #include 9 | 10 | static inline uint32_t android_swap_long(uint32_t v) 11 | { 12 | return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); 13 | } 14 | static inline uint16_t android_swap_short(uint16_t v) 15 | { 16 | return (v<<8) | (v>>8); 17 | } 18 | 19 | #define DEVICE_BYTE_ORDER LITTLE_ENDIAN 20 | #if BYTE_ORDER == DEVICE_BYTE_ORDER 21 | #define dtohl(x) (x) 22 | #define dtohs(x) (x) 23 | #define htodl(x) (x) 24 | #define htods(x) (x) 25 | #else 26 | #define dtohl(x) (android_swap_long(x)) 27 | #define dtohs(x) (android_swap_short(x)) 28 | #define htodl(x) (android_swap_long(x)) 29 | #define htods(x) (android_swap_short(x)) 30 | #endif 31 | #if BYTE_ORDER == LITTLE_ENDIAN 32 | #define fromlel(x) (x) 33 | #define fromles(x) (x) 34 | #define tolel(x) (x) 35 | #define toles(x) (x) 36 | #else 37 | #define fromlel(x) (android_swap_long(x)) 38 | #define fromles(x) (android_swap_short(x)) 39 | #define tolel(x) (android_swap_long(x)) 40 | #define toles(x) (android_swap_short(x)) 41 | #endif 42 | 43 | #endif //EDXPOSED_TEMP_BYTEORDER_H 44 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/art/runtime/art_method.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 双草酸酯 on 12/19/20. 3 | // 4 | 5 | #ifndef EDXPOSED_ART_METHOD_H 6 | #define EDXPOSED_ART_METHOD_H 7 | 8 | #include "jni/edxp_pending_hooks.h" 9 | #include 10 | 11 | namespace art { 12 | namespace art_method { 13 | CREATE_MEM_FUNC_SYMBOL_ENTRY(std::string, PrettyMethod, void *thiz, bool with_signature) { 14 | if (UNLIKELY(thiz == nullptr)) 15 | return "null"; 16 | if (LIKELY(PrettyMethodSym)) 17 | return PrettyMethodSym(thiz, with_signature); 18 | else return "null sym"; 19 | } 20 | 21 | inline static std::string PrettyMethod(void *thiz) { 22 | return PrettyMethod(thiz, true); 23 | } 24 | 25 | static void Setup(void *handle, HookFunType hook_func) { 26 | LOGD("art_method hook setup, handle=%p", handle); 27 | RETRIEVE_MEM_FUNC_SYMBOL(PrettyMethod, "_ZN3art9ArtMethod12PrettyMethodEb"); 28 | } 29 | } 30 | } 31 | 32 | #endif //EDXPOSED_ART_METHOD_H 33 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/art/runtime/instrumentation.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mlgmx on 2021/2/7. 3 | // 4 | 5 | #ifndef EDXPOSED_INSTRUMENTATION_H 6 | #define EDXPOSED_INSTRUMENTATION_H 7 | 8 | #include "base/object.h" 9 | 10 | namespace art { 11 | namespace instrumentation { 12 | 13 | CREATE_MEM_HOOK_STUB_ENTRIES( 14 | "_ZN3art15instrumentation15Instrumentation21UpdateMethodsCodeImplEPNS_9ArtMethodEPKv", 15 | void, UpdateMethodsCode, (void * thiz, void * art_method, const void *quick_code), { 16 | if (UNLIKELY(edxp::isHooked(art_method))) { 17 | LOGD("Skip update method code for hooked method %s", 18 | art_method::PrettyMethod(art_method).c_str()); 19 | return; 20 | } else { 21 | backup(thiz, art_method, quick_code); 22 | } 23 | }); 24 | 25 | static void DisableUpdateHookedMethodsCode(void *handle, HookFunType hook_func) { 26 | edxp::HookSym(handle, hook_func, UpdateMethodsCode); 27 | } 28 | } 29 | } 30 | #endif //EDXPOSED_INSTRUMENTATION_H 31 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/art/runtime/jni_env_ext.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "jni.h" 5 | #include "base/object.h" 6 | 7 | namespace art { 8 | 9 | class JNIEnvExt : edxp::HookedObject { 10 | 11 | private: 12 | CREATE_MEM_FUNC_SYMBOL_ENTRY(jobject, NewLocalRef, void *thiz, void *mirror_ptr) { 13 | return NewLocalRefSym(thiz, mirror_ptr); 14 | } 15 | 16 | CREATE_MEM_FUNC_SYMBOL_ENTRY(void, DeleteLocalRef, void *thiz, jobject obj) { 17 | return DeleteLocalRefSym(thiz, obj); 18 | } 19 | 20 | public: 21 | JNIEnvExt(void *thiz) : HookedObject(thiz) {} 22 | 23 | // @ApiSensitive(Level.MIDDLE) 24 | static void Setup(void *handle, HookFunType hook_func) { 25 | RETRIEVE_MEM_FUNC_SYMBOL(NewLocalRef, "_ZN3art9JNIEnvExt11NewLocalRefEPNS_6mirror6ObjectE"); 26 | RETRIEVE_MEM_FUNC_SYMBOL(DeleteLocalRef, "_ZN3art9JNIEnvExt14DeleteLocalRefEP8_jobject"); 27 | } 28 | 29 | jobject NewLocalRefer(void *mirror_ptr) { 30 | return NewLocalRef(thiz_, mirror_ptr); 31 | } 32 | 33 | void DeleteLocalRef(jobject obj) { 34 | DeleteLocalRef(thiz_, obj); 35 | } 36 | }; 37 | 38 | 39 | } -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/art/runtime/reflection.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mlgmx on 2021/2/7. 3 | // 4 | 5 | #ifndef EDXPOSED_REFLECTION_H 6 | #define EDXPOSED_REFLECTION_H 7 | 8 | #include "base/object.h" 9 | 10 | namespace art { 11 | 12 | CREATE_HOOK_STUB_ENTRIES( 13 | "_ZN3art12VerifyAccessENS_6ObjPtrINS_6mirror6ObjectEEENS0_INS1_5ClassEEEjS5_", 14 | bool, VerifyAccess, 15 | (void * obj, void * declaring_class, uint32_t access_flags, void * calling_class), { 16 | auto calling_desc = art::mirror::Class(calling_class).GetDescriptor(); 17 | if (UNLIKELY(calling_desc.find("de/robv/android/xposed/MethodHooker") != 18 | std::string::npos)) { 19 | return true; 20 | } 21 | return backup(obj, declaring_class, access_flags, calling_class); 22 | }); 23 | 24 | static void PermissiveAccessByReflection(void *handle, HookFunType hook_func) { 25 | edxp::HookSym(handle, hook_func, VerifyAccess); 26 | } 27 | } 28 | #endif //EDXPOSED_REFLECTION_H 29 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/art/runtime/runtime.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | namespace art { 8 | 9 | class Runtime : public edxp::HookedObject { 10 | 11 | private: 12 | inline static Runtime *instance_; 13 | 14 | CREATE_MEM_FUNC_SYMBOL_ENTRY(void, DeoptimizeBootImage, void *thiz) { 15 | if (LIKELY(DeoptimizeBootImageSym)) 16 | DeoptimizeBootImageSym(thiz); 17 | } 18 | 19 | public: 20 | Runtime(void *thiz) : HookedObject(thiz) {} 21 | 22 | static Runtime *Current() { 23 | return instance_; 24 | } 25 | 26 | // @ApiSensitive(Level.LOW) 27 | static void Setup(void *handle, HookFunType hook_func) { 28 | RETRIEVE_MEM_FUNC_SYMBOL(DeoptimizeBootImage, 29 | "_ZN3art7Runtime19DeoptimizeBootImageEv"); 30 | RETRIEVE_FIELD_SYMBOL(instance, "_ZN3art7Runtime9instance_E"); 31 | void * thiz = *reinterpret_cast(instance); 32 | LOGD("_ZN3art7Runtime9instance_E = %p", thiz); 33 | instance_ = new Runtime(thiz); 34 | } 35 | }; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/art/runtime/thread.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace art { 7 | 8 | class Thread : public edxp::HookedObject { 9 | 10 | CREATE_MEM_FUNC_SYMBOL_ENTRY(edxp::ObjPtr, DecodeJObject, void *thiz, jobject obj) { 11 | if (DecodeJObjectSym) 12 | return DecodeJObjectSym(thiz, obj); 13 | else 14 | return {.data=nullptr}; 15 | } 16 | CREATE_FUNC_SYMBOL_ENTRY(void *, CurrentFromGdb) { 17 | if (LIKELY(CurrentFromGdbSym)) 18 | return CurrentFromGdbSym(); 19 | else 20 | return nullptr; 21 | } 22 | 23 | public: 24 | Thread(void *thiz) : HookedObject(thiz) {} 25 | static Thread Current() { 26 | return Thread(CurrentFromGdb()); 27 | } 28 | 29 | static void Setup(void *handle, [[maybe_unused]] HookFunType hook_func) { 30 | RETRIEVE_MEM_FUNC_SYMBOL(DecodeJObject, 31 | "_ZNK3art6Thread13DecodeJObjectEP8_jobject"); 32 | RETRIEVE_FUNC_SYMBOL(CurrentFromGdb, 33 | "_ZN3art6Thread14CurrentFromGdbEv"); 34 | } 35 | 36 | void *DecodeJObject(jobject obj) { 37 | if (LIKELY(thiz_ && DecodeJObjectSym)) { 38 | return DecodeJObject(thiz_, obj).data; 39 | } 40 | return nullptr; 41 | } 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/config.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include "art/base/macros.h" 8 | #include "utils.h" 9 | 10 | namespace edxp { 11 | 12 | //#define LOG_DISABLED 13 | //#define DEBUG 14 | 15 | 16 | inline bool constexpr Is64() { 17 | #if defined(__LP64__) 18 | return true; 19 | #else 20 | return false; 21 | #endif 22 | } 23 | 24 | inline constexpr bool is64 = Is64(); 25 | 26 | #if defined(__LP64__) 27 | # define LP_SELECT(lp32, lp64) lp64 28 | #else 29 | # define LP_SELECT(lp32, lp64) lp32 30 | #endif 31 | 32 | static const auto kEntryClassName = "com.elderdrivers.riru.edxp.core.Main"s; 33 | static const auto kClassLinkerClassName = "com.elderdrivers.riru.edxp.art.ClassLinker"s; 34 | static const auto kSandHookClassName = "com.swift.sandhook.SandHook"s; 35 | static const auto kSandHookNeverCallClassName = "com.swift.sandhook.ClassNeverCall"s; 36 | 37 | static const auto kLibArtName = "libart.so"s; 38 | static const auto kLibFwName = "libandroidfw.so"s; 39 | 40 | static const auto kLibBasePath = 41 | LP_SELECT("/system/lib/"s, 42 | "/system/lib64/"s); 43 | static const auto kLibArtLegacyPath = kLibBasePath + kLibArtName; 44 | static const auto kLibFwPath = kLibBasePath + kLibFwName; 45 | 46 | inline constexpr const char *const BoolToString(bool b) { 47 | return b ? "true" : "false"; 48 | } 49 | } -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/dl_util.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include "logging.h" 6 | 7 | namespace edxp { 8 | 9 | inline static void *DlOpen(const char *file) { 10 | void *handle = dlopen(file, RTLD_LAZY | RTLD_GLOBAL); 11 | if (!handle) { 12 | LOGE("dlopen(%s) failed: %s", file, dlerror()); 13 | } 14 | return handle; 15 | } 16 | 17 | template 18 | inline static T DlSym(void *handle, const char *sym_name) { 19 | if (!handle) { 20 | LOGE("dlsym(%s) failed: handle is null", sym_name); 21 | } 22 | T symbol = reinterpret_cast(dlsym(handle, sym_name)); 23 | if (!symbol) { 24 | LOGE("dlsym(%s) failed: %s", sym_name, dlerror()); 25 | } 26 | return symbol; 27 | } 28 | 29 | class ScopedDlHandle { 30 | 31 | public: 32 | ScopedDlHandle(const char *file) { 33 | handle_ = DlOpen(file); 34 | } 35 | 36 | ~ScopedDlHandle() { 37 | if (handle_) { 38 | dlclose(handle_); 39 | } 40 | } 41 | 42 | void *Get() const { 43 | return handle_; 44 | } 45 | 46 | template 47 | T DlSym(const char *sym_name) const { 48 | return edxp::DlSym(handle_, sym_name); 49 | } 50 | 51 | bool IsValid() const { 52 | return handle_ != nullptr; 53 | } 54 | 55 | private: 56 | void *handle_; 57 | }; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/logging.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOGGING_H 2 | #define _LOGGING_H 3 | 4 | #include 5 | 6 | #ifndef LOG_TAG 7 | #define LOG_TAG "EdXposed" 8 | #endif 9 | 10 | #ifdef LOG_DISABLED 11 | #define LOGD(...) 12 | #define LOGV(...) 13 | #define LOGI(...) 14 | #define LOGW(...) 15 | #define LOGE(...) 16 | #else 17 | #ifndef NDEBUG 18 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) 19 | #else 20 | #define LOGD(...) 21 | #endif 22 | #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__) 23 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) 24 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__) 25 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) 26 | #define PLOGE(fmt, args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno)) 27 | #endif 28 | 29 | #endif // _LOGGING_H 30 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/include/native_util.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma clang diagnostic push 3 | #pragma clang diagnostic ignored "-Wunused-value" 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "JNIHelper.h" 11 | 12 | namespace edxp { 13 | 14 | ALWAYS_INLINE inline void RegisterNativeMethodsInternal(JNIEnv *env, 15 | const char *class_name, 16 | const JNINativeMethod *methods, 17 | jint method_count) { 18 | 19 | ScopedLocalRef clazz(env, 20 | Context::GetInstance()->FindClassFromLoader(env, class_name)); 21 | if (clazz.get() == nullptr) { 22 | LOG(FATAL) << "Couldn't find class: " << class_name; 23 | return; 24 | } 25 | jint jni_result = JNI_RegisterNatives(env, clazz.get(), methods, method_count); 26 | CHECK_EQ(JNI_OK, jni_result); 27 | } 28 | 29 | #define REGISTER_EDXP_NATIVE_METHODS(class_name) \ 30 | RegisterNativeMethodsInternal(env, (class_name), gMethods, arraysize(gMethods)) 31 | 32 | } // namespace edxp 33 | 34 | #pragma clang diagnostic pop -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/art_class_linker.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "art_class_linker.h" 9 | 10 | namespace edxp { 11 | 12 | static std::unordered_set deopted_methods; 13 | 14 | static void ClassLinker_setEntryPointsToInterpreter(JNI_START, jobject method) { 15 | void *reflected_method = getArtMethod(env, method); 16 | if (deopted_methods.count(reflected_method)) { 17 | LOGD("method %p has been deopted before, skip...", reflected_method); 18 | return; 19 | } 20 | LOGD("deoptimizing method: %p", reflected_method); 21 | art::ClassLinker::Current()->SetEntryPointsToInterpreter(reflected_method); 22 | deopted_methods.insert(reflected_method); 23 | LOGD("method deoptimized: %p", reflected_method); 24 | } 25 | 26 | static JNINativeMethod gMethods[] = { 27 | NATIVE_METHOD(ClassLinker, setEntryPointsToInterpreter, "(Ljava/lang/reflect/Member;)V") 28 | }; 29 | 30 | void RegisterArtClassLinker(JNIEnv *env) { 31 | REGISTER_EDXP_NATIVE_METHODS(kClassLinkerClassName.c_str()); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/art_class_linker.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | namespace edxp { 5 | 6 | void RegisterArtClassLinker(JNIEnv *); 7 | 8 | } // namespace edxp 9 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/art_heap.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "art_heap.h" 8 | 9 | namespace edxp { 10 | 11 | 12 | static jint Heap_waitForGcToComplete(JNI_START) { 13 | art::gc::collector::GcType gcType = art::gc::Heap::Current()->WaitForGcToComplete( 14 | art::gc::GcCause::kGcCauseNone, art::Thread::Current().Get()); 15 | return gcType; 16 | } 17 | 18 | static JNINativeMethod gMethods[] = { 19 | NATIVE_METHOD(Heap, waitForGcToComplete, "()I") 20 | }; 21 | 22 | void RegisterArtHeap(JNIEnv *env) { 23 | REGISTER_EDXP_NATIVE_METHODS("com.elderdrivers.riru.edxp.art.Heap"); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/art_heap.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | namespace edxp { 5 | 6 | void RegisterArtHeap(JNIEnv *); 7 | 8 | } // namespace edxp 9 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/edxp_config_manager.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "jni.h" 5 | 6 | namespace edxp { 7 | 8 | void RegisterConfigManagerMethods(JNIEnv *env); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/edxp_pending_hooks.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "jni.h" 5 | 6 | namespace edxp { 7 | 8 | bool IsClassPending(void *); 9 | 10 | void RegisterPendingHooks(JNIEnv *); 11 | 12 | bool isHooked(void* art_method); 13 | 14 | void recordHooked(void* art_method); 15 | 16 | void DonePendingHook(void *clazz); 17 | 18 | bool IsMethodPending(void* art_method); 19 | 20 | } // namespace edxp 21 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/edxp_resources_hook.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "edxp_resources_hook.h" 7 | 8 | namespace edxp { 9 | 10 | static jboolean ResourcesHook_initXResourcesNative(JNI_START) { 11 | return XposedBridge_initXResourcesNative(env, clazz); 12 | } 13 | 14 | // @ApiSensitive(Level.MIDDLE) 15 | static jboolean ResourcesHook_removeFinalFlagNative(JNI_START, jclass target_class) { 16 | if (target_class) { 17 | jclass class_clazz = JNI_FindClass(env, "java/lang/Class"); 18 | jfieldID java_lang_Class_accessFlags = JNI_GetFieldID( 19 | env, class_clazz, "accessFlags", "I"); 20 | jint access_flags = env->GetIntField(target_class, java_lang_Class_accessFlags); 21 | env->SetIntField(target_class, java_lang_Class_accessFlags, access_flags & ~kAccFinal); 22 | return JNI_TRUE; 23 | } 24 | return JNI_FALSE; 25 | } 26 | 27 | static JNINativeMethod gMethods[] = { 28 | NATIVE_METHOD(ResourcesHook, initXResourcesNative, "()Z"), 29 | NATIVE_METHOD(ResourcesHook, removeFinalFlagNative, "(Ljava/lang/Class;)Z"), 30 | }; 31 | 32 | void RegisterEdxpResourcesHook(JNIEnv *env) { 33 | REGISTER_EDXP_NATIVE_METHODS("com.elderdrivers.riru.edxp.core.ResourcesHook"); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/edxp_resources_hook.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "jni.h" 5 | 6 | namespace edxp { 7 | 8 | static constexpr uint32_t kAccFinal = 0x0010; 9 | 10 | void RegisterEdxpResourcesHook(JNIEnv *); 11 | 12 | } // namespace edxp 13 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/jni/edxp_yahfa.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "jni.h" 5 | 6 | namespace edxp { 7 | 8 | void RegisterEdxpYahfa(JNIEnv *); 9 | 10 | } // namespace edxp 11 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/native_hook.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace edxp { 7 | 8 | void InstallInlineHooks(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/resource_hook.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace edxp { 7 | 8 | jboolean XposedBridge_initXResourcesNative(JNIEnv *env, jclass); 9 | 10 | void XResources_rewriteXmlReferencesNative(JNIEnv *env, jclass, 11 | jlong parserPtr, jobject origRes, jobject repRes); 12 | } 13 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/riru_hook.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #define XHOOK_REGISTER(NAME) \ 5 | if (xhook_register(".*", #NAME, (void*) new_##NAME, (void **) &old_##NAME) == 0) { \ 6 | void *f = riru_get_func(#NAME); \ 7 | if (f != nullptr) { \ 8 | memcpy(&old_##NAME, &f, sizeof(void *)); \ 9 | } \ 10 | riru_set_func(#NAME, (void *) new_##NAME); \ 11 | } else { \ 12 | LOGE("failed to register riru hook " #NAME "."); \ 13 | } 14 | 15 | #define NEW_FUNC_DEF(ret, func, ...) \ 16 | static ret (*old_##func)(__VA_ARGS__); \ 17 | static ret new_##func(__VA_ARGS__) 18 | 19 | namespace edxp { 20 | 21 | // @ApiSensitive(Level.HIGH) 22 | static constexpr const char *kPropKeyCompilerFilter = "dalvik.vm.dex2oat-filter"; 23 | static constexpr const char *kPropKeyCompilerFlags = "dalvik.vm.dex2oat-flags"; 24 | static constexpr const char *kPropKeyUseJitProfiles = "dalvik.vm.usejitprofiles"; 25 | static constexpr const char *kPropKeyPmBgDexopt = "pm.dexopt.bg-dexopt"; 26 | 27 | static constexpr const char *kPropValueCompilerFilter = "quicken"; 28 | static constexpr const char *kPropValuePmBgDexopt = "speed"; 29 | static constexpr const char *kPropValueCompilerFlags = "--inline-max-code-units=0"; 30 | static constexpr const char *kPropValueCompilerFlagsWS = " --inline-max-code-units=0"; 31 | 32 | 33 | void InstallRiruHooks(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /edxp-core/src/main/cpp/main/src/rirud_socket.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by loves on 12/2/2020. 3 | // 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | 10 | class RirudSocket { 11 | public: 12 | // class DirIter {}; 13 | 14 | class RirudSocketException : public std::runtime_error { 15 | public: 16 | RirudSocketException(const std::string &what) : std::runtime_error(what) {} 17 | }; 18 | 19 | RirudSocket(); 20 | 21 | std::string ReadFile(const std::filesystem::path &path); 22 | 23 | // DirIter ReadDir(const std::filesystem::path &path); 24 | // DirIter RecursiveReadDir(const std::filesystem::path &path); 25 | 26 | ~RirudSocket(); 27 | 28 | private: 29 | RirudSocket(const RirudSocket &) = delete; 30 | 31 | RirudSocket operator=(const RirudSocket &) = delete; 32 | 33 | 34 | inline static const uint32_t ACTION_READ_FILE = 4; 35 | 36 | template 37 | void Write(const T &); 38 | 39 | template 40 | void Read(T &); 41 | 42 | void Write(const char *buf, size_t len) const; 43 | 44 | void Read(char *buf, size_t len) const; 45 | 46 | int fd_ = -1; 47 | }; 48 | -------------------------------------------------------------------------------- /edxp-core/template_override/EdXposed.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElderDrivers/EdXposed/8f2308cdde0a8151a2b4b0151c58b203154a8c6f/edxp-core/template_override/EdXposed.apk -------------------------------------------------------------------------------- /edxp-core/template_override/META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | ################# 4 | # Initialization 5 | ################# 6 | 7 | umask 022 8 | 9 | # echo before loading util_functions 10 | ui_print() { echo "$1"; } 11 | 12 | require_new_magisk() { 13 | ui_print "*******************************" 14 | ui_print " Please install Magisk v20.4+! " 15 | ui_print "*******************************" 16 | exit 1 17 | } 18 | 19 | ######################### 20 | # Load util_functions.sh 21 | ######################### 22 | 23 | OUTFD=$2 24 | ZIPFILE=$3 25 | 26 | mount /data 2>/dev/null 27 | 28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk 29 | . /data/adb/magisk/util_functions.sh 30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk 31 | 32 | install_module 33 | exit 0 -------------------------------------------------------------------------------- /edxp-core/template_override/META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /edxp-core/template_override/sepolicy.rule: -------------------------------------------------------------------------------- 1 | allow system_server system_server process execmem 2 | allow system_server system_server memprotect mmap_zero -------------------------------------------------------------------------------- /edxp-core/template_override/service.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | MODDIR=${0%/*} 4 | 5 | if [[ -f "${MODDIR}/reboot_twice_flag" ]]; then 6 | rm -f "${MODDIR}/reboot_twice_flag" 7 | reboot 8 | fi -------------------------------------------------------------------------------- /edxp-core/template_override/system.prop: -------------------------------------------------------------------------------- 1 | # TODO ensure quicken is not essential 2 | #dalvik.vm.dex2oat-filter=quicken 3 | dalvik.vm.dex2oat-flags=--inline-max-code-units=0 4 | #dalvik.vm.image-dex2oat-flags=--inline-max-code-units=0 --compiler-filter=speed 5 | -------------------------------------------------------------------------------- /edxp-core/template_override/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | MODDIR=${0%/*} 4 | 5 | rm -rf /data/misc/riru/modules/edxp 6 | if [[ -f "/data/adb/riru/modules/edxp.prop" ]]; then 7 | OLD_CONFIG=$(cat "/data/adb/riru/modules/edxp.prop") 8 | rm -rf "/data/adb/riru/modules/${OLD_CONFIG}" 9 | rm "/data/adb/riru/modules/edxp.prop" 10 | fi 11 | if [[ -f "/data/misc/riru/modules/edxp.prop" ]]; then 12 | OLD_CONFIG=$(cat "/data/misc/riru/modules/edxp.prop") 13 | rm -rf "/data/misc/riru/modules/${OLD_CONFIG}" 14 | rm "/data/misc/riru/modules/edxp.prop" 15 | fi 16 | -------------------------------------------------------------------------------- /edxp-core/template_override/verify.sh: -------------------------------------------------------------------------------- 1 | TMPDIR_FOR_VERIFY="$TMPDIR/.vunzip" 2 | mkdir "$TMPDIR_FOR_VERIFY" 3 | 4 | abort_verify() { 5 | ui_print "*********************************************************" 6 | ui_print "! $1" 7 | ui_print "! ${LANG_VERIFY_ERR_NOTICE}" 8 | abort "*********************************************************" 9 | } 10 | 11 | # extract 12 | extract() { 13 | zip=$1 14 | file=$2 15 | dir=$3 16 | junk_paths=$4 17 | [ -z "$junk_paths" ] && junk_paths=false 18 | opts="-o" 19 | [ $junk_paths = true ] && opts="-oj" 20 | 21 | file_path="" 22 | hash_path="" 23 | if [ $junk_paths = true ]; then 24 | file_path="$dir/$(basename "$file")" 25 | hash_path="$TMPDIR_FOR_VERIFY/$(basename "$file").s" 26 | else 27 | file_path="$dir/$file" 28 | hash_path="$TMPDIR_FOR_VERIFY/$file.s" 29 | fi 30 | 31 | unzip $opts "$zip" "$file" -d "$dir" >&2 32 | [ -f "$file_path" ] || abort_verify "$file ${LANG_VERIFY_ERR_NOT_EXIST}" 33 | 34 | unzip $opts "$zip" "$file.s" -d "$TMPDIR_FOR_VERIFY" >&2 35 | [ -f "$hash_path" ] || abort_verify "$file.s ${LANG_VERIFY_ERR_NOT_EXIST}" 36 | 37 | (echo "$(cat "$hash_path") $file_path" | sha256sum -c -s -) || abort_verify "${LANG_VERIFY_ERR_MISMATCH} $file" 38 | ui_print "- ${LANG_VERIFY_SUCCESS} $file" >&1 39 | } -------------------------------------------------------------------------------- /edxp-core/tpl/module.prop.tpl: -------------------------------------------------------------------------------- 1 | id=${moduleId} 2 | name=Riru - EdXposed 3 | version=${versionName} 4 | versionCode=${versionCode} 5 | author=${authorList} 6 | api=${apiCode} 7 | description=Another enhanced implementation of Xposed Framework. Supports Android 8.0, 8.1, 9, 10, 11 or above. Requires Riru v23 or above installed. Telegram: @EdXposed 8 | minApi=${minApi} -------------------------------------------------------------------------------- /edxp-sandhook/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /template_override/system/framework -------------------------------------------------------------------------------- /edxp-sandhook/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -dontoptimize 24 | -dontobfuscate 25 | -keep class de.robv.android.xposed.** {*;} 26 | -keep class android.** { *; } 27 | 28 | -keep interface com.elderdrivers.riru.common.KeepAll 29 | -keep interface com.elderdrivers.riru.common.KeepMembers 30 | 31 | -keep class * implements com.elderdrivers.riru.common.KeepAll { *; } 32 | -keepclassmembers class * implements com.elderdrivers.riru.common.KeepMembers { *; } 33 | 34 | -keep class com.swift.sandhook.** {*;} 35 | 36 | -keepclasseswithmembers class * { 37 | native ; 38 | } -------------------------------------------------------------------------------- /edxp-sandhook/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/config/SandHookEdxpConfig.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.sandhook.config; 2 | 3 | import com.elderdrivers.riru.edxp.config.BaseEdxpConfig; 4 | 5 | public class SandHookEdxpConfig extends BaseEdxpConfig { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/core/SandHookEdxpImpl.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.sandhook.core; 2 | 3 | import android.os.Build; 4 | 5 | import com.elderdrivers.riru.edxp.core.BaseEdxpImpl; 6 | import com.elderdrivers.riru.edxp.core.EdxpImpl; 7 | import com.elderdrivers.riru.edxp.core.Main; 8 | import com.elderdrivers.riru.edxp.core.Yahfa; 9 | import com.swift.sandhook.xposedcompat.methodgen.SandHookXposedBridge; 10 | 11 | public class SandHookEdxpImpl extends BaseEdxpImpl { 12 | 13 | static { 14 | final EdxpImpl edxpImpl = new SandHookEdxpImpl(); 15 | if (Main.setEdxpImpl(edxpImpl)) { 16 | edxpImpl.init(); 17 | } 18 | } 19 | 20 | @Override 21 | protected com.elderdrivers.riru.edxp.proxy.Router createRouter() { 22 | return new SandHookRouter(); 23 | } 24 | 25 | @Variant 26 | @Override 27 | public int getVariant() { 28 | return SANDHOOK; 29 | } 30 | 31 | @Override 32 | public void init() { 33 | Yahfa.init(Build.VERSION.SDK_INT); 34 | getRouter().injectConfig(); 35 | SandHookXposedBridge.init(); 36 | setInitialized(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/entry/AppBootstrapHookInfo.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.sandhook.entry; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp.sandhook.hooker.HandleBindAppHooker; 5 | import com.elderdrivers.riru.edxp.sandhook.hooker.LoadedApkConstructorHooker; 6 | 7 | public class AppBootstrapHookInfo implements KeepMembers { 8 | public static String[] hookItemNames = { 9 | HandleBindAppHooker.class.getName(), 10 | LoadedApkConstructorHooker.class.getName(), 11 | }; 12 | 13 | public static Class[] hookItems = { 14 | HandleBindAppHooker.class, 15 | LoadedApkConstructorHooker.class, 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/entry/SysBootstrapHookInfo.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.sandhook.entry; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp.sandhook.hooker.HandleBindAppHooker; 5 | import com.elderdrivers.riru.edxp.sandhook.hooker.LoadedApkConstructorHooker; 6 | import com.elderdrivers.riru.edxp.sandhook.hooker.SystemMainHooker; 7 | 8 | public class SysBootstrapHookInfo implements KeepMembers { 9 | public static String[] hookItemNames = { 10 | HandleBindAppHooker.class.getName(), 11 | SystemMainHooker.class.getName(), 12 | LoadedApkConstructorHooker.class.getName() 13 | }; 14 | 15 | public static Class[] hookItems = { 16 | HandleBindAppHooker.class, 17 | SystemMainHooker.class, 18 | LoadedApkConstructorHooker.class, 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/entry/SysInnerHookInfo.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.sandhook.entry; 2 | 3 | import com.elderdrivers.riru.common.KeepMembers; 4 | import com.elderdrivers.riru.edxp.sandhook.hooker.StartBootstrapServicesHooker; 5 | import com.elderdrivers.riru.edxp.sandhook.hooker.StartBootstrapServicesHooker11; 6 | import com.elderdrivers.riru.edxp.util.Versions; 7 | 8 | public class SysInnerHookInfo implements KeepMembers { 9 | 10 | public static Class getSysInnerHookerClass() { 11 | return Versions.hasR() ? 12 | StartBootstrapServicesHooker11.class : 13 | StartBootstrapServicesHooker.class; 14 | } 15 | 16 | public static String[] hookItemNames = { 17 | getSysInnerHookerClass().getName() 18 | }; 19 | 20 | public static Class[] hookItems = { 21 | getSysInnerHookerClass() 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/hookstub/CallOriginCallBack.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.xposedcompat.hookstub; 2 | 3 | public interface CallOriginCallBack { 4 | long call(long... args) throws Throwable; 5 | } 6 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/methodgen/ErrorCatch.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.xposedcompat.methodgen; 2 | 3 | import android.util.Log; 4 | 5 | import com.swift.sandhook.SandHook; 6 | import com.swift.sandhook.xposedcompat.XposedCompat; 7 | 8 | import java.lang.reflect.Member; 9 | import java.lang.reflect.Method; 10 | 11 | public class ErrorCatch { 12 | 13 | public static Object callOriginError(Member originMethod, Method backupMethod, Object thiz, Object[] args) throws Throwable { 14 | if (XposedCompat.retryWhenCallOriginError) { 15 | Log.w("SandHook", "method <" + originMethod.toString() + "> use invoke to call origin!"); 16 | return SandHook.callOriginMethod(originMethod, backupMethod, thiz, args); 17 | } else { 18 | return null; 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/methodgen/HookMaker.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.xposedcompat.methodgen; 2 | 3 | import java.lang.reflect.Member; 4 | import java.lang.reflect.Method; 5 | 6 | import de.robv.android.xposed.XposedBridge; 7 | 8 | public interface HookMaker { 9 | void start(Member member, XposedBridge.AdditionalHookInfo hookInfo, 10 | ClassLoader appClassLoader) throws Exception; 11 | Method getHookMethod(); 12 | Method getBackupMethod(); 13 | Method getCallBackupMethod(); 14 | } 15 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/utils/ApplicationUtils.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.xposedcompat.utils; 2 | 3 | import android.app.Application; 4 | 5 | import java.lang.reflect.Method; 6 | 7 | public class ApplicationUtils { 8 | 9 | private static Class classActivityThread; 10 | private static Method currentApplicationMethod; 11 | 12 | static Application application; 13 | 14 | public static Application currentApplication() { 15 | if (application != null) 16 | return application; 17 | if (currentApplicationMethod == null) { 18 | try { 19 | classActivityThread = Class.forName("android.app.ActivityThread"); 20 | currentApplicationMethod = classActivityThread.getDeclaredMethod("currentApplication"); 21 | } catch (Exception e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | if (currentApplicationMethod == null) 26 | return null; 27 | try { 28 | application = (Application) currentApplicationMethod.invoke(null); 29 | } catch (Exception e) { 30 | } 31 | return application; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/utils/DexLog.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.xposedcompat.utils; 2 | 3 | import android.util.Log; 4 | 5 | import com.elderdrivers.riru.edxp.sandhook.BuildConfig; 6 | 7 | import java.lang.reflect.Member; 8 | 9 | 10 | public class DexLog { 11 | 12 | public static final String TAG = "SandXposed"; 13 | 14 | public static volatile boolean DEBUG = BuildConfig.DEBUG; 15 | 16 | public static int v(String s) { 17 | return Log.v(TAG, s); 18 | } 19 | 20 | public static int i(String s) { 21 | return Log.i(TAG, s); 22 | } 23 | 24 | public static int d(String s) { 25 | if (DEBUG) { 26 | return Log.d(TAG, s); 27 | } else { 28 | return 0; 29 | } 30 | } 31 | 32 | public static void printMethodHookIn(Member member) { 33 | if (DEBUG && member != null) { 34 | Log.d("SandHook", "method <" + member.toString() + "> hook in"); 35 | } 36 | } 37 | 38 | public static void printCallOriginError(Member member) { 39 | Log.e("SandHook", "method <" + member.toString() + "> call origin error!"); 40 | } 41 | 42 | public static int w(String s) { 43 | return Log.w(TAG, s); 44 | } 45 | 46 | public static int e(String s) { 47 | return Log.e(TAG, s); 48 | } 49 | 50 | public static int e(String s, Throwable t) { 51 | return Log.e(TAG, s, t); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /edxp-service/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /template_override/system/framework -------------------------------------------------------------------------------- /edxp-service/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -dontoptimize 24 | -dontobfuscate 25 | 26 | -keep interface com.elderdrivers.riru.common.KeepAll 27 | -keep interface com.elderdrivers.riru.common.KeepMembers 28 | 29 | -keep class * implements com.elderdrivers.riru.common.KeepAll { *; } 30 | -keepclassmembers class * implements com.elderdrivers.riru.common.KeepMembers { *; } 31 | 32 | -keepclasseswithmembers class * { 33 | native ; 34 | } 35 | -------------------------------------------------------------------------------- /edxp-service/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /edxp-yahfa/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /template_override/system/framework -------------------------------------------------------------------------------- /edxp-yahfa/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -dontoptimize 24 | -dontobfuscate 25 | -keep class de.robv.android.xposed.** {*;} 26 | -keep class android.** { *; } 27 | 28 | -keep interface com.elderdrivers.riru.common.KeepAll 29 | -keep interface com.elderdrivers.riru.common.KeepMembers 30 | 31 | -keep class * implements com.elderdrivers.riru.common.KeepAll { *; } 32 | -keepclassmembers class * implements com.elderdrivers.riru.common.KeepMembers { *; } 33 | 34 | -keepclasseswithmembers class * { 35 | native ; 36 | } 37 | -------------------------------------------------------------------------------- /edxp-yahfa/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /edxp-yahfa/src/main/java/com/elderdrivers/riru/edxp/yahfa/config/YahfaEdxpConfig.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.yahfa.config; 2 | 3 | import com.elderdrivers.riru.edxp.config.BaseEdxpConfig; 4 | 5 | public class YahfaEdxpConfig extends BaseEdxpConfig { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /edxp-yahfa/src/main/java/com/elderdrivers/riru/edxp/yahfa/core/YahfaEdxpImpl.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.yahfa.core; 2 | 3 | import android.os.Build; 4 | 5 | import com.elderdrivers.riru.edxp.core.BaseEdxpImpl; 6 | import com.elderdrivers.riru.edxp.core.EdxpImpl; 7 | import com.elderdrivers.riru.edxp.core.Main; 8 | import com.elderdrivers.riru.edxp.core.Proxy; 9 | import com.elderdrivers.riru.edxp.core.Yahfa; 10 | import com.elderdrivers.riru.edxp.proxy.NormalProxy; 11 | import com.elderdrivers.riru.edxp.proxy.Router; 12 | 13 | public class YahfaEdxpImpl extends BaseEdxpImpl { 14 | 15 | static { 16 | final EdxpImpl edxpImpl = new YahfaEdxpImpl(); 17 | if (Main.setEdxpImpl(edxpImpl)) { 18 | edxpImpl.init(); 19 | } 20 | } 21 | 22 | @Variant 23 | @Override 24 | public int getVariant() { 25 | return YAHFA; 26 | } 27 | 28 | @Override 29 | public void init() { 30 | Yahfa.init(Build.VERSION.SDK_INT); 31 | getRouter().injectConfig(); 32 | setInitialized(); 33 | } 34 | 35 | @Override 36 | protected Proxy createNormalProxy() { 37 | return new NormalProxy(getRouter()); 38 | } 39 | 40 | @Override 41 | protected Router createRouter() { 42 | return new YahfaRouter(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /edxp-yahfa/src/main/java/com/elderdrivers/riru/edxp/yahfa/core/YahfaRouter.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.yahfa.core; 2 | 3 | import com.elderdrivers.riru.edxp.config.EdXpConfigGlobal; 4 | import com.elderdrivers.riru.edxp.proxy.BaseRouter; 5 | import com.elderdrivers.riru.edxp.yahfa.config.YahfaEdxpConfig; 6 | import com.elderdrivers.riru.edxp.yahfa.config.YahfaHookProvider; 7 | import com.elderdrivers.riru.edxp.yahfa.dexmaker.DynamicBridge; 8 | 9 | public class YahfaRouter extends BaseRouter { 10 | 11 | YahfaRouter() { 12 | } 13 | 14 | public void onEnterChildProcess() { 15 | DynamicBridge.onForkPost(); 16 | } 17 | 18 | public void injectConfig() { 19 | EdXpConfigGlobal.sConfig = new YahfaEdxpConfig(); 20 | EdXpConfigGlobal.sHookProvider = new YahfaHookProvider(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /edxp-yahfa/src/main/java/com/elderdrivers/riru/edxp/yahfa/dexmaker/DexLog.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.yahfa.dexmaker; 2 | 3 | import android.util.Log; 4 | 5 | import com.elderdrivers.riru.edxp.yahfa.BuildConfig; 6 | 7 | public class DexLog { 8 | 9 | public static final String TAG = "EdXposed"; 10 | 11 | public static int v(String s) { 12 | return Log.v(TAG, s); 13 | } 14 | 15 | public static int i(String s) { 16 | return Log.i(TAG, s); 17 | } 18 | 19 | public static int d(String s) { 20 | if (BuildConfig.DEBUG) { 21 | return Log.d(TAG, s); 22 | } 23 | return 0; 24 | } 25 | 26 | public static int w(String s) { 27 | return Log.w(TAG, s); 28 | } 29 | 30 | public static int e(String s) { 31 | return Log.e(TAG, s); 32 | } 33 | 34 | public static int e(String s, Throwable t) { 35 | return Log.e(TAG, s, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | androidCompileSdkVersion=30 2 | androidMinSdkVersion=26 3 | androidTargetSdkVersion=30 4 | androidCompileNdkVersion=22.0.7026061 5 | android.prefabVersion=1.1.2 6 | apiCode=93 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElderDrivers/EdXposed/8f2308cdde0a8151a2b4b0151c58b203154a8c6f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Nov 13 15:00:57 CST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 7 | -------------------------------------------------------------------------------- /hiddenapi-stubs/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /libs 3 | -------------------------------------------------------------------------------- /hiddenapi-stubs/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion androidCompileSdkVersion.toInteger() 5 | ndkVersion androidCompileNdkVersion 6 | } 7 | 8 | task makeStubJar(type: Jar){ 9 | dependsOn assemble 10 | baseName 'framework-stub' 11 | from("${buildDir}/intermediates/javac/release/classes/") 12 | exclude('BuildConfig.class', 'R.class') 13 | exclude{ it.name.startsWith('R$')} 14 | outputs.file(archivePath) 15 | } 16 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/app/ActivityThread.java: -------------------------------------------------------------------------------- 1 | package android.app; 2 | 3 | import android.content.pm.ApplicationInfo; 4 | import android.content.res.CompatibilityInfo; 5 | 6 | public final class ActivityThread { 7 | public static ActivityThread currentActivityThread() { 8 | throw new UnsupportedOperationException("STUB"); 9 | } 10 | 11 | public static Application currentApplication() { 12 | throw new UnsupportedOperationException("STUB"); 13 | } 14 | 15 | public static String currentPackageName() { 16 | throw new UnsupportedOperationException("STUB"); 17 | } 18 | 19 | public final LoadedApk getPackageInfoNoCheck(ApplicationInfo ai, CompatibilityInfo compatInfo) { 20 | throw new UnsupportedOperationException("STUB"); 21 | } 22 | public ContextImpl getSystemContext() { 23 | throw new UnsupportedOperationException("STUB"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/app/LoadedApk.java: -------------------------------------------------------------------------------- 1 | package android.app; 2 | 3 | import android.content.pm.ApplicationInfo; 4 | 5 | public final class LoadedApk { 6 | public ApplicationInfo getApplicationInfo() { 7 | throw new UnsupportedOperationException("STUB"); 8 | } 9 | 10 | public ClassLoader getClassLoader() { 11 | throw new UnsupportedOperationException("STUB"); 12 | } 13 | 14 | public String getPackageName() { 15 | throw new UnsupportedOperationException("STUB"); 16 | } 17 | 18 | public String getResDir() { 19 | throw new UnsupportedOperationException("STUB"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/content/pm/PackageParser.java: -------------------------------------------------------------------------------- 1 | package android.content.pm; 2 | 3 | import java.io.File; 4 | 5 | public class PackageParser { 6 | public static class PackageLite { 7 | public final String packageName = null; 8 | } 9 | 10 | /** Before SDK21 */ 11 | public static PackageLite parsePackageLite(String packageFile, int flags) { 12 | throw new UnsupportedOperationException("STUB"); 13 | } 14 | 15 | /** Since SDK21 */ 16 | public static PackageLite parsePackageLite(File packageFile, int flags) throws PackageParserException { 17 | throw new UnsupportedOperationException("STUB"); 18 | } 19 | 20 | /** Since SDK21 */ 21 | @SuppressWarnings("serial") 22 | public static class PackageParserException extends Exception { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/content/res/AssetManager.java: -------------------------------------------------------------------------------- 1 | package android.content.res; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | public final class AssetManager { 7 | public final int addAssetPath(String path) { 8 | throw new UnsupportedOperationException("STUB"); 9 | } 10 | 11 | public void close() { 12 | throw new UnsupportedOperationException("STUB"); 13 | } 14 | 15 | public final InputStream open(String fileName) throws IOException { 16 | throw new UnsupportedOperationException("STUB"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/content/res/CompatibilityInfo.java: -------------------------------------------------------------------------------- 1 | package android.content.res; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | public class CompatibilityInfo implements Parcelable { 7 | @Override 8 | public int describeContents() { 9 | throw new UnsupportedOperationException("STUB"); 10 | } 11 | 12 | @Override 13 | public void writeToParcel(Parcel dest, int flags) { 14 | throw new UnsupportedOperationException("STUB"); 15 | } 16 | 17 | public static final Parcelable.Creator CREATOR = null; 18 | } 19 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/content/res/ResourcesImpl.java: -------------------------------------------------------------------------------- 1 | package android.content.res; 2 | 3 | public class ResourcesImpl { 4 | } 5 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/os/IServiceManager.java: -------------------------------------------------------------------------------- 1 | package android.os; 2 | 3 | public interface IServiceManager { 4 | } 5 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/os/SELinux.java: -------------------------------------------------------------------------------- 1 | package android.os; 2 | 3 | public class SELinux { 4 | public static final String getContext() { 5 | throw new UnsupportedOperationException("STUB"); 6 | } 7 | 8 | public static final boolean isSELinuxEnabled() { 9 | throw new UnsupportedOperationException("STUB"); 10 | } 11 | 12 | public static final boolean isSELinuxEnforced() { 13 | throw new UnsupportedOperationException("STUB"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/android/os/ServiceManager.java: -------------------------------------------------------------------------------- 1 | package android.os; 2 | 3 | public class ServiceManager { 4 | private static IServiceManager sServiceManager; 5 | 6 | private static IServiceManager getIServiceManager() { 7 | throw new IllegalArgumentException("Stub!"); 8 | } 9 | 10 | public static IBinder getService(String name) { 11 | throw new UnsupportedOperationException("STUB"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/com/android/internal/os/RuntimeInit.java: -------------------------------------------------------------------------------- 1 | package com.android.internal.os; 2 | 3 | public class RuntimeInit { 4 | public static final void main(String[] argv) { 5 | throw new UnsupportedOperationException("STUB"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/com/android/internal/os/ZygoteInit.java: -------------------------------------------------------------------------------- 1 | package com.android.internal.os; 2 | 3 | public class ZygoteInit { 4 | public static void main(String[] argv) { 5 | throw new UnsupportedOperationException("STUB"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/com/android/internal/util/XmlUtils.java: -------------------------------------------------------------------------------- 1 | package com.android.internal.util; 2 | 3 | import org.xmlpull.v1.XmlPullParserException; 4 | 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.util.HashMap; 8 | 9 | public class XmlUtils { 10 | @SuppressWarnings("rawtypes") 11 | public static final HashMap readMapXml(InputStream in) throws XmlPullParserException, IOException { 12 | throw new UnsupportedOperationException("STUB"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/dalvik/system/BaseDexClassLoader.java: -------------------------------------------------------------------------------- 1 | // 2 | // Source code recreated from a .class file by IntelliJ IDEA 3 | // (powered by Fernflower decompiler) 4 | // 5 | 6 | package dalvik.system; 7 | 8 | import java.io.File; 9 | import java.net.URL; 10 | import java.util.Enumeration; 11 | 12 | public class BaseDexClassLoader extends ClassLoader { 13 | public BaseDexClassLoader(String dexPath, File optimizedDirectory, String librarySearchPath, ClassLoader parent) { 14 | throw new RuntimeException("Stub!"); 15 | } 16 | 17 | protected Class findClass(String name) throws ClassNotFoundException { 18 | throw new RuntimeException("Stub!"); 19 | } 20 | 21 | protected URL findResource(String name) { 22 | throw new RuntimeException("Stub!"); 23 | } 24 | 25 | protected Enumeration findResources(String name) { 26 | throw new RuntimeException("Stub!"); 27 | } 28 | 29 | public String findLibrary(String name) { 30 | throw new RuntimeException("Stub!"); 31 | } 32 | 33 | protected synchronized Package getPackage(String name) { 34 | throw new RuntimeException("Stub!"); 35 | } 36 | 37 | public String toString() { 38 | throw new RuntimeException("Stub!"); 39 | } 40 | 41 | public void addDexPath(String dexPath) { 42 | throw new RuntimeException("Stub!"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/xposed/dummy/XResourcesSuperClass.java: -------------------------------------------------------------------------------- 1 | package xposed.dummy; 2 | 3 | import android.content.res.Resources; 4 | 5 | /** 6 | * This class is used as super class of XResources. 7 | * 8 | * This implementation isn't included in the .dex file. Instead, it's created on the device. 9 | * Usually, it will extend Resources, but some ROMs use their own Resources subclass. 10 | * In that case, XResourcesSuperClass will extend the ROM's subclass in an attempt to increase 11 | * compatibility. 12 | */ 13 | public class XResourcesSuperClass extends Resources { 14 | /** Dummy, will never be called (objects are transferred to this class only). */ 15 | protected XResourcesSuperClass() { 16 | super(null, null, null); 17 | throw new UnsupportedOperationException(); 18 | } 19 | 20 | protected XResourcesSuperClass(ClassLoader classLoader) { 21 | super(classLoader); 22 | throw new UnsupportedOperationException(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /hiddenapi-stubs/src/main/java/xposed/dummy/XTypedArraySuperClass.java: -------------------------------------------------------------------------------- 1 | package xposed.dummy; 2 | 3 | import android.content.res.Resources; 4 | import android.content.res.TypedArray; 5 | 6 | /** 7 | * This class is used as super class of XResources.XTypedArray. 8 | * 9 | * This implementation isn't included in the .dex file. Instead, it's created on the device. 10 | * Usually, it will extend TypedArray, but some ROMs use their own TypedArray subclass. 11 | * In that case, XTypedArraySuperClass will extend the ROM's subclass in an attempt to increase 12 | * compatibility. 13 | */ 14 | public class XTypedArraySuperClass extends TypedArray { 15 | /** Dummy, will never be called (objects are transferred to this class only). */ 16 | protected XTypedArraySuperClass(Resources resources) { 17 | super(resources); 18 | throw new UnsupportedOperationException(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sandhook-annotation/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sandhook-annotation/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | 3 | dependencies { 4 | implementation fileTree(dir: 'libs', include: ['*.jar']) 5 | } 6 | 7 | sourceCompatibility = "1.7" 8 | targetCompatibility = "1.7" -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/HookClass.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface HookClass { 11 | Class value(); 12 | } 13 | -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/HookMethod.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface HookMethod { 11 | String value() default ""; 12 | } 13 | -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/HookMethodBackup.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD,ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface HookMethodBackup { 11 | String value() default ""; 12 | } 13 | -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/HookMode.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface HookMode { 11 | 12 | int AUTO = 0; 13 | int INLINE = 1; 14 | int REPLACE = 2; 15 | 16 | int value() default AUTO; 17 | } 18 | -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/HookReflectClass.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface HookReflectClass { 11 | String value(); 12 | } 13 | -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/MethodParams.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD,ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface MethodParams { 11 | Class[] value(); 12 | } -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/MethodReflectParams.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD,ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface MethodReflectParams { 11 | 12 | String BOOLEAN = "boolean"; 13 | String BYTE = "byte"; 14 | String CHAR = "char"; 15 | String DOUBLE = "double"; 16 | String FLOAT = "float"; 17 | String INT = "int"; 18 | String LONG = "long"; 19 | String SHORT = "short"; 20 | 21 | String[] value(); 22 | } -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/Param.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.PARAMETER}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface Param { 11 | String value() default ""; 12 | } 13 | -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/SkipParamCheck.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD, ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface SkipParamCheck { 11 | } 12 | -------------------------------------------------------------------------------- /sandhook-annotation/src/main/java/com/swift/sandhook/annotation/ThisObject.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.PARAMETER}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface ThisObject { 11 | } 12 | -------------------------------------------------------------------------------- /sandhook-hooklib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.cxx 3 | -------------------------------------------------------------------------------- /sandhook-hooklib/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -keep class com.swift.sandhook.** { *; } 24 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | project(sandhook.edxp) 3 | 4 | ENABLE_LANGUAGE(ASM) 5 | 6 | add_definitions(-std=c++11) 7 | 8 | set(${PROJECT_NAME}_SOURCES 9 | sandhook.cpp 10 | trampoline/trampoline.cpp 11 | trampoline/trampoline_manager.cpp 12 | utils/dlfcn_nougat.cpp 13 | utils/hide_api.cpp 14 | utils/utils.cpp 15 | utils/offset.cpp 16 | utils/elf_util.cpp 17 | casts/cast_art_method.cpp 18 | casts/cast_compiler_options.cpp 19 | art/art_method.cpp 20 | art/art_compiler_options.cpp 21 | art/art_classlinker.cpp 22 | trampoline/arch/arm32.S 23 | trampoline/arch/arm64.S 24 | inst/insts_arm32.cpp 25 | inst/insts_arm64.cpp 26 | nativehook/native_hook.cpp 27 | ) 28 | 29 | add_library(${PROJECT_NAME} 30 | SHARED 31 | ${${PROJECT_NAME}_SOURCES}) 32 | 33 | target_link_libraries(${PROJECT_NAME} log) -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/art/art_classlinker.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 双草酸酯 on 11/27/20. 3 | // 4 | #include "../includes/art_classlinker.h" 5 | 6 | using namespace art; 7 | void ClassLinker::MakeInitializedClassesVisiblyInitialized(void* self, bool wait) { 8 | 9 | } -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/art/art_compiler_options.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/2/24. 3 | // 4 | 5 | #include "../includes/art_compiler_options.h" 6 | #include "../includes/cast_compiler_options.h" 7 | #include "../includes/hide_api.h" 8 | 9 | using namespace SandHook; 10 | using namespace art; 11 | 12 | extern int SDK_INT; 13 | 14 | size_t CompilerOptions::getInlineMaxCodeUnits() { 15 | if (SDK_INT < ANDROID_N) 16 | return 0; 17 | return CastCompilerOptions::inlineMaxCodeUnits->get(this); 18 | } 19 | 20 | bool CompilerOptions::setInlineMaxCodeUnits(size_t units) { 21 | if (SDK_INT < ANDROID_N) 22 | return false; 23 | CastCompilerOptions::inlineMaxCodeUnits->set(this, units); 24 | return true; 25 | } 26 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/casts/cast_compiler_options.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/2/24. 3 | // 4 | 5 | #include "../includes/cast_compiler_options.h" 6 | #include "../includes/hide_api.h" 7 | 8 | extern int SDK_INT; 9 | 10 | namespace SandHook { 11 | 12 | 13 | class CastInlineMaxCodeUnits : public IMember { 14 | protected: 15 | Size calOffset(JNIEnv *jniEnv, art::CompilerOptions *p) override { 16 | if (SDK_INT < ANDROID_N) 17 | return getParentSize() + 1; 18 | if (SDK_INT >= ANDROID_Q) { 19 | return BYTE_POINT + 3 * sizeof(size_t); 20 | } 21 | if (SDK_INT >= ANDROID_O) { 22 | return BYTE_POINT + 5 * sizeof(size_t); 23 | } else { 24 | return BYTE_POINT + 6 * sizeof(size_t); 25 | } 26 | } 27 | }; 28 | 29 | void CastCompilerOptions::init(JNIEnv *jniEnv) { 30 | inlineMaxCodeUnits->init(jniEnv, nullptr, sizeof(art::CompilerOptions)); 31 | } 32 | 33 | IMember* CastCompilerOptions::inlineMaxCodeUnits = new CastInlineMaxCodeUnits(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/arch.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/1/12. 3 | // 4 | 5 | #ifndef SANDHOOK_ARCH_H 6 | #define SANDHOOK_ARCH_H 7 | 8 | #define BYTE_POINT sizeof(void*) 9 | 10 | typedef size_t Size; 11 | 12 | //32bit 13 | #if defined(__i386__) || defined(__arm__) 14 | //64bit 15 | #elif defined(__aarch64__) || defined(__x86_64__) 16 | #else 17 | #endif 18 | 19 | #if defined(__arm__) 20 | static void clearCacheArm32(char* begin, char *end) 21 | { 22 | const int syscall = 0xf0002; 23 | __asm __volatile ( 24 | "mov r0, %0\n" 25 | "mov r1, %1\n" 26 | "mov r3, %2\n" 27 | "mov r2, #0x0\n" 28 | "svc 0x00000000\n" 29 | : 30 | : "r" (begin), "r" (end), "r" (syscall) 31 | : "r0", "r1", "r3" 32 | ); 33 | } 34 | #endif 35 | 36 | #define ANDROID_K 19 37 | #define ANDROID_L 21 38 | #define ANDROID_L2 22 39 | #define ANDROID_M 23 40 | #define ANDROID_N 24 41 | #define ANDROID_N2 25 42 | #define ANDROID_O 26 43 | #define ANDROID_O2 27 44 | #define ANDROID_P 28 45 | #define ANDROID_Q 29 46 | #define ANDROID_R 30 47 | 48 | #endif //SANDHOOK_ARCH_H -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/arch_base.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SwiftGan on 2019/1/17. 3 | // 4 | 5 | #ifndef SANDHOOK_BASE_H 6 | #define SANDHOOK_BASE_H 7 | 8 | #define FUNCTION_START(x) \ 9 | .text; \ 10 | .align 4; \ 11 | .global x; \ 12 | x: \ 13 | 14 | #define FUNCTION_START_T(x) \ 15 | .syntax unified; \ 16 | .text; \ 17 | .align 4; \ 18 | .thumb; \ 19 | .thumb_func; \ 20 | .global x; \ 21 | x: \ 22 | 23 | #define FUNCTION_END(x) .size x, .-x 24 | 25 | #define REPLACEMENT_HOOK_TRAMPOLINE replacement_hook_trampoline 26 | #define INLINE_HOOK_TRAMPOLINE inline_hook_trampoline 27 | #define DIRECT_JUMP_TRAMPOLINE direct_jump_trampoline 28 | #define CALL_ORIGIN_TRAMPOLINE call_origin_trampoline 29 | 30 | #define INLINE_HOOK_TRAMPOLINE_T inline_hook_trampoline_t 31 | #define DIRECT_JUMP_TRAMPOLINE_T direct_jump_trampoline_t 32 | #define CALL_ORIGIN_TRAMPOLINE_T call_origin_trampoline_t 33 | 34 | #endif //SANDHOOK_BASE_H 35 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/art_classlinker.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 双草酸酯 on 11/27/20. 3 | // 4 | 5 | #ifndef SANDHOOK_ART_CLASSLINKER_H 6 | #define SANDHOOK_ART_CLASSLINKER_H 7 | 8 | #endif //SANDHOOK_ART_CLASSLINKER_H 9 | namespace art { 10 | class ClassLinker { 11 | public: 12 | void MakeInitializedClassesVisiblyInitialized(void* self, bool wait); 13 | }; 14 | } -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/art_compiler_options.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/2/23. 3 | // 4 | 5 | #ifndef ART_COMPILER_OPTIONS_H 6 | #define ART_COMPILER_OPTIONS_H 7 | 8 | #include 9 | 10 | namespace art { 11 | class CompilerOptions { 12 | public: 13 | void* compiler_filter_; 14 | size_t huge_method_threshold_; 15 | size_t large_method_threshold_; 16 | size_t small_method_threshold_; 17 | size_t tiny_method_threshold_; 18 | size_t num_dex_methods_threshold_; 19 | size_t inline_depth_limit_; 20 | size_t inline_max_code_units_; 21 | 22 | size_t getInlineMaxCodeUnits(); 23 | bool setInlineMaxCodeUnits(size_t units); 24 | 25 | }; 26 | } 27 | 28 | #endif //ART_COMPILER_OPTIONS_H 29 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/art_jit.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/2/23. 3 | // 4 | 5 | #ifndef SANDHOOK_ART_JIT_H 6 | #define SANDHOOK_ART_JIT_H 7 | 8 | namespace art { 9 | namespace jit { 10 | 11 | //7.0 - 9.0 12 | class JitCompiler { 13 | public: 14 | virtual ~JitCompiler(); 15 | std::unique_ptr compilerOptions; 16 | }; 17 | 18 | class Jit { 19 | public: 20 | //void* getCompilerOptions(); 21 | }; 22 | 23 | 24 | 25 | }; 26 | } 27 | 28 | #endif //SANDHOOK_ART_JIT_H 29 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/art_runtime.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/2/23. 3 | // 4 | 5 | #ifndef SANDHOOK_ART_RUNTIME_H 6 | #define SANDHOOK_ART_RUNTIME_H 7 | 8 | #include "art_jit.h" 9 | 10 | namespace art { 11 | class Runtime { 12 | 13 | public: 14 | jit::Jit* getJit(); 15 | }; 16 | } 17 | 18 | #endif //SANDHOOK_ART_RUNTIME_H 19 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/cast_art_method.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/1/12. 3 | // 4 | 5 | #ifndef SANDHOOK_CAST_ART_METHOD_H 6 | #define SANDHOOK_CAST_ART_METHOD_H 7 | 8 | #include "cast.h" 9 | #include "trampoline_manager.h" 10 | 11 | namespace SandHook { 12 | 13 | class CastArtMethod { 14 | public: 15 | static Size size; 16 | static IMember* entryPointQuickCompiled; 17 | static IMember* entryPointFromInterpreter; 18 | static IMember* entryPointFromJNI; 19 | static ArrayMember* dexCacheResolvedMethods; 20 | static IMember* dexMethodIndex; 21 | static IMember* accessFlag; 22 | static IMember* declaringClass; 23 | static IMember* hotnessCount; 24 | static void* quickToInterpreterBridge; 25 | static void* genericJniStub; 26 | static void* staticResolveStub; 27 | static bool canGetJniBridge; 28 | static bool canGetInterpreterBridge; 29 | 30 | static void init(JNIEnv *env); 31 | static void copy(art::mirror::ArtMethod* from, art::mirror::ArtMethod* to); 32 | 33 | }; 34 | 35 | } 36 | 37 | #endif //SANDHOOK_CAST_ART_METHOD_H 38 | 39 | 40 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/cast_compiler_options.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/1/12. 3 | // 4 | 5 | #ifndef SANDHOOK_CAST_COMPILER_OPTIONS_H 6 | #define SANDHOOK_CAST_COMPILER_OPTIONS_H 7 | 8 | #include "cast.h" 9 | #include "art_compiler_options.h" 10 | 11 | namespace SandHook { 12 | 13 | class CastCompilerOptions { 14 | public: 15 | static void init(JNIEnv *jniEnv); 16 | static IMember* inlineMaxCodeUnits; 17 | }; 18 | 19 | 20 | } 21 | 22 | #endif //SANDHOOK_CAST_COMPILER_OPTIONS_H 23 | 24 | 25 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/dlfcn_nougat.h: -------------------------------------------------------------------------------- 1 | #ifndef DLFCN_NOUGAT_H 2 | #define DLFCN_NOUGAT_H 3 | 4 | //see implementation in https://tech.meituan.com/2017/07/20/android-remote-debug.html 5 | extern "C" { 6 | int fake_dlclose(void *handle); 7 | 8 | void *fake_dlopen(const char *filename, int flags); 9 | 10 | void *fake_dlsym(void *handle, const char *name); 11 | 12 | const char *fake_dlerror(); 13 | 14 | void *getSymCompat(const char *filename, const char *name); 15 | } 16 | 17 | #endif //DLFCN_NOUGAT_H 18 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/log.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SwiftGan on 2019/2/15. 3 | // 4 | 5 | #ifndef SANDHOOK_LOG_H 6 | #define SANDHOOK_LOG_H 7 | 8 | #include "android/log.h" 9 | 10 | #define TAG "SandHook-Native" 11 | 12 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) 13 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) 14 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) 15 | 16 | #endif //SANDHOOK_LOG_H 17 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/native_hook.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SwiftGan on 2019/4/12. 3 | // 4 | 5 | #ifndef SANDHOOK_NATIVE_HOOK_H 6 | #define SANDHOOK_NATIVE_HOOK_H 7 | 8 | #include "sandhook.h" 9 | 10 | namespace SandHook { 11 | 12 | class NativeHook { 13 | public: 14 | static bool hookDex2oat(bool disableDex2oat); 15 | }; 16 | 17 | } 18 | 19 | #endif //SANDHOOK_NATIVE_HOOK_H 20 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/never_call.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by swift on 2019/6/3. 3 | // 4 | 5 | #ifndef SANDHOOK_NEVER_CALL_H 6 | #define SANDHOOK_NEVER_CALL_H 7 | 8 | #include 9 | 10 | extern "C" 11 | JNIEXPORT void JNICALL 12 | Java_com_swift_sandhook_ClassNeverCall_neverCallNative(JNIEnv *env, jobject instance); 13 | 14 | #endif //SANDHOOK_NEVER_CALL_H 15 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/offset.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by swift on 2019/2/3. 3 | // 4 | 5 | #ifndef SANDHOOK_OFFSET_H 6 | #define SANDHOOK_OFFSET_H 7 | 8 | #include 9 | 10 | namespace SandHook { 11 | 12 | class Offset { 13 | public: 14 | 15 | template 16 | static int findOffset(void *start, size_t len, size_t step, T value); 17 | 18 | template 19 | static int findOffsetWithCB1(void *start, size_t len, size_t step, bool func(int, T)); 20 | 21 | template 22 | static int findOffsetWithCB2(void *start1, void *start2, size_t len, size_t step, bool func(T, T)); 23 | 24 | }; 25 | 26 | } 27 | 28 | #endif //SANDHOOK_OFFSET_H 29 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/sandhook.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SwiftGan on 2019/4/12. 3 | // 4 | 5 | #ifndef SANDHOOK_SANDHOOK_H 6 | #define SANDHOOK_SANDHOOK_H 7 | 8 | #include 9 | 10 | extern "C" 11 | JNIEXPORT bool nativeHookNoBackup(void* origin, void* hook); 12 | 13 | extern "C" 14 | JNIEXPORT void* findSym(const char *elf, const char *sym_name); 15 | 16 | #endif //SANDHOOK_SANDHOOK_H 17 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/includes/utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 甘尧 on 2019/1/13. 3 | // 4 | 5 | #ifndef SANDHOOK_UTILS_H 6 | #define SANDHOOK_UTILS_H 7 | 8 | #include 9 | #include 10 | #include "jni.h" 11 | #include "../includes/arch.h" 12 | #include 13 | #include 14 | #include 15 | 16 | #define RoundUpToPtrSize(x) (x + BYTE_POINT - 1 - ((x + BYTE_POINT - 1) & (BYTE_POINT - 1))) 17 | 18 | extern "C" { 19 | 20 | Size getAddressFromJava(JNIEnv *env, const char *className, const char *fieldName); 21 | 22 | Size callStaticMethodAddr(JNIEnv *env, const char *className, const char *method, const char *sig, ...); 23 | 24 | jobject callStaticMethodObject(JNIEnv *env, const char *className, const char *method, const char *sig, ...); 25 | 26 | jobject getMethodObject(JNIEnv *env, const char *clazz, const char *method); 27 | 28 | Size getAddressFromJavaByCallMethod(JNIEnv *env, const char *className, const char *methodName); 29 | 30 | jint getIntFromJava(JNIEnv *env, const char *className, const char *fieldName); 31 | 32 | bool getBooleanFromJava(JNIEnv *env, const char *className, const char *fieldName); 33 | 34 | bool munprotect(size_t addr, size_t len); 35 | 36 | bool flushCacheExt(Size addr, Size len); 37 | 38 | } 39 | 40 | 41 | #endif //SANDHOOK_UTILS_H 42 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/cpp/utils/lock.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SwiftGan on 2019/1/21. 3 | // 4 | 5 | #ifndef SANDHOOK_LOCK_H 6 | #define SANDHOOK_LOCK_H 7 | 8 | #include "mutex" 9 | #include "../includes/hide_api.h" 10 | 11 | namespace SandHook { 12 | 13 | class AutoLock { 14 | public: 15 | inline AutoLock(std::mutex& mutex) : mLock(mutex) { mLock.lock(); } 16 | inline AutoLock(std::mutex* mutex) : mLock(*mutex) { mLock.lock(); } 17 | inline ~AutoLock() { mLock.unlock(); } 18 | private: 19 | std::mutex& mLock; 20 | }; 21 | 22 | class StopTheWorld { 23 | public: 24 | inline StopTheWorld() { suspendVM(); } 25 | inline ~StopTheWorld() { resumeVM(); } 26 | }; 27 | 28 | } 29 | 30 | #endif //SANDHOOK_LOCK_H 31 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/java/com/swift/sandhook/ArtMethodSizeTest.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook; 2 | 3 | public class ArtMethodSizeTest { 4 | public final static void method1(){} 5 | public final static void method2(){} 6 | } 7 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/java/com/swift/sandhook/ClassNeverCall.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook; 2 | 3 | import android.util.Log; 4 | 5 | public class ClassNeverCall { 6 | private void neverCall() {} 7 | private void neverCall2() { 8 | Log.e("ClassNeverCall", "ClassNeverCall2"); 9 | } 10 | private static void neverCallStatic() {} 11 | private native void neverCallNative(); 12 | private native void neverCallNative2(); 13 | } 14 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/java/com/swift/sandhook/HookLog.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook; 2 | 3 | import android.util.Log; 4 | 5 | 6 | public class HookLog { 7 | 8 | public static final String TAG = "SandHook"; 9 | 10 | public static boolean DEBUG = SandHookConfig.DEBUG; 11 | 12 | public static int v(String s) { 13 | return Log.v(TAG, s); 14 | } 15 | 16 | public static int i(String s) { 17 | return Log.i(TAG, s); 18 | } 19 | 20 | public static int d(String s) { 21 | return Log.d(TAG, s); 22 | } 23 | 24 | public static int w(String s) { 25 | return Log.w(TAG, s); 26 | } 27 | 28 | public static int e(String s) { 29 | return Log.e(TAG, s); 30 | } 31 | 32 | public static int e(String s, Throwable t) { 33 | return Log.e(TAG, s, t); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/java/com/swift/sandhook/SandHookConfig.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.os.Build; 5 | 6 | import com.swift.sandhook.lib.BuildConfig; 7 | 8 | public class SandHookConfig { 9 | 10 | public volatile static int SDK_INT = Build.VERSION.SDK_INT; 11 | //Debug status of hook target process 12 | public volatile static boolean DEBUG = true; 13 | //Enable compile with jit 14 | public volatile static boolean compiler = SDK_INT < 29; 15 | public volatile static ClassLoader initClassLoader; 16 | public volatile static int curUser = 0; 17 | public volatile static boolean delayHook = true; 18 | 19 | public volatile static String libSandHookPath; 20 | public volatile static LibLoader libLoader = new LibLoader() { 21 | @SuppressLint("UnsafeDynamicallyLoadedCode") 22 | @Override 23 | public void loadLib() { 24 | if (SandHookConfig.libSandHookPath == null) { 25 | System.loadLibrary("sandhook"); 26 | } else { 27 | System.load(SandHookConfig.libSandHookPath); 28 | } 29 | } 30 | }; 31 | 32 | public interface LibLoader { 33 | void loadLib(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/java/com/swift/sandhook/wrapper/HookErrorException.java: -------------------------------------------------------------------------------- 1 | package com.swift.sandhook.wrapper; 2 | 3 | public class HookErrorException extends Exception { 4 | public HookErrorException(String s) { 5 | super(s); 6 | } 7 | 8 | public HookErrorException(String message, Throwable cause) { 9 | super(message, cause); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /sandhook-hooklib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | hooklib 3 | 4 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':edxp-core', ':xposed-bridge', ':hiddenapi-stubs', ':dexmaker', ':dalvikdx', ':edxp-common', ':edxp-yahfa', ':edxp-sandhook', ':edxp-service', ':sandhook-hooklib', ':sandhook-annotation' -------------------------------------------------------------------------------- /xposed-bridge/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /xposed-bridge/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -dontobfuscate 24 | -dontoptimize 25 | -keep class de.robv.android.xposed.** {*;} 26 | -keep class android.** { *; } -------------------------------------------------------------------------------- /xposed-bridge/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/MODIFICATIONS.txt: -------------------------------------------------------------------------------- 1 | This is the original source code of the Apache Commons Lang library version 3.1 2 | as downloaded from http://commons.apache.org/lang/download_lang.cgi, except for 3 | these modifications: 4 | - Class MemberUtils changed to public 5 | - Method compareParameterTypes in MemberUtils changed to public 6 | - Prefix "external." for packages to avoid conflicts with other apps 7 | - Removed unused sub-packages for smaller file size: 8 | concurrent/ 9 | event/ 10 | math/ 11 | text/ 12 | time/ 13 | - Removed unused classes for smaller file size: 14 | AnnotationUtils.java 15 | BitField.java 16 | BooleanUtils.java 17 | CharEncoding.java 18 | CharRange.java 19 | CharSet.java 20 | CharSetUtils.java 21 | EnumUtils.java 22 | LocaleUtils.java 23 | RandomStringUtils.java 24 | Range.java 25 | SerializationException.java 26 | SerializationUtils.java 27 | StringEscapeUtils.java 28 | builder/StandardToStringStyle.java 29 | exception/ContextedException.java 30 | exception/ContextedRuntimeException.java 31 | exception/DefaultExceptionContext.java 32 | exception/ExceptionContext.java 33 | exception/ExceptionUtils.java 34 | mutable/MutableBoolean.java 35 | mutable/MutableByte.java 36 | mutable/MutableDouble.java 37 | mutable/MutableFloat.java 38 | mutable/MutableLong.java 39 | mutable/MutableObject.java 40 | mutable/MutableShort.java 41 | reflect/ConstructorUtils.java 42 | reflect/FieldUtils.java 43 | reflect/TypeUtils.java 44 | tuple/MutablePair.java 45 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/NOTICE.txt: -------------------------------------------------------------------------------- 1 | Apache Commons Lang 2 | Copyright 2001-2011 The Apache Software Foundation 3 | 4 | This product includes software developed by 5 | The Apache Software Foundation (http://www.apache.org/). 6 | 7 | This product includes software from the Spring Framework, 8 | under the Apache License 2.0 (see: StringUtils.containsWhitespace()) 9 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/external/org/apache/commons/lang3/builder/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | Assists in creating consistent equals(Object), toString(), 20 | hashCode(), and compareTo(Object) methods. 21 | @see java.lang.Object#equals(Object) 22 | @see java.lang.Object#toString() 23 | @see java.lang.Object#hashCode() 24 | @see java.lang.Comparable#compareTo(Object) 25 | @since 1.0 26 |

These classes are not thread-safe.

27 | 28 | 29 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/external/org/apache/commons/lang3/exception/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | Provides functionality for Exceptions. 20 |

Contains the concept of an exception with context i.e. such an exception 21 | will contain a map with keys and values. This provides an easy way to pass valuable 22 | state information at exception time in useful form to a calling process.

23 |

Lastly, {@link org.apache.commons.lang3.exception.ExceptionUtils} 24 | also contains Throwable manipulation and examination routines.

25 | @since 1.0 26 | 27 | 28 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/external/org/apache/commons/lang3/mutable/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | 25 | Provides typed mutable wrappers to primitive values and Object. 26 | @since 2.1 27 |

These classes are not thread-safe.

28 | 29 | 30 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/external/org/apache/commons/lang3/overview.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 |

20 | This document is the API specification for the Apache Commons Lang library. 21 |

22 | 23 | 24 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/external/org/apache/commons/lang3/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | Provides highly reusable static utility methods, chiefly concerned 20 | with adding value to the {@link java.lang} classes. 21 | @since 1.0 22 |

Most of these classes are immutable and thus thread-safe. 23 | However Charset is not currently guaranteed thread-safe under all circumstances.

24 | 25 | 26 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/external/org/apache/commons/lang3/reflect/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | 25 | Accumulates common high-level uses of the java.lang.reflect APIs. 26 | @since 3.0 27 |

These classes are immutable, and therefore thread-safe.

28 | 29 | 30 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/apacheCommonsLang/external/org/apache/commons/lang3/tuple/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | Tuple classes, starting with a Pair class in version 3.0. 20 | @since 3.0 21 | 22 | 23 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/android/app/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains {@link android.app.AndroidAppHelper} with various methods for information about the current app. 3 | */ 4 | package android.app; 5 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/android/content/res/XResForwarder.java: -------------------------------------------------------------------------------- 1 | package android.content.res; 2 | 3 | /** 4 | * Instances of this class can be used for {@link XResources#setReplacement(String, String, String, Object)} 5 | * and its variants. They forward the resource request to a different {@link android.content.res.Resources} 6 | * instance with a possibly different ID. 7 | * 8 | *

Usually, instances aren't created directly but via {@link XModuleResources#fwd}. 9 | */ 10 | public class XResForwarder { 11 | private final Resources res; 12 | private final int id; 13 | 14 | /** 15 | * Creates a new instance. 16 | * 17 | * @param res The target {@link android.content.res.Resources} instance to forward requests to. 18 | * @param id The target resource ID. 19 | */ 20 | public XResForwarder(Resources res, int id) { 21 | this.res = res; 22 | this.id = id; 23 | } 24 | 25 | /** Returns the target {@link android.content.res.Resources} instance. */ 26 | public Resources getResources() { 27 | return res; 28 | } 29 | 30 | /** Returns the target resource ID. */ 31 | public int getId() { 32 | return id; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/android/content/res/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains classes that are required for replacing resources. 3 | */ 4 | package android.content.res; 5 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/com/elderdrivers/riru/edxp/config/EdXpConfigGlobal.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.config; 2 | 3 | import com.elderdrivers.riru.edxp.hook.HookProvider; 4 | 5 | public class EdXpConfigGlobal { 6 | 7 | public static volatile EdxpConfig sConfig; 8 | public static volatile HookProvider sHookProvider; 9 | 10 | public static EdxpConfig getConfig() { 11 | if (sConfig == null) { 12 | throw new IllegalArgumentException("sConfig should not be null."); 13 | } 14 | return sConfig; 15 | } 16 | 17 | public static HookProvider getHookProvider() { 18 | if (sHookProvider == null) { 19 | throw new IllegalArgumentException("sHookProvider should not be null."); 20 | } 21 | return sHookProvider; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/com/elderdrivers/riru/edxp/config/EdxpConfig.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.config; 2 | 3 | public interface EdxpConfig { 4 | 5 | String getConfigPath(String suffix); 6 | 7 | String getDataPathPrefix(); 8 | 9 | String getInstallerPackageName(); 10 | 11 | String getLibSandHookName(); 12 | 13 | boolean isNoModuleLogEnabled(); 14 | 15 | boolean isResourcesHookEnabled(); 16 | 17 | boolean isSELinuxEnforced(); 18 | 19 | boolean isBlackWhiteListMode(); 20 | 21 | String getModulesList(); 22 | } 23 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/com/elderdrivers/riru/edxp/hook/HookProvider.java: -------------------------------------------------------------------------------- 1 | package com.elderdrivers.riru.edxp.hook; 2 | 3 | import java.lang.reflect.Member; 4 | 5 | import de.robv.android.xposed.XposedBridge; 6 | 7 | public interface HookProvider { 8 | 9 | void hookMethod(Member method, XposedBridge.AdditionalHookInfo additionalInfo); 10 | 11 | void unhookMethod(Member method); 12 | 13 | Object invokeOriginalMethod(Member method, long methodId, Object thisObject, Object[] args) throws Throwable; 14 | 15 | Member findMethodNative(Member hookMethod); 16 | 17 | void deoptMethods(String packageName, ClassLoader classLoader); 18 | 19 | long getMethodId(Member member); 20 | 21 | Object findMethodNative(Class clazz, String methodName, String methodSig); 22 | 23 | void deoptMethodNative(Object method); 24 | 25 | boolean initXResourcesNative(); 26 | 27 | boolean removeFinalFlagNative(Class clazz); 28 | 29 | boolean methodHooked(Member target); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/IModuleContext.java: -------------------------------------------------------------------------------- 1 | package de.robv.android.xposed; 2 | 3 | public interface IModuleContext { 4 | 5 | String getApkPath(); 6 | } 7 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/IXposedHookCmdInit.java: -------------------------------------------------------------------------------- 1 | package de.robv.android.xposed; 2 | 3 | 4 | /** 5 | * Hook the initialization of Java-based command-line tools (like pm). 6 | * 7 | * @hide Xposed no longer hooks command-line tools, therefore this interface shouldn't be 8 | * implemented anymore. 9 | */ 10 | public interface IXposedHookCmdInit extends IXposedMod { 11 | /** 12 | * Called very early during startup of a command-line tool. 13 | * @param startupParam Details about the module itself and the started process. 14 | * @throws Throwable Everything is caught, but it will prevent further initialization of the module. 15 | */ 16 | void initCmdApp(StartupParam startupParam) throws Throwable; 17 | 18 | /** Data holder for {@link #initCmdApp}. */ 19 | final class StartupParam { 20 | /*package*/ StartupParam() {} 21 | 22 | /** The path to the module's APK. */ 23 | public String modulePath; 24 | 25 | /** The class name of the tools that the hook was invoked for. */ 26 | public String startClassName; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/IXposedMod.java: -------------------------------------------------------------------------------- 1 | package de.robv.android.xposed; 2 | 3 | /** Marker interface for Xposed modules. Cannot be implemented directly. */ 4 | /* package */ interface IXposedMod {} 5 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/annotation/ApiSensitive.java: -------------------------------------------------------------------------------- 1 | package de.robv.android.xposed.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Annotation that indicates a element is sensitive to Android API level. 10 | *

11 | * Annotated elements' compatibility should be checked when adapting to new Android versions. 12 | */ 13 | @Retention(RetentionPolicy.SOURCE) 14 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) 15 | public @interface ApiSensitive { 16 | Level value() default Level.HIGH; 17 | } 18 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/annotation/Level.java: -------------------------------------------------------------------------------- 1 | package de.robv.android.xposed.annotation; 2 | 3 | public enum Level { 4 | LOW, MIDDLE, HIGH; 5 | 6 | private Level() { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/callbacks/IXUnhook.java: -------------------------------------------------------------------------------- 1 | package de.robv.android.xposed.callbacks; 2 | 3 | import de.robv.android.xposed.IXposedHookZygoteInit; 4 | 5 | /** 6 | * Interface for objects that can be used to remove callbacks. 7 | * 8 | *

Just like hooking methods etc., unhooking applies only to the current process. 9 | * In other process (or when the app is removed from memory and then restarted), the hook will still 10 | * be active. The Zygote process (see {@link IXposedHookZygoteInit}) is an exception, the hook won't 11 | * be inherited by any future processes forked from it in the future. 12 | * 13 | * @param The class of the callback. 14 | */ 15 | public interface IXUnhook { 16 | /** 17 | * Returns the callback that has been registered. 18 | */ 19 | T getCallback(); 20 | 21 | /** 22 | * Removes the callback. 23 | */ 24 | void unhook(); 25 | } 26 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/callbacks/XC_InitZygote.java: -------------------------------------------------------------------------------- 1 | package de.robv.android.xposed.callbacks; 2 | 3 | import de.robv.android.xposed.IXposedHookZygoteInit; 4 | 5 | /** 6 | * This class is only used for internal purposes, except for the {@link StartupParam} 7 | * subclass. 8 | */ 9 | public abstract class XC_InitZygote extends XCallback implements IXposedHookZygoteInit { 10 | 11 | /** 12 | * Creates a new callback with default priority. 13 | * 14 | * @hide 15 | */ 16 | @SuppressWarnings("deprecation") 17 | public XC_InitZygote() { 18 | super(); 19 | } 20 | 21 | /** 22 | * Creates a new callback with a specific priority. 23 | * 24 | * @param priority See {@link XCallback#priority}. 25 | * @hide 26 | */ 27 | public XC_InitZygote(int priority) { 28 | super(priority); 29 | } 30 | 31 | /** 32 | * @hide 33 | */ 34 | @Override 35 | protected void call(Param param) throws Throwable { 36 | if (param instanceof StartupParam) 37 | initZygote((StartupParam) param); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/callbacks/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains the base classes for callbacks. 3 | * 4 | *

For historical reasons, {@link de.robv.android.xposed.XC_MethodHook} and 5 | * {@link de.robv.android.xposed.XC_MethodReplacement} are directly in the 6 | * {@code de.robv.android.xposed} package. 7 | */ 8 | package de.robv.android.xposed.callbacks; 9 | 10 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains the main classes of the Xposed framework. 3 | */ 4 | package de.robv.android.xposed; 5 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/de/robv/android/xposed/services/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains file access services provided by the Xposed framework. 3 | */ 4 | package de.robv.android.xposed.services; 5 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/ResConst.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Panxiaobo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package pxb.android; 17 | 18 | public interface ResConst { 19 | int RES_STRING_POOL_TYPE = 0x0001; 20 | int RES_TABLE_TYPE = 0x0002; 21 | int RES_TABLE_PACKAGE_TYPE = 0x0200; 22 | int RES_TABLE_TYPE_SPEC_TYPE = 0x0202; 23 | int RES_TABLE_TYPE_TYPE = 0x0201; 24 | 25 | int RES_XML_TYPE = 0x0003; 26 | int RES_XML_RESOURCE_MAP_TYPE = 0x0180; 27 | int RES_XML_END_NAMESPACE_TYPE = 0x0101; 28 | int RES_XML_END_ELEMENT_TYPE = 0x0103; 29 | int RES_XML_START_NAMESPACE_TYPE = 0x0100; 30 | int RES_XML_START_ELEMENT_TYPE = 0x0102; 31 | int RES_XML_CDATA_TYPE = 0x0104; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/arsc/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Panxiaobo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package pxb.android.arsc; 17 | 18 | import java.util.Map; 19 | import java.util.TreeMap; 20 | 21 | public class Config { 22 | public final int entryCount; 23 | public final byte[] id; 24 | public Map resources = new TreeMap(); 25 | /* package */int wChunkSize; 26 | /* package */int wEntryStart; 27 | /* package */int wPosition; 28 | 29 | public Config(byte[] id, int entryCount) { 30 | super(); 31 | this.id = id; 32 | this.entryCount = entryCount; 33 | } 34 | } -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/arsc/ResEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Panxiaobo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package pxb.android.arsc; 17 | 18 | public class ResEntry { 19 | public final int flag; 20 | 21 | public final ResSpec spec; 22 | /** 23 | * {@link BagValue} or {@link Value} 24 | */ 25 | public Object value; 26 | 27 | /* package */int wOffset; 28 | 29 | public ResEntry(int flag, ResSpec spec) { 30 | super(); 31 | this.flag = flag; 32 | this.spec = spec; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/arsc/ResSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Panxiaobo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package pxb.android.arsc; 17 | 18 | public class ResSpec { 19 | public int flags; 20 | public final int id; 21 | public String name; 22 | 23 | public ResSpec(int id) { 24 | super(); 25 | this.id = id; 26 | } 27 | 28 | public void updateName(String s) { 29 | String name = this.name; 30 | if (name == null) { 31 | this.name = s; 32 | } else if (!s.equals(name)) { 33 | throw new RuntimeException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/arsc/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Panxiaobo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package pxb.android.arsc; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class Type { 22 | public List configs = new ArrayList(); 23 | public int id; 24 | public String name; 25 | public ResSpec[] specs; 26 | /* package */int wPosition; 27 | 28 | public void addConfig(Config config) { 29 | if (config.entryCount != specs.length) { 30 | throw new RuntimeException(); 31 | } 32 | configs.add(config); 33 | } 34 | 35 | public ResSpec getSpec(int resId) { 36 | ResSpec res = specs[resId]; 37 | if (res == null) { 38 | res = new ResSpec(resId); 39 | specs[resId] = res; 40 | } 41 | return res; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/arsc/Value.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Panxiaobo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package pxb.android.arsc; 17 | 18 | public class Value { 19 | public final int data; 20 | public String raw; 21 | public final int type; 22 | 23 | public Value(int type, int data, String raw) { 24 | super(); 25 | this.type = type; 26 | this.data = data; 27 | this.raw = raw; 28 | } 29 | 30 | public String toString() { 31 | if (type == 0x03) { 32 | return raw; 33 | } 34 | return String.format("{t=0x%02x d=0x%08x}", type, data); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/axml/AxmlVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Panxiaobo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package pxb.android.axml; 17 | 18 | /** 19 | * visitor to visit an axml 20 | * 21 | * @author Panxiaobo 22 | */ 23 | public class AxmlVisitor extends NodeVisitor { 24 | 25 | public AxmlVisitor() { 26 | super(); 27 | 28 | } 29 | 30 | public AxmlVisitor(NodeVisitor av) { 31 | super(av); 32 | } 33 | 34 | /** 35 | * create a ns 36 | * 37 | * @param prefix 38 | * @param uri 39 | * @param ln 40 | */ 41 | public void ns(String prefix, String uri, int ln) { 42 | if (nv != null && nv instanceof AxmlVisitor) { 43 | ((AxmlVisitor) nv).ns(prefix, uri, ln); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/axml/ValueWrapper.java: -------------------------------------------------------------------------------- 1 | package pxb.android.axml; 2 | 3 | public class ValueWrapper { 4 | 5 | public static final int ID = 1; 6 | public static final int STYLE = 2; 7 | public static final int CLASS = 3; 8 | public final int type; 9 | public final String raw; 10 | public final int ref; 11 | 12 | private ValueWrapper(int type, int ref, String raw) { 13 | super(); 14 | this.type = type; 15 | this.raw = raw; 16 | this.ref = ref; 17 | } 18 | 19 | public ValueWrapper replaceRaw(String raw) { 20 | return new ValueWrapper(type, ref, raw); 21 | } 22 | 23 | public static ValueWrapper wrapId(int ref, String raw) { 24 | return new ValueWrapper(ID, ref, raw); 25 | } 26 | 27 | public static ValueWrapper wrapStyle(int ref, String raw) { 28 | return new ValueWrapper(STYLE, ref, raw); 29 | } 30 | 31 | public static ValueWrapper wrapClass(int ref, String raw) { 32 | return new ValueWrapper(CLASS, ref, raw); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /xposed-bridge/src/main/java/pxb/android/package.html: -------------------------------------------------------------------------------- 1 |

Source code of axml project.

2 |

Revision 2394d02d86bb - Apr 22, 2014

--------------------------------------------------------------------------------