Add DexFile API
This commit is contained in:
parent
c389162c7a
commit
4478fd3e15
|
|
@ -48,12 +48,14 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Executable;
|
import java.lang.reflect.Executable;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
@ -894,4 +896,10 @@ public class LSPosedContext extends XposedContext {
|
||||||
public synchronized void log(@NonNull String message, @NonNull Throwable throwable) {
|
public synchronized void log(@NonNull String message, @NonNull Throwable throwable) {
|
||||||
Log.e(TAG, mPackageName + ": " + message, throwable);
|
Log.e(TAG, mPackageName + ": " + message, throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public DexFile openDexFile(ByteBuffer dexData) throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ import android.content.ContextWrapper;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
public class XposedContextWrapper extends ContextWrapper implements XposedInterface {
|
public class XposedContextWrapper extends ContextWrapper implements XposedInterface {
|
||||||
|
|
||||||
|
|
@ -125,6 +127,12 @@ public class XposedContextWrapper extends ContextWrapper implements XposedInterf
|
||||||
getBaseContext().log(message, throwable);
|
getBaseContext().log(message, throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public DexFile openDexFile(ByteBuffer dexData) throws IOException {
|
||||||
|
return getBaseContext().openDexFile(dexData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected void attachBaseContext(Context base) {
|
final protected void attachBaseContext(Context base) {
|
||||||
if (base instanceof XposedContext || base instanceof XposedContextWrapper) {
|
if (base instanceof XposedContext || base instanceof XposedContextWrapper) {
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ package io.github.libxposed;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ConcurrentModificationException;
|
import java.util.ConcurrentModificationException;
|
||||||
|
|
||||||
public interface XposedInterface {
|
public interface XposedInterface {
|
||||||
|
|
@ -143,4 +145,195 @@ public interface XposedInterface {
|
||||||
void log(@NonNull String message);
|
void log(@NonNull String message);
|
||||||
|
|
||||||
void log(@NonNull String message, @NonNull Throwable throwable);
|
void log(@NonNull String message, @NonNull Throwable throwable);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
DexFile openDexFile(ByteBuffer dexData) throws IOException;
|
||||||
|
|
||||||
|
interface DexFile 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 {
|
||||||
|
long 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