入口
d.g.c.o.g.a.doExecution
// // Decompiled by Jadx - 784ms // package d.g.c.o.g; import android.content.Context; import com.stardust.autojs.engine.LoopBasedJavaScriptEngine; import com.stardust.autojs.engine.encryption.ScriptEncryption; import com.stardust.autojs.script.JavaScriptFileSource; import com.stardust.autojs.script.JavaScriptSource; import com.stardust.autojs.script.StringScriptSource; import com.stardust.pio.PFiles; import d.b.b.h.f; import d.g.c.s.a; import h.d; import h.q.c.j; import java.io.ByteArrayInputStream; import java.io.File; import java.security.GeneralSecurityException; import java.util.Map; import java.util.Objects; import org.mozilla.javascript.CompileContext; import org.mozilla.javascript.Script; public final class a extends LoopBasedJavaScriptEngine { public final File a; /* * JADX INFO: super call moved to the top of the method (can break code * semantics) */ public a(Context context, File file, Map<String, ? extends Object> map) { super(context, map); j.e(context, "context"); j.e(file, "projectDir"); j.e(map, "engineArgs"); j.e(context, "context"); j.e(map, "engineArgs"); this.a = file; } /* * JADX WARNING: Code restructure failed: missing block: B:36:0x0099, code lost: * r1 = move-exception; */ /* * JADX WARNING: Code restructure failed: missing block: B:37:0x009a, code lost: * d.b.b.h.f.u(r11, r0); */ /* * JADX WARNING: Code restructure failed: missing block: B:38:0x009d, code lost: * throw r1; */ /* JADX WARNING: Removed duplicated region for block: B:17:0x0050 */ /* * JADX WARNING: Removed duplicated region for block: B:19:0x0055 A[SYNTHETIC, * Splitter:B:19:0x0055] */ private Object b(JavaScriptSource javaScriptSource) { a.a aVar; j.e(javaScriptSource, "source"); if (!(javaScriptSource instanceof JavaScriptFileSource)) { return a.super.doExecution(javaScriptSource); } JavaScriptFileSource javaScriptFileSource = (JavaScriptFileSource) javaScriptSource; byte[] readBytes = PFiles.readBytes(javaScriptFileSource.g.getPath()); j.d(readBytes, "bytes"); j.e(readBytes, "bytes"); int length = readBytes.length; byte[] bArr = d.g.c.s.a.a; if (length >= bArr.length + 1) { int i = 0; int length2 = bArr.length; while (true) { if (i >= length2) { byte b = readBytes[d.g.c.s.a.a.length]; a.a aVar2 = a.a.d; if (b != 18) { aVar2 = a.a.e; if (b != 19) { aVar2 = null; } } aVar = aVar2; } else if (readBytes[i] != d.g.c.s.a.a[i]) { break; } else { i++; } } if (aVar != null) { return a.super.doExecution(javaScriptSource); } try { byte[] decrypt$default = ScriptEncryption.Companion.decrypt$default(ScriptEncryption.Companion, readBytes, 8, 0, 4, (Object) null); int ordinal = aVar.ordinal(); if (ordinal == 0) { String name = javaScriptFileSource.g.getName(); j.d(name, "source.file.name"); return a.super.execute(new StringScriptSource(name, new String(decrypt$default, h.v.a.a))); } else if (ordinal == 1) { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decrypt$default); j.e(byteArrayInputStream, "inputStream"); b bVar = new b(byteArrayInputStream); Object readObject = bVar.readObject(); if (readObject != null) { Script script = (Script) readObject; f.u(bVar, (Throwable) null); return script.exec(getContext(), getScriptable()); } throw new NullPointerException("null cannot be cast to non-null type org.mozilla.javascript.Script"); } else { throw new d(); } } catch (GeneralSecurityException e) { e.printStackTrace(); return a.super.doExecution(javaScriptSource); } } aVar = null; if (aVar != null) { } } public Object doExecution(JavaScriptSource javaScriptSource) { j.e(javaScriptSource, "source"); if (!(javaScriptSource instanceof JavaScriptFileSource)) { return b(javaScriptSource); } try { Class<?> cls = Class .forName(CompileContext.Companion.generateClassName(this.a, ((JavaScriptFileSource) javaScriptSource).g)); j.d(cls, "Class.forName(className)"); Script newInstance = cls.newInstance(); Objects.requireNonNull(newInstance, "null cannot be cast to non-null type org.mozilla.javascript.Script"); return newInstance.exec(getContext(), getScriptable()); } catch (Exception unused) { return b(javaScriptSource); } } }
构造函数
public a(Context context, File file, Map<String, ? extends Object> map) {
三个参数依次为
com.stardust.autojs.inrt.App@bbdd4e1 /data/user/0/com.example.script1631687221234/files/project "<instance: java.util.Map, $className: h.m.g>"
构造函数堆栈
d.g.c.o.g.a.<init>(Native Method) d.g.c.o.h.d$a.createEngine(:5) com.stardust.autojs.engine.ScriptEngineManager.createEngine() com.stardust.autojs.engine.ScriptEngineManager.createEngineOfSource() com.stardust.autojs.engine.ScriptEngineManager.createEngineOfSourceOrThrow() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.run() java.lang.Thread.run(Thread.java:761)
doExecution
public Object doExecution(JavaScriptSource javaScriptSource) {
参数javaScriptSource
main.js
doExecution堆栈
d.g.c.o.g.a.doExecution(Native Method) com.stardust.autojs.engine.JavaScriptEngine.execute() com.stardust.autojs.engine.LoopBasedJavaScriptEngine.access$001() d.g.c.n.c.run(:2) android.os.Handler.handleCallback(Handler.java:751) android.os.Handler.dispatchMessage(Handler.java:95) android.os.Looper.loop(Looper.java:154) com.stardust.autojs.engine.LoopBasedJavaScriptEngine.execute() com.stardust.autojs.engine.LoopBasedJavaScriptEngine.execute() com.stardust.autojs.execution.LoopedBasedJavaScriptExecution.doExecution() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.run() java.lang.Thread.run(Thread.java:761)
CompileContext.Companion.generateClassName方法
// org.mozilla.javascript.CompileContext$Companion Class<?> cls = Class.forName(CompileContext.Companion.generateClassName(this.a, ((JavaScriptFileSource) javaScriptSource).g));
generateClassName参数和返回值
return newInstance.exec(getContext(), getScriptable());
newInstance.exec参数
<instance: org.mozilla.javascript.Context, $className: d.g.c.q.c>" "<instance: org.mozilla.javascript.Scriptable, $className: d.g.c.q.i>
newInstance.exec堆栈
org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e.exec(Native Method) d.g.c.o.g.a.doExecution(:2) com.stardust.autojs.engine.JavaScriptEngine.execute() com.stardust.autojs.engine.LoopBasedJavaScriptEngine.access$001() d.g.c.n.c.run(:2) android.os.Handler.handleCallback(Handler.java:751) android.os.Handler.dispatchMessage(Handler.java:95) android.os.Looper.loop(Looper.java:154) com.stardust.autojs.engine.LoopBasedJavaScriptEngine.execute() com.stardust.autojs.engine.LoopBasedJavaScriptEngine.execute() com.stardust.autojs.execution.LoopedBasedJavaScriptExecution.doExecution() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.run() java.lang.Thread.run(Thread.java:761)
org.mozilla.javascript.Interface Scriptable官网说明
org.mozilla.javascript.ScriptRuntime
参数
"<instance: org.mozilla.javascript.Callable, $className: org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e>" "<instance: org.mozilla.javascript.Context, $className: d.g.c.q.c>" "<instance: org.mozilla.javascript.Scriptable, $className: d.g.c.q.i>" "<instance: org.mozilla.javascript.Scriptable, $className: d.g.c.q.i>" null false
返回值
org.mozilla.javascript.Undefined@0
堆栈
org.mozilla.javascript.ScriptRuntime.doTopCall(Native Method) org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e.call() org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e.exec() d.g.c.o.g.a.doExecution(:2) com.stardust.autojs.engine.JavaScriptEngine.execute() com.stardust.autojs.engine.LoopBasedJavaScriptEngine.access$001() d.g.c.n.c.run(:2) android.os.Handler.handleCallback(Handler.java:751) android.os.Handler.dispatchMessage(Handler.java:95) android.os.Looper.loop(Looper.java:154) com.stardust.autojs.engine.LoopBasedJavaScriptEngine.execute() com.stardust.autojs.engine.LoopBasedJavaScriptEngine.execute() com.stardust.autojs.execution.LoopedBasedJavaScriptExecution.doExecution() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.run() java.lang.Thread.run(Thread.java:761)
org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e
参数
"<instance: org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e>" "<instance: org.mozilla.javascript.Context, $className: d.g.c.q.c>" "<instance: org.mozilla.javascript.Scriptable, $className: d.g.c.q.i>" "<instance: org.mozilla.javascript.Scriptable, $className: d.g.c.q.i>" null
返回值
org.mozilla.javascript.Undefined@0
堆栈
org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e._c_script_0(Native Method) org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e.call() org.mozilla.javascript.ContextFactory.doTopCall() org.mozilla.javascript.ScriptRuntime.doTopCall() org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e.call() org.autojs.autojspro.gen._7a9076d6d94e62c13d641aa71f19ae8e.exec() d.g.c.o.g.a.doExecution(:2) com.stardust.autojs.engine.JavaScriptEngine.execute() com.stardust.autojs.engine.LoopBasedJavaScriptEngine.access$001() d.g.c.n.c.run(:2) android.os.Handler.handleCallback(Handler.java:751) android.os.Handler.dispatchMessage(Handler.java:95) android.os.Looper.loop(Looper.java:154) com.stardust.autojs.engine.LoopBasedJavaScriptEngine.execute() com.stardust.autojs.engine.LoopBasedJavaScriptEngine.execute() com.stardust.autojs.execution.LoopedBasedJavaScriptExecution.doExecution() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.execute() com.stardust.autojs.execution.RunnableScriptExecution.run() java.lang.Thread.run(Thread.java:761)
org.mozilla.javascript.ScriptRuntime
setName
引用自mozilla官网
public static java.lang.Object setName(Scriptable bound, java.lang.Object value, Context cx, Scriptable scope, java.lang.String id)
callName
引用自mozilla官网
public static java.lang.Object callName(java.lang.Object[] args, java.lang.String name, Context cx, Scriptable scope) Implement name(args) call shrinking optimizer code.
未完待续