Impl: retransform

This commit is contained in:
xiaozhou233 committed 2026-04-02 14:19:13 +08:00
1 parent 5e7972779f
commit f73265ac3e
5 files changed
+185 -1

No files matched your search

@@ -42,4 +42,23 @@ void JNICALL ClassFileLoadHook(
PLOGI << "Captured class: " << name << " (length: " << class_data_len << ")";
}
}
/* =========================
* 2. Apply patches
* ========================= */
if (pendingRetransform.contains(name)) {
auto& bytes = pendingRetransform[name];
unsigned char* new_buf = nullptr;
jvmti_env->Allocate(bytes.size(), &new_buf);
memcpy(new_buf, bytes.data(), bytes.size());
*new_class_data_len = (jint)bytes.size();
*new_classbytes = new_buf;
pendingRetransform.erase(name);
PLOGI << "Retransformed: " << name << " (new length: " << bytes.size() << ")";
}
}