Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print the renamed function name in a frida snippet #1773

Merged
merged 4 commits into from
Jan 28, 2023
Merged
Changes from 1 commit
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
16 changes: 13 additions & 3 deletions jadx-gui/src/main/java/jadx/gui/ui/codearea/FridaAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import jadx.api.JavaClass;
import jadx.api.JavaField;
import jadx.api.JavaMethod;
import jadx.api.data.ICodeRename;
import jadx.api.data.impl.JadxNodeRef;
import jadx.api.metadata.ICodeNodeRef;
import jadx.api.metadata.annotations.NodeDeclareRef;
import jadx.api.metadata.annotations.VarNode;
Expand Down Expand Up @@ -78,10 +80,18 @@ private String generateMethodSnippet(JMethod jMth) {
MethodNode mth = jMth.getJavaMethod().getMethodNode();
MethodInfo methodInfo = mth.getMethodInfo();
String methodName;
String newMethodName;
if (methodInfo.isConstructor()) {
methodName = "$init";
newMethodName = methodName;
} else {
methodName = StringEscapeUtils.escapeEcmaScript(methodInfo.getName());
newMethodName = methodName;
Ran-Naor marked this conversation as resolved.
Show resolved Hide resolved
for (ICodeRename rename : getCodeArea().getContentPanel().getTabbedPane().getMainWindow().getProject().getCodeData().getRenames()) {
if (null == rename.getCodeRef() && rename.getNodeRef().equals(JadxNodeRef.forMth(jMth.getJavaMethod()))) {
newMethodName = rename.getNewName();
}
}
}
String overload;
if (isOverloaded(mth)) {
Expand All @@ -106,15 +116,15 @@ private String generateMethodSnippet(JMethod jMth) {
// no return value
return classSnippet + "\n"
+ shortClassName + "[\"" + methodName + "\"]" + overload + ".implementation = function (" + args + ") {\n"
+ " console.log('" + shortClassName + "." + methodName + " is called'" + logArgs + ");\n"
+ " console.log('" + shortClassName + "." + newMethodName + " is called'" + logArgs + ");\n"
+ " this[\"" + methodName + "\"](" + args + ");\n"
+ "};";
}
return classSnippet + "\n"
+ shortClassName + "[\"" + methodName + "\"]" + overload + ".implementation = function (" + args + ") {\n"
+ " console.log('" + shortClassName + "." + methodName + " is called'" + logArgs + ");\n"
+ " console.log('" + shortClassName + "." + newMethodName + " is called'" + logArgs + ");\n"
+ " let ret = this[\"" + methodName + "\"](" + args + ");\n"
+ " console.log('" + shortClassName + "." + methodName + " return: ' + ret);\n"
+ " console.log('" + shortClassName + "." + newMethodName + " return: ' + ret);\n"
+ " return ret;\n"
+ "};";
}
Expand Down