Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions core/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
-keepclassmembers class org.lsposed.lspd.impl.LSPosedHookCallback {
public <methods>;
}
-keep,allowoptimization,allowobfuscation @io.github.libxposed.api.annotations.* class * {
@io.github.libxposed.api.annotations.BeforeInvocation <methods>;
@io.github.libxposed.api.annotations.AfterInvocation <methods>;
-keepclassmembers,allowoptimization class ** implements io.github.libxposed.api.XposedInterface$Hooker {
public static *** before();
public static *** before(io.github.libxposed.api.XposedInterface$BeforeHookCallback);
public static void after();
public static void after(io.github.libxposed.api.XposedInterface$AfterHookCallback);
public static void after(io.github.libxposed.api.XposedInterface$AfterHookCallback, ***);
}
-assumenosideeffects class android.util.Log {
public static *** v(...);
Expand Down
6 changes: 1 addition & 5 deletions core/src/main/java/org/lsposed/lspd/hooker/AttachHooker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

import de.robv.android.xposed.XposedInit;
import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.XposedHooker;

@XposedHooker
public class AttachHooker implements XposedInterface.Hooker {

@AfterInvocation
public static void afterHookedMethod(XposedInterface.AfterHookCallback callback) {
public static void after(XposedInterface.AfterHookCallback callback) {
XposedInit.loadModules((ActivityThread) callback.getThisObject());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
import org.lsposed.lspd.util.Utils.Log;

import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.BeforeInvocation;
import io.github.libxposed.api.annotations.XposedHooker;

@XposedHooker
public class CrashDumpHooker implements XposedInterface.Hooker {

@BeforeInvocation
public static void beforeHookedMethod(XposedInterface.BeforeHookCallback callback) {
public static void before(XposedInterface.BeforeHookCallback callback) {
try {
var e = (Throwable) callback.getArgs()[0];
LSPosedBridge.log("Crash unexpectedly: " + Log.getStackTraceString(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
import org.lsposed.lspd.util.Hookers;

import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.XposedHooker;

// system_server initialization
@XposedHooker
public class HandleSystemServerProcessHooker implements XposedInterface.Hooker {

public interface Callback {
Expand All @@ -42,8 +39,7 @@ public interface Callback {
public static volatile Callback callback = null;

@SuppressLint("PrivateApi")
@AfterInvocation
public static void afterHookedMethod() {
public static void after() {
Hookers.logD("ZygoteInit#handleSystemServerProcess() starts");
try {
// get system_server classLoader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.XposedModuleInterface;
import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.XposedHooker;

@SuppressLint("BlockedPrivateApi")
@XposedHooker
public class LoadedApkCreateCLHooker implements XposedInterface.Hooker {
private final static Field defaultClassLoaderField;

Expand All @@ -77,8 +74,7 @@ static void addLoadedApk(LoadedApk loadedApk) {
loadedApks.add(loadedApk);
}

@AfterInvocation
public static void afterHookedMethod(XposedInterface.AfterHookCallback callback) {
public static void after(XposedInterface.AfterHookCallback callback) {
LoadedApk loadedApk = (LoadedApk) callback.getThisObject();

if (callback.getArgs()[0] != null || !loadedApks.contains(loadedApk)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.XposedInit;
import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.XposedHooker;

// when a package is loaded for an existing process, trigger the callbacks as well
@XposedHooker
public class LoadedApkCtorHooker implements XposedInterface.Hooker {

@AfterInvocation
public static void afterHookedMethod(XposedInterface.AfterHookCallback callback) {
public static void after(XposedInterface.AfterHookCallback callback) {
Hookers.logD("LoadedApk#<init> starts");

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
import org.lsposed.lspd.nativebridge.HookBridge;

import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.XposedHooker;

@XposedHooker
public class OpenDexFileHooker implements XposedInterface.Hooker {

@AfterInvocation
public static void afterHookedMethod(XposedInterface.AfterHookCallback callback) {
public static void after(XposedInterface.AfterHookCallback callback) {
ClassLoader classLoader = null;
for (var arg : callback.getArgs()) {
if (arg instanceof ClassLoader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.XposedModuleInterface;
import io.github.libxposed.api.annotations.BeforeInvocation;
import io.github.libxposed.api.annotations.XposedHooker;

@XposedHooker
public class StartBootstrapServicesHooker implements XposedInterface.Hooker {

@BeforeInvocation
public static void beforeHookedMethod() {
public static void before() {
logD("SystemServer#startBootstrapServices() starts");

try {
Expand Down
22 changes: 8 additions & 14 deletions core/src/main/java/org/lsposed/lspd/impl/LSPosedBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

import de.robv.android.xposed.XposedBridge;
import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.BeforeInvocation;
import io.github.libxposed.api.annotations.XposedHooker;
import io.github.libxposed.api.errors.HookFailedError;

public class LSPosedBridge {
Expand Down Expand Up @@ -218,16 +215,14 @@ public static void dummyCallback() {
throw new IllegalArgumentException("Cannot hook Method.invoke");
} else if (hooker == null) {
throw new IllegalArgumentException("hooker should not be null!");
} else if (hooker.getAnnotation(XposedHooker.class) == null) {
throw new IllegalArgumentException("Hooker should be annotated with @XposedHooker");
}

Method beforeInvocation = null, afterInvocation = null;
var modifiers = Modifier.PUBLIC | Modifier.STATIC;
for (var method : hooker.getDeclaredMethods()) {
if (method.getAnnotation(BeforeInvocation.class) != null) {
if (method.getName().equals("before")) {
if (beforeInvocation != null) {
throw new IllegalArgumentException("More than one method annotated with @BeforeInvocation");
throw new IllegalArgumentException("More than one method named before");
}
boolean valid = (method.getModifiers() & modifiers) == modifiers;
var params = method.getParameterTypes();
Expand All @@ -237,13 +232,12 @@ public static void dummyCallback() {
valid = false;
}
if (!valid) {
throw new IllegalArgumentException("BeforeInvocation method format is invalid");
throw new IllegalArgumentException("before method format is invalid");
}
beforeInvocation = method;
}
if (method.getAnnotation(AfterInvocation.class) != null) {
} else if (method.getName().equals("after")) {
if (afterInvocation != null) {
throw new IllegalArgumentException("More than one method annotated with @AfterInvocation");
throw new IllegalArgumentException("More than one method named after");
}
boolean valid = (method.getModifiers() & modifiers) == modifiers;
valid &= method.getReturnType().equals(void.class);
Expand All @@ -254,13 +248,13 @@ public static void dummyCallback() {
valid = false;
}
if (!valid) {
throw new IllegalArgumentException("AfterInvocation method format is invalid");
throw new IllegalArgumentException("after method format is invalid");
}
afterInvocation = method;
}
}
if (beforeInvocation == null && afterInvocation == null) {
throw new IllegalArgumentException("No method annotated with @BeforeInvocation or @AfterInvocation");
throw new IllegalArgumentException("No method named before or after found in " + hooker.getName());
}
try {
if (beforeInvocation == null) {
Expand All @@ -271,7 +265,7 @@ public static void dummyCallback() {
var ret = beforeInvocation.getReturnType();
var params = afterInvocation.getParameterTypes();
if (ret != void.class && params.length == 2 && !ret.equals(params[1])) {
throw new IllegalArgumentException("BeforeInvocation and AfterInvocation method format is invalid");
throw new IllegalArgumentException("before and after method format is invalid");
}
}
} catch (NoSuchMethodException e) {
Expand Down
13 changes: 12 additions & 1 deletion core/src/main/java/org/lsposed/lspd/impl/LSPosedContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,16 @@ public <T> boolean deoptimize(@NonNull Constructor<T> constructor) {

@Nullable
@Override
public Object invokeOrigin(@NonNull Method method, @Nullable Object thisObject, Object[] args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException {
public Object invokeOrigin(@NonNull Method method, @Nullable Object thisObject, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException {
return HookBridge.invokeOriginalMethod(method, thisObject, args);
}

@Override
public <T> void invokeOrigin(@NonNull Constructor<T> constructor, @NonNull T thisObject, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException {
// The bridge returns an Object (null for void/constructors), which we discard.
HookBridge.invokeOriginalMethod(constructor, thisObject, args);
}

private static char getTypeShorty(Class<?> type) {
if (type == int.class) {
return 'I';
Expand Down Expand Up @@ -257,6 +263,11 @@ public Object invokeSpecial(@NonNull Method method, @NonNull Object thisObject,
return HookBridge.invokeSpecialMethod(method, getExecutableShorty(method), method.getDeclaringClass(), thisObject, args);
}

@Override
public <T> void invokeSpecial(@NonNull Constructor<T> constructor, @NonNull T thisObject, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException {
HookBridge.invokeSpecialMethod(constructor, getExecutableShorty(constructor), constructor.getDeclaringClass(), thisObject, args);
}

@NonNull
@Override
public <T> T newInstanceOrigin(@NonNull Constructor<T> constructor, Object... args) throws InvocationTargetException, IllegalAccessException, InstantiationException {
Expand Down
2 changes: 1 addition & 1 deletion external/apache/commons-lang
Submodule commons-lang updated 37 files
+6 −5 .github/workflows/codeql-analysis.yml
+1 −1 .github/workflows/dependency-review.yml
+4 −3 .github/workflows/maven.yml
+1 −1 .github/workflows/scorecards-analysis.yml
+5 −0 pom.xml
+14 −0 src/changes/changes.xml
+429 −113 src/main/java/org/apache/commons/lang3/ArrayUtils.java
+23 −12 src/main/java/org/apache/commons/lang3/ClassUtils.java
+7 −3 src/main/java/org/apache/commons/lang3/Conversion.java
+3 −3 src/main/java/org/apache/commons/lang3/DoubleRange.java
+4 −4 src/main/java/org/apache/commons/lang3/IntegerRange.java
+3 −3 src/main/java/org/apache/commons/lang3/LongRange.java
+3 −3 src/main/java/org/apache/commons/lang3/NumberRange.java
+4 −4 src/main/java/org/apache/commons/lang3/ObjectUtils.java
+15 −19 src/main/java/org/apache/commons/lang3/StringUtils.java
+5 −3 src/main/java/org/apache/commons/lang3/ThreadUtils.java
+28 −29 src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
+23 −10 src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java
+2 −0 src/main/java/org/apache/commons/lang3/concurrent/UncheckedFutureImpl.java
+7 −2 src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java
+1 −1 src/main/java/org/apache/commons/lang3/text/StrBuilder.java
+20 −9 src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
+9 −9 src/main/java/org/apache/commons/lang3/time/TimeZones.java
+1 −1 src/site/resources/checkstyle/checkstyle.xml
+118 −0 src/test/java/org/apache/commons/lang3/ArrayUtilsConcatTest.java
+157 −0 src/test/java/org/apache/commons/lang3/ArrayUtilsGetDimensions.java
+50 −15 src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+68 −0 src/test/java/org/apache/commons/lang3/ClassUtilsShortClassNameTest.java
+5 −1 src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
+5 −0 src/test/java/org/apache/commons/lang3/StringUtilsAbbreviateTest.java
+31 −0 src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java
+84 −0 src/test/java/org/apache/commons/lang3/arch/ProcessorTest.java
+117 −114 src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
+66 −0 src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java
+63 −1 src/test/java/org/apache/commons/lang3/concurrent/UncheckedFutureTest.java
+19 −19 src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
+30 −2 src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.lsposed.lspd.util.Utils;

import io.github.libxposed.api.XposedInterface;
import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.XposedHooker;


public class ParasiticManagerSystemHooker implements HandleSystemServerProcessHooker.Callback {
Expand All @@ -33,10 +31,8 @@ public static void beforeHookedMethod(XposedInterface.BeforeHookCallback callbac
}
}*/

@XposedHooker
private static class Hooker implements XposedInterface.Hooker {
@AfterInvocation
public static void afterHookedMethod(XposedInterface.AfterHookCallback callback) throws Throwable {
public static void after(XposedInterface.AfterHookCallback callback) throws Throwable {
var intent = (Intent) callback.getArgs()[0];
if (intent == null) return;
if (!intent.hasCategory("org.lsposed.manager.LAUNCH_MANAGER")) return;
Expand Down
Loading