Commit Graph

6 Commits

Author SHA1 Message Date
WeiguangTWK 43ffcee9c8 Treewide: Add more API 101 behaviour 2026-04-02 20:31:28 +08:00
JingMatrix fc718e739b Implement hookClassInitializer API for static initializers (#535)
Since standard Java Reflection cannot access the `<clinit>` method (class's static initializer), we add a new native function, `HookBridge.getStaticInitializer`, which uses JNI `GetStaticMethodID` to retrieve a `Method` handle for it. The `LSPosedContext` API then passes this handle to the existing `doHook` machinery.

There are two possible exceptions thrown by the API:

- `IllegalArgumentException`: Thrown for user-level errors, such as attempting to hook a class that has no static initializer block (`static { ... }`). This is a predictable failure based on the provided class.

- `HookFailedError`: Thrown when the underlying native hooking engine (`lsplant`) fails to install the hook. This indicates a framework or environment-level issue (e.g., ART incompatibility, method inlining by the JIT/AOT compiler) and is not a fault in the module's logic.
2026-02-14 16:04:58 +01:00
JingMatrix cdc536f10b Adapt LSPosedBridge to convention-based hooker discovery (#534)
We update `LSPosedBridge` to align with upstream API changes, which have replaced annotation-based hooker discovery with a naming convention.

The `doHook` implementation has been refactored to:
- Remove dependencies on the deleted `io.github.libxposed.api.annotations` package (`XposedHooker`, `BeforeInvocation`, `AfterInvocation`).
- Scan for public static methods explicitly named `before` and `after` instead of relying on annotations.
- Enforce validation on these named methods to ensure they match the required signatures.

To adapt to this change, existing Hooker classes are refactored by removing the deprecated annotations and renaming their callback methods to `before` and `after` respectively.

Co-authored-by: frknkrc44 <krc440002@gmail.com>
2026-02-14 16:03:50 +01:00
JingMatrix ea71745430 Implement constructor invocation APIs in LSPosedContext (#533)
Unlike the existing `newInstance` variants which allocate and return a new object, these new APIs execute constructor logic on an existing, pre-allocated instance (`thisObject`). This separation of allocation and initialization allows for invoking original or super constructors within hook callbacks where the object reference is already established.

The implementation leverages the existing JNI `HookBridge` methods, as `invokeOriginalMethod` and `invokeSpecialMethod` already support void-return signatures required for constructor execution.

Co-authored-by: frknkrc44 <krc440002@gmail.com>
2026-02-14 16:02:02 +01:00
JingMatrix 211bd5f115
Centralize dependencies and migrate to submodules (#512)
Centralize dependencies and migrate to submodules

Move `apache` and `axml` modules to a unified `external` directory and migrate libxposed API and service interfaces from Maven dependencies to Git submodules.

Included changes:
- Updated .gitmodules with new paths.
- Simplified core.yml CI workflow.
- Updated Gradle project references to use the new directory structure.
- Added documentation for external components.
2026-01-22 15:13:06 +01:00
JingMatrix 4cec46a074 Fix and refactor DexParser implementation (#509)
In the LSPosedDexParser constructor, the methodIds array is allocated correctly, but the loop condition is wrong: its length is divided by 3 twice.

We rewrite this class in Kotlin, marking the first commit of refactoring LSPosed into Vector.

Co-authored-by: Willian Wang <git@willian.wang>
2026-01-21 18:12:25 +01:00