-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleFunctions.cs
More file actions
33 lines (29 loc) · 1.07 KB
/
Copy pathModuleFunctions.cs
File metadata and controls
33 lines (29 loc) · 1.07 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
using System.Diagnostics;
namespace SharpMemory;
public class ModuleFunctions
{
SharpMem SharpMem { get; init; }
public ModuleFunctions(SharpMem sharpMem)
{
SharpMem = sharpMem;
}
public long GetModuleAddress(string moduleName) => (long)GetModule(moduleName).BaseAddress;
public ProcessModule GetModule(string moduleName) => GetModuleAndDuplicates(moduleName).First();
public ProcessModule[] GetModuleAndDuplicates(string moduleName) => GetAllModules().Where(x => x.ModuleName.Equals(moduleName, StringComparison.InvariantCultureIgnoreCase)).ToArray();
public ProcessModule[] GetAllModules()
{
try
{
List<ProcessModule> list = new();
for(int i = 0; i < SharpMem.Process.Modules.Count; i++)
if(SharpMem.Process.Modules[i] != null)
list.Add(SharpMem.Process.Modules[i]);
return list.ToArray();
}
catch(Exception ex)
{
Debug.WriteLine("ModuleSearchException: " + ex.Message);
}
return null;
}
}