-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPS2.cs
63 lines (52 loc) · 1.66 KB
/
PS2.cs
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
using System;
using System.Runtime.InteropServices;
using LiveSplit.EMUHELP;
using LiveSplit.EMUHELP.PS2;
public class Playstation2 : PS2 { }
public class PS2 : HelperBase
{
public PS2(bool generateCode) : base(generateCode)
{
var ProcessNames = new string[]
{
"pcsx2x64",
"pcsx2-qt",
"pcsx2x64-avx2",
"pcsx2-avx2",
"pcsx2",
"retroarch",
};
GameProcess = new ProcessHook(ProcessNames);
Debugs.Info(" => PS2 Helper started");
}
public PS2()
: this(true) { }
protected override void InitActions()
{
Emu = Game.ProcessName.ToLower() switch {
"pcsx2x64" or "pcsx2-qt" or "pcsx2x64-avx2" or "pcsx2-avx2" or "pcsx2" => new PCSX2(this),
"retroarch" => new Retroarch(this),
_ => throw new NotImplementedException(),
};
}
internal override bool IsAddressInBounds<T>(ulong address)
{
var size = address + (ulong)Marshal.SizeOf<T>();
return address >= 0x00100000 && size <= 0x02000000;
}
internal override bool IsStringAddressInBounds(ulong address, int stringLength)
{
var size = address + (ulong)stringLength;
return address >= 0x00100000 && size <= 0x02000000;
}
public override bool TryGetAddress(ulong address, out IntPtr realAddress)
{
realAddress = default;
if (Emu.GetMemoryAddress(0) == null)
return false;
if (address < 0x00100000 || address > 0x01FFFFFF)
return false;
realAddress = (IntPtr)((ulong)Emu.GetMemoryAddress(0) + address);
return true;
}
}