You’re almost there — sign up to start building in Notion today.
Sign up or login
Working with Objects/Instances

Working with Objects/Instances

There are lot’s of situations which you can’t create new object to calling an method or changing an property. You need to finding existing instances and then manipulate them.
To achieve this goal you can use use
Java.choose
.
Example:
Java.perform( function(){ Java.choose("com.example.package.player", { onMatch: function(instance){ instance.increaseLives() send("[+] Player lives increased to: " + instance.lives.value) }, onCompelet: function(){ console.log("[+] Done") } }) } )

Passing an Object as Parameter

Java.perform(function(){ var itemClassRef = Java.use("com.example.package.Item") var itemClassObj = itemClassRef.$new(1000) var bossClassRef = Java.use("com.example.package.Boss") bossClassRef.$new(itemClassObj) })
💡 Callout icon
You can use
Java.choose
to send an existing object as an parameter.

Hooking Constructors

In order to hooking contractors we should use
$init
keyword.
let Player = Java.use("de.fgerbig.spacepeng.components.Player"); Player.$init.implementation = function(){ console.log("[+] Hooking constructors") this.$init() }

Tasks

Print player lives and then change them in SpacePeng application
Multiple shot
Coins Rain
etc