95 lines
2.7 KiB
C#
95 lines
2.7 KiB
C#
using Dalamud.Hooking;
|
|
using Dalamud.Utility.Signatures;
|
|
|
|
namespace Screenie;
|
|
|
|
internal unsafe class NoUi : IDisposable {
|
|
private delegate void TextureCreateDelegate(nint* a1, nint* a2);
|
|
private delegate nint TexturesCreateDelegate(nint a1);
|
|
private delegate nint TexturesRecreateDelegate(nint a1);
|
|
|
|
[Signature("40 55 53 57 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? B8", DetourName = nameof(TextureCreateDetour))]
|
|
private Hook<TextureCreateDelegate>? _textureCreateHook;
|
|
|
|
[Signature("40 55 53 56 57 41 55 48 8B EC 48 83 EC 60 48 8B 35", DetourName = nameof(TexturesCreateDetour))]
|
|
private Hook<TexturesCreateDelegate>? _texturesCreateHook;
|
|
|
|
[Signature("40 55 53 41 55 48 8B EC 48 83 EC 50", DetourName = nameof(TexturesRecreateDetour))]
|
|
private Hook<TexturesRecreateDelegate>? _texturesRecreateHook;
|
|
|
|
private Plugin Plugin { get; }
|
|
|
|
private bool _enabled;
|
|
|
|
private nint* _ffxivTexture = null;
|
|
private nint _ffxivRecreationStruct = 0;
|
|
private nint _ffxivCreationStruct = 0;
|
|
|
|
internal NoUi(Plugin plugin) {
|
|
this.Plugin = plugin;
|
|
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
|
|
|
|
if (
|
|
this._textureCreateHook == null
|
|
|| this._texturesCreateHook == null
|
|
|| this._texturesRecreateHook == null
|
|
) {
|
|
Plugin.Log.Warning("could not create texture hook(s), disabling noui");
|
|
return;
|
|
}
|
|
|
|
this._textureCreateHook.Enable();
|
|
this._texturesCreateHook.Enable();
|
|
this._texturesRecreateHook.Enable();
|
|
|
|
this._enabled = true;
|
|
}
|
|
|
|
public void Dispose() {
|
|
this._enabled = false;
|
|
|
|
this._texturesRecreateHook?.Dispose();
|
|
this._texturesCreateHook?.Dispose();
|
|
this._textureCreateHook?.Dispose();
|
|
}
|
|
|
|
private void TextureCreateDetour(nint* a1, nint* a2) {
|
|
Plugin.Log.Info(nameof(TextureCreateDetour));
|
|
this._ffxivTexture = a1;
|
|
|
|
this._textureCreateHook!.Original(a1, a2);
|
|
|
|
this._ffxivTexture = null;
|
|
}
|
|
|
|
private nint TexturesCreateDetour(nint a1) {
|
|
Plugin.Log.Info(nameof(TexturesCreateDetour));
|
|
this._ffxivCreationStruct = a1;
|
|
// ffxiv_current_creation_index = -1;
|
|
// ffxiv_created_resources.clear();
|
|
|
|
var ret = this._texturesCreateHook!.Original(a1);
|
|
|
|
this._ffxivCreationStruct = 0;
|
|
|
|
return ret;
|
|
}
|
|
|
|
private nint TexturesRecreateDetour(nint a1) {
|
|
Plugin.Log.Info(nameof(TexturesRecreateDetour));
|
|
this._ffxivRecreationStruct = a1;
|
|
|
|
var ret = this._texturesRecreateHook!.Original(a1);
|
|
|
|
this._ffxivRecreationStruct = 0;
|
|
|
|
return ret;
|
|
}
|
|
|
|
internal void GetNoUiBuffer() {
|
|
if (!this._enabled) {
|
|
return;
|
|
}
|
|
}
|
|
}
|