feat: port aelrynth 2026.9.27.2 snapshot onto GitHub history
Overlay upstream/main (9b5e276) onto BlankenshipG main without rewriting
history. Keep origin-only Decal/plugin/docs trees. Re-apply aelrynth.com
and sibling-fork URL fixes that aelrynth git still has as tombohar links.
Co-authored-by: BlankenshipG <BlankenshipG@users.noreply.github.com>
This commit is contained in:
parent
ac0d743e16
commit
4ddbb52eb2
244 changed files with 59710 additions and 3067 deletions
|
|
@ -10,12 +10,23 @@ internal static class SelectedTargetHooks
|
|||
{
|
||||
private const int SetSelectedObjectVa = 0x0058D110;
|
||||
private const int SelectedIdVa = 0x00871E54;
|
||||
private static readonly byte[] SetSelectedObjectSignature =
|
||||
|
||||
// Phase B: resolve s_selected_id's address by code-xref (ret; mov eax,[s_selected_id] =
|
||||
// C3 A1 <addr>), operand at offset 2; the VA stays as fallback. Resolved in Initialize.
|
||||
private static readonly byte?[] PatXrefSelectedId = [ 0xC3, 0xA1, null, null, null, null, 0x89, 0x87 ];
|
||||
private static int _selectedIdAddr = SelectedIdVa;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the AC client's currently-selected target id directly from the
|
||||
/// global. Used by PluginManager.DispatchLoginCompleteToLoadedPlugins to
|
||||
/// re-seed plugins with the live target after a deferred init (events
|
||||
/// fired before <c>_initialized=true</c> are dropped by the queue gate).
|
||||
/// </summary>
|
||||
public static uint ReadCurrentSelectedId() => ReadUInt32(_selectedIdAddr);
|
||||
// Verified unique + lands at 0x0058D110 offline (tools/pe_pattern.py).
|
||||
private static readonly byte?[] SetSelectedObjectPattern =
|
||||
[
|
||||
0x8B, 0x4C, 0x24, 0x08, 0x85, 0xC9, 0xA1, 0x54,
|
||||
0x1E, 0x87, 0x00, 0x56, 0x8B, 0x74, 0x24, 0x08,
|
||||
0x57, 0x8B, 0xF8, 0x75, 0x04, 0x3B, 0xC6, 0x74,
|
||||
0x7A, 0x85, 0xC0, 0x74, 0x14, 0x50, 0xE8
|
||||
0x8B, 0x4C, 0x24, 0x08, 0x85, 0xC9, 0xA1, 0x54
|
||||
];
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
|
|
@ -40,17 +51,19 @@ internal static class SelectedTargetHooks
|
|||
return;
|
||||
}
|
||||
|
||||
int funcOff = SetSelectedObjectVa - textSection.TextBaseVa;
|
||||
if (!PatternScanner.VerifyBytes(textSection.Bytes, funcOff, SetSelectedObjectSignature))
|
||||
HookResolver.ResolveResult resolved = HookResolver.Resolve(textSection, "SelectedTarget.SetSelectedObject", SetSelectedObjectPattern, SetSelectedObjectVa);
|
||||
if (!resolved.Success)
|
||||
{
|
||||
_statusMessage = $"ACCWeenieObject::SetSelectedObject signature mismatch @ 0x{SetSelectedObjectVa:X8}.";
|
||||
_statusMessage = $"ACCWeenieObject::SetSelectedObject unresolved (VA 0x{SetSelectedObjectVa:X8}).";
|
||||
RynthLog.Compat($"Compat: selected-target hook failed - {_statusMessage}");
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedIdAddr = HookResolver.ResolveData(textSection, "SelectedTarget.s_selected_id", PatXrefSelectedId, 2, SelectedIdVa).Address.ToInt32();
|
||||
|
||||
try
|
||||
{
|
||||
_targetAddress = new IntPtr(textSection.TextBaseVa + funcOff);
|
||||
_targetAddress = resolved.Address;
|
||||
_setSelectedObjectDetour = SetSelectedObjectDetour;
|
||||
IntPtr detourPtr = Marshal.GetFunctionPointerForDelegate(_setSelectedObjectDetour);
|
||||
_originalSetSelectedObject = Marshal.GetDelegateForFunctionPointer<SetSelectedObjectDelegate>(MinHook.HookCreate(_targetAddress, detourPtr));
|
||||
|
|
@ -59,7 +72,7 @@ internal static class SelectedTargetHooks
|
|||
|
||||
IsInstalled = true;
|
||||
_statusMessage = $"Hooked ACCWeenieObject::SetSelectedObject @ 0x{_targetAddress.ToInt32():X8}.";
|
||||
RynthLog.Verbose(
|
||||
RynthLog.Info(
|
||||
$"Compat: selected-target hook ready - SetSelectedObject=0x{_targetAddress.ToInt32():X8}, selectedId=0x{SelectedIdVa:X8}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -71,7 +84,7 @@ internal static class SelectedTargetHooks
|
|||
|
||||
private static void SetSelectedObjectDetour(uint selectedId, int reselect)
|
||||
{
|
||||
uint previousTargetId = ReadUInt32(SelectedIdVa);
|
||||
uint previousTargetId = ReadUInt32(_selectedIdAddr);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -83,13 +96,17 @@ internal static class SelectedTargetHooks
|
|||
throw;
|
||||
}
|
||||
|
||||
uint currentTargetId = ReadUInt32(SelectedIdVa);
|
||||
uint currentTargetId = ReadUInt32(_selectedIdAddr);
|
||||
if (currentTargetId == previousTargetId)
|
||||
return;
|
||||
|
||||
if (Interlocked.Increment(ref _detourLogCount) <= 5)
|
||||
RynthLog.Compat($"Compat: selected-target detour fired (#{_detourLogCount}) - prev=0x{previousTargetId:X8} curr=0x{currentTargetId:X8} reselect={reselect}");
|
||||
PluginManager.QueueSelectedTargetChange(currentTargetId, previousTargetId);
|
||||
}
|
||||
|
||||
private static int _detourLogCount;
|
||||
|
||||
private static uint ReadUInt32(int address)
|
||||
{
|
||||
return unchecked((uint)Marshal.ReadInt32(new IntPtr(address)));
|
||||
|
|
|
|||
Loading…
Reference in a new issue