mirror of
https://github.com/LSPosed/LSPlant.git
synced 2025-05-05 14:06:37 +08:00
Reformat code
This commit is contained in:
parent
fd8e2e4c17
commit
a3f95f050b
@ -8,7 +8,7 @@
|
|||||||
namespace lsplant::art {
|
namespace lsplant::art {
|
||||||
class DexFile {
|
class DexFile {
|
||||||
struct Header {
|
struct Header {
|
||||||
uint8_t magic_[8];
|
[[maybe_unused]] uint8_t magic_[8];
|
||||||
uint32_t checksum_; // See also location_checksum_
|
uint32_t checksum_; // See also location_checksum_
|
||||||
};
|
};
|
||||||
CREATE_FUNC_SYMBOL_ENTRY(std::unique_ptr<DexFile>, OpenMemory, const uint8_t* dex_file,
|
CREATE_FUNC_SYMBOL_ENTRY(std::unique_ptr<DexFile>, OpenMemory, const uint8_t* dex_file,
|
||||||
|
@ -24,17 +24,13 @@ class Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Thread *Current() {
|
static Thread *Current() { return CurrentFromGdb(); }
|
||||||
return CurrentFromGdb();
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool Init(const HookHandler &handler) {
|
static bool Init(const HookHandler &handler) {
|
||||||
if (!RETRIEVE_MEM_FUNC_SYMBOL(DecodeJObject,
|
if (!RETRIEVE_MEM_FUNC_SYMBOL(DecodeJObject, "_ZNK3art6Thread13DecodeJObjectEP8_jobject")) {
|
||||||
"_ZNK3art6Thread13DecodeJObjectEP8_jobject")) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!RETRIEVE_FUNC_SYMBOL(CurrentFromGdb,
|
if (!RETRIEVE_FUNC_SYMBOL(CurrentFromGdb, "_ZN3art6Thread14CurrentFromGdbEv")) {
|
||||||
"_ZN3art6Thread14CurrentFromGdbEv")) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -47,4 +43,4 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace lsplant::art
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string_view>
|
|
||||||
#include <shared_mutex>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <list>
|
|
||||||
#include <sys/system_properties.h>
|
#include <sys/system_properties.h>
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <shared_mutex>
|
||||||
|
#include <string_view>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "logging.hpp"
|
#include "logging.hpp"
|
||||||
#include "utils/hook_helper.hpp"
|
|
||||||
#include "lsplant.hpp"
|
#include "lsplant.hpp"
|
||||||
|
#include "utils/hook_helper.hpp"
|
||||||
|
|
||||||
namespace lsplant {
|
namespace lsplant {
|
||||||
|
|
||||||
@ -19,7 +21,6 @@ enum class Arch {
|
|||||||
kX8664,
|
kX8664,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
consteval inline Arch GetArch() {
|
consteval inline Arch GetArch() {
|
||||||
#if defined(__i386__)
|
#if defined(__i386__)
|
||||||
return Arch::kX86;
|
return Arch::kX86;
|
||||||
@ -70,7 +71,7 @@ class ArtMethod;
|
|||||||
namespace dex {
|
namespace dex {
|
||||||
class ClassDef;
|
class ClassDef;
|
||||||
}
|
}
|
||||||
}
|
} // namespace art
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// target, backup
|
// target, backup
|
||||||
@ -80,12 +81,15 @@ inline std::shared_mutex hooked_methods_lock_;
|
|||||||
inline std::list<std::pair<art::ArtMethod *, art::ArtMethod *>> jit_movements_;
|
inline std::list<std::pair<art::ArtMethod *, art::ArtMethod *>> jit_movements_;
|
||||||
inline std::shared_mutex jit_movements_lock_;
|
inline std::shared_mutex jit_movements_lock_;
|
||||||
|
|
||||||
inline std::unordered_map<const art::dex::ClassDef *, std::list<std::tuple<art::ArtMethod *, art::ArtMethod *, art::ArtMethod *>>> pending_classes_;
|
inline std::unordered_map<
|
||||||
|
const art::dex::ClassDef *,
|
||||||
|
std::list<std::tuple<art::ArtMethod *, art::ArtMethod *, art::ArtMethod *>>>
|
||||||
|
pending_classes_;
|
||||||
inline std::shared_mutex pending_classes_lock_;
|
inline std::shared_mutex pending_classes_lock_;
|
||||||
|
|
||||||
inline std::unordered_set<const art::ArtMethod *> pending_methods_;
|
inline std::unordered_set<const art::ArtMethod *> pending_methods_;
|
||||||
inline std::shared_mutex pending_methods_lock_;
|
inline std::shared_mutex pending_methods_lock_;
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
inline bool IsHooked(art::ArtMethod *art_method) {
|
inline bool IsHooked(art::ArtMethod *art_method) {
|
||||||
std::shared_lock lk(hooked_methods_lock_);
|
std::shared_lock lk(hooked_methods_lock_);
|
||||||
@ -117,9 +121,8 @@ inline void RecordJitMovement(art::ArtMethod *target, art::ArtMethod *backup) {
|
|||||||
jit_movements_.emplace_back(target, backup);
|
jit_movements_.emplace_back(target, backup);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void RecordPending(const art::dex::ClassDef *class_def, art::ArtMethod *target,
|
||||||
RecordPending(const art::dex::ClassDef *class_def, art::ArtMethod *target, art::ArtMethod *hook,
|
art::ArtMethod *hook, art::ArtMethod *backup) {
|
||||||
art::ArtMethod *backup) {
|
|
||||||
{
|
{
|
||||||
std::unique_lock lk(pending_methods_lock_);
|
std::unique_lock lk(pending_methods_lock_);
|
||||||
pending_methods_.emplace(target);
|
pending_methods_.emplace(target);
|
||||||
@ -151,4 +154,4 @@ inline void OnPending(const art::dex::ClassDef *class_def) {
|
|||||||
OnPending(target, hook, backup);
|
OnPending(target, hook, backup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace lsplant
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
|
|
||||||
#include "lsplant.hpp"
|
|
||||||
#include "jni_helper.hpp"
|
#include "jni_helper.hpp"
|
||||||
|
#include "lsplant.hpp"
|
||||||
|
|
||||||
#if defined(__LP64__)
|
#if defined(__LP64__)
|
||||||
#define LP_SELECT(lp32, lp64) lp64
|
#define LP_SELECT(lp32, lp64) lp64
|
||||||
|
@ -14,8 +14,16 @@
|
|||||||
#define LOGE(...)
|
#define LOGE(...)
|
||||||
#else
|
#else
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#define LOGD(fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "%s:%d#%s" ": " fmt, __FILE_NAME__, __LINE__, __PRETTY_FUNCTION__ __VA_OPT__(,) __VA_ARGS__)
|
#define LOGD(fmt, ...) \
|
||||||
#define LOGV(fmt, ...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "%s:%d#%s" ": " fmt, __FILE_NAME__, __LINE__, __PRETTY_FUNCTION__ __VA_OPT__(,) __VA_ARGS__)
|
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, \
|
||||||
|
"%s:%d#%s" \
|
||||||
|
": " fmt, \
|
||||||
|
__FILE_NAME__, __LINE__, __PRETTY_FUNCTION__ __VA_OPT__(, ) __VA_ARGS__)
|
||||||
|
#define LOGV(fmt, ...) \
|
||||||
|
__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, \
|
||||||
|
"%s:%d#%s" \
|
||||||
|
": " fmt, \
|
||||||
|
__FILE_NAME__, __LINE__, __PRETTY_FUNCTION__ __VA_OPT__(, ) __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define LOGD(...)
|
#define LOGD(...)
|
||||||
#define LOGV(...)
|
#define LOGV(...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user