Merge branch 'master' into v9

This commit is contained in:
Ava Chaney 2023-05-29 17:48:39 -07:00
commit 1de8b6983d
6 changed files with 38 additions and 41 deletions

View file

@ -140,3 +140,8 @@ indent_style = space
indent_size = 4
tab_width = 4
dotnet_style_parentheses_in_other_operators=always_for_clarity:silent
[*.{yaml,yml}]
indent_style = space
indent_size = 2
tab_width = 2

View file

@ -1,5 +1,10 @@
name: Tag Build
on: [push]
on:
push:
branches:
- master
tags-ignore:
- '*' # don't needlessly execute on tags
jobs:
tag:

View file

@ -20,12 +20,12 @@ using Dalamud.Interface.Internal.ManagedAsserts;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.Style;
using Dalamud.Interface.Windowing;
using Dalamud.Logging.Internal;
using Dalamud.Utility;
using Dalamud.Utility.Timing;
using ImGuiNET;
using ImGuiScene;
using PInvoke;
using Serilog;
// general dev notes, here because it's easiest
@ -47,8 +47,6 @@ namespace Dalamud.Interface.Internal;
[ServiceManager.BlockingEarlyLoadedService]
internal class InterfaceManager : IDisposable, IServiceType
{
private static ModuleLog Log = new ModuleLog("IM");
private const float DefaultFontSizePt = 12.0f;
private const float DefaultFontSizePx = DefaultFontSizePt * 4.0f / 3.0f;
private const ushort Fallback1Codepoint = 0x3013; // Geta mark; FFXIV uses this to indicate that a glyph is missing.
@ -78,41 +76,16 @@ internal class InterfaceManager : IDisposable, IServiceType
private bool isOverrideGameCursor = true;
[ServiceManager.ServiceConstructor]
private InterfaceManager(SigScanner sigScanner)
private InterfaceManager()
{
Log.Verbose("ctor called");
this.dispatchMessageWHook = Hook<DispatchMessageWDelegate>.FromImport(
null, "user32.dll", "DispatchMessageW", 0, this.DispatchMessageWDetour);
this.setCursorHook = Hook<SetCursorDelegate>.FromImport(
null, "user32.dll", "SetCursor", 0, this.SetCursorDetour);
Log.Verbose("Import hooks applied");
this.fontBuildSignal = new ManualResetEvent(false);
this.address = new SwapChainVtableResolver();
this.address.Setup();
Log.Verbose("Resolver setup complete");
Log.Verbose("===== S W A P C H A I N =====");
Log.Verbose($"Is ReShade: {this.address.IsReshade}");
Log.Verbose($"Present address 0x{this.address.Present.ToInt64():X}");
Log.Verbose($"ResizeBuffers address 0x{this.address.ResizeBuffers.ToInt64():X}");
this.presentHook = Hook<PresentDelegate>.FromAddress(this.address.Present, this.PresentDetour);
this.resizeBuffersHook = Hook<ResizeBuffersDelegate>.FromAddress(this.address.ResizeBuffers, this.ResizeBuffersDetour);
Log.Verbose("Present and ResizeBuffers hooked");
var wndProcAddress = sigScanner.ScanText("E8 ?? ?? ?? ?? 80 7C 24 ?? ?? 74 ?? B8");
Log.Verbose($"WndProc address 0x{wndProcAddress.ToInt64():X}");
this.processMessageHook = Hook<ProcessMessageDelegate>.FromAddress(wndProcAddress, this.ProcessMessageDetour);
this.setCursorHook.Enable();
this.presentHook.Enable();
this.resizeBuffersHook.Enable();
this.dispatchMessageWHook.Enable();
this.processMessageHook.Enable();
Log.Verbose("Hooks enabled");
}
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
@ -1009,9 +982,10 @@ internal class InterfaceManager : IDisposable, IServiceType
}
[ServiceManager.CallWhenServicesReady]
private void ContinueConstruction()
private void ContinueConstruction(SigScanner sigScanner, Framework framework)
{
this.framework.RunOnFrameworkThread(() =>
this.address.Setup(sigScanner);
framework.RunOnFrameworkThread(() =>
{
while ((this.GameWindowHandle = NativeFunctions.FindWindowEx(IntPtr.Zero, this.GameWindowHandle, "FFXIVGAME", IntPtr.Zero)) != IntPtr.Zero)
{
@ -1030,6 +1004,23 @@ internal class InterfaceManager : IDisposable, IServiceType
{
Log.Error(ex, "Could not enable immersive mode");
}
this.presentHook = Hook<PresentDelegate>.FromAddress(this.address.Present, this.PresentDetour, true);
this.resizeBuffersHook = Hook<ResizeBuffersDelegate>.FromAddress(this.address.ResizeBuffers, this.ResizeBuffersDetour, true);
Log.Verbose("===== S W A P C H A I N =====");
Log.Verbose($"Present address 0x{this.presentHook!.Address.ToInt64():X}");
Log.Verbose($"ResizeBuffers address 0x{this.resizeBuffersHook!.Address.ToInt64():X}");
var wndProcAddress = sigScanner.ScanText("E8 ?? ?? ?? ?? 80 7C 24 ?? ?? 74 ?? B8");
Log.Verbose($"WndProc address 0x{wndProcAddress.ToInt64():X}");
this.processMessageHook = Hook<ProcessMessageDelegate>.FromAddress(wndProcAddress, this.ProcessMessageDetour);
this.setCursorHook.Enable();
this.presentHook.Enable();
this.resizeBuffersHook.Enable();
this.dispatchMessageWHook.Enable();
this.processMessageHook.Enable();
});
}

View file

@ -91,11 +91,7 @@ public class HappyEyeballsCallback : IDisposable
private async Task<NetworkStream> AttemptConnection(IPAddress address, int port, CancellationToken token, CancellationToken delayToken)
{
await AsyncUtils.CancellableDelay(-1, delayToken).ConfigureAwait(false);
if (token.IsCancellationRequested)
{
return Task.FromCanceled<NetworkStream>(token).Result;
}
token.ThrowIfCancellationRequested();
var socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
{
@ -116,9 +112,9 @@ public class HappyEyeballsCallback : IDisposable
private async Task<List<IPAddress>> GetSortedAddresses(string hostname, CancellationToken token)
{
// This method abuses DNS ordering and LINQ a bit. We can normally assume that "addresses" will be provided in
// This method abuses DNS ordering and LINQ a bit. We can normally assume that addresses will be provided in
// the order the system wants to use. GroupBy will return its groups *in the order they're discovered*. Meaning,
// the first group created will always be the "preferred" group, and all other groups are in preference order.
// the first group created will always be the preferred group, and all other groups are in preference order.
// This means a straight zipper merge is nice and clean and gives us most -> least preferred, repeating.
var dnsRecords = await Dns.GetHostAddressesAsync(hostname, this.forcedAddressFamily, token);

View file

@ -51,7 +51,7 @@ public static class AsyncUtils
{
try
{
await Task.Delay(millisecondsDelay, cancellationToken);
await Task.Delay(millisecondsDelay, cancellationToken).ConfigureAwait(false);
}
catch (TaskCanceledException)
{

@ -1 +1 @@
Subproject commit 5e9568845ac302540ce1135abbff7bef98314714
Subproject commit 7c59a83931338d7124d3fd75a2d7734dcc5dc2a1