-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMod.cs
77 lines (66 loc) · 2.5 KB
/
Mod.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Reloaded.Hooks.ReloadedII.Interfaces;
using Reloaded.Memory.Interfaces;
using Reloaded.Memory.Sigscan;
using Reloaded.Memory;
using Reloaded.Mod.Interfaces;
using System.Diagnostics;
using hifipc.nopillarbox.Template;
namespace hifipc.nopillarbox
{
/// <summary>
/// Your mod logic goes here.
/// </summary>
public class Mod : ModBase // <= Do not Remove.
{
/// <summary>
/// Provides access to the mod loader API.
/// </summary>
private readonly IModLoader _modLoader;
/// <summary>
/// Provides access to the Reloaded.Hooks API.
/// </summary>
/// <remarks>This is null if you remove dependency on Reloaded.SharedLib.Hooks in your mod.</remarks>
private readonly IReloadedHooks? _hooks;
/// <summary>
/// Provides access to the Reloaded logger.
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Entry point into the mod, instance that created this class.
/// </summary>
private readonly IMod _owner;
/// <summary>
/// The configuration of the currently executing mod.
/// </summary>
private readonly IModConfig _modConfig;
public Mod(ModContext context)
{
_modLoader = context.ModLoader;
_hooks = context.Hooks;
_logger = context.Logger;
_owner = context.Owner;
_modConfig = context.ModConfig;
var currentProcess = Process.GetCurrentProcess();
var mainModule = currentProcess.MainModule;
var scanner = new Scanner(currentProcess, mainModule);
var res = scanner.FindPattern("F6 41 30 01 45 0F 29 43 ??");
if (res.Found)
{
nint address = mainModule!.BaseAddress + res.Offset;
_logger.WriteLineAsync($"[{_modConfig.ModId}] Signature found at 0x{address:X}");
Memory.Instance.SafeWrite(
(nuint)(address + 3), new byte[] { 0x00 }
);
}
else
{
_logger.WriteLineAsync($"[{_modConfig.ModId}] Signature not found, mod will not work!", System.Drawing.Color.Red);
}
}
#region For Exports, Serialization etc.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public Mod() { }
#pragma warning restore CS8618
#endregion
}
}