add disassembly window

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@107 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2008-11-22 07:49:23 +00:00
parent a85c542bc7
commit 9cd1775552
12 changed files with 345 additions and 24 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace ProcessHacker.Asm
namespace ProcessHacker
{
public partial class Asm
{
+1 -1
View File
@@ -24,7 +24,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace ProcessHacker.Asm
namespace ProcessHacker
{
public partial class Asm
{
+1 -1
View File
@@ -24,7 +24,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace ProcessHacker.Asm
namespace ProcessHacker
{
public unsafe partial class Asm
{
+6 -10
View File
@@ -24,7 +24,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace ProcessHacker.Asm
namespace ProcessHacker
{
public unsafe partial class Asm
{
@@ -38,8 +38,6 @@ namespace ProcessHacker.Asm
private int _dispSize;
private int _immSize;
private int _softError;
private int _nDump;
private int _nResult;
private bool _addComment;
private byte* _cmd;
@@ -152,7 +150,7 @@ namespace ProcessHacker.Asm
if ((PutDefSeg != 0 || seg != defSeg) && seg != SEG_UNDEF)
pr += SegName[seg] + ":";
if (!Ideal)
if (Ideal)
pr += "[";
pr += descr;
@@ -440,7 +438,7 @@ namespace ProcessHacker.Asm
else
DecodeRG(c, regsize, type);
if (!memonly)
if (memonly)
_softError = DAE_MEMORY;
return;
@@ -1132,15 +1130,15 @@ namespace ProcessHacker.Asm
return (cond == 0) ? 1 : 0;
}
public int Disasm(byte[] src, int srcsize, int srcIp, int disasmmode)
public int Disassemble(byte[] src, int srcsize, int srcIp, int disasmmode)
{
fixed (byte* pSrc = src)
{
return Disasm(pSrc, srcsize, srcIp, disasmmode);
return Disassemble(pSrc, srcsize, srcIp, disasmmode);
}
}
public int Disasm(byte* src, int srcsize, int srcIp, int disasmmode)
public int Disassemble(byte* src, int srcsize, int srcIp, int disasmmode)
{
bool repeated, is3dnow;
int searchi = 0;
@@ -1160,8 +1158,6 @@ namespace ProcessHacker.Asm
_dispSize = _immSize = 0;
lockprefix = 0;
repprefix = 0;
_nDump = 0;
_nResult = 0;
_cmd = src;
_size = srcsize;
_pFixup = null;
+106
View File
@@ -0,0 +1,106 @@
namespace ProcessHacker
{
partial class DisassemblyWindow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DisassemblyWindow));
this.listDisasm = new System.Windows.Forms.ListView();
this.columnAddress = new System.Windows.Forms.ColumnHeader();
this.columnRaw = new System.Windows.Forms.ColumnHeader();
this.columnCode = new System.Windows.Forms.ColumnHeader();
this.columnComment = new System.Windows.Forms.ColumnHeader();
this.SuspendLayout();
//
// listDisasm
//
this.listDisasm.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listDisasm.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnAddress,
this.columnRaw,
this.columnCode,
this.columnComment});
this.listDisasm.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listDisasm.FullRowSelect = true;
this.listDisasm.GridLines = true;
this.listDisasm.HideSelection = false;
this.listDisasm.Location = new System.Drawing.Point(12, 12);
this.listDisasm.Name = "listDisasm";
this.listDisasm.ShowItemToolTips = true;
this.listDisasm.Size = new System.Drawing.Size(498, 509);
this.listDisasm.TabIndex = 0;
this.listDisasm.UseCompatibleStateImageBehavior = false;
this.listDisasm.View = System.Windows.Forms.View.Details;
this.listDisasm.VirtualMode = true;
this.listDisasm.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.listDisasm_RetrieveVirtualItem);
//
// columnAddress
//
this.columnAddress.Text = "Address";
this.columnAddress.Width = 80;
//
// columnRaw
//
this.columnRaw.Text = "Raw";
this.columnRaw.Width = 100;
//
// columnCode
//
this.columnCode.Text = "Code";
this.columnCode.Width = 140;
//
// columnComment
//
this.columnComment.Text = "Comment";
this.columnComment.Width = 160;
//
// DisassemblyWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(522, 533);
this.Controls.Add(this.listDisasm);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "DisassemblyWindow";
this.Text = "Disassembly";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListView listDisasm;
private System.Windows.Forms.ColumnHeader columnAddress;
private System.Windows.Forms.ColumnHeader columnRaw;
private System.Windows.Forms.ColumnHeader columnCode;
private System.Windows.Forms.ColumnHeader columnComment;
}
}
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ProcessHacker
{
public partial class DisassemblyWindow : Form
{
private List<string[]> _disasm = new List<string[]>();
public DisassemblyWindow(Stream s, long position, int maxCount)
{
InitializeComponent();
Asm.Disassembler disasm = new Asm.Disassembler();
s.Seek(position, SeekOrigin.Begin);
while ((maxCount != -1 && _disasm.Count < maxCount) || (maxCount == -1))
{
byte[] data = new byte[16];
s.Read(data, 0, 16);
s.Seek(disasm.Disassemble(data, 16, 0, Asm.DISASM_FILE) - 16, SeekOrigin.Current);
_disasm.Add(new string[]
{
"0x" + s.Position.ToString("x8"),
disasm.Result.Dump.ToString(),
disasm.Result.Result.ToString(),
disasm.Result.Comment
});
if (maxCount == -1)
if (disasm.Result.Result.ToString().StartsWith("ret"))
break;
}
listDisasm.VirtualListSize = _disasm.Count;
}
private void listDisasm_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{
string[] item = _disasm[e.ItemIndex];
e.Item = new ListViewItem(item);
}
}
}
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAOrEo+vnv57/47uZ/+C2lP/dsY7/2a2J/9aohP/TpH7/0J96/82bdf/KmHH/yJVt/8WS
av/Dj2j/w49n/8OPZ+vuy6r/6NXI/+jUxP/n0sL/5dDA/+XOvf/jzLv/48q4/+LJtv/hx7T/4MSy/9/D
sP/fw6//3sGu/97Brf/Dj2f/8tCw/+rYzP/8/Pz/2rmj//z8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8//z8
/P/8/Pz/zKCB//z8/P/fwq//xJFp//XUtf/s3ND/3sKu/92+qv/bvKb/2bmi/9i2nv/Ws5v/1bCW/9Ot
k//Rqo7/0KeL/8+lh//NooT/4MSy/8eUbf/42Lr/7d7U//z8/P/8/Pz/3sGt//z8/P/bu6X//Pz8/9i1
nf/8/Pz/1a+W//z8/P/8/Pz//Pz8/+HItf/KmHH/+ty+/+7g1v/jy7n/4sm3/+DFs//fw7D/3sGs/9y+
qf/au6X/2bih/9e1nf/Wspn/6dbK//z8/P/jy7n/zpx2//zewP/v4tj//Pz8/+TMu//8/Pz/4cm2//z8
/P/fwq///Pz8/9y9qP/8/Pz/2beg//z8/P/38/D/5c69/9GhfP/83sD/7+LY/+/i2P/v4tj/7uHX/+7g
1v/u39T/7d3S/+zc0f/r2s7/6tjM/+rXyv/o1cf/59PE/+fRwf/Vp4L//N7A4/zewP+6uLX/srCt//rb
vf/42Lr/9tW2//PSsv/wzq3/7cmp/+rEo//nv57/47uZ/+C2lP/dsY7/2a2J4wAAAAAAAAAAw8PD/bu7
u7SysrIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANDQ
0PjJycn4wcHBZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AADZ2dln1NTU9s/Pz+/IyMjlv7+/2La2tsOtra2To6OjfZqamm6QkJBJhoaGBAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA//+sQf//rEEAAKxBAACsQQAArEEAAKxBAACsQQAArEEAAKxBAACsQQAArEHH/6xBx/+sQcAH
rEH//6xB//+sQQ==
</value>
</data>
</root>
+1
View File
@@ -308,6 +308,7 @@
this.listExports.UseCompatibleStateImageBehavior = false;
this.listExports.View = System.Windows.Forms.View.Details;
this.listExports.VirtualMode = true;
this.listExports.DoubleClick += new System.EventHandler(this.listExports_DoubleClick);
this.listExports.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.listExports_RetrieveVirtualItem);
//
// columnExportName
+9
View File
@@ -25,6 +25,7 @@ using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ProcessHacker.PE;
using System.IO;
namespace ProcessHacker
{
@@ -349,5 +350,13 @@ namespace ProcessHacker
}
}
}
private void listExports_DoubleClick(object sender, EventArgs e)
{
DisassemblyWindow dw = new DisassemblyWindow(new FileStream(_path, FileMode.Open, FileAccess.Read),
PEFile.RvaToVa(_peFile, _peFile.ExportData.ExportAddressTable[listExports.SelectedIndices[0]].ExportRVA), -1);
dw.Show();
}
}
}
+11 -11
View File
@@ -127,19 +127,19 @@
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADK
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADI
AgAAAk1TRnQBSQFMAwEBAAEEAQABBAEAARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMA
ARADAAEBAQABIAYAARD/AP8A/wD/AEIAAVYBVwFWAbgDBAEG9AADJgE4AVEBaQFRAfcBWwFeAVsB2dEA
Ab4BCQH/AQABuAEEAf8BAAGxAQAB/wEAAakBAAH/AQABoQEAAf8BAAGZAQAB/wEAAZEBAAH/AQABiAEA
Af8BAAGAAQAB/wEAAYgBAAH/AQABoQEAAf8BAAGLAQAB/wFZAVwBWQHPzAABAQ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AYUBxwGLAf8BgQHF
AYcB/wEXAcIBggH/AQABkQEAAf8BWQFcAVkBycgAAQIBxwEOAf8BAgHHAQ4B/wEAAcMBCwH/AQABvgEH
Af8BAAG4AQIB/wEAAbEBAAH/AQABqQEAAf8BAAGhAQAB/wEAAZkBAAH/AQABkQEAAf8BAAGjAQAB/wEA
AZ0BAAH/AVgBXAFYAdH0AAFRAW0BUQH3AVoBXwFaAdv4AAFWAVgBVgG7AwQBBv8A/wD/AP8A0AABQgFN
AT4HAAE+AwABKAMAAUADAAEQAwABAQEAAQEFAAGAFwAD/wEAAv8GAAL/BgAC/wYAAv8GAAH/AecGAAH/
AccGAAGAAQMGAAGAAQEGAAGAAQEGAAGAAQMGAAH/AecGAAH/AecGAAL/BgAC/wYAAv8GAAL/BgAL
</value>
</data>
<metadata name="vistaMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+10
View File
@@ -141,6 +141,10 @@
<DependentUpon>AboutWindow.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\DisassemblyWindow.resx">
<DependentUpon>DisassemblyWindow.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ErrorDialog.resx">
<DependentUpon>ErrorDialog.cs</DependentUpon>
</EmbeddedResource>
@@ -227,6 +231,12 @@
<Compile Include="Components\ProcessTree.Designer.cs">
<DependentUpon>ProcessTree.cs</DependentUpon>
</Compile>
<Compile Include="Forms\DisassemblyWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\DisassemblyWindow.Designer.cs">
<DependentUpon>DisassemblyWindow.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ErrorDialog.cs">
<SubType>Form</SubType>
</Compile>