diff --git a/.gitmodules b/.gitmodules index 9dc2c725..10165e6a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "external/cxx"] - path = external/cxx - url = https://github.com/LSPosed/libcxx.git [submodule "external/lsplant"] path = external/lsplant url = https://github.com/LSPosed/LSPlant.git @@ -10,3 +7,6 @@ [submodule "external/fmt"] path = external/fmt url = https://github.com/fmtlib/fmt.git +[submodule "external/cxx"] + path = external/cxx + url = https://github.com/topjohnwu/libcxx.git diff --git a/core/src/main/jni/include/config_bridge.h b/core/src/main/jni/include/config_bridge.h index 0ac540b9..b24d4fec 100644 --- a/core/src/main/jni/include/config_bridge.h +++ b/core/src/main/jni/include/config_bridge.h @@ -16,32 +16,30 @@ * * Copyright (C) 2022 LSPosed Contributors */ +#pragma once -// -// Created by Kotori0 on 2022/4/14. -// - -#ifndef LSPOSED_CONFIGBRIDGE_H -#define LSPOSED_CONFIGBRIDGE_H #include -using obfuscation_map_t = std::map; -class ConfigBridge { -public: - inline static ConfigBridge *GetInstance() { - return instance_.get(); - } +namespace lspd { + using obfuscation_map_t = std::map; - inline static std::unique_ptr ReleaseInstance() { - return std::move(instance_); - } + class ConfigBridge { + public: + inline static ConfigBridge *GetInstance() { + return instance_.get(); + } - virtual obfuscation_map_t& obfuscation_map() = 0; - virtual void obfuscation_map(obfuscation_map_t) = 0; + inline static std::unique_ptr ReleaseInstance() { + return std::move(instance_); + } - virtual ~ConfigBridge() = default; -protected: - inline static std::unique_ptr instance_ = nullptr; -}; + virtual obfuscation_map_t &obfuscation_map() = 0; -#endif //LSPOSED_CONFIGBRIDGE_H + virtual void obfuscation_map(obfuscation_map_t) = 0; + + virtual ~ConfigBridge() = default; + + protected: + static std::unique_ptr instance_; + }; +} diff --git a/core/src/main/jni/include/context.h b/core/src/main/jni/include/context.h index 59bd29d5..ca56bd02 100644 --- a/core/src/main/jni/include/context.h +++ b/core/src/main/jni/include/context.h @@ -52,7 +52,7 @@ namespace lspd { virtual ~Context() = default; protected: - inline static std::unique_ptr instance_; + static std::unique_ptr instance_; jobject inject_class_loader_ = nullptr; jclass entry_class_ = nullptr; diff --git a/core/src/main/jni/src/context.cpp b/core/src/main/jni/src/context.cpp index 1d057300..69375ddd 100644 --- a/core/src/main/jni/src/context.cpp +++ b/core/src/main/jni/src/context.cpp @@ -31,7 +31,11 @@ using namespace lsplant; + namespace lspd { + std::unique_ptr lspd::Context::instance_; + std::unique_ptr ConfigBridge::instance_; + Context::PreloadedDex::PreloadedDex(int fd, std::size_t size) { LOGD("Context::PreloadedDex::PreloadedDex: fd={}, size={}", fd, size); auto *addr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); diff --git a/daemon/src/main/jni/dex2oat.cpp b/daemon/src/main/jni/dex2oat.cpp index 202c99ff..212301d7 100644 --- a/daemon/src/main/jni/dex2oat.cpp +++ b/daemon/src/main/jni/dex2oat.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "logging.h" diff --git a/daemon/src/main/jni/logcat.cpp b/daemon/src/main/jni/logcat.cpp index c8021286..2334cf8a 100644 --- a/daemon/src/main/jni/logcat.cpp +++ b/daemon/src/main/jni/logcat.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include using namespace std::string_view_literals; diff --git a/daemon/src/main/jni/logging.h b/daemon/src/main/jni/logging.h index 34d7f606..86a7220a 100644 --- a/daemon/src/main/jni/logging.h +++ b/daemon/src/main/jni/logging.h @@ -22,6 +22,7 @@ #define _LOGGING_H #include +#include #ifndef LOG_TAG #define LOG_TAG "LSPosed" diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 82bdcfb8..1c6af93b 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -9,37 +9,40 @@ SET_OPTION(Plugin.SymbolResolver OFF) set(LIBCXX_SOURCES algorithm.cpp - any.cpp +# any.cpp atomic.cpp barrier.cpp - bind.cpp +# bind.cpp charconv.cpp chrono.cpp condition_variable.cpp condition_variable_destructor.cpp - debug.cpp +# debug.cpp exception.cpp - filesystem/directory_iterator.cpp - filesystem/int128_builtins.cpp - filesystem/operations.cpp +# filesystem/directory_iterator.cpp +# filesystem/int128_builtins.cpp +# filesystem/operations.cpp functional.cpp future.cpp # use absl instead # hash.cpp - ios.cpp - iostream.cpp - locale.cpp +# ios.cpp +# iostream.cpp +# locale.cpp memory.cpp mutex.cpp mutex_destructor.cpp new.cpp optional.cpp random.cpp - regex.cpp +# regex.cpp +# ryu/d2fixed.cpp +# ryu/d2s.cpp +# ryu/f2s.cpp shared_mutex.cpp stdexcept.cpp string.cpp - strstream.cpp +# strstream.cpp system_error.cpp thread.cpp # typeinfo.cpp @@ -51,17 +54,18 @@ set(LIBCXX_SOURCES list(TRANSFORM LIBCXX_SOURCES PREPEND cxx/src/) -set(LIBCXX_EXPORT_FLAGS) -set(LIBCXX_FLAGS - -fvisibility-global-new-delete-hidden - -fvisibility=hidden - -fvisibility-inlines-hidden +set(LIBCXX_EXPORT_FLAGS -DLIBCXX_BUILDING_LIBCXXABI -D_LIBCPP_NO_EXCEPTIONS -D_LIBCPP_NO_RTTI -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS - -D__STDC_FORMAT_MACROS + -D_LIBCXXABI_NO_EXCEPTIONS + ) +set(LIBCXX_FLAGS + -fvisibility-global-new-delete-hidden + -fvisibility=hidden + -fvisibility-inlines-hidden ) set(LIBCXX_EXPORT_INCLUDES cxx/include) set(LIBCXX_INCLUDES cxx/src) @@ -84,7 +88,6 @@ set(LIBCXXABI_SOURCES ) list(TRANSFORM LIBCXXABI_SOURCES PREPEND cxx/src/abi/) set(LIBCXXABI_FLAGS - -D_LIBCXXABI_NO_EXCEPTIONS -Wno-macro-redefined -Wno-unknown-attributes -DHAS_THREAD_LOCAL) diff --git a/external/cxx b/external/cxx index 82090ae7..12c8f4e9 160000 --- a/external/cxx +++ b/external/cxx @@ -1 +1 @@ -Subproject commit 82090ae75f7d284f2647a67f3f80f28f54eaddfc +Subproject commit 12c8f4e93f196a700137e983dcceeac43cf807f2 diff --git a/external/lsplant b/external/lsplant index 9c33903c..bbabd250 160000 --- a/external/lsplant +++ b/external/lsplant @@ -1 +1 @@ -Subproject commit 9c33903c87a240ae38dbf7fdf49c0748addd073d +Subproject commit bbabd25043f4fd8056cf5df55e2839de824467a1 diff --git a/magisk-loader/src/main/jni/src/config_impl.h b/magisk-loader/src/main/jni/src/config_impl.h index 4b035422..08109c52 100644 --- a/magisk-loader/src/main/jni/src/config_impl.h +++ b/magisk-loader/src/main/jni/src/config_impl.h @@ -17,28 +17,24 @@ * Copyright (C) 2022 LSPosed Contributors */ -// -// Created by Kotori0 on 2022/4/14. -// - -#ifndef LSPOSED_CONFIGIMPL_H -#define LSPOSED_CONFIGIMPL_H +#pragma once #include "config_bridge.h" #include "service.h" -class ConfigImpl: public ConfigBridge { -public: - inline static void Init() { - instance_ = std::make_unique(); - } +namespace lspd { + class ConfigImpl : public ConfigBridge { + public: + inline static void Init() { + instance_ = std::make_unique(); + } - virtual obfuscation_map_t& obfuscation_map() override { return obfuscation_map_; } - virtual void obfuscation_map(obfuscation_map_t m) override { obfuscation_map_ = std::move(m); } + virtual obfuscation_map_t &obfuscation_map() override { return obfuscation_map_; } -private: - inline static std::map obfuscation_map_; -}; + virtual void + obfuscation_map(obfuscation_map_t m) override { obfuscation_map_ = std::move(m); } - -#endif //LSPOSED_CONFIGIMPL_H + private: + inline static std::map obfuscation_map_; + }; +} diff --git a/magisk-loader/src/main/jni/src/service.cpp b/magisk-loader/src/main/jni/src/service.cpp index 538b07a6..7493cd2e 100644 --- a/magisk-loader/src/main/jni/src/service.cpp +++ b/magisk-loader/src/main/jni/src/service.cpp @@ -33,6 +33,8 @@ using namespace lsplant; namespace lspd { + std::unique_ptr Service::instance_; + jboolean Service::exec_transact_replace(jboolean *res, JNIEnv *env, [[maybe_unused]] jobject obj, va_list args) { diff --git a/magisk-loader/src/main/jni/src/service.h b/magisk-loader/src/main/jni/src/service.h index a49ee06c..d2186370 100644 --- a/magisk-loader/src/main/jni/src/service.h +++ b/magisk-loader/src/main/jni/src/service.h @@ -89,7 +89,7 @@ namespace lspd { std::map RequestObfuscationMap(JNIEnv *env, const lsplant::ScopedLocalRef &binder); private: - inline static std::unique_ptr instance_ = std::make_unique(); + static std::unique_ptr instance_; bool initialized_ = false; Service() = default;