mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Provide actual hook names.
This commit is contained in:
parent
07382537a0
commit
cec28a1823
2 changed files with 16 additions and 16 deletions
|
|
@ -8,19 +8,19 @@ public sealed class PapHandler(PapRewriter.PapResourceHandlerPrototype papResour
|
|||
|
||||
public void Enable()
|
||||
{
|
||||
ReadOnlySpan<string> signatures =
|
||||
ReadOnlySpan<(string Sig, string Name)> signatures =
|
||||
[
|
||||
Sigs.LoadAlwaysResidentMotionPacks,
|
||||
Sigs.LoadWeaponDependentResidentMotionPacks,
|
||||
Sigs.LoadInitialResidentMotionPacks,
|
||||
Sigs.LoadMotionPacks,
|
||||
Sigs.LoadMotionPacks2,
|
||||
Sigs.LoadMigratoryMotionPack,
|
||||
(Sigs.LoadAlwaysResidentMotionPacks, nameof(Sigs.LoadAlwaysResidentMotionPacks)),
|
||||
(Sigs.LoadWeaponDependentResidentMotionPacks, nameof(Sigs.LoadWeaponDependentResidentMotionPacks)),
|
||||
(Sigs.LoadInitialResidentMotionPacks, nameof(Sigs.LoadInitialResidentMotionPacks)),
|
||||
(Sigs.LoadMotionPacks, nameof(Sigs.LoadMotionPacks)),
|
||||
(Sigs.LoadMotionPacks2, nameof(Sigs.LoadMotionPacks2)),
|
||||
(Sigs.LoadMigratoryMotionPack, nameof(Sigs.LoadMigratoryMotionPack)),
|
||||
];
|
||||
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
foreach (var sig in signatures)
|
||||
_papRewriter.Rewrite(sig);
|
||||
foreach (var (sig, name) in signatures)
|
||||
_papRewriter.Rewrite(sig, name);
|
||||
Penumbra.Log.Debug(
|
||||
$"[PapHandler] Rewrote {signatures.Length} .pap functions for inlined GetResourceAsync in {stopwatch.ElapsedMilliseconds} ms.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ public sealed class PapRewriter(PapRewriter.PapResourceHandlerPrototype papResou
|
|||
private readonly Dictionary<nint, AsmHook> _hooks = [];
|
||||
private readonly List<nint> _nativeAllocList = [];
|
||||
|
||||
public void Rewrite(string sig)
|
||||
public void Rewrite(string sig, string name)
|
||||
{
|
||||
if (!_scanner.TryScanText(sig, out var address))
|
||||
throw new Exception($"Signature [{sig}] could not be found.");
|
||||
throw new Exception($"Signature for {name} [{sig}] could not be found.");
|
||||
|
||||
var funcInstructions = _scanner.GetFunctionInstructions(address).ToArray();
|
||||
var hookPoints = ScanPapHookPoints(funcInstructions).ToList();
|
||||
|
|
@ -68,20 +68,20 @@ public sealed class PapRewriter(PapRewriter.PapResourceHandlerPrototype papResou
|
|||
|
||||
// Plop 'rax' (our return value, the path size) into r8, so it's the third argument for the subsequent Crc32() call
|
||||
"mov r8, rax",
|
||||
], "Pap Redirection"
|
||||
], $"{name}.PapRedirection"
|
||||
);
|
||||
|
||||
_hooks.Add(hookAddress, hook);
|
||||
hook.Enable();
|
||||
|
||||
// Now we're adjusting every single reference to the stack allocated 'path' to our substantially bigger 'stringLoc'
|
||||
UpdatePathAddresses(stackAccesses, stringAllocation);
|
||||
UpdatePathAddresses(stackAccesses, stringAllocation, name);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePathAddresses(IEnumerable<Instruction> stackAccesses, nint stringAllocation)
|
||||
private void UpdatePathAddresses(IEnumerable<Instruction> stackAccesses, nint stringAllocation, string name)
|
||||
{
|
||||
foreach (var stackAccess in stackAccesses)
|
||||
foreach (var (stackAccess, index) in stackAccesses.WithIndex())
|
||||
{
|
||||
var hookAddress = new IntPtr((long)stackAccess.IP + stackAccess.Length);
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ public sealed class PapRewriter(PapRewriter.PapResourceHandlerPrototype papResou
|
|||
[
|
||||
"use64",
|
||||
$"mov {targetRegister}, 0x{stringAllocation:x8}",
|
||||
], "Pap Stack Accesses"
|
||||
], $"{name}.PapStackAccess[{index}]"
|
||||
);
|
||||
|
||||
_hooks.Add(hookAddress, hook);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue