OLD | NEW |
| (Empty) |
1 using System.Diagnostics; | |
2 using Google.MsAd7.BaseImpl.Interfaces; | |
3 using Microsoft.VisualStudio; | |
4 using Microsoft.VisualStudio.Debugger.Interop; | |
5 | |
6 namespace Google.MsAd7.BaseImpl | |
7 { | |
8 public class MemoryBytes : IDebugMemoryBytes2 | |
9 { | |
10 // Keep track of the top and bottom of the address space, in | |
11 // untrusted terms. | |
12 public static readonly ulong kMinAddr = 0; | |
13 public static readonly ulong kMaxAddr = 0xffffffff; | |
14 | |
15 public MemoryBytes(ISimpleDebugger dbg, ulong address, uint size) { | |
16 dbg_ = dbg; | |
17 address_ = address; | |
18 size_ = size; | |
19 } | |
20 | |
21 public ISimpleDebugger Dbg { | |
22 get { return dbg_; } | |
23 } | |
24 | |
25 public ulong Address { | |
26 get { return address_; } | |
27 } | |
28 | |
29 public ulong Size { | |
30 get { return size_; } | |
31 } | |
32 | |
33 #region Implementation of IDebugMemoryBytes2 | |
34 | |
35 public int ReadAt(IDebugMemoryContext2 pStartContext, uint dwCount, byte[] r
gbMemory, out uint pdwRead, ref uint pdwUnreadable) { | |
36 Debug.Assert(pStartContext is MemoryContext); | |
37 Debug.Assert(rgbMemory.Length >= dwCount); | |
38 | |
39 var context = (MemoryContext) pStartContext; | |
40 Debug.WriteLine(string.Format("MemoryBytes.ReadAt({0})", context.Address))
; | |
41 | |
42 pdwRead = dwCount; | |
43 pdwUnreadable = 0; | |
44 | |
45 if (context.Address + dwCount > kMaxAddr) { | |
46 pdwRead = (uint)(context.Address > kMaxAddr ? 0 : kMaxAddr - context.Add
ress); | |
47 pdwUnreadable = dwCount - pdwRead; | |
48 } | |
49 | |
50 dbg_.GetMemory(context.Address, rgbMemory, pdwRead); | |
51 | |
52 return VSConstants.S_OK; | |
53 } | |
54 | |
55 public int WriteAt(IDebugMemoryContext2 pStartContext, uint dwCount, byte[]
rgbMemory) { | |
56 Debug.Assert(pStartContext is MemoryContext); | |
57 Debug.Assert(rgbMemory.Length == dwCount); | |
58 | |
59 var context = (MemoryContext)pStartContext; | |
60 Debug.WriteLine(string.Format("MemoryBytes.WriteAt({0})", context.Address)
); | |
61 | |
62 dbg_.SetMemory(context.Address, rgbMemory, dwCount); | |
63 | |
64 return VSConstants.S_OK; | |
65 } | |
66 | |
67 public int GetSize(out ulong pqwSize) { | |
68 // TODO(ilewis): replace this bogus impl with a real one | |
69 pqwSize = 4096; | |
70 return VSConstants.S_OK; | |
71 } | |
72 | |
73 #endregion | |
74 | |
75 private ISimpleDebugger dbg_; | |
76 private ulong address_; | |
77 private uint size_; | |
78 } | |
79 } | |
OLD | NEW |