mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 00:11:22 +00:00
AS3 PCode serach
This commit is contained in:
@@ -26,14 +26,34 @@ public class ABCSearchResult {
|
||||
|
||||
private final ScriptPack scriptPack;
|
||||
|
||||
private final int classIndex;
|
||||
|
||||
private final int methodIndex;
|
||||
|
||||
public ABCSearchResult(ScriptPack scriptPack) {
|
||||
this.scriptPack = scriptPack;
|
||||
classIndex = 0;
|
||||
methodIndex = 0;
|
||||
}
|
||||
|
||||
public ABCSearchResult(ScriptPack scriptPack, int classIndex, int methodIndex) {
|
||||
this.scriptPack = scriptPack;
|
||||
this.classIndex = classIndex;
|
||||
this.methodIndex = methodIndex;
|
||||
}
|
||||
|
||||
public ScriptPack getScriptPack() {
|
||||
return scriptPack;
|
||||
}
|
||||
|
||||
public int getClassIndex() {
|
||||
return classIndex;
|
||||
}
|
||||
|
||||
public int getMethodIndex() {
|
||||
return methodIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return scriptPack.getClassPath().toString();
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package com.jpexs.decompiler.flash.search;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.cache.ScriptDecompiledListener;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
@@ -55,7 +57,10 @@ public class ActionScriptSearch {
|
||||
ASMSource asm = item.getValue();
|
||||
|
||||
if (pcode) {
|
||||
//Main.startWork(workText + " \"" + txt + "\" - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
|
||||
if (listener != null) {
|
||||
listener.onSearch(pos, asms.size(), item.getKey());
|
||||
}
|
||||
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
asm.getASMSource(ScriptExportMode.PCODE, writer, null);
|
||||
String text = writer.toString();
|
||||
@@ -137,29 +142,53 @@ public class ActionScriptSearch {
|
||||
}
|
||||
}
|
||||
|
||||
int fpos = pos;
|
||||
Future<HighlightedText> text = SWF.getCachedFuture(pack, new ScriptDecompiledListener<HighlightedText>() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (listener != null) {
|
||||
listener.onDecompile(fpos, allpacks.size(), pack.getClassPath().toString());
|
||||
}
|
||||
if (pcode) {
|
||||
if (listener != null) {
|
||||
listener.onSearch(pos, allpacks.size(), pack.getClassPath().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(HighlightedText result) {
|
||||
if (listener != null) {
|
||||
listener.onSearch(fpos, allpacks.size(), pack.getClassPath().toString());
|
||||
}
|
||||
List<MethodId> methodInfos = new ArrayList<>();
|
||||
pack.getMethodInfos(methodInfos);
|
||||
|
||||
if (pat.matcher(result.text).find()) {
|
||||
ABCSearchResult searchResult = new ABCSearchResult(pack);
|
||||
found.add(searchResult);
|
||||
ABC abc = pack.abc;
|
||||
for (MethodId methodInfo : methodInfos) {
|
||||
int bodyIndex = abc.findBodyIndex(methodInfo.getMethodIndex());
|
||||
if (bodyIndex != -1) {
|
||||
MethodBody body = abc.bodies.get(bodyIndex);
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
abc.bodies.get(bodyIndex).getCode().toASMSource(abc.constants, abc.method_info.get(body.method_info), body, ScriptExportMode.PCODE, writer);
|
||||
String text = writer.toString();
|
||||
if (pat.matcher(text).find()) {
|
||||
ABCSearchResult searchResult = new ABCSearchResult(pack, methodInfo.getClassIndex(), methodInfo.getMethodIndex());
|
||||
found.add(searchResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
int fpos = pos;
|
||||
Future<HighlightedText> text = SWF.getCachedFuture(pack, new ScriptDecompiledListener<HighlightedText>() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (listener != null) {
|
||||
listener.onDecompile(fpos, allpacks.size(), pack.getClassPath().toString());
|
||||
}
|
||||
}
|
||||
|
||||
futures.add(text);
|
||||
@Override
|
||||
public void onComplete(HighlightedText result) {
|
||||
if (listener != null) {
|
||||
listener.onSearch(fpos, allpacks.size(), pack.getClassPath().toString());
|
||||
}
|
||||
|
||||
if (pat.matcher(result.text).find()) {
|
||||
ABCSearchResult searchResult = new ABCSearchResult(pack);
|
||||
found.add(searchResult);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
futures.add(text);
|
||||
}
|
||||
}
|
||||
|
||||
for (Future<HighlightedText> future : futures) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2016 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.search;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class MethodId {
|
||||
|
||||
private final int classIndex;
|
||||
|
||||
private final int methodIndex;
|
||||
|
||||
public MethodId(int classIndex, int methodIndex) {
|
||||
this.classIndex = classIndex;
|
||||
this.methodIndex = methodIndex;
|
||||
}
|
||||
|
||||
public int getClassIndex() {
|
||||
return classIndex;
|
||||
}
|
||||
|
||||
public int getMethodIndex() {
|
||||
return methodIndex;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user