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

fixbug: jit_load of Android10 is with empty param #71

Merged
merged 3 commits into from
Dec 21, 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: 3 additions & 0 deletions hooklib/src/main/cpp/casts/cast_compiler_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace SandHook {
Size calOffset(JNIEnv *jniEnv, art::CompilerOptions *p) override {
if (SDK_INT < ANDROID_N)
return getParentSize() + 1;
if (SDK_INT >= ANDROID_Q) {
return BYTE_POINT + 3 * sizeof(size_t);
}
if (SDK_INT >= ANDROID_O) {
return BYTE_POINT + 5 * sizeof(size_t);
} else {
Expand Down
2 changes: 1 addition & 1 deletion hooklib/src/main/cpp/sandhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ JNIEXPORT jboolean JNICALL
Java_com_swift_sandhook_SandHook_initNative(JNIEnv *env, jclass type, jint sdk, jboolean debug) {
SDK_INT = sdk;
DEBUG = debug;
SandHook::CastCompilerOptions::init(env);
initHideApi(env);
SandHook::CastArtMethod::init(env);
SandHook::CastCompilerOptions::init(env);
trampolineManager.init(SandHook::CastArtMethod::entryPointQuickCompiled->getOffset());
return JNI_TRUE;

Expand Down
17 changes: 11 additions & 6 deletions hooklib/src/main/cpp/utils/hide_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ extern int SDK_INT;
extern "C" {


void* (*jitLoad)(bool*) = nullptr;
void* jitCompilerHandle = nullptr;
bool (*jitCompileMethod)(void*, void*, void*, bool) = nullptr;
bool (*jitCompileMethodQ)(void*, void*, void*, bool, bool) = nullptr;
Expand Down Expand Up @@ -91,11 +90,17 @@ extern "C" {
bool)>(getSymCompat(jit_lib_path,
"jit_compile_method"));
}
jitLoad = reinterpret_cast<void* (*)(bool*)>(getSymCompat(jit_lib_path, "jit_load"));
bool generate_debug_info = false;

if (jitLoad != nullptr) {
jitCompilerHandle = (jitLoad)(&generate_debug_info);
auto jit_load = getSymCompat(jit_lib_path, "jit_load");
if (jit_load) {
if (SDK_INT >= ANDROID_Q) {
// Android 10:void* jit_load()
// Android 11: JitCompilerInterface* jit_load()
jitCompilerHandle = reinterpret_cast<void*(*)()>(jit_load)();
} else {
// void* jit_load(bool* generate_debug_info)
bool generate_debug_info = false;
jitCompilerHandle = reinterpret_cast<void*(*)(void*)>(jit_load)(&generate_debug_info);
}
} else {
jitCompilerHandle = getGlobalJitCompiler();
}
Expand Down