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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user