Commit 10f5e044 authored by swift_gan's avatar swift_gan Committed by swift_gan

can skip size check

parent 0722234f
......@@ -86,6 +86,7 @@ namespace SandHook {
}
bool inlineSecurityCheck = true;
bool skipAllCheck = false;
private:
Size quickCompileOffset;
......
......@@ -273,6 +273,12 @@ Java_com_swift_sandhook_SandHook_setInlineSafeCheck(JNIEnv *env, jclass type, jb
trampolineManager.inlineSecurityCheck = check;
}
extern "C"
JNIEXPORT void JNICALL
Java_com_swift_sandhook_SandHook_skipAllSafeCheck(JNIEnv *env, jclass type, jboolean skip) {
trampolineManager.skipAllCheck = skip;
}
extern "C"
JNIEXPORT void JNICALL
Java_com_swift_sandhook_test_TestClass_jni_1test(JNIEnv *env, jobject instance) {
......
......@@ -69,10 +69,15 @@ namespace SandHook {
};
bool TrampolineManager::canSafeInline(mirror::ArtMethod *method) {
if (skipAllCheck)
return true;
//check size
if (!method->isNative()) {
uint32_t originCodeSize = sizeOfEntryCode(method);
if (originCodeSize < SIZE_DIRECT_JUMP_TRAMPOLINE) {
LOGW("can not inline due to origin code is too small(size is %d)", originCodeSize);
return false;
}
}
......
......@@ -242,6 +242,7 @@ public class SandHook {
//default on!
public static native void setInlineSafeCheck(boolean check);
public static native void skipAllSafeCheck(boolean skip);
private static native int hookMethod(Member originMethod, Method hookMethod, Method backupMethod, int hookMode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment