Match original Xposed
This commit is contained in:
parent
d3a5b282cb
commit
715a25d0bd
|
|
@ -74,13 +74,7 @@ public final class DynamicBridge {
|
||||||
if (hooker == null) {
|
if (hooker == null) {
|
||||||
throw new IllegalStateException("method not hooked, cannot call original method.");
|
throw new IllegalStateException("method not hooked, cannot call original method.");
|
||||||
}
|
}
|
||||||
try {
|
return hooker.callBackup(thisObject, args);
|
||||||
return hooker.callBackup(thisObject, args);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw new InvocationTargetException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,29 +18,32 @@ public class LspHooker {
|
||||||
this.backup = backup;
|
this.backup = backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object callBackup(Object thisObject, Object[] args) throws Throwable {
|
public Object callBackup(Object thisObject, Object[] args) throws InvocationTargetException, IllegalAccessException {
|
||||||
try {
|
if (args == null) {
|
||||||
if (args == null) {
|
args = new Object[0];
|
||||||
args = new Object[0];
|
}
|
||||||
}
|
if (Modifier.isStatic(method.getModifiers())) {
|
||||||
if (Modifier.isStatic(method.getModifiers())) {
|
return backup.invoke(null, args);
|
||||||
return backup.invoke(null, args);
|
} else {
|
||||||
} else {
|
Object[] newArgs = new Object[args.length + 1];
|
||||||
Object[] newArgs = new Object[args.length + 1];
|
newArgs[0] = thisObject;
|
||||||
newArgs[0] = thisObject;
|
System.arraycopy(args, 0, newArgs, 1, args.length);
|
||||||
System.arraycopy(args, 0, newArgs, 1, args.length);
|
return backup.invoke(null, newArgs);
|
||||||
return backup.invoke(null, newArgs);
|
|
||||||
}
|
|
||||||
} catch (InvocationTargetException ite) {
|
|
||||||
throw ite.getCause();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
public Object handleHookedMethod(Object[] args) throws Throwable {
|
public Object handleHookedMethod(Object[] args) throws Throwable {
|
||||||
|
if (disableHooks) {
|
||||||
|
try {
|
||||||
|
return backup.invoke(null, args);
|
||||||
|
} catch (InvocationTargetException ite) {
|
||||||
|
throw ite.getCause();
|
||||||
|
}
|
||||||
|
}
|
||||||
Object[] callbacksSnapshot = additionalInfo.callbacks.getSnapshot();
|
Object[] callbacksSnapshot = additionalInfo.callbacks.getSnapshot();
|
||||||
final int callbacksLength = callbacksSnapshot.length;
|
final int callbacksLength = callbacksSnapshot.length;
|
||||||
if (disableHooks || callbacksLength == 0) {
|
if (callbacksLength == 0) {
|
||||||
try {
|
try {
|
||||||
return backup.invoke(null, args);
|
return backup.invoke(null, args);
|
||||||
} catch (InvocationTargetException ite) {
|
} catch (InvocationTargetException ite) {
|
||||||
|
|
@ -84,7 +87,11 @@ public class LspHooker {
|
||||||
|
|
||||||
// call original method if not requested otherwise
|
// call original method if not requested otherwise
|
||||||
if (!param.returnEarly) {
|
if (!param.returnEarly) {
|
||||||
param.setResult(callBackup(param.thisObject, param.args));
|
try {
|
||||||
|
param.setResult(callBackup(param.thisObject, param.args));
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
param.setThrowable(e.getCause());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// call "after method" callbacks
|
// call "after method" callbacks
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue