Move DexParser to util package
This commit is contained in:
parent
fd82805c39
commit
702c10eff4
|
|
@ -66,6 +66,7 @@ import de.robv.android.xposed.XposedInit;
|
||||||
import io.github.libxposed.XposedContext;
|
import io.github.libxposed.XposedContext;
|
||||||
import io.github.libxposed.XposedModule;
|
import io.github.libxposed.XposedModule;
|
||||||
import io.github.libxposed.XposedModuleInterface;
|
import io.github.libxposed.XposedModuleInterface;
|
||||||
|
import io.github.libxposed.util.DexParser;
|
||||||
|
|
||||||
public class LSPosedContext extends XposedContext {
|
public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,3 @@ import android.content.Context;
|
||||||
public abstract class XposedContext extends Context implements XposedInterface {
|
public abstract class XposedContext extends Context implements XposedInterface {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import io.github.libxposed.util.DexParser;
|
||||||
|
|
||||||
public class XposedContextWrapper extends ContextWrapper implements XposedInterface {
|
public class XposedContextWrapper extends ContextWrapper implements XposedInterface {
|
||||||
|
|
||||||
XposedContextWrapper(XposedContext base) {
|
XposedContextWrapper(XposedContext base) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import java.lang.reflect.Method;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ConcurrentModificationException;
|
import java.util.ConcurrentModificationException;
|
||||||
|
|
||||||
|
import io.github.libxposed.util.DexParser;
|
||||||
|
|
||||||
public interface XposedInterface {
|
public interface XposedInterface {
|
||||||
int API = 100;
|
int API = 100;
|
||||||
|
|
||||||
|
|
@ -148,192 +150,4 @@ public interface XposedInterface {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
DexParser parseDex(ByteBuffer dexData) throws IOException;
|
DexParser parseDex(ByteBuffer dexData) throws IOException;
|
||||||
|
|
||||||
interface DexParser extends AutoCloseable {
|
|
||||||
interface ClassDef {
|
|
||||||
@NonNull
|
|
||||||
TypeId getType();
|
|
||||||
|
|
||||||
int getAccessFlags();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
TypeId getSuperClass();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
TypeList getInterfaces();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
StringId getSourceFile();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
EncodedField[] getStaticFields();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
EncodedField[] getInstanceFields();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
EncodedMethod[] getDirectMethods();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
EncodedMethod[] getVirtualMethods();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
FieldAnnotation[] getFieldAnnotations();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
MethodAnnotation[] getMethodAnnotations();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
ParameterAnnotation[] getParameterAnnotations();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FieldAnnotation {
|
|
||||||
@NonNull
|
|
||||||
FieldId getField();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
AnnotationItem[] getAnnotations();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MethodAnnotation {
|
|
||||||
@NonNull
|
|
||||||
MethodId getMethod();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
AnnotationItem[] getAnnotations();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ParameterAnnotation {
|
|
||||||
@NonNull
|
|
||||||
MethodId getMethod();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
AnnotationList getAnnotations();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AnnotationList {
|
|
||||||
@NonNull
|
|
||||||
AnnotationItem[] getAnnotations();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AnnotationItem {
|
|
||||||
int getVisibility();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
Annotation getAnnotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Annotation {
|
|
||||||
@NonNull
|
|
||||||
TypeId getType();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
AnnotationElement[] getElements();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AnnotationElement {
|
|
||||||
int getType();
|
|
||||||
|
|
||||||
ByteBuffer value();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeList {
|
|
||||||
@NonNull
|
|
||||||
TypeId[] getTypes();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeId {
|
|
||||||
@NonNull
|
|
||||||
StringId getDescriptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EncodedField {
|
|
||||||
@NonNull
|
|
||||||
FieldId getField();
|
|
||||||
|
|
||||||
int getAccessFlags();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EncodedMethod {
|
|
||||||
@NonNull
|
|
||||||
MethodId getMethod();
|
|
||||||
|
|
||||||
int getAccessFlags();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
MethodId[] getInvokedMethods();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
FieldId[] getAccessedFields();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
FieldId[] getAssignedFields();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
int[] getOpcodes();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
StringId getReferencedString();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Id {
|
|
||||||
int getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface StringId extends Id {
|
|
||||||
@NonNull
|
|
||||||
String getString();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FieldId extends Id {
|
|
||||||
@NonNull
|
|
||||||
TypeId getType();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
TypeId getDeclaringClass();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
StringId getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MethodId extends Id {
|
|
||||||
@NonNull
|
|
||||||
TypeId getDeclaringClass();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
ProtoId getProtoType();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
StringId getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ProtoId extends Id {
|
|
||||||
@NonNull
|
|
||||||
StringId getShorty();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
TypeId getReturnType();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
ClassDef[] getClassDef();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
StringId[] getStringId();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
TypeId[] getTypeId();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
FieldId[] getFieldId();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
MethodId[] getMethodId();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
ProtoId[] getProtoId();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
TypeList[] getTypeList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,195 @@
|
||||||
|
package io.github.libxposed.util;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
public interface DexParser extends AutoCloseable {
|
||||||
|
|
||||||
|
interface ClassDef {
|
||||||
|
@NonNull
|
||||||
|
TypeId getType();
|
||||||
|
|
||||||
|
int getAccessFlags();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
TypeId getSuperClass();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
TypeList getInterfaces();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
StringId getSourceFile();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
EncodedField[] getStaticFields();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
EncodedField[] getInstanceFields();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
EncodedMethod[] getDirectMethods();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
EncodedMethod[] getVirtualMethods();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
FieldAnnotation[] getFieldAnnotations();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
MethodAnnotation[] getMethodAnnotations();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
ParameterAnnotation[] getParameterAnnotations();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FieldAnnotation {
|
||||||
|
@NonNull
|
||||||
|
FieldId getField();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
AnnotationItem[] getAnnotations();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MethodAnnotation {
|
||||||
|
@NonNull
|
||||||
|
MethodId getMethod();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
AnnotationItem[] getAnnotations();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ParameterAnnotation {
|
||||||
|
@NonNull
|
||||||
|
MethodId getMethod();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
AnnotationList getAnnotations();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AnnotationList {
|
||||||
|
@NonNull
|
||||||
|
AnnotationItem[] getAnnotations();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AnnotationItem {
|
||||||
|
int getVisibility();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
Annotation getAnnotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Annotation {
|
||||||
|
@NonNull
|
||||||
|
TypeId getType();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
AnnotationElement[] getElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AnnotationElement {
|
||||||
|
int getType();
|
||||||
|
|
||||||
|
ByteBuffer value();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TypeList {
|
||||||
|
@NonNull
|
||||||
|
TypeId[] getTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TypeId {
|
||||||
|
@NonNull
|
||||||
|
StringId getDescriptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EncodedField {
|
||||||
|
@NonNull
|
||||||
|
FieldId getField();
|
||||||
|
|
||||||
|
int getAccessFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EncodedMethod {
|
||||||
|
@NonNull
|
||||||
|
MethodId getMethod();
|
||||||
|
|
||||||
|
int getAccessFlags();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
MethodId[] getInvokedMethods();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
FieldId[] getAccessedFields();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
FieldId[] getAssignedFields();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
int[] getOpcodes();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
StringId getReferencedString();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Id {
|
||||||
|
int getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StringId extends Id {
|
||||||
|
@NonNull
|
||||||
|
String getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FieldId extends Id {
|
||||||
|
@NonNull
|
||||||
|
TypeId getType();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
TypeId getDeclaringClass();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
StringId getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MethodId extends Id {
|
||||||
|
@NonNull
|
||||||
|
TypeId getDeclaringClass();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
ProtoId getProtoType();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
StringId getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProtoId extends Id {
|
||||||
|
@NonNull
|
||||||
|
StringId getShorty();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
TypeId getReturnType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
ClassDef[] getClassDef();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
StringId[] getStringId();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
TypeId[] getTypeId();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
FieldId[] getFieldId();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
MethodId[] getMethodId();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
ProtoId[] getProtoId();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
TypeList[] getTypeList();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue