mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 11:10:56 +00:00
#1170 Extract from Memory in Command Line 2
This commit is contained in:
@@ -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<String> args) {
|
||||
if (args.size() < 1) {
|
||||
badArguments("memorSearch");
|
||||
badArguments("memorySearch");
|
||||
}
|
||||
|
||||
AtomicInteger cnt = new AtomicInteger();
|
||||
List<com.jpexs.process.Process> procs = null;
|
||||
List<com.jpexs.process.Process> procs = new ArrayList<>();
|
||||
List<Process> 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() {
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class LoadFromMemoryFrame extends AppFrame {
|
||||
|
||||
private MainFrame mainFrame;
|
||||
|
||||
private List<com.jpexs.process.Process> processlist;
|
||||
private List<com.jpexs.process.Process> processList;
|
||||
|
||||
private List<SwfInMemory> 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<DefaultTableModel> sorter = new TableRowSorter<>(resTableModel);
|
||||
tableRes.setRowSorter(sorter);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -29,3 +29,4 @@ column.version = Version
|
||||
column.fileSize = File Size
|
||||
column.pid = PID
|
||||
column.processName = Process Name
|
||||
column.address = Address
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ public interface Process extends Comparable<Process>, Searchable {
|
||||
@Override
|
||||
public String toString();
|
||||
|
||||
public String getPid();
|
||||
public long getPid();
|
||||
|
||||
@Override
|
||||
public Map<Long, InputStream> search(byte[]... data);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user