Skip to content

Commit 069dd50

Browse files
Fix the circular dependency issue below Android7.
Fix some dynamic proxy errors. Fixed some cases where Android11 could not read the file path
1 parent 21c8401 commit 069dd50

38 files changed

+407
-499
lines changed

app/build.gradle

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ plugins {
2424
def highHookModuleName = 'hookh'
2525
def lowHookModuleName = 'hookl'
2626
def hookModuleName = (rootProject.props['buildApi'] ?: rootProject.targetSdk) >= 24 ? highHookModuleName : lowHookModuleName
27-
def mVersionCode = 1400
28-
def mVersionName = "1.4"
27+
def mVersionCode = 1500
28+
def mVersionName = "1.5"
2929
def appType = rootProject.props['appType']
3030
android {
3131
compileSdkVersion 30
@@ -54,7 +54,7 @@ android {
5454
cFlags ""
5555
abiFilters.addAll(rootProject.props['abis'] ?: ['armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'])
5656
arguments '-DANDROID_PLATFORM=' + (rootProject.props['buildApi']), "-DHOOK_MODULE_NAME=${hookModuleName}",
57-
'-DMERGE_BUILD=' + (rootProject.props['mergeBuild'] ?: true),
57+
'-DMERGE_BUILD=' + rootProject.props['mergeBuild'],
5858
'-DHOOK_LOG_LEVEL=' + (rootProject.props['logLevel']),
5959
"-DMODULE_VERSION=${mVersionCode}",
6060
"-DMODULE_VERSION_NAME=\"${mVersionName}\""
@@ -98,7 +98,7 @@ android {
9898
variant.sourceSets.each {
9999
it.jniLibs.srcDirs = ["src/main/libs/${buildType}"]
100100
}
101-
variant.outputs.all{
101+
variant.outputs.all {
102102
outputFileName = "datafilter-${buildType}-${mVersionName}-${appType}.apk"
103103
}
104104
}
@@ -116,7 +116,12 @@ tasks.whenTaskAdded { task ->
116116
}
117117
}
118118
dir.eachFileRecurse {
119-
if (it.name == "lib${hookModuleName}.so") {
119+
if (it.parentFile.name == 'x86_64' || it.parentFile.name == 'arm64-v8a') {
120+
if (!rootProject.props['mergeBuild'] && it.name == "lib${hookModuleName}64.so") {
121+
println "delete current build hook module: ${it.name}"
122+
it.delete()
123+
}
124+
} else if (it.name == "lib${hookModuleName}.so") {
120125
println "delete building library: ${it.absolutePath}"
121126
it.delete()
122127
}

app/src/main/cpp/CMakeLists.txt

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ include_directories(interface)
2525
set(COPY_DIR ${CMAKE_ANDROID_ARCH_ABI})
2626
if (${MERGE_BUILD} AND ${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a")
2727
set(COPY_DIR "armeabi-v7a")
28-
set(HOOK_MODULE_NAME ${HOOK_MODULE_NAME}64)
2928
elseif (${MERGE_BUILD} AND ${CMAKE_ANDROID_ARCH_ABI} STREQUAL "x86_64")
3029
set(COPY_DIR "x86")
31-
set(HOOK_MODULE_NAME ${HOOK_MODULE_NAME}64)
3230
endif ()
33-
34-
message(STATUS "api:${ANDROID_PLATFORM}, build type:${THIS_BUILD_TYPE}, hook module:${HOOK_MODULE_NAME}, copy dir:${COPY_DIR}")
31+
if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a" OR ${CMAKE_ANDROID_ARCH_ABI} STREQUAL "x86_64")
32+
set(HOOK_MODULE_NAME ${HOOK_MODULE_NAME}64)
33+
endif()
34+
message(STATUS "api:${ANDROID_PLATFORM}, build type:${THIS_BUILD_TYPE}, hook module:${HOOK_MODULE_NAME}, merge build:${MERGE_BUILD}, copy dir:${COPY_DIR}")
3535

3636
add_library(
37-
${HOOK_MODULE_NAME}
38-
SHARED
37+
${HOOK_MODULE_NAME}
38+
SHARED
3939

4040
hook/hook_common.cpp
4141
hook/hook_main.cpp
@@ -57,38 +57,36 @@ add_library(
5757
# Java Native Hook
5858
hook/hook_java_native.cpp
5959

60-
common/maps_util.cpp
61-
common/exec_strings.cpp
60+
common/maps_util.cpp
6261
# JNI Common
6362
common/jni_helper.cpp
6463
)
6564

6665

67-
6866
# Searches for a specified prebuilt library and stores the path as a
6967
# variable. Because CMake includes system libraries in the search path by
7068
# default, you only need to specify the name of the public NDK library
7169
# you want to add. CMake verifies that the library exists before
7270
# completing its build.
7371

7472
find_library( # Sets the name of the path variable.
75-
log-lib
73+
log-lib
7674

77-
# Specifies the name of the NDK library that
78-
# you want CMake to locate.
79-
log)
75+
# Specifies the name of the NDK library that
76+
# you want CMake to locate.
77+
log)
8078

8179

8280
# Specifies libraries CMake should link to your target library. You
8381
# can link multiple libraries, such as libraries you define in this
8482
# build script, prebuilt third-party libraries, or system libraries.
8583

8684
target_link_libraries(
87-
${HOOK_MODULE_NAME}
88-
${log-lib})
85+
${HOOK_MODULE_NAME}
86+
${log-lib})
8987
set_target_properties(${HOOK_MODULE_NAME} PROPERTIES
90-
RUNTIME_OUTPUT_DIRECTORY
91-
${CMAKE_CURRENT_SOURCE_DIR}/../libs/${THIS_BUILD_TYPE}/${COPY_DIR})
88+
RUNTIME_OUTPUT_DIRECTORY
89+
${CMAKE_CURRENT_SOURCE_DIR}/../libs/${THIS_BUILD_TYPE}/${COPY_DIR})
9290

9391
set_target_properties(${HOOK_MODULE_NAME} PROPERTIES
9492
LIBRARY_OUTPUT_DIRECTORY

app/src/main/cpp/common/exec_strings.cpp

Lines changed: 0 additions & 64 deletions
This file was deleted.

app/src/main/cpp/common/exec_strings.h

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
#define HOOK_LOG_LEVEL 2
3-
#define MODULE_VERSION 1400
4-
#define MODULE_VERSION_NAME "1.4"
3+
#define MODULE_VERSION 1500
4+
#define MODULE_VERSION_NAME "1.5"

app/src/main/cpp/hook/hook_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class FXHandler {
9191
std::map<std::string, std::string> load_class_blacklist;
9292
std::map<std::string, std::string> static_class_blacklist;
9393
int pid;
94+
int api;
9495
private:
9596
std::map<std::string, std::vector<RuntimeBean>> runtime_blacklist;
9697
static FXHandler *instance_;

0 commit comments

Comments
 (0)