mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add logging of destructed resource handles.
This commit is contained in:
parent
71a7520e58
commit
f00fe54bb3
4 changed files with 21 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Dalamud.Hooking;
|
||||||
using Dalamud.Logging;
|
using Dalamud.Logging;
|
||||||
using Dalamud.Utility.Signatures;
|
using Dalamud.Utility.Signatures;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.Resource;
|
using FFXIVClientStructs.FFXIV.Client.System.Resource;
|
||||||
|
|
@ -13,6 +14,23 @@ namespace Penumbra.Interop.Loader;
|
||||||
|
|
||||||
public unsafe partial class ResourceLoader
|
public unsafe partial class ResourceLoader
|
||||||
{
|
{
|
||||||
|
public delegate IntPtr ResourceHandleDestructor( ResourceHandle* handle );
|
||||||
|
|
||||||
|
[Signature( "48 89 5C 24 ?? 57 48 83 EC ?? 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 B8",
|
||||||
|
DetourName = nameof( ResourceHandleDestructorDetour ) )]
|
||||||
|
public static Hook< ResourceHandleDestructor >? ResourceHandleDestructorHook;
|
||||||
|
|
||||||
|
private IntPtr ResourceHandleDestructorDetour( ResourceHandle* handle )
|
||||||
|
{
|
||||||
|
if( handle != null )
|
||||||
|
{
|
||||||
|
PluginLog.Information( "[ResourceLoader] Destructing Resource Handle {Path:l} at 0x{Address:X} (Refcount {Refcount}) .", handle->FileName,
|
||||||
|
( ulong )handle, handle->RefCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResourceHandleDestructorHook!.Original( handle );
|
||||||
|
}
|
||||||
|
|
||||||
// A static pointer to the SE Resource Manager
|
// A static pointer to the SE Resource Manager
|
||||||
[Signature( "48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 32 C0", ScanType = ScanType.StaticAddress, UseFlags = SignatureUseFlags.Pointer )]
|
[Signature( "48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 32 C0", ScanType = ScanType.StaticAddress, UseFlags = SignatureUseFlags.Pointer )]
|
||||||
public static ResourceManager** ResourceManager;
|
public static ResourceManager** ResourceManager;
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,7 @@ public unsafe partial class ResourceLoader
|
||||||
ReadSqPackHook.Dispose();
|
ReadSqPackHook.Dispose();
|
||||||
GetResourceSyncHook.Dispose();
|
GetResourceSyncHook.Dispose();
|
||||||
GetResourceAsyncHook.Dispose();
|
GetResourceAsyncHook.Dispose();
|
||||||
|
ResourceHandleDestructorHook?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int ComputeHash( Utf8String path, GetResourceParameters* pGetResParams )
|
private int ComputeHash( Utf8String path, GetResourceParameters* pGetResParams )
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ public unsafe partial class ResourceLoader : IDisposable
|
||||||
ResourceRequested += LogPath;
|
ResourceRequested += LogPath;
|
||||||
ResourceLoaded += LogResource;
|
ResourceLoaded += LogResource;
|
||||||
FileLoaded += LogLoadedFile;
|
FileLoaded += LogLoadedFile;
|
||||||
|
ResourceHandleDestructorHook?.Enable();
|
||||||
EnableHooks();
|
EnableHooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,6 +45,7 @@ public unsafe partial class ResourceLoader : IDisposable
|
||||||
ResourceRequested -= LogPath;
|
ResourceRequested -= LogPath;
|
||||||
ResourceLoaded -= LogResource;
|
ResourceLoaded -= LogResource;
|
||||||
FileLoaded -= LogLoadedFile;
|
FileLoaded -= LogLoadedFile;
|
||||||
|
ResourceHandleDestructorHook?.Disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnableReplacements()
|
public void EnableReplacements()
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,6 @@ public partial class ConfigWindow
|
||||||
: newName.Any( c => ( symbol = c ) > ( char )0x7F )
|
: newName.Any( c => ( symbol = c ) > ( char )0x7F )
|
||||||
? ( $"Path contains invalid symbol {symbol}. Only ASCII is allowed.", false )
|
? ( $"Path contains invalid symbol {symbol}. Only ASCII is allowed.", false )
|
||||||
: ( $"Press Enter or Click Here to Save (Current Directory: {old})", true );
|
: ( $"Press Enter or Click Here to Save (Current Directory: {old})", true );
|
||||||
|
|
||||||
return ( ImGui.Button( text, w ) || saved ) && valid;
|
return ( ImGui.Button( text, w ) || saved ) && valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue