mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE][EXPERIMENTAL] Проверка Stacktrace в агента
This commit is contained in:
parent
efd58d66c7
commit
8e1000ec41
1 changed files with 26 additions and 11 deletions
|
@ -32,18 +32,33 @@ public boolean isAgentStarted() {
|
|||
|
||||
public static void premain(String agentArgument, Instrumentation instrumentation) {
|
||||
System.out.println("Launcher Agent");
|
||||
checkAgentStacktrace();
|
||||
inst = instrumentation;
|
||||
SafeExitJVMLegacy.class.getName();
|
||||
SafeExitJVM.class.getName();
|
||||
NativeJVMHalt.class.getName();
|
||||
NativeJVMHalt.initFunc();
|
||||
boolean bad = false;
|
||||
try {
|
||||
for (StackTraceElement e : new Throwable().getStackTrace())
|
||||
if (Class.forName(e.getClassName()).getClassLoader() != Runtime.class.getClassLoader() && Class.forName(e.getClassName()) != LauncherAgent.class) bad = true;
|
||||
} catch(Throwable e) { bad = true; }
|
||||
if (bad) NativeJVMHalt.haltA(-17);
|
||||
else isAgentStarted = true;
|
||||
//SafeExitJVMLegacy.class.getName();
|
||||
//SafeExitJVM.class.getName();
|
||||
//NativeJVMHalt.class.getName();
|
||||
//NativeJVMHalt.initFunc();
|
||||
isAgentStarted = true;
|
||||
}
|
||||
public static void checkAgentStacktrace()
|
||||
{
|
||||
RuntimeException ex = new SecurityException("Error check agent stacktrace");
|
||||
boolean isFoundNative = false;
|
||||
boolean foundPreMain = false;
|
||||
for(StackTraceElement e : ex.getStackTrace())
|
||||
{
|
||||
if(e.isNativeMethod())
|
||||
{
|
||||
if(!isFoundNative) isFoundNative = true;
|
||||
else throw ex;
|
||||
}
|
||||
if(e.getMethodName().equals("premain"))
|
||||
{
|
||||
if(!foundPreMain) foundPreMain = true;
|
||||
else throw ex;
|
||||
}
|
||||
}
|
||||
if(!isFoundNative || !foundPreMain) throw ex;
|
||||
}
|
||||
|
||||
public static boolean isStarted() {
|
||||
|
|
Loading…
Reference in a new issue