Update JingMatrix/LSPosed
Users of Android 16 beta 3 has reported LSPlant failure, for which we should thus update LSPosed. See issue https://github.com/JingMatrix/LSPlant/issues/2. Files are reformatted.
This commit is contained in:
parent
9703dc4b49
commit
95ed02d4bb
|
|
@ -56,6 +56,9 @@ jobs:
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@v4
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
|
||||||
|
- name: Setup Android SDK
|
||||||
|
uses: android-actions/setup-android@v3
|
||||||
|
|
||||||
- name: Setup ninja
|
- name: Setup ninja
|
||||||
uses: seanmiddleditch/gha-setup-ninja@master
|
uses: seanmiddleditch/gha-setup-ninja@master
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ val coreVerName by extra(coreLatestTag)
|
||||||
val androidMinSdkVersion by extra(28)
|
val androidMinSdkVersion by extra(28)
|
||||||
val androidTargetSdkVersion by extra(35)
|
val androidTargetSdkVersion by extra(35)
|
||||||
val androidCompileSdkVersion by extra(35)
|
val androidCompileSdkVersion by extra(35)
|
||||||
val androidCompileNdkVersion by extra("27.1.12297006")
|
val androidCompileNdkVersion by extra("29.0.13113456")
|
||||||
val androidBuildToolsVersion by extra("35.0.0")
|
val androidBuildToolsVersion by extra("35.0.0")
|
||||||
val androidSourceCompatibility by extra(JavaVersion.VERSION_21)
|
val androidSourceCompatibility by extra(JavaVersion.VERSION_21)
|
||||||
val androidTargetCompatibility by extra(JavaVersion.VERSION_21)
|
val androidTargetCompatibility by extra(JavaVersion.VERSION_21)
|
||||||
|
|
|
||||||
2
core
2
core
|
|
@ -1 +1 @@
|
||||||
Subproject commit c9e11c6770d5a6c9a0b7f9a5a243d031c25e0e0a
|
Subproject commit 90d3712c6e99199ae9797de15710dd12c4b107e4
|
||||||
Binary file not shown.
|
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,7 @@ done
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
@ -206,7 +205,7 @@ fi
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# and any embedded shellness will be escaped.
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
project(lspatch)
|
project(lspatch)
|
||||||
cmake_minimum_required(VERSION 3.4.1)
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
add_subdirectory(${CORE_ROOT} core)
|
add_subdirectory(${CORE_ROOT} core)
|
||||||
|
|
||||||
aux_source_directory(src SRC_LIST)
|
aux_source_directory(src SRC_LIST)
|
||||||
|
|
|
||||||
|
|
@ -12,45 +12,44 @@ using namespace lsplant;
|
||||||
namespace art {
|
namespace art {
|
||||||
class ProfileSaver {
|
class ProfileSaver {
|
||||||
private:
|
private:
|
||||||
inline static MemberHooker<"_ZN3art12ProfileSaver20ProcessProfilingInfoEbPt", ProfileSaver,
|
inline static auto ProcessProfilingInfo_ =
|
||||||
bool(bool, uint16_t *)>
|
"_ZN3art12ProfileSaver20ProcessProfilingInfoEbPt"_sym.hook->*
|
||||||
ProcessProfilingInfo_ = +[](ProfileSaver *thiz, bool a, uint16_t *b) {
|
[]<MemBackup auto backup>(ProfileSaver *thiz, bool a, uint16_t *b) static -> bool {
|
||||||
LOGD("skipped profile saving");
|
LOGD("skipped profile saving");
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static MemberHooker<"_ZN3art12ProfileSaver20ProcessProfilingInfoEbbPt", ProfileSaver,
|
inline static auto ProcessProfilingInfoWithBool_ =
|
||||||
bool(bool, bool, uint16_t *)>
|
"_ZN3art12ProfileSaver20ProcessProfilingInfoEbbPt"_sym.hook->*
|
||||||
ProcessProfilingInfoWithBool_ = +[](ProfileSaver *thiz, bool, bool, uint16_t *) {
|
[]<MemBackup auto backup>(ProfileSaver *thiz, bool, bool, uint16_t *) static -> bool {
|
||||||
LOGD("skipped profile saving");
|
LOGD("skipped profile saving");
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static Hooker<"execve",
|
inline static auto execve_ =
|
||||||
int(const char *pathname, const char *argv[], char *const envp[])>
|
"execve"_sym.hook->*[]<Backup auto backup>(const char *pathname, const char *argv[],
|
||||||
execve_ = +[](const char *pathname, const char *argv[], char *const envp[]) {
|
char *const envp[]) static -> int {
|
||||||
if (strstr(pathname, "dex2oat")) {
|
if (strstr(pathname, "dex2oat")) {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
while (argv[count++] != nullptr);
|
while (argv[count++] != nullptr);
|
||||||
std::unique_ptr<const char *[]> new_args =
|
std::unique_ptr<const char *[]> new_args = std::make_unique<const char *[]>(count + 1);
|
||||||
std::make_unique<const char *[]>(count + 1);
|
for (size_t i = 0; i < count - 1; ++i) new_args[i] = argv[i];
|
||||||
for (size_t i = 0; i < count - 1; ++i) new_args[i] = argv[i];
|
new_args[count - 1] = "--inline-max-code-units=0";
|
||||||
new_args[count - 1] = "--inline-max-code-units=0";
|
new_args[count] = nullptr;
|
||||||
new_args[count] = nullptr;
|
|
||||||
|
|
||||||
LOGD("dex2oat by disable inline!");
|
LOGD("dex2oat by disable inline!");
|
||||||
int ret = execve_(pathname, new_args.get(), envp);
|
int ret = backup(pathname, new_args.get(), envp);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
int ret = execve_(pathname, argv, envp);
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
}
|
||||||
|
int ret = backup(pathname, argv, envp);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void DisableInline(const HookHandler &handler) {
|
static void DisableInline(const HookHandler &handler) {
|
||||||
handler.hook(ProcessProfilingInfo_);
|
handler(ProcessProfilingInfo_);
|
||||||
handler.hook(ProcessProfilingInfoWithBool_);
|
handler(ProcessProfilingInfoWithBool_);
|
||||||
handler.hook(execve_);
|
handler(execve_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace art
|
} // namespace art
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef LSPATCH_OAT_FILE_MANAGER_H
|
#ifndef LSPATCH_OAT_FILE_MANAGER_H
|
||||||
#define LSPATCH_OAT_FILE_MANAGER_H
|
#define LSPATCH_OAT_FILE_MANAGER_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "utils/hook_helper.hpp"
|
#include "utils/hook_helper.hpp"
|
||||||
|
|
||||||
|
|
@ -28,41 +30,40 @@ using namespace lsplant;
|
||||||
namespace art {
|
namespace art {
|
||||||
class FileManager {
|
class FileManager {
|
||||||
public:
|
public:
|
||||||
inline static MemberHooker<
|
inline static auto RunBackgroundVerificationWithContext_ =
|
||||||
"_ZN3art14OatFileManager25RunBackgroundVerificationERKNSt3__"
|
("_ZN3art14OatFileManager25RunBackgroundVerificationERKNSt3__"_sym |
|
||||||
"16vectorIPKNS_7DexFileENS1_9allocatorIS5_EEEEP8_jobjectPKc",
|
"16vectorIPKNS_7DexFileENS1_9allocatorIS5_EEEEP8_jobjectPKc"_sym)
|
||||||
FileManager, void(const std::vector<const void *> &, jobject, const char *)>
|
.hook
|
||||||
RunBackgroundVerificationWithContext_ =
|
->*[]<MemBackup auto backup>(
|
||||||
+[](FileManager *thiz, const std::vector<const void *> &dex_files, jobject class_loader,
|
FileManager *thiz, const std::vector<const void *> &dex_files,
|
||||||
const char *class_loader_context) {
|
jobject class_loader, const char *class_loader_context) static -> void {
|
||||||
if (lspd::Context::GetInstance()->GetCurrentClassLoader() == nullptr) {
|
if (lspd::Context::GetInstance()->GetCurrentClassLoader() == nullptr) {
|
||||||
LOGD("Disabled background verification");
|
LOGD("Disabled background verification");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RunBackgroundVerificationWithContext_(thiz, dex_files, class_loader,
|
backup(thiz, dex_files, class_loader, class_loader_context);
|
||||||
class_loader_context);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
inline static MemberHooker<
|
inline static auto RunBackgroundVerification_ =
|
||||||
"_ZN3art14OatFileManager25RunBackgroundVerificationERKNSt3__"
|
("_ZN3art14OatFileManager25RunBackgroundVerificationERKNSt3__"_sym |
|
||||||
"16vectorIPKNS_7DexFileENS1_9allocatorIS5_EEEEP8_jobject",
|
"16vectorIPKNS_7DexFileENS1_9allocatorIS5_EEEEP8_jobject"_sym)
|
||||||
FileManager, void(const std::vector<const void *> &, jobject)>
|
.hook
|
||||||
RunBackgroundVerification_ =
|
->*
|
||||||
+[](FileManager *thiz, const std::vector<const void *> &dex_files,
|
[]<MemBackup auto backup>(FileManager *thiz, const std::vector<const void *> &dex_files,
|
||||||
jobject class_loader) {
|
jobject class_loader) static -> void {
|
||||||
if (lspd::Context::GetInstance()->GetCurrentClassLoader() == nullptr) {
|
if (lspd::Context::GetInstance()->GetCurrentClassLoader() == nullptr) {
|
||||||
LOGD("Disabled background verification");
|
LOGD("Disabled background verification");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RunBackgroundVerification_(thiz, dex_files, class_loader);
|
backup(thiz, dex_files, class_loader);
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void DisableBackgroundVerification(const lsplant::HookHandler &handler) {
|
static void DisableBackgroundVerification(const lsplant::HookHandler &handler) {
|
||||||
const int api_level = lspd::GetAndroidApiLevel();
|
const int api_level = lspd::GetAndroidApiLevel();
|
||||||
if (api_level >= __ANDROID_API_Q__) {
|
if (api_level >= __ANDROID_API_Q__) {
|
||||||
handler.hook(RunBackgroundVerificationWithContext_);
|
handler(RunBackgroundVerificationWithContext_);
|
||||||
handler.hook(RunBackgroundVerification_);
|
handler(RunBackgroundVerification_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
#include "utils/hook_helper.hpp"
|
#include "utils/hook_helper.hpp"
|
||||||
#include "utils/jni_helper.hpp"
|
#include "utils/jni_helper.hpp"
|
||||||
|
|
||||||
|
using lsplant::operator""_sym;
|
||||||
|
|
||||||
namespace lspd {
|
namespace lspd {
|
||||||
|
|
||||||
std::string apkPath;
|
std::string apkPath;
|
||||||
|
|
@ -19,7 +21,7 @@ std::string redirectPath;
|
||||||
|
|
||||||
inline static constexpr auto kLibCName = "libc.so";
|
inline static constexpr auto kLibCName = "libc.so";
|
||||||
|
|
||||||
std::unique_ptr<const SandHook::ElfImg>& GetC(bool release = false) {
|
std::unique_ptr<const SandHook::ElfImg> &GetC(bool release = false) {
|
||||||
static std::unique_ptr<const SandHook::ElfImg> kImg = nullptr;
|
static std::unique_ptr<const SandHook::ElfImg> kImg = nullptr;
|
||||||
if (release) {
|
if (release) {
|
||||||
kImg.reset();
|
kImg.reset();
|
||||||
|
|
@ -29,23 +31,24 @@ std::unique_ptr<const SandHook::ElfImg>& GetC(bool release = false) {
|
||||||
return kImg;
|
return kImg;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static lsplant::Hooker<"__openat", int(int, const char*, int, int)> __openat_ =
|
inline static auto __openat_ =
|
||||||
+[](int fd, const char* pathname, int flag, int mode) {
|
"__openat"_sym.hook->*[]<lsplant::Backup auto backup>(int fd, const char *pathname, int flag,
|
||||||
if (pathname == apkPath) {
|
int mode) static -> int {
|
||||||
LOGD("Redirect openat from {} to {}", pathname, redirectPath);
|
if (pathname == apkPath) {
|
||||||
return __openat_(fd, redirectPath.c_str(), flag, mode);
|
LOGD("Redirect openat from {} to {}", pathname, redirectPath);
|
||||||
}
|
return backup(fd, redirectPath.c_str(), flag, mode);
|
||||||
return __openat_(fd, pathname, flag, mode);
|
}
|
||||||
};
|
return backup(fd, pathname, flag, mode);
|
||||||
|
};
|
||||||
|
|
||||||
bool HookOpenat(const lsplant::HookHandler& handler) { return handler.hook(__openat_); }
|
bool HookOpenat(const lsplant::HookHandler &handler) { return handler(__openat_); }
|
||||||
|
|
||||||
LSP_DEF_NATIVE_METHOD(void, SigBypass, enableOpenatHook, jstring origApkPath,
|
LSP_DEF_NATIVE_METHOD(void, SigBypass, enableOpenatHook, jstring origApkPath,
|
||||||
jstring cacheApkPath) {
|
jstring cacheApkPath) {
|
||||||
auto r = HookOpenat(lsplant::InitInfo{
|
auto r = HookOpenat(lsplant::InitInfo{
|
||||||
.inline_hooker =
|
.inline_hooker =
|
||||||
[](auto t, auto r) {
|
[](auto t, auto r) {
|
||||||
void* bk = nullptr;
|
void *bk = nullptr;
|
||||||
return HookInline(t, r, &bk) == 0 ? bk : nullptr;
|
return HookInline(t, r, &bk) == 0 ? bk : nullptr;
|
||||||
},
|
},
|
||||||
.art_symbol_resolver = [](auto symbol) { return GetC()->getSymbAddress(symbol); },
|
.art_symbol_resolver = [](auto symbol) { return GetC()->getSymbAddress(symbol); },
|
||||||
|
|
@ -66,6 +69,6 @@ LSP_DEF_NATIVE_METHOD(void, SigBypass, enableOpenatHook, jstring origApkPath,
|
||||||
static JNINativeMethod gMethods[] = {
|
static JNINativeMethod gMethods[] = {
|
||||||
LSP_NATIVE_METHOD(SigBypass, enableOpenatHook, "(Ljava/lang/String;Ljava/lang/String;)V")};
|
LSP_NATIVE_METHOD(SigBypass, enableOpenatHook, "(Ljava/lang/String;Ljava/lang/String;)V")};
|
||||||
|
|
||||||
void RegisterBypass(JNIEnv* env) { REGISTER_LSP_NATIVE_METHODS(SigBypass); }
|
void RegisterBypass(JNIEnv *env) { REGISTER_LSP_NATIVE_METHODS(SigBypass); }
|
||||||
|
|
||||||
} // namespace lspd
|
} // namespace lspd
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue