From c663732a1ed224d7eda3d294ee153fa08289dbee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Andr=C3=A9?= Date: Wed, 12 Jul 2023 23:35:33 -0300 Subject: [PATCH] Fix ExHIBIT Auto-Install with newer games --- StringReloads/AutoInstall/ExHIBIT.cs | 37 ++++++++++++++++--- StringReloads/Hook/Base/Hook.cs | 3 ++ StringReloads/Hook/Others/ExHIBIT_Question.cs | 27 ++++++++++++++ StringReloads/Hook/Others/ExHIBIT_Say.cs | 4 +- StringReloads/Hook/Others/ExHIBIT_SayV2.cs | 26 +++++++++++++ StringReloads/Hook/Others/ExHIBIT_lstrcpyA.cs | 11 +++--- StringReloads/Hook/Types/Delegates.cs | 6 +++ 7 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 StringReloads/Hook/Others/ExHIBIT_Question.cs create mode 100644 StringReloads/Hook/Others/ExHIBIT_SayV2.cs diff --git a/StringReloads/AutoInstall/ExHIBIT.cs b/StringReloads/AutoInstall/ExHIBIT.cs index 8633914..5a7ea57 100644 --- a/StringReloads/AutoInstall/ExHIBIT.cs +++ b/StringReloads/AutoInstall/ExHIBIT.cs @@ -15,11 +15,31 @@ class ExHIBIT : IAutoInstall ExHIBIT_lstrcpyA lstrcpyAHook; ExHIBIT_Say10 Say10Hook; + ExHIBIT_Say11 Say12Hook; ExHIBIT_PrintSub3 PrintSub3Hook; + ExHIBIT_Question QuestionHook; public void Install() { - if (Say10Hook == null) - Say10Hook = new ExHIBIT_Say10(); + if (Say10Hook == null && Say12Hook == null) + { + try + { + Say10Hook = new ExHIBIT_Say10(); + } + catch + { + Say12Hook = new ExHIBIT_Say11(); + } + } + + if (QuestionHook == null) + { + try + { + QuestionHook = new ExHIBIT_Question(); + } + catch { } + } if (PrintSub3Hook == null) PrintSub3Hook = new ExHIBIT_PrintSub3(); @@ -30,9 +50,14 @@ public void Install() if (lstrcpyAHook == null) lstrcpyAHook = new ExHIBIT_lstrcpyA(Resident); - Say10Hook.Install(); + Say10Hook?.Install(); + Say12Hook?.Install(); PrintSub3Hook.Install(); - lstrcpyAHook.Install(); + + if (QuestionHook == null) + lstrcpyAHook.Install(); + else + QuestionHook.Install(); } public bool IsCompatible() @@ -51,7 +76,9 @@ public bool IsCompatible() public void Uninstall() { - Say10Hook.Uninstall(); + Say10Hook?.Uninstall(); + Say12Hook?.Uninstall(); + QuestionHook?.Uninstall(); PrintSub3Hook.Uninstall(); lstrcpyAHook.Uninstall(); } diff --git a/StringReloads/Hook/Base/Hook.cs b/StringReloads/Hook/Base/Hook.cs index 6be5ad9..216a2ea 100644 --- a/StringReloads/Hook/Base/Hook.cs +++ b/StringReloads/Hook/Base/Hook.cs @@ -95,6 +95,9 @@ public void Compile(bool ImportHook = false, IntPtr? TargetModule = null) else Function = GetProcAddress(hModule, Ordinal); + if (Function == null) + throw new Exception("Target Export Not Found"); + if (ImportHook) SetupImportHook(TargetModule == null ? Config.GameBaseAddress : TargetModule.Value.ToPointer()); else diff --git a/StringReloads/Hook/Others/ExHIBIT_Question.cs b/StringReloads/Hook/Others/ExHIBIT_Question.cs new file mode 100644 index 0000000..c29b4e6 --- /dev/null +++ b/StringReloads/Hook/Others/ExHIBIT_Question.cs @@ -0,0 +1,27 @@ +using StringReloads.Engine.String; +using StringReloads.Hook.Base; +using System; + +namespace StringReloads.Hook.Others +{ + unsafe class ExHIBIT_Question : Hook + { + public override string Library => "resident.dll"; + + public const string ExportName = "?prepareQuestion@RetouchSystem@@QAEXHPBD@Z"; + + public override string Export => ExportName; + + public override void Initialize() + { + HookDelegate = hExHIBIT_Question; + Compile(); + } + + private void hExHIBIT_Question(void* This, void* a1, void* Text) + { + Text = EntryPoint.SRL.ProcessString((CString)Text); + Bypass(This, a1, Text); + } + } +} diff --git a/StringReloads/Hook/Others/ExHIBIT_Say.cs b/StringReloads/Hook/Others/ExHIBIT_Say.cs index 9587eed..56d9a27 100644 --- a/StringReloads/Hook/Others/ExHIBIT_Say.cs +++ b/StringReloads/Hook/Others/ExHIBIT_Say.cs @@ -7,7 +7,9 @@ unsafe class ExHIBIT_Say10 : Hook { public override string Library => "resident.dll"; - public override string Export => "?say@RetouchAdvCharacter@@QAEXHPBD0_NHHHHPAVRetouchPrintParam@@K@Z"; + public const string ExportName ="?say@RetouchAdvCharacter@@QAEXHPBD0_NHHHHPAVRetouchPrintParam@@K@Z"; + + public override string Export => ExportName; public override void Initialize() { diff --git a/StringReloads/Hook/Others/ExHIBIT_SayV2.cs b/StringReloads/Hook/Others/ExHIBIT_SayV2.cs new file mode 100644 index 0000000..a072508 --- /dev/null +++ b/StringReloads/Hook/Others/ExHIBIT_SayV2.cs @@ -0,0 +1,26 @@ +using StringReloads.Engine.String; +using StringReloads.Hook.Base; + +namespace StringReloads.Hook.Others +{ + unsafe class ExHIBIT_Say11 : Hook + { + public override string Library => "resident.dll"; + + //?say@RetouchAdvCharacter@@QAEXHPBD0_NHHHHPAVRetouchPrintParam@@KPAVUxRuFukidashiData@@@Z + public const string ExportName = "?say@RetouchAdvCharacter@@QAEXHPBD0_NHHHHPAVRetouchPrintParam@@KPAVUxRuFukidashiData@@@Z"; + + public override string Export => ExportName; + + public override void Initialize() + { + HookDelegate = hExHIBIT_Say12; + Compile(); + } + + void hExHIBIT_Say12(void* This, void* a1, void* a2, byte* Text, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9, void* a10, void* a11) { + Text = EntryPoint.SRL.ProcessString((CString)Text); + Bypass(This, a1, a2, Text, a4, a5, a6, a7, a8, a9, a10, a11); + } + } +} diff --git a/StringReloads/Hook/Others/ExHIBIT_lstrcpyA.cs b/StringReloads/Hook/Others/ExHIBIT_lstrcpyA.cs index ed28892..8b2192b 100644 --- a/StringReloads/Hook/Others/ExHIBIT_lstrcpyA.cs +++ b/StringReloads/Hook/Others/ExHIBIT_lstrcpyA.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Text; +using Antlr.Runtime.Tree; using StringReloads.Engine.String; using StringReloads.Hook.Base; @@ -32,15 +33,15 @@ public override void Initialize() { } string Str = (CString)lpString2; - if (Minify(Str).Length == 0) + if (MinifiedCount(Str) == 0) return Bypass(lpString1, lpString2); lpString2 = EntryPoint.SRL.ProcessString((CString)lpString2); return Bypass(lpString1, lpString2); } - private string Minify(string Input) { - StringBuilder Builder = new StringBuilder(); + private int MinifiedCount(string Input) { + int Result = 0; foreach (var Char in Input) { if (Char >= '0' && Char <= '9') continue; @@ -48,9 +49,9 @@ private string Minify(string Input) { continue; if (Char == ';' || char.IsWhiteSpace(Char)) continue; - Builder.Append(Char); + Result++; } - return Builder.ToString().Replace("NULL", "").Trim(); + return Result; } } } diff --git a/StringReloads/Hook/Types/Delegates.cs b/StringReloads/Hook/Types/Delegates.cs index c6b5153..22d8c0f 100644 --- a/StringReloads/Hook/Types/Delegates.cs +++ b/StringReloads/Hook/Types/Delegates.cs @@ -56,6 +56,12 @@ namespace StringReloads.Hook [UnmanagedFunctionPointer(CallingConvention.ThisCall)] public unsafe delegate void ExHIBIT_Say10Delegate(void* This, void* a1, void* a2, byte* Text, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9, void* a10); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public unsafe delegate void ExHIBIT_Say11Delegate(void* This, void* a1, void* a2, byte* Text, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9, void* a10, void* a11); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public unsafe delegate void ExHIBIT_QuestionDelegate(void* This, void* a1, void* Text); [UnmanagedFunctionPointer(CallingConvention.ThisCall)] public unsafe delegate void ExHIBIT_PrintSub3Delegate(void* This, void* Text, void* a2, void* a3);