hacky (re|g)shade workaround

This commit is contained in:
goaaats 2021-10-08 02:48:26 +02:00
parent 80cb19d4d2
commit ef1a94adde
No known key found for this signature in database
GPG key ID: F18F057873895461
2 changed files with 53 additions and 2 deletions

View file

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Game.Internal.DXGI.Definitions;
@ -26,6 +28,11 @@ namespace Dalamud.Game.Internal.DXGI
/// <inheritdoc/>
public IntPtr ResizeBuffers { get; set; }
/// <summary>
/// Gets a value indicating whether or not ReShade is loaded/used.
/// </summary>
public bool IsReshade { get; private set; }
/// <inheritdoc/>
protected override unsafe void Setup64Bit(SigScanner sig)
{
@ -34,6 +41,32 @@ namespace Dalamud.Game.Internal.DXGI
var scVtbl = GetVTblAddresses(new IntPtr(kernelDev->SwapChain->DXGISwapChain), Enum.GetValues(typeof(IDXGISwapChainVtbl)).Length);
this.Present = scVtbl[(int)IDXGISwapChainVtbl.Present];
var modules = Process.GetCurrentProcess().Modules;
foreach (ProcessModule processModule in modules)
{
if (processModule.FileName != null && processModule.FileName.EndsWith("game\\dxgi.dll"))
{
// reshade master@4232872 RVA
// var p = processModule.BaseAddress + 0x82C7E0; // DXGISwapChain::Present
// var p = processModule.BaseAddress + 0x82FAC0; // DXGISwapChain::runtime_present
var scanner = new SigScanner(processModule);
try
{
var p = scanner.ScanText("F6 C2 01 0F 85 ?? ?? ?? ??");
Log.Information($"ReShade DLL: {processModule.FileName} with DXGISwapChain::runtime_present at {p:X}");
this.Present = p;
this.IsReshade = true;
}
catch (Exception ex)
{
Log.Error(ex, "Could not find reshade DXGISwapChain::runtime_present offset!");
}
}
}
this.ResizeBuffers = scVtbl[(int)IDXGISwapChainVtbl.ResizeBuffers];
}