fix: actually remove afk
This commit is contained in:
parent
f430b035c4
commit
2cdc4e5441
|
@ -19,6 +19,8 @@ namespace XIVChatPlugin {
|
|||
|
||||
private delegate byte IsInputDelegate(IntPtr a1);
|
||||
|
||||
private delegate byte IsInputAfkDelegate();
|
||||
|
||||
private delegate byte RequestFriendListDelegate(IntPtr manager);
|
||||
|
||||
private delegate int FormatFriendListNameDelegate(long a1, long a2, long a3, int a4, IntPtr data, long a6);
|
||||
|
@ -36,6 +38,7 @@ namespace XIVChatPlugin {
|
|||
private delegate IntPtr XivStringDtorDelegate(IntPtr memory);
|
||||
|
||||
private readonly Hook<IsInputDelegate>? _isInputHook;
|
||||
private readonly Hook<IsInputAfkDelegate>? _isInputAfkHook;
|
||||
private readonly Hook<RequestFriendListDelegate>? _friendListHook;
|
||||
private readonly Hook<FormatFriendListNameDelegate>? _formatHook;
|
||||
private readonly Hook<OnReceiveFriendListChunkDelegate>? _receiveChunkHook;
|
||||
|
@ -48,7 +51,14 @@ namespace XIVChatPlugin {
|
|||
private readonly XivStringCtorDelegate? _xivStringCtor;
|
||||
private readonly XivStringDtorDelegate? _xivStringDtor;
|
||||
|
||||
internal bool HadInput { get; set; }
|
||||
[Flags]
|
||||
private enum InputSetters {
|
||||
None = 0,
|
||||
Normal = 1 << 0,
|
||||
Afk = 1 << 1,
|
||||
}
|
||||
|
||||
private InputSetters HadInput { get; set; } = InputSetters.None;
|
||||
private IntPtr UiModulePtr { get; }
|
||||
private IntPtr ColourHandler { get; }
|
||||
private IntPtr ColourLookup { get; }
|
||||
|
@ -70,6 +80,7 @@ namespace XIVChatPlugin {
|
|||
var getUiModulePtr = this.Plugin.ScanText("E8 ?? ?? ?? ?? 48 83 7F ?? 00 48 8B F0");
|
||||
var easierProcessChatBoxPtr = this.Plugin.ScanText("48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9");
|
||||
var inputPtr = this.Plugin.ScanText("80 B9 ?? ?? ?? ?? ?? 0F 9C C0");
|
||||
var inputAfkPtr = this.Plugin.ScanText("E8 ?? ?? ?? ?? 0F 28 74 24 ?? 0F B6 F0");
|
||||
var friendListPtr = this.Plugin.ScanText("40 53 48 81 EC 80 0F 00 00 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 48 8B D9 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 85 C0 0F 84 ?? ?? ?? ?? 44 0F B6 43 ?? 33 C9");
|
||||
var formatPtr = this.Plugin.ScanText("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 41 56 48 83 EC 30 48 8B 6C 24 ??");
|
||||
var recvChunkPtr = this.Plugin.ScanText("48 89 5C 24 ?? 56 48 83 EC 20 48 8B 0D ?? ?? ?? ?? 48 8B F2");
|
||||
|
@ -156,7 +167,14 @@ namespace XIVChatPlugin {
|
|||
|
||||
if (inputPtr != IntPtr.Zero) {
|
||||
this._isInputHook = new Hook<IsInputDelegate>(inputPtr, new IsInputDelegate(this.IsInputDetour));
|
||||
this._isInputHook.Enable();
|
||||
} else {
|
||||
PluginLog.Warning("Pointer was null, disabling hook: {0}", nameof(inputPtr));
|
||||
}
|
||||
|
||||
if (inputAfkPtr != IntPtr.Zero) {
|
||||
this._isInputAfkHook = new Hook<IsInputAfkDelegate>(inputAfkPtr, new IsInputAfkDelegate(this.IsInputAfkDetour));
|
||||
} else {
|
||||
PluginLog.Warning("Pointer was null, disabling hook: {0}", nameof(inputAfkPtr));
|
||||
}
|
||||
|
||||
this._friendListHook?.Enable();
|
||||
|
@ -164,6 +182,7 @@ namespace XIVChatPlugin {
|
|||
this._receiveChunkHook?.Enable();
|
||||
this._chatChannelChangeHook?.Enable();
|
||||
this._isInputHook?.Enable();
|
||||
this._isInputAfkHook?.Enable();
|
||||
|
||||
if (this._xivStringCtor != null && this._xivStringDtor != null) {
|
||||
this._emptyXivString = Marshal.AllocHGlobal(0x68);
|
||||
|
@ -172,11 +191,20 @@ namespace XIVChatPlugin {
|
|||
}
|
||||
|
||||
private byte IsInputDetour(IntPtr a1) {
|
||||
if (!this.Plugin.Config.MessagesCountAsInput || !this.HadInput) {
|
||||
if (!this.Plugin.Config.MessagesCountAsInput || this.HadInput == InputSetters.None) {
|
||||
return this._isInputHook!.Original(a1);
|
||||
}
|
||||
|
||||
this.HadInput = false;
|
||||
this.HadInput &= ~InputSetters.Normal;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private byte IsInputAfkDetour() {
|
||||
if (!this.Plugin.Config.MessagesCountAsInput || this.HadInput == InputSetters.None) {
|
||||
return this._isInputAfkHook!.Original();
|
||||
}
|
||||
|
||||
this.HadInput &= ~InputSetters.Afk;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -226,7 +254,7 @@ namespace XIVChatPlugin {
|
|||
return;
|
||||
}
|
||||
|
||||
this.HadInput = true;
|
||||
this.HadInput = InputSetters.Normal | InputSetters.Afk;
|
||||
|
||||
var uiModule = this._getUiModule(Marshal.ReadIntPtr(this.UiModulePtr));
|
||||
|
||||
|
@ -351,6 +379,7 @@ namespace XIVChatPlugin {
|
|||
this._receiveChunkHook?.Dispose();
|
||||
this._chatChannelChangeHook?.Dispose();
|
||||
this._isInputHook?.Dispose();
|
||||
this._isInputAfkHook?.Dispose();
|
||||
|
||||
if (this._emptyXivString != IntPtr.Zero) {
|
||||
this._xivStringDtor?.Invoke(this._emptyXivString);
|
||||
|
|
Loading…
Reference in New Issue