-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDolphinAccessor.cs
More file actions
73 lines (62 loc) · 2.17 KB
/
DolphinAccessor.cs
File metadata and controls
73 lines (62 loc) · 2.17 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
using System;
namespace DolphinMemoryWrapper {
public enum DolphinStatus {
Hooked,
NotRunning,
NotEmulating,
Unhooked
}
public class DolphinAccessor {
protected DolphinProcess Process { get; set; }
public DolphinStatus Status { get; protected set; }
public IntPtr EmuStartAddress {
get {
return this.Process.EmuStartAddress;
}
}
public bool EmuStartAddressBacked {
get {
return this.Process.EmuStartAddressBacked;
}
}
public DolphinAccessor() {
this.Process = getNewDolphinProcess();
this.Status = DolphinStatus.Unhooked;
}
public bool hook() {
if (!this.Process.findProcess()) {
this.Status = DolphinStatus.NotRunning;
Console.WriteLine("Dolphin not running");
} else if (!this.Process.findEmuStartAddress()) {
this.Status = DolphinStatus.NotEmulating;
Console.WriteLine("Dolphin not emulating");
} else {
this.Status = DolphinStatus.Hooked;
Console.WriteLine("Dolphin hooked");
return true;
}
return false;
}
public void unhook() {
this.Process = getNewDolphinProcess();
this.Status = DolphinStatus.Unhooked;
}
public bool read(long offset, MemoryType type, out byte[] buffer, bool reverseBytes = false) {
if (this.Status == DolphinStatus.Hooked) {
return this.Process.read(offset, type, out buffer, reverseBytes);
}
buffer = new byte[0];
return false;
}
public bool write(long offset, byte[] buffer, MemoryType type, bool reverseBytes = false) {
if (this.Status == DolphinStatus.Hooked) {
return this.Process.write(offset, buffer, type, reverseBytes);
}
return false;
}
protected DolphinProcess getNewDolphinProcess() {
// TODO: Linux
return new WindowsDolphinProcess();
}
}
}