Skip to content

Commit

Permalink
Upgrade cxx (LSPosed#2780)
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 authored Oct 4, 2023
1 parent cc31605 commit 888a7db
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 65 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
42 changes: 20 additions & 22 deletions core/src/main/jni/include/config_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <map>

using obfuscation_map_t = std::map<std::string, std::string>;
class ConfigBridge {
public:
inline static ConfigBridge *GetInstance() {
return instance_.get();
}
namespace lspd {
using obfuscation_map_t = std::map<std::string, std::string>;

class ConfigBridge {
public:
inline static ConfigBridge *GetInstance() {
return instance_.get();
}

inline static std::unique_ptr<ConfigBridge> ReleaseInstance() {
return std::move(instance_);
}

inline static std::unique_ptr<ConfigBridge> ReleaseInstance() {
return std::move(instance_);
}
virtual obfuscation_map_t &obfuscation_map() = 0;

virtual obfuscation_map_t& obfuscation_map() = 0;
virtual void obfuscation_map(obfuscation_map_t) = 0;
virtual void obfuscation_map(obfuscation_map_t) = 0;

virtual ~ConfigBridge() = default;
protected:
inline static std::unique_ptr<ConfigBridge> instance_ = nullptr;
};
virtual ~ConfigBridge() = default;

#endif //LSPOSED_CONFIGBRIDGE_H
protected:
static std::unique_ptr<ConfigBridge> instance_;
};
}
2 changes: 1 addition & 1 deletion core/src/main/jni/include/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace lspd {
virtual ~Context() = default;

protected:
inline static std::unique_ptr<Context> instance_;
static std::unique_ptr<Context> instance_;
jobject inject_class_loader_ = nullptr;
jclass entry_class_ = nullptr;

Expand Down
4 changes: 4 additions & 0 deletions core/src/main/jni/src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@

using namespace lsplant;


namespace lspd {
std::unique_ptr<lspd::Context> lspd::Context::instance_;
std::unique_ptr<ConfigBridge> 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);
Expand Down
1 change: 1 addition & 0 deletions daemon/src/main/jni/dex2oat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sys/mount.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sched.h>

#include "logging.h"

Expand Down
1 change: 1 addition & 0 deletions daemon/src/main/jni/logcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cinttypes>
#include <chrono>
#include <thread>
#include <functional>
#include <sys/system_properties.h>

using namespace std::string_view_literals;
Expand Down
1 change: 1 addition & 0 deletions daemon/src/main/jni/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define _LOGGING_H

#include <android/log.h>
#include <errno.h>

#ifndef LOG_TAG
#define LOG_TAG "LSPosed"
Expand Down
39 changes: 21 additions & 18 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion external/cxx
Submodule cxx updated 2899 files
32 changes: 14 additions & 18 deletions magisk-loader/src/main/jni/src/config_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConfigImpl>();
}

virtual obfuscation_map_t& obfuscation_map() override { return obfuscation_map_; }
virtual void obfuscation_map(obfuscation_map_t m) override { obfuscation_map_ = std::move(m); }
namespace lspd {
class ConfigImpl : public ConfigBridge {
public:
inline static void Init() {
instance_ = std::make_unique<ConfigImpl>();
}

private:
inline static std::map<std::string, std::string> obfuscation_map_;
};
virtual obfuscation_map_t &obfuscation_map() override { return 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<std::string, std::string> obfuscation_map_;
};
}
2 changes: 2 additions & 0 deletions magisk-loader/src/main/jni/src/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
using namespace lsplant;

namespace lspd {
std::unique_ptr<Service> Service::instance_;

jboolean
Service::exec_transact_replace(jboolean *res, JNIEnv *env, [[maybe_unused]] jobject obj,
va_list args) {
Expand Down
2 changes: 1 addition & 1 deletion magisk-loader/src/main/jni/src/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace lspd {
std::map<std::string, std::string> RequestObfuscationMap(JNIEnv *env, const lsplant::ScopedLocalRef<jobject> &binder);

private:
inline static std::unique_ptr<Service> instance_ = std::make_unique<Service>();
static std::unique_ptr<Service> instance_;
bool initialized_ = false;

Service() = default;
Expand Down

0 comments on commit 888a7db

Please sign in to comment.