Skip to content

Commit

Permalink
fix(gui): correct Frida snippet for constructor (PR #1605)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Areizen and Your Name authored Aug 6, 2022
1 parent 75b52d6 commit cd32151
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion jadx-gui/src/main/java/jadx/gui/ui/codearea/FridaAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ private String generateMethodSnippet(JMethod jMth) {
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();

Expand Down Expand Up @@ -108,7 +111,7 @@ private String generateMethodSnippet(JMethod jMth) {
+ " 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;
Expand Down

0 comments on commit cd32151

Please sign in to comment.