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 << ")";
}
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ struct ClassFileData {
// ======== Global references to prevent GC ========
// Remember to release these references when they are no longer needed, otherwise it will cause memory leaks
jclass clazz;
jclass classloader;
jobject classloader;
jobject protection_domain;
};
+1
View File
@@ -5,6 +5,7 @@
#include <JuiceAgent/Logger.hpp>
#include <libagent.hpp>
#include <utils.hpp>
#include <global.hpp>
// Generated by JuiceAgent-API
#include <cn_xiaozhou233_juiceagent_api_JuiceAgent.h>