Impl: Inject JuiceLoaderAPI

This commit is contained in:
xiaozhou233 committed 2026-03-30 13:37:51 +08:00
1 parent e5ac60d476
commit c5817a3b06
1 file changed
+10
+10
View File
@@ -6,6 +6,8 @@
namespace libloader
{
void entrypoint(const char* runtime_dir) {
// Load Config
config::Config cfg(runtime_dir);
if (!cfg.is_valid()) {
PLOGE << "Invalid config";
@@ -14,11 +16,19 @@ namespace libloader
InjectionInfo info = cfg.get_injection_info();
config::print_injection_info(info);
// Attach to JVM
jvm::Jvm jvm;
if (!jvm.attach()) {
PLOGE << "Attach failed";
return;
}
// Inject JuiceLoaderAPI.jar
jint status = jvm.get_jvmti()->AddToSystemClassLoaderSearch(info.JuiceAgentAPIJarPath.c_str());
if (status != JNI_OK) {
PLOGE << "AddToSystemClassLoaderSearch failed: " << status;
}
}
} // namespace libloader