From 994d592fa418a0f3829fed44e78415d364e5eaad Mon Sep 17 00:00:00 2001 From: Topaz Whitelock Date: Sun, 27 Feb 2022 11:41:20 +0300 Subject: [PATCH] Fix shortcut flickering. Should be handled with care, dnSpy is a bitch. --- KH2/Functions.cs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/KH2/Functions.cs b/KH2/Functions.cs index 0fddb5c..3b35596 100644 --- a/KH2/Functions.cs +++ b/KH2/Functions.cs @@ -11,6 +11,7 @@ using System.Text; using System.Linq; using System.Diagnostics; +using System.Collections.Generic; using System.Runtime.InteropServices; using DiscordRPC; @@ -391,21 +392,29 @@ public static void OverrideText() public static void OverrideShortcuts() { var _confirmRead = Hypervisor.Read(Variables.ConfirmAddress); - var _shortRead = Hypervisor.Read(Variables.ShortcutStartAddress); + Hypervisor.UnlockBlock(Variables.ShortcutStartAddress); - if (_confirmRead == 0x00 && _shortRead != 0x02BA) + if (_confirmRead == 0x00) { - Hypervisor.UnlockBlock(Variables.ShortcutStartAddress); - Hypervisor.Write(Variables.ShortcutStartAddress, 0x02BA); - Hypervisor.Write(Variables.ShortcutStartAddress + 0x06, 0x02AB); + var _shortRead = Hypervisor.Read(Variables.ShortcutStartAddress); + + if (_shortRead != 0x02BA) + { + Hypervisor.Write(Variables.ShortcutStartAddress, 0x02BA); + Hypervisor.Write(Variables.ShortcutStartAddress + 0x06, 0x02AB); + } } - else if (_confirmRead == 0x01 && _shortRead != 0x02AB) + else if (_confirmRead == 0x01) { - Hypervisor.UnlockBlock(Variables.ShortcutStartAddress); - Hypervisor.Write(Variables.ShortcutStartAddress, 0x02AB); - Hypervisor.Write(Variables.ShortcutStartAddress + 0x06, 0x02BA); + var _shortRead = Hypervisor.Read(Variables.ShortcutStartAddress); + + if (_shortRead != 0x02AB) + { + Hypervisor.Write(Variables.ShortcutStartAddress, 0x02AB); + Hypervisor.Write(Variables.ShortcutStartAddress + 0x06, 0x02BA); + } } }