-
Notifications
You must be signed in to change notification settings - Fork 404
Expand file tree
/
Copy pathBaseFunctionNode.cs
More file actions
72 lines (57 loc) · 1.96 KB
/
Copy pathBaseFunctionNode.cs
File metadata and controls
72 lines (57 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Drawing;
using System.Linq;
using ReClassNET.Memory;
using ReClassNET.UI;
namespace ReClassNET.Nodes
{
public abstract class BaseFunctionNode : BaseNode
{
protected class FunctionNodeInstruction
{
public string Address;
public string Data;
public string Instruction;
}
protected IntPtr address = IntPtr.Zero;
protected readonly List<FunctionNodeInstruction> instructions = new List<FunctionNodeInstruction>();
protected int DrawInstructions(ViewInfo view, int tx, int y)
{
Contract.Requires(view != null);
var minWidth = 26 * view.Font.Width;
foreach (var instruction in instructions)
{
y += view.Font.Height;
using (var brush = new SolidBrush(view.Settings.HiddenColor))
{
var x = AddText(view, tx, y, view.Settings.AddressColor, HotSpot.ReadOnlyId, instruction.Address) + 6;
view.Context.FillRectangle(brush, x, y, 1, view.Font.Height);
x += 6;
x = Math.Max(AddText(view, x, y, view.Settings.HexColor, HotSpot.ReadOnlyId, instruction.Data) + 6, x + minWidth);
view.Context.FillRectangle(brush, x, y, 1, view.Font.Height);
x += 6;
AddText(view, x, y, view.Settings.ValueColor, HotSpot.ReadOnlyId, instruction.Instruction);
}
}
return y;
}
protected void DisassembleRemoteCode(MemoryBuffer memory, IntPtr address, out int memorySize)
{
Contract.Requires(memory != null);
memorySize = 0;
var disassembler = new Disassembler(memory.Process.CoreFunctions);
foreach (var instruction in disassembler.RemoteDisassembleFunction(memory.Process, address, 8192))
{
memorySize += instruction.Length;
instructions.Add(new FunctionNodeInstruction
{
Address = instruction.Address.ToString(Constants.StringHexFormat),
Data = string.Join(" ", instruction.Data.Take(instruction.Length).Select(b => $"{b:X2}")),
Instruction = instruction.Instruction
});
}
}
}
}