mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-16 03:59:14 +03:00
36 lines
967 B
Java
36 lines
967 B
Java
package ru.gravit.launcher;
|
|
|
|
import java.io.IOException;
|
|
import java.lang.instrument.Instrumentation;
|
|
import java.util.jar.JarFile;
|
|
|
|
import ru.gravit.utils.helper.LogHelper;
|
|
|
|
@LauncherAPI
|
|
public class LauncherAgent {
|
|
private static boolean isAgentStarted = false;
|
|
public static Instrumentation inst;
|
|
|
|
public static void addJVMClassPath(String path) throws IOException {
|
|
LogHelper.debug("Launcher Agent addJVMClassPath");
|
|
inst.appendToSystemClassLoaderSearch(new JarFile(path));
|
|
}
|
|
|
|
public boolean isAgentStarted() {
|
|
return isAgentStarted;
|
|
}
|
|
|
|
public static long getObjSize(Object obj) {
|
|
return inst.getObjectSize(obj);
|
|
}
|
|
|
|
public static void premain(String agentArgument, Instrumentation instrumentation) {
|
|
System.out.println("Launcher Agent");
|
|
inst = instrumentation;
|
|
isAgentStarted = true;
|
|
}
|
|
|
|
public static boolean isStarted() {
|
|
return isAgentStarted;
|
|
}
|
|
}
|