Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API in edconfig & Replace whale with dobby #658

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,5 @@ Notice: These community group don't accept any bug report, please use [Get help]
- [Riru](https://github.com/RikkaApps/Riru): provides a way to inject codes into zygote process
- [XposedBridge](https://github.com/rovo89/XposedBridge): the OG xposed framework APIs
- [dexmaker](https://github.com/linkedin/dexmaker) and [dalvikdx](https://github.com/JakeWharton/dalvik-dx): to dynamiclly generate YAHFA hooker classes
- [Whale](https://github.com/asLody/whale): used for inline hooking
- [SandHook](https://github.com/ganyao114/SandHook/): ART hooking framework for SandHook variant

- [Dobby](https://github.com/jmpews/Dobby): used for inline hooking
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ Edxposed 拥有三个不同的版本
- [Riru](https://github.com/RikkaApps/Riru): 提供一种将代码注入 zygote 进程的方法
- [XposedBridge](https://github.com/rovo89/XposedBridge): 原版 xposed 框架的 API
- [dexmaker](https://github.com/linkedin/dexmaker) 和 [dalvikdx](https://github.com/JakeWharton/dalvik-dx): 动态生成 YAHFA hook 类
- [Whale](https://github.com/asLody/whale): 用于 hook 内联方法
- [SandHook](https://github.com/ganyao114/SandHook/): SandHook 分支的 ART hooking 框架
- [Dobby](https://github.com/jmpews/Dobby): 用于 hook 内联方法

1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ only_commits:
- edxp-common/
- edxp-core/
- edxp-sandhook/
- edxp-whale/
- edxp-yahfa/
- hiddenapi-stubs/
- xposed-bridge/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ public String getXposedPropPath() {
public String getLibSandHookName() {
return ConfigManager.getLibSandHookName();
}
@Override
public String getLibWhaleName() {
return ConfigManager.getLibWhaleName();
}

@Override
public boolean isDynamicModulesMode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ private static boolean isFileExists(String path) {

public static native String getLibSandHookName();

public static native String getLibWhaleName();

public static native String getInstallerConfigPath(String suffix);

public static native String getDataPathPrefix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public interface EdxpImpl extends KeepAll {
int NONE = 0;
int YAHFA = 1;
int SANDHOOK = 2;
int WHALE = 3;

@NonNull
Proxy getNormalProxy();
Expand All @@ -31,7 +30,7 @@ public interface EdxpImpl extends KeepAll {
boolean isInitialized();

@Retention(SOURCE)
@IntDef({NONE, YAHFA, SANDHOOK, WHALE})
@IntDef({NONE, YAHFA, SANDHOOK})
@interface Variant {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,5 @@ private static void loadEdxpImpls() {
}catch(Throwable ignored) {
Utils.logD("not using yahfa");
}
try {
Class.forName("com.elderdrivers.riru.edxp.whale.core.WhaleEdxpImpl");
}catch(Throwable ignored) {
Utils.logD("not found whale");
}
}
}
3 changes: 2 additions & 1 deletion edxp-core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
/template_override/module.prop
/template_override/system
/template_override/system_x86
/template_override/riru/module.prop.new
*.iml
/.cxx
/.cxx
4 changes: 1 addition & 3 deletions edxp-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ ext {
module_name = "EdXposed"
jar_dest_dir = "${projectDir}/template_override/system/framework/"
is_windows = OperatingSystem.current().isWindows()
backends = ["YAHFA", "SandHook", "Whale"]
backends = ["YAHFA", "SandHook"]
yahfa_module_id = "riru_edxposed"
sandhook_module_id = yahfa_module_id + "_sandhook"
whale_module_id = yahfa_module_id + "_whale"
yahfa_authors = "solohsu, MlgmXyysd & rk700"
sandhook_authors = "solohsu, MlgmXyysd & ganyao114"
whale_authors = "solohsu, MlgmXyysd & asLody"

riruModuleId = "edxp"
zipPathMagiskRelease = "$buildDir/tmp/release/magisk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ remove_edxposed() {
ui_print "- Deleting EdXposed..."
rm -r -f /data/adb/modules/riru_edxposed/
rm -r -f /data/adb/modules/riru_edxposed_sandhook/
rm -r -f /data/adb/modules/riru_edxposed_whale/
rm -r -f /data/misc/riru/modules/edxposed/
rm -r -f /data/misc/riru/modules/edxp/
ui_print "- Done"
Expand Down
14 changes: 0 additions & 14 deletions edxp-core/src/main/cpp/main/include/android_build.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace art {
static void Setup(void *handle, HookFunType hook_func) {
LOGD("Classlinker hook setup, handle=%p", handle);
// TODO: Maybe not compatible with Android 10-
int api_level = GetAndroidApiLevel();
int api_level = edxp::GetAndroidApiLevel();
size_t OFFSET_classlinker; // Get offset from art::Runtime::RunRootClinits() call in IDA
switch(api_level) {
case __ANDROID_API_O__:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace art {

// @ApiSensitive(Level.HIGH)
static void DisableHiddenApi(void *handle, HookFunType hook_func) {
const int api_level = GetAndroidApiLevel();
const int api_level = edxp::GetAndroidApiLevel();
if (api_level < __ANDROID_API_P__) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace art {
// @ApiSensitive(Level.LOW)
// http://androidxref.com/9.0.0_r3/xref/art/runtime/oat_file_manager.cc#637
static void DisableOnlyUseSystemOatFiles(void *handle, HookFunType hook_func) {
const int api_level = GetAndroidApiLevel();
const int api_level = edxp::GetAndroidApiLevel();
if (api_level >= __ANDROID_API_P__) {
HOOK_FUNC(SetOnlyUseSystemOatFiles,
"_ZN3art14OatFileManager24SetOnlyUseSystemOatFilesEv", // 9 & 11
Expand Down
2 changes: 0 additions & 2 deletions edxp-core/src/main/cpp/main/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <sys/types.h>
#include <string>
#include "art/base/macros.h"
#include "android_build.h"
#include "utils.h"

namespace edxp {
Expand All @@ -30,7 +29,6 @@ namespace edxp {

static const auto kLibArtName = "libart.so"_str;
static const auto kLibFwName = "libandroidfw.so"_str;
static const auto kLibWhaleName = "libwhale.edxp.so"_str;
static const auto kLibSandHookName = "libsandhook.edxp.so"_str;
static const auto kLibDlName = "libdl.so"_str;
static const auto kLibSandHookNativeName = "libsandhook-native.so"_str;
Expand Down
8 changes: 8 additions & 0 deletions edxp-core/src/main/cpp/main/include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@
#include <string>
#include <filesystem>
#include "logging.h"
#include <sys/system_properties.h>

namespace edxp {

static inline int32_t GetAndroidApiLevel() {
char prop_value[PROP_VALUE_MAX];
__system_property_get("ro.build.version.sdk", prop_value);
return atoi(prop_value);
}

inline const std::string operator ""_str(const char *str, std::size_t size) {
return {str, size};
}
Expand Down
2 changes: 1 addition & 1 deletion edxp-core/src/main/cpp/main/src/config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include <vector>
#include <string>

#include <android_build.h>
#include <logging.h>
#include <climits>
#include <fstream>
#include <sstream>
#include "art/runtime/native/native_util.h"
#include "config_manager.h"
#include "utils.h"

namespace edxp {
namespace fs = std::filesystem;
Expand Down
2 changes: 0 additions & 2 deletions edxp-core/src/main/cpp/main/src/config_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ namespace edxp {

inline auto GetLibSandHookName() const { return kLibSandHookName; }

inline auto GetLibWhaleName() const { return kLibWhaleName; }

inline auto GetDataPathPrefix() const { return data_path_prefix_; }

inline auto GetConfigPath(const std::string &suffix) const {
Expand Down
1 change: 0 additions & 1 deletion edxp-core/src/main/cpp/main/src/edxp_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace edxp {
NONE = 0,
YAHFA = 1,
SANDHOOK = 2,
WHALE = 3
};

class Context {
Expand Down
5 changes: 0 additions & 5 deletions edxp-core/src/main/cpp/main/src/jni/edxp_config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ namespace edxp {
return env->NewStringUTF(ConfigManager::GetInstance()->GetXposedPropPath().c_str());
}

static jstring ConfigManager_getLibWhaleName(JNI_START) {
return env->NewStringUTF(ConfigManager::GetInstance()->GetLibWhaleName().c_str());
}

static jstring ConfigManager_getLibSandHookName(JNI_START) {
return env->NewStringUTF(ConfigManager::GetInstance()->GetLibSandHookName().c_str());
}
Expand Down Expand Up @@ -73,7 +69,6 @@ namespace edxp {
NATIVE_METHOD(ConfigManager, getInstallerPackageName, "()Ljava/lang/String;"),
NATIVE_METHOD(ConfigManager, getXposedPropPath, "()Ljava/lang/String;"),
NATIVE_METHOD(ConfigManager, getLibSandHookName, "()Ljava/lang/String;"),
NATIVE_METHOD(ConfigManager, getLibWhaleName, "()Ljava/lang/String;"),
NATIVE_METHOD(ConfigManager, getDataPathPrefix, "()Ljava/lang/String;"),
NATIVE_METHOD(ConfigManager, getInstallerConfigPath,
"(Ljava/lang/String;)Ljava/lang/String;"),
Expand Down
3 changes: 1 addition & 2 deletions edxp-core/src/main/cpp/main/src/native_hook.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

#include <dlfcn.h>
#include <android_build.h>
#include <string>
#include <vector>
#include <config_manager.h>
Expand All @@ -9,7 +8,7 @@
#include <art/runtime/jni_env_ext.h>
#include <dobby.h>
#include "android_restriction.h" // from Dobby

#include "utils.h"
#include "logging.h"
#include "native_hook.h"
#include "riru_hook.h"
Expand Down
2 changes: 1 addition & 1 deletion edxp-core/src/main/cpp/main/src/riru_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <xhook.h>
#include <sys/system_properties.h>
#include <logging.h>
#include <android_build.h>
#include "utils.h"
#include "riru_hook.h"

namespace edxp {
Expand Down
8 changes: 0 additions & 8 deletions edxp-core/template_override/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ JAR_EDDEXMAKER="$(getRandomNameExist 8 "" ".dex" "
#/system/framework
#").jar"
LIB_RIRU_EDXP="libriru_${RIRU_EDXP}.so"
LIB_WHALE_EDXP="lib$(getRandomNameExist 10 "lib" ".so" "
/system/lib
/system/lib64
").so"
LIB_SANDHOOK_EDXP="lib$(getRandomNameExist 13 "lib" ".so" "
/system/lib
/system/lib64
Expand Down Expand Up @@ -272,12 +268,10 @@ mv "${MODPATH}/system/framework/edxp.dex" "${MODPATH}/system/framework/${JAR_EDX
mv "${MODPATH}/system/framework/eddexmaker.dex" "${MODPATH}/system/framework/${JAR_EDDEXMAKER}"
#mv "${MODPATH}/system/framework/edconfig.jar" "${MODPATH}/system/framework/${JAR_EDCONFIG}"
mv "${MODPATH}/system/lib/libriru_edxp.so" "${MODPATH}/system/lib/${LIB_RIRU_EDXP}"
#mv "${MODPATH}/system/lib/libwhale.edxp.so" "${MODPATH}/system/lib/${LIB_WHALE_EDXP}"
mv "${MODPATH}/system/lib/libsandhook-native.so" "${MODPATH}/system/lib/libsandhook-native.so"

if [[ "${IS64BIT}" == true ]]; then
mv "${MODPATH}/system/lib64/libriru_edxp.so" "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}"
#mv "${MODPATH}/system/lib64/libwhale.edxp.so" "${MODPATH}/system/lib64/${LIB_WHALE_EDXP}"
mv "${MODPATH}/system/lib64/libsandhook-native.so" "${MODPATH}/system/lib64/libsandhook-native.so"
fi

Expand All @@ -293,14 +287,12 @@ ui_print "- Resetting libraries path"
sed -i 's:/system/framework/edxp.dex\:/system/framework/eddalvikdx.dex\:/system/framework/eddexmaker.dex:/system/framework/'"${JAR_EDXP}"'\:/system/framework/'"${JAR_EDDALVIKDX}"'\:/system/framework/'"${JAR_EDDEXMAKER}"':g' "${MODPATH}/system/lib/${LIB_RIRU_EDXP}"
#sed -i 's:/system/framework/edconfig.jar:/system/framework/'"${JAR_EDCONFIG}"':g' "${MODPATH}/system/lib/${LIB_RIRU_EDXP}"
sed -i 's:libriru_edxp.so:'"${LIB_RIRU_EDXP}"':g' "${MODPATH}/system/lib/${LIB_RIRU_EDXP}"
#sed -i 's:libwhale.edxp.so:'"${LIB_WHALE_EDXP}"':g' "${MODPATH}/system/lib/${LIB_RIRU_EDXP}"
sed -i 's:libsandhook.edxp.so:'"${LIB_SANDHOOK_EDXP}"':g' "${MODPATH}/system/lib/${LIB_RIRU_EDXP}"

if [[ "${IS64BIT}" == true ]]; then
sed -i 's:/system/framework/edxp.dex\:/system/framework/eddalvikdx.dex\:/system/framework/eddexmaker.dex:/system/framework/'"${JAR_EDXP}"'\:/system/framework/'"${JAR_EDDALVIKDX}"'\:/system/framework/'"${JAR_EDDEXMAKER}"':g' "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}"
# sed -i 's:/system/framework/edconfig.jar:/system/framework/'"${JAR_EDCONFIG}"':g' "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}"
sed -i 's:libriru_edxp.so:'"${LIB_RIRU_EDXP}"':g' "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}"
#sed -i 's:libwhale.edxp.so:'"${LIB_WHALE_EDXP}"':g' "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}"
sed -i 's:libsandhook.edxp.so:'"${LIB_SANDHOOK_EDXP}"':g' "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}"
fi

Expand Down
6 changes: 0 additions & 6 deletions edxp-core/template_override/riru/module.prop.new

This file was deleted.

2 changes: 1 addition & 1 deletion edxp-core/tpl/edconfig.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=91.0-$version ($backend)
version=92.0-$version ($backend)
arch=arm64
minsdk=26
maxsdk=29
Expand Down
1 change: 0 additions & 1 deletion edxp-sandhook/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ afterEvaluate {
from (dexOutPath){
rename("classes.dex", "edxp.dex")
}
from "${projectDir}/src/main/resources/"
destinationDir file(templateRootPath + "system/framework/")
outputs.upToDateWhen { false }
}
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions edxp-whale/.gitignore

This file was deleted.

72 changes: 0 additions & 72 deletions edxp-whale/build.gradle

This file was deleted.

Loading