[core] Manually release ElfImg (#747)

This commit is contained in:
LoveSy 2021-06-15 10:06:53 +08:00 committed by GitHub
parent b49001cfab
commit cef4137c7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 7 deletions

View File

@ -99,16 +99,14 @@ android {
"-D__FILE__=__FILE_NAME__",
"-DRIRU_MODULE",
"-DRIRU_MODULE_API_VERSION=$moduleMaxRiruApiVersion",
"""-DMODULE_NAME=\"$riruModuleId\""""
// "-DRIRU_MODULE_VERSION=$verCode", // this will stop ccache from hitting
// """-DRIRU_MODULE_VERSION_NAME=\"$verName\"""",
"""-DMODULE_NAME=\"$riruModuleId\"""",
)
cppFlags("-std=c++20", *flags)
cFlags("-std=c18", *flags)
arguments(
"-DANDROID_STL=none",
"-DVERSION_CODE=$verCode",
"-DVERSION_NAME=$verName"
"-DVERSION_NAME=$verName",
)
targets("lspd")
}

View File

@ -18,6 +18,7 @@
## Copyright (C) 2021 LSPosed Contributors
##
project(libcxx)
cmake_minimum_required(VERSION 3.4.1)
find_program(CCACHE ccache)

View File

@ -231,6 +231,7 @@ namespace lspd {
} else {
auto context = Context::ReleaseInstance();
auto service = Service::ReleaseInstance();
art_img.reset();
LOGD("skipped %s", process_name.get());
setAllowUnload(true);
}

View File

@ -58,6 +58,10 @@ namespace SandHook {
return base != nullptr;
}
const std::string name() const {
return elf;
}
~ElfImg();
private:

View File

@ -47,7 +47,7 @@ namespace lspd {
return;
}
LOGD("Start to install inline hooks");
SandHook::ElfImg &handle_libart = *art_img;
const auto &handle_libart = *art_img;
if (!handle_libart.isValid()) {
LOGE("Failed to fetch libart.so");
}

View File

@ -39,7 +39,7 @@ namespace lspd {
void *sym_openDexFileNative = nullptr;
void *sym_setTrusted = nullptr;
void *sym_set_table_override = nullptr;
std::unique_ptr<SandHook::ElfImg> art_img = nullptr;
std::unique_ptr<const SandHook::ElfImg> art_img = nullptr;
bool findLibArt() {
art_img = std::make_unique<SandHook::ElfImg>(kLibArtName);

View File

@ -32,7 +32,7 @@ namespace SandHook {
namespace lspd {
extern bool sym_initialized;
extern std::unique_ptr<SandHook::ElfImg> art_img;
extern std::unique_ptr<const SandHook::ElfImg> art_img;
extern void *sym_do_dlopen;
extern void *sym_openInMemoryDexFilesNative;
extern void *sym_createCookieWithArray;