fix(gui): correct Frida snippet for constructor (PR #1605)

When hooking a constructor with Frida, call `$new` instead of `$init`. `$init` cannot be used to instantiate an object and is reserved for hooking.

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
Areizen
2022-08-06 21:16:37 +02:00
committed by GitHub
parent 75b52d672e
commit cd32151083
@@ -79,8 +79,11 @@ public final class FridaAction extends JNodeAction {
JavaMethod javaMethod = jMth.getJavaMethod();
MethodInfo methodInfo = javaMethod.getMethodNode().getMethodInfo();
String methodName = StringEscapeUtils.escapeEcmaScript(methodInfo.getName());
String callMethodName = methodName;
if (methodInfo.isConstructor()) {
methodName = "$init";
callMethodName = "$new";
}
String shortClassName = javaMethod.getDeclaringClass().getName();
@@ -108,7 +111,7 @@ public final class FridaAction extends JNodeAction {
+ " console.log('%s ret value is ' + ret);\n"
+ " return ret;\n"
+ "};",
functionUntilImplementation, functionParametersString, methodName, logParametersString, methodName,
functionUntilImplementation, functionParametersString, methodName, logParametersString, callMethodName,
functionParametersString, methodName);
return generateClassSnippet(jMth.getJParent()) + "\n" + functionParameterAndBody;