Add the current files and make a README.md for those who are not coming from the tutorial or want to build this themselves

This commit is contained in:
X3F200C 2023-10-17 07:51:05 -04:00
parent ccc000ffb9
commit fcd281f792
5 changed files with 138 additions and 1 deletions

View File

@ -1,3 +1,19 @@
# PalaLauncher4Linux
A live patcher for Paladium Games launcher to allow launching games on Linux
A live patcher for Paladium Games launcher to allow launching games on Linux
## Compiling
Compiling should be easy and done automatically on any IDE that uses `pom.xml` files.
In my case, I use Pulsar (Atom's continuation) with its `ide-java` package and it works well.
Just don't forget to compile for Java 8 for better compatibility with the launcher.
## Packaging
This is pretty straightforward, just make a `.jar` file with the contents of the `target/classes` folder and add the contents of a [Javassist .jar](https://github.com/jboss-javassist/javassist/releases) into the .jar previously made.
## Using
Simple, just add `-javaagent:path/to/the/built.jar` before `.jar` when you start the launcher located in the `~/paladium-games` folder.
Also be sure to use Java 8 for better compatibility.

35
pom.xml Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>net.x3f200c.pala4linux.launcherpatch</groupId>
<artifactId>PalaLauncher4Linux</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
<dependencies>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.29.2-GA</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,37 @@
package net.x3f200c.pala4linux.launcherpatch;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import java.lang.Class;
import java.lang.String;
import net.x3f200c.pala4linux.launcherpatch.LauncherPatcher;
public class LauncherPatch {
public static void premain(String agentArgs, Instrumentation inst) {
patch(inst);
}
public static void agentmain(String agentArgs, Instrumentation inst) {
patch(inst);
}
public static void patch(Instrumentation inst) {
Class<?> routeHandlerClass = null;
ClassLoader routeHandlerClassLoader = null;
try {
routeHandlerClass = Class.forName("fr.paladium.router.route.common.CommonRoute");
routeHandlerClassLoader = routeHandlerClass.getClassLoader();
} catch(ClassNotFoundException e) {
}
LauncherPatcher dt = new LauncherPatcher(routeHandlerClass.getName(), routeHandlerClassLoader);
inst.addTransformer(dt, true);
try {
inst.retransformClasses(routeHandlerClass);
} catch(UnmodifiableClassException e) {
}
}
}

View File

@ -0,0 +1,45 @@
package net.x3f200c.pala4linux.launcherpatch;
import java.lang.instrument.ClassFileTransformer;
import java.io.IOException;
import java.security.ProtectionDomain;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.NotFoundException;
import javassist.CannotCompileException;
class LauncherPatcher implements ClassFileTransformer {
private final String targetClassName;
public LauncherPatcher(String className, ClassLoader classLoader) {
this.targetClassName = className;
}
@Override
public byte[] transform(ClassLoader loader, String className, Class<?> redefinedClass, ProtectionDomain protectionDomain, byte[] classBuffer) {
byte[] bytecode = classBuffer;
String finalTargetClassName = this.targetClassName.replaceAll("\\.", "/");
if (!className.equals(finalTargetClassName)) {
return bytecode;
}
if (className.equals(finalTargetClassName)) {
try {
ClassPool cp = ClassPool.getDefault();
CtClass crClass = cp.get("fr.paladium.router.route.common.CommonRoute");
CtMethod osGetterMethod = crClass.getDeclaredMethod("handleGetOS");
osGetterMethod.setBody("{ return fr.paladium.router.handler.CefRouteHandler.create().success(\"os\", \"windows\"); }");
bytecode = crClass.toBytecode();
crClass.detach();
} catch(NotFoundException | CannotCompileException | IOException e) {
}
}
return bytecode;
}
}

View File

@ -0,0 +1,4 @@
Agent-Class: net.x3f200c.pala4linux.launcherpatch.LauncherPatch
Can-Redefine-Classes: true
Can-Retransform-Classes: true
Premain-Class: net.x3f200c.pala4linux.launcherpatch.LauncherPatch