mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
fix: dodgy RTSS workaround
This commit is contained in:
parent
dbdd584d89
commit
2f88a4e0e6
2 changed files with 62 additions and 0 deletions
|
|
@ -1,7 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using CheapLoc;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.Internal.DXGI;
|
using Dalamud.Game.Internal.DXGI;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
|
|
@ -44,6 +49,9 @@ namespace Dalamud.Interface
|
||||||
private Dalamud dalamud;
|
private Dalamud dalamud;
|
||||||
private RawDX11Scene scene;
|
private RawDX11Scene scene;
|
||||||
|
|
||||||
|
private delegate void InstallRTSSHook();
|
||||||
|
private string rtssPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This event gets called by a plugin UiBuilder when read
|
/// This event gets called by a plugin UiBuilder when read
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -72,6 +80,23 @@ namespace Dalamud.Interface
|
||||||
Address = vtableResolver;
|
Address = vtableResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var rtss = NativeFunctions.GetModuleHandle("RTSSHooks64.dll");
|
||||||
|
|
||||||
|
if (rtss != IntPtr.Zero) {
|
||||||
|
var fileName = new StringBuilder(255);
|
||||||
|
NativeFunctions.GetModuleFileName(rtss, fileName, fileName.Capacity);
|
||||||
|
this.rtssPath = fileName.ToString();
|
||||||
|
Log.Verbose("RTSS at {0}", this.rtssPath);
|
||||||
|
|
||||||
|
if (!NativeFunctions.FreeLibrary(rtss))
|
||||||
|
throw new Win32Exception();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.Error(e, "RTSS Free failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var setCursorAddr = LocalHook.GetProcAddress("user32.dll", "SetCursor");
|
var setCursorAddr = LocalHook.GetProcAddress("user32.dll", "SetCursor");
|
||||||
|
|
||||||
Log.Verbose("===== S W A P C H A I N =====");
|
Log.Verbose("===== S W A P C H A I N =====");
|
||||||
|
|
@ -97,6 +122,18 @@ namespace Dalamud.Interface
|
||||||
this.setCursorHook.Enable();
|
this.setCursorHook.Enable();
|
||||||
this.presentHook.Enable();
|
this.presentHook.Enable();
|
||||||
this.resizeBuffersHook.Enable();
|
this.resizeBuffersHook.Enable();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!string.IsNullOrEmpty(this.rtssPath)) {
|
||||||
|
NativeFunctions.LoadLibrary(this.rtssPath);
|
||||||
|
|
||||||
|
var installAddr = LocalHook.GetProcAddress("RTSSHooks64.dll", "InstallRTSSHook");
|
||||||
|
var installDele = Marshal.GetDelegateForFunctionPointer<InstallRTSSHook>(installAddr);
|
||||||
|
installDele.Invoke();
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.Error(ex, "Could not reload RTSS");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Disable()
|
private void Disable()
|
||||||
|
|
|
||||||
|
|
@ -61,5 +61,30 @@ namespace Dalamud
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
|
public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool FreeLibrary(IntPtr hModule);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||||
|
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
[PreserveSig]
|
||||||
|
public static extern uint GetModuleFileName
|
||||||
|
(
|
||||||
|
[In]
|
||||||
|
IntPtr hModule,
|
||||||
|
|
||||||
|
[Out]
|
||||||
|
StringBuilder lpFilename,
|
||||||
|
|
||||||
|
[In]
|
||||||
|
[MarshalAs(UnmanagedType.U4)]
|
||||||
|
int nSize
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)]
|
||||||
|
public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)]string lpFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue