Skip to content

Commit b384321

Browse files
committed
Adapt to the restructure of lsplant
Update submodule JingMatrix/LSPlant
1 parent 165ad94 commit b384321

7 files changed

Lines changed: 23 additions & 15 deletions

File tree

.github/workflows/core.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ jobs:
8080
restore-keys: ${{ runner.os }}
8181
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
8282

83+
- name: Setup Android SDK
84+
uses: android-actions/setup-android@v3
85+
8386
- name: Remove Android's cmake
8487
shell: bash
8588
run: rm -rf $ANDROID_HOME/cmake

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ val androidTargetSdkVersion by extra(35)
7070
val androidMinSdkVersion by extra(27)
7171
val androidBuildToolsVersion by extra("35.0.0")
7272
val androidCompileSdkVersion by extra(35)
73-
val androidCompileNdkVersion by extra("27.1.12297006")
73+
val androidCompileNdkVersion by extra("29.0.13113456")
7474
val androidSourceCompatibility by extra(JavaVersion.VERSION_21)
7575
val androidTargetCompatibility by extra(JavaVersion.VERSION_21)
7676

core/src/main/jni/include/framework/androidfw/resource_types.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <cstdint>
2525
#include "utils/hook_helper.hpp"
2626

27+
using lsplant::operator""_sym;
28+
2729
// @ApiSensitive(Level.MIDDLE)
2830
namespace android {
2931

@@ -142,11 +144,11 @@ namespace android {
142144

143145
using stringAtRet = expected<StringPiece16, NullOrIOError>;
144146

145-
inline static lsplant::MemberFunction<{"_ZNK7android13ResStringPool8stringAtEjPj",
146-
"_ZNK7android13ResStringPool8stringAtEmPm"}, ResStringPool, stringAtRet (size_t)> stringAtS_;
147+
inline static auto stringAtS_ = ("_ZNK7android13ResStringPool8stringAtEjPj"_sym |
148+
"_ZNK7android13ResStringPool8stringAtEmPm"_sym).as<stringAtRet (ResStringPool::*)(size_t)>;
147149

148-
inline static lsplant::MemberFunction<{"_ZNK7android13ResStringPool8stringAtEj",
149-
"_ZNK7android13ResStringPool8stringAtEm"}, ResStringPool, const char16_t* (size_t, size_t *)> stringAt_;
150+
inline static auto stringAt_ = ("_ZNK7android13ResStringPool8stringAtEj"_sym |
151+
"_ZNK7android13ResStringPool8stringAtEm"_sym).as<const char16_t* (ResStringPool::*)(size_t, size_t *)>;
150152

151153
StringPiece16 stringAt(size_t idx) const {
152154
if (stringAt_) {
@@ -163,7 +165,7 @@ namespace android {
163165
}
164166

165167
static bool setup(const lsplant::HookHandler &handler) {
166-
return handler.dlsym(stringAt_) || handler.dlsym(stringAtS_);
168+
return handler(stringAt_) || handler(stringAtS_);
167169
}
168170
};
169171

core/src/main/jni/src/jni/resources_hook.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ namespace lspd {
7575
"_ZNK7android12ResXMLParser18getAttributeNameIDEm")))) {
7676
return false;
7777
}
78-
return android::ResStringPool::setup(lsplant::InitInfo {
78+
return android::ResStringPool::setup(InitInfo {
7979
.art_symbol_resolver = [&](auto s) {
80-
return fw.template getSymbAddress(s);
80+
return fw.template getSymbAddress<>(s);
8181
}
8282
});
8383
}
@@ -111,7 +111,7 @@ namespace lspd {
111111

112112
// @ApiSensitive(Level.MIDDLE)
113113
LSP_DEF_NATIVE_METHOD(jboolean, ResourcesHook, makeInheritable, jclass target_class) {
114-
if (lsplant::MakeClassInheritable(env, target_class)) {
114+
if (MakeClassInheritable(env, target_class)) {
115115
return JNI_TRUE;
116116
}
117117
return JNI_FALSE;

core/src/main/jni/src/native_api.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
* callback will not work.
4848
*/
4949

50+
using lsplant::operator""_sym;
51+
5052
namespace lspd {
5153

5254
std::list<NativeOnModuleLoaded> moduleLoadedCallbacks;
@@ -91,10 +93,10 @@ namespace lspd {
9193
return false;
9294
}
9395

94-
inline static lsplant::Hooker<"__dl__Z9do_dlopenPKciPK17android_dlextinfoPKv",
95-
void*(const char*, int, const void*, const void*)>
96-
do_dlopen = +[](const char* name, int flags, const void* extinfo, const void* caller_addr) {
97-
auto *handle = do_dlopen(name, flags, extinfo, caller_addr);
96+
inline static auto do_dlopen_ = "__dl__Z9do_dlopenPKciPK17android_dlextinfoPKv"_sym.hook->*[]
97+
<lsplant::Backup auto backup>
98+
(const char* name, int flags, const void* extinfo, const void* caller_addr) static -> void* {
99+
auto *handle = backup(name, flags, extinfo, caller_addr);
98100
std::string ns;
99101
if (name) {
100102
ns = std::string(name);
@@ -133,6 +135,6 @@ namespace lspd {
133135
};
134136

135137
bool InstallNativeAPI(const lsplant::HookHandler & handler) {
136-
return handler.hook(do_dlopen);
138+
return handler(do_dlopen_);
137139
}
138140
}

external/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ OPTION(LSPLANT_BUILD_SHARED OFF)
2323
add_subdirectory(dobby)
2424
add_subdirectory(fmt)
2525
add_subdirectory(lsplant/lsplant/src/main/jni)
26+
target_compile_options(lsplant_static PUBLIC -Wno-gnu-anonymous-struct)
2627
target_compile_definitions(fmt-header-only INTERFACE FMT_USE_LOCALE=0 FMT_USE_FLOAT=0 FMT_USE_DOUBLE=0 FMT_USE_LONG_DOUBLE=0 FMT_USE_BITINT=0)

0 commit comments

Comments
 (0)