返回提交历史
Modified
XFEExtension.NetCore.MemoryEditor/MemoryEditor.cs
+11
-2
Modified
XFEExtension.NetCore.MemoryEditor/MemoryListener.cs
+6
-4
Modified
XFEExtension.NetCore.MemoryEditor/MemoryValue.cs
+2
-1
Modified
XFEExtension.NetCore.MemoryEditor/XFEExtension.NetCore.MemoryEditor.csproj
+4
-3
XFEstudio/XFEExtension.NetCore.MemoryEditor
add-现在监听器可以自定义监听器标识名了
7ed01da
代码差异
4 个文件
+23
-10
@@ -49,7 +49,16 @@ public partial class MemoryEditor
49
49
/// </summary>
50
50
/// <typeparam name="T">待监听的内存的数据类型(int,float,long等)</typeparam>
51
51
/// <param name="address">待监听的内存地址</param>
52
public void AddListener<T>(nint address) where T : struct => _ = Listener.StartListen<T>(address);
52
/// <param name="customName">自定义监听器标识名</param>
53
public void AddListener<T>(nint address, string customName = "") where T : struct => _ = Listener.StartListen<T>(address, customName);
54
/// <summary>
55
/// 添加监听器
56
/// </summary>
57
/// <typeparam name="T">待监听的内存的数据类型(int,float,long等)</typeparam>
58
/// <param name="address">待监听的内存地址</param>
59
/// <param name="delay">检测频率,以毫秒为单位</param>
60
/// <param name="customName">自定义监听器标识名</param>
61
public void AddListener<T>(nint address, int delay, string customName = "") where T : struct => _ = Listener.StartListen<T>(address, delay, customName);
53
62
/// <summary>
54
63
/// 移除并停止指定监听器
55
64
/// </summary>
@@ -58,7 +67,7 @@ public partial class MemoryEditor
58
67
/// <summary>
59
68
/// 移除所有监听器
60
69
/// </summary>
61
public void RemoveListeners()=> Listener.StopListener();
70
public void RemoveListeners() => Listener.StopListener();
62
71
/// <summary>
63
72
/// 解析基址对应的实际地址
64
73
/// </summary>
@@ -26,8 +26,9 @@ public class MemoryListener : IDisposable
26
26
/// </summary>
27
27
/// <typeparam name="T">待监听的内存的数据类型(int,float,long等)</typeparam>
28
28
/// <param name="memoryAddress">待监听的内存地址</param>
29
/// <param name="customName">自定义监听器标识名</param>
29
30
/// <returns></returns>
30
public async Task StartListen<T>(nint memoryAddress) where T : struct
31
public async Task StartListen<T>(nint memoryAddress, string customName = "") where T : struct
31
32
{
32
33
IsListening = true;
33
34
listeningList.Add(memoryAddress, true);
@@ -39,7 +40,7 @@ public class MemoryListener : IDisposable
39
40
var currentValue = MemoryEditor.ReadMemory<T>(ProcessHandler, memoryAddress);
40
41
if (!currentValue.Equals(lastValue))
41
42
{
42
ValueChanged?.Invoke(memoryAddress, new(lastValue, currentValue));
43
ValueChanged?.Invoke(memoryAddress, new(lastValue, currentValue, customName));
43
44
lastValue = currentValue;
44
45
}
45
46
}
@@ -52,8 +53,9 @@ public class MemoryListener : IDisposable
52
53
/// <typeparam name="T">待监听的内存的数据类型(int,float,long等)</typeparam>
53
54
/// <param name="memoryAddress">待监听的内存地址</param>
54
55
/// <param name="delay">检测频率,以毫秒为单位</param>
56
/// <param name="customName">自定义监听器标识名</param>
55
57
/// <returns></returns>
56
public async Task StartListen<T>(nint memoryAddress, int delay = 10) where T : struct
58
public async Task StartListen<T>(nint memoryAddress, int delay, string customName = "") where T : struct
57
59
{
58
60
IsListening = true;
59
61
listeningList.Add(memoryAddress, true);
@@ -65,7 +67,7 @@ public class MemoryListener : IDisposable
65
67
var currentValue = MemoryEditor.ReadMemory<T>(ProcessHandler, memoryAddress);
66
68
if (!currentValue.Equals(lastValue))
67
69
{
68
ValueChanged?.Invoke(memoryAddress, new(lastValue, currentValue));
70
ValueChanged?.Invoke(memoryAddress, new(lastValue, currentValue, customName));
69
71
currentValue = lastValue;
70
72
}
71
73
Thread.Sleep(delay);
@@ -5,4 +5,5 @@
5
5
/// </summary>
6
6
/// <param name="PreviousValue">改变前的值</param>
7
7
/// <param name="CurrentValue">当前值</param>
8
public record struct MemoryValue(object PreviousValue, object CurrentValue) { }
8
/// <param name="CustomName">自定义标识名</param>
9
public record struct MemoryValue(object PreviousValue, object CurrentValue, string? CustomName) { }
@@ -13,14 +13,15 @@
13
13
<PackageReadmeFile>README.md</PackageReadmeFile>
14
14
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.MemoryEditor.git</RepositoryUrl>
15
15
<PackageTags>XFE;XFEExtension;MemoryEdit;Memory</PackageTags>
16
<PackageReleaseNotes>fix-修复监听一直触发的bug
17
add-现在监听将使用MemoryValue类</PackageReleaseNotes>
16
<PackageReleaseNotes>fix-修复监听器地址不能正常传输的bug
17
add-现在监听器可以自定义监听器标识名了
18
</PackageReleaseNotes>
18
19
<Copyright>寰宇朽力网络科技版权所有</Copyright>
19
20
<PackageProjectUrl>https://github.com/XFEstudio/XFEExtension.NetCore.MemoryEditor.git</PackageProjectUrl>
20
21
<GenerateDocumentationFile>True</GenerateDocumentationFile>
21
22
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
22
23
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
23
<Version>1.2.0</Version>
24
<Version>1.3.0</Version>
24
25
</PropertyGroup>
25
26
26
27
<ItemGroup>