BugFix and Update: C++ 20

This commit is contained in:
xiaozhou233 committed 2026-04-02 12:51:23 +08:00
1 parent ad69f9d11a
commit 9aa77848d7
4 files changed
+30 -2

No files matched your search

@@ -14,5 +14,32 @@ void JNICALL ClassFileLoadHook(
unsigned char** new_classbytes) {
// Delete this log when the hook is stable, or it will cause performance issues
std::cout << "ClassFileLoadHook: " << name << std::endl;
if (!name) {
PLOGW << "name is null";
return;
}
/* =========================
* 1. Capture original bytes
* ========================= */
std::lock_guard<std::mutex> lock(classDataMutex);
if (classToCapture.contains(name)) {
if (!classFileDataMap.contains(name)) {
ClassFileData data;
data.className = name;
data.bytecode.assign(classbytes, classbytes + class_data_len);
// Experimental: class/classloader/protection_domain references (to be used in future features, e.g. dynamic patching)
data.clazz = class_being_redefined;
data.classloader = loader;
data.protection_domain = protection_domain;
classFileDataMap[name] = std::move(data);
classToCapture.erase(name);
PLOGI << "Captured class: " << name << " (length: " << class_data_len << ")";
}
}
}