Commit 60d2f219 authored by swift_gan's avatar swift_gan

fix call origin method by invoke!

parent 465929e1
......@@ -47,6 +47,11 @@ bool ArtMethod::isNative() {
return ((accessFlags & 0x0100) != 0);
}
bool ArtMethod::isStatic() {
uint32_t accessFlags = getAccessFlags();
return ((accessFlags & 0x0008) != 0);
}
bool ArtMethod::isCompiled() {
return getQuickCodeEntry() != SandHook::CastArtMethod::quickToInterpreterBridge;
}
......@@ -65,8 +70,9 @@ void ArtMethod::setAccessFlags(uint32_t flags) {
void ArtMethod::setPrivate() {
uint32_t accessFlag = getAccessFlags();
accessFlag &= ~ 0x1;
accessFlag |= 0x2;
accessFlag &= ~ 0x0001;
accessFlag &= ~ 0x0004;
accessFlag |= 0x0002;
setAccessFlags(accessFlag);
}
......@@ -138,4 +144,4 @@ void ArtMethod::backup(ArtMethod *backup) {
Size ArtMethod::size() {
return CastArtMethod::size;
}
\ No newline at end of file
}
......@@ -47,6 +47,7 @@ public:
bool isAbstract();
bool isNative();
bool isStatic();
bool isCompiled();
bool isThumbCode();
......
......@@ -75,6 +75,9 @@ void ensureMethodDeclaringClass(art::mirror::ArtMethod *origin, art::mirror::Art
if (SDK_INT >= ANDROID_O) {
backup->disableInterpreterForO();
}
if (!backup->isStatic()) {
backup->setPrivate();
}
backup->tryDisableInline();
} else if (trampoline->replacement != nullptr) {
origin->backup(backup);
......@@ -89,6 +92,9 @@ void ensureMethodDeclaringClass(art::mirror::ArtMethod *origin, art::mirror::Art
if (SDK_INT >= ANDROID_O) {
backup->disableInterpreterForO();
}
if (!backup->isStatic()) {
backup->setPrivate();
}
backup->tryDisableInline();
} else {
return;
......@@ -117,6 +123,9 @@ bool doHookWithReplacement(JNIEnv* env,
backupMethod->disableInterpreterForO();
}
backupMethod->tryDisableInline();
if (!backupMethod->isStatic()) {
backupMethod->setPrivate();
}
backupMethod->flushCache();
}
......@@ -183,6 +192,9 @@ bool doHookWithInline(JNIEnv* env,
backupMethod->disableInterpreterForO();
}
backupMethod->tryDisableInline();
if (!backupMethod->isStatic()) {
backupMethod->setPrivate();
}
backupMethod->flushCache();
}
return true;
......
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