mirror of
https://github.com/LSPosed/LSPlant.git
synced 2025-05-04 20:42:02 +08:00
Make backup logic as a function
This commit is contained in:
parent
68f8a63e8f
commit
897c70b74a
@ -155,6 +155,17 @@ public:
|
||||
reinterpret_cast<uintptr_t>(this) + declaring_class_offset));
|
||||
}
|
||||
|
||||
void BackupTo(ArtMethod *backup) {
|
||||
SetNonCompilable();
|
||||
|
||||
// copy after setNonCompilable
|
||||
backup->CopyFrom(this);
|
||||
|
||||
ClearFastInterpretFlag();
|
||||
|
||||
if (!backup->IsStatic()) backup->SetPrivate();
|
||||
}
|
||||
|
||||
static art::ArtMethod *FromReflectedMethod(JNIEnv *env, jobject method) {
|
||||
if (art_method_field) [[likely]] {
|
||||
return reinterpret_cast<art::ArtMethod *>(
|
||||
|
@ -592,18 +592,12 @@ bool DoHook(ArtMethod *target, ArtMethod *hook, ArtMethod *backup) {
|
||||
} else {
|
||||
LOGV("Generated trampoline %p", entrypoint);
|
||||
|
||||
target->SetNonCompilable();
|
||||
hook->SetNonCompilable();
|
||||
|
||||
// copy after setNonCompilable
|
||||
backup->CopyFrom(target);
|
||||
|
||||
target->ClearFastInterpretFlag();
|
||||
target->BackupTo(backup);
|
||||
|
||||
target->SetEntryPoint(entrypoint);
|
||||
|
||||
if (!backup->IsStatic()) backup->SetPrivate();
|
||||
|
||||
LOGV("Done hook: target(%p:0x%x) -> %p; backup(%p:0x%x) -> %p; hook(%p:0x%x) -> %p", target,
|
||||
target->GetAccessFlags(), target->GetEntryPoint(), backup, backup->GetAccessFlags(),
|
||||
backup->GetEntryPoint(), hook, hook->GetAccessFlags(), hook->GetEntryPoint());
|
||||
|
Loading…
x
Reference in New Issue
Block a user