本文整理汇总了C#中Reko.Core.MemoryArea类的典型用法代码示例。如果您正苦于以下问题:C# MemoryArea类的具体用法?C# MemoryArea怎么用?C# MemoryArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemoryArea类属于Reko.Core命名空间,在下文中一共展示了MemoryArea类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisassembleWord
private static SparcInstruction DisassembleWord(uint instr)
{
var bytes = new byte[4];
new BeImageWriter(bytes).WriteBeUInt32(0, instr);
var img = new MemoryArea(Address.Ptr32(0x00100000), bytes);
return Disassemble(img);
}
示例2: RunTest
private MachineInstruction RunTest(params byte[] bytes)
{
var image = new MemoryArea(Address.Ptr32(0x200), bytes);
var rdr = new LeImageReader(image, 0);
var dasm = new Disassembler(rdr);
return dasm.First();
}
示例3: BuildTest
private void BuildTest(params string[] bitStrings)
{
var bytes = bitStrings.Select(bits => base.ParseBitPattern(bits))
.SelectMany(u => new byte[] { (byte) u, (byte) (u >> 8), (byte) (u >> 16), (byte) (u >> 24) })
.ToArray();
image = new MemoryArea(Address.Ptr32(0x00100000), bytes);
}
示例4: UShortFixup
public void UShortFixup()
{
var bytes = new byte[] { 0x01, 0x02, 0x03 };
var img = new MemoryArea(Address.SegPtr(0x0C00, 0), bytes);
ushort newSeg = img.FixupLeUInt16(1, 0x4444);
Assert.AreEqual(0x4746, newSeg);
}
示例5: Setup
public void Setup()
{
mr = new MockRepository();
form = new MainForm();
sc = new ServiceContainer();
loader = mr.StrictMock<ILoader>();
dec = mr.StrictMock<IDecompiler>();
sc = new ServiceContainer();
uiSvc = new FakeShellUiService();
host = mr.StrictMock<DecompilerHost>();
memSvc = mr.StrictMock<ILowLevelViewService>();
var mem = new MemoryArea(Address.Ptr32(0x10000), new byte[1000]);
var imageMap = new SegmentMap(
mem.BaseAddress,
new ImageSegment("code", mem, AccessMode.ReadWriteExecute));
var arch = mr.StrictMock<IProcessorArchitecture>();
var platform = mr.StrictMock<IPlatform>();
program = new Program(imageMap, arch, platform);
project = new Project { Programs = { program } };
browserSvc = mr.StrictMock<IProjectBrowserService>();
sc.AddService<IDecompilerUIService>(uiSvc);
sc.AddService(typeof(IDecompilerShellUiService), uiSvc);
sc.AddService(typeof(IDecompilerService), new DecompilerService());
sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService());
sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener());
sc.AddService(typeof(IProjectBrowserService), browserSvc);
sc.AddService(typeof(ILowLevelViewService), memSvc);
sc.AddService<ILoader>(loader);
sc.AddService<DecompilerHost>(host);
i = new TestInitialPageInteractor(sc, dec);
}
示例6: Setup
public void Setup()
{
mem = new MemoryArea(Address.Ptr32(0x00100000), new byte[1024]);
var arch = new FakeArchitecture();
this.program = new Program
{
Architecture = arch,
SegmentMap = new SegmentMap(
mem.BaseAddress,
new ImageSegment(".text", mem, AccessMode.ReadWriteExecute)),
Platform = new DefaultPlatform(null, arch),
};
store = program.TypeStore;
factory = program.TypeFactory;
globals = program.Globals;
store.EnsureExpressionTypeVariable(factory, globals);
StructureType s = new StructureType(null, 0);
s.Fields.Add(0x00100000, PrimitiveType.Word32, null);
TypeVariable tvGlobals = store.EnsureExpressionTypeVariable(factory, globals);
EquivalenceClass eqGlobals = new EquivalenceClass(tvGlobals);
eqGlobals.DataType = s;
globals.TypeVariable.DataType = new Pointer(eqGlobals, 4);
globals.DataType = globals.TypeVariable.DataType;
}
示例7: ReadDataBlocks
public SegmentMap ReadDataBlocks(LeImageReader rdr)
{
var segs = new List<ImageSegment>();
var addrMin = Address.Ptr16(0);
var addrMax = Address.Ptr16(0);
for (;;)
{
var seg = ReadDataBlock(rdr);
if (seg == null)
break;
segs.Add(seg);
addrMax = Address.Max(addrMax, seg.MemoryArea.EndAddress);
}
var image = new MemoryArea(addrMin, new byte[addrMax - addrMin]);
foreach (var seg in segs)
{
var bytes = seg.MemoryArea.Bytes;
Array.Copy(
bytes, 0,
image.Bytes, seg.Address.ToUInt16(),
bytes.Length);
}
return new SegmentMap(
addrMin,
new ImageSegment("image", image, AccessMode.ReadWriteExecute));
}
示例8: Disassemble32
private X86Instruction Disassemble32(params byte[] bytes)
{
var img = new MemoryArea(Address.Ptr32(0x10000), bytes);
var rdr = img.CreateLeReader(img.BaseAddress);
var dasm = new X86Disassembler(ProcessorMode.Protected32, rdr, PrimitiveType.Word32, PrimitiveType.Word32, false);
return dasm.First();
}
示例9: BuildTest
private void BuildTest(params ushort[] words)
{
var bytes = words
.SelectMany(u => new byte[] { (byte)u, (byte)(u >> 8), })
.ToArray();
image = new MemoryArea(Address.Ptr32(0x00100000), bytes);
}
示例10: Sm_Overlaps
public void Sm_Overlaps()
{
SegmentMap im = new SegmentMap(Address.SegPtr(0x8000, 0));
var mem = new MemoryArea(im.BaseAddress, new byte[40]);
var seg = new ImageSegment("8000", Address.SegPtr(0x8000, 10), mem, AccessMode.ReadWrite);
im.AddSegment(seg);
}
示例11: DecSvc_DecompilerProjectName
public void DecSvc_DecompilerProjectName()
{
IDecompilerService svc = new DecompilerService();
var loader = mr.StrictMock<ILoader>();
var host = mr.StrictMock<DecompilerHost>();
var arch = mr.StrictMock<IProcessorArchitecture>();
var platform = mr.StrictMock<IPlatform>();
var fileName = OsPath.Relative("foo", "bar", "baz.exe");
var bytes = new byte[100];
var mem = new MemoryArea(Address.Ptr32(0x1000), bytes);
var imageMap = new SegmentMap(
mem.BaseAddress,
new ImageSegment("code", mem, AccessMode.ReadWriteExecute));
var prog = new Program(imageMap, arch, platform);
sc.AddService<DecompilerHost>(host);
platform.Stub(p => p.CreateMetadata()).Return(new TypeLibrary());
loader.Stub(l => l.LoadImageBytes(fileName, 0)).Return(bytes);
loader.Stub(l => l.LoadExecutable(fileName, bytes, null)).Return(prog);
loader.Replay();
var dec = new DecompilerDriver(loader, sc);
mr.ReplayAll();
svc.Decompiler = dec;
svc.Decompiler.Load(fileName);
Assert.IsNotNull(svc.Decompiler.Project);
Assert.AreEqual("baz.exe", svc.ProjectName, "Should have project name available.");
mr.VerifyAll();
}
示例12: RunTest
private void RunTest(string sExp, params byte[] bytes)
{
var image = new MemoryArea(Address.Ptr32(0x0100000), bytes);
var dasm = new CilDisassembler(image.CreateLeReader(0)).GetEnumerator();
Assert.IsTrue(dasm.MoveNext());
var instr = dasm.Current;
Assert.AreEqual(sExp, instr.ToString());
}
示例13: ReadLeUInt32
public void ReadLeUInt32()
{
MemoryArea img = new MemoryArea(Address.Ptr32(0x10000), new byte[] {
0x78, 0x56, 0x34, 0x12 });
Constant c = img.ReadLe(0, PrimitiveType.Word32);
Assert.AreSame(PrimitiveType.Word32, c.DataType);
Assert.AreEqual("0x12345678", c.ToString());
}
示例14: Given_Image
private ImageSegment Given_Image(int size)
{
var bytes = Enumerable.Range(0, size).Select(b => (byte)b).ToArray();
var mem = new MemoryArea(Address.Ptr32(0x1000000), bytes);
var seg = new ImageSegment(".text", mem, AccessMode.ReadExecute);
program.SegmentMap = new SegmentMap(mem.BaseAddress, seg);
return seg;
}
示例15: BuildTest
private void BuildTest(params ushort[] words)
{
var bytes = words
.SelectMany(
w => new byte[] { (byte)w, (byte)(w >> 8) })
.ToArray();
image = new MemoryArea(LoadAddress, bytes);
}