LSPosed / LSPlant

A hook framework for Android Runtime (ART)
https://lsposed.org/LSPlant/
GNU Lesser General Public License v3.0
814 stars 203 forks source link

Use LSPlant in zygisk modules #53

Closed nitanmarcel closed 10 months ago

nitanmarcel commented 10 months ago

Is it possible to integrame LSPlant in an zygisk module? I tried searching for way of doing it but I can't seem to find an optimal way of doing it. Is there a way to maybe use it in an ndk project and statically include lsposed in the zygisk library?

BryanGIG commented 10 months ago

Yes, you can use LsPlant in zygisk module

You just have to init LsPlant in your native and use java hook api such as Maple or anything else to be able hook from java

I've tried it, and it works

yujincheng08 commented 10 months ago

LSPosed is also one example.

nitanmarcel commented 10 months ago

Yes, you can use LsPlant in zygisk module

You just have to init LsPlant in your native and use java hook api such as Maple or anything else to be able hook from java

I've tried it, and it works

Won't that mean that I somehow have to load the dex with the java side of hooks into the process from zygisk.so?

That's where I'm confused, Maple and some of the similar projects creates it's own zygisk.so file so I won't be able to load the hooks defined in java in the process. Or am I? Maybe I'm just setting up my projects in the wrong way.

BryanGIG commented 10 months ago

Won't that mean that I somehow have to load the dex with the java side of hooks into the process from zygisk.so?

Yes, you need to load dex into your targeted process,

That's where I'm confused, Maple and some of the similar projects creates it's own zygisk.so file so I won't be able to load the hooks defined in java in the process. Or am I? Maybe I'm just setting up my projects in the wrong way.

You just need to take the java library and register the native function to your own zygisk.so, then you can call lsplant api from it

As, @yujincheng08 said, LSPosed can be reference for this implementation

nitanmarcel commented 10 months ago

Ah, thanks to both.

Idk why I had the idea that LSPosed doesn't use LSPatch and they are different implementations for the same thing. Anyway looking a little more carefully at the lsposed repo I got a good example on how to use it in my own project.

Thanks, I appreciate it.