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

How to Create a instance for android? #272

Closed
mutepigz opened this issue May 6, 2017 · 2 comments
Closed

How to Create a instance for android? #272

mutepigz opened this issue May 6, 2017 · 2 comments

Comments

@mutepigz
Copy link

mutepigz commented May 6, 2017

I face a problem that I want to call a function but it belongs to a class
I tried code like

var Class = Java.use("com.test.Main");                                                                                                                      
Class.function("123");

but it error

cannot call instance method without an instance

so how to create a instance for android?

@Oreaz
Copy link

Oreaz commented May 8, 2017

https://www.frida.re/docs/javascript-api/#java

Java.use(className): dynamically get a JavaScript wrapper for className that you can instantiate objects from by calling $new() on it to invoke a constructor.

Another example

Java.perform(function () {
	var stringClass = Java.use("java.lang.String");
	var stringInstance = stringClass.$new("Hello World");
	send(stringInstance.toString());
});

basically in the example code it's the equivalent of
new String("Hello World") in Java
https://developer.android.com/reference/java/lang/String.html

@royhershkovitz
Copy link

@oleavr oleavr closed this as completed Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants