-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
300 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/plugins/osu/EmberMemoryReader.Abstract/Data/GlobalGameModerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using EmberKernel.Services.EventBus; | ||
using EmberMemory.Components.Collector; | ||
using EmberMemory.Readers; | ||
using System; | ||
|
||
namespace EmberMemoryReader.Abstract.Data | ||
{ | ||
public class GlobalGameModerator : IComparableCollector<GlobalGameModeratorInfo> | ||
{ | ||
|
||
private static readonly string GlobalModsPattern = "\x8B\xF1\xA1\x00\x00\x00\x00\x25\x00\x00\x40\x00\x85\xC0"; | ||
private static readonly string GlobalModsMask = "xxx????xxxxxxx"; | ||
|
||
public int ReadInterval { get; set; } = 500; | ||
public int RetryLimit { get; set; } = int.MaxValue; | ||
|
||
private DirectMemoryReader Reader { get; } | ||
public GlobalGameModerator(DirectMemoryReader reader) | ||
{ | ||
Reader = reader; | ||
} | ||
|
||
private IntPtr ModAddress; | ||
public bool TryInitialize() | ||
{ | ||
try | ||
{ | ||
Reader.Reload(); | ||
Reader.TryFindPattern(GlobalModsPattern.ToBytes(), GlobalModsMask, 3, out ModAddress); | ||
if (!Reader.TryReadIntPtr(ModAddress, out ModAddress)) return false; | ||
return true; | ||
} | ||
finally | ||
{ | ||
Reader.ResetRegion(); | ||
} | ||
} | ||
|
||
public bool TryRead(out Event result) | ||
{ | ||
if (Reader.TryReadInt(ModAddress, out var listeningMods)) | ||
{ | ||
result = new GlobalGameModeratorInfo() { GlobalRawModerator = listeningMods }; | ||
return true; | ||
} | ||
result = null; | ||
return false; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/plugins/osu/EmberMemoryReader.Abstract/Data/GlobalGameModeratorInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using EmberKernel.Services.EventBus; | ||
using System; | ||
|
||
namespace EmberMemoryReader.Abstract.Data | ||
{ | ||
public class GlobalGameModeratorInfo : Event<GlobalGameModeratorInfo>, IComparable<GlobalGameModeratorInfo>, IEquatable<GlobalGameModeratorInfo> | ||
{ | ||
public int GlobalRawModerator { get; set; } | ||
public int CompareTo(GlobalGameModeratorInfo other) | ||
{ | ||
return GlobalRawModerator - other.GlobalRawModerator; | ||
} | ||
|
||
public bool Equals(GlobalGameModeratorInfo other) | ||
{ | ||
return GlobalRawModerator == other.GlobalRawModerator; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.