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
100[[nodiscard, maybe_unused, gnu::visibility("default")]] bool Init(JNIEnv *env,
101 const InitInfo &info);
102
139[[nodiscard, maybe_unused, gnu::visibility("default")]] jobject Hook(JNIEnv *env,
140 jobject target_method,
141 jobject hooker_object,
142 jobject callback_method);
143
151[[nodiscard, maybe_unused, gnu::visibility("default")]] bool UnHook(JNIEnv *env,
152 jobject target_method);
153
160[[nodiscard, maybe_unused, gnu::visibility("default")]] bool IsHooked(JNIEnv *env, jobject method);
161
176[[nodiscard, maybe_unused, gnu::visibility("default")]] bool Deoptimize(JNIEnv *env,
177 jobject method);
178
186[[nodiscard, maybe_unused, gnu::visibility("default")]] void *GetNativeFunction(JNIEnv *env,
187 jobject method);
188
194[[nodiscard, maybe_unused, gnu::visibility("default")]] bool MakeClassInheritable(JNIEnv *env,
195 jclass target);
196
204[[nodiscard, maybe_unused, gnu::visibility("default")]] bool MakeDexFileTrusted(JNIEnv *env,
205 jobject cookie);
206} // namespace v2
207} // 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:58
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:62
InlineUnhookFunType inline_unhooker
The inline unhooker function. Must not be null.
Definition lsplant.hpp:60
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. Must not be null.
Definition lsplant.hpp:64