hide memory search on non windows platform + show warning on command-line memory search on non-windows platform

This commit is contained in:
honfika@gmail.com
2016-05-18 15:56:54 +02:00
committed by Vitali Deatlov
parent 41124afa8a
commit 018df9f9b9
2 changed files with 69 additions and 59 deletions

View File

@@ -1922,75 +1922,83 @@ public class CommandLineArgumentParser {
badArguments("memorysearch");
}
AtomicInteger cnt = new AtomicInteger();
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 (Platform.isWindows()) {
AtomicInteger cnt = new AtomicInteger();
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");
}
}
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);
boolean found = false;
if (processList != null) {
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
}
}
found = true;
}
}
if (!found) {
System.out.println("Process name=" + arg + " was not found.");
if (!found) {
System.out.println("Process id=" + processId + " was not found.");
}
} else {
boolean found = false;
if (processList != null) {
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() {
try {
new SearchInMemory(new SearchInMemoryListener() {
@Override
public void publish(Object... chunks) {
for (Object s : chunks) {
if (s instanceof SwfInMemory) {
SwfInMemory swf = (SwfInMemory) s;
String fileName = cnt.getAndIncrement() + ".swf";
System.out.println("SWF found (" + fileName + "). Version: " + swf.version + ", file size: " + swf.fileSize + ", address: " + swf.address);
Helper.writeFile(fileName, swf.is);
@Override
public void publish(Object... chunks) {
for (Object s : chunks) {
if (s instanceof SwfInMemory) {
SwfInMemory swf = (SwfInMemory) s;
String fileName = cnt.getAndIncrement() + ".swf";
System.out.println("SWF found (" + fileName + "). Version: " + swf.version + ", file size: " + swf.fileSize + ", address: " + swf.address);
Helper.writeFile(fileName, swf.is);
}
}
}
}
@Override
public void setProgress(int progress) {
// ignore
}
}).search(procs);
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
@Override
public void setProgress(int progress) {
// ignore
}
}).search(procs);
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
}
} else {
System.err.println("Memory search is only available on Windows platform.");
}
System.exit(0);

View File

@@ -882,9 +882,11 @@ public abstract class MainFrameMenu implements MenuBuilder {
addToggleMenuItem("/tools/timeline", translate("menu.tools.timeline"), null, "timeline32", this::timelineActionPerformed, PRIORITY_TOP, null);
addMenuItem("/tools/showProxy", translate("menu.tools.proxy"), "proxy16", this::showProxyActionPerformed, PRIORITY_MEDIUM, null, true, null, false);
addMenuItem("/tools/searchMemory", translate("menu.tools.searchMemory"), "loadmemory16", this::searchMemoryActionPerformed, PRIORITY_MEDIUM, null, true, null, false);
//addMenuItem("/tools/searchCache", translate("menu.tools.searchCache"), "loadcache16", this::searchCacheActionPerformed, PRIORITY_MEDIUM, null, true, null);
if (Platform.isWindows()) {
addMenuItem("/tools/searchMemory", translate("menu.tools.searchMemory"), "loadmemory16", this::searchMemoryActionPerformed, PRIORITY_MEDIUM, null, true, null, false);
}
//addMenuItem("/tools/searchCache", translate("menu.tools.searchCache"), "loadcache16", this::searchCacheActionPerformed, PRIORITY_MEDIUM, null, true, null);
addMenuItem("/tools/deobfuscation", translate("menu.tools.deobfuscation"), "deobfuscate16", null, 0, null, false, null, false);
addMenuItem("/tools/deobfuscation/renameOneIdentifier", translate("menu.tools.deobfuscation.globalrename"), "rename16", this::renameOneIdentifier, PRIORITY_MEDIUM, null, true, null, false);
addMenuItem("/tools/deobfuscation/renameInvalidIdentifiers", translate("menu.tools.deobfuscation.renameinvalid"), "renameall16", this::renameInvalidIdentifiers, PRIORITY_MEDIUM, null, true, null, false);