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

feat(gui): add parameters logging in Frida code snippet #1498

Merged
merged 1 commit into from
May 28, 2022
Merged
Changes from all commits
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
17 changes: 13 additions & 4 deletions jadx-gui/src/main/java/jadx/gui/ui/codearea/FridaAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,24 @@ private String generateMethodSnippet(JMethod jMth) {
} else {
functionUntilImplementation = String.format("%s[\"%s\"].implementation", shortClassName, methodName);
}
String functionParametersString = String.join(", ", collectMethodArgNames(javaMethod));

List<String> methodArgNames = collectMethodArgNames(javaMethod);

String functionParametersString = String.join(", ", methodArgNames);
String logParametersString =
methodArgNames.stream().map(e -> String.format("'%s: ' + %s", e, e)).collect(Collectors.joining(" + ', ' + "));
if (logParametersString.length() > 0) {
logParametersString = " + ', ' + " + logParametersString;
}
String functionParameterAndBody = String.format(
"%s = function(%s){\n"
+ " console.log('%s is called');\n"
"%s = function (%s) {\n"
+ " console.log('%s is called'%s);\n"
+ " let ret = this.%s(%s);\n"
+ " console.log('%s ret value is ' + ret);\n"
+ " return ret;\n"
+ "};",
functionUntilImplementation, functionParametersString, methodName, methodName, functionParametersString, methodName);
functionUntilImplementation, functionParametersString, methodName, logParametersString, methodName,
functionParametersString, methodName);

return generateClassSnippet(jMth.getJParent()) + "\n" + functionParameterAndBody;
}
Expand Down