mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Fix data window hook
This commit is contained in:
parent
e641cac71c
commit
93ae7c9a66
1 changed files with 39 additions and 32 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
@ -71,8 +72,6 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
|
|
||||||
private UIDebug addonInspector = null;
|
private UIDebug addonInspector = null;
|
||||||
|
|
||||||
private delegate int MessageBoxWDelegate(IntPtr hWnd, string text, string caption, NativeFunctions.MessageBoxType type);
|
|
||||||
|
|
||||||
private Hook<MessageBoxWDelegate>? messageBoxMinHook;
|
private Hook<MessageBoxWDelegate>? messageBoxMinHook;
|
||||||
|
|
||||||
// IPC
|
// IPC
|
||||||
|
|
@ -123,6 +122,12 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
this.Load();
|
this.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private delegate int MessageBoxWDelegate(
|
||||||
|
IntPtr hWnd,
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string text,
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string caption,
|
||||||
|
NativeFunctions.MessageBoxType type);
|
||||||
|
|
||||||
private enum DataKind
|
private enum DataKind
|
||||||
{
|
{
|
||||||
Server_OpCode,
|
Server_OpCode,
|
||||||
|
|
@ -327,36 +332,7 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DataKind.Hook:
|
case DataKind.Hook:
|
||||||
{
|
this.DrawHook();
|
||||||
try
|
|
||||||
{
|
|
||||||
if (ImGui.Button("Create"))
|
|
||||||
{
|
|
||||||
this.messageBoxMinHook = Hook<MessageBoxWDelegate>.FromSymbol(
|
|
||||||
"User32", "MessageBoxW", MessageBoxWDetour);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.Button("Enable")) this.messageBoxMinHook?.Enable();
|
|
||||||
|
|
||||||
if (ImGui.Button("Disable")) this.messageBoxMinHook?.Disable();
|
|
||||||
|
|
||||||
if (ImGui.Button("Dispose"))
|
|
||||||
{
|
|
||||||
this.messageBoxMinHook?.Dispose();
|
|
||||||
this.messageBoxMinHook = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.Button("Test")) NativeFunctions.MessageBoxW(IntPtr.Zero, "Hi", "Hello", NativeFunctions.MessageBoxType.Ok);
|
|
||||||
|
|
||||||
if (this.messageBoxMinHook != null)
|
|
||||||
ImGui.Text("Enabled: " + this.messageBoxMinHook?.IsEnabled);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex, "MinHook error caught");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1609,6 +1585,37 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawHook()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ImGui.Button("Create"))
|
||||||
|
this.messageBoxMinHook = Hook<MessageBoxWDelegate>.FromSymbol("User32", "MessageBoxW", this.MessageBoxWDetour);
|
||||||
|
|
||||||
|
if (ImGui.Button("Enable"))
|
||||||
|
this.messageBoxMinHook?.Enable();
|
||||||
|
|
||||||
|
if (ImGui.Button("Disable"))
|
||||||
|
this.messageBoxMinHook?.Disable();
|
||||||
|
|
||||||
|
if (ImGui.Button("Dispose"))
|
||||||
|
{
|
||||||
|
this.messageBoxMinHook?.Dispose();
|
||||||
|
this.messageBoxMinHook = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.Button("Test"))
|
||||||
|
NativeFunctions.MessageBoxW(IntPtr.Zero, "Hi", "Hello", NativeFunctions.MessageBoxType.Ok);
|
||||||
|
|
||||||
|
if (this.messageBoxMinHook != null)
|
||||||
|
ImGui.Text("Enabled: " + this.messageBoxMinHook?.IsEnabled);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "MinHook error caught");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task TestTaskInTaskDelay()
|
private async Task TestTaskInTaskDelay()
|
||||||
{
|
{
|
||||||
await Task.Delay(5000);
|
await Task.Delay(5000);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue