Commit f65fd71c authored by swift_gan's avatar swift_gan

Merge remote-tracking branch 'origin/master' into method_stubs

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