mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Update GetResourceSync and GetResourceAsync function signatures for testing, including unused stack parameters.
This commit is contained in:
parent
5e9c7f7eac
commit
d903f1b8c3
1 changed files with 15 additions and 14 deletions
|
|
@ -44,7 +44,7 @@ public unsafe class ResourceService : IDisposable, IRequiredService
|
|||
{
|
||||
var hash = path.Crc32;
|
||||
return GetResourceHandler(true, (ResourceManager*)_resourceManager.ResourceManagerAddress,
|
||||
&category, &type, &hash, path.Path, null, false);
|
||||
&category, &type, &hash, path.Path, null, 0, 0, 0);
|
||||
}
|
||||
|
||||
public SafeResourceHandle GetSafeResource(ResourceCategory category, ResourceType type, CiByteString path)
|
||||
|
|
@ -76,10 +76,10 @@ public unsafe class ResourceService : IDisposable, IRequiredService
|
|||
public event GetResourcePreDelegate? ResourceRequested;
|
||||
|
||||
private delegate ResourceHandle* GetResourceSyncPrototype(ResourceManager* resourceManager, ResourceCategory* pCategoryId,
|
||||
ResourceType* pResourceType, int* pResourceHash, byte* pPath, GetResourceParameters* pGetResParams);
|
||||
ResourceType* pResourceType, int* pResourceHash, byte* pPath, GetResourceParameters* pGetResParams, nint unk7, uint unk8);
|
||||
|
||||
private delegate ResourceHandle* GetResourceAsyncPrototype(ResourceManager* resourceManager, ResourceCategory* pCategoryId,
|
||||
ResourceType* pResourceType, int* pResourceHash, byte* pPath, GetResourceParameters* pGetResParams, bool isUnknown);
|
||||
ResourceType* pResourceType, int* pResourceHash, byte* pPath, GetResourceParameters* pGetResParams, byte isUnknown, nint unk8, uint unk9);
|
||||
|
||||
[Signature(Sigs.GetResourceSync, DetourName = nameof(GetResourceSyncDetour))]
|
||||
private readonly Hook<GetResourceSyncPrototype> _getResourceSyncHook = null!;
|
||||
|
|
@ -88,27 +88,28 @@ public unsafe class ResourceService : IDisposable, IRequiredService
|
|||
private readonly Hook<GetResourceAsyncPrototype> _getResourceAsyncHook = null!;
|
||||
|
||||
private ResourceHandle* GetResourceSyncDetour(ResourceManager* resourceManager, ResourceCategory* categoryId, ResourceType* resourceType,
|
||||
int* resourceHash, byte* path, GetResourceParameters* pGetResParams)
|
||||
=> GetResourceHandler(true, resourceManager, categoryId, resourceType, resourceHash, path, pGetResParams, false);
|
||||
int* resourceHash, byte* path, GetResourceParameters* pGetResParams, nint unk8, uint unk9)
|
||||
=> GetResourceHandler(true, resourceManager, categoryId, resourceType, resourceHash, path, pGetResParams, 0, unk8, unk9);
|
||||
|
||||
private ResourceHandle* GetResourceAsyncDetour(ResourceManager* resourceManager, ResourceCategory* categoryId, ResourceType* resourceType,
|
||||
int* resourceHash, byte* path, GetResourceParameters* pGetResParams, bool isUnk)
|
||||
=> GetResourceHandler(false, resourceManager, categoryId, resourceType, resourceHash, path, pGetResParams, isUnk);
|
||||
int* resourceHash, byte* path, GetResourceParameters* pGetResParams, byte isUnk, nint unk8, uint unk9)
|
||||
=> GetResourceHandler(false, resourceManager, categoryId, resourceType, resourceHash, path, pGetResParams, isUnk, unk8, unk9);
|
||||
|
||||
/// <summary>
|
||||
/// Resources can be obtained synchronously and asynchronously. We need to change behaviour in both cases.
|
||||
/// Both work basically the same, so we can reduce the main work to one function used by both hooks.
|
||||
/// </summary>
|
||||
private ResourceHandle* GetResourceHandler(bool isSync, ResourceManager* resourceManager, ResourceCategory* categoryId,
|
||||
ResourceType* resourceType, int* resourceHash, byte* path, GetResourceParameters* pGetResParams, bool isUnk)
|
||||
ResourceType* resourceType, int* resourceHash, byte* path, GetResourceParameters* pGetResParams, byte isUnk, nint unk8, uint unk9)
|
||||
{
|
||||
using var performance = _performance.Measure(PerformanceType.GetResourceHandler);
|
||||
if (!Utf8GamePath.FromPointer(path, MetaDataComputation.CiCrc32, out var gamePath))
|
||||
{
|
||||
Penumbra.Log.Error("[ResourceService] Could not create GamePath from resource path.");
|
||||
return isSync
|
||||
? _getResourceSyncHook.Original(resourceManager, categoryId, resourceType, resourceHash, path, pGetResParams)
|
||||
: _getResourceAsyncHook.Original(resourceManager, categoryId, resourceType, resourceHash, path, pGetResParams, isUnk);
|
||||
? _getResourceSyncHook.Original(resourceManager, categoryId, resourceType, resourceHash, path, pGetResParams, unk8, unk9)
|
||||
: _getResourceAsyncHook.Original(resourceManager, categoryId, resourceType, resourceHash, path, pGetResParams, isUnk, unk8,
|
||||
unk9);
|
||||
}
|
||||
|
||||
ResourceHandle* returnValue = null;
|
||||
|
|
@ -117,17 +118,17 @@ public unsafe class ResourceService : IDisposable, IRequiredService
|
|||
if (returnValue != null)
|
||||
return returnValue;
|
||||
|
||||
return GetOriginalResource(isSync, *categoryId, *resourceType, *resourceHash, gamePath.Path, pGetResParams, isUnk);
|
||||
return GetOriginalResource(isSync, *categoryId, *resourceType, *resourceHash, gamePath.Path, pGetResParams, isUnk, unk8, unk9);
|
||||
}
|
||||
|
||||
/// <summary> Call the original GetResource function. </summary>
|
||||
public ResourceHandle* GetOriginalResource(bool sync, ResourceCategory categoryId, ResourceType type, int hash, CiByteString path,
|
||||
GetResourceParameters* resourceParameters = null, bool unk = false)
|
||||
GetResourceParameters* resourceParameters = null, byte unk = 0, nint unk8 = 0, uint unk9 = 0)
|
||||
=> sync
|
||||
? _getResourceSyncHook.OriginalDisposeSafe(_resourceManager.ResourceManager, &categoryId, &type, &hash, path.Path,
|
||||
resourceParameters)
|
||||
resourceParameters, unk8, unk9)
|
||||
: _getResourceAsyncHook.OriginalDisposeSafe(_resourceManager.ResourceManager, &categoryId, &type, &hash, path.Path,
|
||||
resourceParameters, unk);
|
||||
resourceParameters, unk, unk8, unk9);
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue