mirror of
https://github.com/LSPosed/LSPlant.git
synced 2025-05-04 20:42:02 +08:00
upgrade to ndk 29 an use module partition
This commit is contained in:
parent
e2a35a4fab
commit
0110cf7e6e
@ -6,5 +6,5 @@ val androidTargetSdkVersion by extra(35)
|
||||
val androidMinSdkVersion by extra(21)
|
||||
val androidBuildToolsVersion by extra("35.0.0")
|
||||
val androidCompileSdkVersion by extra(35)
|
||||
val androidNdkVersion by extra("28.0.13004108")
|
||||
val androidNdkVersion by extra("29.0.13113456")
|
||||
val androidCmakeVersion by extra("3.28.0+")
|
||||
|
@ -4,17 +4,17 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module clazz;
|
||||
export module lsplant:clazz;
|
||||
|
||||
import common;
|
||||
import art_method;
|
||||
import thread;
|
||||
import handle;
|
||||
import :common;
|
||||
import :art_method;
|
||||
import :thread;
|
||||
import :handle;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art::mirror {
|
||||
export namespace lsplant::art::mirror {
|
||||
|
||||
export class Class {
|
||||
class Class {
|
||||
private:
|
||||
inline static auto GetDescriptor_ =
|
||||
"_ZN3art6mirror5Class13GetDescriptorEPNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE"_sym.as<const char *(Class::*)(std::string *)>;
|
||||
|
@ -6,17 +6,13 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module art_method;
|
||||
export module lsplant:art_method;
|
||||
|
||||
import common;
|
||||
import :common;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art {
|
||||
namespace mirror {
|
||||
class Class;
|
||||
}
|
||||
|
||||
export class ArtMethod {
|
||||
export namespace lsplant::art {
|
||||
class ArtMethod {
|
||||
inline static auto PrettyMethod_ =
|
||||
"_ZN3art9ArtMethod12PrettyMethodEPS0_b"_sym.as<std::string(ArtMethod::*)(bool)>;
|
||||
|
||||
|
@ -4,15 +4,15 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module class_linker;
|
||||
export module lsplant:class_linker;
|
||||
|
||||
import art_method;
|
||||
import thread;
|
||||
import common;
|
||||
import clazz;
|
||||
import handle;
|
||||
import :art_method;
|
||||
import :thread;
|
||||
import :common;
|
||||
import :clazz;
|
||||
import :handle;
|
||||
import :runtime;
|
||||
import hook_helper;
|
||||
import runtime;
|
||||
|
||||
namespace lsplant::art {
|
||||
export class ClassLinker {
|
||||
|
@ -6,9 +6,9 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module dex_file;
|
||||
export module lsplant:dex_file;
|
||||
|
||||
import common;
|
||||
import :common;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art {
|
||||
|
@ -2,10 +2,10 @@ module;
|
||||
|
||||
#include <android/api-level.h>
|
||||
|
||||
export module scope_gc_critical_section;
|
||||
export module lsplant:scope_gc_critical_section;
|
||||
|
||||
import thread;
|
||||
import common;
|
||||
import :thread;
|
||||
import :common;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art::gc {
|
||||
|
@ -3,9 +3,9 @@ module;
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
export module handle;
|
||||
export module lsplant:handle;
|
||||
|
||||
import art_method;
|
||||
import :art_method;
|
||||
|
||||
namespace lsplant::art {
|
||||
|
||||
|
@ -2,10 +2,10 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module instrumentation;
|
||||
export module lsplant:instrumentation;
|
||||
|
||||
import art_method;
|
||||
import common;
|
||||
import :art_method;
|
||||
import :common;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art {
|
||||
|
@ -2,11 +2,11 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module jit;
|
||||
export module lsplant:jit;
|
||||
|
||||
import art_method;
|
||||
import common;
|
||||
import thread;
|
||||
import :art_method;
|
||||
import :common;
|
||||
import :thread;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art::jit {
|
||||
|
@ -2,11 +2,11 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module jit_code_cache;
|
||||
export module lsplant:jit_code_cache;
|
||||
|
||||
import art_method;
|
||||
import common;
|
||||
import thread;
|
||||
import :art_method;
|
||||
import :common;
|
||||
import :thread;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art::jit {
|
||||
|
@ -2,11 +2,11 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module jni_id_manager;
|
||||
export module lsplant:jni_id_manager;
|
||||
|
||||
import art_method;
|
||||
import common;
|
||||
import handle;
|
||||
import :art_method;
|
||||
import :common;
|
||||
import :handle;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art::jni {
|
||||
|
@ -5,9 +5,9 @@ module;
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
export module runtime;
|
||||
export module lsplant:runtime;
|
||||
|
||||
import common;
|
||||
import :common;
|
||||
import hook_helper;
|
||||
|
||||
namespace lsplant::art {
|
||||
|
@ -1,6 +1,6 @@
|
||||
module;
|
||||
|
||||
export module thread;
|
||||
export module lsplant:thread;
|
||||
|
||||
import hook_helper;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module;
|
||||
|
||||
export module thread_list;
|
||||
export module lsplant:thread_list;
|
||||
|
||||
import hook_helper;
|
||||
|
||||
|
@ -9,12 +9,12 @@ module;
|
||||
#include <string_view>
|
||||
|
||||
#include "logging.hpp"
|
||||
#include "utils/jni_helper.hpp"
|
||||
|
||||
export module common;
|
||||
export module lsplant:common;
|
||||
export import jni_helper;
|
||||
export import hook_helper;
|
||||
|
||||
namespace lsplant {
|
||||
export namespace lsplant {
|
||||
|
||||
namespace art {
|
||||
class ArtMethod;
|
||||
@ -22,12 +22,12 @@ namespace mirror {
|
||||
class Class;
|
||||
}
|
||||
namespace dex {
|
||||
export class ClassDef {};
|
||||
class ClassDef {};
|
||||
} // namespace dex
|
||||
|
||||
} // namespace art
|
||||
|
||||
export enum class Arch {
|
||||
enum class Arch {
|
||||
kArm,
|
||||
kArm64,
|
||||
kX86,
|
||||
@ -61,7 +61,6 @@ template <class T, class Hash = phmap::priv::hash_default_hash<T>,
|
||||
size_t N = 4>
|
||||
using SharedHashSet = phmap::parallel_flat_hash_set<T, Hash, Eq, Alloc, N, std::shared_mutex>;
|
||||
|
||||
export {
|
||||
constexpr auto kArch = GetArch();
|
||||
|
||||
template <typename T>
|
||||
@ -175,5 +174,4 @@ export {
|
||||
std::unique_lock lk(jit_movements_lock_);
|
||||
jit_movements_.emplace_back(target, backup);
|
||||
}
|
||||
}
|
||||
} // namespace lsplant
|
||||
|
@ -4,8 +4,7 @@ module;
|
||||
|
||||
export module lsplant;
|
||||
|
||||
export namespace lsplant {
|
||||
inline namespace v2 {
|
||||
export namespace lsplant::inline v2{
|
||||
using lsplant::v2::InitInfo;
|
||||
using lsplant::v2::Init;
|
||||
using lsplant::v2::Hook;
|
||||
@ -16,4 +15,3 @@ export namespace lsplant {
|
||||
using lsplant::v2::MakeClassInheritable;
|
||||
using lsplant::v2::MakeDexFileTrusted;
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,6 @@ namespace lsplant {
|
||||
template <size_t N>
|
||||
struct FixedString {
|
||||
consteval FixedString(const char (&str)[N]) { std::copy_n(str, N, data); }
|
||||
#if defined(__LP64__)
|
||||
template <size_t M>
|
||||
consteval FixedString(const char (&)[M], const char (&str)[N]) : FixedString(str) {}
|
||||
#else
|
||||
template <size_t M>
|
||||
consteval FixedString(const char (&str)[N], const char (&)[M]) : FixedString(str) {}
|
||||
#endif
|
||||
char data[N] = {};
|
||||
};
|
||||
|
||||
@ -181,29 +174,11 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Dummy;
|
||||
template<typename F>
|
||||
concept Backup = std::is_function_v<std::remove_pointer_t<F>>;
|
||||
|
||||
template<typename F>
|
||||
concept Backup = std::is_function_v<std::remove_pointer_t<F>> || requires(F&& f) { { f(std::declval<Dummy*>()) } -> std::same_as<Dummy*>; };
|
||||
|
||||
template<typename F>
|
||||
concept MemBackup = std::is_function_v<std::remove_pointer_t<F>> || requires(F&& f) { { f(std::declval<Dummy*>()) } -> std::same_as<Dummy**>; };
|
||||
|
||||
template <typename T>
|
||||
T return_t();
|
||||
|
||||
// for ndk 29+, use decltype(F::template operator()<&decltype([] static {})::operator()>)
|
||||
// and remove Dummy, set MemBackup as std::is_member_function_pointer_v<F>
|
||||
template<typename F, bool mem>
|
||||
using Signature = decltype(F::template operator()<[](auto...a) static {
|
||||
using D = std::conditional_t<mem, Dummy**, Dummy*>;
|
||||
if constexpr ((false || ... || std::is_same_v<decltype(a), Dummy*>)) {
|
||||
return return_t<D>();
|
||||
} else {
|
||||
return return_t<decltype(F::template operator()<[](auto...) -> D {}>(std::declval<decltype(a)>()...))>();
|
||||
}
|
||||
}>);
|
||||
concept MemBackup = std::is_member_function_pointer_v<std::remove_pointer_t<F>> || Backup<F>;
|
||||
|
||||
template<FixedString S>
|
||||
struct Symbol {
|
||||
@ -218,21 +193,18 @@ struct Symbol {
|
||||
|
||||
[[no_unique_address]] struct Hook {
|
||||
template<typename F>
|
||||
requires(requires { std::declval<Signature<F, false>>(); })
|
||||
auto operator->*(F&&) const {
|
||||
using HookerType = Hooker<S, Signature<F, false>>;
|
||||
return HookerType{static_cast<decltype(HookerType::replace_)>(&F::template operator()<HookerType::operator()>)};
|
||||
};
|
||||
template<typename F>
|
||||
requires(requires { std::declval<Signature<F, true>>(); })
|
||||
auto operator->*(F&&) const {
|
||||
constexpr auto c = []<class This, typename Ret, typename... Args>(Ret(*f)(This*, Args...)) -> Ret(This::*)(Args...) {
|
||||
using Signature = decltype(F::template operator()<&decltype([] static {})::operator()>);
|
||||
if constexpr (requires { F::template operator()<&decltype([] {})::operator()>; }) {
|
||||
using HookerType = Hooker<S, decltype([]<class This, typename Ret, typename... Args>(Ret(*)(This*, Args...)) -> Ret(This::*)(Args...) {
|
||||
return {};
|
||||
};
|
||||
using HookerType = Hooker<S, decltype(c.template operator()(std::declval<Signature<F, true>>()))>;
|
||||
}.template operator()(std::declval<Signature>()))>;
|
||||
return HookerType{static_cast<decltype(HookerType::replace_)>(&F::template operator()<HookerType::operator()>)};
|
||||
} else {
|
||||
using HookerType = Hooker<S, Signature>;
|
||||
return HookerType{static_cast<decltype(HookerType::replace_)>(&F::template operator()<HookerType::operator()>)};
|
||||
}
|
||||
};
|
||||
|
||||
} hook;
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
module;
|
||||
|
||||
#include "lsplant.hpp"
|
||||
|
||||
#include <android/api-level.h>
|
||||
#include <bits/sysconf.h>
|
||||
#include <jni.h>
|
||||
@ -12,29 +16,23 @@
|
||||
|
||||
#include "logging.hpp"
|
||||
|
||||
module lsplant;
|
||||
|
||||
import dex_builder;
|
||||
import lsplant;
|
||||
|
||||
import common;
|
||||
import art_method;
|
||||
import clazz;
|
||||
import thread;
|
||||
import instrumentation;
|
||||
import runtime;
|
||||
import thread_list;
|
||||
import class_linker;
|
||||
import scope_gc_critical_section;
|
||||
import jit_code_cache;
|
||||
import jni_id_manager;
|
||||
import dex_file;
|
||||
import jit;
|
||||
import hook_helper;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma ide diagnostic ignored "ConstantConditionsOC"
|
||||
#pragma ide diagnostic ignored "Simplify"
|
||||
#pragma ide diagnostic ignored "UnreachableCode"
|
||||
import :common;
|
||||
import :art_method;
|
||||
import :clazz;
|
||||
import :thread;
|
||||
import :instrumentation;
|
||||
import :runtime;
|
||||
import :thread_list;
|
||||
import :class_linker;
|
||||
import :scope_gc_critical_section;
|
||||
import :jit_code_cache;
|
||||
import :jni_id_manager;
|
||||
import :dex_file;
|
||||
import :jit;
|
||||
|
||||
namespace lsplant {
|
||||
|
||||
@ -633,6 +631,7 @@ std::string GetProxyMethodShorty(JNIEnv *env, jobject proxy_method) {
|
||||
} // namespace
|
||||
|
||||
inline namespace v2 {
|
||||
extern "C++" {
|
||||
|
||||
using ::lsplant::IsHooked;
|
||||
|
||||
@ -835,8 +834,7 @@ using ::lsplant::IsHooked;
|
||||
if (!cookie) return false;
|
||||
return DexFile::SetTrusted(env, cookie);
|
||||
}
|
||||
}
|
||||
} // namespace v2
|
||||
|
||||
} // namespace lsplant
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
Loading…
x
Reference in New Issue
Block a user