Support for showing if app is 32bit vs 64bit, and support for doing message hooks on both

Added support for message hook viewer to hook both 32 and 64 bit
applications.
Fixed filtering on the msg hook viewer
Added custom filtering on msg hook viewer
Added Process Id targetting on msg hook viewer
Added SetMsgHook.exe command line app as an alternative way of starting
msg hook viewer.
This commit is contained in:
Edward Jakubowski
2014-06-03 06:28:14 -04:00
parent 05748b4582
commit d100d23259
41 changed files with 1232 additions and 72 deletions

View File

@@ -12,7 +12,9 @@ import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JToolBar;
import javax.swing.JButton;
import javax.swing.JScrollPane;
@@ -26,6 +28,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Toolkit;
import java.io.*;
import javax.swing.JLabel;
@@ -36,7 +39,8 @@ public class TestIdeFrame extends JFrame {
public static String RES_STR_RUN_IMG = "/org/synthuse/img/arrow-right-3.png";
public static String RES_STR_CLEAR_IMG = "/org/synthuse/img/user-trash-2.png";
public static String RES_STR_COPY_IMG = "/org/synthuse/img/edit-copy-7.png";
public static String RES_STR_SAVE_IMG = "/org/synthuse/img/document-save-6.png";
public static String RES_STR_OPEN_IMG = "/org/synthuse/img/document-open-folder.png";
/**
*
*/
@@ -46,6 +50,8 @@ public class TestIdeFrame extends JFrame {
private JButton btnRun;
private JButton btnClear;
private JButton btnCopy;
private JButton btnSave;
private JButton btnOpen;
private JLabel lblStatus;
/**
@@ -68,32 +74,30 @@ public class TestIdeFrame extends JFrame {
btnRun = new JButton("Run");
btnRun.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (btnRun.getText().equals("Run")) {
btnRun.setText("Stop");
btnRun.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_STOP_IMG)));
CommandProcessor.STOP_PROCESSOR.set(false);
CommandProcessor.executeThreaded(txtTest.getText(), new CommandProcessor.Events() {
@Override
public void statusChanged(String status) {
lblStatus.setText(status);
}
@Override
public void executionCompleted() {
btnRun.setText("Run");
btnRun.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_RUN_IMG)));
}
});
}
else {
CommandProcessor.STOP_PROCESSOR.set(true);
//btnRun.setText("Run");
//btnRun.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_RUN_IMG)));
}
runTestScript();
}
});
btnRun.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_RUN_IMG)));
toolBar.add(btnRun);
btnSave = new JButton("Save");
btnSave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
saveTestScript();
}
});
btnSave.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_SAVE_IMG)));
toolBar.add(btnSave);
btnOpen = new JButton("Open");
btnOpen.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
openTestScript();
}
});
btnOpen.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_OPEN_IMG)));
toolBar.add(btnOpen);
btnClear = new JButton("Clear");
btnClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
@@ -135,5 +139,83 @@ public class TestIdeFrame extends JFrame {
});
super.setAlwaysOnTop(SynthuseDlg.config.isAlwaysOnTop());
}
public void runTestScript()
{
if (btnRun.getText().equals("Run")) {
btnRun.setText("Stop");
btnRun.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_STOP_IMG)));
CommandProcessor.STOP_PROCESSOR.set(false);
CommandProcessor.executeThreaded(txtTest.getText(), new CommandProcessor.Events() {
@Override
public void statusChanged(String status) {
lblStatus.setText(status);
}
@Override
public void executionCompleted() {
btnRun.setText("Run");
btnRun.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_RUN_IMG)));
}
});
}
else {
CommandProcessor.STOP_PROCESSOR.set(true);
//btnRun.setText("Run");
//btnRun.setIcon(new ImageIcon(SynthuseDlg.class.getResource(RES_STR_RUN_IMG)));
}
}
private void saveTestScript()
{
JFileChooser fChoose = new JFileChooser();
fChoose.setFileFilter(new FileNameExtensionFilter("Text Files", "txt", "text"));
int result = fChoose.showSaveDialog(this);
if (result == JFileChooser.CANCEL_OPTION)
return;
File file = fChoose.getSelectedFile();
if (fChoose.getFileFilter().getDescription().startsWith("Text") && !file.getAbsolutePath().toLowerCase().endsWith(".txt"))
file = new File(file.getAbsolutePath() + ".txt"); //append extension if not already there
FileWriter fw = null;
try {
fw = new FileWriter(file);
fw.write(txtTest.getText());
fw.flush();
fw.close();
fw = null;
} catch (Exception e) {
e.printStackTrace();
}
if (fw != null)
try { fw.close(); } catch (Exception e){ e.printStackTrace(); };
lblStatus.setText("Script Saved: " + file.getAbsolutePath());
}
private void openTestScript()
{
JFileChooser fChoose = new JFileChooser();
fChoose.setFileFilter(new FileNameExtensionFilter("Text Files", "txt", "text"));
int result = fChoose.showOpenDialog(this);
if (result == JFileChooser.CANCEL_OPTION)
return;
File file = fChoose.getSelectedFile();
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(file));
String line = "";
txtTest.setText("");
while((line = br.readLine()) != null){
txtTest.append(line + System.getProperty("line.separator"));
//System.out.println(line);
}
br.close();
br = null;
} catch (Exception e) {
e.printStackTrace();
}
if (br != null)
try { br.close(); } catch (Exception e){ e.printStackTrace(); };
lblStatus.setText("Script Loaded: " + file.getAbsolutePath());
}
}