This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
255 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
[versions] | ||
picocli = "4.7.6" | ||
teavm = "0.10.0" | ||
|
||
[libraries] | ||
jspecify = { group = "org.jspecify", name = "jspecify", version = "0.3.0" } | ||
picocli = { group = "info.picocli", name = "picocli", version.ref = "picocli" } | ||
picocli-codegen = { group = "info.picocli", name = "picocli-codegen", version.ref = "picocli" } | ||
proguard = { group = "com.github.run-slicer", name = "proguard", version = "82ace0a065" } | ||
teavm-core = { group = "org.teavm", name = "teavm-core", version.ref = "teavm" } | ||
|
||
[plugins] | ||
shadow = { id = "com.gradleup.shadow", version = "8.3.0" } | ||
blossom = { id = "net.kyori.blossom", version = "2.1.0" } | ||
teavm = { id = "org.teavm", version.ref = "teavm" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
plugins { | ||
id("poke.base-conventions") | ||
alias(libs.plugins.teavm) | ||
} | ||
|
||
dependencies { | ||
implementation(project(":${rootProject.name}-core")) | ||
compileOnly(libs.teavm.core) | ||
} | ||
|
||
teavm.js { | ||
mainClass = "run.slicer.poke.js.Main" | ||
moduleType = org.teavm.gradle.api.JSModuleType.ES2015 | ||
// obfuscated = false | ||
// optimization = org.teavm.gradle.api.OptimizationLevel.NONE | ||
} | ||
|
||
tasks { | ||
register<Copy>("copyDist") { | ||
group = "build" | ||
|
||
from("../README.md", "../LICENSE", generateJavaScript, "poke.d.ts") | ||
into("dist") | ||
|
||
doLast { | ||
file("dist/package.json").writeText( | ||
""" | ||
{ | ||
"name": "@run-slicer/poke", | ||
"version": "${project.version}", | ||
"description": "A library for performing Java bytecode normalization and generic deobfuscation.", | ||
"main": "poke-js.js", | ||
"types": "poke.d.ts", | ||
"keywords": [ | ||
"deobfuscation", | ||
"java", | ||
"bytecode", | ||
"optimization" | ||
], | ||
"author": "run-slicer", | ||
"license": "GPL-2.0-only" | ||
} | ||
""".trimIndent() | ||
) | ||
} | ||
} | ||
|
||
build { | ||
dependsOn("copyDist") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare module "@run-slicer/poke" { | ||
export interface Config { | ||
passes?: number; | ||
optimize?: boolean; | ||
verify?: boolean; | ||
} | ||
|
||
export function analyze(data: Uint8Array, config?: Config): Uint8Array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package run.slicer.poke.js; | ||
|
||
import org.teavm.jso.JSByRef; | ||
import org.teavm.jso.JSExport; | ||
import org.teavm.jso.core.JSObjects; | ||
import run.slicer.poke.Analyzer; | ||
|
||
public class Main { | ||
@JSExport | ||
public static @JSByRef byte[] analyze(@JSByRef byte[] data, Options options) { | ||
return analyze0(data, options == null || JSObjects.isUndefined(options) ? JSObjects.create() : options); | ||
} | ||
|
||
private static byte[] analyze0(byte[] data, Options options) { | ||
final Analyzer analyzer = Analyzer.builder() | ||
.passes(options.passes()) | ||
.optimize(options.optimize()) | ||
.verify(options.verify()) | ||
.build(); | ||
|
||
return analyzer.analyze(data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package run.slicer.poke.js; | ||
|
||
import org.teavm.jso.JSBody; | ||
import org.teavm.jso.JSObject; | ||
|
||
public interface Options extends JSObject { | ||
@JSBody(script = "return this.passes || 0;") | ||
int passes(); | ||
|
||
@JSBody(script = "return Boolean(this.optimize);") | ||
boolean optimize(); | ||
|
||
@JSBody(script = "return Boolean(this.verify);") | ||
boolean verify(); | ||
} |
122 changes: 122 additions & 0 deletions
122
...avm/java/run/slicer/poke/js/teavm/classlib/java/util/concurrent/DummyExecutorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package run.slicer.poke.js.teavm.classlib.java.util.concurrent; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.concurrent.*; | ||
|
||
final class DummyExecutorService implements ExecutorService { | ||
private boolean shutdown = false; | ||
|
||
@Override | ||
public void shutdown() { | ||
this.shutdown = true; | ||
} | ||
|
||
@Override | ||
public List<Runnable> shutdownNow() { | ||
this.shutdown = true; | ||
return List.of(); | ||
} | ||
|
||
@Override | ||
public boolean isShutdown() { | ||
return this.shutdown; | ||
} | ||
|
||
@Override | ||
public boolean isTerminated() { | ||
return this.shutdown; | ||
} | ||
|
||
@Override | ||
public boolean awaitTermination(long timeout, TimeUnit unit) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public <T> Future<T> submit(Callable<T> task) { | ||
try { | ||
return new Task<>(task.call(), null); | ||
} catch (Throwable t) { | ||
return new Task<>(null, t); | ||
} | ||
} | ||
|
||
@Override | ||
public <T> Future<T> submit(Runnable task, T result) { | ||
try { | ||
task.run(); | ||
} catch (Throwable t) { | ||
return new Task<>(null, t); | ||
} | ||
|
||
return new Task<>(result, null); | ||
} | ||
|
||
@Override | ||
public Future<?> submit(Runnable task) { | ||
try { | ||
task.run(); | ||
} catch (Throwable t) { | ||
return new Task<>(null, t); | ||
} | ||
|
||
return new Task<>(null, null); | ||
} | ||
|
||
@Override | ||
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void execute(Runnable command) { | ||
command.run(); | ||
} | ||
|
||
private record Task<T>(T value, Throwable error) implements Future<T> { | ||
@Override | ||
public boolean cancel(boolean mayInterruptIfRunning) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isDone() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public T get() throws ExecutionException { | ||
if (this.error != null) { | ||
throw new ExecutionException(this.error); | ||
} | ||
|
||
return this.value; | ||
} | ||
|
||
@Override | ||
public T get(long timeout, TimeUnit unit) throws ExecutionException { | ||
return this.get(); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...c/teavm/java/run/slicer/poke/js/teavm/classlib/java/util/concurrent/TExecutorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package run.slicer.poke.js.teavm.classlib.java.util.concurrent; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
public interface TExecutorService extends Executor { | ||
TFuture<?> submit(Runnable task); | ||
|
||
void shutdown(); | ||
} |
10 changes: 10 additions & 0 deletions
10
js/src/teavm/java/run/slicer/poke/js/teavm/classlib/java/util/concurrent/TExecutors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package run.slicer.poke.js.teavm.classlib.java.util.concurrent; | ||
|
||
import java.util.concurrent.ThreadFactory; | ||
|
||
public class TExecutors { | ||
@SuppressWarnings("DataFlowIssue") | ||
public static TExecutorService newFixedThreadPool(int ignored0, ThreadFactory ignored1) { | ||
return (TExecutorService) ((Object) new DummyExecutorService()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
js/src/teavm/java/run/slicer/poke/js/teavm/classlib/java/util/concurrent/TFuture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package run.slicer.poke.js.teavm.classlib.java.util.concurrent; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
|
||
public interface TFuture<V> { | ||
V get() throws InterruptedException, ExecutionException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mapClass|run.slicer.poke.js.teavm.classlib.java.util.concurrent.TExecutors=java.util.concurrent.Executors | ||
mapClass|run.slicer.poke.js.teavm.classlib.java.util.concurrent.TExecutorService=java.util.concurrent.ExecutorService | ||
mapClass|run.slicer.poke.js.teavm.classlib.java.util.concurrent.TFuture=java.util.concurrent.Future |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters