LSPlant LSPosed Developers
Loading...
Searching...
No Matches
lsplant.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <jni.h>
4
5#include <cstdint>
6#include <functional>
7#include <span>
8#include <string_view>
9
11namespace lsplant {
12
13inline namespace v2 {
84
96[[nodiscard, maybe_unused, gnu::visibility("default")]] bool Init(JNIEnv *env,
97 const InitInfo &info);
98
135[[nodiscard, maybe_unused, gnu::visibility("default")]] jobject Hook(JNIEnv *env,
136 jobject target_method,
137 jobject hooker_object,
138 jobject callback_method);
139
147[[nodiscard, maybe_unused, gnu::visibility("default")]] bool UnHook(JNIEnv *env,
148 jobject target_method);
149
156[[nodiscard, maybe_unused, gnu::visibility("default")]] bool IsHooked(JNIEnv *env, jobject method);
157
172[[nodiscard, maybe_unused, gnu::visibility("default")]] bool Deoptimize(JNIEnv *env,
173 jobject method);
174
182[[nodiscard, maybe_unused, gnu::visibility("default")]] void *GetNativeFunction(JNIEnv *env,
183 jobject method);
184
190[[nodiscard, maybe_unused, gnu::visibility("default")]] bool MakeClassInheritable(JNIEnv *env,
191 jclass target);
192
200[[nodiscard, maybe_unused, gnu::visibility("default")]] bool MakeDexFileTrusted(JNIEnv *env,
201 jobject cookie);
202} // namespace v2
203} // namespace lsplant
struct _jobject * jobject
Definition jni.h:101
jobject jclass
Definition jni.h:102
jobject Hook(JNIEnv *env, jobject target_method, jobject hooker_object, jobject callback_method)
Hook a Java method by providing the target_method together with the context object hooker_object and ...
void * GetNativeFunction(JNIEnv *env, jobject method)
Get the registered native function pointer of a native function. It helps user to hook native methods...
bool UnHook(JNIEnv *env, jobject target_method)
Unhook a Java function that is previously hooked.
bool IsHooked(JNIEnv *env, jobject method)
Check if a Java function is hooked by LSPlant or not.
bool MakeDexFileTrusted(JNIEnv *env, jobject cookie)
Make a DexFile trustable so that it can access hidden APIs. This is useful because we likely need to ...
bool Init(JNIEnv *env, const InitInfo &info)
Initialize LSPlant for the proceeding hook. It mainly prefetch needed symbols and hook some functions...
bool Deoptimize(JNIEnv *env, jobject method)
Deoptimize a method to avoid hooked callee not being called because of inline.
bool MakeClassInheritable(JNIEnv *env, jclass target)
Make a class inheritable. It will make the class non-final and make all its private constructors prot...
Information and configuration that are needed to call Init()
Definition lsplant.hpp:16
InlineHookFunType inline_hooker
The inline hooker function. Must not be null.
Definition lsplant.hpp:57
std::string_view generated_class_name
The generated class name. Must not be empty. It contains a field and a method and they could be set b...
Definition lsplant.hpp:68
std::string_view generated_method_name
The generated class name. Must not be empty. If {target} is set, it will follows the name of the targ...
Definition lsplant.hpp:75
MemoryRecycler executable_memory_recycler
The memory recycler for executable code. May be null. It must be non-null if executable_memory_alloca...
Definition lsplant.hpp:82
std::string_view generated_field_name
The generated field name. Must not be empty.
Definition lsplant.hpp:72
MemoryAllocator executable_memory_allocator
The memory allocator for executable code. May be null. If provided, it will be used to allocate memor...
Definition lsplant.hpp:79
ArtSymbolResolver art_symbol_resolver
The symbol resolver to libart.so. Must not be null.
Definition lsplant.hpp:61
InlineUnhookFunType inline_unhooker
The inline unhooker function. Must not be null.
Definition lsplant.hpp:59
std::string_view generated_source_name
The generated source name. Could be empty.
Definition lsplant.hpp:70
ArtSymbolPrefixResolver art_symbol_prefix_resolver
The symbol prefix resolver to libart.so. May be null.
Definition lsplant.hpp:64