diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index c95db01d3..dd41efc38 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -131,6 +131,8 @@ import com.jpexs.helpers.stat.StatisticData; import com.jpexs.helpers.stat.Statistics; import com.jpexs.helpers.streams.SeekableInputStream; import com.jpexs.helpers.utf8.Utf8Helper; +import com.jpexs.process.Process; +import com.jpexs.process.ProcessTools; import com.sun.jna.Platform; import com.sun.jna.platform.win32.Kernel32; import gnu.jpdf.PDFJob; @@ -1859,11 +1861,56 @@ public class CommandLineArgumentParser { private static void parseMemorySearch(Stack args) { if (args.size() < 1) { - badArguments("memorSearch"); + badArguments("memorySearch"); } AtomicInteger cnt = new AtomicInteger(); - List procs = null; + List procs = new ArrayList<>(); + List processList = ProcessTools.listProcesses(); + while (args.size() > 0) { + String arg = args.pop(); + if (arg.matches("\\d+")) { + int processId = 0; + try { + processId = Integer.parseInt(arg); + } catch (NumberFormatException nfe) { + System.err.println("ProcessId should be integer"); + badArguments("memorySearch"); + } + + boolean found = false; + for (Process process : processList) { + if (process.getPid() == processId) { + if (!procs.contains(process)) { + procs.add(process); + } + + found = true; + break; // only 1 process can have this process id + } + } + + if (!found) { + System.out.println("Process id=" + processId + " was not found."); + } + } else { + boolean found = false; + for (Process process : processList) { + if (process.getFileName().equals(arg)) { + if (!procs.contains(process)) { + procs.add(process); + } + + found = true; + } + } + + if (!found) { + System.out.println("Process name=" + arg + " was not found."); + } + } + } + try { new SearchInMemory(new SearchInMemoryListener() { diff --git a/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java b/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java index 8f3a0d84e..c8264ff8e 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java @@ -71,7 +71,7 @@ public class LoadFromMemoryFrame extends AppFrame { private MainFrame mainFrame; - private List processlist; + private List processList; private List foundIs; @@ -132,18 +132,18 @@ public class LoadFromMemoryFrame extends AppFrame { private void addResultRow(SwfInMemory swf) { if (swf != null) { com.jpexs.process.Process process = swf.process; - resTableModel.addRow(new Object[]{swf.version, swf.fileSize, process.getPid(), process.getFileName()}); + resTableModel.addRow(new Object[]{swf.version, swf.fileSize, process.getPid(), process.getFileName(), swf.address}); } else { String notFound = translate("notfound"); - resTableModel.addRow(new Object[]{notFound, 0, "", ""}); + resTableModel.addRow(new Object[]{notFound, 0, "", "", 0}); } } private void refreshList() { model.clear(); - processlist = ProcessTools.listProcesses(); - Collections.sort(processlist); - for (com.jpexs.process.Process p : processlist) { + processList = ProcessTools.listProcesses(); + Collections.sort(processList); + for (com.jpexs.process.Process p : processList) { model.addElement(p); } } @@ -172,6 +172,7 @@ public class LoadFromMemoryFrame extends AppFrame { if (processing) { return; } + selProcesses = list.getSelectedValuesList(); if (!selProcesses.isEmpty()) { processing = true; @@ -240,6 +241,8 @@ public class LoadFromMemoryFrame extends AppFrame { return String.class; case 3: return String.class; + case 4: + return Long.class; } return null; } @@ -253,6 +256,7 @@ public class LoadFromMemoryFrame extends AppFrame { resTableModel.addColumn(translate("column.fileSize")); resTableModel.addColumn(translate("column.pid")); resTableModel.addColumn(translate("column.processName")); + resTableModel.addColumn(translate("column.address")); tableRes = new JTable(resTableModel); TableRowSorter sorter = new TableRowSorter<>(resTableModel); tableRes.setRowSorter(sorter); diff --git a/src/com/jpexs/decompiler/flash/gui/SearchInMemory.java b/src/com/jpexs/decompiler/flash/gui/SearchInMemory.java index e79b0200e..c4dffa33c 100644 --- a/src/com/jpexs/decompiler/flash/gui/SearchInMemory.java +++ b/src/com/jpexs/decompiler/flash/gui/SearchInMemory.java @@ -67,7 +67,7 @@ public class SearchInMemory { is.seek(0); is = new ReReadableInputStream(new LimitedInputStream(is, limit)); if (swf.fileSize > 0 && swf.version > 0 && !swf.getTags().isEmpty() && swf.version <= SWF.MAX_VERSION) { - SwfInMemory s = new SwfInMemory(is, swf.version, swf.fileSize, proc); + SwfInMemory s = new SwfInMemory(is, addr, swf.version, swf.fileSize, proc); publish(s); swfStreams.add(s); } diff --git a/src/com/jpexs/decompiler/flash/gui/SwfInMemory.java b/src/com/jpexs/decompiler/flash/gui/SwfInMemory.java index 4d40e92a0..06d8aaf56 100644 --- a/src/com/jpexs/decompiler/flash/gui/SwfInMemory.java +++ b/src/com/jpexs/decompiler/flash/gui/SwfInMemory.java @@ -29,12 +29,15 @@ public class SwfInMemory { public int version; + public long address; + public long fileSize; public com.jpexs.process.Process process; - public SwfInMemory(ReReadableInputStream is, int version, long fileSize, com.jpexs.process.Process process) { + public SwfInMemory(ReReadableInputStream is, long address, int version, long fileSize, com.jpexs.process.Process process) { this.is = is; + this.address = address; this.version = version; this.fileSize = fileSize; this.process = process; diff --git a/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame.properties index e1c18fb57..664bff985 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame.properties @@ -29,3 +29,4 @@ column.version = Version column.fileSize = File Size column.pid = PID column.processName = Process Name +column.address = Address diff --git a/src/com/jpexs/process/Process.java b/src/com/jpexs/process/Process.java index 1262f1c96..5d2d69df0 100644 --- a/src/com/jpexs/process/Process.java +++ b/src/com/jpexs/process/Process.java @@ -1,16 +1,16 @@ /* * 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 . */ @@ -37,7 +37,7 @@ public interface Process extends Comparable, Searchable { @Override public String toString(); - public String getPid(); + public long getPid(); @Override public Map search(byte[]... data); diff --git a/src/com/jpexs/process/win32/Win32Process.java b/src/com/jpexs/process/win32/Win32Process.java index 402d61b67..0100dc24b 100644 --- a/src/com/jpexs/process/win32/Win32Process.java +++ b/src/com/jpexs/process/win32/Win32Process.java @@ -39,8 +39,8 @@ public class Win32Process implements Process { public DWORD th32ProcessID; @Override - public String getPid() { - return Long.toString(th32ProcessID.longValue()); + public long getPid() { + return th32ProcessID.longValue(); } public Win32Process(String filePath, String fileName, BufferedImage icon, DWORD th32ProcessID) {