mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] OW2 asm.
This commit is contained in:
parent
8e87f55cff
commit
b7673cf134
2 changed files with 5 additions and 5 deletions
|
@ -28,7 +28,7 @@
|
||||||
dependencies {
|
dependencies {
|
||||||
pack project(':LauncherAPI') // Not error on obf.
|
pack project(':LauncherAPI') // Not error on obf.
|
||||||
bundle 'com.github.oshi:oshi-core:3.13.0'
|
bundle 'com.github.oshi:oshi-core:3.13.0'
|
||||||
bundle 'org.ow2.asm:asm-tree:7.1'
|
compileOnly 'org.ow2.asm:asm-all:5.0.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
task genRuntimeJS(type: Zip) {
|
task genRuntimeJS(type: Zip) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation
|
||||||
if (trimmedArg.contains("r")) rt = false;
|
if (trimmedArg.contains("r")) rt = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
replaceClasses(pb, rt);
|
if (rt || pb) replaceClasses(pb, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isStarted() {
|
public static boolean isStarted() {
|
||||||
|
@ -54,7 +54,7 @@ public static boolean isStarted() {
|
||||||
* @author https://github.com/Konloch/JVM-Sandbox
|
* @author https://github.com/Konloch/JVM-Sandbox
|
||||||
* Replaces the Runtime class via instrumentation, transforms the class via ASM
|
* Replaces the Runtime class via instrumentation, transforms the class via ASM
|
||||||
*/
|
*/
|
||||||
public static void replaceClasses(boolean pb, boolean rt) {
|
private static void replaceClasses(boolean pb, boolean rt) {
|
||||||
for(Class<?> c : inst.getAllLoadedClasses()) {
|
for(Class<?> c : inst.getAllLoadedClasses()) {
|
||||||
if(rt && c.getName().equals("java.lang.Runtime")) {
|
if(rt && c.getName().equals("java.lang.Runtime")) {
|
||||||
try {
|
try {
|
||||||
|
@ -84,7 +84,7 @@ public static void replaceClasses(boolean pb, boolean rt) {
|
||||||
* @author https://github.com/Konloch/JVM-Sandbox
|
* @author https://github.com/Konloch/JVM-Sandbox
|
||||||
* Use ASM to modify the byte array
|
* Use ASM to modify the byte array
|
||||||
*/
|
*/
|
||||||
public static byte[] transformClass(String className, byte[] classBytes) {
|
private static byte[] transformClass(String className, byte[] classBytes) {
|
||||||
if (className.equals("java.lang.Runtime")) {
|
if (className.equals("java.lang.Runtime")) {
|
||||||
ClassReader cr=new ClassReader(classBytes);
|
ClassReader cr=new ClassReader(classBytes);
|
||||||
ClassNode cn=new ClassNode();
|
ClassNode cn=new ClassNode();
|
||||||
|
@ -146,7 +146,7 @@ public static byte[] transformClass(String className, byte[] classBytes) {
|
||||||
* @return array, respending this class in bytecode.
|
* @return array, respending this class in bytecode.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static byte[] getClassFile(Class<?> clazz) throws IOException {
|
private static byte[] getClassFile(Class<?> clazz) throws IOException {
|
||||||
InputStream is = clazz.getResourceAsStream( "/" + clazz.getName().replace('.', '/') + ".class");
|
InputStream is = clazz.getResourceAsStream( "/" + clazz.getName().replace('.', '/') + ".class");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
Loading…
Reference in a new issue