public static void Main() { byte[] mipsCode = new byte[] { 0x0C, 0x10, 0x00, 0x97, 0x00, 0x00, 0x00, 0x00, 0x24, 0x02, 0x00, 0x0c, 0x8f, 0xa2, 0x00, 0x00, 0x34, 0x21, 0x34, 0x56 }; byte[] mipsCode2 = new byte[] { 0x56, 0x34, 0x21, 0x34, 0xc2, 0x17, 0x01, 0x00 }; uint address = 0x1000; UIntPtr insnCount = UIntPtr.Zero; platform[] platforms = { new platform( Architecture.Mips, Mode.Mode32 | Mode.BigEndian, OptionValue.SyntaxDefault, mipsCode, "MIPS-32 (Big-endian)" ), new platform( Architecture.Mips, Mode.Mode64 | Mode.LittleEndian, OptionValue.SyntaxDefault, mipsCode2, "MIPS-64-EL (Little-endian)" ) }; for (int j = 0; j < platforms.Length; j++) { System.Console.WriteLine(); System.Console.WriteLine("************"); System.Console.WriteLine("Platform: {0}", platforms[j].comment); System.Console.WriteLine(); Capstone.Capstone cs = new Capstone.Capstone(platforms[j].arch, platforms[j].mode); cs.SetSyntax(platforms[j].syntax); cs.SetDetail(true); Instruction[] insns = cs.Disassemble(platforms[j].code, address, insnCount); for (int i = 0; i < insns.Length; i++) { Console.WriteLine(insns[i]); PrintInsnDetail(platforms[j].mode, insns[i]); Console.WriteLine(); } } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public static void Main() { byte[] arm64Code = new byte[] { 0x21, 0x7c, 0x02, 0x9b, 0x21, 0x7c, 0x00, 0x53, 0x00, 0x40, 0x21, 0x4b, 0xe1, 0x0b, 0x40, 0xb9, 0x20, 0x04, 0x81, 0xda, 0x20, 0x08, 0x02, 0x8b }; uint address = 0x1000; UIntPtr insnCount = UIntPtr.Zero; platform[] platforms = { new platform( Architecture.Arm64, Mode.Arm, OptionValue.Off, arm64Code, "ARM-64" ) }; for (int j = 0; j < platforms.Length; j++) { System.Console.WriteLine(); System.Console.WriteLine("************"); System.Console.WriteLine("Platform: {0}", platforms[j].comment); System.Console.WriteLine(); Capstone.Capstone cs = new Capstone.Capstone(platforms[j].arch, platforms[j].mode); cs.SetSyntax(platforms[j].syntax); cs.SetDetail(true); Instruction[] insns = cs.Disassemble(platforms[j].code, address, insnCount); for (int i = 0; i < insns.Length; i++) { Console.WriteLine(insns[i]); PrintInsnDetail(platforms[j].mode, insns[i]); Console.WriteLine(); } } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public static void Main() { byte[] PowerPCCode = new byte[] { 0x80, 0x20, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x10, 0x43, 0x23, 0x0e, 0xd0, 0x44, 0x00, 0x80, 0x4c, 0x43, 0x22, 0x02, 0x2d, 0x03, 0x00, 0x80, 0x7c, 0x43, 0x20, 0x14, 0x7c, 0x43, 0x20, 0x93, 0x4f, 0x20, 0x00, 0x21, 0x4c, 0xc8, 0x00, 0x21 }; uint address = 0x1000; UIntPtr insnCount = UIntPtr.Zero; platform[] platforms = { new platform( Architecture.PPC, Mode.BigEndian, OptionValue.SyntaxDefault, PowerPCCode, "PPC-64" ) }; for (int j = 0; j < platforms.Length; j++) { System.Console.WriteLine(); System.Console.WriteLine("************"); System.Console.WriteLine("Platform: {0}", platforms[j].comment); System.Console.WriteLine(); Capstone.Capstone cs = new Capstone.Capstone(platforms[j].arch, platforms[j].mode); cs.SetSyntax(platforms[j].syntax); cs.SetDetail(true); Instruction[] insns = cs.Disassemble(platforms[j].code, address, insnCount); for (int i = 0; i < insns.Length; i++) { Console.WriteLine(insns[i]); PrintInsnDetail(platforms[j].mode, insns[i]); Console.WriteLine(); } } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public static void Main() { byte[] code16 = 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 }; byte[] code32 = 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 }; byte[] code64 = new byte[] { 0x55, 0x48, 0x8b, 0x05, 0xb8, 0x13, 0x00, 0x00 }; uint address = 0x1000; UIntPtr insnCount = UIntPtr.Zero; platform[] platforms = { new platform( Architecture.X86, Mode.Mode16, OptionValue.SyntaxIntel, code16, "X86 16bit (Intel syntax)" ), new platform( Architecture.X86, Mode.Mode32, OptionValue.SyntaxATT, code32, "X86 32bit (AT&T syntax)" ), new platform( Architecture.X86, Mode.Mode32, OptionValue.SyntaxIntel, code32, "X86 32bit (Intel syntax)" ), new platform( Architecture.X86, Mode.Mode64, OptionValue.SyntaxIntel, code64, "X86 64bit (Intel syntax)" ) }; for (int j = 0; j < platforms.Length; j++) { System.Console.WriteLine(); System.Console.WriteLine("************"); System.Console.WriteLine("Platform: {0}", platforms[j].comment); System.Console.WriteLine(); Capstone.Capstone cs = new Capstone.Capstone(platforms[j].arch, platforms[j].mode); cs.SetSyntax(platforms[j].syntax); cs.SetDetail(true); Instruction[] insns = cs.Disassemble(platforms[j].code, address, insnCount); for (int i = 0; i < insns.Length; i++) { Console.WriteLine(insns[i]); PrintInsnDetail(platforms[j].mode, insns[i]); Console.WriteLine(); } } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public static void Main() { byte[] armCode = 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 }; byte[] armCode2 = new byte[] { 0xd1, 0xe8, 0x00, 0xf0, 0xf0, 0x24, 0x04, 0x07, 0x1f, 0x3c, 0xf2, 0xc0, 0x00, 0x00, 0x4f, 0xf0, 0x00, 0x01, 0x46, 0x6c }; byte[] thumbCode = new byte[] { 0x70, 0x47, 0xeb, 0x46, 0x83, 0xb0, 0xc9, 0x68, 0x1f, 0xb1 }; byte[] thumbCode2 = new byte[] { 0x4f, 0xf0, 0x00, 0x01, 0xbd, 0xe8, 0x00, 0x88, 0xd1, 0xe8, 0x00, 0xf0 }; uint address = 0x1000; UIntPtr insnCount = UIntPtr.Zero; platform[] platforms = { new platform( Architecture.Arm, Mode.Arm, OptionValue.Off, armCode, "ARM" ), new platform( Architecture.Arm, Mode.Thumb, OptionValue.Off, thumbCode, "Thumb" ), new platform( Architecture.Arm, Mode.Thumb, OptionValue.Off, armCode2, "Thumb-mixed" ), new platform( Architecture.Arm, Mode.Thumb, OptionValue.Off, thumbCode2, "Thumb-2" ) }; for (int j = 0; j < platforms.Length; j++) { System.Console.WriteLine(); System.Console.WriteLine("************"); System.Console.WriteLine("Platform: {0}", platforms[j].comment); System.Console.WriteLine(); Capstone.Capstone cs = new Capstone.Capstone(platforms[j].arch, platforms[j].mode); cs.SetSyntax(platforms[j].syntax); cs.SetDetail(true); Instruction[] insns = cs.Disassemble(platforms[j].code, address, insnCount); for (int i = 0; i < insns.Length; i++) { Console.WriteLine(insns[i]); PrintInsnDetail(platforms[j].mode, insns[i]); Console.WriteLine(); } } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }