forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseFunctionNode.cs
More file actions
77 lines (60 loc) · 2.11 KB
/
BaseFunctionNode.cs
File metadata and controls
77 lines (60 loc) · 2.11 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
73
74
75
76
77
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 { get; set; }
public string Data { get; set; }
public string Instruction { get; set; }
}
protected IntPtr address = IntPtr.Zero;
protected readonly List<FunctionNodeInstruction> instructions = new List<FunctionNodeInstruction>();
protected Size DrawInstructions(ViewInfo view, int tx, int y)
{
Contract.Requires(view != null);
var origY = y;
var minWidth = 26 * view.Font.Width;
var maxWidth = 0;
using (var brush = new SolidBrush(view.Settings.HiddenColor))
{
foreach (var instruction in instructions)
{
y += view.Font.Height;
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;
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.ReadOnlyId, instruction.Instruction);
maxWidth = Math.Max(x - tx, maxWidth);
}
}
return new Size(maxWidth, y - origY);
}
protected void DisassembleRemoteCode(RemoteProcess process, IntPtr address, out int memorySize)
{
Contract.Requires(process != null);
memorySize = 0;
var disassembler = new Disassembler(process.CoreFunctions);
foreach (var instruction in disassembler.RemoteDisassembleFunction(process, address, 8192))
{
memorySize += instruction.Length;
instructions.Add(new FunctionNodeInstruction
{
Address = instruction.Address.ToString(Constants.AddressHexFormat),
Data = string.Join(" ", instruction.Data.Take(instruction.Length).Select(b => $"{b:X2}")),
Instruction = instruction.Instruction
});
}
}
}
}