mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-26 01:17:52 -04:00
More cleanup
This commit is contained in:
@@ -3,6 +3,7 @@ package io.xpipe.core.util;
|
||||
import io.xpipe.core.charsetter.NewLine;
|
||||
import io.xpipe.core.process.OsType;
|
||||
import io.xpipe.core.process.ShellTypes;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
@@ -105,6 +106,6 @@ public class Deobfuscator {
|
||||
}
|
||||
|
||||
var t = ShellTypes.getPlatformDefault();
|
||||
return LocalProcess.executeSimpleBooleanCommand(t.getWhichCommand("retrace." + t.getScriptFileEnding()));
|
||||
return ShellStore.local().create().executeBooleanSimpleCommand(t.getWhichCommand("retrace." + t.getScriptFileEnding()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package io.xpipe.core.util;
|
||||
|
||||
import io.xpipe.core.process.ShellTypes;
|
||||
|
||||
public class LocalProcess {
|
||||
|
||||
public static boolean executeSimpleBooleanCommand(String cmd) throws Exception {
|
||||
var proc = new ProcessBuilder(ShellTypes.getPlatformDefault().executeCommandListWithShell(cmd)).redirectErrorStream(true).redirectOutput(
|
||||
ProcessBuilder.Redirect.DISCARD).start();
|
||||
return proc.waitFor() == 0;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package io.xpipe.core.util;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ModuleHelper {
|
||||
|
||||
public static boolean isImage() {
|
||||
@@ -10,4 +15,43 @@ public class ModuleHelper {
|
||||
.getProtocol()
|
||||
.equals("jrt");
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static Module getEveryoneModule() {
|
||||
Method getDeclaredFields0 = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
|
||||
getDeclaredFields0.setAccessible(true);
|
||||
Field[] fields = (Field[]) getDeclaredFields0.invoke(Module.class, false);
|
||||
Field modifiers = null;
|
||||
for (Field each : fields) {
|
||||
if ("EVERYONE_MODULE".equals(each.getName())) {
|
||||
modifiers = each;
|
||||
break;
|
||||
}
|
||||
}
|
||||
modifiers.setAccessible(true);
|
||||
return (Module) modifiers.get(null);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static void exportAndOpen(String pkg, Module mod) {
|
||||
if (mod.isExported(pkg) && mod.isOpen(pkg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Method getDeclaredFields0 = Class.class.getDeclaredMethod("getDeclaredMethods0", boolean.class);
|
||||
getDeclaredFields0.setAccessible(true);
|
||||
Method[] fields = (Method[]) getDeclaredFields0.invoke(Module.class, false);
|
||||
Method modifiers = null;
|
||||
for (Method each : fields) {
|
||||
if ("implAddExportsOrOpens".equals(each.getName())) {
|
||||
modifiers = each;
|
||||
break;
|
||||
}
|
||||
}
|
||||
modifiers.setAccessible(true);
|
||||
|
||||
var e = getEveryoneModule();
|
||||
modifiers.invoke(mod, pkg, e, false, true);
|
||||
modifiers.invoke(mod, pkg, e, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user