mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
improve reshade no-addon support
This commit is contained in:
parent
43c14fa30b
commit
934fc6c948
1 changed files with 53 additions and 29 deletions
|
|
@ -58,7 +58,10 @@ internal class SwapChainVtableResolver : BaseAddressResolver, ISwapChainAddressR
|
||||||
var modules = Process.GetCurrentProcess().Modules;
|
var modules = Process.GetCurrentProcess().Modules;
|
||||||
foreach (ProcessModule processModule in modules)
|
foreach (ProcessModule processModule in modules)
|
||||||
{
|
{
|
||||||
if (processModule.FileName != null && processModule.FileName.EndsWith("game\\dxgi.dll"))
|
if (processModule.FileName == null || !processModule.FileName.EndsWith("game\\dxgi.dll"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var fileInfo = FileVersionInfo.GetVersionInfo(processModule.FileName);
|
var fileInfo = FileVersionInfo.GetVersionInfo(processModule.FileName);
|
||||||
|
|
||||||
|
|
@ -67,7 +70,7 @@ internal class SwapChainVtableResolver : BaseAddressResolver, ISwapChainAddressR
|
||||||
|
|
||||||
if (!fileInfo.FileDescription.Contains("GShade") && !fileInfo.FileDescription.Contains("ReShade"))
|
if (!fileInfo.FileDescription.Contains("GShade") && !fileInfo.FileDescription.Contains("ReShade"))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// warning: these comments may no longer be accurate.
|
// warning: these comments may no longer be accurate.
|
||||||
// reshade master@4232872 RVA
|
// reshade master@4232872 RVA
|
||||||
// var p = processModule.BaseAddress + 0x82C7E0; // DXGISwapChain::Present
|
// var p = processModule.BaseAddress + 0x82C7E0; // DXGISwapChain::Present
|
||||||
|
|
@ -77,47 +80,68 @@ internal class SwapChainVtableResolver : BaseAddressResolver, ISwapChainAddressR
|
||||||
// 6.0+ - F6 C2 01 0F 85 88
|
// 6.0+ - F6 C2 01 0F 85 88
|
||||||
|
|
||||||
var scanner = new SigScanner(processModule);
|
var scanner = new SigScanner(processModule);
|
||||||
var runtimePresentSig = "F6 C2 01 0F 85"; // NOTE: This sig is from reshade's DLL, normally dxgi.dll.
|
var reShadeDxgiPresent = IntPtr.Zero;
|
||||||
|
|
||||||
try
|
if (fileInfo.FileVersion?.StartsWith("6.") == true)
|
||||||
{
|
{
|
||||||
if (fileInfo.FileVersion.StartsWith("6."))
|
// No Addon
|
||||||
|
if (scanner.TryScanText("F6 C2 01 0F 85 A8", out reShadeDxgiPresent))
|
||||||
{
|
{
|
||||||
runtimePresentSig = "F6 C2 01 0F 85 88";
|
Log.Information("Hooking present for ReShade 6 No-Addon");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Addon
|
||||||
|
else if (scanner.TryScanText("F6 C2 01 0F 85 88", out reShadeDxgiPresent))
|
||||||
|
{
|
||||||
|
Log.Information("Hooking present for ReShade 6 Addon");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Error("Failed to get ReShade 6 DXGISwapChain::on_present offset!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex, "Failed to get reshade version info - falling back to 5.x signature");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
// Looks like this sig only works for GShade 4
|
||||||
|
if (reShadeDxgiPresent == IntPtr.Zero && fileInfo.FileDescription?.Contains("GShade 4.") == true)
|
||||||
{
|
{
|
||||||
// Looks like this sig only works for GShade 4
|
if (scanner.TryScanText("E8 ?? ?? ?? ?? 45 0F B6 5E ??", out reShadeDxgiPresent))
|
||||||
if (fileInfo.FileDescription?.Contains("GShade 4.") == true)
|
|
||||||
{
|
{
|
||||||
Log.Verbose("Hooking present for GShade 4");
|
Log.Information("Hooking present for GShade 4");
|
||||||
runtimePresentSig = "E8 ?? ?? ?? ?? 45 0F B6 5E ??";
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Error("Failed to find GShade 4 DXGISwapChain::on_present offset!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
if (reShadeDxgiPresent == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Log.Error(ex, "Failed to get reshade version info - falling back to default DXGISwapChain::on_present signature");
|
if (scanner.TryScanText("F6 C2 01 0F 85", out reShadeDxgiPresent))
|
||||||
|
{
|
||||||
|
Log.Information("Hooking present for ReShade with fallback 5.X sig");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Error("Failed to find ReShade DXGISwapChain::on_present offset with fallback sig!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
Log.Information("ReShade DLL: {FileName} ({Info} - {Version}) with DXGISwapChain::on_present at {Address}",
|
||||||
{
|
processModule.FileName,
|
||||||
var p = scanner.ScanText(runtimePresentSig);
|
fileInfo.FileDescription ?? "Unknown",
|
||||||
Log.Information($"ReShade DLL: {processModule.FileName} with DXGISwapChain::on_present at {p:X}");
|
fileInfo.FileVersion ?? "Unknown",
|
||||||
|
reShadeDxgiPresent.ToString("X"));
|
||||||
|
|
||||||
this.Present = p;
|
this.Present = reShadeDxgiPresent;
|
||||||
this.IsReshade = true;
|
this.IsReshade = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Error(ex, "Could not find reshade DXGISwapChain::on_present offset!");
|
Log.Error(e, "Failed to get ReShade version info");
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue