mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-01 15:44:19 +00:00
Added #1718 Show progress on injecting debug info / SWD generation (before Debugging)
This commit is contained in:
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Display object depth in flash panel
|
||||
- Show imported files on script import, able to cancel import
|
||||
- [#270] AS3 show progress on deofuscating p-code
|
||||
- [#1718] Show progress on injecting debug info / SWD generation (before Debugging)
|
||||
|
||||
### Fixed
|
||||
- [#1761] AS3 - try..finally inside another structure like if
|
||||
@@ -2332,6 +2333,7 @@ All notable changes to this project will be documented in this file.
|
||||
[alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8
|
||||
[alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7
|
||||
[#270]: https://www.free-decompiler.com/flash/issues/270
|
||||
[#1718]: https://www.free-decompiler.com/flash/issues/1718
|
||||
[#1761]: https://www.free-decompiler.com/flash/issues/1761
|
||||
[#1762]: https://www.free-decompiler.com/flash/issues/1762
|
||||
[#1763]: https://www.free-decompiler.com/flash/issues/1763
|
||||
|
||||
@@ -3386,14 +3386,14 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @param decompileDir Directory to virtual decompile (will affect
|
||||
* debugfile)
|
||||
*/
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir) {
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir) throws InterruptedException {
|
||||
enableDebugging(injectAS3Code, decompileDir, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables debugging. Adds tags to enable debugging.
|
||||
*/
|
||||
public void enableDebugging() {
|
||||
public void enableDebugging() throws InterruptedException {
|
||||
enableDebugging(false, null, false);
|
||||
}
|
||||
|
||||
@@ -3406,7 +3406,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* debugfile)
|
||||
* @param telemetry Enable telemetry info?
|
||||
*/
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry) {
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry) throws InterruptedException {
|
||||
enableDebugging(injectAS3Code, decompileDir, telemetry, false);
|
||||
}
|
||||
|
||||
@@ -3414,9 +3414,15 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* Injects debugline and debugfile instructions to AS3 P-code (lines of
|
||||
* P-code)
|
||||
*/
|
||||
public void injectAS3PcodeDebugInfo() {
|
||||
public void injectAS3PcodeDebugInfo() throws InterruptedException {
|
||||
List<ScriptPack> packs = getAS3Packs();
|
||||
int i = 0;
|
||||
for (ScriptPack s : packs) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
i++;
|
||||
informListeners("inject_debuginfo", "" + i + "/" + packs.size() + ": " + s.getPath());
|
||||
int abcIndex = s.allABCs.indexOf(s.abc);
|
||||
if (s.isSimple) {
|
||||
s.injectPCodeDebugInfo(abcIndex);
|
||||
@@ -3429,9 +3435,15 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
*
|
||||
* @param decompileDir Directory to set file information paths
|
||||
*/
|
||||
public void injectAS3DebugInfo(File decompileDir) {
|
||||
public void injectAS3DebugInfo(File decompileDir) throws InterruptedException {
|
||||
List<ScriptPack> packs = getAS3Packs();
|
||||
int i = 0;
|
||||
for (ScriptPack s : packs) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
i++;
|
||||
informListeners("inject_debuginfo", "" + i + "/" + packs.size() + ": " + s.getPath());
|
||||
if (s.isSimple) {
|
||||
s.injectDebugInfo(decompileDir);
|
||||
}
|
||||
@@ -3448,7 +3460,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @param telemetry Enable telemetry info?
|
||||
* @param pcodeLevel inject Pcode lines instead of decompiled lines
|
||||
*/
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry, boolean pcodeLevel) {
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry, boolean pcodeLevel) throws InterruptedException {
|
||||
|
||||
if (injectAS3Code) {
|
||||
if (pcodeLevel) {
|
||||
@@ -3532,7 +3544,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return r;
|
||||
}
|
||||
|
||||
public boolean generatePCodeSwdFile(File file, Map<String, Set<Integer>> breakpoints) throws IOException {
|
||||
public boolean generatePCodeSwdFile(File file, Map<String, Set<Integer>> breakpoints) throws IOException, InterruptedException {
|
||||
DebugIDTag dit = getDebugId();
|
||||
if (dit == null) {
|
||||
return false;
|
||||
@@ -3552,6 +3564,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
List<String> names = new ArrayList<>(asms.keySet());
|
||||
Collections.sort(names);
|
||||
for (String name : names) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
informListeners("generate_swd", name);
|
||||
moduleId++;
|
||||
String sname = "#PCODE " + name;
|
||||
int bitmap = SWD.bitmapAction;
|
||||
@@ -3623,6 +3639,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
List<String> names = new ArrayList<>(asms.keySet());
|
||||
Collections.sort(names);
|
||||
for (String name : names) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
informListeners("generate_swd", name);
|
||||
List<SWD.DebugRegisters> regitems = new ArrayList<>();
|
||||
moduleId++;
|
||||
HighlightedText cs;
|
||||
|
||||
@@ -198,6 +198,7 @@ public class Main {
|
||||
|
||||
public static CancellableWorker importWorker = null;
|
||||
public static CancellableWorker deobfuscatePCodeWorker = null;
|
||||
public static CancellableWorker swfPrepareWorker = null;
|
||||
|
||||
//This method makes file watcher to shut up during our own file saving
|
||||
public static void startSaving(File savedFile) {
|
||||
@@ -375,13 +376,13 @@ public class Main {
|
||||
|
||||
private static interface SwfPreparation {
|
||||
|
||||
public SWF prepare(SWF swf);
|
||||
public SWF prepare(SWF swf) throws InterruptedException;
|
||||
}
|
||||
|
||||
private static class SwfRunPrepare implements SwfPreparation {
|
||||
|
||||
@Override
|
||||
public SWF prepare(SWF swf) {
|
||||
public SWF prepare(SWF swf) throws InterruptedException {
|
||||
if (Configuration.autoOpenLoadedSWFs.get()) {
|
||||
if (!DebuggerTools.hasDebugger(swf)) {
|
||||
DebuggerTools.switchDebugger(swf);
|
||||
@@ -401,8 +402,26 @@ public class Main {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF prepare(SWF instrSWF) {
|
||||
public SWF prepare(SWF instrSWF) throws InterruptedException {
|
||||
instrSWF = super.prepare(instrSWF);
|
||||
|
||||
EventListener prepEventListner = new EventListener() {
|
||||
@Override
|
||||
public void handleExportingEvent(String type, int index, int count, Object data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleExportedEvent(String type, int index, int count, Object data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(String event, Object data) {
|
||||
if (event.equals("inject_debuginfo")) {
|
||||
startWork(AppStrings.translate("work.injecting_debuginfo") + "..." + (String) data, swfPrepareWorker);
|
||||
}
|
||||
}
|
||||
};
|
||||
instrSWF.addEventListener(prepEventListner);
|
||||
try {
|
||||
File fTempFile = new File(instrSWF.getFile());
|
||||
instrSWF.enableDebugging(true, new File("."), true, doPCode);
|
||||
@@ -426,6 +445,22 @@ public class Main {
|
||||
swfFileName = swfFileName + ".swd";
|
||||
}
|
||||
File swdFile = new File(swfFileName);
|
||||
instrSWF.addEventListener(new EventListener() {
|
||||
@Override
|
||||
public void handleExportingEvent(String type, int index, int count, Object data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleExportedEvent(String type, int index, int count, Object data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(String event, Object data) {
|
||||
if (event.equals("generate_swd")) {
|
||||
startWork(AppStrings.translate("work.generating_swd") + "..." + (String) data, swfPrepareWorker);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (doPCode) {
|
||||
instrSWF.generatePCodeSwdFile(swdFile, getPackBreakPoints(true));
|
||||
} else {
|
||||
@@ -436,11 +471,12 @@ public class Main {
|
||||
} catch (IOException ex) {
|
||||
//ignore, return instrSWF
|
||||
}
|
||||
instrSWF.removeEventListener(prepEventListner);
|
||||
return instrSWF;
|
||||
}
|
||||
}
|
||||
|
||||
private static void prepareSwf(SwfPreparation prep, File toPrepareFile, File origFile, List<File> tempFiles) throws IOException {
|
||||
private static void prepareSwf(SwfPreparation prep, File toPrepareFile, File origFile, List<File> tempFiles) throws IOException, InterruptedException {
|
||||
SWF instrSWF = null;
|
||||
try (FileInputStream fis = new FileInputStream(toPrepareFile)) {
|
||||
instrSWF = new SWF(fis, toPrepareFile.getAbsolutePath(), origFile == null ? "unknown.swf" : origFile.getName(), false);
|
||||
@@ -520,7 +556,8 @@ public class Main {
|
||||
|
||||
} catch (IOException ex) {
|
||||
return;
|
||||
|
||||
} catch (InterruptedException ex) {
|
||||
return;
|
||||
}
|
||||
if (tempFile != null) {
|
||||
synchronized (Main.class) {
|
||||
@@ -570,6 +607,12 @@ public class Main {
|
||||
Main.stopWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
swfPrepareWorker = this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
synchronized (Main.class) {
|
||||
|
||||
@@ -852,4 +852,7 @@ imagePanel.depth = depth:
|
||||
|
||||
work.importing_as = Importing script
|
||||
importing_as.finishedin = Imported in %time%
|
||||
work.deobfuscating_pcode = Deobfuscating pcode
|
||||
work.deobfuscating_pcode = Deobfuscating pcode
|
||||
|
||||
work.injecting_debuginfo = Injecting debug info
|
||||
work.generating_swd = Generating SWD file
|
||||
@@ -828,4 +828,7 @@ imagePanel.depth = hloubka:
|
||||
|
||||
work.importing_as = Importuji skript
|
||||
importing_as.finishedin = Importov\u00e1no za %time%
|
||||
work.deobfuscating_pcode = Deobfuskov\u00e1n\u00ed p-k\u00f3du
|
||||
work.deobfuscating_pcode = Deobfuskov\u00e1n\u00ed p-k\u00f3du
|
||||
|
||||
work.injecting_debuginfo = Injektuji lad\u00edc\u00ed informace
|
||||
work.generating_swd = Generaruji SWD soubor
|
||||
Reference in New Issue
Block a user