vfsfitvnm / frida-il2cpp-bridge

A Frida module to dump, trace or hijack any Il2Cpp application at runtime, without needing the global-metadata.dat file.
https://github.com/vfsfitvnm/frida-il2cpp-bridge/wiki
MIT License
914 stars 191 forks source link

can't invoke a no-static function #520

Open XUCharles opened 5 days ago

XUCharles commented 5 days ago

i want to implementation a no-static function。 eg:

Il2Cpp.perform(() => { const assembly = Il2Cpp.domain.assembly("Test.GameLogic"); const targetClass = assembly.image.class("TFramework.GameLogic.BattleCharacterMovementComponent"); const targetMethod = targetClass.method("SetSpeed"); targetMethod.implementation = function (speed){ console.log("speed", speed) //speed = ptr(30) res = targetMethod.invoke(speed) return res } } this function is System.Void SetSpeed(System.Single speed), a no-static function。 i just want to invoke this function or modify the parameters of the function. but throw a error il2cpp: cannot invoke non-static method SetSpeed as it must be invoked throught a Il2Cpp.Object, not a Il2Cpp.Class. how can i implement it

thinhbuzz commented 5 days ago

targetMethod.invoke(speed) => this.method("SetSpeed").invoke(speed)

XUCharles commented 5 days ago

targetMethod.invoke(speed) => this.method("SetSpeed").invoke(speed)

thanks!! it works

XUCharles commented 4 days ago

targetMethod.invoke(speed) => this.method("SetSpeed").invoke(speed)

if the speed or the res is not a float type but a UnityEngine.Vector3 such as (2.3 ,2 ,4). how can i modify it. i try: var res = this.method("SetSpeed").invoke() res.x = xxx return res or
var modifiedRes = new Il2Cpp.ValueType(res.handle) modifiedRes.x = xxx return modifiedRes just does't work

thinhbuzz commented 4 days ago

modifiedRes.field('x').value = xxx

XUCharles commented 4 days ago

modifiedRes.field('x').value = xxx

it help. thanks

thinhbuzz commented 4 days ago

you're welcome