Remove useless hooks

This commit is contained in:
LoveSy 2020-11-23 23:50:42 +08:00 committed by 双草酸酯
parent 6c1761ae54
commit 854021c7d8
3 changed files with 0 additions and 60 deletions

View File

@ -29,7 +29,6 @@ namespace edxp {
static const auto kSandHookNeverCallClassName = "com.swift.sandhook.ClassNeverCall"_str;
static const auto kLibArtName = "libart.so"_str;
static const auto kLibFwkName = "libandroid_runtime.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;
@ -39,16 +38,10 @@ namespace edxp {
static const auto kLibBasePath = std::string(
LP_SELECT("/system/lib/",
"/system/lib64/"));
static const auto kLinkerPath = std::string(
LP_SELECT("/apex/com.android.runtime/bin/linker",
"/apex/com.android.runtime/bin/linker64"));
static const auto kLibDlPath = kLibBasePath + kLibDlName;
static const auto kLibArtLegacyPath = kLibBasePath + kLibArtName;
static const auto kLibSandHookPath = kLibBasePath + kLibSandHookName;
static const auto kLibSandHookNativePath = kLibBasePath + kLibSandHookNativeName;
static const auto kLibFwPath = kLibBasePath + kLibFwName;
static const auto kLibFwkPath = kLibBasePath + kLibFwkName;
inline constexpr const char *const BoolToString(bool b) {
return b ? "true" : "false";

View File

@ -1,38 +0,0 @@
#pragma once
#include <android-base/strings.h>
#include "base/object.h"
namespace android {
// Static whitelist of open paths that the zygote is allowed to keep open.
static const char *kPathWhitelist[] = {
"/data/app/",
"/data/app-private/"
};
class FileDescriptorWhitelist : public edxp::HookedObject {
public:
FileDescriptorWhitelist(void *thiz) : HookedObject(thiz) {}
static void Setup(void *handle, HookFunType hook_func) {
HOOK_FUNC(IsAllowed,
"_ZNK23FileDescriptorWhitelist9IsAllowedERKNSt3__112"
"basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE");
}
private:
CREATE_HOOK_STUB_ENTRIES(bool, IsAllowed, void *thiz, const std::string &path) {
for (const auto &whitelist_path : kPathWhitelist) {
if (android::base::StartsWith(path, whitelist_path))
return true;
}
return IsAllowedBackup(thiz, path);
}
};
}

View File

@ -18,7 +18,6 @@
#include "art/runtime/gc/heap.h"
#include "art/runtime/hidden_api.h"
#include "art/runtime/oat_file_manager.h"
#include "framework/fd_utils.h"
std::vector<soinfo_t> linker_get_solist(); // Dobby but not in .h
@ -26,13 +25,10 @@ namespace edxp {
static volatile bool installed = false;
static volatile bool art_hooks_installed = false;
static volatile bool fwk_hooks_installed = false;
static HookFunType hook_func = nullptr;
void InstallArtHooks(void *art_handle);
void InstallFwkHooks(void *fwk_handle);
void InstallInlineHooks() {
if (installed) {
LOGI("Inline hooks have been installed, skip");
@ -72,9 +68,6 @@ namespace edxp {
ScopedDlHandle art_handle(kLibArtLegacyPath.c_str());
InstallArtHooks(art_handle.Get());
}
ScopedDlHandle fwk_handle(kLibFwkPath.c_str());
InstallFwkHooks(fwk_handle.Get());
}
void InstallArtHooks(void *art_handle) {
@ -94,13 +87,5 @@ namespace edxp {
art_hooks_installed = true;
LOGI("ART hooks installed");
}
void InstallFwkHooks(void *fwk_handle) {
if (fwk_hooks_installed) {
return;
}
android::FileDescriptorWhitelist::Setup(fwk_handle, hook_func);
}
}