本文整理汇总了C#中TargetMemoryAccess.ReadAddress方法的典型用法代码示例。如果您正苦于以下问题:C# TargetMemoryAccess.ReadAddress方法的具体用法?C# TargetMemoryAccess.ReadAddress怎么用?C# TargetMemoryAccess.ReadAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TargetMemoryAccess
的用法示例。
在下文中一共展示了TargetMemoryAccess.ReadAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrentType
internal override TargetType GetCurrentType(TargetMemoryAccess target)
{
// location.Address resolves to the address of the MonoObject,
// dereferencing it once gives us the vtable, dereferencing it
// twice the class.
TargetAddress address;
address = target.ReadAddress (Location.GetAddress (target));
address = target.ReadAddress (address);
return Type.File.MonoLanguage.ReadMonoClass (target, address);
}
示例2: GetAddress
internal override TargetAddress GetAddress(TargetMemoryAccess target)
{
TargetAddress address = reference.GetAddress (target);
if (address.IsNull)
return TargetAddress.Null;
else
return target.ReadAddress (address);
}
示例3: GetValue
void GetValue(TargetMemoryAccess target, Registers regs,
TargetAddress cfa, int reg, Column column)
{
switch (column.State) {
case State.Register: {
GetRegisterValue (regs, reg, column);
break;
}
case State.SameValue:
regs [GetArchRegister (reg)].Valid = true;
break;
case State.Undefined:
break;
case State.Offset: {
TargetAddress addr = cfa + column.Offset;
long value = target.ReadAddress (addr).Address;
regs [GetArchRegister (reg)].SetValue (address, value);
break;
}
default:
throw new NotSupportedException ();
}
}
示例4: unwind_method
StackFrame unwind_method(StackFrame frame, TargetMemoryAccess memory, byte[] code,
int pos, int offset)
{
Registers old_regs = frame.Registers;
Registers regs = CopyRegisters (old_regs);
if (!old_regs [(int) X86_Register.RBP].Valid)
return null;
TargetAddress rbp = new TargetAddress (
memory.AddressDomain, old_regs [(int) X86_Register.RBP].Value);
int addr_size = TargetAddressSize;
TargetAddress new_rbp = memory.ReadAddress (rbp);
regs [(int) X86_Register.RBP].SetValue (rbp, new_rbp);
TargetAddress new_rip = memory.ReadAddress (rbp + addr_size);
regs [(int) X86_Register.RIP].SetValue (rbp + addr_size, new_rip);
TargetAddress new_rsp = rbp + 2 * addr_size;
regs [(int) X86_Register.RSP].SetValue (rbp, new_rsp);
rbp -= addr_size;
int length = System.Math.Min (code.Length, offset);
while (pos < length) {
byte opcode = code [pos++];
long value;
if ((opcode == 0x41) && (pos < length)) {
byte opcode2 = code [pos++];
if ((opcode2 < 0x50) || (opcode2 > 0x57))
break;
switch (opcode2) {
case 0x50: /* r8 */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.R8].SetValue (rbp, value);
break;
case 0x51: /* r9 */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.R9].SetValue (rbp, value);
break;
case 0x52: /* r10 */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.R10].SetValue (rbp, value);
break;
case 0x53: /* r11 */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.R11].SetValue (rbp, value);
break;
case 0x54: /* r12 */
value = (long) memory.ReadAddress (rbp).Address;
regs [(int) X86_Register.R12].SetValue (rbp, value);
break;
case 0x55: /* r13 */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.R13].SetValue (rbp, value);
break;
case 0x56: /* r14 */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.R14].SetValue (rbp, value);
break;
case 0x57: /* r15 */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.R15].SetValue (rbp, value);
break;
}
} else {
if ((opcode < 0x50) || (opcode > 0x57))
break;
switch (opcode) {
case 0x50: /* rax */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.RAX].SetValue (rbp, value);
break;
case 0x51: /* rcx */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.RCX].SetValue (rbp, value);
break;
case 0x52: /* rdx */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.RDX].SetValue (rbp, value);
break;
case 0x53: /* rbx */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.RBX].SetValue (rbp, value);
break;
case 0x56: /* rsi */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.RSI].SetValue (rbp, value);
break;
case 0x57: /* rdi */
value = memory.ReadLongInteger (rbp);
regs [(int) X86_Register.RDI].SetValue (rbp, value);
break;
}
}
//.........这里部分代码省略.........
示例5: MonoClassGetParent
public TargetAddress MonoClassGetParent(TargetMemoryAccess memory,
TargetAddress klass)
{
return memory.ReadAddress (klass + MonoMetadataInfo.KlassParentOffset);
}
示例6: GetLMF
internal override StackFrame GetLMF(ThreadServant thread, TargetMemoryAccess memory, ref TargetAddress lmf_address)
{
TargetAddress lmf = lmf_address;
TargetBinaryReader reader = memory.ReadMemory (lmf_address, 88).GetReader ();
lmf_address = reader.ReadTargetAddress (); // prev
reader.ReadTargetAddress ();
reader.ReadTargetAddress (); // method
TargetAddress rip = reader.ReadTargetAddress ();
if (lmf_address.IsNull)
return null;
TargetAddress rbx = reader.ReadTargetAddress ();
TargetAddress rbp = reader.ReadTargetAddress ();
TargetAddress rsp = reader.ReadTargetAddress ();
TargetAddress r12 = reader.ReadTargetAddress ();
TargetAddress r13 = reader.ReadTargetAddress ();
TargetAddress r14 = reader.ReadTargetAddress ();
TargetAddress r15 = reader.ReadTargetAddress ();
Registers regs = new Registers (this);
if ((lmf_address.Address & 1) == 0) {
rip = memory.ReadAddress (rsp - 8);
regs [(int) X86_Register.RIP].SetValue (rsp - 8, rip);
regs [(int) X86_Register.RBP].SetValue (lmf + 40, rbp);
} else {
TargetAddress new_rbp = memory.ReadAddress (rbp);
regs [(int) X86_Register.RIP].SetValue (lmf + 24, rip);
regs [(int) X86_Register.RBP].SetValue (rbp, new_rbp);
rbp = new_rbp;
lmf_address--;
}
regs [(int) X86_Register.RBX].SetValue (lmf + 32, rbx);
regs [(int) X86_Register.RSP].SetValue (lmf + 48, rsp);
regs [(int) X86_Register.R12].SetValue (lmf + 56, r12);
regs [(int) X86_Register.R13].SetValue (lmf + 64, r13);
regs [(int) X86_Register.R14].SetValue (lmf + 72, r14);
regs [(int) X86_Register.R15].SetValue (lmf + 80, r15);
return CreateFrame (thread.Client, FrameType.LMF, memory, rip, rsp, rbp, regs);
}
示例7: read_prologue
StackFrame read_prologue(StackFrame frame, TargetMemoryAccess memory,
byte[] code, int offset)
{
int length = code.Length;
int pos = 0;
if (length < 4)
return null;
while ((pos < length) &&
(code [pos] == 0x90) || (code [pos] == 0xcc))
pos++;
if (pos+5 >= length) {
// unknown prologue
return null;
}
if (pos >= offset) {
Registers regs = CopyRegisters (frame.Registers);
TargetAddress new_rip = memory.ReadAddress (frame.StackPointer);
regs [(int) X86_Register.RIP].SetValue (frame.StackPointer, new_rip);
TargetAddress new_rsp = frame.StackPointer + TargetAddressSize;
TargetAddress new_rbp = frame.FrameAddress;
regs [(int) X86_Register.RSP].SetValue (new_rsp);
return CreateFrame (frame.Thread, FrameType.Normal, memory, new_rip, new_rsp, new_rbp, regs);
}
// push %ebp
if (code [pos++] != 0x55) {
// unknown prologue
return null;
}
if (pos >= offset) {
Registers regs = CopyRegisters (frame.Registers);
int addr_size = TargetAddressSize;
TargetAddress new_rbp = memory.ReadAddress (frame.StackPointer);
regs [(int) X86_Register.RBP].SetValue (frame.StackPointer, new_rbp);
TargetAddress new_rsp = frame.StackPointer + addr_size;
TargetAddress new_rip = memory.ReadAddress (new_rsp);
regs [(int) X86_Register.RIP].SetValue (new_rsp, new_rip);
new_rsp -= addr_size;
regs [(int) X86_Register.RSP].SetValue (new_rsp);
return CreateFrame (frame.Thread, FrameType.Normal, memory, new_rip, new_rsp, new_rbp, regs);
}
if (code [pos++] != 0x48) {
// unknown prologue
return null;
}
// mov %ebp, %esp
if (((code [pos] != 0x8b) || (code [pos+1] != 0xec)) &&
((code [pos] != 0x89) || (code [pos+1] != 0xe5))) {
// unknown prologue
return null;
}
pos += 2;
if (pos >= offset)
return null;
return unwind_method (frame, memory, code, pos, offset);
}
示例8: do_read_symbol_table
// This method reads the MonoDebuggerSymbolTable structure
// (struct definition is in mono-debug-debugger.h)
void do_read_symbol_table(TargetMemoryAccess memory)
{
TargetAddress symtab_address = memory.ReadAddress (info.SymbolTable);
if (symtab_address.IsNull)
throw new SymbolTableException ("Symbol table is null.");
TargetReader header = new TargetReader (
memory.ReadMemory (symtab_address, info.SymbolTableSize));
long magic = header.BinaryReader.ReadInt64 ();
if (magic != MonoDebuggerInfo.DynamicMagic)
throw new SymbolTableException (
"Debugger symbol table has unknown magic {0:x}.", magic);
int version = header.ReadInteger ();
if (version < MonoDebuggerInfo.MinDynamicVersion)
throw new SymbolTableException (
"Debugger symbol table has version {0}, but " +
"expected at least {1}.", version,
MonoDebuggerInfo.MinDynamicVersion);
if (version > MonoDebuggerInfo.MaxDynamicVersion)
throw new SymbolTableException (
"Debugger symbol table has version {0}, but " +
"expected at most {1}.", version,
MonoDebuggerInfo.MaxDynamicVersion);
int total_size = header.ReadInteger ();
if (total_size != info.SymbolTableSize)
throw new SymbolTableException (
"Debugger symbol table has size {0}, but " +
"expected {1}.", total_size, info.SymbolTableSize);
TargetAddress corlib_address = header.ReadAddress ();
TargetAddress global_data_table_ptr = header.ReadAddress ();
TargetAddress data_table_list = header.ReadAddress ();
TargetAddress symfile_by_index = header.ReadAddress ();
if (corlib_address.IsNull)
throw new SymbolTableException ("Corlib address is null.");
corlib = load_symfile (memory, corlib_address);
if (corlib == null)
throw new SymbolTableException ("Cannot read corlib!");
TargetAddress ptr = symfile_by_index;
while (!ptr.IsNull) {
TargetAddress next_ptr = memory.ReadAddress (ptr);
TargetAddress address = memory.ReadAddress (
ptr + memory.TargetMemoryInfo.TargetAddressSize);
ptr = next_ptr;
load_symfile (memory, address);
}
ptr = data_table_list;
while (!ptr.IsNull) {
TargetAddress next_ptr = memory.ReadAddress (ptr);
TargetAddress address = memory.ReadAddress (
ptr + memory.TargetMemoryInfo.TargetAddressSize);
ptr = next_ptr;
add_data_table (memory, address);
}
global_data_table = new GlobalDataTable (this, global_data_table_ptr);
}
示例9: Read
public void Read(TargetMemoryAccess memory)
{
int address_size = memory.TargetMemoryInfo.TargetAddressSize;
int header_size = 16 + address_size;
if (first_chunk.IsNull) {
first_chunk = memory.ReadAddress (TableAddress + 8);
current_chunk = first_chunk;
}
if (current_chunk.IsNull)
return;
again:
TargetReader reader = new TargetReader (
memory.ReadMemory (current_chunk, header_size));
reader.ReadInteger (); /* size */
int allocated_size = reader.ReadInteger ();
int current_offset = reader.ReadInteger ();
reader.ReadInteger (); /* dummy */
TargetAddress next = reader.ReadAddress ();
read_data_items (memory, current_chunk + header_size,
last_offset, current_offset);
last_offset = current_offset;
if (!next.IsNull && (current_offset == allocated_size)) {
current_chunk = next;
last_offset = 0;
goto again;
}
}
示例10: GetLMF
internal override StackFrame GetLMF(ThreadServant thread, TargetMemoryAccess memory,
ref TargetAddress lmf_address)
{
TargetAddress lmf = lmf_address;
TargetBinaryReader reader = memory.ReadMemory (lmf, 36).GetReader ();
lmf_address = reader.ReadTargetAddress (); // prev
reader.Position = 16;
TargetAddress ebx = reader.ReadTargetAddress ();
TargetAddress edi = reader.ReadTargetAddress ();
TargetAddress esi = reader.ReadTargetAddress ();
TargetAddress ebp = reader.ReadTargetAddress ();
TargetAddress eip = reader.ReadTargetAddress ();
Registers regs = new Registers (this);
regs [(int) X86_Register.RBX].SetValue (lmf + 16, ebx);
regs [(int) X86_Register.RDI].SetValue (lmf + 20, edi);
regs [(int) X86_Register.RSI].SetValue (lmf + 24, esi);
regs [(int) X86_Register.RBP].SetValue (lmf + 28, ebp);
regs [(int) X86_Register.RIP].SetValue (lmf + 32, eip);
TargetAddress new_ebp = memory.ReadAddress (ebp);
regs [(int) X86_Register.RBP].SetValue (ebp, new_ebp);
TargetAddress new_esp = ebp + 8;
regs [(int) X86_Register.RSP].SetValue (ebp, new_esp);
return CreateFrame (thread.Client, FrameType.LMF, memory, eip, new_esp, new_ebp, regs);
}
示例11: UnwindStack
internal override StackFrame UnwindStack(StackFrame frame, TargetMemoryAccess memory,
byte[] code, int offset)
{
StackFrame new_frame;
if ((code != null) && (code.Length > 3)) {
new_frame = read_prologue (frame, memory, code, offset);
if (new_frame != null)
return new_frame;
}
TargetAddress ebp = frame.FrameAddress;
new_frame = do_hacks (frame, memory);
if (new_frame != null)
return new_frame;
int addr_size = TargetAddressSize;
Registers regs = new Registers (this);
TargetAddress new_ebp = memory.ReadAddress (ebp);
regs [(int) X86_Register.RBP].SetValue (ebp, new_ebp);
TargetAddress new_eip = memory.ReadAddress (ebp + addr_size);
regs [(int) X86_Register.RIP].SetValue (ebp + addr_size, new_eip);
TargetAddress new_esp = ebp + 2 * addr_size;
regs [(int) X86_Register.RSP].SetValue (ebp, new_esp);
ebp -= addr_size;
return CreateFrame (frame.Thread, FrameType.Normal, memory, new_eip, new_esp, new_ebp, regs);
}
示例12: MonoArrayTypeGetBounds
internal void MonoArrayTypeGetBounds(TargetMemoryAccess memory,
TargetAddress data)
{
//
// FIXME: Only check whether the low bounds are all zero
//
int num_sizes = memory.ReadByte (data + memory.TargetAddressSize + 1);
if (num_sizes != 0)
throw new InternalError ();
int num_lobounds = memory.ReadByte (data + memory.TargetAddressSize + 2);
if (num_lobounds == 0)
return;
TargetAddress array = memory.ReadAddress (data + 3 * memory.TargetAddressSize);
TargetBinaryReader bounds = memory.ReadMemory (array, num_lobounds * 4).GetReader ();
for (int i = 0; i < num_lobounds; i++) {
int bound = bounds.ReadInt32 ();
if (bound != 0)
throw new InternalError ();
}
}
示例13: GetBooleanClass
//
// Fundamental types
//
public TargetAddress GetBooleanClass(TargetMemoryAccess memory)
{
return memory.ReadAddress (MonoMetadataInfo.MonoDefaultsAddress +
MonoMetadataInfo.MonoDefaultsBooleanOffset);
}
示例14: MonoTypeGetData
public TargetAddress MonoTypeGetData(TargetMemoryAccess memory, TargetAddress type)
{
return memory.ReadAddress (type);
}
示例15: MonoMethodGetClass
public TargetAddress MonoMethodGetClass(TargetMemoryAccess memory, TargetAddress method)
{
return memory.ReadAddress (method + MonoMetadataInfo.MonoMethodKlassOffset);
}