接口 XposedInterface

所有已知实现类:
XposedInterfaceWrapper, XposedModule

public interface XposedInterface
Xposed interface for modules to operate on application processes.
  • 字段详细资料

    • API_101

      static final int API_101
      Behavior changes: all modules
      • Modules cannot be injected into zygote; they are only loaded within the process of the scope.
      Behavior changes: Modules targeting 101 or higher
      • This is the first API version.
      另请参阅:
    • LIB_API

      static final int LIB_API
      The API version of this library. This is a static value for the framework. Modules should use getApiVersion() to check the API version at runtime.
      另请参阅:
    • PROP_CAP_SYSTEM

      static final long PROP_CAP_SYSTEM
      The framework has the capability to hook system_server and other system processes.
      另请参阅:
    • PROP_CAP_REMOTE

      static final long PROP_CAP_REMOTE
      The framework provides remote preferences and remote files support.
      另请参阅:
    • PROP_RT_API_PROTECTION

      static final long PROP_RT_API_PROTECTION
      The framework disallows accessing Xposed API via reflection or dynamically loaded code.
      另请参阅:
    • PRIORITY_DEFAULT

      static final int PRIORITY_DEFAULT
      The default hook priority.
      另请参阅:
    • PRIORITY_LOWEST

      static final int PRIORITY_LOWEST
      Execute at the end of the interception chain.
      另请参阅:
    • PRIORITY_HIGHEST

      static final int PRIORITY_HIGHEST
      Execute at the beginning of the interception chain.
      另请参阅:
  • 方法详细资料

    • getApiVersion

      default int getApiVersion()
      Gets the runtime Xposed API version. Framework implementations must not override this method.
    • getFrameworkName

      @NonNull String getFrameworkName()
      Gets the Xposed framework name of current implementation.
    • getFrameworkVersion

      @NonNull String getFrameworkVersion()
      Gets the Xposed framework version of current implementation.
    • getFrameworkVersionCode

      long getFrameworkVersionCode()
      Gets the Xposed framework version code of current implementation.
    • getFrameworkProperties

      long getFrameworkProperties()
      Gets the Xposed framework properties. Properties with prefix PROP_RT_ may change among launches.
    • hook

      @NonNull XposedInterface.HookBuilder hook(@NonNull Executable origin)
      Hook a method / constructor.
      参数:
      origin - The executable to be hooked
      返回:
      The builder for the hook
    • hookClassInitializer

      @NonNull XposedInterface.HookBuilder hookClassInitializer(@NonNull Class<?> origin)
      Hook the static initializer (<clinit>) of a class.

      The static initializer is treated as a regular static void() method with no parameters. Accordingly, in the XposedInterface.Chain passed to the hooker:

      Note: If the class is already initialized, the hook will never be called.

      参数:
      origin - The class whose static initializer is to be hooked
      返回:
      The builder for the hook
    • deoptimize

      boolean deoptimize(@NonNull Executable executable)
      Deoptimizes a method / constructor in case hooked callee is not called because of inline.

      By deoptimizing the method, the runtime will fall back to calling all callees without inlining. For example, when a short hooked method B is invoked by method A, the callback to B is not invoked after hooking, which may mean A has inlined B inside its method body. To force A to call the hooked B, you can deoptimize A and then your hook can take effect.

      Generally, you need to find all the callers of your hooked callee, and that can hardly be achieved (but you can still search all callers by using DexKit). Use this method if you are sure the deoptimized callers are all you need. Otherwise, it would be better to change the hook point or to deoptimize the whole app manually (by simply reinstalling the app without uninstall).

      参数:
      executable - The method / constructor to deoptimize
      返回:
      Indicate whether the deoptimizing succeed or not
    • getInvoker

      @NonNull XposedInterface.Invoker<?,Method> getInvoker(@NonNull Method method)
      Get a method invoker for the given method. Invocations through invokers will bypass access checks. The default type of the invoker is XposedInterface.Invoker.Type.Chain.FULL.
      参数:
      method - The method to get the invoker for
      返回:
      The method invoker
    • getInvoker

      @NonNull <T> XposedInterface.CtorInvoker<T> getInvoker(@NonNull Constructor<T> constructor)
      Get a constructor invoker for the given constructor. Invocations through invokers will bypass access checks. The default type of the invoker is XposedInterface.Invoker.Type.Chain.FULL.
      类型参数:
      T - The type of the constructor
      参数:
      constructor - The constructor to get the invoker for
      返回:
      The constructor invoker
    • log

      void log(int priority, @Nullable String tag, @NonNull String msg)
      Writes a message to the Xposed log.
      参数:
      priority - The log priority, see Log
      tag - The log tag
      msg - The log message
    • log

      void log(int priority, @Nullable String tag, @NonNull String msg, @Nullable Throwable tr)
      Writes a message to the Xposed log.
      参数:
      priority - The log priority, see Log
      tag - The log tag
      msg - The log message
      tr - An exception to log
    • getModuleApplicationInfo

      @NonNull ApplicationInfo getModuleApplicationInfo()
      Gets the application info of the module.
    • getRemotePreferences

      @NonNull SharedPreferences getRemotePreferences(@NonNull String group)
      Gets remote preferences stored in Xposed framework. Note that those are read-only in hooked apps.
      参数:
      group - Group name
      返回:
      The preferences
      抛出:
      UnsupportedOperationException - If the framework is embedded
    • listRemoteFiles

      @NonNull String[] listRemoteFiles()
      List all files in the module's shared data directory.
      返回:
      The file list
      抛出:
      UnsupportedOperationException - If the framework is embedded
    • openRemoteFile

      @NonNull ParcelFileDescriptor openRemoteFile(@NonNull String name) throws FileNotFoundException
      Open a file in the module's shared data directory. The file is opened in read-only mode.
      参数:
      name - File name, must not contain path separators and . or ..
      返回:
      The file descriptor
      抛出:
      FileNotFoundException - If the file does not exist or the path is forbidden
      UnsupportedOperationException - If the framework is embedded