Skip to content

Commit

Permalink
Fix the circular dependency issue below Android7.
Browse files Browse the repository at this point in the history
Fix some dynamic proxy errors.
Fixed some cases where Android11 could not read the file path
  • Loading branch information
sanfengAndroid committed Mar 2, 2021
1 parent 21c8401 commit 069dd50
Show file tree
Hide file tree
Showing 38 changed files with 407 additions and 499 deletions.
15 changes: 10 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ plugins {
def highHookModuleName = 'hookh'
def lowHookModuleName = 'hookl'
def hookModuleName = (rootProject.props['buildApi'] ?: rootProject.targetSdk) >= 24 ? highHookModuleName : lowHookModuleName
def mVersionCode = 1400
def mVersionName = "1.4"
def mVersionCode = 1500
def mVersionName = "1.5"
def appType = rootProject.props['appType']
android {
compileSdkVersion 30
Expand Down Expand Up @@ -54,7 +54,7 @@ android {
cFlags ""
abiFilters.addAll(rootProject.props['abis'] ?: ['armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'])
arguments '-DANDROID_PLATFORM=' + (rootProject.props['buildApi']), "-DHOOK_MODULE_NAME=${hookModuleName}",
'-DMERGE_BUILD=' + (rootProject.props['mergeBuild'] ?: true),
'-DMERGE_BUILD=' + rootProject.props['mergeBuild'],
'-DHOOK_LOG_LEVEL=' + (rootProject.props['logLevel']),
"-DMODULE_VERSION=${mVersionCode}",
"-DMODULE_VERSION_NAME=\"${mVersionName}\""
Expand Down Expand Up @@ -98,7 +98,7 @@ android {
variant.sourceSets.each {
it.jniLibs.srcDirs = ["src/main/libs/${buildType}"]
}
variant.outputs.all{
variant.outputs.all {
outputFileName = "datafilter-${buildType}-${mVersionName}-${appType}.apk"
}
}
Expand All @@ -116,7 +116,12 @@ tasks.whenTaskAdded { task ->
}
}
dir.eachFileRecurse {
if (it.name == "lib${hookModuleName}.so") {
if (it.parentFile.name == 'x86_64' || it.parentFile.name == 'arm64-v8a') {
if (!rootProject.props['mergeBuild'] && it.name == "lib${hookModuleName}64.so") {
println "delete current build hook module: ${it.name}"
it.delete()
}
} else if (it.name == "lib${hookModuleName}.so") {
println "delete building library: ${it.absolutePath}"
it.delete()
}
Expand Down
32 changes: 15 additions & 17 deletions app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ include_directories(interface)
set(COPY_DIR ${CMAKE_ANDROID_ARCH_ABI})
if (${MERGE_BUILD} AND ${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a")
set(COPY_DIR "armeabi-v7a")
set(HOOK_MODULE_NAME ${HOOK_MODULE_NAME}64)
elseif (${MERGE_BUILD} AND ${CMAKE_ANDROID_ARCH_ABI} STREQUAL "x86_64")
set(COPY_DIR "x86")
set(HOOK_MODULE_NAME ${HOOK_MODULE_NAME}64)
endif ()

message(STATUS "api:${ANDROID_PLATFORM}, build type:${THIS_BUILD_TYPE}, hook module:${HOOK_MODULE_NAME}, copy dir:${COPY_DIR}")
if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a" OR ${CMAKE_ANDROID_ARCH_ABI} STREQUAL "x86_64")
set(HOOK_MODULE_NAME ${HOOK_MODULE_NAME}64)
endif()
message(STATUS "api:${ANDROID_PLATFORM}, build type:${THIS_BUILD_TYPE}, hook module:${HOOK_MODULE_NAME}, merge build:${MERGE_BUILD}, copy dir:${COPY_DIR}")

add_library(
${HOOK_MODULE_NAME}
SHARED
${HOOK_MODULE_NAME}
SHARED

hook/hook_common.cpp
hook/hook_main.cpp
Expand All @@ -57,38 +57,36 @@ add_library(
# Java Native Hook
hook/hook_java_native.cpp

common/maps_util.cpp
common/exec_strings.cpp
common/maps_util.cpp
# JNI Common
common/jni_helper.cpp
)



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

find_library( # Sets the name of the path variable.
log-lib
log-lib

# Specifies the name of the NDK library that
# you want CMake to locate.
log)
# Specifies the name of the NDK library that
# you want CMake to locate.
log)


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

target_link_libraries(
${HOOK_MODULE_NAME}
${log-lib})
${HOOK_MODULE_NAME}
${log-lib})
set_target_properties(${HOOK_MODULE_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/../libs/${THIS_BUILD_TYPE}/${COPY_DIR})
RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/../libs/${THIS_BUILD_TYPE}/${COPY_DIR})

set_target_properties(${HOOK_MODULE_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
Expand Down
64 changes: 0 additions & 64 deletions app/src/main/cpp/common/exec_strings.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions app/src/main/cpp/common/exec_strings.h

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/cpp/common/module_config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#define HOOK_LOG_LEVEL 2
#define MODULE_VERSION 1400
#define MODULE_VERSION_NAME "1.4"
#define MODULE_VERSION 1500
#define MODULE_VERSION_NAME "1.5"
1 change: 1 addition & 0 deletions app/src/main/cpp/hook/hook_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class FXHandler {
std::map<std::string, std::string> load_class_blacklist;
std::map<std::string, std::string> static_class_blacklist;
int pid;
int api;
private:
std::map<std::string, std::vector<RuntimeBean>> runtime_blacklist;
static FXHandler *instance_;
Expand Down
Loading

0 comments on commit 069dd50

Please sign in to comment.