Skip to content

Commit

Permalink
+ Deprecated old native instruction collection and enumerator
Browse files Browse the repository at this point in the history
+ Updated documentation and code for new deferred instruction enumerator
  • Loading branch information
9ee1 committed Aug 12, 2015
1 parent e97109d commit e21e76b
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 118 deletions.
18 changes: 0 additions & 18 deletions Capstone.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,24 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
.NET4Debug|x86 = .NET4Debug|x86
.NET4Release|x86 = .NET4Release|x86
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1297DCEE-009D-4739-8124-3F064EA9EA10}..NET4Debug|x86.ActiveCfg = .NET45Release|x86
{1297DCEE-009D-4739-8124-3F064EA9EA10}..NET4Debug|x86.Build.0 = .NET45Release|x86
{1297DCEE-009D-4739-8124-3F064EA9EA10}..NET4Release|x86.ActiveCfg = .NET45Release|x86
{1297DCEE-009D-4739-8124-3F064EA9EA10}..NET4Release|x86.Build.0 = .NET45Release|x86
{1297DCEE-009D-4739-8124-3F064EA9EA10}.Debug|x86.ActiveCfg = .NET45Debug|x86
{1297DCEE-009D-4739-8124-3F064EA9EA10}.Debug|x86.Build.0 = .NET45Debug|x86
{1297DCEE-009D-4739-8124-3F064EA9EA10}.Release|x86.ActiveCfg = .NET45Release|x86
{1297DCEE-009D-4739-8124-3F064EA9EA10}.Release|x86.Build.0 = .NET45Release|x86
{7D755424-C594-4605-820D-9AF880E091BC}..NET4Debug|x86.ActiveCfg = .NET45Release|x86
{7D755424-C594-4605-820D-9AF880E091BC}..NET4Debug|x86.Build.0 = .NET45Release|x86
{7D755424-C594-4605-820D-9AF880E091BC}..NET4Release|x86.ActiveCfg = .NET45Release|x86
{7D755424-C594-4605-820D-9AF880E091BC}..NET4Release|x86.Build.0 = .NET45Release|x86
{7D755424-C594-4605-820D-9AF880E091BC}.Debug|x86.ActiveCfg = .NET45Debug|x86
{7D755424-C594-4605-820D-9AF880E091BC}.Debug|x86.Build.0 = .NET45Debug|x86
{7D755424-C594-4605-820D-9AF880E091BC}.Release|x86.ActiveCfg = .NET45Release|x86
{7D755424-C594-4605-820D-9AF880E091BC}.Release|x86.Build.0 = .NET45Release|x86
{D1A6EC03-1420-4516-8548-4117A18DA8B3}..NET4Debug|x86.ActiveCfg = .NET45Release|x86
{D1A6EC03-1420-4516-8548-4117A18DA8B3}..NET4Debug|x86.Build.0 = .NET45Release|x86
{D1A6EC03-1420-4516-8548-4117A18DA8B3}..NET4Release|x86.ActiveCfg = .NET45Release|x86
{D1A6EC03-1420-4516-8548-4117A18DA8B3}..NET4Release|x86.Build.0 = .NET45Release|x86
{D1A6EC03-1420-4516-8548-4117A18DA8B3}.Debug|x86.ActiveCfg = .NET45Debug|x86
{D1A6EC03-1420-4516-8548-4117A18DA8B3}.Debug|x86.Build.0 = .NET45Debug|x86
{D1A6EC03-1420-4516-8548-4117A18DA8B3}.Release|x86.ActiveCfg = .NET45Release|x86
{D1A6EC03-1420-4516-8548-4117A18DA8B3}.Release|x86.Build.0 = .NET45Release|x86
{D8E7BF01-1424-4312-AF14-982E7DA9B9BC}..NET4Debug|x86.ActiveCfg = .NET4Debug|x86
{D8E7BF01-1424-4312-AF14-982E7DA9B9BC}..NET4Debug|x86.Build.0 = .NET4Debug|x86
{D8E7BF01-1424-4312-AF14-982E7DA9B9BC}..NET4Release|x86.ActiveCfg = .NET4Release|x86
{D8E7BF01-1424-4312-AF14-982E7DA9B9BC}..NET4Release|x86.Build.0 = .NET4Release|x86
{D8E7BF01-1424-4312-AF14-982E7DA9B9BC}.Debug|x86.ActiveCfg = .NET4Debug|x86
{D8E7BF01-1424-4312-AF14-982E7DA9B9BC}.Debug|x86.Build.0 = .NET4Debug|x86
{D8E7BF01-1424-4312-AF14-982E7DA9B9BC}.Release|x86.ActiveCfg = .NET4Release|x86
{D8E7BF01-1424-4312-AF14-982E7DA9B9BC}.Release|x86.Build.0 = .NET4Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
20 changes: 10 additions & 10 deletions CapstoneCMD/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal static void Main(string[] args) {
Program.ShowArm(DisassembleMode.Arm32);
break;
case "ARM32-V8":
Program.ShowArm((int)DisassembleMode.Arm32 + DisassembleMode.ArmV8);
Program.ShowArm((int) DisassembleMode.Arm32 + DisassembleMode.ArmV8);
break;
case "ARM32-Thumb":
Program.ShowArm(DisassembleMode.ArmThumb);
Expand Down Expand Up @@ -74,16 +74,16 @@ internal static void ShowArm(DisassembleMode mode) {
var code = new byte[0];
switch (mode) {
case DisassembleMode.Arm32:
code = new byte[] {0xED, 0xFF, 0xFF, 0xEB, 0x04, 0xe0, 0x2d, 0xe5, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x83, 0x22, 0xe5, 0xf1, 0x02, 0x03, 0x0e, 0x00, 0x00, 0xa0, 0xe3, 0x02, 0x30, 0xc1, 0xe7, 0x00, 0x00, 0x53, 0xe3, 0x00, 0x02, 0x01, 0xf1, 0x05, 0x40, 0xd0, 0xe8, 0xf4, 0x80, 0x00, 0x00};
code = new byte[] { 0xED, 0xFF, 0xFF, 0xEB, 0x04, 0xe0, 0x2d, 0xe5, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x83, 0x22, 0xe5, 0xf1, 0x02, 0x03, 0x0e, 0x00, 0x00, 0xa0, 0xe3, 0x02, 0x30, 0xc1, 0xe7, 0x00, 0x00, 0x53, 0xe3, 0x00, 0x02, 0x01, 0xf1, 0x05, 0x40, 0xd0, 0xe8, 0xf4, 0x80, 0x00, 0x00 };
break;
case (int)DisassembleMode.Arm32 + DisassembleMode.ArmV8:
case (int) DisassembleMode.Arm32 + DisassembleMode.ArmV8:
code = new byte[] { 0xe0, 0x3b, 0xb2, 0xee, 0x42, 0x00, 0x01, 0xe1, 0x51, 0xf0, 0x7f, 0xf5 };
break;
case DisassembleMode.ArmThumb:
code = new byte[] {0x70, 0x47, 0xeb, 0x46, 0x83, 0xb0, 0xc9, 0x68, 0x1f, 0xb1, 0x30, 0xbf, 0xaf, 0xf3, 0x20, 0x84};
code = new byte[] { 0x70, 0x47, 0xeb, 0x46, 0x83, 0xb0, 0xc9, 0x68, 0x1f, 0xb1, 0x30, 0xbf, 0xaf, 0xf3, 0x20, 0x84 };
break;
case (int) DisassembleMode.ArmThumb + DisassembleMode.ArmCortexM:
code = new byte[] {0xef, 0xf3, 0x02, 0x80};
code = new byte[] { 0xef, 0xf3, 0x02, 0x80 };
break;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ internal static void ShowArm64() {
// Disassemble All Binary Code.
//
// ...
var code = new byte[] {0x09, 0x00, 0x38, 0xd5, 0xbf, 0x40, 0x00, 0xd5, 0x0c, 0x05, 0x13, 0xd5, 0x20, 0x50, 0x02, 0x0e, 0x20, 0xe4, 0x3d, 0x0f, 0x00, 0x18, 0xa0, 0x5f, 0xa2, 0x00, 0xae, 0x9e, 0x9f, 0x37, 0x03, 0xd5, 0xbf, 0x33, 0x03, 0xd5, 0xdf, 0x3f, 0x03, 0xd5, 0x21, 0x7c, 0x02, 0x9b, 0x21, 0x7c, 0x00, 0x53, 0x00, 0x40, 0x21, 0x4b, 0xe1, 0x0b, 0x40, 0xb9, 0x20, 0x04, 0x81, 0xda, 0x20, 0x08, 0x02, 0x8b, 0x10, 0x5b, 0xe8, 0x3c};
var code = new byte[] { 0x09, 0x00, 0x38, 0xd5, 0xbf, 0x40, 0x00, 0xd5, 0x0c, 0x05, 0x13, 0xd5, 0x20, 0x50, 0x02, 0x0e, 0x20, 0xe4, 0x3d, 0x0f, 0x00, 0x18, 0xa0, 0x5f, 0xa2, 0x00, 0xae, 0x9e, 0x9f, 0x37, 0x03, 0xd5, 0xbf, 0x33, 0x03, 0xd5, 0xdf, 0x3f, 0x03, 0xd5, 0x21, 0x7c, 0x02, 0x9b, 0x21, 0x7c, 0x00, 0x53, 0x00, 0x40, 0x21, 0x4b, 0xe1, 0x0b, 0x40, 0xb9, 0x20, 0x04, 0x81, 0xda, 0x20, 0x08, 0x02, 0x8b, 0x10, 0x5b, 0xe8, 0x3c };
var instructions = disassembler.DisassembleAll(code, 0x2C);

var hexCode = BitConverter.ToString(code).Replace("-", " ");
Expand Down Expand Up @@ -327,11 +327,11 @@ internal static void ShowX86() {
// Disassemble All Binary Code.
//
// ...
var code = new byte[] {0x8d, 0x4c, 0x32, 0x08, 0x01, 0xd8, 0x81, 0xc6, 0x34, 0x12, 0x00, 0x00, 0x05, 0x23, 0x01, 0x00, 0x00, 0x36, 0x8b, 0x84, 0x91, 0x23, 0x01, 0x00, 0x00, 0x41, 0x8d, 0x84, 0x39, 0x89, 0x67, 0x00, 0x00, 0x8d, 0x87, 0x89, 0x67, 0x00, 0x00, 0xb4, 0xc6};
var code = new byte[] { 0x8d, 0x4c, 0x32, 0x08, 0x01, 0xd8, 0x81, 0xc6, 0x34, 0x12, 0x00, 0x00, 0x05, 0x23, 0x01, 0x00, 0x00, 0x36, 0x8b, 0x84, 0x91, 0x23, 0x01, 0x00, 0x00, 0x41, 0x8d, 0x84, 0x39, 0x89, 0x67, 0x00, 0x00, 0x8d, 0x87, 0x89, 0x67, 0x00, 0x00, 0xb4, 0xc6 };
#if DISASSEMBLE_STREAM
//$REVIEW: uxmal: This exercises the lazy stream implementation of the disassembler.
// It isn't greed and tries to disassembly all the instructions at once,
// but only on demand.
//$REVIEW: uxmal: This exercises the lazy stream implementation of the disassembler.
// It isn't greed and tries to disassembly all the instructions at once,
// but only on demand.
var instructions = disassembler.DisassembleStream(code, 0, 0x1000);
#else
var instructions = disassembler.DisassembleAll(code);
Expand Down
Loading

0 comments on commit e21e76b

Please sign in to comment.